ソースを参照

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年前
コミット
2c4fe17288
27個のファイルの変更620行の追加1476行の削除
  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 ファイルの表示

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

+ 118
- 55
src/com/dmdirc/addons/ui_swing/MainFrame.java ファイルの表示

22
 
22
 
23
 package com.dmdirc.addons.ui_swing;
23
 package com.dmdirc.addons.ui_swing;
24
 
24
 
25
+import com.dmdirc.FrameContainer;
25
 import com.dmdirc.Main;
26
 import com.dmdirc.Main;
26
 import com.dmdirc.ServerManager;
27
 import com.dmdirc.ServerManager;
27
 import com.dmdirc.actions.ActionManager;
28
 import com.dmdirc.actions.ActionManager;
28
 import com.dmdirc.actions.CoreActionType;
29
 import com.dmdirc.actions.CoreActionType;
29
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
30
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
30
-import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
31
 import com.dmdirc.addons.ui_swing.components.SplitPane;
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
 import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
34
 import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
35
+import com.dmdirc.addons.ui_swing.dialogs.ConfirmQuitDialog;
34
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
36
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
35
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
37
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
36
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
38
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
39
+import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
37
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
40
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
38
 import com.dmdirc.config.IdentityManager;
41
 import com.dmdirc.config.IdentityManager;
39
 import com.dmdirc.interfaces.ConfigChangeListener;
42
 import com.dmdirc.interfaces.ConfigChangeListener;
43
+import com.dmdirc.interfaces.FrameInfoListener;
44
+import com.dmdirc.interfaces.SelectionListener;
40
 import com.dmdirc.logger.ErrorLevel;
45
 import com.dmdirc.logger.ErrorLevel;
41
 import com.dmdirc.logger.Logger;
46
 import com.dmdirc.logger.Logger;
42
 import com.dmdirc.ui.CoreUIUtils;
47
 import com.dmdirc.ui.CoreUIUtils;
43
 import com.dmdirc.ui.IconManager;
48
 import com.dmdirc.ui.IconManager;
49
+import com.dmdirc.ui.WindowManager;
44
 import com.dmdirc.ui.interfaces.MainWindow;
50
 import com.dmdirc.ui.interfaces.MainWindow;
45
 import com.dmdirc.ui.interfaces.Window;
51
 import com.dmdirc.ui.interfaces.Window;
52
+import com.dmdirc.util.QueuedLinkedHashSet;
46
 import com.dmdirc.util.ReturnableThread;
53
 import com.dmdirc.util.ReturnableThread;
47
 
54
 
48
 import java.awt.Dimension;
55
 import java.awt.Dimension;
49
-import java.awt.Dialog.ModalityType;
50
 import java.awt.event.WindowEvent;
56
 import java.awt.event.WindowEvent;
51
 import java.awt.event.WindowFocusListener;
57
 import java.awt.event.WindowFocusListener;
52
 import java.awt.event.WindowListener;
58
 import java.awt.event.WindowListener;
57
 import javax.swing.JPanel;
63
 import javax.swing.JPanel;
58
 import javax.swing.JSplitPane;
64
 import javax.swing.JSplitPane;
59
 import javax.swing.MenuSelectionManager;
65
 import javax.swing.MenuSelectionManager;
66
+import javax.swing.SwingUtilities;
60
 import javax.swing.WindowConstants;
67
 import javax.swing.WindowConstants;
61
 
68
 
62
 import net.miginfocom.swing.MigLayout;
69
 import net.miginfocom.swing.MigLayout;
65
  * The main application frame.
72
  * The main application frame.
66
  */
73
  */
67
 public final class MainFrame extends JFrame implements WindowListener,
74
 public final class MainFrame extends JFrame implements WindowListener,
68
-        MainWindow, ConfigChangeListener {
75
+        MainWindow, ConfigChangeListener, SelectionListener,
76
+        SwingWindowListener, FrameInfoListener {
69
 
77
 
70
     /**
78
     /**
71
      * A version number for this class. It should be changed whenever the class
79
      * A version number for this class. It should be changed whenever the class
73
      * objects being unserialized with the new class).
81
      * objects being unserialized with the new class).
74
      */
82
      */
75
     private static final long serialVersionUID = 9;
83
     private static final long serialVersionUID = 9;
84
+    /** Focus queue. */
85
+    private final QueuedLinkedHashSet<TextFrame> focusOrder;
76
     /** The main application icon. */
86
     /** The main application icon. */
77
     private ImageIcon imageIcon;
87
     private ImageIcon imageIcon;
78
     /** The frame manager that's being used. */
88
     /** The frame manager that's being used. */
79
     private FrameManager mainFrameManager;
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
     /** Main panel. */
94
     /** Main panel. */
83
     private JPanel frameManagerPanel;
95
     private JPanel frameManagerPanel;
84
     /** Frame manager position. */
96
     /** Frame manager position. */
95
     private final String version;
107
     private final String version;
96
     /** Main split pane. */
108
     /** Main split pane. */
97
     private SplitPane mainSplitPane;
109
     private SplitPane mainSplitPane;
110
+    /** Frame manager used for ctrl tab frame switching. */
111
+    private final CtrlTabWindowManager frameManager;
98
 
112
 
99
     /**
113
     /**
100
      * Creates new form MainFrame.
114
      * Creates new form MainFrame.
106
 
120
 
107
         this.controller = controller;
121
         this.controller = controller;
108
 
122
 
123
+        focusOrder = new QueuedLinkedHashSet<TextFrame>();
109
         initComponents();
124
         initComponents();
110
 
125
 
111
-        imageIcon = new ImageIcon(IconManager.getIconManager().getImage("icon"));
126
+        imageIcon = new ImageIcon(IconManager.getIconManager()
127
+                .getImage("icon"));
112
         setIconImage(imageIcon.getImage());
128
         setIconImage(imageIcon.getImage());
113
 
129
 
114
         CoreUIUtils.centreWindow(this);
130
         CoreUIUtils.centreWindow(this);
149
                 MenuSelectionManager.defaultManager().clearSelectedPath();
165
                 MenuSelectionManager.defaultManager().clearSelectedPath();
150
             }
166
             }
151
         });
167
         });
168
+        WindowManager.addSelectionListener(this);
169
+        controller.getWindowFactory().addWindowListener(this);
152
 
170
 
153
         setTitle(getTitlePrefix());
171
         setTitle(getTitlePrefix());
172
+        frameManager = new CtrlTabWindowManager(controller, rootPane);
154
     }
173
     }
155
 
174
 
156
     /**
175
     /**
207
             /** {@inheritDoc} */
226
             /** {@inheritDoc} */
208
             @Override
227
             @Override
209
             public void run() {
228
             public void run() {
210
-                setObject(desktopPane.getSelectedWindow());
229
+                setObject(activeFrame);
211
             }
230
             }
212
         });
