Skip to content

Package: EMFFormsCategorizationRendererService

EMFFormsCategorizationRendererService

nameinstructionbranchcomplexitylinemethod
EMFFormsCategorizationRendererService()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
activate(BundleContext)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
deactivate(BundleContext)
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getRendererInstance(VCategorization, ViewModelContext)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSpreadsheetRendererFactory()
M: 0 C: 20
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
isApplicable(VElement, ViewModelContext)
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setReportService(ReportService)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.spreadsheet.core.renderer.categorization;
15:
16: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorization;
17: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
18: import org.eclipse.emf.ecp.view.spi.model.VElement;
19: import org.eclipse.emfforms.spi.common.report.ReportService;
20: import org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsAbstractSpreadsheetRenderer;
21: import org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererFactory;
22: import org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService;
23: import org.osgi.framework.BundleContext;
24: import org.osgi.framework.ServiceReference;
25: import org.osgi.service.component.annotations.Activate;
26: import org.osgi.service.component.annotations.Component;
27: import org.osgi.service.component.annotations.Deactivate;
28: import org.osgi.service.component.annotations.Reference;
29:
30: /**
31: * The {@link EMFFormsSpreadsheetRendererService} for {@link VCategorization}.
32: *
33: * @author Eugen Neufeld
34: */
35: @Component
36: public class EMFFormsCategorizationRendererService implements EMFFormsSpreadsheetRendererService<VCategorization> {
37:
38:         private EMFFormsSpreadsheetRendererFactory emfformsSpreadsheetRendererFactory;
39:
40:         private ReportService reportService;
41:
42:         /**
43:          * The ReportService to use.
44:          *
45:          * @param reportService the reportService to set
46:          */
47:         @Reference(unbind = "-")
48:         protected void setReportService(ReportService reportService) {
49:                 this.reportService = reportService;
50:         }
51:
52:         private ServiceReference<EMFFormsSpreadsheetRendererFactory> serviceReference;
53:         private BundleContext bundleContext;
54:
55:         /**
56:          * The activate method.
57:          *
58:          * @param bundleContext The BundleContext
59:          */
60:         @Activate
61:         public void activate(BundleContext bundleContext) {
62:                 this.bundleContext = bundleContext;
63:
64:         }
65:
66:         /**
67:          * The deactivate method.
68:          *
69:          * @param bundleContext The BundleContext
70:          */
71:         @Deactivate
72:         public void deactivate(BundleContext bundleContext) {
73:•                if (serviceReference != null) {
74:                         bundleContext.ungetService(serviceReference);
75:                 }
76:         }
77:
78:         /**
79:          * Gets and returns the {@link EMFFormsSpreadsheetRendererFactory}.
80:          *
81:          * @return The {@link EMFFormsSpreadsheetRendererFactory}
82:          */
83:         protected EMFFormsSpreadsheetRendererFactory getSpreadsheetRendererFactory() {
84:•                if (emfformsSpreadsheetRendererFactory == null) {
85:                         serviceReference = bundleContext.getServiceReference(EMFFormsSpreadsheetRendererFactory.class);
86:                         emfformsSpreadsheetRendererFactory = bundleContext.getService(serviceReference);
87:                 }
88:                 return emfformsSpreadsheetRendererFactory;
89:         }
90:
91:         /**
92:          * {@inheritDoc}
93:          *
94:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService#isApplicable(VElement,ViewModelContext)
95:          */
96:         @Override
97:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
98:•                if (VCategorization.class.isInstance(vElement)) {
99:                         return 1;
100:                 }
101:                 return NOT_APPLICABLE;
102:         }
103:
104:         /**
105:          * {@inheritDoc}
106:          *
107:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService#getRendererInstance(VElement,ViewModelContext)
108:          */
109:         @Override
110:         public EMFFormsAbstractSpreadsheetRenderer<VCategorization> getRendererInstance(VCategorization vElement,
111:                 ViewModelContext viewModelContext) {
112:                 return new EMFFormsCategorizationRenderer(getSpreadsheetRendererFactory(), reportService);
113:         }
114:
115: }