From: Niki Roo Date: Thu, 23 May 2019 08:02:37 +0000 (+0200) Subject: fix ConfigItem NPE and ConfigEditor Save/Reset/Defaults X-Git-Tag: fanfix-3.0.1~29^2~38 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=9cc3f77b412d86229861ed54a0d95027996099e4;p=fanfix.git fix ConfigItem NPE and ConfigEditor Save/Reset/Defaults --- diff --git a/src/be/nikiroo/utils/ui/ConfigEditor.java b/src/be/nikiroo/utils/ui/ConfigEditor.java index ca85f61..45a534e 100644 --- a/src/be/nikiroo/utils/ui/ConfigEditor.java +++ b/src/be/nikiroo/utils/ui/ConfigEditor.java @@ -5,6 +5,7 @@ import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import javax.swing.BoxLayout; @@ -57,11 +58,13 @@ public class ConfigEditor> extends JPanel { main.setLayout(new BoxLayout(main, BoxLayout.PAGE_AXIS)); main.setBorder(new EmptyBorder(5, 5, 5, 5)); - + main.add(new JLabel(title)); - items = MetaInfo.getItems(type, bundle); - for (MetaInfo item : items) { + items = new ArrayList>(); + List> groupedItems = MetaInfo.getItems(type, bundle); + for (MetaInfo item : groupedItems) { + // will init this.items addItem(main, item, 0); } @@ -129,6 +132,7 @@ public class ConfigEditor> extends JPanel { bpane.add(pane, BorderLayout.CENTER); main.add(bpane); } else { + items.add(item); main.add(new ConfigItem(item, nhgap)); } } diff --git a/src/be/nikiroo/utils/ui/ConfigItem.java b/src/be/nikiroo/utils/ui/ConfigItem.java index 4633370..04bf76c 100644 --- a/src/be/nikiroo/utils/ui/ConfigItem.java +++ b/src/be/nikiroo/utils/ui/ConfigItem.java @@ -348,7 +348,8 @@ public class ConfigItem> extends JPanel { info.addSaveListener(new Runnable() { @Override public void run() { - String value = field.getSelectedItem().toString(); + Object item = field.getSelectedItem(); + String value = item == null ? null : item.toString(); if (isChanged(value)) { info.setString(value); }