Skip to content

Package: SingleControl

SingleControl

nameinstructionbranchcomplexitylinemethod
SingleControl()
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%
addControlDecoration(Control)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
dispose()
M: 6 C: 9
60%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 2 C: 4
67%
M: 0 C: 1
100%
handleValidation(Diagnostic)
M: 74 C: 0
0%
M: 14 C: 0
0%
M: 8 C: 0
0%
M: 17 C: 0
0%
M: 1 C: 0
0%
resetValidation()
M: 25 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
showLabel()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
updateValidationColor(Color)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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.edit.internal.swt.controls;
15:
16: import org.eclipse.emf.common.util.Diagnostic;
17: import org.eclipse.emf.ecp.edit.internal.swt.util.SWTControl;
18: import org.eclipse.jface.fieldassist.ControlDecoration;
19: import org.eclipse.swt.graphics.Color;
20: import org.eclipse.swt.graphics.Image;
21: import org.eclipse.swt.widgets.Control;
22:
23: /**
24: * This class defines a SingleControl which is used for displaying {@link org.eclipse.emf.ecore.EStructuralFeature
25: * EStructuralFeature}s which have maximum 1
26: * value.
27: *
28: * @author Eugen Neufeld
29: *
30: */
31: @Deprecated
32: public abstract class SingleControl extends SWTControl {
33:
34:         // private static final String VALIDATION_ERROR_ICON = "icons/validation_error.png";//$NON-NLS-1$
35:         private ControlDecoration controlDecoration;
36:
37:         // private static final Color VALIDATION_ERROR_BACKGROUND_COLOR=new Color(Display.getDefault(), 255, 140, 0);
38:
39:         /**
40:          * {@inheritDoc}
41:          *
42:          * @deprecated
43:          */
44:         @Deprecated
45:         @Override
46:         public void handleValidation(Diagnostic diagnostic) {
47:•                if (diagnostic.getData().size() < 2) {
48:                         return;
49:                 }
50:•                if (!diagnostic.getData().get(0).equals(getFirstSetting().getEObject())
51:•                        || !diagnostic.getData().get(1).equals(getFirstStructuralFeature())) {
52:                         return;
53:                 }
54:
55:                 final Image image = getValidationIcon(diagnostic.getSeverity());
56:                 Diagnostic reason = diagnostic;
57:•                if (diagnostic.getChildren() != null && diagnostic.getChildren().size() != 0) {
58:                         reason = diagnostic.getChildren().get(0);
59:                 }
60:•                if (validationLabel != null) {
61:                         validationLabel.setImage(image);
62:                         validationLabel.setToolTipText(reason.getMessage());
63:
64:                 }
65:•                if (controlDecoration != null) {
66:                         controlDecoration.setDescriptionText(reason.getMessage());
67:                         controlDecoration.show();
68:                 }
69:                 updateValidationColor(getValidationBackgroundColor(diagnostic.getSeverity()));
70:         }
71:
72:         /**
73:          * Allows controls to supply a second visual effect for controls on validation. The color to set is provided as the
74:          * parameter.
75:          *
76:          * @param color the color to set, null if the default background color should be set
77:          */
78:         protected void updateValidationColor(Color color) {
79:
80:         }
81:
82:         protected void addControlDecoration(Control control) {
83:                 // controlDecoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT);
84:                 // final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
85:                 // FieldDecorationRegistry.DEC_ERROR);
86:                 // controlDecoration.setImage(fieldDecoration.getImage());
87:                 // controlDecoration.hide();
88:         }
89:
90:         /**
91:          * {@inheritDoc}
92:          *
93:          * @deprecated
94:          */
95:         @Deprecated
96:         @Override
97:         public void resetValidation() {
98:•                if (getControl() == null) {
99:                         return;
100:                 }
101:                 updateValidationColor(null);
102:•                if (validationLabel != null) {
103:                         validationLabel.setImage(null);
104:                         validationLabel.setToolTipText(""); //$NON-NLS-1$
105:                 }
106:•                if (controlDecoration != null) {
107:                         controlDecoration.hide();
108:                 }
109:         }
110:
111:         /**
112:          * {@inheritDoc}
113:          */
114:         @Override
115:         public void dispose() {
116:                 super.dispose();
117:•                if (validationLabel != null) {
118:                         validationLabel.dispose();
119:                 }
120:•                if (controlDecoration != null) {
121:                         controlDecoration.dispose();
122:                 }
123:         }
124:
125:         /**
126:          * {@inheritDoc}
127:          *
128:          * @deprecated
129:          */
130:         @Override
131:         @Deprecated
132:         public boolean showLabel() {
133:                 return true;
134:         }
135: }