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
 import net.miginfocom.layout.ComponentWrapper;
42
 import net.miginfocom.layout.ComponentWrapper;
43
 import net.miginfocom.layout.LayoutCallback;
43
 import net.miginfocom.layout.LayoutCallback;
44
 
44
 
45
-import net.miginfocom.layout.PlatformDefaults;
46
 import net.miginfocom.swing.MigLayout;
45
 import net.miginfocom.swing.MigLayout;
47
 
46
 
48
 /**
47
 /**
56
      * serialized objects being unserialized with the new class).
55
      * serialized objects being unserialized with the new class).
57
      */
56
      */
58
     private static final long serialVersionUID = -3268284364607758509L;
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
     /** Active preferences category. */
58
     /** Active preferences category. */
69
     private PreferencesCategory category;
59
     private PreferencesCategory category;
70
     /** Parent window. */
60
     /** Parent window. */
85
     private Map<PreferencesCategory, JPanel> panels;
75
     private Map<PreferencesCategory, JPanel> panels;
86
     /** Category loading swing worker. */
76
     /** Category loading swing worker. */
87
     private SwingWorker worker;
77
     private SwingWorker worker;
88
-    /** Waiting. */
89
-    private boolean waiting;
90
 
78
 
91
     /**
79
     /**
92
      * Instantiates a new category panel.
80
      * Instantiates a new category panel.
226
      * 
214
      * 
227
      * @param b
215
      * @param b
228
      */
216
      */
229
-    public void setWaiting(boolean b) {
230
-        waiting = b;
217
+    public void setWaiting(final boolean b) {
231
         scrollPane.setViewportView(waitingCategory);
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
             @Override
99
             @Override
100
             protected PreferencesManager doInBackground() throws Exception {
100
             protected PreferencesManager doInBackground() throws Exception {
101
                 mainPanel.setWaiting(true);
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
             /** {@inheritDoc} */
113
             /** {@inheritDoc} */
107
             protected void done() {
115
             protected void done() {
108
                 if (!isCancelled()) {
116
                 if (!isCancelled()) {
109
                     try {
117
                     try {
110
-                        setPrefsManager(get());
118
+                        final PreferencesManager prefsManager = get();
119
+                        if (prefsManager != null) {
120
+                            setPrefsManager(prefsManager);
121
+                        }
111
                     } catch (InterruptedException ex) {
122
                     } catch (InterruptedException ex) {
112
                         //Ignore
123
                         //Ignore
113
                     } catch (ExecutionException ex) {
124
                     } catch (ExecutionException ex) {

Loading…
Cancel
Save