fix ConfigItems, especially regarding items
authorNiki Roo <niki@nikiroo.be>
Sat, 1 Jun 2019 08:57:13 +0000 (10:57 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 1 Jun 2019 08:57:13 +0000 (10:57 +0200)
src/be/nikiroo/utils/ui/ConfigEditor.java
src/be/nikiroo/utils/ui/ConfigItem.java
src/be/nikiroo/utils/ui/ConfigItemBoolean.java
src/be/nikiroo/utils/ui/ConfigItemBrowse.java
src/be/nikiroo/utils/ui/ConfigItemColor.java
src/be/nikiroo/utils/ui/ConfigItemCombobox.java
src/be/nikiroo/utils/ui/ConfigItemInteger.java
src/be/nikiroo/utils/ui/ConfigItemLocale.java
src/be/nikiroo/utils/ui/ConfigItemPassword.java
src/be/nikiroo/utils/ui/ConfigItemString.java

index 27e517b88c04e17ee929aaef7f5c21a3e6490ebb..c687c98fee5637dfb8e10b7bad32f6be102ef9d5 100644 (file)
@@ -139,7 +139,7 @@ public class ConfigEditor<E extends Enum<E>> extends JPanel {
                        main.add(bpane);
                } else {
                        items.add(item);
-                       main.add(new ConfigItem<E>(item, nhgap));
+                       main.add(ConfigItem.createItem(item, nhgap));
                }
        }
 
index 045d83870213914a806e85609a6e60c9a05ba4de..46775e11ecd12e459d8777708fe6dfc535f0a0cd 100644 (file)
@@ -10,7 +10,9 @@ import java.awt.event.MouseEvent;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.swing.BoxLayout;
 import javax.swing.ImageIcon;
@@ -40,13 +42,13 @@ import be.nikiroo.utils.resources.MetaInfo;
  * @param <E>
  *            the type of {@link Bundle} to edit
  */
