Skip to content

Package: ReadOnlyConfigurationSWTRendererService

ReadOnlyConfigurationSWTRendererService

nameinstructionbranchcomplexitylinemethod
ReadOnlyConfigurationSWTRendererService()
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: 6 C: 37
86%
M: 3 C: 5
63%
M: 2 C: 3
60%
M: 3 C: 11
79%
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) 2011-2019 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.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.VReadOnlyColumnConfiguration;
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: * Renderer service for {@link ReadOnlyConfigurationSWTRenderer}.
35: *
36: * @author Lucas Koehler
37: *
38: */
39: @Component(name = "ReadOnlyConfigurationSWTRendererService")
40: public class ReadOnlyConfigurationSWTRendererService 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, viewModelContext.getDomainModel());
73:•                        if (viewModelContext.getDomainModel() instanceof VReadOnlyColumnConfiguration
74:•                                && valueProperty
75:                                         .getStructuralFeature() == VTablePackage.Literals.READ_ONLY_COLUMN_CONFIGURATION__COLUMN_DOMAIN_REFERENCES) {
76:                                 return 10d;
77:                         }
78:                 } catch (final DatabindingFailedException ex) {
79:                         reportService.report(new AbstractReport(ex));
80:                 }
81:
82:                 return NOT_APPLICABLE;
83:         }
84:
85:         @Override
86:         public Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
87:                 return ReadOnlyConfigurationSWTRenderer.class;
88:         }
89:
90: }