Skip to content

Package: TemplateColorHexControlTester

TemplateColorHexControlTester

nameinstructionbranchcomplexitylinemethod
TemplateColorHexControlTester()
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: 46 C: 151
77%
M: 23 C: 25
52%
M: 23 C: 2
8%
M: 23 C: 33
59%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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.model.VTTemplatePackage;
23: import org.eclipse.emf.ecp.view.template.style.background.model.VTBackgroundPackage;
24: import org.eclipse.emf.ecp.view.template.style.fontProperties.model.VTFontPropertiesPackage;
25: import org.eclipse.emf.ecp.view.template.style.validation.model.VTValidationPackage;
26: import org.eclipse.emfforms.spi.common.report.ReportService;
27: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
28: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
29: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
30:
31: /**
32: * The tester for the
33: * {@link org.eclipse.emf.ecp.view.template.style.tableValidation.model.VTTableValidationStyleProperty#getImagePath()
34: * VTTableValidationStyleProperty#getImagePath()}.
35: *
36: * @author Eugen Neufeld
37: *
38: */
39: public class TemplateColorHexControlTester implements ECPRendererTester {
40:         // BEGIN COMPLEX CODE
41:         @Override
42:         public int isApplicable(VElement vElement, ViewModelContext viewModelContext) {
43:•                if (!VControl.class.isInstance(vElement)) {
44:                         return NOT_APPLICABLE;
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:•                if (VTFontPropertiesPackage.eINSTANCE.getFontPropertiesStyleProperty_ColorHEX().equals(feature)) {
60:                         return 5;
61:                 }
62:
63:                 // validationstyle
64:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_OkColorHEX().equals(feature)) {
65:                         return 5;
66:                 }
67:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_OkForegroundColorHEX().equals(feature)) {
68:                         return 5;
69:                 }
70:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_InfoColorHEX().equals(feature)) {
71:                         return 5;
72:                 }
73:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_InfoForegroundColorHEX().equals(feature)) {
74:                         return 5;
75:                 }
76:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_WarningColorHEX().equals(feature)) {
77:                         return 5;
78:                 }
79:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_WarningForegroundColorHEX().equals(feature)) {
80:                         return 5;
81:                 }
82:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_ErrorColorHEX().equals(feature)) {
83:                         return 5;
84:                 }
85:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_ErrorForegroundColorHEX().equals(feature)) {
86:                         return 5;
87:                 }
88:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_CancelColorHEX().equals(feature)) {
89:                         return 5;
90:                 }
91:•                if (VTValidationPackage.eINSTANCE.getValidationStyleProperty_CancelForegroundColorHEX().equals(feature)) {
92:                         return 5;
93:                 }
94:                 // template validation (Deprecated)
95:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_OkColorHEX().equals(feature)) {
96:                         return 5;
97:                 }
98:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_OkForegroundColorHEX().equals(feature)) {
99:                         return 5;
100:                 }
101:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_InfoColorHEX().equals(feature)) {
102:                         return 5;
103:                 }
104:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_InfoForegroundColorHEX().equals(feature)) {
105:                         return 5;
106:                 }
107:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_WarningColorHEX().equals(feature)) {
108:                         return 5;
109:                 }
110:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_WarningForegroundColorHEX().equals(feature)) {
111:                         return 5;
112:                 }
113:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_ErrorColorHEX().equals(feature)) {
114:                         return 5;
115:                 }
116:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_ErrorForegroundColorHEX().equals(feature)) {
117:                         return 5;
118:                 }
119:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_CancelColorHEX().equals(feature)) {
120:                         return 5;
121:                 }
122:•                if (VTTemplatePackage.eINSTANCE.getControlValidationTemplate_CancelForegroundColorHEX().equals(feature)) {
123:                         return 5;
124:                 }
125:                 // background
126:•                if (VTBackgroundPackage.eINSTANCE.getBackgroundStyleProperty_Color().equals(feature)) {
127:                         return 5;
128:                 }
129:
130:                 return NOT_APPLICABLE;
131:         }
132:         // END COMPLEX CODE
133: }