-public class ConfigItem<E extends Enum<E>> extends JPanel {
+public abstract class ConfigItem<E extends Enum<E>> extends JPanel {
        private static final long serialVersionUID = 1L;
 
        private static int minimumHeight = -1;
 
        /** A small 16x16 "?" blue in PNG, base64 encoded. */
-       private static String img64Info = //
+       private static String img64info = //
        ""
                        + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI"
                        + "WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wURFRg6IrtcdgAAATdJREFUOMvtkj8sQ1EUxr9z/71G"
@@ -58,7 +60,7 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
                        + "eUvgn195AwlZWyvjtQdhAAAAAElFTkSuQmCC";
 
        /** A small 16x16 "+" image with colours */
-       private static String img54add = //
+       private static String img64add = //
        ""
                        + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI"
                        + "WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wUeES0QBFvvnAAAAB1pVFh0Q29tbWVudAAAAAAAQ3Jl"
@@ -75,7 +77,7 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
                        + "oRFoAAAAAElFTkSuQmCC";
 
        /** A small 32x32 "-" image with colours */
-       private static String img64Remove = //
+       private static String img64remove = //
        ""
                        + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI"
                        + "WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wUeESw5X/JGsQAAAB1pVFh0Q29tbWVudAAAAAAAQ3Jl"
@@ -93,87 +95,53 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
 
        /** The original value before current changes. */
        private Object orig;
+       private List<Object> origs = new ArrayList<Object>();
        private List<Integer> dirtyBits;
 
+       /** The fields (one for non-array, a list for arrays). */
        private JComponent field;
        private List<JComponent> fields = new ArrayList<JComponent>();
 
+       /** The fields to panel map to get the actual item added to 'main'. */
+       private Map<Integer, JComponent> itemFields = new HashMap<Integer, JComponent>();
+
+       /** The main panel with all the fields in it. */
+       private JPanel main;
+
        /** The {@link MetaInfo} linked to the field. */
        protected MetaInfo<E> info;
 
        /**
         * Create a new {@link ConfigItem} for the given {@link MetaInfo}.
         * 
-        * @param info
-        *            the {@link MetaInfo}
         * @param nhgap
         *            negative horisontal gap in pixel to use for the label, i.e.,
         *            the step lock sized labels will start smaller by that amount
         *            (the use case would be to align controls that start at a
         *            different horisontal position)
         */
-       public ConfigItem(MetaInfo<E> info, int nhgap) {
-               this(info, true);
-
-               ConfigItem<E> configItem;
-               switch (info.getFormat()) {
-               case BOOLEAN:
-                       configItem = new ConfigItemBoolean<E>(info);
-                       break;
-               case COLOR:
-                       configItem = new ConfigItemColor<E>(info);
-                       break;
-               case FILE:
-                       configItem = new ConfigItemBrowse<E>(info, false);
-                       break;
-               case DIRECTORY:
-                       configItem = new ConfigItemBrowse<E>(info, true);
-                       break;
-               case COMBO_LIST:
-                       configItem = new ConfigItemCombobox<E>(info, true);
-                       break;
-               case FIXED_LIST:
-                       configItem = new ConfigItemCombobox<E>(info, false);
-                       break;
-               case INT:
-                       configItem = new ConfigItemInteger<E>(info);
-                       break;
-               case PASSWORD:
-                       configItem = new ConfigItemPassword<E>(info);
-                       break;
-               case LOCALE:
-                       configItem = new ConfigItemLocale<E>(info);
-                       break;
-               case STRING:
-               default:
-                       configItem = new ConfigItemString<E>(info);
-                       break;
-               }
-
+       public void init(int nhgap) {
                if (info.isArray()) {
                        this.setLayout(new BorderLayout());
                        add(label(nhgap), BorderLayout.WEST);
 
-                       final JPanel main = new JPanel();
+                       main = new JPanel();
+
                        main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
                        int size = info.getListSize(false);
                        for (int i = 0; i < size; i++) {
-                               JComponent field = configItem.createComponent(i);
-                               main.add(field);
+                               addItem(i);
                        }
+                       main.revalidate();
+                       main.repaint();
 
                        final JButton add = new JButton();
-                       setImage(add, img54add, "+");
+                       setImage(add, img64add, "+");
 
-                       final ConfigItem<E> fconfigItem = configItem;
                        add.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
-                                       JComponent field = fconfigItem
-                                                       .createComponent(fconfigItem.info
-                                                                       .getListSize(false));
-                                       main.add(field);
-
+                                       addItem(fields.size());
                                        main.revalidate();
                                        main.repaint();
                                }
@@ -191,11 +159,53 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
                        this.setLayout(new BorderLayout());
                        add(label(nhgap), BorderLayout.WEST);
 
-                       JComponent field = configItem.createComponent(-1);
+                       JComponent field = createField(-1);
                        add(field, BorderLayout.CENTER);
                }
        }
 
+       private void addItem(final int item) {
+               JPanel minusPanel = new JPanel(new BorderLayout());
+               itemFields.put(item, minusPanel);
+
+               JComponent field = createField(item);
+
+               final JButton remove = new JButton();
+               setImage(remove, img64remove, "-");
+
+               remove.addActionListener(new ActionListener() {
+                       @Override
+                       public void actionPerformed(ActionEvent e) {
+                               removeItem(item);
+                       }
+               });
+
+               minusPanel.add(field, BorderLayout.CENTER);
+               minusPanel.add(remove, BorderLayout.EAST);
+
+               main.add(minusPanel);
+               main.revalidate();
+               main.repaint();
+       }
+
+       private void removeItem(int item) {
+               int last = itemFields.size() - 1;
+
+               for (int i = item; i <= last; i++) {
+                       Object value = null;
+                       if (i < last) {
+                               value = getFromField(i + 1);
+                       }
+                       setToField(value, i);
+                       setToInfo(value, i);
+                       setDirtyItem(i);
+               }
+
+               main.remove(itemFields.remove(last));
+               main.revalidate();
+               main.repaint();
+       }
+
        /**
         * Prepare a new {@link ConfigItem} instance, linked to the given
         * {@link MetaInfo}.
@@ -216,10 +226,10 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
 
        /**
         * Create an empty graphical component to be used later by
-        * {@link ConfigItem#getField(int)}.
+        * {@link ConfigItem#createField(int)}.
         * <p>
         * Note that {@link ConfigItem#reload(int)} will be called after it was
-        * created.
+        * created by {@link ConfigItem#createField(int)}.
         * 
         * @param item
         *            the item number to get for an array of values, or -1 to get
@@ -228,10 +238,7 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         * 
         * @return the graphical component
         */
-       protected JComponent createField(@SuppressWarnings("unused") int item) {
-               // Not used by the main class, only the sublasses
-               return null;
-       }
+       abstract protected JComponent createEmptyField(int item);
 
        /**
         * Get the information from the {@link MetaInfo} in the subclass preferred
@@ -244,10 +251,7 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         * 
         * @return the information in the subclass preferred format
         */
-       protected Object getFromInfo(@SuppressWarnings("unused") int item) {
-               // Not used by the main class, only the subclasses
-               return null;
-       }
+       abstract protected Object getFromInfo(int item);
 
        /**
         * Set the value to the {@link MetaInfo}.
@@ -259,23 +263,21 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         *            the whole value (has no effect if {@link MetaInfo#isArray()}
         *            is FALSE)
         */
-       protected void setToInfo(@SuppressWarnings("unused") Object value,
-                       @SuppressWarnings("unused") int item) {
-               // Not used by the main class, only the subclasses
-       }
+       abstract protected void setToInfo(Object value, int item);
 
        /**
+        * The value present in the given item's related field in the subclass
+        * preferred format.
+        * 
         * @param item
         *            the item number to get for an array of values, or -1 to get
         *            the whole value (has no effect if {@link MetaInfo#isArray()}
         *            is FALSE)
         * 
-        * @return
+        * @return the value present in the given item's related field in the
+        *         subclass preferred format
         */
-       protected Object getFromField(@SuppressWarnings("unused") int item) {
-               // Not used by the main class, only the subclasses
-               return null;
-       }
+       abstract protected Object getFromField(int item);
 
        /**
         * Set the value (in the subclass preferred format) into the field.
@@ -287,15 +289,12 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         *            the whole value (has no effect if {@link MetaInfo#isArray()}
         *            is FALSE)
         */
-       protected void setToField(@SuppressWarnings("unused") Object value,
-                       @SuppressWarnings("unused") int item) {
-               // Not used by the main class, only the subclasses
-       }
+       abstract protected void setToField(Object value, int item);
 
        /**
         * Create a new field for the given graphical component at the given index
         * (note that the component is usually created by
-        * {@link ConfigItem#createField(int)}).
+        * {@link ConfigItem#createEmptyField(int)}).
         * 
         * @param item
         *            the item number to get for an array of values, or -1 to get
@@ -319,7 +318,7 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
 
        /**
         * Retrieve the associated graphical component that was created with
-        * {@link ConfigItem#createField(int)}.
+        * {@link ConfigItem#createEmptyField(int)}.
         * 
         * @param item
         *            the item number to get for an array of values, or -1 to get
@@ -340,6 +339,52 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
                return null;
        }
 
+       /**
+        * The original value (before any changes to the {@link MetaInfo}) for this
+        * item.
+        * 
+        * @param item
+        *            the item number to get for an array of values, or -1 to get
+        *            the whole value (has no effect if {@link MetaInfo#isArray()}
+        *            is FALSE)
+        * 
+        * @return the original value
+        */
+       private Object getOrig(int item) {
+               if (item < 0) {
+                       return orig;
+               }
+
+               if (item < origs.size()) {
+                       return origs.get(item);
+               }
+
+               return null;
+       }
+
+       /**
+        * The original value (before any changes to the {@link MetaInfo}) for this
+        * item.
+        * 
+        * @param item
+        *            the item number to get for an array of values, or -1 to get
+        *            the whole value (has no effect if {@link MetaInfo#isArray()}
+        *            is FALSE)
+        * @param value
+        *            the new original value
+        */
+       private void setOrig(Object value, int item) {
+               if (item < 0) {
+                       orig = value;
+               } else {
+                       while (item >= origs.size()) {
+                               origs.add(null);
+                       }
+
+                       origs.set(item, value);
+               }
+       }
+
        /**
         * Manually specify that the given item is "dirty" and thus should be saved
         * when asked.
@@ -366,14 +411,40 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         * 
         * @param value
         *            the value to test
+        * @param item
+        *            the item number to get for an array of values, or -1 to get
+        *            the whole value (has no effect if {@link MetaInfo#isArray()}
+        *            is FALSE)
         * 
         * @return TRUE if it has
         */
-       protected boolean hasValueChanged(Object value) {
+       protected boolean hasValueChanged(Object value, int item) {
                // We consider "" and NULL to be equals
+               Object orig = getOrig(item);
+               if (orig == null) {
+                       orig = "";
+               }
                return !orig.equals(value == null ? "" : value);
        }
 
+       /**
+        * Reload the values to what they currently are in the {@link MetaInfo}.
+        */
+       private void reload() {
+               if (info.isArray()) {
+                       while (!itemFields.isEmpty()) {
+                               main.remove(itemFields.remove(itemFields.size() - 1));
+                       }
+                       main.revalidate();
+                       main.repaint();
+                       for (int item = 0; item < info.getListSize(false); item++) {
+                               reload(item);
+                       }
+               } else {
+                       reload(-1);
+               }
+       }
+
        /**
         * Reload the values to what they currently are in the {@link MetaInfo}.
         * 
@@ -382,12 +453,34 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         *            the whole value (has no effect if {@link MetaInfo#isArray()}
         *            is FALSE)
         */
-       protected void reload(int item) {
+       private void reload(int item) {
+               if (item >= 0 && !itemFields.containsKey(item)) {
+                       addItem(item);
+               }
+
+               // if (item >= 0) {
+               // Object value = getFromField(item);
+               // if (value == null) {
+               // value = "";
+               // }
+               //
+               // boolean empty = value.equals("");
+               //
+               // if (!empty && item >= info.getListSize(false)) {
+               // // item was deleted, remove it
+               // removeItem(item);
+               // return;
+               // }
+               //
+               // // in case of reload after remove
+               // if (!itemFields.containsKey(item)) {
+               // addItem(item);
+               // }
+               // }
+
                Object value = getFromInfo(item);
                setToField(value, item);
-
-               // We consider "" and NULL to be equals
-               orig = (value == null ? "" : value);
+               setOrig(value == null ? "" : value, item);
        }
 
        /**
@@ -395,60 +488,97 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
         * modify it to, reflect the changes so it can be saved later.
         * <p>
         * This method does <b>not</b> call {@link MetaInfo#save(boolean)}.
+        */
+       private void save() {
+               if (info.isArray()) {
+                       boolean dirty = fields.size() != info.getListSize(false);
+                       for (int item = 0; item < fields.size(); item++) {
+                               if (getDirtyBit(item)) {
+                                       dirty = true;
+                               }
+                       }
+
+                       if (dirty) {
+                               info.setString(null, -1);
+                               for (int item = 0; item < fields.size(); item++) {
+                                       Object value = null;
+                                       if (getField(item) != null) {
+                                               value = getFromField(item);
+                                               if ("".equals(value)) {
+                                                       value = null;
+                                               }
+                                       }
+
+                                       info.setDirty();
+                                       setToInfo(value, item);
+                                       setOrig(value, item);
+                               }
+                       }
+               } else {
+                       if (getDirtyBit(-1)) {
+                               Object value = getFromField(-1);
+
+                               info.setDirty();
+                               setToInfo(value, -1);
+                               setOrig(value, -1);
+                       }
+               }
+       }
+
+       /**
+        * Check if the item is dirty, and clear the dirty bit if set.
         * 
         * @param item
         *            the item number to get for an array of values, or -1 to get
         *            the whole value (has no effect if {@link MetaInfo#isArray()}
         *            is FALSE)
+        * 
+        * @return TRUE if it was dirty, FALSE if not
         */
-       protected void save(int item) {
-               Object value = getFromField(item);
-
-               boolean dirty = false;
+       private boolean getDirtyBit(int item) {
                if (dirtyBits != null) {
-                       dirty = dirtyBits.remove((Integer) item);
-               } else {
-                       // We consider "" and NULL to be equals
-                       dirty = hasValueChanged(value);
+                       return dirtyBits.remove((Integer) item);
                }
 
-               if (dirty) {
-                       info.setDirty();
-                       setToInfo(value, item);
-                       orig = (value == null ? "" : value);
+               Object value = null;
+               if (getField(item) != null) {
+                       value = getFromField(item);
                }
+
+               return hasValueChanged(value, item);
        }
 
        /**
+        * Create a new field for the given item.
         * 
         * @param item
         *            the item number to get for an array of values, or -1 to get
         *            the whole value (has no effect if {@link MetaInfo#isArray()}
         *            is FALSE)
-        * @param addTo
-        * @param nhgap
         * 
-        * @return
+        * @return the newly created field
         */
-       protected JComponent createComponent(final int item) {
-               setField(item, createField(item));
+       protected JComponent createField(final int item) {
+               JComponent field = createEmptyField(item);
+               setField(item, field);
                reload(item);
 
                info.addReloadedListener(new Runnable() {
                        @Override
                        public void run() {
-                               reload(item);
+                               reload();
                        }
                });
                info.addSaveListener(new Runnable() {
                        @Override
                        public void run() {
-                               save(item);
+                               save();
                        }
                });
 
-               JComponent field = getField(item);
-               setPreferredSize(field);
+               int height = Math
+                               .max(getMinimumHeight(), field.getMinimumSize().height);
+               field.setPreferredSize(new Dimension(200, height));
 
                return field;
        }
@@ -504,7 +634,7 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
 
                JLabel help = new JLabel("");
                help.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
-               setImage(help, img64Info, "?");
+               setImage(help, img64info, "?");
 
                help.addMouseListener(new MouseAdapter() {
                        @Override
@@ -531,18 +661,62 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
                return pane;
        }
 
-       protected void setPreferredSize(JComponent field) {
-               int height = Math
-                               .max(getMinimumHeight(), field.getMinimumSize().height);
-               setPreferredSize(new Dimension(200, height));
-       }
+       /**
+        * Create a new {@link ConfigItem} for the given {@link MetaInfo}.
+        * 
+        * @param <E>
+        *            the type of {@link Bundle} to edit
+        * 
+        * @param info
+        *            the {@link MetaInfo}
+        * @param nhgap
+        *            negative horisontal gap in pixel to use for the label, i.e.,
+        *            the step lock sized labels will start smaller by that amount
+        *            (the use case would be to align controls that start at a
+        *            different horisontal position)
+        * 
+        * @return the new {@link ConfigItem}
+        */
+       static public <E extends Enum<E>> ConfigItem<E> createItem(
+                       MetaInfo<E> info, int nhgap) {
 
-       static private int getMinimumHeight() {
-               if (minimumHeight < 0) {
-                       minimumHeight = new JTextField("Test").getMinimumSize().height;
+               ConfigItem<E> configItem;
+               switch (info.getFormat()) {
+               case BOOLEAN:
+                       configItem = new ConfigItemBoolean<E>(info);
+                       break;
+               case COLOR:
+                       configItem = new ConfigItemColor<E>(info);
+                       break;
+               case FILE:
+                       configItem = new ConfigItemBrowse<E>(info, false);
+                       break;
+               case DIRECTORY:
+                       configItem = new ConfigItemBrowse<E>(info, true);
+                       break;
+               case COMBO_LIST:
+                       configItem = new ConfigItemCombobox<E>(info, true);
+                       break;
+               case FIXED_LIST:
+                       configItem = new ConfigItemCombobox<E>(info, false);
+                       break;
+               case INT:
+                       configItem = new ConfigItemInteger<E>(info);
+                       break;
+               case PASSWORD:
+                       configItem = new ConfigItemPassword<E>(info);
+                       break;
+               case LOCALE:
+                       configItem = new ConfigItemLocale<E>(info);
+                       break;
+               case STRING:
+               default:
+                       configItem = new ConfigItemString<E>(info);
+                       break;
                }
 
-               return minimumHeight;
+               configItem.init(nhgap);
+               return configItem;
        }
 
        /**
@@ -598,4 +772,12 @@ public class ConfigItem<E extends Enum<E>> extends JPanel {
                        button.setText(fallbackText);
                }
        }
+
+       static private int getMinimumHeight() {
+               if (minimumHeight < 0) {
+                       minimumHeight = new JTextField("Test").getMinimumSize().height;
+               }
+
+               return minimumHeight;
+       }
 }
index 8ebb7d1b76e87a8fb847bb7d8f99be70baa99c7c..255ec1338f442eaa2f4c5802e1d54a570a035ce9 100644 (file)
@@ -53,7 +53,7 @@ class ConfigItemBoolean<E extends Enum<E>> extends ConfigItem<E> {
        }
 
        @Override
-       protected JComponent createField(int item) {
+       protected JComponent createEmptyField(int item) {
                // Should not happen!
                if (getFromInfo(item) == null) {
                        System.err
index c13c396aa3801db913fd2a4a52e4c9bcdccb43b7..6c8af99f1fa66289eafa16c52ee50d32b89925bb 100644 (file)
@@ -70,7 +70,7 @@ class ConfigItemBrowse<E extends Enum<E>> extends ConfigItem<E> {
        }
 
        @Override
-       protected JComponent createField(final int item) {
+       protected JComponent createEmptyField(final int item) {
                final JPanel pane = new JPanel(new BorderLayout());
                final JTextField field = new JTextField();
                field.addKeyListener(new KeyAdapter() {
@@ -81,7 +81,7 @@ class ConfigItemBrowse<E extends Enum<E>> extends ConfigItem<E> {
                                        file = new File(field.getText());
                                }
 
-                               if (hasValueChanged(file)) {
+                               if (hasValueChanged(file, item)) {
                                        setDirtyItem(item);
                                }
                        }
@@ -99,7 +99,7 @@ class ConfigItemBrowse<E extends Enum<E>> extends ConfigItem<E> {
                                        File file = chooser.getSelectedFile();
                                        if (file != null) {
                                                setToField(file, item);
-                                               if (hasValueChanged(file)) {
+                                               if (hasValueChanged(file, item)) {
                                                        setDirtyItem(item);
                                                }
                                        }
index fa216cd8cc35f7ebf9ad654a30df10461013c0e3..500efff4b3b802831ad584550ea183f0d0bb9195 100644 (file)
@@ -90,7 +90,7 @@ class ConfigItemColor<E extends Enum<E>> extends ConfigItem<E> {
        }
 
        @Override
-       protected JComponent createField(final int item) {
+       protected JComponent createEmptyField(final int item) {
                final JPanel pane = new JPanel(new BorderLayout());
                final JTextField field = new JTextField();
 
index 28c5df8d89002fa219040a3a3441421f60be2466..b77e0a820596bea9356c69ab3d378e53afe878e8 100644 (file)
@@ -60,7 +60,7 @@ class ConfigItemCombobox<E extends Enum<E>> extends ConfigItem<E> {
        // rawtypes for Java 1.6 (and 1.7 ?) support
        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
-       protected JComponent createField(int item) {
+       protected JComponent createEmptyField(int item) {
                JComboBox field = new JComboBox(allowedValues);
                field.setEditable(editable);
                return field;
index 06c903a01b75c025338b7ac15d75d030f7e3acf0..9b838a55125888a473d5700d8ad31dba28c6ae72 100644 (file)
@@ -47,7 +47,7 @@ class ConfigItemInteger<E extends Enum<E>> extends ConfigItem<E> {
        }
 
        @Override
-       protected JComponent createField(int item) {
+       protected JComponent createEmptyField(int item) {
                return new JSpinner();
        }
 }
index b648645eab0be6645de4b14e1760a1cd47c9d672..abe915bbc74aa43624903eefadeea6c587c835aa 100644 (file)
@@ -26,8 +26,8 @@ class ConfigItemLocale<E extends Enum<E>> extends ConfigItemCombobox<E> {
        // rawtypes for Java 1.6 (and 1.7 ?) support
        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
-       protected JComponent createField(int item) {
-               JComboBox field = (JComboBox) super.createField(item);
+       protected JComponent createEmptyField(int item) {
+               JComboBox field = (JComboBox) super.createEmptyField(item);
                field.setRenderer(new DefaultListCellRenderer() {
                        private static final long serialVersionUID = 1L;
 
index e7987000de40fd6ab0da5dad48c88b8f0ad99c68..348b78f36a82eee99ff3e3f2b14064d61f427622 100644 (file)
@@ -16,7 +16,7 @@ import be.nikiroo.utils.resources.MetaInfo;
 class ConfigItemPassword<E extends Enum<E>> extends ConfigItem<E> {
        private static final long serialVersionUID = 1L;
        /** A small 16x16 pass-protecet icon in PNG, base64 encoded. */
-       private static String img64PassProtected = //
+       private static String img64passProtected = //
        ""
                        + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAAnNCSVQICFXsRgQAAAD5SURBVCjP"
                        + "ndG9LoNxGIbxHxJTG9U0IsJAdCSNqZEa9BR87BaHYfW5ESYkmjQh4giwIU00MWFwAPWRSmpgaf6G"
@@ -26,7 +26,7 @@ class ConfigItemPassword<E extends Enum<E>> extends ConfigItem<E> {
                        + "lbp3l5b1xR/1rWrYf/MLWpplWwswQpMAAAAASUVORK5CYII=";
 
        /** A small 16x16 pass-unprotecet icon in PNG, base64 encoded. */
-       private static String img64PassUnprotected = //
+       private static String img64passUnprotected = //
        ""
                        + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAA"
                        + "CxMAAAsTAQCanBgAAAAHdElNRQfjBR8MIilwhCwdAAABK0lEQVQoz5XQv0uUAQCH8c/7qod4nect"
@@ -78,24 +78,24 @@ class ConfigItemPassword<E extends Enum<E>> extends ConfigItem<E> {
        }
 
        @Override
-       protected JComponent createField(int item) {
+       protected JComponent createEmptyField(int item) {
                JPanel pane = new JPanel(new BorderLayout());
                final JPasswordField field = new JPasswordField();
                field.setEchoChar('*');
 
                final JButton show = new JButton();
                final Boolean[] visible = new Boolean[] { false };
-               setImage(show, img64PassProtected, "/");
+               setImage(show, img64passProtected, "/");
                show.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                                visible[0] = !visible[0];
                                if (visible[0]) {
                                        field.setEchoChar((char) 0);
-                                       setImage(show, img64PassUnprotected, "o");
+                                       setImage(show, img64passUnprotected, "o");
                                } else {
                                        field.setEchoChar('*');
-                                       setImage(show, img64PassProtected, "/");
+                                       setImage(show, img64passProtected, "/");
                                }
                        }
                });
index 73dffe9a4aed859984572ae908bb862636f50f81..99a8cc38e2cec33e27175ad3ad214d611680e8a4 100644 (file)
@@ -47,7 +47,7 @@ class ConfigItemString<E extends Enum<E>> extends ConfigItem<E> {
        }
 
        @Override
-       protected JComponent createField(int item) {
+       protected JComponent createEmptyField(int item) {
                return new JTextField();
        }
 }