1 package be
.nikiroo
.utils
.ui
;
3 import javax
.swing
.JComboBox
;
4 import javax
.swing
.JComponent
;
6 import be
.nikiroo
.utils
.resources
.MetaInfo
;
8 class ConfigItemCombobox
<E
extends Enum
<E
>> extends ConfigItem
<E
> {
9 private static final long serialVersionUID
= 1L;
11 private boolean editable
;
12 private String
[] allowedValues
;
15 * Create a new {@link ConfigItemCombobox} for the given {@link MetaInfo}.
18 * the {@link MetaInfo}
20 * allows the user to type in another value not in the list
22 public ConfigItemCombobox(MetaInfo
<E
> info
, boolean editable
) {
24 this.editable
= editable
;
25 this.allowedValues
= info
.getAllowedValues();
29 protected Object
getFromField(int item
) {
30 // rawtypes for Java 1.6 (and 1.7 ?) support
31 @SuppressWarnings("rawtypes")
32 JComboBox field
= (JComboBox
) getField(item
);
34 return field
.getSelectedItem();
41 protected Object
getFromInfo(int item
) {
42 return getInfo().getString(item
, false);
46 protected void setToField(Object value
, int item
) {
47 // rawtypes for Java 1.6 (and 1.7 ?) support
48 @SuppressWarnings("rawtypes")
49 JComboBox field
= (JComboBox
) getField(item
);
51 field
.setSelectedItem(value
);
56 protected void setToInfo(Object value
, int item
) {
57 getInfo().setString((String
) value
, item
);
60 // rawtypes for Java 1.6 (and 1.7 ?) support
61 @SuppressWarnings({ "unchecked", "rawtypes" })
63 protected JComponent
createEmptyField(int item
) {
64 JComboBox field
= new JComboBox(allowedValues
);
65 field
.setEditable(editable
);