Browse Source

Remove MDI from the client.

Tidy up mainframe (creating a new dialog class).
Fix OptionalJSpinner having an excessive border.

Fixes issue CLIENT-66
Fixes issue CLIENT-2

Change-Id: I450fe4a6060988843caad0b22a1ac2ffad9e4c28
Depends-On: If58397d37b89c8fe6e099c47fb4d26fdc4589b49
Reviewed-on: http://gerrit.dmdirc.com/1630
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.5
Greg Holmes 13 years ago
parent
commit
2c4fe17288
27 changed files with 620 additions and 1476 deletions
  1. 0
    1
      src/com/dmdirc/addons/dcc/ui/EmptyWindow.java
  2. 118
    55
      src/com/dmdirc/addons/ui_swing/MainFrame.java
  3. 4
    8
      src/com/dmdirc/addons/ui_swing/SwingController.java
  4. 1
    1
      src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java
  5. 7
    8
      src/com/dmdirc/addons/ui_swing/actions/NextFrameAction.java
  6. 7
    8
      src/com/dmdirc/addons/ui_swing/actions/PreviousFrameAction.java
  7. 6
    0
      src/com/dmdirc/addons/ui_swing/components/CheckBoxMenuItem.java
  8. 36
    74
      src/com/dmdirc/addons/ui_swing/components/MDIBar.java
  9. 3
    1
      src/com/dmdirc/addons/ui_swing/components/TreeScroller.java
  10. 0
    471
      src/com/dmdirc/addons/ui_swing/components/desktopPane/DMDircDesktopPane.java
  11. 0
    93
      src/com/dmdirc/addons/ui_swing/components/desktopPane/ProxyDesktopPaneUI.java
  12. 11
    18
      src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java
  13. 5
    8
      src/com/dmdirc/addons/ui_swing/components/frames/CustomFrame.java
  14. 9
    11
      src/com/dmdirc/addons/ui_swing/components/frames/CustomInputFrame.java
  15. 11
    12
      src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java
  16. 7
    12
      src/com/dmdirc/addons/ui_swing/components/frames/QueryFrame.java
  17. 14
    18
      src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java
  18. 102
    483
      src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java
  19. 1
    1
      src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java
  20. 66
    0
      src/com/dmdirc/addons/ui_swing/dialogs/ConfirmQuitDialog.java
  21. 15
    3
      src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java
  22. 184
    0
      src/com/dmdirc/addons/ui_swing/framemanager/ctrltab/CtrlTabWindowManager.java
  23. 2
    1
      src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java
  24. 0
    99
      src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/ArrangeWindows.java
  25. 4
    10
      src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/TextFrameComparator.java
  26. 6
    80
      src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java
  27. 1
    0
      src/com/dmdirc/addons/ui_swing/plugin.config

+ 0
- 1
src/com/dmdirc/addons/dcc/ui/EmptyWindow.java View File

@@ -46,7 +46,6 @@ public class EmptyWindow extends TextFrame {
46 46
     public EmptyWindow(final SwingController controller, final FrameContainer<?> owner) {
47 47
         super(owner, controller);
48 48
         setTextPane(null);
49
-        pack();
50 49
     }
51 50
 
52 51
     /** {@inheritDoc} */

+ 118
- 55
src/com/dmdirc/addons/ui_swing/MainFrame.java View File

@@ -22,31 +22,37 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25
+import com.dmdirc.FrameContainer;
25 26
 import com.dmdirc.Main;
26 27
 import com.dmdirc.ServerManager;
27 28
 import com.dmdirc.actions.ActionManager;
28 29
 import com.dmdirc.actions.CoreActionType;
29 30
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
30
-import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
31 31
 import com.dmdirc.addons.ui_swing.components.SplitPane;
32
-import com.dmdirc.addons.ui_swing.components.desktopPane.DMDircDesktopPane;
32
+import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
33
+import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
33 34
 import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
35
+import com.dmdirc.addons.ui_swing.dialogs.ConfirmQuitDialog;
34 36
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
35 37
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
36 38
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
39
+import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
37 40
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
38 41
 import com.dmdirc.config.IdentityManager;
39 42
 import com.dmdirc.interfaces.ConfigChangeListener;
43
+import com.dmdirc.interfaces.FrameInfoListener;
44
+import com.dmdirc.interfaces.SelectionListener;
40 45
 import com.dmdirc.logger.ErrorLevel;
41 46
 import com.dmdirc.logger.Logger;
42 47
 import com.dmdirc.ui.CoreUIUtils;
43 48
 import com.dmdirc.ui.IconManager;
49
+import com.dmdirc.ui.WindowManager;
44 50
 import com.dmdirc.ui.interfaces.MainWindow;
45 51
 import com.dmdirc.ui.interfaces.Window;
52
+import com.dmdirc.util.QueuedLinkedHashSet;
46 53
 import com.dmdirc.util.ReturnableThread;
47 54
 
48 55
 import java.awt.Dimension;
49
-import java.awt.Dialog.ModalityType;
50 56
 import java.awt.event.WindowEvent;
51 57
 import java.awt.event.WindowFocusListener;
52 58
 import java.awt.event.WindowListener;
@@ -57,6 +63,7 @@ import javax.swing.JFrame;
57 63
 import javax.swing.JPanel;
58 64
 import javax.swing.JSplitPane;
59 65
 import javax.swing.MenuSelectionManager;
66
+import javax.swing.SwingUtilities;
60 67
 import javax.swing.WindowConstants;
61 68
 
62 69
 import net.miginfocom.swing.MigLayout;
@@ -65,7 +72,8 @@ import net.miginfocom.swing.MigLayout;
65 72
  * The main application frame.
66 73
  */
67 74
 public final class MainFrame extends JFrame implements WindowListener,
68
-        MainWindow, ConfigChangeListener {
75
+        MainWindow, ConfigChangeListener, SelectionListener,
76
+        SwingWindowListener, FrameInfoListener {
69 77
 
70 78
     /**
71 79
      * A version number for this class. It should be changed whenever the class
@@ -73,12 +81,16 @@ public final class MainFrame extends JFrame implements WindowListener,
73 81
      * objects being unserialized with the new class).
74 82
      */
75 83
     private static final long serialVersionUID = 9;
84
+    /** Focus queue. */
85
+    private final QueuedLinkedHashSet<TextFrame> focusOrder;
76 86
     /** The main application icon. */
77 87
     private ImageIcon imageIcon;
78 88
     /** The frame manager that's being used. */
79 89
     private FrameManager mainFrameManager;
80
-    /** Dekstop pane. */
81
-    private DMDircDesktopPane desktopPane;
90
+    /** Active frame. */
91
+    private TextFrame activeFrame;
92
+    /** Panel holding frame. */
93
+    private JPanel framePanel;
82 94
     /** Main panel. */
83 95
     private JPanel frameManagerPanel;
84 96
     /** Frame manager position. */
@@ -95,6 +107,8 @@ public final class MainFrame extends JFrame implements WindowListener,
95 107
     private final String version;
96 108
     /** Main split pane. */
97 109
     private SplitPane mainSplitPane;
110
+    /** Frame manager used for ctrl tab frame switching. */
111
+    private final CtrlTabWindowManager frameManager;
98 112
 
99 113
     /**
100 114
      * Creates new form MainFrame.
@@ -106,9 +120,11 @@ public final class MainFrame extends JFrame implements WindowListener,
106 120
 
107 121
         this.controller = controller;
108 122
 
123
+        focusOrder = new QueuedLinkedHashSet<TextFrame>();
109 124
         initComponents();
110 125
 
111
-        imageIcon = new ImageIcon(IconManager.getIconManager().getImage("icon"));
126
+        imageIcon = new ImageIcon(IconManager.getIconManager()
127
+                .getImage("icon"));
112 128
         setIconImage(imageIcon.getImage());
113 129
 
114 130
         CoreUIUtils.centreWindow(this);
@@ -149,8 +165,11 @@ public final class MainFrame extends JFrame implements WindowListener,
149 165
                 MenuSelectionManager.defaultManager().clearSelectedPath();
150 166
             }
151 167
         });
168
+        WindowManager.addSelectionListener(this);
169
+        controller.getWindowFactory().addWindowListener(this);
152 170
 
153 171
         setTitle(getTitlePrefix());
172
+        frameManager = new CtrlTabWindowManager(controller, rootPane);
154 173
     }
155 174
 
156 175
     /**
@@ -207,12 +226,12 @@ public final class MainFrame extends JFrame implements WindowListener,
207 226
             /** {@inheritDoc} */
208 227
             @Override
209 228
             public void run() {
210
-                setObject(desktopPane.getSelectedWindow());
229
+                setObject(activeFrame);
211 230
             }
212 231
         });
213 232
     }
214 233
 
215
-    /** {@inheritDoc */
234
+    /** {@inheritDoc} */
216 235
     @Override
