From a037637226b1b5f9621238587341f51364aca2fd Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 1 Jun 2019 10:57:13 +0200 Subject: [PATCH] fix ConfigItems, especially regarding items --- src/be/nikiroo/utils/ui/ConfigEditor.java | 2 +- src/be/nikiroo/utils/ui/ConfigItem.java | 414 +++++++++++++----- .../nikiroo/utils/ui/ConfigItemBoolean.java | 2 +- src/be/nikiroo/utils/ui/ConfigItemBrowse.java | 6 +- src/be/nikiroo/utils/ui/ConfigItemColor.java | 2 +- .../nikiroo/utils/ui/ConfigItemCombobox.java | 2 +- .../nikiroo/utils/ui/ConfigItemInteger.java | 2 +- src/be/nikiroo/utils/ui/ConfigItemLocale.java | 4 +- .../nikiroo/utils/ui/ConfigItemPassword.java | 12 +- src/be/nikiroo/utils/ui/ConfigItemString.java | 2 +- 10 files changed, 315 insertions(+), 133 deletions(-) diff --git a/src/be/nikiroo/utils/ui/ConfigEditor.java b/src/be/nikiroo/utils/ui/ConfigEditor.java index 27e517b..c687c98 100644 --- a/src/be/nikiroo/utils/ui/ConfigEditor.java +++ b/src/be/nikiroo/utils/ui/ConfigEditor.java @@ -139,7 +139,7 @@ public class ConfigEditor> extends JPanel { main.add(bpane); } else { items.add(item); - main.add(new ConfigItem(item, nhgap)); + main.add(ConfigItem.createItem(item, nhgap)); } } diff --git a/src/be/nikiroo/utils/ui/ConfigItem.java b/src/be/nikiroo/utils/ui/ConfigItem.java index 045d838..46775e1 100644 --- a/src/be/nikiroo/utils/ui/ConfigItem.java +++ b/src/be/nikiroo/utils/ui/ConfigItem.java @@ -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 * the type of {@link Bundle} to edit */ -public class ConfigItem> extends JPanel { +public abstract class ConfigItem> 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> 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> 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> extends JPanel { /** The original value before current changes. */ private Object orig; + private List origs = new ArrayList(); private List dirtyBits; + /** The fields (one for non-array, a list for arrays). */ private JComponent field; private List fields = new ArrayList(); + /** The fields to panel map to get the actual item added to 'main'. */ + private Map itemFields = new HashMap(); + + /** The main panel with all the fields in it. */ + private JPanel main; + /** The {@link MetaInfo} linked to the field. */ protected MetaInfo 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 info, int nhgap) { - this(info, true); - - ConfigItem configItem; - switch (info.getFormat()) { - case BOOLEAN: - configItem = new ConfigItemBoolean(info); - break; - case COLOR: - configItem = new ConfigItemColor(info); - break; - case FILE: - configItem = new ConfigItemBrowse(info, false); - break; - case DIRECTORY: - configItem = new ConfigItemBrowse(info, true); - break; - case COMBO_LIST: - configItem = new ConfigItemCombobox(info, true); - break; - case FIXED_LIST: - configItem = new ConfigItemCombobox(info, false); - break; - case INT: - configItem = new ConfigItemInteger(info); - break; - case PASSWORD: - configItem = new ConfigItemPassword(info); - break; - case LOCALE: - configItem = new ConfigItemLocale(info); - break; - case STRING: - default: - configItem = new ConfigItemString(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 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> 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> extends JPanel { /** * Create an empty graphical component to be used later by - * {@link ConfigItem#getField(int)}. + * {@link ConfigItem#createField(int)}. *

* 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> 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> 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> 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> 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> 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> 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> 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> 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> extends JPanel { * modify it to, reflect the changes so it can be saved later. *

* This method does not 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> 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> 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 + * 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 > ConfigItem createItem( + MetaInfo info, int nhgap) { - static private int getMinimumHeight() { - if (minimumHeight < 0) { - minimumHeight = new JTextField("Test").getMinimumSize().height; + ConfigItem configItem; + switch (info.getFormat()) { + case BOOLEAN: + configItem = new ConfigItemBoolean(info); + break; + case COLOR: + configItem = new ConfigItemColor(info); + break; + case FILE: + configItem = new ConfigItemBrowse(info, false); + break; + case DIRECTORY: + configItem = new ConfigItemBrowse(info, true); + break; + case COMBO_LIST: + configItem = new ConfigItemCombobox(info, true); + break; + case FIXED_LIST: + configItem = new ConfigItemCombobox(info, false); + break; + case INT: + configItem = new ConfigItemInteger(info); + break; + case PASSWORD: + configItem = new ConfigItemPassword(info); + break; + case LOCALE: + configItem = new ConfigItemLocale(info); + break; + case STRING: + default: + configItem = new ConfigItemString(info); + break; } - return minimumHeight; + configItem.init(nhgap); + return configItem; } /** @@ -598,4 +772,12 @@ public class ConfigItem> extends JPanel { button.setText(fallbackText); } } + + static private int getMinimumHeight() { + if (minimumHeight < 0) { + minimumHeight = new JTextField("Test").getMinimumSize().height; + } + + return minimumHeight; + } } diff --git a/src/be/nikiroo/utils/ui/ConfigItemBoolean.java b/src/be/nikiroo/utils/ui/ConfigItemBoolean.java index 8ebb7d1..255ec13 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemBoolean.java +++ b/src/be/nikiroo/utils/ui/ConfigItemBoolean.java @@ -53,7 +53,7 @@ class ConfigItemBoolean> extends ConfigItem { } @Override - protected JComponent createField(int item) { + protected JComponent createEmptyField(int item) { // Should not happen! if (getFromInfo(item) == null) { System.err diff --git a/src/be/nikiroo/utils/ui/ConfigItemBrowse.java b/src/be/nikiroo/utils/ui/ConfigItemBrowse.java index c13c396..6c8af99 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemBrowse.java +++ b/src/be/nikiroo/utils/ui/ConfigItemBrowse.java @@ -70,7 +70,7 @@ class ConfigItemBrowse> extends ConfigItem { } @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> extends ConfigItem { file = new File(field.getText()); } - if (hasValueChanged(file)) { + if (hasValueChanged(file, item)) { setDirtyItem(item); } } @@ -99,7 +99,7 @@ class ConfigItemBrowse> extends ConfigItem { File file = chooser.getSelectedFile(); if (file != null) { setToField(file, item); - if (hasValueChanged(file)) { + if (hasValueChanged(file, item)) { setDirtyItem(item); } } diff --git a/src/be/nikiroo/utils/ui/ConfigItemColor.java b/src/be/nikiroo/utils/ui/ConfigItemColor.java index fa216cd..500efff 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemColor.java +++ b/src/be/nikiroo/utils/ui/ConfigItemColor.java @@ -90,7 +90,7 @@ class ConfigItemColor> extends ConfigItem { } @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(); diff --git a/src/be/nikiroo/utils/ui/ConfigItemCombobox.java b/src/be/nikiroo/utils/ui/ConfigItemCombobox.java index 28c5df8..b77e0a8 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemCombobox.java +++ b/src/be/nikiroo/utils/ui/ConfigItemCombobox.java @@ -60,7 +60,7 @@ class ConfigItemCombobox> extends ConfigItem { // 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; diff --git a/src/be/nikiroo/utils/ui/ConfigItemInteger.java b/src/be/nikiroo/utils/ui/ConfigItemInteger.java index 06c903a..9b838a5 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemInteger.java +++ b/src/be/nikiroo/utils/ui/ConfigItemInteger.java @@ -47,7 +47,7 @@ class ConfigItemInteger> extends ConfigItem { } @Override - protected JComponent createField(int item) { + protected JComponent createEmptyField(int item) { return new JSpinner(); } } diff --git a/src/be/nikiroo/utils/ui/ConfigItemLocale.java b/src/be/nikiroo/utils/ui/ConfigItemLocale.java index b648645..abe915b 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemLocale.java +++ b/src/be/nikiroo/utils/ui/ConfigItemLocale.java @@ -26,8 +26,8 @@ class ConfigItemLocale> extends ConfigItemCombobox { // 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; diff --git a/src/be/nikiroo/utils/ui/ConfigItemPassword.java b/src/be/nikiroo/utils/ui/ConfigItemPassword.java index e798700..348b78f 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemPassword.java +++ b/src/be/nikiroo/utils/ui/ConfigItemPassword.java @@ -16,7 +16,7 @@ import be.nikiroo.utils.resources.MetaInfo; class ConfigItemPassword> extends ConfigItem { 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> extends ConfigItem { + "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> extends ConfigItem { } @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, "/"); } } }); diff --git a/src/be/nikiroo/utils/ui/ConfigItemString.java b/src/be/nikiroo/utils/ui/ConfigItemString.java index 73dffe9..99a8cc3 100644 --- a/src/be/nikiroo/utils/ui/ConfigItemString.java +++ b/src/be/nikiroo/utils/ui/ConfigItemString.java @@ -47,7 +47,7 @@ class ConfigItemString> extends ConfigItem { } @Override - protected JComponent createField(int item) { + protected JComponent createEmptyField(int item) { return new JTextField(); } } -- 2.27.0