1 package be
.nikiroo
.utils
.ui
;
3 import javax
.swing
.JComboBox
;
4 import javax
.swing
.JComponent
;
6 import be
.nikiroo
.utils
.resources
.MetaInfo
;
8 public class ConfigItemCombobox
<E
extends Enum
<E
>> extends ConfigItem
<E
> {
9 private static final long serialVersionUID
= 1L;
11 private boolean editable
;
14 * Create a new {@link ConfigItemCombobox} for the given {@link MetaInfo}.
17 * the {@link MetaInfo}
19 * allows the user to type in another value not in the list
21 public ConfigItemCombobox(MetaInfo
<E
> info
, boolean editable
) {
23 this.editable
= editable
;
27 protected Object
getFromField(int item
) {
28 // rawtypes for Java 1.6 (and 1.7 ?) support
29 @SuppressWarnings("rawtypes")
30 JComboBox field
= (JComboBox
) getField(item
);
32 return field
.getSelectedItem();
39 protected Object
getFromInfo(int item
) {
40 return info
.getString(item
, false);
44 protected void setToField(Object value
, int item
) {
45 // rawtypes for Java 1.6 (and 1.7 ?) support
46 @SuppressWarnings("rawtypes")
47 JComboBox field
= (JComboBox
) getField(item
);
49 field
.setSelectedItem(value
);
54 protected void setToInfo(Object value
, int item
) {
55 info
.setString((String
) value
, item
);
58 // rawtypes for Java 1.6 (and 1.7 ?) support
59 @SuppressWarnings({ "unchecked", "rawtypes" })
61 protected JComponent
createField(int item
) {
62 JComboBox field
= new JComboBox(info
.getAllowedValues());
63 field
.setEditable(editable
);