Skip to content

Package: FeaturePathDMRSubMappedEClassReferenceTester

FeaturePathDMRSubMappedEClassReferenceTester

nameinstructionbranchcomplexitylinemethod
FeaturePathDMRSubMappedEClassReferenceTester()
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%
isApplicable(VElement, ViewModelContext)
M: 71 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 21 C: 0
0%
M: 1 C: 0
0%

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.mappingdmr.tooling;
15:
16: import org.eclipse.core.databinding.observable.IObserving;
17: import org.eclipse.core.databinding.observable.value.IObservableValue;
18: import org.eclipse.emf.ecore.EObject;
19: import org.eclipse.emf.ecore.EStructuralFeature;
20: import org.eclipse.emf.ecp.view.model.common.ECPRendererTester;
21: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
22: import org.eclipse.emf.ecp.view.spi.mappingdmr.model.VMappingDomainModelReference;
23: import org.eclipse.emf.ecp.view.spi.mappingdmr.model.VMappingdmrPackage;
24: import org.eclipse.emf.ecp.view.spi.model.VControl;
25: import org.eclipse.emf.ecp.view.spi.model.VElement;
26: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
27: import org.eclipse.emfforms.spi.common.report.ReportService;
28: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
29: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
30: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
31:
32: /**
33: * A Tester for the FeaturePathControl which is added as a child of a {@link VMappingDomainModelReference}.
34: *
35: * @author Eugen Neufeld
36: *
37: */
38: public class FeaturePathDMRSubMappedEClassReferenceTester implements
39:         ECPRendererTester {
40:
41:         @Override
42:         public int isApplicable(VElement vElement, ViewModelContext viewModelContext) {
43:
44:•                if (!VControl.class.isInstance(vElement)) {
45:                         return NOT_APPLICABLE;
46:                 }
47:
48:                 final VControl control = (VControl) vElement;
49:•                if (control.getDomainModelReference() == null) {
50:                         return NOT_APPLICABLE;
51:                 }
52:                 IObservableValue observableValue;
53:                 try {
54:                         observableValue = viewModelContext.getService(EMFFormsDatabinding.class)
55:                                 .getObservableValue(control.getDomainModelReference(), viewModelContext.getDomainModel());
56:                 } catch (final DatabindingFailedException ex) {
57:                         viewModelContext.getService(ReportService.class).report(new DatabindingFailedReport(ex));
58:                         return NOT_APPLICABLE;
59:                 }
60:                 final EStructuralFeature feature = (EStructuralFeature) observableValue.getValueType();
61:                 final EObject eObject = (EObject) ((IObserving) observableValue).getObserved();
62:                 observableValue.dispose();
63:
64:•                if (VMappingDomainModelReference.class.isInstance(eObject.eContainer())
65:•                        && VViewPackage.eINSTANCE
66:                                 .getFeaturePathDomainModelReference_DomainModelEFeature() == feature) {
67:                         return 6;
68:                 }
69:•                if (VMappingDomainModelReference.class.isInstance(eObject)
70:•                        && VMappingdmrPackage.eINSTANCE.getMappingDomainModelReference_DomainModelReference() == feature) {
71:                         return 6;
72:                 }
73:
74:                 return NOT_APPLICABLE;
75:         }
76: }