Skip to content

Package: DIViewSWTRendererService

DIViewSWTRendererService

nameinstructionbranchcomplexitylinemethod
DIViewSWTRendererService()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
activate(BundleContext)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
deactivate(BundleContext)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getRendererInstance(VView, ViewModelContext)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isApplicable(VElement, ViewModelContext)
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setEMFFormsLocaleProvider(EMFFormsLocaleProvider)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setReportService(ReportService)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
unsetEMFFormsLocaleProvider(EMFFormsLocaleProvider)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
unsetReportService(ReportService)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

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.emf.ecp.ui.view.swt.di.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.locale.EMFFormsLocaleProvider;
20: import org.eclipse.emfforms.spi.common.report.ReportService;
21: import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
22: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererFactory;
23: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService;
24: import org.osgi.framework.BundleContext;
25: import org.osgi.framework.ServiceReference;
26:
27: /**
28: * NumberControlSWTRendererService which provides the NumberControlSWTRenderer.
29: *
30: * @author Eugen Neufeld
31: *
32: */
33: public class DIViewSWTRendererService implements EMFFormsRendererService<VView> {
34:
35:         private EMFFormsRendererFactory rendererFactory;
36:         private ReportService reportService;
37:         private ServiceReference<EMFFormsRendererFactory> serviceReference;
38:         private EMFFormsLocaleProvider localeProvider;
39:
40:         /**
41:          * Activate ViewSWTRendererService.
42:          *
43:          * @param bundleContext The {@link BundleContext}
44:          */
45:         protected void activate(BundleContext bundleContext) {
46:                 serviceReference = bundleContext.getServiceReference(EMFFormsRendererFactory.class);
47:                 rendererFactory = bundleContext.getService(serviceReference);
48:         }
49:
50:         /**
51:          * Deactivate ViewSWTRendererService.
52:          *
53:          * @param bundleContext The {@link BundleContext}
54:          */
55:         protected void deactivate(BundleContext bundleContext) {
56:                 bundleContext.ungetService(serviceReference);
57:         }
58:
59:         /**
60:          * Called by the initializer to set the ReportService.
61:          *
62:          * @param reportService The ReportService
63:          */
64:         protected void setReportService(ReportService reportService) {
65:                 this.reportService = reportService;
66:         }
67:
68:         /**
69:          * Called by the initializer to unset the ReportService.
70:          *
71:          * @param reportService The ReportService
72:          */
73:         protected void unsetReportService(ReportService reportService) {
74:                 this.reportService = null;
75:         }
76:
77:         /**
78:          * Called by the initializer to set the EMFFormsLocaleProvider.
79:          *
80:          * @param localeProvider The EMFFormsLocaleProvider
81:          */
82:         protected void setEMFFormsLocaleProvider(EMFFormsLocaleProvider localeProvider) {
83:                 this.localeProvider = localeProvider;
84:         }
85:
86:         /**
87:          * Called by the initializer to unset the EMFFormsLocaleProvider.
88:          *
89:          * @param localeProvider The EMFFormsLocaleProvider
90:          */
91:         protected void unsetEMFFormsLocaleProvider(EMFFormsLocaleProvider localeProvider) {
92:                 this.localeProvider = null;
93:         }
94:
95:         /**
96:          * {@inheritDoc}
97:          *
98:          * @see org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService#isApplicable(VElement,ViewModelContext)
99:          */
100:         @Override
101:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
102:•                if (!VView.class.isInstance(vElement)) {
103:                         return NOT_APPLICABLE;
104:                 }
105:                 return 3d;
106:         }
107:
108:         /**
109:          * {@inheritDoc}
110:          *
111:          * @see org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService#getRendererInstance(org.eclipse.emf.ecp.view.spi.model.VElement,
112:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
113:          */
114:         @Override
115:         public AbstractSWTRenderer<VView> getRendererInstance(VView vElement, ViewModelContext viewModelContext) {
116:                 return new DIViewSWTRenderer(vElement, viewModelContext, reportService, rendererFactory, localeProvider);
117:         }
118:
119: }