Browse Source

Add interface for active frame management.

Change-Id: I9028e6f92a6e076a0d446ef2321898924d6faa39
Reviewed-on: http://gerrit.dmdirc.com/3322
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/22/3322/4
Greg Holmes 10 years ago
parent
commit
e4369ec0e7

+ 10
- 31
src/com/dmdirc/addons/ui_swing/MainFrame.java View File

@@ -32,6 +32,7 @@ import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
32 32
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
33 33
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
34 34
 import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
35
+import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
35 36
 import com.dmdirc.events.ClientFocusGainedEvent;
36 37
 import com.dmdirc.events.ClientFocusLostEvent;
37 38
 import com.dmdirc.events.ClientMinimisedEvent;
@@ -71,7 +72,7 @@ import static com.dmdirc.addons.ui_swing.SwingPreconditions.checkOnEDT;
71 72
  */
72 73
 public class MainFrame extends JFrame implements WindowListener,
73 74
         ConfigChangeListener, SwingWindowListener, FrameInfoListener,
74
-        NotificationListener {
75
+        NotificationListener, ActiveFrameManager {
75 76
 
76 77
     /** A version number for this class. */
77 78
     private static final long serialVersionUID = 9;
@@ -212,15 +213,6 @@ public class MainFrame extends JFrame implements WindowListener,
212 213
         }
213 214
     }
214 215
 
215
-    /**
216
-     * Returns the window that is currently active.
217
-     *
218
-     * @return The active window
219
-     */
220
-    public TextFrame getActiveFrame() {
221
-        return activeFrame;
222
-    }
223
-
224 216
     @Override
225 217
     public MenuBar getJMenuBar() {
226 218
         return (MenuBar) super.getJMenuBar();
@@ -565,11 +557,12 @@ public class MainFrame extends JFrame implements WindowListener,
565 557
         }
566 558
     }
567 559
 
568
-    /**
569
-     * Changes the visible frame.
570
-     *
571
-     * @param activeFrame The frame to be activated, or null to show none
572
-     */
560
+    @Override
561
+    public TextFrame getActiveFrame() {
562
+        return activeFrame;
563
+    }
564
+
565
+    @Override
573 566
     public void setActiveFrame(final TextFrame activeFrame) {
574 567
         UIUtilities.invokeLater(new Runnable() {
575 568
 
@@ -611,26 +604,12 @@ public class MainFrame extends JFrame implements WindowListener,
611 604
         });
612 605
     }
613 606
 
614
-    /**
615
-     * Registers a new selection listener with this frame. The listener will be notified whenever
616
-     * the currently selected frame is changed.
617
-     *
618
-     * @param listener The listener to be added
619
-     *
620
-     * @see #setActiveFrame(com.dmdirc.addons.ui_swing.components.frames.TextFrame)
621
-     * @see #getActiveFrame()
622
-     */
607
+    @Override
623 608
     public void addSelectionListener(final SelectionListener listener) {
624 609
         listeners.add(SelectionListener.class, listener);
625 610
     }
626 611
 
627
-    /**
628
-     * Removes a previously registered selection listener.
629
-     *
630
-     * @param listener The listener to be removed
631
-     *
632
-     * @see #addSelectionListener(com.dmdirc.addons.ui_swing.SelectionListener)
633
-     */
612
+    @Override
634 613
     public void removeSelectionListener(final SelectionListener listener) {
635 614
         listeners.remove(SelectionListener.class, listener);
636 615
     }

+ 67
- 0
src/com/dmdirc/addons/ui_swing/interfaces/ActiveFrameManager.java View File

@@ -0,0 +1,67 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.interfaces;
24
+
25
+import com.dmdirc.addons.ui_swing.SelectionListener;
26
+import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
27
+
28
+/**
29
+ * Interface to the management of the active window in the swing ui.
30
+ */
31
+public interface ActiveFrameManager {
32
+
33
+    /**
34
+     * Returns the window that is currently active.
35
+     *
36
+     * @return The active window
37
+     */
38
+    TextFrame getActiveFrame();
39
+
40
+    /**
41
+     * Changes the visible frame.
42
+     *
43
+     * @param activeFrame The frame to be activated, or null to show none
44
+     */
45
+    void setActiveFrame(TextFrame activeFrame);
46
+
47
+    /**
48
+     * Registers a new selection listener with this frame. The listener will be notified whenever
49
+     * the currently selected frame is changed.
50
+     *
51
+     * @param listener The listener to be added
52
+     *
53
+     * @see #setActiveFrame(com.dmdirc.addons.ui_swing.components.frames.TextFrame)
54
+     * @see #getActiveFrame()
55
+     */
56
+    void addSelectionListener(SelectionListener listener);
57
+
58
+    /**
59
+     * Removes a previously registered selection listener.
60
+     *
61
+     * @param listener The listener to be removed
62
+     *
63
+     * @see #addSelectionListener(com.dmdirc.addons.ui_swing.SelectionListener)
64
+     */
65
+    void removeSelectionListener(SelectionListener listener);
66
+
67
+}

Loading…
Cancel
Save