Skip to content

Package: DMRSelectorControlTester

DMRSelectorControlTester

nameinstructionbranchcomplexitylinemethod
DMRSelectorControlTester()
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%
isApplicable(VElement, ViewModelContext)
M: 6 C: 48
89%
M: 3 C: 5
63%
M: 3 C: 2
40%
M: 3 C: 14
82%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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.view.template.internal.tooling.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.model.common.ECPRendererTester;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
20: import org.eclipse.emf.ecp.view.spi.model.VControl;
21: import org.eclipse.emf.ecp.view.spi.model.VElement;
22: import org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.VTDomainmodelreferencePackage;
23: import org.eclipse.emfforms.spi.common.report.ReportService;
24: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
25: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
26: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
27: import org.eclipse.emfforms.spi.ide.view.segments.ToolingModeUtil;
28:
29: /**
30: * The tester for the {@link ViewModelSelectControlSWTRenderer}.
31: *
32: * @author Eugen Neufeld
33: *
34: */
35: public class DMRSelectorControlTester implements ECPRendererTester {
36:
37:         @Override
38:         public int isApplicable(VElement vElement, ViewModelContext viewModelContext) {
39:•                if (ToolingModeUtil.isSegmentToolingEnabled()) {
40:                         return NOT_APPLICABLE;
41:                 }
42:•                if (!VControl.class.isInstance(vElement)) {
43:                         return NOT_APPLICABLE;
44:                 }
45:                 final VControl control = (VControl) vElement;
46:•                if (control.getDomainModelReference() == null) {
47:                         return NOT_APPLICABLE;
48:                 }
49:                 IValueProperty valueProperty;
50:                 try {
51:                         valueProperty = viewModelContext.getService(EMFFormsDatabinding.class)
52:                                 .getValueProperty(control.getDomainModelReference(), viewModelContext.getDomainModel());
53:                 } catch (final DatabindingFailedException ex) {
54:                         viewModelContext.getService(ReportService.class).report(new DatabindingFailedReport(ex));
55:                         return NOT_APPLICABLE;
56:                 }
57:                 final EStructuralFeature feature = (EStructuralFeature) valueProperty.getValueType();
58:                 if (VTDomainmodelreferencePackage.eINSTANCE.getDomainModelReferenceSelector_DomainModelReference().equals(
59:•                        feature)) {
60:                         return 5;
61:                 }
62:                 return NOT_APPLICABLE;
63:         }
64:
65: }