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