3780a7e21058a1c9a80475ce8932112aa350e039
1 package be
.nikiroo
.utils
.ui
;
3 import java
.awt
.BorderLayout
;
5 import javax
.swing
.JCheckBox
;
6 import javax
.swing
.JLabel
;
7 import javax
.swing
.JPanel
;
8 import javax
.swing
.JTextField
;
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 \""
43 + "\", we consider it is FALSE");
47 field
.setSelected(state
);
49 info
.addReloadedListener(new Runnable() {
52 Boolean state
= info
.getBoolean();
54 info
.getDefaultBoolean();
60 field
.setSelected(state
);
63 info
.addSaveListener(new Runnable() {
66 info
.setBoolean(field
.isSelected());
70 this.add(new JLabel(info
.getName() + ": "), BorderLayout
.WEST
);
71 this.add(field
, BorderLayout
.CENTER
);
73 final JTextField field
= new JTextField();
74 field
.setToolTipText(info
.getDescription());
75 field
.setText(info
.getString());
77 info
.addReloadedListener(new Runnable() {
80 field
.setText(info
.getString());
83 info
.addSaveListener(new Runnable() {
86 info
.setString(field
.getText());
90 this.add(new JLabel(info
.getName() + ": "), BorderLayout
.WEST
);
91 this.add(field
, BorderLayout
.CENTER
);