231
         });
213
     }
232
     }
214
 
233
 
215
-    /** {@inheritDoc */
234
+    /** {@inheritDoc} */
216
     @Override
235
     @Override
217
     public MenuBar getJMenuBar() {
236
     public MenuBar getJMenuBar() {
218
         return (MenuBar) super.getJMenuBar();
237
         return (MenuBar) super.getJMenuBar();
227
     /** {@inheritDoc}. */
246
     /** {@inheritDoc}. */
228
     @Override
247
     @Override
229
     public void setTitle(final String title) {
248
     public void setTitle(final String title) {
230
-        if (title != null && getActiveFrame() != null && getActiveFrame().
231
-                isMaximum()) {
249
+        if (title != null && getActiveFrame() != null) {
232
             super.setTitle(getTitlePrefix() + " - " + title);
250
             super.setTitle(getTitlePrefix() + " - " + title);
233
         } else {
251
         } else {
234
             super.setTitle(getTitlePrefix());
252
             super.setTitle(getTitlePrefix());
241
         return "DMDirc" + (showVersion ? " " + version : "");
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
     private void initComponents() {
403
     private void initComponents() {
402
         statusBar = new SwingStatusBar(controller, this);
404
         statusBar = new SwingStatusBar(controller, this);
403
         frameManagerPanel = new JPanel();
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
         mainSplitPane = new SplitPane(SplitPane.Orientation.HORIZONTAL);
408
         mainSplitPane = new SplitPane(SplitPane.Orientation.HORIZONTAL);
407
 
409
 
408
         initFrameManagers();
410
         initFrameManagers();
453
         switch (position) {
455
         switch (position) {
454
             case TOP:
456
             case TOP:
455
                 mainSplitPane.setTopComponent(frameManagerPanel);
457
                 mainSplitPane.setTopComponent(frameManagerPanel);
456
-                mainSplitPane.setBottomComponent(desktopPane);
458
+                mainSplitPane.setBottomComponent(framePanel);
457
                 mainSplitPane.setResizeWeight(0.0);
459
                 mainSplitPane.setResizeWeight(0.0);
458
                 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
460
                 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
459
                 frameManagerPanel.setPreferredSize(new Dimension(
461
                 frameManagerPanel.setPreferredSize(new Dimension(
462
                 break;
464
                 break;
463
             case LEFT:
465
             case LEFT:
464
                 mainSplitPane.setLeftComponent(frameManagerPanel);
466
                 mainSplitPane.setLeftComponent(frameManagerPanel);
465
-                mainSplitPane.setRightComponent(desktopPane);
467
+                mainSplitPane.setRightComponent(framePanel);
466
                 mainSplitPane.setResizeWeight(0.0);
468
                 mainSplitPane.setResizeWeight(0.0);
467
                 mainSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
469
                 mainSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
468
                 frameManagerPanel.setPreferredSize(new Dimension(
470
                 frameManagerPanel.setPreferredSize(new Dimension(
470
                         "frameManagerSize"), Integer.MAX_VALUE));
472
                         "frameManagerSize"), Integer.MAX_VALUE));
471
                 break;
473
                 break;
472
             case BOTTOM:
474
             case BOTTOM:
473
-                mainSplitPane.setTopComponent(desktopPane);
475
+                mainSplitPane.setTopComponent(framePanel);
474
                 mainSplitPane.setBottomComponent(frameManagerPanel);
476
                 mainSplitPane.setBottomComponent(frameManagerPanel);
475
                 mainSplitPane.setResizeWeight(1.0);
477
                 mainSplitPane.setResizeWeight(1.0);
476
                 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
478
                 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
479
                         getOptionInt("ui", "frameManagerSize")));
481
                         getOptionInt("ui", "frameManagerSize")));
480
                 break;
482
                 break;
481
             case RIGHT:
483
             case RIGHT:
482
-                mainSplitPane.setLeftComponent(desktopPane);
484
+                mainSplitPane.setLeftComponent(framePanel);
483
                 mainSplitPane.setRightComponent(frameManagerPanel);
485
                 mainSplitPane.setRightComponent(frameManagerPanel);
484
                 mainSplitPane.setResizeWeight(1.0);
486
                 mainSplitPane.setResizeWeight(1.0);
485
                 mainSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
487
                 mainSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
508
     public void quit(final int exitCode) {
510
     public void quit(final int exitCode) {
509
         if (exitCode == 0 && IdentityManager.getGlobalConfig().getOptionBool(
511
         if (exitCode == 0 && IdentityManager.getGlobalConfig().getOptionBool(
510
                 "ui", "confirmQuit")) {
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
                  * A version number for this class. It should be changed
516
                  * A version number for this class. It should be changed
517
                  * whenever the class structure is changed (or anything else
517
                  * whenever the class structure is changed (or anything else
518
                  * that would prevent serialized objects being unserialized
518
                  * that would prevent serialized objects being unserialized
519
                  * with the new class).
519
                  * with the new class).
520
                  */
520
                  */
521
-                private static final long serialVersionUID = 1;
521
+                private static final long serialVersionUID = 9;
522
 
522
 
523
                 /** {@inheritDoc} */
523
                 /** {@inheritDoc} */
524
                 @Override
524
                 @Override
525
-                public boolean save() {
525
+                protected void handleQuit() {
526
                     doQuit(exitCode);
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
             return;
530
             return;
537
         }
531
         }
538
         doQuit(exitCode);
532
         doQuit(exitCode);
543
      *
537
      *
544
      * @param exitCode Exit code
538
      * @param exitCode Exit code
545
      */
539
      */
546
-    private void doQuit(final int exitCode) {
540
+    public void doQuit(final int exitCode) {
547
         this.exitCode = exitCode;
541
         this.exitCode = exitCode;
548
 
542
 
549
         new LoggingSwingWorker() {
543
         new LoggingSwingWorker() {
575
         if ("ui".equals(domain)) {
569
         if ("ui".equals(domain)) {
576
             if ("lookandfeel".equals(key)) {
570
             if ("lookandfeel".equals(key)) {
577
                 controller.updateLookAndFeel();
571
                 controller.updateLookAndFeel();
578
-            } else if ("framemanager".equals(key) || "framemanagerPosition".equals(key)) {
572
+            } else if ("framemanager".equals(key)
573
+                    || "framemanagerPosition".equals(key)) {
579
                 UIUtilities.invokeLater(new Runnable() {
574
                 UIUtilities.invokeLater(new Runnable() {
580
 
575
 
581
                     /** {@inheritDoc} */
576
                     /** {@inheritDoc} */
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 ファイルの表示

48
 import com.dmdirc.addons.ui_swing.dialogs.sslcertificate.SSLCertificateDialog;
48
 import com.dmdirc.addons.ui_swing.dialogs.sslcertificate.SSLCertificateDialog;
49
 import com.dmdirc.addons.ui_swing.dialogs.updater.SwingUpdaterDialog;
49
 import com.dmdirc.addons.ui_swing.dialogs.updater.SwingUpdaterDialog;
50
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
50
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
51
+import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
51
 import com.dmdirc.addons.ui_swing.wizard.WizardListener;
52
 import com.dmdirc.addons.ui_swing.wizard.WizardListener;
52
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
53
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
53
 import com.dmdirc.config.Identity;
54
 import com.dmdirc.config.Identity;
824
     private PreferencesCategory createAdvancedCategory() {
825
     private PreferencesCategory createAdvancedCategory() {
825
         final PreferencesCategory advanced = new PluginPreferencesCategory(
826
         final PreferencesCategory advanced = new PluginPreferencesCategory(
826
                 getPluginInfo(), "Advanced", "");
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
         advanced.addSetting(new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
829
         advanced.addSetting(new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
834
                 new NumericalValidator(10, -1), "ui", "frameBufferSize",
830
                 new NumericalValidator(10, -1), "ui", "frameBufferSize",
835
                 "Window buffer size", "The maximum number of lines in a window"
831
                 "Window buffer size", "The maximum number of lines in a window"
836
                 + " buffer"));
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
         advanced.addSetting(
836
         advanced.addSetting(
841
                 new PreferencesSetting(PreferencesType.BOOLEAN, "ui",
837
                 new PreferencesSetting(PreferencesType.BOOLEAN, "ui",
842
                 "useOneTouchExpandable", "Use one touch expandable split panes?",
838
                 "useOneTouchExpandable", "Use one touch expandable split panes?",

+ 1
- 1
src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java ファイルの表示

169
                 }
169
                 }
170
 
170
 
171
                 if (focus) {
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 ファイルの表示

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.actions;
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
 import java.awt.event.ActionEvent;
27
 import java.awt.event.ActionEvent;
28
 
28
 
39
      * objects being unserialized with the new class).
39
      * objects being unserialized with the new class).
40
      */
40
      */
41
     private static final long serialVersionUID = 1;
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
      * Creates a new next frame action.
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
         super();
51
         super();
52
-
53
-        desktopPane = pane;
52
+        this.manager = manager;
54
     }
53
     }
55
 
54
 
56
     /**
55
     /**
60
      */
59
      */
61
     @Override
60
     @Override
62
     public void actionPerformed(final ActionEvent evt) {
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 ファイルの表示

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.actions;
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
 import java.awt.event.ActionEvent;
27
 import java.awt.event.ActionEvent;
28
 
28
 
39
      * objects being unserialized with the new class).
39
      * objects being unserialized with the new class).
40
      */
40
      */
41
     private static final long serialVersionUID = 1;
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
      * Creates a new previous frame action.
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
         super();
51
         super();
52
-
53
-        desktopPane = pane;
52
+        this.manager = manager;
54
     }
53
     }
55
 
54
 
56
     /**
55
     /**
60
      */
59
      */
61
     @Override
60
     @Override
62
     public void actionPerformed(final ActionEvent evt) {
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 ファイルの表示

35
  */
35
  */
36
 public class CheckBoxMenuItem extends JCheckBoxMenuItem {
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
     /** Menu path to use when clicked. */
44
     /** Menu path to use when clicked. */
39
     private static MenuElement[] path;
45
     private static MenuElement[] path;
40
 
46
 

+ 36
- 74
src/com/dmdirc/addons/ui_swing/components/MDIBar.java ファイルの表示

1
 /*
1
 /*
2
- * 
3
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
2
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- * 
3
+ *
5
  * Permission is hereby granted, free of charge, to any person obtaining a copy
4
  * 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
5
  * of this software and associated documentation files (the "Software"), to deal
7
  * in the Software without restriction, including without limitation the rights
6
  * in the Software without restriction, including without limitation the rights
8
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
  * 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
8
  * copies of the Software, and to permit persons to whom the Software is
10
  * furnished to do so, subject to the following conditions:
9
  * furnished to do so, subject to the following conditions:
11
- * 
10
+ *
12
  * The above copyright notice and this permission notice shall be included in
11
  * The above copyright notice and this permission notice shall be included in
13
  * all copies or substantial portions of the Software.
12
  * all copies or substantial portions of the Software.
14
- * 
13
+ *
15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
 import com.dmdirc.addons.ui_swing.MainFrame;
26
 import com.dmdirc.addons.ui_swing.MainFrame;
28
 import com.dmdirc.addons.ui_swing.SwingController;
27
 import com.dmdirc.addons.ui_swing.SwingController;
29
 import com.dmdirc.addons.ui_swing.SwingWindowListener;
28
 import com.dmdirc.addons.ui_swing.SwingWindowListener;
30
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
31
 import com.dmdirc.config.ConfigManager;
29
 import com.dmdirc.config.ConfigManager;
32
 import com.dmdirc.config.IdentityManager;
30
 import com.dmdirc.config.IdentityManager;
33
 import com.dmdirc.interfaces.ConfigChangeListener;
31
 import com.dmdirc.interfaces.ConfigChangeListener;
38
 
36
 
39
 import java.awt.event.ActionEvent;
37
 import java.awt.event.ActionEvent;
40
 import java.awt.event.ActionListener;
38
 import java.awt.event.ActionListener;
41
-import java.beans.PropertyChangeEvent;
42
-import java.beans.PropertyChangeListener;
43
 
39
 
44
-import javax.swing.JInternalFrame;
45
 import javax.swing.JPanel;
40
 import javax.swing.JPanel;
46
 import javax.swing.SwingUtilities;
41
 import javax.swing.SwingUtilities;
47
 
42
 
48
 import net.miginfocom.swing.MigLayout;
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
     private static final long serialVersionUID = -8028057596226636245L;
56
     private static final long serialVersionUID = -8028057596226636245L;
57
+    /** Icon size for the close button. */
57
     private static final int ICON_SIZE = 12;
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
      * Instantiates a new MDI bar.
71
      * Instantiates a new MDI bar.
73
      * @param mainFrame Main frame instance
74
      * @param mainFrame Main frame instance
74
      */
75
      */
75
     public MDIBar(final SwingController controller, final MainFrame mainFrame) {
76
     public MDIBar(final SwingController controller, final MainFrame mainFrame) {
77
+        super();
78
+
76
         this.mainFrame = mainFrame;
79
         this.mainFrame = mainFrame;
77
         this.config = IdentityManager.getGlobalConfig();
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
         closeButton = new NoFocusButton(IconManager.getIconManager().
84
         closeButton = new NoFocusButton(IconManager.getIconManager().
82
                 getScaledIcon("close-12", ICON_SIZE, ICON_SIZE));
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
         setOpaque(false);
87
         setOpaque(false);
89
         setLayout(new MigLayout("hmax 17, ins 1 0 0 0, fill"));
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
         add(closeButton, "w 17!, h 17!, right");
89
         add(closeButton, "w 17!, h 17!, right");
93
 
90
 
94
         controller.getWindowFactory().addWindowListener(this);
91
         controller.getWindowFactory().addWindowListener(this);
95
 
92
 
96
         WindowManager.addSelectionListener(this);
93
         WindowManager.addSelectionListener(this);
97
         closeButton.addActionListener(this);
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
         check();
97
         check();
103
     }
98
     }
106
     @Override
101
     @Override
107
     public void setEnabled(final boolean enabled) {
102
     public void setEnabled(final boolean enabled) {
108
         closeButton.setEnabled(enabled);
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
     private void check() {
110
     private void check() {
114
         SwingUtilities.invokeLater(new Runnable() {
111
         SwingUtilities.invokeLater(new Runnable() {
115
 
112
 
116
             @Override
113
             @Override
117
             public void run() {
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
     /** {@inheritDoc} */
121
     /** {@inheritDoc} */
136
     @Override
122
     @Override
137
     public void windowAdded(final Window parent, final Window window) {
123
     public void windowAdded(final Window parent, final Window window) {
138
-        ((JInternalFrame) window).addPropertyChangeListener(
139
-                "maximum", this);
140
-
141
         check();
124
         check();
142
     }
125
     }
143
 
126
 
144
     /** {@inheritDoc} */
127
     /** {@inheritDoc} */
145
     @Override
128
     @Override
146
     public void windowDeleted(final Window parent, final Window window) {
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
         check();
130
         check();
164
     }
131
     }
165
 
132
 
170
      */
137
      */
171
     @Override
138
     @Override
172
     public void actionPerformed(final ActionEvent e) {
139
     public void actionPerformed(final ActionEvent e) {
173
-        if (activeFrame == null) {
140
+        if (mainFrame.getActiveFrame() == null) {
174
             return;
141
             return;
175
         }
142
         }
176
         if (closeButton.equals(e.getSource())) {
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
     /** {@inheritDoc} */
148
     /** {@inheritDoc} */
186
     @Override
149
     @Override
187
     public void configChanged(final String domain, final String key) {
150
     public void configChanged(final String domain, final String key) {
188
-        visibility = config.getOption("ui", "mdiBarVisibility");
151
+        visibility = config.getOptionBool(configDomain, "mdiBarVisibility");
189
         check();
152
         check();
190
     }
153
     }
191
 
154
 
192
     /** {@inheritDoc} */
155
     /** {@inheritDoc} */
193
     @Override
156
     @Override
194
     public void selectionChanged(final FrameContainer<?> window) {
157
     public void selectionChanged(final FrameContainer<?> window) {
195
-        activeFrame = controller.getWindowFactory().getSwingWindow(window);
196
         check();
158
         check();
197
     }
159
     }
198
 }
160
 }

+ 3
- 1
src/com/dmdirc/addons/ui_swing/components/TreeScroller.java ファイルの表示

122
      * Removes this tree scroller from the tree.
122
      * Removes this tree scroller from the tree.
123
      */
123
      */
124
     public void unregister() {
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 ファイルの表示

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 ファイルの表示

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 ファイルの表示

65
      * objects being unserialized with the new class).
65
      * objects being unserialized with the new class).
66
      */
66
      */
67
     private static final long serialVersionUID = 10;
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
     /** split pane. */
72
     /** split pane. */
71
     private SplitPane splitPane;
73
     private SplitPane splitPane;
72
     /** popup menu item. */
74
     /** popup menu item. */
73
     private JMenuItem settingsMI;
75
     private JMenuItem settingsMI;
74
-    /** The channel object that owns this frame. */
75
-    private final Channel parentChannel;
76
-    /** Identity. */
77
-    private Identity identity;
78
     /** Nicklist. */
76
     /** Nicklist. */
79
     private NickList nicklist;
77
     private NickList nicklist;
80
     /** Topic bar. */
78
     /** Topic bar. */
104
                 "shownicklist", this);
102
                 "shownicklist", this);
105
         ActionManager.addListener(this, CoreActionType.CLIENT_CLOSING);
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
         identity = IdentityManager.getChannelConfig(getChannel().getServer().
108
         identity = IdentityManager.getChannelConfig(getChannel().getServer().
113
                 getNetwork(), getChannel().getChannelInfo().getName());
109
                 getNetwork(), getChannel().getChannelInfo().getName());
191
 
187
 
192
         splitPane = new SplitPane(SplitPane.Orientation.HORIZONTAL);
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
         splitPane.setLeftComponent(getTextPane());
197
         splitPane.setLeftComponent(getTextPane());
203
         if (getContainer().getConfigManager().getOptionBool(getController()
198
         if (getContainer().getConfigManager().getOptionBool(getController()
208
         }
203
         }
209
         splitPane.setResizeWeight(1);
204
         splitPane.setResizeWeight(1);
210
         splitPane.setDividerLocation(-1);
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 ファイルの表示

31
 
31
 
32
 /**
32
 /**
33
  * A very basic custom frame.
33
  * A very basic custom frame.
34
- * 
35
- * @author chris
36
  */
34
  */
37
 public class CustomFrame extends TextFrame {
35
 public class CustomFrame extends TextFrame {
38
 
36
 
49
      * @param owner The frame container that owns this frame
47
      * @param owner The frame container that owns this frame
50
      * @param controller Swing controller
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
         super(owner, controller);
52
         super(owner, controller);
54
 
53
 
55
         initComponents();
54
         initComponents();
59
      * Initialises components in this frame.
58
      * Initialises components in this frame.
60
      */
59
      */
61
     private void initComponents() {
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
     /** {@inheritDoc} */
66
     /** {@inheritDoc} */

+ 9
- 11
src/com/dmdirc/addons/ui_swing/components/frames/CustomInputFrame.java ファイルの表示

36
 /**
36
 /**
37
  * A custom frame that includes an input field (for use with writable
37
  * A custom frame that includes an input field (for use with writable
38
  * containers).
38
  * containers).
39
- * 
40
- * @author chris
41
  */
39
  */
42
 public class CustomInputFrame extends InputTextFrame {
40
 public class CustomInputFrame extends InputTextFrame {
43
 
41
 
50
 
48
 
51
     /**
49
     /**
52
      * Creates a new instance of CustomInputFrame.
50
      * Creates a new instance of CustomInputFrame.
53
-     * 
51
+     *
54
      * @param owner The frame container that owns this frame
52
      * @param owner The frame container that owns this frame
55
      * @param controller Swing controller
53
      * @param controller Swing controller
56
      */
54
      */
58
             final WritableFrameContainer<? extends InputWindow> owner) {
56
             final WritableFrameContainer<? extends InputWindow> owner) {
59
         super(controller, owner);
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
         initComponents();
62
         initComponents();
64
     }
63
     }
68
     @Deprecated
67
     @Deprecated
69
     @SuppressWarnings("unchecked")
68
     @SuppressWarnings("unchecked")
70
     public final CommandParser getCommandParser() {
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
      * Initialises components in this frame.
75
      * Initialises components in this frame.
76
      */
76
      */
77
     private void initComponents() {
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
     /** {@inheritDoc} */
84
     /** {@inheritDoc} */

+ 11
- 12
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java ファイルの表示

52
 import javax.swing.JPanel;
52
 import javax.swing.JPanel;
53
 import javax.swing.JPopupMenu;
53
 import javax.swing.JPopupMenu;
54
 import javax.swing.KeyStroke;
54
 import javax.swing.KeyStroke;
55
-import javax.swing.event.InternalFrameEvent;
56
 
55
 
57
 import net.miginfocom.layout.PlatformDefaults;
56
 import net.miginfocom.layout.PlatformDefaults;
58
 
57
 
318
             if (point != null) {
317
             if (point != null) {
319
                 initPopupMenu();
318
                 initPopupMenu();
320
                 inputFieldPopup.show(this, (int) point.getX(),
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
                         getUnitValueX("related").getValue());
322
                         getUnitValueX("related").getValue());
323
             }
323
             }
324
         }
324
         }
339
         }
339
         }
340
 
340
 
341
         try {
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
             clipboard = (String) Toolkit.getDefaultToolkit().
344
             clipboard = (String) Toolkit.getDefaultToolkit().
344
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
345
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
345
             doPaste(clipboard);
346
             doPaste(clipboard);
346
         } catch (IOException ex) {
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
         } catch (UnsupportedFlavorException ex) {
350
         } catch (UnsupportedFlavorException ex) {
350
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
351
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
351
         }
352
         }
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
     @Override
484
     @Override
488
-    public void internalFrameActivated(final InternalFrameEvent event) {
489
-        super.internalFrameActivated(event);
485
+    public void activateFrame() {
486
+        super.activateFrame();
490
         if (useAwayIndicator && getContainer().getServer() != null) {
487
         if (useAwayIndicator && getContainer().getServer() != null) {
491
             awayLabel.setVisible(getContainer().getServer().isAway());
488
             awayLabel.setVisible(getContainer().getServer().isAway());
492
         }
489
         }
493
         inputField.requestFocusInWindow();
490
         inputField.requestFocusInWindow();
494
     }
491
     }
492
+
493
+
495
 }
494
 }

+ 7
- 12
src/com/dmdirc/addons/ui_swing/components/frames/QueryFrame.java ファイルの表示

43
      * objects being unserialized with the new class).
43
      * objects being unserialized with the new class).
44
      */
44
      */
45
     private static final long serialVersionUID = 8;
45
     private static final long serialVersionUID = 8;
46
-    /** This channel's command parser. */
47
-    private final CommandParser commandParser;
48
 
46
 
49
     /**
47
     /**
50
      * Creates a new QueryFrame.
48
      * Creates a new QueryFrame.
51
-     * 
49
+     *
52
      * @param owner Parent Frame container
50
      * @param owner Parent Frame container
53
      * @param controller Swing controller
51
      * @param controller Swing controller
54
      */
52
      */
57
 
55
 
58
         initComponents();
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
     /** {@inheritDoc} */
62
     /** {@inheritDoc} */
73
      * Initialises components in this frame.
70
      * Initialises components in this frame.
74
      */
71
      */
75
     private void initComponents() {
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
     /** {@inheritDoc} */
79
     /** {@inheritDoc} */

+ 14
- 18
src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java ファイルの表示

51
      * objects being unserialized with the new class).
51
      * objects being unserialized with the new class).
52
      */
52
      */
53
     private static final long serialVersionUID = 9;
53
     private static final long serialVersionUID = 9;
54
-    /** This channel's command parser. */
55
-    private final CommandParser commandParser;
56
     /** popup menu item. */
54
     /** popup menu item. */
57
     private JMenuItem settingsMI;
55
     private JMenuItem settingsMI;
58
 
56
 
59
     /**
57
     /**
60
      * Creates a new ServerFrame.
58
      * Creates a new ServerFrame.
61
-     * 
59
+     *
62
      * @param owner Parent Frame container
60
      * @param owner Parent Frame container
63
      * @param controller Swing controller
61
      * @param controller Swing controller
64
      */
62
      */
66
         super(controller, owner);
64
         super(controller, owner);
67
 
65
 
68
         initComponents();
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
     /** {@inheritDoc} */
72
     /** {@inheritDoc} */
86
         settingsMI = new JMenuItem("Settings");
83
         settingsMI = new JMenuItem("Settings");
87
         settingsMI.addActionListener(this);
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
      * {@inheritDoc}.
93
      * {@inheritDoc}.
99
-     * 
94
+     *
100
      * @param actionEvent Action event
95
      * @param actionEvent Action event
101
      */
96
      */
102
     @Override
97
     @Override
134
     /** {@inheritDoc} */
129
     /** {@inheritDoc} */
135
     @Override
130
     @Override
136
     public void addCustomPopupItems(final JPopupMenu popupMenu) {
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
             settingsMI.setEnabled(true);
134
             settingsMI.setEnabled(true);
139
         } else {
135
         } else {
140
             settingsMI.setEnabled(false);
136
             settingsMI.setEnabled(false);
143
         if (popupMenu.getComponentCount() > 0) {
139
         if (popupMenu.getComponentCount() > 0) {
144
             popupMenu.addSeparator();
140
             popupMenu.addSeparator();
145
         }
141
         }
146
-        
142
+
147
         popupMenu.add(settingsMI);
143
         popupMenu.add(settingsMI);
148
     }
144
     }
149
 
145
 
151
     @Override
147
     @Override
152
     public void close() {
148
     public void close() {
153
         if (ServerSettingsDialog.hasServerSettingsDialog()) {
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
         super.close();
153
         super.close();
158
     }
154
     }

+ 102
- 483
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java ファイルの表示

33
 import com.dmdirc.addons.ui_swing.actions.InputFieldCopyAction;
33
 import com.dmdirc.addons.ui_swing.actions.InputFieldCopyAction;
34
 import com.dmdirc.addons.ui_swing.actions.NicknameCopyAction;
34
 import com.dmdirc.addons.ui_swing.actions.NicknameCopyAction;
35
 import com.dmdirc.addons.ui_swing.actions.SearchAction;
35
 import com.dmdirc.addons.ui_swing.actions.SearchAction;
36
-import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
37
 import com.dmdirc.addons.ui_swing.components.SwingSearchBar;
36
 import com.dmdirc.addons.ui_swing.components.SwingSearchBar;
38
 import com.dmdirc.addons.ui_swing.textpane.ClickTypeValue;
37
 import com.dmdirc.addons.ui_swing.textpane.ClickTypeValue;
39
 import com.dmdirc.addons.ui_swing.textpane.MouseEventType;
38
 import com.dmdirc.addons.ui_swing.textpane.MouseEventType;
54
 import com.dmdirc.config.ConfigManager;
53
 import com.dmdirc.config.ConfigManager;
55
 import com.dmdirc.interfaces.ConfigChangeListener;
54
 import com.dmdirc.interfaces.ConfigChangeListener;
56
 import com.dmdirc.interfaces.FrameCloseListener;
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
 import com.dmdirc.parser.common.ChannelJoinRequest;
56
 import com.dmdirc.parser.common.ChannelJoinRequest;
61
-import com.dmdirc.ui.IconManager;
62
 import com.dmdirc.ui.interfaces.InputWindow;
57
 import com.dmdirc.ui.interfaces.InputWindow;
63
 import com.dmdirc.ui.interfaces.Window;
58
 import com.dmdirc.ui.interfaces.Window;
59
+import com.dmdirc.ui.messages.IRCDocument;
64
 import com.dmdirc.util.StringTranscoder;
60
 import com.dmdirc.util.StringTranscoder;
65
 
61
 
66
-import java.awt.Container;
67
-import java.awt.Dimension;
68
 import java.awt.Point;
62
 import java.awt.Point;
69
 import java.awt.event.KeyEvent;
63
 import java.awt.event.KeyEvent;
70
 import java.awt.event.MouseEvent;
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
 import java.nio.charset.Charset;
65
 import java.nio.charset.Charset;
77
 import java.nio.charset.IllegalCharsetNameException;
66
 import java.nio.charset.IllegalCharsetNameException;
78
 import java.nio.charset.UnsupportedCharsetException;
67
 import java.nio.charset.UnsupportedCharsetException;
79
-import java.util.logging.Level;
80
 
68
 
81
-import javax.swing.BorderFactory;
82
 import javax.swing.JComponent;
69
 import javax.swing.JComponent;
83
-import javax.swing.JInternalFrame;
84
 import javax.swing.JMenu;
70
 import javax.swing.JMenu;
85
 import javax.swing.JMenuItem;
71
 import javax.swing.JMenuItem;
86
 import javax.swing.JPanel;
72
 import javax.swing.JPanel;
88
 import javax.swing.JSeparator;
74
 import javax.swing.JSeparator;
89
 import javax.swing.KeyStroke;
75
 import javax.swing.KeyStroke;
90
 import javax.swing.SwingUtilities;
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
 import net.miginfocom.swing.MigLayout;
78
 import net.miginfocom.swing.MigLayout;
100
 
79
 
101
 /**
80
 /**
102
  * Implements a generic (internal) frame.
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
      * A version number for this class. It should be changed whenever the class
87
      * A version number for this class. It should be changed whenever the class
113
      * structure is changed (or anything else that would prevent serialized
88
      * structure is changed (or anything else that would prevent serialized
122
     private SwingSearchBar searchBar;
97
     private SwingSearchBar searchBar;
123
     /** String transcoder. */
98
     /** String transcoder. */
124
     private StringTranscoder transcoder;
99
     private StringTranscoder transcoder;
125
-    /** Are we closing? */
126
-    private boolean closing = false;
127
     /** Command parser for popup commands. */
100
     /** Command parser for popup commands. */
128
     private final CommandParser commandParser;
101
     private final CommandParser commandParser;
129
     /** Swing controller. */
102
     /** Swing controller. */
130
     private final SwingController controller;
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
      * Creates a new instance of Frame.
106
      * Creates a new instance of Frame.
147
 
116
 
148
         final ConfigManager config = owner.getConfigManager();
117
         final ConfigManager config = owner.getConfigManager();
149
 
118
 
150
-        setFrameIcon(IconManager.getIconManager().getIcon(owner.getIcon()));
151
-
152
-        owner.addFrameInfoListener(this);
153
         owner.addCloseListener(this);
119
         owner.addCloseListener(this);
154
         owner.setTitle(frameParent.getTitle());
120
         owner.setTitle(frameParent.getTitle());
155
 
121
 
167
         commandParser = findCommandParser();
133
         commandParser = findCommandParser();
168
 
134
 
169
         initComponents();
135
         initComponents();
170
-        setMaximizable(true);
171
-        setClosable(true);
172
-        setResizable(true);
173
-        setIconifiable(true);
174
         setFocusable(true);
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
         getTextPane().addTextPaneListener(this);
138
         getTextPane().addTextPaneListener(this);
182
 
139
 
183
         config.addChangeListener("ui", "foregroundcolour", this);
140
         config.addChangeListener("ui", "foregroundcolour", this);
185
         config.addChangeListener("ui", "frameBufferSize", this);
142
         config.addChangeListener("ui", "frameBufferSize", this);
186
         updateColours();
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
         return localParser;
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
     /** {@inheritDoc} */
173
     /** {@inheritDoc} */
304
     @Override
174
     @Override
305
     public void activateFrame() {
175
     public void activateFrame() {
307
 
177
 
308
             @Override
178
             @Override
309
             public void run() {
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
 
189
 
333
             @Override
190
             @Override
334
             public void run() {
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
     @Override
203
     @Override
355
     public void minimise() {
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
     @Override
214
     @Override
374
     public void maximise() {
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
     @Override
225
     @Override
411
     public void restore() {
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
     @Override
236
     @Override
438
     public void toggleMaximise() {
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
         getActionMap().put("endAction", new TextPaneEndAction(getTextPane()));
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
     /** {@inheritDoc} */
344
     /** {@inheritDoc} */
756
     @Override
345
     @Override
757
     public FrameContainer<?> getContainer() {
346
     public FrameContainer<?> getContainer() {
1019
     /** {@inheritDoc} */
608
     /** {@inheritDoc} */
1020
     @Override
609
     @Override
1021
     public void configChanged(final String domain, final String key) {
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
             return;
613
             return;
1024
         }
614
         }
1025
 
615
 
1031
 
621
 
1032
     /** {@inheritDoc} */
622
     /** {@inheritDoc} */
1033
     @Override
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
     /** {@inheritDoc} */
628
     /** {@inheritDoc} */
1046
     @Override
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
     @Override
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
     @Override
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
     /** {@inheritDoc} */
679
     /** {@inheritDoc} */
1075
     @Override
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 ファイルの表示

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

+ 66
- 0
src/com/dmdirc/addons/ui_swing/dialogs/ConfirmQuitDialog.java ファイルの表示

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 ファイルの表示

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs;
23
 package com.dmdirc.addons.ui_swing.dialogs;
24
 
24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.ui.CoreUIUtils;
26
 import com.dmdirc.ui.CoreUIUtils;
26
 
27
 
27
 import java.awt.Component;
28
 import java.awt.Component;
31
 import java.awt.Window;
32
 import java.awt.Window;
32
 import java.awt.event.WindowAdapter;
33
 import java.awt.event.WindowAdapter;
33
 import java.awt.event.WindowEvent;
34
 import java.awt.event.WindowEvent;
35
+import java.util.concurrent.Semaphore;
34
 
36
 
35
 import javax.swing.JButton;
37
 import javax.swing.JButton;
36
 import javax.swing.JDialog;
38
 import javax.swing.JDialog;
148
      * @param owner Window to center on
150
      * @param owner Window to center on
149
      */
151
      */
150
     public void displayBlocking(final Component owner) {
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
         SwingUtilities.invokeLater(new Runnable() {
158
         SwingUtilities.invokeLater(new Runnable() {
152
 
159
 
153
             /** {@inheritDoc} */
160
             /** {@inheritDoc} */
154
             @Override
161
             @Override
155
             public void run() {
162
             public void run() {
156
                 display(owner);
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 ファイルの表示

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 ファイルの表示

326
                         addWindow(nodes.get(window), childWindow);
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
                     selectionChanged(controller.getMainFrame().getActiveFrame()
331
                     selectionChanged(controller.getMainFrame().getActiveFrame()
331
                             .getContainer());
332
                             .getContainer());
332
                 }
333
                 }

+ 0
- 99
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/ArrangeWindows.java ファイルの表示

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 ファイルの表示

28
 import java.io.Serializable;
28
 import java.io.Serializable;
29
 import java.util.Comparator;
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
  * comparator if appropriate.
33
  * comparator if appropriate.
36
  */
34
  */
37
-public class JInternalFrameComparator implements Comparator<JInternalFrame>,
35
+public class TextFrameComparator implements Comparator<TextFrame>,
38
         Serializable {
36
         Serializable {
39
 
37
 
40
     /**
38
     /**
56
      * +1 if item1 is after item2.
54
      * +1 if item1 is after item2.
57
      */
55
      */
58
     @Override
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 ファイルの表示

48
 import javax.swing.JMenuItem;
48
 import javax.swing.JMenuItem;
49
 import javax.swing.JPopupMenu;
49
 import javax.swing.JPopupMenu;
50
 import javax.swing.JSeparator;
50
 import javax.swing.JSeparator;
51
-import javax.swing.event.MenuEvent;
52
-import javax.swing.event.MenuListener;
53
 
51
 
54
 /**
52
 /**
55
  * Manages the window menu window list.
53
  * Manages the window menu window list.
56
  */
54
  */
57
 public final class WindowMenuFrameManager extends JMenu implements
55
 public final class WindowMenuFrameManager extends JMenu implements
58
-        SwingWindowListener, ActionListener, SelectionListener, MenuListener {
56
+        SwingWindowListener, ActionListener, SelectionListener {
59
 
57
 
60
     /**
58
     /**
61
      * A version number for this class. It should be changed whenever the class
59
      * A version number for this class. It should be changed whenever the class
68
             new FrameContainerComparator();
66
             new FrameContainerComparator();
69
     /** Non frame container menu count. */
67
     /** Non frame container menu count. */
70
     private final int itemCount;
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
     /** Seperator. */
71
     /** Seperator. */
75
     private final JSeparator separator;
72
     private final JSeparator separator;
76
-    /** Active window. */
77
-    private Window activeWindow;
78
     /** Enabled menu items? */
73
     /** Enabled menu items? */
79
     private final AtomicBoolean enabledMenuItems = new AtomicBoolean(false);
74
     private final AtomicBoolean enabledMenuItems = new AtomicBoolean(false);
80
     /** Swing controller. */
75
     /** Swing controller. */
103
         setText("Window");
98
         setText("Window");
104
         setMnemonic('w');
99
         setMnemonic('w');
105
         controller.getWindowFactory().addWindowListener(this);
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
         closeMenuItem = new JMenuItem(IconManager.getIconManager().getIcon(
102
         closeMenuItem = new JMenuItem(IconManager.getIconManager().getIcon(
125
                 "close"));
103
                 "close"));
129
         closeMenuItem.addActionListener(this);
107
         closeMenuItem.addActionListener(this);
130
         add(closeMenuItem);
108
         add(closeMenuItem);
131
 
109
 
132
-        add(new ArrangeWindows(controller));
133
-
134
         separator = new JPopupMenu.Separator();
110
         separator = new JPopupMenu.Separator();
135
         add(separator);
111
         add(separator);
136
 
112
 
137
         itemCount = getMenuComponentCount();
113
         itemCount = getMenuComponentCount();
138
-        checkToggleState();
139
 
114
 
140
         new WindowMenuScroller(this, controller.getDomain(), itemCount);
115
         new WindowMenuScroller(this, controller.getDomain(), itemCount);
141
     }
116
     }
148
         enabledMenuItems.set((getMenuComponentCount() > itemCount));
123
         enabledMenuItems.set((getMenuComponentCount() > itemCount));
149
         separator.setVisible(enabledMenuItems.get());
124
         separator.setVisible(enabledMenuItems.get());
150
         closeMenuItem.setEnabled(enabledMenuItems.get());
125
         closeMenuItem.setEnabled(enabledMenuItems.get());
151
-        toggleStateMenuItem.setEnabled(enabledMenuItems.get());
152
-        minimiseMenuItem.setEnabled(enabledMenuItems.get());
153
     }
126
     }
154
 
127
 
155
     /** {@inheritDoc} */
128
     /** {@inheritDoc} */
317
     @Override
290
     @Override
318
     public void actionPerformed(final ActionEvent e) {
291
     public void actionPerformed(final ActionEvent e) {
319
         if (enabledMenuItems.get()) {
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
         synchronized (menus) {
304
         synchronized (menus) {
336
             synchronized (items) {
305
             synchronized (items) {
337
                 synchronized (menuItems) {
306
                 synchronized (menuItems) {
338
-                    activeWindow = controller.getWindowFactory().getSwingWindow(
339
-                            window);
307
+                    checkMenuItems();
340
                     values.addAll(menus.values());
308
                     values.addAll(menus.values());
341
                     values.addAll(items.values());
309
                     values.addAll(items.values());
342
                     values.addAll(menuItems.values());
310
                     values.addAll(menuItems.values());
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
      * Compares the new child with the existing children or parent to decide
338
      * Compares the new child with the existing children or parent to decide
395
      * where it needs to be inserted.
339
      * where it needs to be inserted.
474
 
418
 
475
         return comparator.compare(newChild, child) >= 1;
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 ファイルの表示

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

読み込み中…
キャンセル
保存