Lines 12-23
Link Here
|
12 |
|
12 |
|
13 |
import org.eclipse.jface.viewers.CellEditor; |
13 |
import org.eclipse.jface.viewers.CellEditor; |
14 |
import org.eclipse.jface.viewers.ComboBoxCellEditor; |
14 |
import org.eclipse.jface.viewers.ComboBoxCellEditor; |
|
|
15 |
import org.eclipse.jface.viewers.ILabelProvider; |
16 |
|
15 |
import org.eclipse.swt.SWT; |
17 |
import org.eclipse.swt.SWT; |
16 |
import org.eclipse.swt.widgets.Composite; |
18 |
import org.eclipse.swt.widgets.Composite; |
17 |
|
19 |
|
18 |
/** |
20 |
/** |
19 |
* Descriptor for a property that has a value which should be edited |
21 |
* Descriptor for a property that has a value which should be edited |
20 |
* with a combo box cell editor. |
22 |
* with a combo box cell editor. This class provides a default |
|
|
23 |
* <code>ILabelProvider</code> that will render the label of the given |
24 |
* descriptor as the <code>String</code> found in the value array at the |
25 |
* currently selected index. |
21 |
* <p> |
26 |
* <p> |
22 |
* This class may be instantiated; it is not intended to be subclassed. |
27 |
* This class may be instantiated; it is not intended to be subclassed. |
23 |
* </p> |
28 |
* </p> |
Lines 35-64
Link Here
|
35 |
* The list of possible values to display in the combo box |
40 |
* The list of possible values to display in the combo box |
36 |
*/ |
41 |
*/ |
37 |
private String[] values; |
42 |
private String[] values; |
38 |
/** |
43 |
|
39 |
* Creates an property descriptor with the given id, display name, and list |
44 |
/** |
40 |
* of value labels to display in the combo box cell editor. |
45 |
* Creates an property descriptor with the given id, display name, and list |
41 |
* |
46 |
* of value labels to display in the combo box cell editor. |
42 |
* @param id the id of the property |
47 |
* |
43 |
* @param displayName the name to display for the property |
48 |
* @param id the id of the property |
44 |
* @param valuesArray the list of possible values to display in the combo box |
49 |
* @param displayName the name to display for the property |
45 |
*/ |
50 |
* @param valuesArray the list of possible values to display in the combo box |
46 |
public ComboBoxPropertyDescriptor(Object id, String displayName, String[] valuesArray) { |
51 |
*/ |
47 |
super(id, displayName); |
52 |
public ComboBoxPropertyDescriptor(Object id, String displayName, String[] valuesArray) { |
48 |
values = valuesArray; |
53 |
super(id, displayName); |
49 |
} |
54 |
values = valuesArray; |
50 |
/** |
55 |
} |
51 |
* The <code>ComboBoxPropertyDescriptor</code> implementation of this |
56 |
|
52 |
* <code>IPropertyDescriptor</code> method creates and returns a new |
57 |
/** |
53 |
* <code>ComboBoxCellEditor</code>. |
58 |
* The <code>ComboBoxPropertyDescriptor</code> implementation of this |
54 |
* <p> |
59 |
* <code>IPropertyDescriptor</code> method creates and returns a new |
55 |
* The editor is configured with the current validator if there is one. |
60 |
* <code>ComboBoxCellEditor</code>. |
56 |
* </p> |
61 |
* <p> |
57 |
*/ |
62 |
* The editor is configured with the current validator if there is one. |
58 |
public CellEditor createPropertyEditor(Composite parent) { |
63 |
* </p> |
59 |
CellEditor editor = new ComboBoxCellEditor(parent, values, SWT.READ_ONLY); |
64 |
*/ |
60 |
if (getValidator() != null) |
65 |
public CellEditor createPropertyEditor(Composite parent) { |
61 |
editor.setValidator(getValidator()); |
66 |
CellEditor editor = new ComboBoxCellEditor(parent, values, SWT.READ_ONLY); |
62 |
return editor; |
67 |
if (getValidator() != null) |
63 |
} |
68 |
editor.setValidator(getValidator()); |
|
|
69 |
return editor; |
70 |
} |
71 |
|
72 |
/** |
73 |
* The <code>ComboBoxPropertyDescriptor</code> implementation of this |
74 |
* <code>IPropertyDescriptor</code> method returns the value set by |
75 |
* the <code>setProvider</code> method or, if no value has been set |
76 |
* it returns a <code>ComboBoxLabelProvider</code> created from the |
77 |
* valuesArray of this <code>ComboBoxPropertyDescriptor</code>. |
78 |
* |
79 |
* @see #setLabelProvider |
80 |
*/ |
81 |
public ILabelProvider getLabelProvider() { |
82 |
if (isLabelProviderSet()) |
83 |
return super.getLabelProvider(); |
84 |
else |
85 |
return new ComboBoxLabelProvider(values); |
86 |
} |
64 |
} |
87 |
} |