Skip to content

Package: AttributeValueControlTester

AttributeValueControlTester

nameinstructionbranchcomplexitylinemethod
AttributeValueControlTester()
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: 2 C: 48
96%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 13
93%
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.viewModelElement.model.VTViewModelElementPackage;
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: * The tester for the {@link ViewModelSelectControlSWTRenderer}.
30: *
31: * @author Eugen Neufeld
32: *
33: */
34: public class AttributeValueControlTester implements ECPRendererTester {
35:
36:         @Override
37:         public int isApplicable(VElement vElement, ViewModelContext viewModelContext) {
38:•                if (!VControl.class.isInstance(vElement)) {
39:                         return NOT_APPLICABLE;
40:                 }
41:                 final VControl control = (VControl) vElement;
42:•                if (control.getDomainModelReference() == null) {
43:                         return NOT_APPLICABLE;
44:                 }
45:                 IValueProperty valueProperty;
46:                 try {
47:                         valueProperty = viewModelContext.getService(EMFFormsDatabinding.class)
48:                                 .getValueProperty(control.getDomainModelReference(), viewModelContext.getDomainModel());
49:                 } catch (final DatabindingFailedException ex) {
50:                         viewModelContext.getService(ReportService.class).report(new DatabindingFailedReport(ex));
51:                         return NOT_APPLICABLE;
52:                 }
53:                 final EStructuralFeature feature = (EStructuralFeature) valueProperty.getValueType();
54:•                if (VTViewModelElementPackage.eINSTANCE.getViewModelElementSelector_AttributeValue().equals(feature)) {
55:                         return 5;
56:                 }
57:                 return NOT_APPLICABLE;
58:         }
59:
60: }