1 package be
.nikiroo
.utils
.ui
;
3 import java
.awt
.BorderLayout
;
5 import javax
.swing
.JCheckBox
;
6 import javax
.swing
.JPanel
;
7 import javax
.swing
.JTextField
;
8 import javax
.swing
.border
.EmptyBorder
;
10 import be
.nikiroo
.utils
.resources
.Bundle
;
11 import be
.nikiroo
.utils
.resources
.Meta
.Format
;
12 import be
.nikiroo
.utils
.resources
.MetaInfo
;
15 * A graphical item that reflect a configuration option from the given
21 * the type of {@link Bundle} to edit
23 public class ConfigItem
<E
extends Enum
<E
>> extends JPanel
{
24 private static final long serialVersionUID
= 1L;
26 public ConfigItem(final MetaInfo
<E
> info
) {
27 this.setLayout(new BorderLayout());
28 this.setBorder(new EmptyBorder(2, 10, 2, 10));
30 if (info
.getFormat() == Format
.BOOLEAN
) {
31 final JCheckBox field
= new JCheckBox();
32 field
.setToolTipText(info
.getDescription());
33 Boolean state
= info
.getBoolean();
35 info
.getDefaultBoolean();
41 .println("No default value given for BOOLEAN parameter "
42 + info
.getName() + ", we consider it is FALSE");
46 field
.setSelected(state
);
48 info
.addReloadListener(new Runnable() {
51 field
.setText(info
.getString());
55 this.add(field
, BorderLayout
.CENTER
);
57 final JTextField field
= new JTextField();
58 field
.setToolTipText(info
.getDescription());
59 field
.setText(info
.getString());
61 info
.addReloadListener(new Runnable() {
64 field
.setText(info
.getString());
68 this.add(field
, BorderLayout
.CENTER
);