Skip to content

Package: ColumnEnablementConfigurationDMRRendererService

ColumnEnablementConfigurationDMRRendererService

nameinstructionbranchcomplexitylinemethod
ColumnEnablementConfigurationDMRRendererService()
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: 2 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: 7 C: 37
84%
M: 3 C: 5
63%
M: 2 C: 3
60%
M: 3 C: 12
80%
M: 0 C: 1
100%
setEMFFormsDatabindingEMF(EMFFormsDatabindingEMF)
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) 2017 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: * Edgar Mueller - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.editor.controls;
15:
16: import org.eclipse.emf.databinding.IEMFValueProperty;
17: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
18: import org.eclipse.emf.ecp.view.spi.model.VControl;
19: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
20: import org.eclipse.emf.ecp.view.spi.model.VElement;
21: import org.eclipse.emf.ecp.view.spi.table.model.VEnablementConfiguration;
22: import org.eclipse.emf.ecp.view.spi.table.model.VTablePackage;
23: import org.eclipse.emfforms.spi.common.report.AbstractReport;
24: import org.eclipse.emfforms.spi.common.report.ReportService;
25: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
26: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
27: import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
28: import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService;
29: import org.osgi.service.component.annotations.Component;
30: import org.osgi.service.component.annotations.Reference;
31: import org.osgi.service.component.annotations.ReferenceCardinality;
32:
33: /**
34: * {@link EMFFormsDIRendererService} for configuring the enabled state of column.
35: *
36: * @author Edgar Mueller
37: *
38: */
39: @Component(name = "ColumnEnablementConfigurationDMRRendererService", service = EMFFormsDIRendererService.class)
40: public class ColumnEnablementConfigurationDMRRendererService implements EMFFormsDIRendererService<VControl> {
41:
42:         private EMFFormsDatabindingEMF databinding;
43:         private ReportService reportService;
44:
45:         /**
46:          * @param databinding {@link EMFFormsDatabindingEMF}
47:          */
48:         @Reference(cardinality = ReferenceCardinality.MANDATORY, unbind = "-")
49:         public void setEMFFormsDatabindingEMF(EMFFormsDatabindingEMF databinding) {
50:                 this.databinding = databinding;
51:         }
52:
53:         /**
54:          * @param reportService {@link ReportService}
55:          */
56:         @Reference(cardinality = ReferenceCardinality.MANDATORY, unbind = "-")
57:         public void setreportService(ReportService reportService) {
58:                 this.reportService = reportService;
59:         }
60:
61:         @Override
62:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
63:•                if (!VControl.class.isInstance(vElement)) {
64:                         return NOT_APPLICABLE;
65:                 }
66:                 final VDomainModelReference domainModelReference = VControl.class.cast(vElement).getDomainModelReference();
67:•                if (domainModelReference == null) {
68:                         return NOT_APPLICABLE;
69:                 }
70:                 try {
71:                         final IEMFValueProperty valueProperty = databinding.getValueProperty(
72:                                 domainModelReference,
73:                                 viewModelContext.getDomainModel());
74:
75:•                        if (viewModelContext.getDomainModel() instanceof VEnablementConfiguration
76:•                                && valueProperty.getStructuralFeature() == VTablePackage.eINSTANCE
77:                                         .getSingleColumnConfiguration_ColumnDomainReference()) {
78:                                 return 3d;
79:                         }
80:                 } catch (final DatabindingFailedException ex) {
81:                         reportService.report(new AbstractReport(ex));
82:                 }
83:
84:                 return NOT_APPLICABLE;
85:         }
86:
87:         @Override
88:         public Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
89:                 return ColumnEnablementConfigurationDMRRenderer.class;
90:         }
91:
92: }