blob: f2e2d453006fcf72807998dc571cebe16dc9f2e9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.views.properties.widgets;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.HierarchicToFlatContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.TreeToFlatContentProvider;
import org.eclipse.swt.widgets.Composite;
/**
* A PropertyEditor for editing enumerations through a ComboBox
*
* @see org.eclipse.papyrus.infra.widgets.editors.BooleanCheckbox
*
* @author Camille Letavernier
*/
public class EnumCombo extends AbstractPropertyEditor {
/**
* The EnumCombo widget
*/
protected org.eclipse.papyrus.infra.widgets.editors.EnumCombo enumCombo;
/**
* Constructor.
*
* @param parent
* The composite in which the widget will be displayed
* @param style
* The style for the widget
*/
public EnumCombo(Composite parent, int style) {
super(new org.eclipse.papyrus.infra.widgets.editors.EnumCombo(parent, style));
enumCombo = (org.eclipse.papyrus.infra.widgets.editors.EnumCombo) valueEditor;
}
/**
* @Problem : The different options come from input.
* When we don't have an input (e.g. : during preview),
* we don't have the different values, and we can't
* display the correct preview.
* @TODO : Retrieve the values from the DataContext if possible.
*/
@Override
protected void doBinding() {
IStaticContentProvider provider = input.getContentProvider(propertyPath);
if (provider instanceof IHierarchicContentProvider) {
provider = new HierarchicToFlatContentProvider((IHierarchicContentProvider) provider);
} else if (provider instanceof ITreeContentProvider) {
provider = new TreeToFlatContentProvider((ITreeContentProvider) provider);
}
enumCombo.setProviders(input.getContentProvider(propertyPath), input.getLabelProvider(propertyPath));
enumCombo.setUnsettable(!input.isMandatory(propertyPath));
super.doBinding();
}
}
|