Sfoglia il codice sorgente

Show errors when loading frame managers

Change-Id: I7965c1569a86fa288b532169ff2ef44dc04881b3
Reviewed-on: http://gerrit.dmdirc.com/1198
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.4
Greboid 14 anni fa
parent
commit
2aaefca2e3
1 ha cambiato i file con 57 aggiunte e 32 eliminazioni
  1. 57
    32
      src/com/dmdirc/addons/ui_swing/MainFrame.java

+ 57
- 32
src/com/dmdirc/addons/ui_swing/MainFrame.java Vedi File

38
 import com.dmdirc.ui.IconManager;
38
 import com.dmdirc.ui.IconManager;
39
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
39
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
40
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
40
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
41
+import com.dmdirc.logger.ErrorLevel;
42
+import com.dmdirc.logger.Logger;
41
 import com.dmdirc.ui.interfaces.MainWindow;
43
 import com.dmdirc.ui.interfaces.MainWindow;
42
 import com.dmdirc.ui.interfaces.Window;
44
 import com.dmdirc.ui.interfaces.Window;
43
 import com.dmdirc.ui.CoreUIUtils;
45
 import com.dmdirc.ui.CoreUIUtils;
48
 import java.awt.event.WindowEvent;
50
 import java.awt.event.WindowEvent;
49
 import java.awt.event.WindowFocusListener;
51
 import java.awt.event.WindowFocusListener;
50
 import java.awt.event.WindowListener;
52
 import java.awt.event.WindowListener;
53
+import java.lang.reflect.InvocationTargetException;
51
 
54
 
52
 import javax.swing.ImageIcon;
55
 import javax.swing.ImageIcon;
53
 import javax.swing.JDesktopPane;
56
 import javax.swing.JDesktopPane;
100
 
103
 
101
     /**
104
     /**
102
      * Creates new form MainFrame.
105
      * Creates new form MainFrame.
103
-     * 
106
+     *
104
      * @param controller Swing controller
107
      * @param controller Swing controller
105
      */
108
      */
106
     protected MainFrame(final SwingController controller) {
109
     protected MainFrame(final SwingController controller) {
155
 
158
 
156
     /**
159
     /**
157
      * Returns the status bar for this frame.
160
      * Returns the status bar for this frame.
158
-     * 
161
+     *
159
      * @return Status bar
162
      * @return Status bar
160
      */
163
      */
161
     public SwingStatusBar getStatusBar() {
164
     public SwingStatusBar getStatusBar() {
259
 
262
 
260
     /**
263
     /**
261
      * Returns the desktop pane for the frame.
264
      * Returns the desktop pane for the frame.
262
-     * 
265
+     *
263
      * @return JDesktopPane for the frame
266
      * @return JDesktopPane for the frame
264
      */
267
      */
265
     public JDesktopPane getDesktopPane() {
268
     public JDesktopPane getDesktopPane() {
266
         return desktopPane;
269
         return desktopPane;
267
     }
270
     }
268
 
271
 
269
-    /** 
272
+    /**
270
      * {@inheritDoc}.
273
      * {@inheritDoc}.
271
-     * 
274
+     *
272
      * @param windowEvent Window event
275
      * @param windowEvent Window event
273
      */
276
      */
274
     @Override
277
     @Override
276
         //ignore
279
         //ignore
277
     }
280
     }
278
 
281
 
279
-    /** 
282
+    /**
280
      * {@inheritDoc}.
283
      * {@inheritDoc}.
281
-     * 
284
+     *
282
      * @param windowEvent Window event
285
      * @param windowEvent Window event
283
      */
286
      */
284
     @Override
287
     @Override
286
         quit(exitCode);
289
         quit(exitCode);
287
     }
290
     }
288
 
291
 
289
-    /** 
292
+    /**
290
      * {@inheritDoc}.
293
      * {@inheritDoc}.
291
-     * 
294
+     *
292
      * @param windowEvent Window event
295
      * @param windowEvent Window event
293
      */
296
      */
294
     @Override
297
     @Override
303
         }, "Quit thread").start();
306
         }, "Quit thread").start();
304
     }
307
     }
305
 
308
 
306
-    /** 
309
+    /**
307
      * {@inheritDoc}.
310
      * {@inheritDoc}.
308
-     * 
311
+     *
309
      * @param windowEvent Window event
312
      * @param windowEvent Window event
310
      */
313
      */
311
     @Override
314
     @Override
313
         ActionManager.processEvent(CoreActionType.CLIENT_MINIMISED, null);
316
         ActionManager.processEvent(CoreActionType.CLIENT_MINIMISED, null);
314
     }
317
     }
315
 
318
 
316
-    /** 
319
+    /**
317
      * {@inheritDoc}.
320
      * {@inheritDoc}.
318
-     * 
321
+     *
319
      * @param windowEvent Window event
322
      * @param windowEvent Window event
320
      */
323
      */
321
     @Override
324
     @Override
