Skip to content

Package: EEnumControl

EEnumControl

nameinstructionbranchcomplexitylinemethod
EEnumControl()
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%
bindValue()
M: 0 C: 25
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
fillControlComposite(Composite)
M: 0 C: 43
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
getControlsForTooltip()
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%
getUnsetButtonTooltip()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getUnsetLabelText()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setEditable(boolean)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
updateValidationColor(Color)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 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: *******************************************************************************/
15: package org.eclipse.emf.ecp.edit.internal.swt.controls;
16:
17: import org.eclipse.core.databinding.Binding;
18: import org.eclipse.core.databinding.observable.value.IObservableValue;
19: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
20: import org.eclipse.emf.edit.provider.IItemLabelProvider;
21: import org.eclipse.emfforms.spi.localization.LocalizationServiceHelper;
22: import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
23: import org.eclipse.jface.databinding.viewers.typed.ViewerProperties;
24: import org.eclipse.jface.viewers.ArrayContentProvider;
25: import org.eclipse.jface.viewers.ComboViewer;
26: import org.eclipse.jface.viewers.LabelProvider;
27: import org.eclipse.swt.graphics.Color;
28: import org.eclipse.swt.widgets.Composite;
29: import org.eclipse.swt.widgets.Control;
30:
31: /**
32: * This class defines a Control which is used for displaying {@link org.eclipse.emf.ecore.EStructuralFeature
33: * EStructuralFeature}s which have a enum
34: * value.
35: *
36: * @author Eugen Neufeld
37: *
38: */
39: @Deprecated
40: public class EEnumControl extends SingleControl {
41:
42:         private ComboViewer combo;
43:
44:         @Override
45:         protected void fillControlComposite(Composite composite) {
46:                 final Setting firstSetting = getFirstSetting();
47:                 final IItemLabelProvider labelProvider = getItemPropertyDescriptor(firstSetting).getLabelProvider(null);
48:
49:                 combo = new ComboViewer(composite);
50:                 combo.setContentProvider(new ArrayContentProvider());
51:                 combo.setLabelProvider(new LabelProvider() {
52:
53:                         @Override
54:                         public String getText(Object element) {
55:                                 return labelProvider.getText(element);
56:                         }
57:
58:                 });
59:                 combo.setInput(firstSetting.getEStructuralFeature().getEType().getInstanceClass().getEnumConstants());
60:                 combo.setData(CUSTOM_VARIANT, "org_eclipse_emf_ecp_control_enum"); //$NON-NLS-1$
61:         }
62:
63:         /**
64:          * {@inheritDoc}
65:          */
66:         @Override
67:         public void setEditable(boolean isEditable) {
68:                 combo.getControl().setEnabled(isEditable);
69:         }
70:
71:         @Override
72:         public Binding bindValue() {
73:                 final IObservableValue target = ViewerProperties.singleSelection().observe(combo);
74:                 final Binding bindValue = getDataBindingContext().bindValue(target, getModelValue());
75:                 getDataBindingContext().bindValue(WidgetProperties.tooltipText().observe(combo.getControl()), getModelValue());
76:                 return bindValue;
77:         }
78:
79:         /*
80:          * (non-Javadoc)
81:          * @see org.eclipse.emf.ecp.edit.internal.swt.controls.SingleControl#getUnsetLabelText()
82:          */
83:         @Override
84:         protected String getUnsetLabelText() {
85:                 return LocalizationServiceHelper.getString(getClass(),
86:                         DepricatedControlMessageKeys.EEnumControl_NoValueSetClickToSetValue);
87:         }
88:
89:         /*
90:          * (non-Javadoc)
91:          * @see org.eclipse.emf.ecp.edit.internal.swt.controls.SingleControl#getUnsetButtonTooltip()
92:          */
93:         @Override
94:         protected String getUnsetButtonTooltip() {
95:                 return LocalizationServiceHelper.getString(getClass(), DepricatedControlMessageKeys.EEnumControl_UnsetValue);
96:         }
97:
98:         /*
99:          * (non-Javadoc)
100:          * @see org.eclipse.emf.ecp.edit.internal.swt.util.SWTControl#getControlForTooltip()
101:          */
102:         @Override
103:         protected Control[] getControlsForTooltip() {
104:                 // return new Control[] { combo.getControl() };
105:                 return new Control[0];
106:         }
107:
108:         /**
109:          * {@inheritDoc}
110:          *
111:          * @see org.eclipse.emf.ecp.edit.internal.swt.controls.SingleControl#updateValidationColor(org.eclipse.swt.graphics.Color)
112:          */
113:         @Override
114:         protected void updateValidationColor(Color color) {
115:                 combo.getControl().setBackground(color);
116:         }
117:
118: }