Skip to content

Package: FeaturePathDMRReferenceTester

FeaturePathDMRReferenceTester

nameinstructionbranchcomplexitylinemethod
FeaturePathDMRReferenceTester()
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: 55 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 16 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.keyattributedmr.tooling;
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.keyattributedmr.model.VKeyattributedmrPackage;
21: import org.eclipse.emf.ecp.view.spi.model.VControl;
22: import org.eclipse.emf.ecp.view.spi.model.VElement;
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:
28: /**
29: * A Tester for the FeaturePathControl which is added as a child of a
30: * {@link org.eclipse.emf.ecp.view.spi.keyattributedmr.model.VKeyAttributeDomainModelReference
31: * VKeyAttributeDomainModelReference}.
32: *
33: * @author Eugen Neufeld
34: *
35: */
36: public class FeaturePathDMRReferenceTester implements
37:         ECPRendererTester {
38:
39:         @Override
40:         public int isApplicable(VElement vElement, ViewModelContext viewModelContext) {
41:
42:•                if (!VControl.class.isInstance(vElement)) {
43:                         return NOT_APPLICABLE;
44:                 }
45:
46:                 final VControl control = (VControl) vElement;
47:•                if (control.getDomainModelReference() == null) {
48:                         return NOT_APPLICABLE;
49:                 }
50:                 IValueProperty valueProperty;
51:                 try {
52:                         valueProperty = viewModelContext.getService(EMFFormsDatabinding.class)
53:                                 .getValueProperty(control.getDomainModelReference(), viewModelContext.getDomainModel());
54:                 } catch (final DatabindingFailedException ex) {
55:                         viewModelContext.getService(ReportService.class).report(new DatabindingFailedReport(ex));
56:                         return NOT_APPLICABLE;
57:                 }
58:                 final EStructuralFeature feature = (EStructuralFeature) valueProperty.getValueType();
59:
60:•                if (VKeyattributedmrPackage.eINSTANCE.getKeyAttributeDomainModelReference_KeyDMR() == feature) {
61:                         return 6;
62:                 }
63:•                if (VKeyattributedmrPackage.eINSTANCE.getKeyAttributeDomainModelReference_ValueDMR() == feature) {
64:                         return 6;
65:                 }
66:
67:                 return NOT_APPLICABLE;
68:         }
69: }