Skip to content

Package: EMFFormsSpreadsheetViewRendererService

EMFFormsSpreadsheetViewRendererService

nameinstructionbranchcomplexitylinemethod
EMFFormsSpreadsheetViewRendererService()
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: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getFactory()
M: 0 C: 20
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
getRendererInstance(VView, 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%
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;
15:
16: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
17: import org.eclipse.emf.ecp.view.spi.model.VElement;
18: import org.eclipse.emf.ecp.view.spi.model.VView;
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 VView}.
32: *
33: * @author Eugen Neufeld
34: */
35: @Component
36: public class EMFFormsSpreadsheetViewRendererService implements
37:         EMFFormsSpreadsheetRendererService<VView> {
38:
39:         private EMFFormsSpreadsheetRendererFactory emfformsSpreadsheetRendererFactory;
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:          * The deactivate method.
67:          *
68:          * @param bundleContext The BundleContext
69:          */
70:         @Deactivate
71:         public void deactivate(BundleContext bundleContext) {
72:                 bundleContext.ungetService(serviceReference);
73:         }
74:
75:         /**
76:          * {@inheritDoc}
77:          *
78:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService#isApplicable(org.eclipse.emf.ecp.view.spi.model.VElement,
79:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
80:          */
81:         @Override
82:         public double isApplicable(VElement vElement,
83:                 ViewModelContext viewModelContext) {
84:•                if (VView.class.isInstance(vElement)) {
85:                         return 1;
86:                 }
87:                 return NOT_APPLICABLE;
88:         }
89:
90:         private EMFFormsSpreadsheetRendererFactory getFactory() {
91:•                if (emfformsSpreadsheetRendererFactory == null) {
92:                         serviceReference = bundleContext
93:                                 .getServiceReference(EMFFormsSpreadsheetRendererFactory.class);
94:                         emfformsSpreadsheetRendererFactory = bundleContext
95:                                 .getService(serviceReference);
96:                 }
97:                 return emfformsSpreadsheetRendererFactory;
98:         }
99:
100:         /**
101:          * {@inheritDoc}
102:          *
103:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetRendererService#getRendererInstance(org.eclipse.emf.ecp.view.spi.model.VElement,
104:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
105:          */
106:         @Override
107:         public EMFFormsAbstractSpreadsheetRenderer<VView> getRendererInstance(
108:                 VView vElement, ViewModelContext viewModelContext) {
109:                 return new EMFFormsSpreadsheetViewRenderer(getFactory(), reportService);
110:         }
111:
112: }