Browse Source

Fixes issue 3524: Catch config option not found in prefs dialog and report to user nicely.

Change-Id: Id98f89e0c3fdf5931094478ec401fa9050902ce3
Reviewed-on: http://gerrit.dmdirc.com/505
Automatic-Compile: Shane Mc Cormack <shane@dmdirc.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 years ago
parent
commit
d249060bd8

+ 14
- 14
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java View File

@@ -42,7 +42,6 @@ import javax.swing.SwingWorker;
42 42
 import net.miginfocom.layout.ComponentWrapper;
43 43
 import net.miginfocom.layout.LayoutCallback;
44 44
 
45
-import net.miginfocom.layout.PlatformDefaults;
46 45
 import net.miginfocom.swing.MigLayout;
47 46
 
48 47
 /**
@@ -56,15 +55,6 @@ public class CategoryPanel extends JPanel {
56 55
      * serialized objects being unserialized with the new class).
57 56
      */
58 57
     private static final long serialVersionUID = -3268284364607758509L;
59
-    /** Panel gap. */
60
-    private final int padding = (int) PlatformDefaults.getUnitValueX("related").
61
-            getValue();
62
-    /** Panel left padding. */
63
-    private final int leftPadding = (int) PlatformDefaults.getPanelInsets(1).
64
-            getValue();
65
-    /** Panel right padding. */
66
-    private final int rightPadding = (int) PlatformDefaults.getPanelInsets(3).
67
-            getValue();
68 58
     /** Active preferences category. */
69 59
     private PreferencesCategory category;
70 60
     /** Parent window. */
@@ -85,8 +75,6 @@ public class CategoryPanel extends JPanel {
85 75
     private Map<PreferencesCategory, JPanel> panels;
86 76
     /** Category loading swing worker. */
87 77
     private SwingWorker worker;
88
-    /** Waiting. */
89
-    private boolean waiting;
90 78
 
91 79
     /**
92 80
      * Instantiates a new category panel.
@@ -226,8 +214,20 @@ public class CategoryPanel extends JPanel {
226 214
      * 
227 215
      * @param b
228 216
      */
229
-    public void setWaiting(boolean b) {
230
-        waiting = b;
217
+    public void setWaiting(final boolean b) {
231 218
         scrollPane.setViewportView(waitingCategory);
232 219
     }
220
+
221
+    /**
222
+     * Displays an error panel to the end user.
223
+     *
224
+     * @param message Message to display
225
+     */
226
+    public void setError(final String message) {
227
+        final JPanel panel = new JPanel(new MigLayout("fillx"));
228
+        panel.add(new TextLabel("An error has occurred loading the " +
229
+                "preferences dialog, an error has been raised: "), "wrap");
230
+        panel.add(new TextLabel(message));
231
+        scrollPane.setViewportView(panel);
232
+    }
233 233
 }

+ 13
- 2
src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java View File

@@ -99,7 +99,15 @@ public final class SwingPreferencesDialog extends StandardDialog implements
99 99
             @Override
100 100
             protected PreferencesManager doInBackground() throws Exception {
101 101
                 mainPanel.setWaiting(true);
102
-                return new PreferencesManager();
102
+                PreferencesManager prefsManager = null;
103
+                try {
104
+                    prefsManager = new PreferencesManager();
105
+                } catch (IllegalArgumentException ex) {
106
+                    mainPanel.setError(ex.getMessage());
107
+                    Logger.appError(ErrorLevel.HIGH, "Unable to load the" +
108
+                            "preferences dialog.", ex);
109
+                }
110
+                return prefsManager;
103 111
             }
104 112
 
105 113
             /** {@inheritDoc} */
@@ -107,7 +115,10 @@ public final class SwingPreferencesDialog extends StandardDialog implements
107 115
             protected void done() {
108 116
                 if (!isCancelled()) {
109 117
                     try {
110
-                        setPrefsManager(get());
118
+                        final PreferencesManager prefsManager = get();
119
+                        if (prefsManager != null) {
120
+                            setPrefsManager(prefsManager);
121
+                        }
111 122
                     } catch (InterruptedException ex) {
112 123
                         //Ignore
113 124
                     } catch (ExecutionException ex) {

Loading…
Cancel
Save