323
         ActionManager.processEvent(CoreActionType.CLIENT_UNMINIMISED, null);
326
         ActionManager.processEvent(CoreActionType.CLIENT_UNMINIMISED, null);
324
     }
327
     }
325
 
328
 
326
-    /** 
329
+    /**
327
      * {@inheritDoc}.
330
      * {@inheritDoc}.
328
-     * 
331
+     *
329
      * @param windowEvent Window event
332
      * @param windowEvent Window event
330
      */
333
      */
331
     @Override
334
     @Override
333
         //ignore
336
         //ignore
334
     }
337
     }
335
 
338
 
336
-    /** 
339
+    /**
337
      * {@inheritDoc}.
340
      * {@inheritDoc}.
338
-     * 
341
+     *
339
      * @param windowEvent Window event
342
      * @param windowEvent Window event
340
      */
343
      */
341
     @Override
344
     @Override
351
             @Override
354
             @Override
352
             public void run() {
355
             public void run() {
353
                 final String manager = IdentityManager.getGlobalConfig().
356
                 final String manager = IdentityManager.getGlobalConfig().
354
-                        getOption("ui",
355
-                        "framemanager");
356
-
357
+                        getOption("ui", "framemanager");
357
                 try {
358
                 try {
358
                     mainFrameManager = (FrameManager) Class.forName(manager).
359
                     mainFrameManager = (FrameManager) Class.forName(manager).
359
                             getConstructor().newInstance();
360
                             getConstructor().newInstance();
360
-                } catch (Exception ex) {
361
-                    // Throws craploads of exceptions and we want to handle them all
362
-                    // the same way, so we might as well catch Exception
363
-                    mainFrameManager = new TreeFrameManager();
361
+                } catch (InvocationTargetException ex) {
362
+                    Logger.appError(ErrorLevel.MEDIUM, "Unable to load frame "
363
+                            + "manager, falling back to default.", ex);
364
+                } catch (InstantiationException ex) {
365
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
366
+                            + "manager, falling back to default.", ex);
367
+                } catch (NoSuchMethodException ex) {
368
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
369
+                            + "manager, falling back to default.", ex);
370
+                } catch (SecurityException ex) {
371
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
372
+                            + "manager, falling back to default.", ex);
373
+                } catch (IllegalAccessException ex) {
374
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
375
+                            + "manager, falling back to default.", ex);
376
+                } catch (IllegalArgumentException ex) {
377
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
378
+                            + "manager, falling back to default.", ex);
379
+                } catch (ClassNotFoundException ex) {
380
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
381
+                            + "manager, falling back to default.", ex);
382
+                } catch (LinkageError ex) {
383
+                    Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
384
+                            + "manager, falling back to default.", ex);
385
+                } finally {
386
+                    if (mainFrameManager == null) {
387
+                        mainFrameManager = new TreeFrameManager();
388
+                    }
364
                 }
389
                 }
365
                 mainFrameManager.setController(controller);
390
                 mainFrameManager.setController(controller);
366
                 mainFrameManager.setParent(frameManagerPanel);
391
                 mainFrameManager.setParent(frameManagerPanel);
376
     private void initComponents() {
401
     private void initComponents() {
377
         statusBar = new SwingStatusBar(controller, this);
402
         statusBar = new SwingStatusBar(controller, this);
378
         frameManagerPanel = new JPanel();
403
         frameManagerPanel = new JPanel();
379
-        desktopPane = new DMDircDesktopPane(controller, this, controller.getDomain());
404
+        desktopPane = new DMDircDesktopPane(controller, this, controller.
405
+                getDomain());
380
 
406
 
381
         initFrameManagers();
407
         initFrameManagers();
382
 
408
 
399
 
425
 
400
     /**
426
     /**
401
      * Initialises the split pane.
427
      * Initialises the split pane.
402
-     * 
428
+     *
403
      * @return Returns the initialised split pane
429
      * @return Returns the initialised split pane
404
      */
430
      */
405
     private JSplitPane initSplitPane() {
431
     private JSplitPane initSplitPane() {
476
         quit(0);
502
         quit(0);
477
     }
503
     }
478
 
504
 
479
-    /** 
480
-     * Exit code call to quit. 
481
-     * 
505
+    /**
506
+     * Exit code call to quit.
507
+     *
482
      * @param exitCode Exit code
508
      * @param exitCode Exit code
483
      */
509
      */
484
     public void quit(final int exitCode) {
510
     public void quit(final int exitCode) {
577
 
603
 
578
     /**
604
     /**
579
      * Adds a window to this frame manager.
605
      * Adds a window to this frame manager.
580
-     * 
606
+     *
581
      * @param window The server to be added
607
      * @param window The server to be added
582
      * @param index Index of the window to be added
608
      * @param index Index of the window to be added
583
      */
609
      */
609
             }
635
             }
610
         });
636
         });
611
     }
637
     }
612
-
613
-}
638
+}

Loading…
Annulla
Salva