Skip to content

Package: EMFFormsCategorizationElementRendererService

EMFFormsCategorizationElementRendererService

nameinstructionbranchcomplexitylinemethod
EMFFormsCategorizationElementRendererService()
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(VCategorizationElement, 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.VCategorizationElement;
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 VCategorizationElement}.
32: *
33: * @author Eugen Neufeld
34: */
35: @Component
36: public class EMFFormsCategorizationElementRendererService implements
37:         EMFFormsSpreadsheetRendererService<VCategorizationElement> {
38:
39:         private EMFFormsSpreadsheetRendererFactory emfformsSpreadsheetRendererFactory;
40:
41:         private ReportService reportService;
42:
43:         /**
44:          * The ReportService to use.
45:          *
46:          * @param reportService the reportService to set
47:          */
48:         @Reference(unbind = "-")
49:         protected void setReportService(ReportService reportService) {
50:                 this.reportService = reportService;
51:         }
52:
53:         private ServiceReference<EMFFormsSpreadsheetRendererFactory> serviceReference;
54:         private BundleContext bundleContext;
55:
56:         /**
57:          * The activate method.
58:          *
59:          * @param bundleContext The BundleContext
60:          */
61:         @Activate
62:         public void activate(BundleContext bundleContext) {
63:                 this.bundleContext = bundleContext;
64:
65:         }
66:
67:         /**
68:          * The deactivate method.
69:          *
70:          * @param bundleContext The BundleContext
71:          */
72:         @Deactivate
73:         public void deactivate(BundleContext bundleContext) {
74:•                if (serviceReference != null) {
75:                         bundleContext.ungetService(serviceReference);
76:                 }
77:         }
78:
79:         /**
80:          * Gets and returns the {@link EMFFormsSpreadsheetRendererFactory}.
81:          *
82:          * @return The {@link EMFFormsSpreadsheetRendererFactory}
83:          */
84:         protected EMFFormsSpreadsheetRendererFactory getSpreadsheetRendererFactory() {
85:•                if (emfformsSpreadsheetRendererFactory == null) {
86:                         serviceReference = bundleContext.getServiceReference(EMFFormsSpreadsheetRendererFactory.class);
87:                         emfformsSpreadsheetRendererFactory = bundleContext.getService(serviceReference);
88:                 }
89:                 return emfformsSpreadsheetRendererFactory;
90:         }
91:
92:         /**
93:          * {@inheritDoc}
94:          *
95:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService#isApplicable(VElement,ViewModelContext)
96:          */
97:         @Override
98:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
99:•                if (VCategorizationElement.class.isInstance(vElement)) {
100:                         return 1;
101:                 }
102:                 return NOT_APPLICABLE;
103:         }
104:
105:         /**
106:          * {@inheritDoc}
107:          *
108:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService#getRendererInstance(VElement,ViewModelContext)
109:          */
110:         @Override
111:         public EMFFormsAbstractSpreadsheetRenderer<VCategorizationElement> getRendererInstance(
112:                 VCategorizationElement vElement,
113:                 ViewModelContext viewModelContext) {
114:                 return new EMFFormsCategorizationElementRenderer(getSpreadsheetRendererFactory(), reportService);
115:         }
116:
117: }