Skip to content

Package: LinkFeatureControlRendererService

LinkFeatureControlRendererService

nameinstructionbranchcomplexitylinemethod
LinkFeatureControlRendererService()
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%
getRendererClass()
M: 0 C: 2
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: 45
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
setEMFFormsDatabinding(EMFFormsDatabinding)
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%
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-2016 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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.editor.controls;
15:
16: import org.eclipse.core.databinding.property.value.IValueProperty;
17: import org.eclipse.emf.ecore.EStructuralFeature;
18: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
19: import org.eclipse.emf.ecp.view.spi.model.VControl;
20: import org.eclipse.emf.ecp.view.spi.model.VElement;
21: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
22: import org.eclipse.emfforms.spi.common.report.ReportService;
23: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
24: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
25: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
26: import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
27: import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService;
28: import org.osgi.service.component.annotations.Component;
29: import org.osgi.service.component.annotations.Reference;
30:
31: /**
32: * DI renderer service for {@link LinkFeatureControlRenderer}.
33: *
34: * @author Lucas Koehler
35: *
36: */
37: @Component(name = "LinkFeatureControlRendererService")
38: public class LinkFeatureControlRendererService implements EMFFormsDIRendererService<VControl> {
39:
40:         private EMFFormsDatabinding databindingService;
41:         private ReportService reportService;
42:
43:         /**
44:          * Called by the framework to set the {@link EMFFormsDatabinding}.
45:          *
46:          * @param databindingService The {@link EMFFormsDatabinding}
47:          */
48:         @Reference(unbind = "-")
49:         protected void setEMFFormsDatabinding(EMFFormsDatabinding databindingService) {
50:                 this.databindingService = databindingService;
51:         }
52:
53:         /**
54:          * Called by the framework to set the {@link ReportService}.
55:          *
56:          * @param reportService The {@link ReportService}
57:          */
58:         @Reference(unbind = "-")
59:         protected void setReportService(ReportService reportService) {
60:                 this.reportService = reportService;
61:         }
62:
63:         /**
64:          * {@inheritDoc}
65:          *
66:          * @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#isApplicable(org.eclipse.emf.ecp.view.spi.model.VElement,
67:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
68:          */
69:         @Override
70:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
71:•                if (!VControl.class.isInstance(vElement)) {
72:                         return NOT_APPLICABLE;
73:                 }
74:                 final VControl control = (VControl) vElement;
75:•                if (control.getDomainModelReference() == null) {
76:                         return NOT_APPLICABLE;
77:                 }
78:                 IValueProperty valueProperty;
79:                 try {
80:                         valueProperty = databindingService.getValueProperty(control.getDomainModelReference(),
81:                                 viewModelContext.getDomainModel());
82:                 } catch (final DatabindingFailedException ex) {
83:                         reportService.report(new DatabindingFailedReport(ex));
84:                         return NOT_APPLICABLE;
85:                 }
86:                 final EStructuralFeature feature = (EStructuralFeature) valueProperty.getValueType();
87:•                if (VViewPackage.eINSTANCE.getFeaturePathDomainModelReference_DomainModelEFeature() == feature) {
88:                         return 6d;
89:                 }
90:
91:                 return NOT_APPLICABLE;
92:         }
93:
94:         /**
95:          * {@inheritDoc}
96:          *
97:          * @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#getRendererClass()
98:          */
99:         @Override
100:         public Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
101:                 return LinkFeatureControlRenderer.class;
102:         }
103:
104: }