217 236
     public MenuBar getJMenuBar() {
218 237
         return (MenuBar) super.getJMenuBar();
@@ -227,8 +246,7 @@ public final class MainFrame extends JFrame implements WindowListener,
227 246
     /** {@inheritDoc}. */
228 247
     @Override
229 248
     public void setTitle(final String title) {
230
-        if (title != null && getActiveFrame() != null && getActiveFrame().
231
-                isMaximum()) {
249
+        if (title != null && getActiveFrame() != null) {
232 250
             super.setTitle(getTitlePrefix() + " - " + title);
233 251
         } else {
234 252
             super.setTitle(getTitlePrefix());
@@ -241,31 +259,15 @@ public final class MainFrame extends JFrame implements WindowListener,
241 259
         return "DMDirc" + (showVersion ? " " + version : "");
242 260
     }
243 261
 
244
-    /** {@inheritDoc}. */
245
-    @Override
246
-    public boolean getMaximised() {
247
-        return UIUtilities.invokeAndWait(new ReturnableThread<Boolean>() {
248
-
249
-            /** {@inheritDoc}. */
250
-            @Override
251
-            public void run() {
252
-                final Window window = getActiveFrame();
253
-                if (window == null) {
254
-                    setObject(false);
255
-                } else {
256
-                    setObject(getActiveFrame().isMaximum());
257
-                }
258
-            }
259
-        });
260
-    }
261
-
262 262
     /**
263
-     * Returns the desktop pane for the frame.
263
+     * {@inheritDoc}
264 264
      *
265
-     * @return JDesktopPane for the frame
265
+     * @deprecated MDI is no longer implemented
266 266
      */
267
-    public DMDircDesktopPane getDesktopPane() {
268
-        return desktopPane;
267
+    @Deprecated
268
+    @Override
269
+    public boolean getMaximised() {
270
+        return true;
269 271
     }
270 272
 
271 273
     /**
@@ -401,8 +403,8 @@ public final class MainFrame extends JFrame implements WindowListener,
401 403
     private void initComponents() {
402 404
         statusBar = new SwingStatusBar(controller, this);
403 405
         frameManagerPanel = new JPanel();
404
-        desktopPane = new DMDircDesktopPane(controller, this, controller.
405
-                getDomain());
406
+        activeFrame = null;
407
+        framePanel = new JPanel(new MigLayout("fill, ins 0"));
406 408
         mainSplitPane = new SplitPane(SplitPane.Orientation.HORIZONTAL);
407 409
 
408 410
         initFrameManagers();
@@ -453,7 +455,7 @@ public final class MainFrame extends JFrame implements WindowListener,
453 455
         switch (position) {
454 456
             case TOP:
455 457
                 mainSplitPane.setTopComponent(frameManagerPanel);
456
-                mainSplitPane.setBottomComponent(desktopPane);
458
+                mainSplitPane.setBottomComponent(framePanel);
457 459
                 mainSplitPane.setResizeWeight(0.0);
458 460
                 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
459 461
                 frameManagerPanel.setPreferredSize(new Dimension(
@@ -462,7 +464,7 @@ public final class MainFrame extends JFrame implements WindowListener,
462 464
                 break;
463 465
             case LEFT:
464 466
                 mainSplitPane.setLeftComponent(frameManagerPanel);
465
-                mainSplitPane.setRightComponent(desktopPane);
467
+                mainSplitPane.setRightComponent(framePanel);
466 468
                 mainSplitPane.setResizeWeight(0.0);
467 469
                 mainSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
468 470
                 frameManagerPanel.setPreferredSize(new Dimension(
@@ -470,7 +472,7 @@ public final class MainFrame extends JFrame implements WindowListener,
470 472
                         "frameManagerSize"), Integer.MAX_VALUE));
471 473
                 break;
472 474
             case BOTTOM:
473
-                mainSplitPane.setTopComponent(desktopPane);
475
+                mainSplitPane.setTopComponent(framePanel);
474 476
                 mainSplitPane.setBottomComponent(frameManagerPanel);
475 477
                 mainSplitPane.setResizeWeight(1.0);
476 478
                 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
@@ -479,7 +481,7 @@ public final class MainFrame extends JFrame implements WindowListener,
479 481
                         getOptionInt("ui", "frameManagerSize")));
480 482
                 break;
481 483
             case RIGHT:
482
-                mainSplitPane.setLeftComponent(desktopPane);
484
+                mainSplitPane.setLeftComponent(framePanel);
483 485
                 mainSplitPane.setRightComponent(frameManagerPanel);
484 486
                 mainSplitPane.setResizeWeight(1.0);
485 487
                 mainSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
@@ -508,31 +510,23 @@ public final class MainFrame extends JFrame implements WindowListener,
508 510
     public void quit(final int exitCode) {
509 511
         if (exitCode == 0 && IdentityManager.getGlobalConfig().getOptionBool(
510 512
                 "ui", "confirmQuit")) {
511
-            new StandardQuestionDialog(this, ModalityType.APPLICATION_MODAL,
512
-                    "Quit confirm",
513
-                    "You are about to quit DMDirc, are you sure?") {
514
-
513
+            final StandardQuestionDialog dialog = new ConfirmQuitDialog(this) {
514
+                
515 515
                 /**
516 516
                  * A version number for this class. It should be changed
517 517
                  * whenever the class structure is changed (or anything else
518 518
                  * that would prevent serialized objects being unserialized
519 519
                  * with the new class).
520 520
                  */
521
-                private static final long serialVersionUID = 1;
521
+                private static final long serialVersionUID = 9;
522 522
 
523 523
                 /** {@inheritDoc} */
524 524
                 @Override
525
-                public boolean save() {
525
+                protected void handleQuit() {
526 526
                     doQuit(exitCode);
527
-                    return true;
528
-                }
529
-
530
-                /** {@inheritDoc} */
531
-                @Override
532
-                public void cancelled() {
533
-                    // Do nothing
534 527
                 }
535
-            }.display();
528
+            };
529
+            dialog.display();
536 530
             return;
537 531
         }
538 532
         doQuit(exitCode);
@@ -543,7 +537,7 @@ public final class MainFrame extends JFrame implements WindowListener,
543 537
      *
544 538
      * @param exitCode Exit code
545 539
      */
546
-    private void doQuit(final int exitCode) {
540
+    public void doQuit(final int exitCode) {
547 541
         this.exitCode = exitCode;
548 542
 
549 543
         new LoggingSwingWorker() {
@@ -575,7 +569,8 @@ public final class MainFrame extends JFrame implements WindowListener,
575 569
         if ("ui".equals(domain)) {
576 570
             if ("lookandfeel".equals(key)) {
577 571
                 controller.updateLookAndFeel();
578
-            } else if ("framemanager".equals(key) || "framemanagerPosition".equals(key)) {
572
+            } else if ("framemanager".equals(key)
573
+                    || "framemanagerPosition".equals(key)) {
579 574
                 UIUtilities.invokeLater(new Runnable() {
580 575
 
581 576
                     /** {@inheritDoc} */
@@ -603,4 +598,72 @@ public final class MainFrame extends JFrame implements WindowListener,
603 598
             });
604 599
         }
605 600
     }
601
+
602
+    /** {@inheritDoc} */
603
+    @Override
604
+    public void selectionChanged(final FrameContainer<?> window) {
605
+        activeFrame = (TextFrame) controller.getWindowFactory()
606
+                .getSwingWindow(window);
607
+        focusOrder.offerAndMove(activeFrame);
608
+        framePanel.setVisible(false);
609
+        framePanel.removeAll();
610
+        if (activeFrame == null) {
611
+            framePanel.add(new JPanel(), "grow");
612
+            setTitle(null);
613
+        } else {
614
+            framePanel.add(activeFrame, "grow");
615
+            setTitle(window.getTitle());
616
+        }
617
+        framePanel.setVisible(true);
618
+    }
619
+
620
+    /** {@inheritDoc} */
621
+    @Override
622
+    public void windowAdded(final Window parent, final Window window) {
623
+        if (activeFrame == null) {
624
+            window.getContainer().activateFrame();
625
+        }
626
+    }
627
+
628
+    /** {@inheritDoc} */
629
+    @Override
630
+    public void windowDeleted(final Window parent, final Window window) {
631
+        focusOrder.remove((TextFrame) window);
632
+        if (activeFrame.equals(window)) {
633
+            activeFrame = null;
634
+            framePanel.setVisible(false);
635
+            framePanel.removeAll();
636
+            framePanel.setVisible(true);
637
+            if (focusOrder.peek() == null) {
638
+                SwingUtilities.invokeLater(new Runnable() {
639
+
640
+                    /** {@inheritDoc} */
641
+                    @Override
642
+                    public void run() {
643
+                        frameManager.scrollUp();
644
+                    }
645
+                });
646
+            } else {
647
+                focusOrder.peek().getContainer().activateFrame();
648
+            }
649
+        }
650
+    }
651
+
652
+    /** {@inheritDoc} */
653
+    @Override
654
+    public void iconChanged(final FrameContainer<?> window, final String icon) {
655
+        //Ignore
656
+    }
657
+
658
+    /** {@inheritDoc} */
659
+    @Override
660
+    public void nameChanged(final FrameContainer<?> window, final String name) {
661
+        //Ignore
662
+    }
663
+
664
+    @Override
665
+    public void titleChanged(final FrameContainer<?> window,
666
+            final String title) {
667
+        setTitle(title);
668
+    }
606 669
 }

+ 4
- 8
src/com/dmdirc/addons/ui_swing/SwingController.java View File

@@ -48,6 +48,7 @@ import com.dmdirc.addons.ui_swing.dialogs.serversetting.ServerSettingsDialog;
48 48
 import com.dmdirc.addons.ui_swing.dialogs.sslcertificate.SSLCertificateDialog;
49 49
 import com.dmdirc.addons.ui_swing.dialogs.updater.SwingUpdaterDialog;
50 50
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
51
+import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
51 52
 import com.dmdirc.addons.ui_swing.wizard.WizardListener;
52 53
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
53 54
 import com.dmdirc.config.Identity;
@@ -824,19 +825,14 @@ public class SwingController extends Plugin implements Serializable,
824 825
     private PreferencesCategory createAdvancedCategory() {
825 826
         final PreferencesCategory advanced = new PluginPreferencesCategory(
826 827
                 getPluginInfo(), "Advanced", "");
827
-        final Map<String, String> options = new HashMap<String, String>();
828
-
829
-        options.put("alwaysShow", "Always show");
830
-        options.put("neverShow", "Never show");
831
-        options.put("showWhenMaximised", "Show only when windows maximised");
832 828
 
833 829
         advanced.addSetting(new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
834 830
                 new NumericalValidator(10, -1), "ui", "frameBufferSize",
835 831
                 "Window buffer size", "The maximum number of lines in a window"
836 832
                 + " buffer"));
837
-        advanced.addSetting(new PreferencesSetting("ui", "mdiBarVisibility",
838
-                "MDI Bar Visibility", "Controls the visibility of the MDI bar",
839
-                options));
833
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
834
+                getDomain(), "mdiBarVisibility",
835
+                "MDI Bar Visibility", "Controls the visibility of the MDI bar"));
840 836
         advanced.addSetting(
841 837
                 new PreferencesSetting(PreferencesType.BOOLEAN, "ui",
842 838
                 "useOneTouchExpandable", "Use one touch expandable split panes?",

+ 1
- 1
src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java View File

@@ -169,7 +169,7 @@ public class SwingWindowFactory implements FrameListener {
169 169
                 }
170 170
 
171 171
                 if (focus) {
172
-                    childWindow.open();
172
+                    childWindow.activateFrame();
173 173
                 }
174 174
             }
175 175
         });

+ 7
- 8
src/com/dmdirc/addons/ui_swing/actions/NextFrameAction.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.actions;
24 24
 
25
-import com.dmdirc.addons.ui_swing.components.desktopPane.DMDircDesktopPane;
25
+import com.dmdirc.addons.ui_swing.components.TreeScroller;
26 26
 
27 27
 import java.awt.event.ActionEvent;
28 28
 
@@ -39,18 +39,17 @@ public class NextFrameAction extends AbstractAction {
39 39
      * objects being unserialized with the new class).
40 40
      */
41 41
     private static final long serialVersionUID = 1;
42
-    /** Desktop pane. */
43
-    private final DMDircDesktopPane desktopPane;
42
+    /** Tree scroller used to go up and down the frame manager. */
43
+    private final TreeScroller manager;
44 44
 
45 45
     /**
46 46
      * Creates a new next frame action.
47 47
      *
48
-     * @param pane Desktop pane
48
+     * @param manager Tree scroller to scroll with
49 49
      */
50
-    public NextFrameAction(final DMDircDesktopPane pane) {
50
+    public NextFrameAction(final TreeScroller manager) {
51 51
         super();
52
-
53
-        desktopPane = pane;
52
+        this.manager = manager;
54 53
     }
55 54
 
56 55
     /**
@@ -60,6 +59,6 @@ public class NextFrameAction extends AbstractAction {
60 59
      */
61 60
     @Override
62 61
     public void actionPerformed(final ActionEvent evt) {
63
-        desktopPane.scrollDown();
62
+        manager.changeFocus(false);
64 63
     }
65 64
 }

+ 7
- 8
src/com/dmdirc/addons/ui_swing/actions/PreviousFrameAction.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.actions;
24 24
 
25
-import com.dmdirc.addons.ui_swing.components.desktopPane.DMDircDesktopPane;
25
+import com.dmdirc.addons.ui_swing.components.TreeScroller;
26 26
 
27 27
 import java.awt.event.ActionEvent;
28 28
 
@@ -39,18 +39,17 @@ public class PreviousFrameAction extends AbstractAction {
39 39
      * objects being unserialized with the new class).
40 40
      */
41 41
     private static final long serialVersionUID = 1;
42
-    /** Desktop pane. */
43
-    private final DMDircDesktopPane desktopPane;
42
+    /** Tree scroller used to go up and down the frame manager. */
43
+    private final TreeScroller manager;
44 44
 
45 45
     /**
46 46
      * Creates a new previous frame action.
47 47
      *
48
-     * @param pane Desktop pane
48
+     * @param manager Tree scroller to scroll with
49 49
      */
50
-    public PreviousFrameAction(final DMDircDesktopPane pane) {
50
+    public PreviousFrameAction(final TreeScroller manager) {
51 51
         super();
52
-
53
-        desktopPane = pane;
52
+        this.manager = manager;
54 53
     }
55 54
 
56 55
     /**
@@ -60,6 +59,6 @@ public class PreviousFrameAction extends AbstractAction {
60 59
      */
61 60
     @Override
62 61
     public void actionPerformed(final ActionEvent evt) {
63
-        desktopPane.scrollUp();
62
+        manager.changeFocus(true);
64 63
     }
65 64
 }

+ 6
- 0
src/com/dmdirc/addons/ui_swing/components/CheckBoxMenuItem.java View File

@@ -35,6 +35,12 @@ import javax.swing.event.ChangeListener;
35 35
  */
36 36
 public class CheckBoxMenuItem extends JCheckBoxMenuItem {
37 37
 
38
+    /**
39
+     * A version number for this class. It should be changed whenever the class
40
+     * structure is changed (or anything else that would prevent serialized
41
+     * objects being unserialized with the new class).
42
+     */
43
+    private static final long serialVersionUID = 1;
38 44
     /** Menu path to use when clicked. */
39 45
     private static MenuElement[] path;
40 46
 

+ 36
- 74
src/com/dmdirc/addons/ui_swing/components/MDIBar.java View File

@@ -1,17 +1,16 @@
1 1
 /*
2
- * 
3 2
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- * 
3
+ *
5 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
6 5
  * of this software and associated documentation files (the "Software"), to deal
7 6
  * in the Software without restriction, including without limitation the rights
8 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 8
  * copies of the Software, and to permit persons to whom the Software is
10 9
  * furnished to do so, subject to the following conditions:
11
- * 
10
+ *
12 11
  * The above copyright notice and this permission notice shall be included in
13 12
  * all copies or substantial portions of the Software.
14
- * 
13
+ *
15 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -27,7 +26,6 @@ import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.addons.ui_swing.MainFrame;
28 27
 import com.dmdirc.addons.ui_swing.SwingController;
29 28
 import com.dmdirc.addons.ui_swing.SwingWindowListener;
30
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
31 29
 import com.dmdirc.config.ConfigManager;
32 30
 import com.dmdirc.config.IdentityManager;
33 31
 import com.dmdirc.interfaces.ConfigChangeListener;
@@ -38,33 +36,36 @@ import com.dmdirc.ui.interfaces.Window;
38 36
 
39 37
 import java.awt.event.ActionEvent;
40 38
 import java.awt.event.ActionListener;
41
-import java.beans.PropertyChangeEvent;
42
-import java.beans.PropertyChangeListener;
43 39
 
44
-import javax.swing.JInternalFrame;
45 40
 import javax.swing.JPanel;
46 41
 import javax.swing.SwingUtilities;
47 42
 
48 43
 import net.miginfocom.swing.MigLayout;
49 44
 
50 45
 /**
51
- * Provides an MDI style bar for restore/minimise/close.
46
+ * Provides an MDI style bar for closing frames.
52 47
  */
53
-public class MDIBar extends JPanel implements SwingWindowListener, SelectionListener,
54
-        PropertyChangeListener, ActionListener, ConfigChangeListener {
48
+public class MDIBar extends JPanel implements SwingWindowListener,
49
+        SelectionListener, ActionListener, ConfigChangeListener {
55 50
 
51
+    /**
52
+     * A version number for this class. It should be changed whenever the class
53
+     * structure is changed (or anything else that would prevent serialized
54
+     * objects being unserialized with the new class).
55
+     */
56 56
     private static final long serialVersionUID = -8028057596226636245L;
57
+    /** Icon size for the close button. */
57 58
     private static final int ICON_SIZE = 12;
58
-    private NoFocusButton closeButton;
59
-    private NoFocusButton minimiseButton;
60
-    private NoFocusButton restoreButton;
61
-    private MainFrame mainFrame;
62
-    private ConfigManager config;
63
-    private String visibility;
64
-    /** Active frame. */
65
-    private Window activeFrame;
66
-    /** Swing controller. */
67
-    private SwingController controller;
59
+    /** Button to close frames. */
60
+    private final NoFocusButton closeButton;
61
+    /** Main frame component bieng shown in. */
62
+    private final MainFrame mainFrame;
63
+    /** Config manager to get settings from. */
64
+    private final ConfigManager config;
65
+    /** Option domain. */
66
+    private final String configDomain;
67
+    /** Are we meant to be visible? */
68
+    private boolean visibility;
68 69
 
69 70
     /**
70 71
      * Instantiates a new MDI bar.
@@ -73,31 +74,25 @@ public class MDIBar extends JPanel implements SwingWindowListener, SelectionList
73 74
      * @param mainFrame Main frame instance
74 75
      */
75 76
     public MDIBar(final SwingController controller, final MainFrame mainFrame) {
77
+        super();
78
+
76 79
         this.mainFrame = mainFrame;
77 80
         this.config = IdentityManager.getGlobalConfig();
78
-        this.controller = controller;
79
-        visibility = config.getOption("ui", "mdiBarVisibility");
81
+        this.configDomain = controller.getDomain();
82
+        visibility = config.getOptionBool(configDomain, "mdiBarVisibility");
80 83
 
81 84
         closeButton = new NoFocusButton(IconManager.getIconManager().
82 85
                 getScaledIcon("close-12", ICON_SIZE, ICON_SIZE));
83
-        minimiseButton = new NoFocusButton(IconManager.getIconManager().
84
-                getScaledIcon("minimise-12", ICON_SIZE, ICON_SIZE));
85
-        restoreButton = new NoFocusButton(IconManager.getIconManager().
86
-                getScaledIcon("maximise-12", ICON_SIZE, ICON_SIZE));
87 86
 
88 87
         setOpaque(false);
89 88
         setLayout(new MigLayout("hmax 17, ins 1 0 0 0, fill"));
90
-        add(minimiseButton, "w 17!, h 17!, right");
91
-        add(restoreButton, "w 17!, h 17!, right");
92 89
         add(closeButton, "w 17!, h 17!, right");
93 90
 
94 91
         controller.getWindowFactory().addWindowListener(this);
95 92
 
96 93
         WindowManager.addSelectionListener(this);
97 94
         closeButton.addActionListener(this);
98
-        minimiseButton.addActionListener(this);
99
-        restoreButton.addActionListener(this);
100
-        config.addChangeListener("ui", "mdiBarVisibility", this);
95
+        config.addChangeListener(configDomain, "mdiBarVisibility", this);
101 96
 
102 97
         check();
103 98
     }
@@ -106,28 +101,19 @@ public class MDIBar extends JPanel implements SwingWindowListener, SelectionList
106 101
     @Override
107 102
     public void setEnabled(final boolean enabled) {
108 103
         closeButton.setEnabled(enabled);
109
-        minimiseButton.setEnabled(enabled);
110
-        restoreButton.setEnabled(enabled);
111 104
     }
112 105
 
106
+    /**
107
+     * Checks whether this MDI bar should be visible and active and sets itself
108
+     * accordingly.
109
+     */
113 110
     private void check() {
114 111
         SwingUtilities.invokeLater(new Runnable() {
115 112
 
116 113
             @Override
117 114
             public void run() {
118
-                boolean show = true;
119
-                if (mainFrame == null) {
120
-                    show = false;
121
-                    return;
122
-                } else if ("alwaysShow".equalsIgnoreCase(visibility)) {
123
-                    show = mainFrame.getDesktopPane().getAllFrames().length > 0;
124
-                } else if ("neverShow".equalsIgnoreCase(visibility)) {
125
-                    show = false;
126
-                } else if ("showWhenMaximised".equalsIgnoreCase(visibility)) {
127
-                    show = mainFrame.getMaximised();
128
-                }
129
-                setVisible(show);
130
-                setEnabled(mainFrame.getDesktopPane().getAllFrames().length > 0);
115
+                setVisible(visibility);
116
+                setEnabled(mainFrame.getActiveFrame() != null);
131 117
             }
132 118
         });
133 119
     }
@@ -135,31 +121,12 @@ public class MDIBar extends JPanel implements SwingWindowListener, SelectionList
135 121
     /** {@inheritDoc} */
136 122
     @Override
137 123
     public void windowAdded(final Window parent, final Window window) {
138
-        ((JInternalFrame) window).addPropertyChangeListener(
139
-                "maximum", this);
140
-
141 124
         check();
142 125
     }
143 126
 
144 127
     /** {@inheritDoc} */
145 128
     @Override
146 129
     public void windowDeleted(final Window parent, final Window window) {
147
-        ((JInternalFrame) window).removePropertyChangeListener(
148
-                this);
149
-
150
-        check();
151
-    }
152
-
153
-    /** {@inheritDoc} */
154
-    @Override
155
-    public void propertyChange(final PropertyChangeEvent evt) {
156
-        if ((Boolean) evt.getNewValue()) {
157
-            restoreButton.setIcon(IconManager.getIconManager().getScaledIcon(
158
-                    "restore-12", ICON_SIZE, ICON_SIZE));
159
-        } else {
160
-            restoreButton.setIcon(IconManager.getIconManager().getScaledIcon(
161
-                    "maximise-12", ICON_SIZE, ICON_SIZE));
162
-        }
163 130
         check();
164 131
     }
165 132
 
@@ -170,29 +137,24 @@ public class MDIBar extends JPanel implements SwingWindowListener, SelectionList
170 137
      */
171 138
     @Override
172 139
     public void actionPerformed(final ActionEvent e) {
173
-        if (activeFrame == null) {
140
+        if (mainFrame.getActiveFrame() == null) {
174 141
             return;
175 142
         }
176 143
         if (closeButton.equals(e.getSource())) {
177
-            activeFrame.close();
178
-        } else if (minimiseButton.equals(e.getSource())) {
179
-            ((TextFrame) activeFrame).minimise();
180
-        } else if (restoreButton.equals(e.getSource())) {
181
-            activeFrame.toggleMaximise();
144
+            mainFrame.getActiveFrame().close();
182 145
         }
183 146
     }
184 147
 
185 148
     /** {@inheritDoc} */
186 149
     @Override
187 150
     public void configChanged(final String domain, final String key) {
188
-        visibility = config.getOption("ui", "mdiBarVisibility");
151
+        visibility = config.getOptionBool(configDomain, "mdiBarVisibility");
189 152
         check();
190 153
     }
191 154
 
192 155
     /** {@inheritDoc} */
193 156
     @Override
194 157
     public void selectionChanged(final FrameContainer<?> window) {
195
-        activeFrame = controller.getWindowFactory().getSwingWindow(window);
196 158
         check();
197 159
     }
198 160
 }

+ 3
- 1
src/com/dmdirc/addons/ui_swing/components/TreeScroller.java View File

@@ -122,7 +122,9 @@ public class TreeScroller implements MouseWheelListener {
122 122
      * Removes this tree scroller from the tree.
123 123
      */
124 124
     public void unregister() {
125
-        tree.removeMouseWheelListener(this);
125
+        if (tree != null) {
126
+            tree.removeMouseWheelListener(this);
127
+        }
126 128
     }
127 129
 
128 130
     /**

+ 0
- 471
src/com/dmdirc/addons/ui_swing/components/desktopPane/DMDircDesktopPane.java View File

@@ -1,471 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.components.desktopPane;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.addons.ui_swing.BackgroundOption;
27
-import com.dmdirc.addons.ui_swing.MainFrame;
28
-import com.dmdirc.addons.ui_swing.SwingController;
29
-import com.dmdirc.addons.ui_swing.SwingWindowListener;
30
-import com.dmdirc.addons.ui_swing.UIUtilities;
31
-import com.dmdirc.addons.ui_swing.components.TreeScroller;
32
-import com.dmdirc.addons.ui_swing.components.frames.InputTextFrame;
33
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
34
-import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewModel;
35
-import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewNode;
36
-import com.dmdirc.addons.ui_swing.framemanager.windowmenu.JInternalFrameComparator;
37
-import com.dmdirc.config.IdentityManager;
38
-import com.dmdirc.interfaces.ConfigChangeListener;
39
-import com.dmdirc.interfaces.SelectionListener;
40
-import com.dmdirc.logger.ErrorLevel;
41
-import com.dmdirc.logger.Logger;
42
-import com.dmdirc.ui.interfaces.Window;
43
-import com.dmdirc.util.ReturnableThread;
44
-import com.dmdirc.util.URLBuilder;
45
-
46
-import java.awt.Graphics;
47
-import java.awt.Graphics2D;
48
-import java.awt.Image;
49
-import java.beans.PropertyChangeEvent;
50
-import java.beans.PropertyChangeListener;
51
-import java.io.IOException;
52
-import java.net.URL;
53
-import java.util.Arrays;
54
-import java.util.HashMap;
55
-import java.util.Map;
56
-import java.util.Stack;
57
-import java.util.concurrent.atomic.AtomicBoolean;
58
-import javax.imageio.ImageIO;
59
-
60
-import javax.swing.BorderFactory;
61
-import javax.swing.JComponent;
62
-import javax.swing.JDesktopPane;
63
-import javax.swing.JInternalFrame;
64
-import javax.swing.UIManager;
65
-import javax.swing.plaf.DesktopPaneUI;
66
-import javax.swing.tree.DefaultTreeSelectionModel;
67
-import javax.swing.tree.TreeNode;
68
-import javax.swing.tree.TreePath;
69
-import javax.swing.tree.TreeSelectionModel;
70
-
71
-/**
72
- * DMDirc Extentions to JDesktopPane.
73
- */
74
-public class DMDircDesktopPane extends JDesktopPane implements
75
-        SwingWindowListener, SelectionListener, PropertyChangeListener,
76
-        ConfigChangeListener {
77
-
78
-    /**
79
-     * A version number for this class. It should be changed whenever the class
80
-     * structure is changed (or anything else that would prevent serialized
81
-     * objects being unserialized with the new class).
82
-     */
83
-    private static final long serialVersionUID = 1;
84
-    /** The current number of pixels to displace new frames in the X
85
-     * direction. */
86
-    private int xOffset;
87
-    /** The current number of pixels to displace new frames in the Y
88
-     * direction. */
89
-    private int yOffset;
90
-    /** The number of pixels each new internal frame is offset by. */
91
-    private static final int FRAME_OPENING_OFFSET = 30;
92
-    /** Node storage, used for adding and deleting nodes correctly. */
93
-    private final Map<Window, TreeViewNode> nodes;
94
-    /** Data model. */
95
-    private final TreeViewModel model;
96
-    /** Selected model. */
97
-    private final TreeSelectionModel selectionModel;
98
-    /** Tree Scroller. */
99
-    private final TreeScroller treeScroller;
100
-    /** Selected window. */
101
-    private Window selectedWindow;
102
-    /** Maximised state. */
103
-    private boolean maximised;
104
-    /** Changing maximisation. */
105
-    private final AtomicBoolean changing = new AtomicBoolean(false);
106
-    /** Main Frame. */
107
-    private final MainFrame mainFrame;
108
-    /** Background image. */
109
-    private Image backgroundImage;
110
-    /** Background image option. */
111
-    private BackgroundOption backgroundOption;
112
-    /** Config domain. */
113
-    private final String domain;
114
-    /** Swing controller. */
115
-    private final SwingController controller;
116
-
117
-    /**
118
-     * Initialises the DMDirc desktop pane.
119
-     *
120
-     * @param controller The controller that owns this desktop pane
121
-     * @param mainFrame Main frame
122
-     * @param domain Config domain
123
-     */
124
-    public DMDircDesktopPane(final SwingController controller,
125
-            final MainFrame mainFrame, final String domain) {
126
-        super();
127
-
128
-        this.mainFrame = mainFrame;
129
-        this.domain = domain;
130
-        this.controller = controller;
131
-        setBackground(UIManager.getColor("Panel.background"));
132
-        setBorder(BorderFactory.createEtchedBorder());
133
-
134
-        nodes = new HashMap<Window, TreeViewNode>();
135
-        model = new TreeViewModel(new TreeViewNode(null, null));
136
-        selectionModel = new DefaultTreeSelectionModel();
137
-        treeScroller = new TreeScroller(model, selectionModel, false) {
138
-
139
-            /** {@inheritDoc} */
140
-            @Override
141
-            protected void setPath(final TreePath path) {
142
-                super.setPath(path);
143
-                ((TreeViewNode) path.getLastPathComponent()).getWindow().
144
-                        activateFrame();
145
-            }
146
-        };
147
-
148
-        controller.getWindowFactory().addWindowListener(this);
149
-
150
-        IdentityManager.getGlobalConfig().addChangeListener(domain,
151
-                "desktopbackground", this);
152
-        IdentityManager.getGlobalConfig().addChangeListener(domain,
153
-                "desktopbackgroundoption", this);
154
-
155
-        updateCachedSettings();
156
-    }
157
-
158
-    /** {@inheritDoc} */
159
-    @Override
160
-    public void paintComponent(final Graphics g) {
161
-        if (backgroundImage == null) {
162
-            super.paintComponent(g);
163
-        } else {
164
-            UIUtilities.paintBackground((Graphics2D) g, getBounds(),
165
-                    backgroundImage, backgroundOption);
166
-        }
167
-    }
168
-
169
-    /** {@inheritDoc} */
170
-    @Override
171
-    public void setUI(final DesktopPaneUI ui) {
172
-        if (ui instanceof ProxyDesktopPaneUI) {
173
-            super.setUI(ui);
174
-        } else {
175
-            super.setUI(new ProxyDesktopPaneUI(ui, this));
176
-        }
177
-    }
178
-
179
-    /**
180
-     * Add a specified component at the specified index.
181
-     *
182
-     * @param comp Component to add
183
-     * @param index Index for insertion
184
-     */
185
-    public void add(final JComponent comp, final int index) {
186
-        addImpl(comp, null, index);
187
-
188
-        // Make sure it'll fit with our offsets
189
-        if (comp.getWidth() + xOffset > getWidth()) {
190
-            xOffset = 0;
191
-        }
192
-        if (comp.getHeight() + yOffset > getHeight()) {
193
-            yOffset = 0;
194
-        }
195
-
196
-        // Position the frame
197
-        comp.setLocation(xOffset, yOffset);
198
-
199
-        // Increase the offsets
200
-        xOffset += FRAME_OPENING_OFFSET;
201
-        yOffset += FRAME_OPENING_OFFSET;
202
-    }
203
-
204
-    /**
205
-     * Arranges the windows in the specified number of rows and columns.
206
-     *
207
-     * @param windows Windows to arranges
208
-     * @param columns Number of columns to use
209
-     * @param rows Number of rows to use
210
-     */
211
-    private void tileWindows(final JInternalFrame[] windows, final int columns,
212
-            final int rows) {
213
-        ((TextFrame) windows[0]).restore();
214
-        final int total = windows.length;
215
-        final int windowWidth = getWidth() / columns;
216
-        final int windowHeight = getHeight() / rows;
217
-
218
-        int column = 0;
219
-        int x = 0;
220
-        int y = 0;
221
-        for (int i = 0; i < total; i++) {
222
-            windows[i].setBounds(x, y, windowWidth, windowHeight);
223
-            column++;
224
-            x += windowWidth;
225
-            if (column >= columns) {
226
-                column = 0;
227
-                x = 0;
228
-                y += windowHeight;
229
-            }
230
-        }
231
-    }
232
-
233
-    /**
234
-     * Arranges the windows to be equal size in a grid.
235
-     */
236
-    public void tileWindows() {
237
-        if (getAllFrames().length == 0) {
238
-            return;
239
-        }
240
-        final JInternalFrame[] windows = getAllFrames();
241
-        Arrays.sort(windows, new JInternalFrameComparator());
242
-        final int total = windows.length;
243
-        final int columns = (int) Math.floor(Math.sqrt(total));
244
-        final int rows = (int) (Math.ceil(((double) total) / columns));
245
-        tileWindows(windows, columns, rows);
246
-    }
247
-
248
-    /**
249
-     * Arranges the windows to be equal size in a horizontal row.
250
-     */
251
-    public void tileHorizontally() {
252
-        if (getAllFrames().length == 0) {
253
-            return;
254
-        }
255
-        final JInternalFrame[] windows = getAllFrames();
256
-        Arrays.sort(windows, new JInternalFrameComparator());
257
-        tileWindows(windows, 1, windows.length);
258
-    }
259
-
260
-    /**
261
-     * Arranges the windows to be equal size in a vertical row.
262
-     */
263
-    public void tileVertically() {
264
-        if (getAllFrames().length == 0) {
265
-            return;
266
-        }
267
-        final JInternalFrame[] windows = getAllFrames();
268
-        Arrays.sort(windows, new JInternalFrameComparator());
269
-        tileWindows(windows, windows.length, 1);
270
-    }
271
-
272
-    /**
273
-     * Returns the select window.
274
-     *
275
-     * @return Selected window, or null.
276
-     */
277
-    public Window getSelectedWindow() {
278
-        return UIUtilities.invokeAndWait(new ReturnableThread<Window>() {
279
-
280
-            /** {@inheritDoc} */
281
-            @Override
282
-            public void run() {
283
-                setObject(selectedWindow);
284
-            }
285
-        });
286
-    }
287
-
288
-    @Override
289
-    public void windowAdded(final Window parent, final Window window) {
290
-        UIUtilities.invokeAndWait(new Runnable() {
291
-
292
-            /** {@inheritDoc} */
293
-            @Override
294
-            public void run() {
295
-                synchronized (nodes) {
296
-                    addWindow(parent == null ? model.getRootNode() : nodes.get(
297
-                            parent), window);
298
-                }
299
-            }
300
-        });
301
-    }
302
-
303
-    /** {@inheritDoc} */
304
-    @Override
305
-    public void windowDeleted(final Window parent, final Window window) {
306
-        UIUtilities.invokeAndWait(new Runnable() {
307
-
308
-            /** {@inheritDoc} */
309
-            @Override
310
-            public void run() {
311
-                remove((JInternalFrame) window);
312
-                if (nodes == null || nodes.get(window) == null) {
313
-                    return;
314
-                }
315
-                final TreeViewNode node = nodes.get(window);
316
-                if (node.getLevel() == 0) {
317
-                    Logger.appError(ErrorLevel.MEDIUM,
318
-                            "delServer triggered for root node"
319
-                            + node.toString(),
320
-                            new IllegalArgumentException());
321
-                } else {
322
-                    model.removeNodeFromParent(nodes.get(window));
323
-                }
324
-                nodes.remove(window);
325
-                window.getContainer().removeSelectionListener(
326
-                        DMDircDesktopPane.this);
327
-                ((TextFrame) window).removePropertyChangeListener(
328
-                        DMDircDesktopPane.this);
329
-                if (getAllFrames().length == 0) {
330
-                    mainFrame.setTitle(null);
331
-                }
332
-            }
333
-        });
334
-    }
335
-
336
-    /**
337
-     * Adds a window to the frame container.
338
-     *
339
-     * @param parent Parent node
340
-     * @param window Window to add
341
-     */
342
-    public void addWindow(final TreeViewNode parent, final Window window) {
343
-        UIUtilities.invokeAndWait(new Runnable() {
344
-
345
-            /** {@inheritDoc} */
346
-            @Override
347
-            public void run() {
348
-                add((JInternalFrame) window, getAllFrames().length - 1);
349
-                final TreeViewNode node = new TreeViewNode(null, window.
350
-                        getContainer());
351
-                synchronized (nodes) {
352
-                    nodes.put(window, node);
353
-                }
354
-                node.setUserObject(window);
355
-                model.insertNodeInto(node, parent);
356
-                window.getContainer().addSelectionListener(
357
-                        DMDircDesktopPane.this);
358
-                ((TextFrame) window).addPropertyChangeListener(
359
-                        DMDircDesktopPane.this);
360
-            }
361
-        });
362
-    }
363
-
364
-    /** Scrolls up. */
365
-    public void scrollUp() {
366
-        treeScroller.changeFocus(true);
367
-    }
368
-
369
-    /** Scrolls down. */
370
-    public void scrollDown() {
371
-        treeScroller.changeFocus(false);
372
-    }
373
-
374
-    /** {@inheritDoc} */
375
-    @Override
376
-    public void selectionChanged(final FrameContainer<?> window) {
377
-        UIUtilities.invokeLater(new Runnable() {
378
-
379
-            /** {@inheritDoc} */
380
-            @Override
381
-            public void run() {
382
-                selectedWindow = controller.getWindowFactory().getSwingWindow(
383
-                        window);
384
-                final TreeNode[] path = model.getPathToRoot(nodes.get(
385
-                        selectedWindow));
386
-                if (path != null && path.length > 0) {
387
-                    selectionModel.setSelectionPath(new TreePath(path));
388
-                }
389
-                if (selectedWindow instanceof InputTextFrame) {
390
-                    ((InputTextFrame) selectedWindow).requestInputFieldFocus();
391
-                }
392
-                mainFrame.setTitle(selectedWindow.getContainer().getTitle());
393
-            }
394
-        });
395
-    }
396
-
397
-    /** {@inheritDoc} */
398
-    @Override
399
-    public void propertyChange(final PropertyChangeEvent evt) {
400
-        if ("title".equals(evt.getPropertyName())) {
401
-            handleTitleEvent((Window) evt.getSource(),
402
-                    ((Window) evt.getSource()).getContainer().getTitle());
403
-        } else if ("maximum".equals(evt.getPropertyName())) {
404
-            handleMaximiseEvent((Boolean) evt.getNewValue(),
405
-                    ((Window) evt.getSource()).getContainer().getTitle());
406
-        }
407
-    }
408
-
409
-    private void handleTitleEvent(final Window window, final String title) {
410
-        if (maximised && window == selectedWindow) {
411
-            mainFrame.setTitle(title);
412
-        } else if (!maximised) {
413
-            mainFrame.setTitle(null);
414
-        }
415
-    }
416
-
417
-    private void handleMaximiseEvent(final boolean isMaximised,
418
-            final String title) {
419
-        if (changing.getAndSet(true)) {
420
-            return;
421
-        }
422
-
423
-        maximised = isMaximised;
424
-        final Stack<JInternalFrame> stack = new Stack<JInternalFrame>();
425
-        stack.addAll(Arrays.asList(getAllFrames()));
426
-
427
-        while (!stack.empty()) {
428
-            final JInternalFrame frame = stack.pop();
429
-            if (isMaximised && !frame.isMaximum()) {
430
-                ((Window) frame).maximise();
431
-            } else if (!isMaximised && frame.isMaximum()) {
432
-                ((Window) frame).restore();
433
-            }
434
-        }
435
-        if (selectedWindow != null) {
436
-            selectedWindow.activateFrame();
437
-        }
438
-        mainFrame.setTitle(isMaximised ? title : null);
439
-        changing.set(false);
440
-    }
441
-
442
-    private void updateCachedSettings() {
443
-        final String backgroundPath = IdentityManager.getGlobalConfig().
444
-                getOption(domain, "desktopbackground");
445
-        UIUtilities.invokeAndWait(new Runnable() {
446
-
447
-            /** {@inheritDoc} */
448
-            @Override
449
-            public void run() {
450
-                try {
451
-                    final URL url = URLBuilder.buildURL(backgroundPath);
452
-                    if (url != null) {
453
-                        backgroundImage = ImageIO.read(url);
454
-                    }
455
-                } catch (IOException ex) {
456
-                    backgroundImage = null;
457
-                }
458
-            }
459
-        });
460
-        backgroundOption = BackgroundOption.valueOf(IdentityManager
461
-                .getGlobalConfig().getOption(domain,
462
-                "desktopbackgroundoption"));
463
-        repaint();
464
-    }
465
-
466
-    /** {@inheritDoc} */
467
-    @Override
468
-    public void configChanged(final String domain, final String key) {
469
-        updateCachedSettings();
470
-    }
471
-}

+ 0
- 93
src/com/dmdirc/addons/ui_swing/components/desktopPane/ProxyDesktopPaneUI.java View File

@@ -1,93 +0,0 @@
1
-/*
2
- *
3
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6
- * of this software and associated documentation files (the "Software"), to deal
7
- * in the Software without restriction, including without limitation the rights
8
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the Software is
10
- * furnished to do so, subject to the following conditions:
11
- *
12
- * The above copyright notice and this permission notice shall be included in
13
- * all copies or substantial portions of the Software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- * SOFTWARE.
22
- */
23
-
24
-package com.dmdirc.addons.ui_swing.components.desktopPane;
25
-
26
-import com.dmdirc.addons.ui_swing.actions.NextFrameAction;
27
-import com.dmdirc.addons.ui_swing.actions.PreviousFrameAction;
28
-
29
-import javax.swing.ActionMap;
30
-import javax.swing.DefaultDesktopManager;
31
-import javax.swing.InputMap;
32
-import javax.swing.JComponent;
33
-import javax.swing.JDesktopPane;
34
-import javax.swing.KeyStroke;
35
-import javax.swing.plaf.DesktopPaneUI;
36
-
37
-/**
38
- * Proxy desktop pane ui, proxies and adds custom key bindings.
39
- */
40
-public class ProxyDesktopPaneUI extends DesktopPaneUI {
41
-
42
-    private final DesktopPaneUI ui;
43
-    private final DMDircDesktopPane desktopPane;
44
-    private InputMap inputMap;
45
-    private ActionMap actionMap;
46
-
47
-    /**
48
-     * Creates a new proxying desktop pane ui.
49
-     *
50
-     * @param ui UI to proxy to
51
-     * @param desktopPane desktop pane to use
52
-     */
53
-    public ProxyDesktopPaneUI(final DesktopPaneUI ui,
54
-            final DMDircDesktopPane desktopPane) {
55
-        super();
56
-
57
-        this.ui = ui;
58
-        this.desktopPane = desktopPane;
59
-        initInputActionMap();
60
-    }
61
-
62
-    private void initInputActionMap() {
63
-        inputMap = new InputMap();
64
-        actionMap = new ActionMap();
65
-
66
-        inputMap.put(KeyStroke.getKeyStroke("ctrl shift pressed TAB"),
67
-                "selectPreviousFrame");
68
-        inputMap.put(KeyStroke.getKeyStroke("ctrl pressed TAB"),
69
-                "selectNextFrame");
70
-
71
-        actionMap.put("selectNextFrame", new NextFrameAction(desktopPane));
72
-        actionMap.put("selectPreviousFrame",
73
-                new PreviousFrameAction(desktopPane));
74
-    }
75
-
76
-    /** @inheritDoc} */
77
-    @Override
78
-    public void installUI(final JComponent c) {
79
-        ui.installUI(c);
80
-        c.setInputMap(JDesktopPane.WHEN_IN_FOCUSED_WINDOW, null);
81
-        c.setInputMap(JDesktopPane.WHEN_FOCUSED, null);
82
-        c.setInputMap(JDesktopPane.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
83
-                inputMap);
84
-        c.setActionMap(actionMap);
85
-        ((JDesktopPane) c).setDesktopManager(new DefaultDesktopManager());
86
-    }
87
-
88
-    /** @inheritDoc} */
89
-    @Override
90
-    public void uninstallUI(final JComponent c) {
91
-        ui.uninstallUI(c);
92
-    }
93
-}

+ 11
- 18
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java View File

@@ -65,16 +65,14 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
65 65
      * objects being unserialized with the new class).
66 66
      */
67 67
     private static final long serialVersionUID = 10;
68
-    /** This channel's command parser. */
69
-    private final CommandParser commandParser;
68
+    /** The channel object that owns this frame. */
69
+    private final Channel parentChannel;
70
+    /** Identity. */
71
+    private final Identity identity;
70 72
     /** split pane. */
71 73
     private SplitPane splitPane;
72 74
     /** popup menu item. */
73 75
     private JMenuItem settingsMI;
74
-    /** The channel object that owns this frame. */
75
-    private final Channel parentChannel;
76
-    /** Identity. */
77
-    private Identity identity;
78 76
     /** Nicklist. */
79 77
     private NickList nicklist;
80 78
     /** Topic bar. */
@@ -104,10 +102,8 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
104 102
                 "shownicklist", this);
105 103
         ActionManager.addListener(this, CoreActionType.CLIENT_CLOSING);
106 104
 
107
-        commandParser = owner.getCommandParser();
108
-
109
-        setInputHandler(new SwingInputHandler(getInputField(), commandParser,
110
-                this));
105
+        setInputHandler(new SwingInputHandler(getInputField(), 
106
+                owner.getCommandParser(), this));
111 107
 
112 108
         identity = IdentityManager.getChannelConfig(getChannel().getServer().
113 109
                 getNetwork(), getChannel().getChannelInfo().getName());
@@ -191,13 +187,12 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
191 187
 
192 188
         splitPane = new SplitPane(SplitPane.Orientation.HORIZONTAL);
193 189
 
194
-        getContentPane().setLayout(new MigLayout(
195
-                "fill, ins 0, hidemode 3, wrap 1"));
190
+        setLayout(new MigLayout("fill, ins 0, hidemode 3, wrap 1"));
196 191
 
197
-        getContentPane().add(topicBar, "growx, pushx");
198
-        getContentPane().add(splitPane, "grow, push");
199
-        getContentPane().add(getSearchBar(), "growx, pushx");
200
-        getContentPane().add(inputPanel, "growx, pushx");
192
+        add(topicBar, "growx");
193
+        add(splitPane, "grow, push");
194
+        add(getSearchBar(), "growx");
195
+        add(inputPanel, "growx");
201 196
 
202 197
         splitPane.setLeftComponent(getTextPane());
203 198
         if (getContainer().getConfigManager().getOptionBool(getController()
@@ -208,8 +203,6 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
208 203
         }
209 204
         splitPane.setResizeWeight(1);
210 205
         splitPane.setDividerLocation(-1);
211
-
212
-        pack();
213 206
     }
214 207
 
215 208
     /**

+ 5
- 8
src/com/dmdirc/addons/ui_swing/components/frames/CustomFrame.java View File

@@ -31,8 +31,6 @@ import net.miginfocom.swing.MigLayout;
31 31
 
32 32
 /**
33 33
  * A very basic custom frame.
34
- * 
35
- * @author chris
36 34
  */
37 35
 public class CustomFrame extends TextFrame {
38 36
 
@@ -49,7 +47,8 @@ public class CustomFrame extends TextFrame {
49 47
      * @param owner The frame container that owns this frame
50 48
      * @param controller Swing controller
51 49
      */
52
-    public CustomFrame(final SwingController controller, final FrameContainer<?> owner) {
50
+    public CustomFrame(final SwingController controller,
51
+            final FrameContainer<?> owner) {
53 52
         super(owner, controller);
54 53
 
55 54
         initComponents();
@@ -59,11 +58,9 @@ public class CustomFrame extends TextFrame {
59 58
      * Initialises components in this frame.
60 59
      */
61 60
     private void initComponents() {
62
-        getContentPane().setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
63
-        getContentPane().add(getTextPane(), "grow, push");
64
-        getContentPane().add(getSearchBar(), "growx, pushx");
65
-
66
-        pack();
61
+        setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
62
+        add(getTextPane(), "grow, push");
63
+        add(getSearchBar(), "growx, pushx");
67 64
     }
68 65
 
69 66
     /** {@inheritDoc} */

+ 9
- 11
src/com/dmdirc/addons/ui_swing/components/frames/CustomInputFrame.java View File

@@ -36,8 +36,6 @@ import net.miginfocom.swing.MigLayout;
36 36
 /**
37 37
  * A custom frame that includes an input field (for use with writable
38 38
  * containers).
39
- * 
40
- * @author chris
41 39
  */
42 40
 public class CustomInputFrame extends InputTextFrame {
43 41
 
@@ -50,7 +48,7 @@ public class CustomInputFrame extends InputTextFrame {
50 48
 
51 49
     /**
52 50
      * Creates a new instance of CustomInputFrame.
53
-     * 
51
+     *
54 52
      * @param owner The frame container that owns this frame
55 53
      * @param controller Swing controller
56 54
      */
@@ -58,7 +56,8 @@ public class CustomInputFrame extends InputTextFrame {
58 56
             final WritableFrameContainer<? extends InputWindow> owner) {
59 57
         super(controller, owner);
60 58
 
61
-        setInputHandler(new SwingInputHandler(getInputField(), owner.getCommandParser(), this));
59
+        setInputHandler(new SwingInputHandler(getInputField(),
60
+                owner.getCommandParser(), this));
62 61
 
63 62
         initComponents();
64 63
     }
@@ -68,19 +67,18 @@ public class CustomInputFrame extends InputTextFrame {
68 67
     @Deprecated
69 68
     @SuppressWarnings("unchecked")
70 69
     public final CommandParser getCommandParser() {
71
-        return ((WritableFrameContainer<? extends InputWindow>) frameParent).getCommandParser();
70
+        return ((WritableFrameContainer<? extends InputWindow>) frameParent)
71
+                .getCommandParser();
72 72
     }
73 73
 
74 74
     /**
75 75
      * Initialises components in this frame.
76 76
      */
77 77
     private void initComponents() {
78
-        getContentPane().setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
79
-        getContentPane().add(getTextPane(), "grow, push");
80
-        getContentPane().add(getSearchBar(), "growx, pushx");
81
-        getContentPane().add(inputPanel, "growx, pushx");
82
-
83
-        pack();
78
+        setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
79
+        add(getTextPane(), "grow, push");
80
+        add(getSearchBar(), "growx, pushx");
81
+        add(inputPanel, "growx, pushx");
84 82
     }
85 83
 
86 84
     /** {@inheritDoc} */

+ 11
- 12
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java View File

@@ -52,7 +52,6 @@ import javax.swing.JLabel;
52 52
 import javax.swing.JPanel;
53 53
 import javax.swing.JPopupMenu;
54 54
 import javax.swing.KeyStroke;
55
-import javax.swing.event.InternalFrameEvent;
56 55
 
57 56
 import net.miginfocom.layout.PlatformDefaults;
58 57
 
@@ -318,7 +317,8 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
318 317
             if (point != null) {
319 318
                 initPopupMenu();
320 319
                 inputFieldPopup.show(this, (int) point.getX(),
321
-                        (int) point.getY() + getTextPane().getHeight() + (int) PlatformDefaults.
320
+                        (int) point.getY() + getTextPane().getHeight()
321
+                        + (int) PlatformDefaults.
322 322
                         getUnitValueX("related").getValue());
323 323
             }
324 324
         }
@@ -339,13 +339,14 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
339 339
         }
340 340
 
341 341
         try {
342
-            //get the contents of the input field and combine it with the clipboard
342
+            //get the contents of the input field and combine it with the
343
+            //clipboard
343 344
             clipboard = (String) Toolkit.getDefaultToolkit().
344 345
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
345 346
             doPaste(clipboard);
346 347
         } catch (IOException ex) {
347
-            Logger.userError(ErrorLevel.LOW, "Unable to get clipboard contents: " + ex.
348
-                    getMessage());
348
+            Logger.userError(ErrorLevel.LOW,
349
+                    "Unable to get clipboard contents: " + ex.getMessage());
349 350
         } catch (UnsupportedFlavorException ex) {
350 351
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
351 352
         }
@@ -479,17 +480,15 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
479 480
         }
480 481
     }
481 482
 
482
-    /**
483
-     * Activates the input field on frame focus. {@inheritDoc}
484
-     *
485
-     * @param event Internal frame event
486
-     */
483
+    /** {@inheritDoc} */
487 484
     @Override
488
-    public void internalFrameActivated(final InternalFrameEvent event) {
489
-        super.internalFrameActivated(event);
485
+    public void activateFrame() {
486
+        super.activateFrame();
490 487
         if (useAwayIndicator && getContainer().getServer() != null) {
491 488
             awayLabel.setVisible(getContainer().getServer().isAway());
492 489
         }
493 490
         inputField.requestFocusInWindow();
494 491
     }
492
+
493
+
495 494
 }

+ 7
- 12
src/com/dmdirc/addons/ui_swing/components/frames/QueryFrame.java View File

@@ -43,12 +43,10 @@ public final class QueryFrame extends InputTextFrame implements QueryWindow {
43 43
      * objects being unserialized with the new class).
44 44
      */
45 45
     private static final long serialVersionUID = 8;
46
-    /** This channel's command parser. */
47
-    private final CommandParser commandParser;
48 46
 
49 47
     /**
50 48
      * Creates a new QueryFrame.
51
-     * 
49
+     *
52 50
      * @param owner Parent Frame container
53 51
      * @param controller Swing controller
54 52
      */
@@ -57,9 +55,8 @@ public final class QueryFrame extends InputTextFrame implements QueryWindow {
57 55
 
58 56
         initComponents();
59 57
 
60
-        commandParser = owner.getCommandParser();
61
-
62
-        setInputHandler(new SwingInputHandler(getInputField(), commandParser, this));
58
+        setInputHandler(new SwingInputHandler(getInputField(),
59
+                owner.getCommandParser(), this));
63 60
     }
64 61
 
65 62
     /** {@inheritDoc} */
@@ -73,12 +70,10 @@ public final class QueryFrame extends InputTextFrame implements QueryWindow {
73 70
      * Initialises components in this frame.
74 71
      */
75 72
     private void initComponents() {
76
-        getContentPane().setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
77
-        getContentPane().add(getTextPane(), "grow, push");
78
-        getContentPane().add(getSearchBar(), "growx, pushx");
79
-        getContentPane().add(inputPanel, "growx, pushx");
80
-
81
-        pack();
73
+        setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
74
+        add(getTextPane(), "grow, push");
75
+        add(getSearchBar(), "growx, pushx");
76
+        add(inputPanel, "growx, pushx");
82 77
     }
83 78
 
84 79
     /** {@inheritDoc} */

+ 14
- 18
src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java View File

@@ -51,14 +51,12 @@ public final class ServerFrame extends InputTextFrame implements ServerWindow,
51 51
      * objects being unserialized with the new class).
52 52
      */
53 53
     private static final long serialVersionUID = 9;
54
-    /** This channel's command parser. */
55
-    private final CommandParser commandParser;
56 54
     /** popup menu item. */
57 55
     private JMenuItem settingsMI;
58 56
 
59 57
     /**
60 58
      * Creates a new ServerFrame.
61
-     * 
59
+     *
62 60
      * @param owner Parent Frame container
63 61
      * @param controller Swing controller
64 62
      */
@@ -66,10 +64,9 @@ public final class ServerFrame extends InputTextFrame implements ServerWindow,
66 64
         super(controller, owner);
67 65
 
68 66
         initComponents();
69
-        
70
-        commandParser = owner.getCommandParser();
71 67
 
72
-        setInputHandler(new SwingInputHandler(getInputField(), commandParser, this));
68
+        setInputHandler(new SwingInputHandler(getInputField(),
69
+                owner.getCommandParser(), this));
73 70
     }
74 71
 
75 72
     /** {@inheritDoc} */
@@ -86,17 +83,15 @@ public final class ServerFrame extends InputTextFrame implements ServerWindow,
86 83
         settingsMI = new JMenuItem("Settings");
87 84
         settingsMI.addActionListener(this);
88 85
 
89
-        getContentPane().setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
90
-        getContentPane().add(getTextPane(), "grow, push");
91
-        getContentPane().add(getSearchBar(), "growx, pushx");
92
-        getContentPane().add(inputPanel, "growx, pushx");
93
-
94
-        pack();
86
+        setLayout(new MigLayout("ins 0, fill, hidemode 3, wrap 1"));
87
+        add(getTextPane(), "grow, push");
88
+        add(getSearchBar(), "growx, pushx");
89
+        add(inputPanel, "growx, pushx");
95 90
     }
96 91
 
97
-    /** 
92
+    /**
98 93
      * {@inheritDoc}.
99
-     * 
94
+     *
100 95
      * @param actionEvent Action event
101 96
      */
102 97
     @Override
@@ -134,7 +129,8 @@ public final class ServerFrame extends InputTextFrame implements ServerWindow,
134 129
     /** {@inheritDoc} */
135 130
     @Override
136 131
     public void addCustomPopupItems(final JPopupMenu popupMenu) {
137
-        if (getContainer().getServer().getState().equals(ServerState.CONNECTED)) {
132
+        if (getContainer().getServer().getState()
133
+                .equals(ServerState.CONNECTED)) {
138 134
             settingsMI.setEnabled(true);
139 135
         } else {
140 136
             settingsMI.setEnabled(false);
@@ -143,7 +139,7 @@ public final class ServerFrame extends InputTextFrame implements ServerWindow,
143 139
         if (popupMenu.getComponentCount() > 0) {
144 140
             popupMenu.addSeparator();
145 141
         }
146
-        
142
+
147 143
         popupMenu.add(settingsMI);
148 144
     }
149 145
 
@@ -151,8 +147,8 @@ public final class ServerFrame extends InputTextFrame implements ServerWindow,
151 147
     @Override
152 148
     public void close() {
153 149
         if (ServerSettingsDialog.hasServerSettingsDialog()) {
154
-            ServerSettingsDialog.getServerSettingsDialog(getContainer().getServer(),
155
-                getController().getMainFrame()).dispose();
150
+            ServerSettingsDialog.getServerSettingsDialog(getContainer()
151
+                    .getServer(), getController().getMainFrame()).dispose();
156 152
         }
157 153
         super.close();
158 154
     }

+ 102
- 483
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java View File

@@ -33,7 +33,6 @@ import com.dmdirc.addons.ui_swing.actions.HyperlinkCopyAction;
33 33
 import com.dmdirc.addons.ui_swing.actions.InputFieldCopyAction;
34 34
 import com.dmdirc.addons.ui_swing.actions.NicknameCopyAction;
35 35
 import com.dmdirc.addons.ui_swing.actions.SearchAction;
36
-import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
37 36
 import com.dmdirc.addons.ui_swing.components.SwingSearchBar;
38 37
 import com.dmdirc.addons.ui_swing.textpane.ClickTypeValue;
39 38
 import com.dmdirc.addons.ui_swing.textpane.MouseEventType;
@@ -54,33 +53,20 @@ import com.dmdirc.commandparser.parsers.GlobalCommandParser;
54 53
 import com.dmdirc.config.ConfigManager;
55 54
 import com.dmdirc.interfaces.ConfigChangeListener;
56 55
 import com.dmdirc.interfaces.FrameCloseListener;
57
-import com.dmdirc.interfaces.FrameInfoListener;
58
-import com.dmdirc.logger.ErrorLevel;
59
-import com.dmdirc.logger.Logger;
60 56
 import com.dmdirc.parser.common.ChannelJoinRequest;
61
-import com.dmdirc.ui.IconManager;
62 57
 import com.dmdirc.ui.interfaces.InputWindow;
63 58
 import com.dmdirc.ui.interfaces.Window;
59
+import com.dmdirc.ui.messages.IRCDocument;
64 60
 import com.dmdirc.util.StringTranscoder;
65 61
 
66
-import java.awt.Container;
67
-import java.awt.Dimension;
68 62
 import java.awt.Point;
69 63
 import java.awt.event.KeyEvent;
70 64
 import java.awt.event.MouseEvent;
71
-import java.beans.PropertyChangeEvent;
72
-import java.beans.PropertyChangeListener;
73
-import java.beans.PropertyVetoException;
74
-import java.lang.reflect.Constructor;
75
-import java.lang.reflect.InvocationTargetException;
76 65
 import java.nio.charset.Charset;
77 66
 import java.nio.charset.IllegalCharsetNameException;
78 67
 import java.nio.charset.UnsupportedCharsetException;
79
-import java.util.logging.Level;
80 68
 
81
-import javax.swing.BorderFactory;
82 69
 import javax.swing.JComponent;
83
-import javax.swing.JInternalFrame;
84 70
 import javax.swing.JMenu;
85 71
 import javax.swing.JMenuItem;
86 72
 import javax.swing.JPanel;
@@ -88,26 +74,15 @@ import javax.swing.JPopupMenu;
88 74
 import javax.swing.JSeparator;
89 75
 import javax.swing.KeyStroke;
90 76
 import javax.swing.SwingUtilities;
91
-import javax.swing.UIManager;
92
-import javax.swing.WindowConstants;
93
-import javax.swing.event.InternalFrameEvent;
94
-import javax.swing.event.InternalFrameListener;
95
-import javax.swing.plaf.basic.BasicInternalFrameUI;
96
-import javax.swing.plaf.synth.SynthLookAndFeel;
97
-
98
-import net.miginfocom.layout.PlatformDefaults;
77
+
99 78
 import net.miginfocom.swing.MigLayout;
100 79
 
101 80
 /**
102 81
  * Implements a generic (internal) frame.
103 82
  */
104
-public abstract class TextFrame extends JInternalFrame implements Window,
105
-        PropertyChangeListener, InternalFrameListener, ConfigChangeListener,
106
-        FrameInfoListener, TextPaneListener, FrameCloseListener {
107
-
108
-    /** Logger to use. */
109
-    private static final java.util.logging.Logger LOGGER =
110
-            java.util.logging.Logger.getLogger(TextFrame.class.getName());
83
+public abstract class TextFrame extends JPanel implements Window,
84
+        ConfigChangeListener, TextPaneListener, FrameCloseListener {
85
+    
111 86
     /**
112 87
      * A version number for this class. It should be changed whenever the class
113 88
      * structure is changed (or anything else that would prevent serialized
@@ -122,16 +97,10 @@ public abstract class TextFrame extends JInternalFrame implements Window,
122 97
     private SwingSearchBar searchBar;
123 98
     /** String transcoder. */
124 99
     private StringTranscoder transcoder;
125
-    /** Are we closing? */
126
-    private boolean closing = false;
127 100
     /** Command parser for popup commands. */
128 101
     private final CommandParser commandParser;
129 102
     /** Swing controller. */
130 103
     private final SwingController controller;
131
-    /** Are we maximising/restoring? */
132
-    private boolean maximiseRestoreInProgress = false;
133
-    /** Content pane. */
134
-    private final JPanel panel;
135 104
 
136 105
     /**
137 106
      * Creates a new instance of Frame.
@@ -147,9 +116,6 @@ public abstract class TextFrame extends JInternalFrame implements Window,
147 116
 
148 117
         final ConfigManager config = owner.getConfigManager();
149 118
 
150
-        setFrameIcon(IconManager.getIconManager().getIcon(owner.getIcon()));
151
-
152
-        owner.addFrameInfoListener(this);
153 119
         owner.addCloseListener(this);
154 120
         owner.setTitle(frameParent.getTitle());
155 121
 
@@ -167,17 +133,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
167 133
         commandParser = findCommandParser();
168 134
 
169 135
         initComponents();
170
-        setMaximizable(true);
171
-        setClosable(true);
172
-        setResizable(true);
173
-        setIconifiable(true);
174 136
         setFocusable(true);
175
-        setPreferredSize(new Dimension(controller.getMainFrame().getWidth() / 2,
176
-                controller.getMainFrame().getHeight() / 3));
177
-        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
178 137
 
179
-        addPropertyChangeListener("UI", this);
180
-        addInternalFrameListener(this);
181 138
         getTextPane().addTextPaneListener(this);
182 139
 
183 140
         config.addChangeListener("ui", "foregroundcolour", this);
@@ -185,10 +142,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
185 142
         config.addChangeListener("ui", "frameBufferSize", this);
186 143
         updateColours();
187 144
 
188
-        addPropertyChangeListener("maximum", this);
189
-
190
-        panel = new JPanel(new MigLayout("fill"));
191
-        super.getContentPane().add(panel);
145
+        setLayout(new MigLayout("fill"));
192 146
     }
193 147
 
194 148
     /**
@@ -216,90 +170,6 @@ public abstract class TextFrame extends JInternalFrame implements Window,
216 170
         return localParser;
217 171
     }
218 172
 
219
-    /** {@inheritDoc} */
220
-    @Override
221
-    public Container getContentPane() {
222
-        return panel;
223
-    }
224
-
225
-    /**
226
-     * {@inheritDoc}
227
-     *
228
-     * @deprecated Should use {@link FrameContainer#setTitle(java.lang.String)}
229
-     */
230
-    @Override
231
-    @Deprecated
232
-    public void setTitle(final String title) {
233
-        UIUtilities.invokeLater(new Runnable() {
234
-
235
-            /** {@inheritDoc} */
236
-            @Override
237
-            public void run() {
238
-                TextFrame.super.setTitle(title);
239
-            }
240
-        });
241
-    }
242
-
243
-    /**
244
-     * {@inheritDoc}
245
-     *
246
-     * @deprecated Use {@link FrameContainer#getTitle()} instead
247
-     */
248
-    @Override
249
-    @Deprecated
250
-    public String getTitle() {
251
-        return super.getTitle();
252
-    }
253
-
254
-    /** {@inheritDoc} */
255
-    @Override
256
-    @Deprecated
257
-    public void setVisible(final boolean isVisible) {
258
-        UIUtilities.invokeLater(new Runnable() {
259
-
260
-            @Override
261
-            public void run() {
262
-                if (isVisible() && isVisible) {
263
-                    open();
264
-                } else {
265
-                    TextFrame.super.setVisible(isVisible);
266
-                }
267
-            }
268
-        });
269
-    }
270
-
271
-    /** {@inheritDoc} */
272
-    @Override
273
-    public void open() {
274
-        final boolean pref = frameParent.getConfigManager()
275
-                .getOptionBool("ui", "maximisewindows");
276
-        UIUtilities.invokeLater(new Runnable() {
277
-
278
-            @Override
279
-            public void run() {
280
-                if (!isVisible()) {
281
-                    TextFrame.super.setVisible(true);
282
-                }
283
-                try {
284
-                    if ((pref || controller.getMainFrame().getMaximised())
285
-                            && !isMaximum()) {
286
-                        setMaximum(true);
287
-                    }
288
-                } catch (PropertyVetoException ex) {
289
-                    //Ignore
290
-                }
291
-
292
-                try {
293
-                    if (!isSelected()) {
294
-                        setSelected(true);
295
-                    }
296
-                } catch (PropertyVetoException ex) {
297
-                    //Ignore
298
-                }
299
-            }
300
-        });
301
-    }
302
-
303 173
     /** {@inheritDoc} */
304 174
     @Override
305 175
     public void activateFrame() {
@@ -307,20 +177,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
307 177
 
308 178
             @Override
309 179
             public void run() {
310
-                try {
311
-                    if (isIcon()) {
312
-                        setIcon(false);
313
-                    }
314
-                    setMaximum(controller.getMainFrame().getMaximised());
315
-                    if (!isVisible()) {
316
-                        TextFrame.super.setVisible(true);
317
-                    }
318
-                    if (!isSelected()) {
319
-                        setSelected(true);
320
-                    }
321
-                } catch (PropertyVetoException ex) {
322
-                    //Ignore
323
-                }
180
+                frameParent.windowActivated();
324 181
             }
325 182
         });
326 183
     }
@@ -332,122 +189,53 @@ public abstract class TextFrame extends JInternalFrame implements Window,
332 189
 
333 190
             @Override
334 191
             public void run() {
335
-                if (closing) {
336
-                    return;
337
-                }
338
-
339
-                closing = true;
340
-
341
-                try {
342
-                    if (!isClosed()) {
343
-                        setClosed(true);
344
-                    }
345
-                } catch (PropertyVetoException ex) {
346
-                    Logger.userError(ErrorLevel.LOW, "Unable to close frame");
347
-                }
348
-
192
+                frameParent.handleWindowClosing();
349 193
             }
350 194
         });
351 195
     }
352 196
 
353
-    /** {@inheritDoc} */
197
+    /**
198
+     * {@inheritDoc}
199
+     *
200
+     * @deprecated MDI has been removed, these methods are useless
201
+     */
202
+    @Deprecated
354 203
     @Override
355 204
     public void minimise() {
356
-        UIUtilities.invokeLater(new Runnable() {
357
-
358
-            @Override
359
-            public void run() {
360
-                try {
361
-                    if (!isIcon()) {
362
-                        setIcon(true);
363
-                    }
364
-                } catch (PropertyVetoException ex) {
365
-                    Logger.userError(ErrorLevel.LOW,
366
-                            "Unable to minimise frame");
367
-                }
368
-            }
369
-        });
205
+        //Ignore
370 206
     }
371 207
 
372
-    /** {@inheritDoc} */
208
+    /**
209
+     * {@inheritDoc}
210
+     *
211
+     * @deprecated MDI has been removed, these methods are useless
212
+     */
213
+    @Deprecated
373 214
     @Override
374 215
     public void maximise() {
375
-        LOGGER.finest("maximise(): About to invokeAndWait");
376
-
377
-        UIUtilities.invokeLater(new Runnable() {
378
-
379
-            /** {@inheritDoc} */
380
-            @Override
381
-            public void run() {
382
-                LOGGER.finest("maximise(): Running");
383
-
384
-                try {
385
-                    if (isMaximum()) {
386
-                        return;
387
-                    }
388
-
389
-                    maximiseRestoreInProgress = true;
390
-                    LOGGER.finest("maximise(): About to set icon");
391
-                    if (isIcon()) {
392
-                        setIcon(false);
393
-                    }
394
-                    LOGGER.finest("maximise(): About to set maximum");
395
-                    setMaximum(true);
396
-                    LOGGER.finest("maximise(): Done?");
397
-                } catch (PropertyVetoException ex) {
398
-                    Logger.userError(ErrorLevel.LOW,
399
-                            "Unable to minimise frame");
400
-                }
401
-                maximiseRestoreInProgress = false;
402
-
403
-                LOGGER.finest("maximise(): Done running");
404
-            }
405
-        });
406
-        LOGGER.finest("maximise(): Done");
216
+        //Ignore
407 217
     }
408 218
 
409
-    /** {@inheritDoc} */
219
+    /**
220
+     * {@inheritDoc}
221
+     *
222
+     * @deprecated MDI has been removed, these methods are useless
223
+     */
224
+    @Deprecated
410 225
     @Override
411 226
     public void restore() {
412
-        UIUtilities.invokeLater(new Runnable() {
413
-
414
-            /** {@inheritDoc} */
415
-            @Override
416
-            public void run() {
417
-                try {
418
-                    if (!isMaximum()) {
419
-                        return;
420
-                    }
421
-
422
-                    maximiseRestoreInProgress = true;
423
-                    if (isIcon()) {
424
-                        setIcon(false);
425
-                    }
426
-                    setMaximum(false);
427
-                } catch (PropertyVetoException ex) {
428
-                    Logger.userError(ErrorLevel.LOW,
429
-                            "Unable to minimise frame");
430
-                }
431
-                maximiseRestoreInProgress = false;
432
-            }
433
-        });
227
+        //Ignore
434 228
     }
435 229
 
436
-    /** {@inheritDoc} */
230
+    /**
231
+     * {@inheritDoc}
232
+     *
233
+     * @deprecated MDI has been removed, these methods are useless
234
+     */
235
+    @Deprecated
437 236
     @Override
438 237
     public void toggleMaximise() {
439
-        UIUtilities.invokeLater(new Runnable() {
440
-
441
-            /** {@inheritDoc} */
442
-            @Override
443
-            public void run() {
444
-                if (isMaximum()) {
445
-                    restore();
446
-                } else {
447
-                    maximise();
448
-                }
449
-            }
450
-        });
238
+        //Ignore
451 239
     }
452 240
 
453 241
     /**
@@ -553,205 +341,6 @@ public abstract class TextFrame extends JInternalFrame implements Window,
553 341
         getActionMap().put("endAction", new TextPaneEndAction(getTextPane()));
554 342
     }
555 343
 
556
-    /**
557
-     * Removes and reinserts the border of an internal frame on maximising.
558
-     * {@inheritDoc}
559
-     *
560
-     * @param event Property change event
561
-     */
562
-    @Override
563
-    public final void propertyChange(final PropertyChangeEvent event) {
564
-        LOGGER.log(Level.FINER, "Property change: name: {0}  value: {1} -> {3}"
565
-                , new Object[]{event.getPropertyName(), event.getOldValue(),
566
-                event.getNewValue()});
567
-        if ("UI".equals(event.getPropertyName())) {
568
-            if (isMaximum()) {
569
-                hideTitlebar();
570
-            }
571
-        } else {
572
-            if ((Boolean) event.getNewValue()) {
573
-                hideTitlebar();
574
-            } else {
575
-                showTitlebar();
576
-            }
577
-        }
578
-        LOGGER.finest("Done property change");
579
-    }
580
-
581
-    /** Hides the titlebar for this frame. */
582
-    private void hideTitlebar() {
583
-        UIUtilities.invokeLater(new Runnable() {
584
-
585
-            /** {@inheritDoc} */
586
-            @Override
587
-            public void run() {
588
-                panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
589
-                setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
590
-                ((BasicInternalFrameUI) getUI()).setNorthPane(null);
591
-            }
592
-        });
593
-    }
594
-
595
-    /** Shows the titlebar for this frame. */
596
-    private void showTitlebar() {
597
-        UIUtilities.invokeLater(new Runnable() {
598
-
599
-            /** {@inheritDoc} */
600
-            @Override
601
-            public void run() {
602
-                final Class<?> c;
603
-                Object temp = null;
604
-                Constructor<?> constructor;
605
-
606
-                final String componentUI = (String) UIManager.get(
607
-                        "InternalFrameUI");
608
-
609
-                if ("javax.swing.plaf.synth.SynthLookAndFeel"
610
-                        .equals(componentUI)) {
611
-                    temp = SynthLookAndFeel.createUI(TextFrame.this);
612
-                } else {
613
-                    try {
614
-                        c = getClass().getClassLoader().loadClass(componentUI);
615
-                        constructor = c.getConstructor(new Class[]{
616
-                                    javax.swing.JInternalFrame.class});
617
-                        temp = constructor.newInstance(new Object[]{
618
-                                    TextFrame.this});
619
-                    } catch (ClassNotFoundException ex) {
620
-                        Logger.appError(ErrorLevel.MEDIUM,
621
-                                "Unable to readd titlebar", ex);
622
-                    } catch (NoSuchMethodException ex) {
623
-                        Logger.appError(ErrorLevel.MEDIUM,
624
-                                "Unable to readd titlebar", ex);
625
-                    } catch (InstantiationException ex) {
626
-                        Logger.appError(ErrorLevel.MEDIUM,
627
-                                "Unable to readd titlebar", ex);
628
-                    } catch (IllegalAccessException ex) {
629
-                        Logger.appError(ErrorLevel.MEDIUM,
630
-                                "Unable to readd titlebar", ex);
631
-                    } catch (InvocationTargetException ex) {
632
-                        Logger.appError(ErrorLevel.MEDIUM,
633
-                                "Unable to readd titlebar", ex);
634
-                    }
635
-
636
-                }
637
-
638
-                setBorder(UIManager.getBorder("InternalFrame.border"));
639
-                if (temp == null) {
640
-                    temp = new BasicInternalFrameUI(TextFrame.this);
641
-                }
642
-
643
-                setUI((BasicInternalFrameUI) temp);
644
-                final int size = (int) PlatformDefaults.getPanelInsets(0).
645
-                        getValue();
646
-                panel.setBorder(BorderFactory.createEmptyBorder(size, size,
647
-                        size, size));
648
-            }
649
-        });
650
-    }
651
-
652
-    /**
653
-     * Not needed for this class. {@inheritDoc}
654
-     *
655
-     * @param event Internal frame event
656
-     */
657
-    @Override
658
-    public void internalFrameOpened(final InternalFrameEvent event) {
659
-        //Ignore
660
-    }
661
-
662
-    /**
663
-     * Not needed for this class. {@inheritDoc}
664
-     *
665
-     * @param event Internal frame event
666
-     */
667
-    @Override
668
-    public void internalFrameClosing(final InternalFrameEvent event) {
669
-        new LoggingSwingWorker() {
670
-
671
-            /** {@inheritDoc} */
672
-            @Override
673
-            protected Object doInBackground() {
674
-                frameParent.handleWindowClosing();
675
-                return null;
676
-            }
677
-        }.executeInExecutor();
678
-    }
679
-
680
-    /**
681
-     * Not needed for this class. {@inheritDoc}
682
-     *
683
-     * @param event Internal frame event
684
-     */
685
-    @Override
686
-    public void internalFrameClosed(final InternalFrameEvent event) {
687
-        //Ignore.
688
-    }
689
-
690
-    /**
691
-     * Makes the internal frame invisible. {@inheritDoc}
692
-     *
693
-     * @param event Internal frame event
694
-     */
695
-    @Override
696
-    public void internalFrameIconified(final InternalFrameEvent event) {
697
-        UIUtilities.invokeLater(new Runnable() {
698
-
699
-            @Override
700
-            public void run() {
701
-                event.getInternalFrame().setVisible(false);
702
-            }
703
-        });
704
-    }
705
-
706
-    /**
707
-     * Not needed for this class. {@inheritDoc}
708
-     *
709
-     * @param event Internal frame event
710
-     */
711
-    @Override
712
-    public void internalFrameDeiconified(final InternalFrameEvent event) {
713
-        //Ignore.
714
-    }
715
-
716
-    /**
717
-     * Activates the input field on frame focus. {@inheritDoc}
718
-     *
719
-     * @param event Internal frame event
720
-     */
721
-    @Override
722
-    public void internalFrameActivated(final InternalFrameEvent event) {
723
-        LOGGER.log(Level.FINER, "{0} : internalFrameActivated()",
724
-                new Object[] {getName()});
725
-
726
-        if (maximiseRestoreInProgress) {
727
-            return;
728
-        }
729
-        new LoggingSwingWorker() {
730
-
731
-            /** {@inheritDoc} */
732
-            @Override
733
-            protected Object doInBackground() {
734
-                LOGGER.log(Level.FINER,
735
-                        "{0} : internalFrameActivated(): doInBackground",
736
-                        new Object[]{getName()});
737
-                frameParent.windowActivated();
738
-                return null;
739
-            }
740
-        }.executeInExecutor();
741
-    }
742
-
743
-    /**
744
-     * Not needed for this class. {@inheritDoc}
745
-     *
746
-     * @param event Internal frame event
747
-     */
748
-    @Override
749
-    public void internalFrameDeactivated(final InternalFrameEvent event) {
750
-        if (maximiseRestoreInProgress) {
751
-            return;
752
-        }
753
-    }
754
-
755 344
     /** {@inheritDoc} */
756 345
     @Override
757 346
     public FrameContainer<?> getContainer() {
@@ -1019,7 +608,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
1019 608
     /** {@inheritDoc} */
1020 609
     @Override
1021 610
     public void configChanged(final String domain, final String key) {
1022
-        if (getConfigManager() == null || getTextPane() == null) {
611
+        if (getContainer().getConfigManager() == null
612
+                || getTextPane() == null) {
1023 613
             return;
1024 614
         }
1025 615
 
@@ -1031,59 +621,88 @@ public abstract class TextFrame extends JInternalFrame implements Window,
1031 621
 
1032 622
     /** {@inheritDoc} */
1033 623
     @Override
1034
-    public void iconChanged(final FrameContainer<?> window, final String icon) {
1035
-        UIUtilities.invokeLater(new Runnable() {
1036
-
1037
-            /** {@inheritDoc} */
1038
-            @Override
1039
-            public void run() {
1040
-                setFrameIcon(IconManager.getIconManager().getIcon(icon));
1041
-            }
1042
-        });
624
+    public void windowClosing(final FrameContainer<?> window) {
625
+        setVisible(false);
1043 626
     }
1044 627
 
1045 628
     /** {@inheritDoc} */
1046 629
     @Override
1047
-    public void nameChanged(final FrameContainer<?> window,
1048
-            final String name) {
1049
-        //Ignore
630
+    public SwingController getController() {
631
+        return controller;
1050 632
     }
1051 633
 
1052
-    /** {@inheritDoc} */
634
+    /**
635
+     * Updates colour settings from their config values.
636
+     */
637
+    private void updateColours() {
638
+        getTextPane().setForeground(getConfigManager().
639
+                        getOptionColour("ui", "foregroundcolour"));
640
+        getTextPane().setBackground(getConfigManager().
641
+                        getOptionColour("ui", "backgroundcolour"));
642
+    }
643
+
644
+
645
+
646
+    /**
647
+     * {@inheritDoc}
648
+     *
649
+     * @deprecated Use {@link FrameContainer#getTitle()} instead
650
+     */
651
+    @Deprecated
1053 652
     @Override
1054
-    public void titleChanged(final FrameContainer<?> window,
1055
-            final String title) {
1056
-        UIUtilities.invokeLater(new Runnable() {
653
+    public String getTitle() {
654
+        return getContainer().getTitle();
655
+    }
1057 656
 
1058
-            /** {@inheritDoc} */
1059
-            @Override
1060
-            public void run() {
1061
-                // TODO: Can be changed back to setTitle once the deprecated
1062
-                // method is removed
1063
-                TextFrame.super.setTitle(title);
1064
-            }
1065
-        });
657
+    /**
658
+     * {@inheritDoc}
659
+     *
660
+     * @deprecated MDI is no longer implemented, windows are always maximised.
661
+     */
662
+    @Override
663
+    @Deprecated
664
+    public boolean isMaximum() {
665
+        return true;
1066 666
     }
1067 667
 
1068
-    /** {@inheritDoc} */
668
+    /**
669
+     * {@inheritDoc}
670
+     *
671
+     * @deprecated Should use {@link FrameContainer#setTitle(java.lang.String)}
672
+     */
673
+    @Deprecated
1069 674
     @Override
1070
-    public void windowClosing(final FrameContainer<?> window) {
1071
-        setVisible(false);
675
+    public void setTitle(final String title) {
676
+        getContainer().setTitle(title);
1072 677
     }
1073 678
 
1074 679
     /** {@inheritDoc} */
1075 680
     @Override
1076
-    public SwingController getController() {
1077
-        return controller;
681
+    public void open() {
682
+        //Yay, we're open.
1078 683
     }
1079 684
 
1080 685
     /**
1081
-     * Updates colour settings from their config values.
686
+     * {@inheritDoc}
687
+     *
688
+     * @deprecated Should not be used outside the UI, can be removed when the
689
+     * interface method is removed
1082 690
      */
1083
-    private void updateColours() {
1084
-        getTextPane().setForeground(getConfigManager().
1085
-                        getOptionColour("ui", "foregroundcolour"));
1086
-        getTextPane().setBackground(getConfigManager().
1087
-                        getOptionColour("ui", "backgroundcolour"));
691
+    @Deprecated
692
+    @Override
693
+    public void setVisible(final boolean visible) {
694
+        super.setVisible(visible);
695
+    }
696
+
697
+    /**
698
+     * {@inheritDoc}
699
+     *
700
+     * @deprecated Should not be used outside the UI, can be removed when the
701
+     * interface method is removed
702
+     */
703
+    @Deprecated
704
+    @Override
705
+    public boolean isVisible() {
706
+        return super.isVisible();
1088 707
     }
1089 708
 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java View File

@@ -96,7 +96,7 @@ public class MenuBar extends JMenuBar {
96 96
         JMenu menu = null;
97 97
         for (int i = 0; i < getMenuCount(); i++) {
98 98
             menu = getMenu(i);
99
-            if (menu instanceof JMenu && menu.getText().equals(parentMenu)) {
99
+            if (menu != null && menu.getText().equals(parentMenu)) {
100 100
                 break;
101 101
             }
102 102
             menu = null;

+ 66
- 0
src/com/dmdirc/addons/ui_swing/dialogs/ConfirmQuitDialog.java View File

@@ -0,0 +1,66 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+package com.dmdirc.addons.ui_swing.dialogs;
23
+
24
+import java.awt.Window;
25
+
26
+/**
27
+ * A simple dialog to confirm and handle the quitting of the client.
28
+ */
29
+public abstract class ConfirmQuitDialog extends StandardQuestionDialog {
30
+
31
+    /**
32
+     * A version number for this class. It should be changed
33
+     * whenever the class structure is changed (or anything else
34
+     * that would prevent serialized objects being unserialized
35
+     * with the new class).
36
+     */
37
+    private static final long serialVersionUID = 1;
38
+
39
+    /**
40
+     * Creates a new client quit confirmation dialog.
41
+     *
42
+     * @param window Parent window
43
+     */
44
+    public ConfirmQuitDialog(final Window window) {
45
+        super(window, ModalityType.APPLICATION_MODAL, "Quit confirm",
46
+                    "You are about to quit DMDirc, are you sure?");
47
+    }
48
+
49
+    /** {@inheritDoc} */
50
+    @Override
51
+    public boolean save() {
52
+        handleQuit();
53
+        return true;
54
+    }
55
+
56
+    /** {@inheritDoc} */
57
+    @Override
58
+    public void cancelled() {
59
+        // Do nothing
60
+    }
61
+
62
+    /**
63
+     * Called when the user confirms they wish to quit the client.
64
+     */
65
+    protected abstract void handleQuit();
66
+}

+ 15
- 3
src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.ui.CoreUIUtils;
26 27
 
27 28
 import java.awt.Component;
@@ -31,6 +32,7 @@ import java.awt.Frame;
31 32
 import java.awt.Window;
32 33
 import java.awt.event.WindowAdapter;
33 34
 import java.awt.event.WindowEvent;
35
+import java.util.concurrent.Semaphore;
34 36
 
35 37
 import javax.swing.JButton;
36 38
 import javax.swing.JDialog;
@@ -148,17 +150,27 @@ public class StandardDialog extends JDialog {
148 150
      * @param owner Window to center on
149 151
      */
150 152
     public void displayBlocking(final Component owner) {
153
+        if (SwingUtilities.isEventDispatchThread()) {
154
+            throw new IllegalStateException("Unable to display blocking dialog"
155
+                    + " in the EDT.");
156
+        }
157
+        final Semaphore semaphore = new Semaphore(0);
151 158
         SwingUtilities.invokeLater(new Runnable() {
152 159
 
153 160
             /** {@inheritDoc} */
154 161
             @Override
155 162
             public void run() {
156 163
                 display(owner);
164
+                addWindowListener(new WindowAdapter() {
165
+
166
+                    @Override
167
+                    public void windowClosed(final WindowEvent e) {
168
+                        semaphore.release();
169
+                    }
170
+                });
157 171
             }
158 172
         });
159
-        while (isVisible()) {
160
-            Thread.yield();
161
-        }
173
+        semaphore.acquireUninterruptibly();
162 174
     }
163 175
 
164 176
 

+ 184
- 0
src/com/dmdirc/addons/ui_swing/framemanager/ctrltab/CtrlTabWindowManager.java View File

@@ -0,0 +1,184 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.framemanager.ctrltab;
24
+
25
+import com.dmdirc.FrameContainer;
26
+import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.SwingWindowFactory;
28
+import com.dmdirc.addons.ui_swing.SwingWindowListener;
29
+import com.dmdirc.addons.ui_swing.UIUtilities;
30
+import com.dmdirc.addons.ui_swing.actions.NextFrameAction;
31
+import com.dmdirc.addons.ui_swing.actions.PreviousFrameAction;
32
+import com.dmdirc.addons.ui_swing.components.TreeScroller;
33
+import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewModel;
34
+import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewNode;
35
+import com.dmdirc.interfaces.SelectionListener;
36
+import com.dmdirc.logger.ErrorLevel;
37
+import com.dmdirc.logger.Logger;
38
+import com.dmdirc.ui.interfaces.Window;
39
+
40
+import java.awt.event.KeyEvent;
41
+import java.util.HashMap;
42
+import java.util.Map;
43
+
44
+import javax.swing.JComponent;
45
+import javax.swing.KeyStroke;
46
+import javax.swing.tree.DefaultTreeSelectionModel;
47
+import javax.swing.tree.TreeNode;
48
+import javax.swing.tree.TreePath;
49
+import javax.swing.tree.TreeSelectionModel;
50
+
51
+/**
52
+ * A Window manager to handle ctrl[+shift]+tab switching between windows.
53
+ */
54
+public class CtrlTabWindowManager implements SwingWindowListener,
55
+        SelectionListener {
56
+
57
+    /** Node storage, used for adding and deleting nodes correctly. */
58
+    private final Map<Window, TreeViewNode> nodes;
59
+    /** Data model. */
60
+    private final TreeViewModel model;
61
+    /** Tree Scroller. */
62
+    private final TreeScroller treeScroller;
63
+    /** Window factory. */
64
+    private final SwingWindowFactory windowFactory;
65
+    /** Selection model for the tree scroller. */
66
+    private final TreeSelectionModel selectionModel;
67
+
68
+    /**
69
+     * Creates a new ctrl tab window manager.
70
+     *
71
+     * @param controller Parent controller
72
+     * @param component Component to add listen to events on
73
+     */
74
+    public CtrlTabWindowManager(final SwingController controller,
75
+            final JComponent component) {
76
+        nodes = new HashMap<Window, TreeViewNode>();
77
+        model = new TreeViewModel(new TreeViewNode(null, null));
78
+        selectionModel = new DefaultTreeSelectionModel();
79
+        treeScroller = new TreeScroller(model, selectionModel, false) {
80
+
81
+            /** {@inheritDoc} */
82
+            @Override
83
+            protected void setPath(final TreePath path) {
84
+                super.setPath(path);
85
+                ((TreeViewNode) path.getLastPathComponent()).getWindow().
86
+                        activateFrame();
87
+            }
88
+        };
89
+        windowFactory = controller.getWindowFactory();
90
+        windowFactory.addWindowListener(this);
91
+        component.getActionMap().put("prevFrameAction",
92
+                new PreviousFrameAction(treeScroller));
93
+        component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
94
+                .put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
95
+                KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK),
96
+                "prevFrameAction");
97
+        component.getActionMap().put(
98
+                "nextFrameAction", new NextFrameAction(treeScroller));
99
+        component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
100
+                .put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
101
+                KeyEvent.CTRL_DOWN_MASK), "nextFrameAction");
102
+    }
103
+
104
+    /* {@inheritDoc} */
105
+    @Override
106
+    public void windowAdded(final Window parent, final Window window) {
107
+        final TreeViewNode parentNode;
108
+        if (parent == null) {
109
+            parentNode = model.getRootNode();
110
+        } else {
111
+            parentNode = nodes.get(parent);
112
+        }
113
+        window.getContainer().addSelectionListener(this);
114
+        UIUtilities.invokeAndWait(new Runnable() {
115
+
116
+            /** {@inheritDoc} */
117
+            @Override
118
+            public void run() {
119
+                final TreeViewNode node = new TreeViewNode(null, window.
120
+                        getContainer());
121
+                synchronized (nodes) {
122
+                    nodes.put(window, node);
123
+                }
124
+                node.setUserObject(window);
125
+                model.insertNodeInto(node, parentNode);
126
+            }
127
+        });
128
+    }
129
+
130
+    /* {@inheritDoc} */
131
+    @Override
132
+    public void windowDeleted(final Window parent, final Window window) {
133
+         window.getContainer().removeSelectionListener(this);
134
+         UIUtilities.invokeAndWait(new Runnable() {
135
+
136
+            /** {@inheritDoc} */
137
+            @Override
138
+            public void run() {
139
+                if (nodes == null || nodes.get(window) == null) {
140
+                    return;
141
+                }
142
+                final TreeViewNode node = nodes.get(window);
143
+                if (node.getLevel() == 0) {
144
+                    Logger.appError(ErrorLevel.MEDIUM,
145
+                            "delServer triggered for root node"
146
+                            + node.toString(),
147
+                            new IllegalArgumentException());
148
+                } else {
149
+                    model.removeNodeFromParent(nodes.get(window));
150
+                }
151
+                nodes.remove(window);
152
+            }
153
+        });
154
+    }
155
+
156
+    /** Scrolls up. */
157
+    public void scrollUp() {
158
+        treeScroller.changeFocus(true);
159
+    }
160
+
161
+    /** Scrolls down. */
162
+    public void scrollDown() {
163
+        treeScroller.changeFocus(false);
164
+    }
165
+
166
+    /* {@inheritDoc} */
167
+    @Override
168
+    public void selectionChanged(final FrameContainer<?> window) {
169
+        UIUtilities.invokeLater(new Runnable() {
170
+
171
+            /** {@inheritDoc} */
172
+            @Override
173
+            public void run() {
174
+                final Window selectedWindow = windowFactory.getSwingWindow(
175
+                        window);
176
+                final TreeNode[] path = model.getPathToRoot(nodes.get(
177
+                        selectedWindow));
178
+                if (path != null && path.length > 0) {
179
+                    selectionModel.setSelectionPath(new TreePath(path));
180
+                }
181
+            }
182
+        });
183
+    }
184
+}

+ 2
- 1
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java View File

@@ -326,7 +326,8 @@ public final class TreeFrameManager implements FrameManager,
326 326
                         addWindow(nodes.get(window), childWindow);
327 327
                     }
328 328
                 }
329
-                if (controller.getMainFrame().getActiveFrame() != null) {
329
+                if (controller.getMainFrame() != null
330
+                        && controller.getMainFrame().getActiveFrame() != null) {
330 331
                     selectionChanged(controller.getMainFrame().getActiveFrame()
331 332
                             .getContainer());
332 333
                 }

+ 0
- 99
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/ArrangeWindows.java View File

@@ -1,99 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.addons.ui_swing.SwingController;
26
-import com.dmdirc.ui.IconManager;
27
-
28
-import java.awt.event.ActionEvent;
29
-import java.awt.event.ActionListener;
30
-
31
-import javax.swing.JMenu;
32
-import javax.swing.JMenuItem;
33
-
34
-/**
35
- * Menu to add window arrangement options.
36
- */
37
-public class ArrangeWindows extends JMenu implements ActionListener {
38
-    /**
39
-     * A version number for this class. It should be changed whenever the class
40
-     * structure is changed (or anything else that would prevent serialized
41
-     * objects being unserialized with the new class).
42
-     */
43
-    private static final long serialVersionUID = 1;
44
-    /** Menu items for tiling grid, vertical, horizontal. */
45
-    private final JMenuItem grid, vertical, horizontal;
46
-    /** Desktop pane. */
47
-    private SwingController controller;
48
-
49
-    /**
50
-     * Creates a new arrange windows menu.  Provides options to arrange windows
51
-     * in a grid, tile vertically and tile horizontally.
52
-     *
53
-     * @param controller Swing controller to request mainframe/desktop pane.
54
-     */
55
-    public ArrangeWindows(final SwingController controller) {
56
-        super();
57
-
58
-        this.controller = controller;
59
-
60
-        setIcon(IconManager.getIconManager().getIcon("dmdirc"));
61
-        setMnemonic('a');
62
-        setText("Arrange Windows");
63
-
64
-        grid = new JMenuItem(IconManager.getIconManager().getIcon("dmdirc"));
65
-        grid.setMnemonic('g');
66
-        grid.setText("Arrange in grid");
67
-        grid.setActionCommand("grid");
68
-        grid.addActionListener(this);
69
-        add(grid);
70
-
71
-        horizontal = new JMenuItem(IconManager.getIconManager().getIcon(
72
-                "dmdirc"));
73
-        horizontal.setMnemonic('h');
74
-        horizontal.setText("Arrange horizontally");
75
-        horizontal.setActionCommand("horizontal");
76
-        horizontal.addActionListener(this);
77
-        add(horizontal);
78
-
79
-        vertical = new JMenuItem(IconManager.getIconManager().getIcon(
80
-                "dmdirc"));
81
-        vertical.setMnemonic('v');
82
-        vertical.setText("Arrange vertically");
83
-        vertical.setActionCommand("vertical");
84
-        vertical.addActionListener(this);
85
-        add(vertical);
86
-    }
87
-
88
-    /** {@inheritDoc} */
89
-    @Override
90
-    public void actionPerformed(final ActionEvent e) {
91
-        if (e.getActionCommand().equals("grid")) {
92
-            controller.getMainFrame().getDesktopPane().tileWindows();
93
-        } else if (e.getActionCommand().equals("horizontally")) {
94
-            controller.getMainFrame().getDesktopPane().tileHorizontally();
95
-        } else if (e.getActionCommand().equals("verticallt")) {
96
-            controller.getMainFrame().getDesktopPane().tileVertically();
97
-        }
98
-    }
99
-}

src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/JInternalFrameComparator.java → src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/TextFrameComparator.java View File

@@ -28,13 +28,11 @@ import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28 28
 import java.io.Serializable;
29 29
 import java.util.Comparator;
30 30
 
31
-import javax.swing.JInternalFrame;
32
-
33 31
 /**
34
- * A comparator that proxies JInternalFrame arrays to a Frame container
32
+ * A comparator that proxies TextFrame comparisons to a Frame container
35 33
  * comparator if appropriate.
36 34
  */
37
-public class JInternalFrameComparator implements Comparator<JInternalFrame>,
35
+public class TextFrameComparator implements Comparator<TextFrame>,
38 36
         Serializable {
39 37
 
40 38
     /**
@@ -56,11 +54,7 @@ public class JInternalFrameComparator implements Comparator<JInternalFrame>,
56 54
      * +1 if item1 is after item2.
57 55
      */
58 56
     @Override
59
-    public int compare(final JInternalFrame item1, final JInternalFrame item2) {
60
-        if (!(item1 instanceof TextFrame) || (!(item2 instanceof TextFrame))) {
61
-            return 0;
62
-        }
63
-        return comparator.compare(((TextFrame) item1).getContainer(),
64
-                ((TextFrame) item2).getContainer());
57
+    public int compare(final TextFrame item1, final TextFrame item2) {
58
+        return comparator.compare(item1.getContainer(), item2.getContainer());
65 59
     }
66 60
 }

+ 6
- 80
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java View File

@@ -48,14 +48,12 @@ import javax.swing.JMenu;
48 48
 import javax.swing.JMenuItem;
49 49
 import javax.swing.JPopupMenu;
50 50
 import javax.swing.JSeparator;
51
-import javax.swing.event.MenuEvent;
52
-import javax.swing.event.MenuListener;
53 51
 
54 52
 /**
55 53
  * Manages the window menu window list.
56 54
  */
57 55
 public final class WindowMenuFrameManager extends JMenu implements
58
-        SwingWindowListener, ActionListener, SelectionListener, MenuListener {
56
+        SwingWindowListener, ActionListener, SelectionListener {
59 57
 
60 58
     /**
61 59
      * A version number for this class. It should be changed whenever the class
@@ -68,13 +66,10 @@ public final class WindowMenuFrameManager extends JMenu implements
68 66
             new FrameContainerComparator();
69 67
     /** Non frame container menu count. */
70 68
     private final int itemCount;
71
-    /** Menu items for toggling, closing and minimising. */
72
-    private final JMenuItem toggleStateMenuItem, closeMenuItem,
73
-            minimiseMenuItem;
69
+    /** Menu items closing the active window. */
70
+    private final JMenuItem closeMenuItem;
74 71
     /** Seperator. */
75 72
     private final JSeparator separator;
76
-    /** Active window. */
77
-    private Window activeWindow;
78 73
     /** Enabled menu items? */
79 74
     private final AtomicBoolean enabledMenuItems = new AtomicBoolean(false);
80 75
     /** Swing controller. */
@@ -103,23 +98,6 @@ public final class WindowMenuFrameManager extends JMenu implements
103 98
         setText("Window");
104 99
         setMnemonic('w');
105 100
         controller.getWindowFactory().addWindowListener(this);
106
-        addMenuListener(this);
107
-
108
-        minimiseMenuItem = new JMenuItem(IconManager.getIconManager().getIcon(
109
-                "minimise"));
110
-        minimiseMenuItem.setMnemonic('n');
111
-        minimiseMenuItem.setText("Minimise");
112
-        minimiseMenuItem.setActionCommand("Minimise");
113
-        minimiseMenuItem.addActionListener(this);
114
-        add(minimiseMenuItem);
115
-
116
-        toggleStateMenuItem = new JMenuItem(IconManager.getIconManager().getIcon(
117
-                "maximise"));
118
-        toggleStateMenuItem.setMnemonic('m');
119
-        toggleStateMenuItem.setText("Maximise");
120
-        toggleStateMenuItem.setActionCommand("ToggleState");
121
-        toggleStateMenuItem.addActionListener(this);
122
-        add(toggleStateMenuItem);
123 101
 
124 102
         closeMenuItem = new JMenuItem(IconManager.getIconManager().getIcon(
125 103
                 "close"));
@@ -129,13 +107,10 @@ public final class WindowMenuFrameManager extends JMenu implements
129 107
         closeMenuItem.addActionListener(this);
130 108
         add(closeMenuItem);
131 109
 
132
-        add(new ArrangeWindows(controller));
133
-
134 110
         separator = new JPopupMenu.Separator();
135 111
         add(separator);
136 112
 
137 113
         itemCount = getMenuComponentCount();
138
-        checkToggleState();
139 114
 
140 115
         new WindowMenuScroller(this, controller.getDomain(), itemCount);
141 116
     }
@@ -148,8 +123,6 @@ public final class WindowMenuFrameManager extends JMenu implements
148 123
         enabledMenuItems.set((getMenuComponentCount() > itemCount));
149 124
         separator.setVisible(enabledMenuItems.get());
150 125
         closeMenuItem.setEnabled(enabledMenuItems.get());
151
-        toggleStateMenuItem.setEnabled(enabledMenuItems.get());
152
-        minimiseMenuItem.setEnabled(enabledMenuItems.get());
153 126
     }
154 127
 
155 128
     /** {@inheritDoc} */
@@ -317,12 +290,8 @@ public final class WindowMenuFrameManager extends JMenu implements
317 290
     @Override
318 291
     public void actionPerformed(final ActionEvent e) {
319 292
         if (enabledMenuItems.get()) {
320
-            if (e.getActionCommand().equals("ToggleState")) {
321
-                activeWindow.toggleMaximise();
322
-            } else if (e.getActionCommand().equals("Minimise")) {
323
-                activeWindow.minimise();
324
-            } else if (e.getActionCommand().equals("Close")) {
325
-                activeWindow.close();
293
+            if (e.getActionCommand().equals("Close")) {
294
+                controller.getMainFrame().getActiveFrame().close();
326 295
             }
327 296
         }
328 297
     }
@@ -335,8 +304,7 @@ public final class WindowMenuFrameManager extends JMenu implements
335 304
         synchronized (menus) {
336 305
             synchronized (items) {
337 306
                 synchronized (menuItems) {
338
-                    activeWindow = controller.getWindowFactory().getSwingWindow(
339
-                            window);
307
+                    checkMenuItems();
340 308
                     values.addAll(menus.values());
341 309
                     values.addAll(items.values());
342 310
                     values.addAll(menuItems.values());
@@ -366,30 +334,6 @@ public final class WindowMenuFrameManager extends JMenu implements
366 334
         }
367 335
     }
368 336
 
369
-    /**
370
-     * Checks and sets the state of the toggle menu item.
371
-     */
372
-    private void checkToggleState() {
373
-        checkMenuItems();
374
-        if (activeWindow != null) {
375
-            toggleStateMenuItem.setEnabled(true);
376
-            closeMenuItem.setEnabled(true);
377
-            minimiseMenuItem.setEnabled(true);
378
-
379
-            if (activeWindow.isMaximum()) {
380
-                toggleStateMenuItem.setText("Restore");
381
-                toggleStateMenuItem.setIcon(IconManager.getIconManager().getIcon(
382
-                        "restore"));
383
-                toggleStateMenuItem.setMnemonic('r');
384
-            } else {
385
-                toggleStateMenuItem.setText("Maximise");
386
-                toggleStateMenuItem.setIcon(IconManager.getIconManager().getIcon(
387
-                        "maximise"));
388
-                toggleStateMenuItem.setMnemonic('m');
389
-            }
390
-        }
391
-    }
392
-
393 337
     /**
394 338
      * Compares the new child with the existing children or parent to decide
395 339
      * where it needs to be inserted.
@@ -474,22 +418,4 @@ public final class WindowMenuFrameManager extends JMenu implements
474 418
 
475 419
         return comparator.compare(newChild, child) >= 1;
476 420
     }
477
-
478
-    /** {@inheritDoc} */
479
-    @Override
480
-    public void menuSelected(final MenuEvent e) {
481
-        checkToggleState();
482
-    }
483
-
484
-    /** {@inheritDoc} */
485
-    @Override
486
-    public void menuDeselected(final MenuEvent e) {
487
-        //Ignore
488
-    }
489
-
490
-    /** {@inheritDoc} */
491
-    @Override
492
-    public void menuCanceled(final MenuEvent e) {
493
-        //Ignore
494
-    }
495 421
 }

+ 1
- 0
src/com/dmdirc/addons/ui_swing/plugin.config View File

@@ -40,6 +40,7 @@ defaults:
40 40
     showjrewarning=true
41 41
     showtreeexpands=true
42 42
     textpanelinenotification=true
43
+    mdiBarVisibility=true
43 44
 
44 45
 exports:
45 46
   getController in com.dmdirc.addons.ui_swing.SwingController as getController

Loading…
Cancel
Save