Bladeren bron

Remove most singleton uses of WindowManager.

Change-Id: I1f054c7423106afe3fc49db8dc44613ec11c35bb
Depends-On: Idd97b752328310b4f829a45a43de5fdf6f5712a5
Reviewed-on: http://gerrit.dmdirc.com/2817
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 jaren geleden
bovenliggende
commit
3ce4e9f633

+ 4
- 3
src/com/dmdirc/addons/dcc/ChatContainer.java Bestand weergeven

@@ -52,20 +52,21 @@ public class ChatContainer extends DCCFrameContainer implements DCCChatHandler {
52 52
      * @param title The title of this window
53 53
      * @param nick My Current Nickname
54 54
      * @param targetNick Nickname of target
55
+     * @param windowManager Window Management
55 56
      */
56 57
     public ChatContainer(final DCCPlugin plugin, final DCCChat dcc,
57 58
             final AggregateConfigProvider configManager, final String title,
58
-            final String nick, final String targetNick) {
59
+            final String nick, final String targetNick, final WindowManager windowManager) {
59 60
         super(title, "dcc-chat-inactive", configManager,
60 61
                 DCCCommandParser.getDCCCommandParser(configManager),
61 62
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
62
-                WindowComponent.INPUTFIELD.getIdentifier()));
63
+                        WindowComponent.INPUTFIELD.getIdentifier()), windowManager);
63 64
         dccChat = dcc;
64 65
         dcc.setHandler(this);
65 66
         nickname = nick;
66 67
         otherNickname = targetNick;
67 68
 
68
-        WindowManager.getWindowManager().addWindow(plugin.getContainer(), this);
69
+        windowManager.addWindow(plugin.getContainer(), this);
69 70
     }
70 71
 
71 72
     /**

+ 10
- 4
src/com/dmdirc/addons/dcc/DCCCommand.java Bestand weergeven

@@ -42,6 +42,7 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
42 42
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
43 43
 import com.dmdirc.interfaces.CommandController;
44 44
 import com.dmdirc.parser.interfaces.Parser;
45
+import com.dmdirc.ui.WindowManager;
45 46
 import com.dmdirc.ui.input.AdditionalTabTargets;
46 47
 import com.dmdirc.ui.input.TabCompletionType;
47 48
 
@@ -65,6 +66,8 @@ public class DCCCommand extends Command implements IntelligentCommand {
65 66
     private final DCCPlugin myPlugin;
66 67
     /** Main frame instance used as the parent for dialogs. */
67 68
     private final MainFrame mainFrame;
69
+    /** Window management. */
70
+    private final WindowManager windowManager;
68 71
 
69 72
     /**
70 73
      * Creates a new instance of DCCCommand.
@@ -72,11 +75,14 @@ public class DCCCommand extends Command implements IntelligentCommand {
72 75
      * @param controller The controller to use for command information.
73 76
      * @param mainFrame mainFrame instance to use
74 77
      * @param plugin The DCC Plugin that this command belongs to
78
+     * @param windowManager Window management
75 79
      */
76
-    public DCCCommand(final CommandController controller, final MainFrame mainFrame, final DCCPlugin plugin) {
80
+    public DCCCommand(final CommandController controller, final MainFrame mainFrame,
81
+            final DCCPlugin plugin, final WindowManager windowManager) {
77 82
         super(controller);
78 83
         this.mainFrame = mainFrame;
79 84
         myPlugin = plugin;
85
+        this.windowManager = windowManager;
80 86
     }
81 87
 
82 88
     /** {@inheritDoc} */
@@ -144,7 +150,7 @@ public class DCCCommand extends Command implements IntelligentCommand {
144 150
         if (myPlugin.listen(chat)) {
145 151
             final ChatContainer window = new ChatContainer(myPlugin, chat,
146 152
                     origin.getConfigManager(),
147
-                    "*Chat: " + target, myNickname, target);
153
+                    "*Chat: " + target, myNickname, target, windowManager);
148 154
             parser.sendCTCP(target, "DCC", "CHAT chat " + DCC.ipToLong(
149 155
                     myPlugin.getListenIP(parser)) + " " + chat.getPort());
150 156
             ActionManager.getActionManager().triggerEvent(
@@ -222,7 +228,7 @@ public class DCCCommand extends Command implements IntelligentCommand {
222 228
                     final Parser parser = server.getParser();
223 229
                     new TransferContainer(myPlugin, send,
224 230
                             origin.getConfigManager(), "Send: " + target,
225
-                            target, server);
231
+                            target, server, windowManager);
226 232
                     parser.sendCTCP(target, "DCC", "SEND \""
227 233
                             + selectedFile.getName() + "\" "
228 234
                             + DCC.ipToLong(myPlugin.getListenIP(parser))
@@ -234,7 +240,7 @@ public class DCCCommand extends Command implements IntelligentCommand {
234 240
                     if (myPlugin.listen(send)) {
235 241
                         new TransferContainer(myPlugin, send,
236 242
                                 origin.getConfigManager(), "*Send: "
237
-                                + target, target, server);
243
+                                + target, target, server, windowManager);
238 244
                         parser.sendCTCP(target, "DCC", "SEND \""
239 245
                                 + selectedFile.getName() + "\" "
240 246
                                 + DCC.ipToLong(myPlugin.getListenIP(parser))

+ 4
- 2
src/com/dmdirc/addons/dcc/DCCFrameContainer.java Bestand weergeven

@@ -26,6 +26,7 @@ import com.dmdirc.Server;
26 26
 import com.dmdirc.WritableFrameContainer;
27 27
 import com.dmdirc.commandparser.parsers.CommandParser;
28 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29
+import com.dmdirc.ui.WindowManager;
29 30
 import com.dmdirc.ui.input.TabCompleter;
30 31
 
31 32
 import java.util.Collection;
@@ -46,11 +47,12 @@ public abstract class DCCFrameContainer extends WritableFrameContainer {
46 47
      * @param configManager Config manager
47 48
      * @param parser Command parser to use for this window
48 49
      * @param components The UI components that this frame requires
50
+     * @param windowManager Window management
49 51
      */
50 52
     public DCCFrameContainer(final String title, final String icon,
51 53
             final AggregateConfigProvider configManager, final CommandParser parser,
52
-            final Collection<String> components) {
53
-        super(icon, title, title, configManager, parser, components);
54
+            final Collection<String> components, final WindowManager windowManager) {
55
+        super(icon, title, title, configManager, parser, components, windowManager);
54 56
     }
55 57
 
56 58
     /** {@inheritDoc} */

+ 13
- 8
src/com/dmdirc/addons/dcc/DCCPlugin.java Bestand weergeven

@@ -77,6 +77,8 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
77 77
     private final SwingController controller;
78 78
     /** Identity controller to read settings from. */
79 79
     private final IdentityController identityController;
80
+    /** Window Management. */
81
+    private final WindowManager windowManager;
80 82
 
81 83
     /**
82 84
      * Creates a new instance of this plugin.
@@ -85,18 +87,21 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
85 87
      * @param pluginInfo This plugin's plugin info
86 88
      * @param identityController The Identity controller that provides the current config
87 89
      * @param commandController Command controller to register commands
90
+     * @param windowManager Window Management
88 91
      */
89 92
     public DCCPlugin(final SwingController controller,
90 93
             final PluginInfo pluginInfo,
91 94
             final IdentityController identityController,
92
-            final CommandController commandController) {
95
+            final CommandController commandController,
96
+            final WindowManager windowManager) {
93 97
         super(commandController);
94 98
         this.identityController = identityController;
95 99
         this.controller = controller;
100
+        this.windowManager = windowManager;
96 101
         config = controller.getGlobalConfig();
97 102
         this.pluginInfo = pluginInfo;
98
-        registerCommand(new DCCCommand(commandController, controller.getMainFrame(), this),
99
-                DCCCommand.INFO);
103
+        registerCommand(new DCCCommand(commandController, controller.getMainFrame(), this,
104
+                windowManager), DCCCommand.INFO);
100 105
         final SwingWindowFactory factory = controller.getWindowFactory();
101 106
         factory.registerImplementation(new HashSet<>(Arrays.asList(
102 107
                 "com.dmdirc.addons.dcc.ui.PlaceholderPanel")),
@@ -172,7 +177,7 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
172 177
                 final boolean resume = handleResume(jc);
173 178
                 if (reverse && !token.isEmpty()) {
174 179
                     new TransferContainer(DCCPlugin.this, send, config,
175
-                            "*Receive: " + nickname, nickname, null);
180
+                            "*Receive: " + nickname, nickname, null, windowManager);
176 181
                     send.setToken(token);
177 182
                     if (resume) {
178 183
                         if (config.getOptionBool(getDomain(),
@@ -197,7 +202,7 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
197 202
                     }
198 203
                 } else {
199 204
                     new TransferContainer(DCCPlugin.this, send, config,
200
-                            "Receive: " + nickname, nickname, null);
205
+                            "Receive: " + nickname, nickname, null, windowManager);
201 206
                     if (resume) {
202 207
                         parser.sendCTCP(nickname, "DCC", "RESUME "
203 208
                                 + send.getShortFileName() + " "
@@ -381,7 +386,7 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
381 386
             final String myNickname = ((Server) arguments[0]).getParser()
382 387
                     .getLocalClient().getNickname();
383 388
             final DCCFrameContainer f = new ChatContainer(this, chat, config,
384
-                    "Chat: " + nickname, myNickname, nickname);
389
+                    "Chat: " + nickname, myNickname, nickname, windowManager);
385 390
             f.addLine("DCCChatStarting", nickname, chat.getHost(),
386 391
                     chat.getPort());
387 392
             chat.connect();
@@ -629,8 +634,8 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
629 634
      * Create the container window.
630 635
      */
631 636
     protected void createContainer() {
632
-        container = new PlaceholderContainer(this, config, controller);
633
-        WindowManager.getWindowManager().addWindow(container);
637
+        container = new PlaceholderContainer(this, config, controller, windowManager);
638
+        windowManager.addWindow(container);
634 639
     }
635 640
 
636 641
     /** {@inheritDoc} */

+ 5
- 2
src/com/dmdirc/addons/dcc/PlaceholderContainer.java Bestand weergeven

@@ -27,6 +27,7 @@ import com.dmdirc.Server;
27 27
 import com.dmdirc.addons.ui_swing.SwingController;
28 28
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
29 29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
+import com.dmdirc.ui.WindowManager;
30 31
 
31 32
 import java.awt.Dialog.ModalityType;
32 33
 import java.util.Arrays;
@@ -47,11 +48,13 @@ public class PlaceholderContainer extends FrameContainer {
47 48
      * @param plugin The plugin which owns this placeholder
48 49
      * @param config Config manager
49 50
      * @param controller Swing controller
51
+     * @param windowManager Window manager
50 52
      */
51 53
     public PlaceholderContainer(final DCCPlugin plugin,
52
-            final AggregateConfigProvider config, final SwingController controller) {
54
+            final AggregateConfigProvider config, final SwingController controller,
55
+            final WindowManager windowManager) {
53 56
         super("dcc", "DCCs", "DCCs", config, Arrays.asList(
54
-                "com.dmdirc.addons.dcc.ui.PlaceholderPanel"));
57
+                "com.dmdirc.addons.dcc.ui.PlaceholderPanel"), windowManager);
55 58
         this.plugin = plugin;
56 59
         this.controller = controller;
57 60
     }

+ 5
- 3
src/com/dmdirc/addons/dcc/TransferContainer.java Bestand weergeven

@@ -91,14 +91,16 @@ public class TransferContainer extends FrameContainer implements
91 91
      * @param title The title of this window
92 92
      * @param targetNick Nickname of target
93 93
      * @param server The server that initiated this send
94
+     * @param windowManager Window Management
94 95
      */
95 96
     public TransferContainer(final DCCPlugin plugin, final DCCTransfer dcc,
96 97
             final AggregateConfigProvider config, final String title,
97
-            final String targetNick, final Server server) {
98
+            final String targetNick, final Server server,
99
+            final WindowManager windowManager) {
98 100
         super(dcc.getType() == DCCTransfer.TransferType.SEND
99 101
                 ? "dcc-send-inactive" : "dcc-receive-inactive",
100 102
                 title, title, config,
101
-                Arrays.asList("com.dmdirc.addons.dcc.ui.TransferPanel"));
103
+                Arrays.asList("com.dmdirc.addons.dcc.ui.TransferPanel"), windowManager);
102 104
         this.plugin = plugin;
103 105
         this.dcc = dcc;
104 106
         this.server = server;
@@ -114,7 +116,7 @@ public class TransferContainer extends FrameContainer implements
114 116
 
115 117
         otherNickname = targetNick;
116 118
 
117
-        WindowManager.getWindowManager().addWindow(plugin.getContainer(), this);
119
+        windowManager.addWindow(plugin.getContainer(), this);
118 120
     }
119 121
 
120 122
     /** {@inheritDoc} */

+ 3
- 4
src/com/dmdirc/addons/logging/HistoryWindow.java Bestand weergeven

@@ -22,11 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.logging;
24 24
 
25
-import com.dmdirc.util.io.ReverseFileReader;
26 25
 import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.Server;
28
-import com.dmdirc.ui.WindowManager;
29 27
 import com.dmdirc.ui.core.components.WindowComponent;
28
+import com.dmdirc.util.io.ReverseFileReader;
30 29
 
31 30
 import java.util.Arrays;
32 31
 
@@ -46,9 +45,9 @@ public class HistoryWindow extends FrameContainer {
46 45
     public HistoryWindow(final String title, final ReverseFileReader reader,
47 46
                          final FrameContainer parent, final int numLines) {
48 47
         super("raw", title, title, parent.getConfigManager(),
49
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
48
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), parent.getWindowManager());
50 49
 
51
-        WindowManager.getWindowManager().addWindow(parent, this);
50
+        parent.getWindowManager().addWindow(parent, this);
52 51
 
53 52
         final int frameBufferSize = parent.getConfigManager().getOptionInt(
54 53
                 "ui", "frameBufferSize");

+ 5
- 2
src/com/dmdirc/addons/parserdebug/DebugPlugin.java Bestand weergeven

@@ -31,6 +31,7 @@ import com.dmdirc.interfaces.actions.ActionType;
31 31
 import com.dmdirc.parser.interfaces.Parser;
32 32
 import com.dmdirc.parser.interfaces.callbacks.DebugInfoListener;
33 33
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
34
+import com.dmdirc.ui.WindowManager;
34 35
 
35 36
 import java.util.ArrayList;
36 37
 import java.util.Date;
@@ -54,14 +55,16 @@ public final class DebugPlugin extends BaseCommandPlugin implements
54 55
      *
55 56
      * @param actionController The action controller to register listeners with
56 57
      * @param commandController Command controller to register commands
58
+     * @param windowManager Window Manager
57 59
      */
58 60
     public DebugPlugin(final ActionController actionController,
59
-            final CommandController commandController) {
61
+            final CommandController commandController,
62
+            final WindowManager windowManager) {
60 63
         super(commandController);
61 64
 
62 65
         this.actionController = actionController;
63 66
 
64
-        registerCommand(new ParserDebugCommand(commandController, this), ParserDebugCommand.INFO);
67
+        registerCommand(new ParserDebugCommand(commandController, this, windowManager), ParserDebugCommand.INFO);
65 68
     }
66 69
 
67 70
     /** {@inheritDoc} */

+ 4
- 3
src/com/dmdirc/addons/parserdebug/DebugWindow.java Bestand weergeven

@@ -50,15 +50,16 @@ public class DebugWindow extends FrameContainer {
50 50
      * @param title The title of this window
51 51
      * @param parser The parser this plugin is debugging
52 52
      * @param server The Server window this is a child of
53
+     * @param windowManager Window management
53 54
      */
54
-    public DebugWindow(final DebugPlugin plugin, final String title, final Parser parser, final Server server) {
55
+    public DebugWindow(final DebugPlugin plugin, final String title, final Parser parser, final Server server, final WindowManager windowManager) {
55 56
         super("raw", "Parser Debug", title, server.getConfigManager(),
56
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
57
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), windowManager);
57 58
         this.plugin = plugin;
58 59
         this.parser = parser;
59 60
         this.server = server;
60 61
 
61
-        WindowManager.getWindowManager().addWindow(server, this);
62
+        windowManager.addWindow(server, this);
62 63
     }
63 64
 
64 65
     /**

+ 7
- 2
src/com/dmdirc/addons/parserdebug/ParserDebugCommand.java Bestand weergeven

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.context.ServerCommandContext;
33 33
 import com.dmdirc.interfaces.CommandController;
34 34
 import com.dmdirc.parser.interfaces.Parser;
35 35
 import com.dmdirc.parser.interfaces.callbacks.DebugInfoListener;
36
+import com.dmdirc.ui.WindowManager;
36 37
 
37 38
 /**
38 39
  * The ParserDebug Command allows controlling of which parsers spam debug info.
@@ -47,16 +48,20 @@ public final class ParserDebugCommand extends Command {
47 48
             CommandType.TYPE_SERVER);
48 49
     /** My Plugin */
49 50
     final DebugPlugin myPlugin;
51
+    /** Window management. */
52
+    private final WindowManager windowManager;
50 53
 
51 54
     /**
52 55
      * Creates a new instance of ParserDebugCommand.
53 56
      *
54 57
      * @param controller The controller to use for command information.
55 58
      * @param plugin Plugin that owns this command
59
+     * @param windowManager Window management
56 60
      */
57
-    public ParserDebugCommand(final CommandController controller, final DebugPlugin plugin) {
61
+    public ParserDebugCommand(final CommandController controller, final DebugPlugin plugin, final WindowManager windowManager) {
58 62
         super(controller);
59 63
         myPlugin = plugin;
64
+        this.windowManager = windowManager;
60 65
     }
61 66
 
62 67
     /**
@@ -93,7 +98,7 @@ public final class ParserDebugCommand extends Command {
93 98
             try {
94 99
                 parser.getCallbackManager().addCallback(DebugInfoListener.class, myPlugin);
95 100
                 final DebugWindow window = new DebugWindow(myPlugin,
96
-                        "Parser Debug", parser, origin.getServer());
101
+                        "Parser Debug", parser, origin.getServer(), windowManager);
97 102
                 myPlugin.registeredParsers.put(parser, window);
98 103
                 sendLine(origin, isSilent, FORMAT_OUTPUT, "Adding callback ok");
99 104
                 window.addLine("======================", true);

+ 1
- 1
src/com/dmdirc/addons/redirect/FakeWriteableFrameContainer.java Bestand weergeven

@@ -48,7 +48,7 @@ public class FakeWriteableFrameContainer extends WritableFrameContainer {
48 48
     public FakeWriteableFrameContainer(final MessageTarget target) {
49 49
         super(target.getIcon(), target.getName(), target.getTitle(),
50 50
                 target.getConfigManager(), target.getCommandParser(),
51
-                Collections.<String>emptyList());
51
+                Collections.<String>emptyList(), target.getWindowManager());
52 52
         this.target = target;
53 53
     }
54 54
 

+ 7
- 4
src/com/dmdirc/addons/swingdebug/SwingDebugPlugin.java Bestand weergeven

@@ -26,6 +26,7 @@ import com.dmdirc.addons.ui_swing.SwingController;
26 26
 import com.dmdirc.addons.ui_swing.components.CheckBoxMenuItem;
27 27
 import com.dmdirc.interfaces.config.IdentityController;
28 28
 import com.dmdirc.plugins.implementations.BasePlugin;
29
+import com.dmdirc.ui.WindowManager;
29 30
 
30 31
 import java.awt.Toolkit;
31 32
 import java.awt.event.ActionEvent;
@@ -43,10 +44,12 @@ import lombok.RequiredArgsConstructor;
43 44
 @RequiredArgsConstructor
44 45
 public class SwingDebugPlugin extends BasePlugin implements ActionListener {
45 46
 
46
-    /** Swing controller. */
47
-    private final SwingController controller;
48 47
     /** The controller to read/write settings with. */
49 48
     private final IdentityController identityController;
49
+    /** Swing controller. */
50
+    private final SwingController controller;
51
+    /** Window Management. */
52
+    private final WindowManager windowManager;
50 53
     /** Debug menu. */
51 54
     private JMenu debugMenu;
52 55
     /** Debug EDT menu item. */
@@ -101,7 +104,7 @@ public class SwingDebugPlugin extends BasePlugin implements ActionListener {
101 104
         if (e.getSource() == showSysOut) {
102 105
             if (showSysOut.isSelected()) {
103 106
                 sysoutFrame = new SystemStreamContainer(SystemStreamType.Out,
104
-                        controller.getGlobalConfig(), this);
107
+                        controller.getGlobalConfig(), this, windowManager);
105 108
             } else {
106 109
                 sysoutFrame.close();
107 110
             }
@@ -110,7 +113,7 @@ public class SwingDebugPlugin extends BasePlugin implements ActionListener {
110 113
         if (e.getSource() == showSysErr) {
111 114
             if (showSysErr.isSelected()) {
112 115
                 syserrFrame = new SystemStreamContainer(SystemStreamType.Error,
113
-                        controller.getGlobalConfig(), this);
116
+                        controller.getGlobalConfig(), this, windowManager);
114 117
             } else {
115 118
                 syserrFrame.close();
116 119
             }

+ 4
- 3
src/com/dmdirc/addons/swingdebug/SystemStreamContainer.java Bestand weergeven

@@ -47,19 +47,20 @@ public class SystemStreamContainer extends FrameContainer {
47 47
      * @param stream Stream to wrap
48 48
      * @param config Config to wrap
49 49
      * @param plugin Parent plugin
50
+     * @param windowManager Window management
50 51
      */
51 52
     public SystemStreamContainer(final SystemStreamType stream,
52 53
             final AggregateConfigProvider config,
53
-            final SwingDebugPlugin plugin) {
54
+            final SwingDebugPlugin plugin, final WindowManager windowManager) {
54 55
         super("dmdirc", stream.toString(), stream.toString(), config,
55
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
56
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), windowManager);
56 57
         this.plugin = plugin;
57 58
         try {
58 59
             thread = new SystemStreamRedirectThread(stream, getDocument());
59 60
             thread.start();
60 61
         } catch (IOException ex) {
61 62
         }
62
-        WindowManager.getWindowManager().addWindow(this);
63
+        windowManager.addWindow(this);
63 64
     }
64 65
 
65 66
     /** {@inheritDoc} */

+ 10
- 5
src/com/dmdirc/addons/ui_swing/MainFrame.java Bestand weergeven

@@ -36,14 +36,15 @@ import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
36 36
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
37 37
 import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
38 38
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
39
-import com.dmdirc.interfaces.config.ConfigChangeListener;
40 39
 import com.dmdirc.interfaces.FrameInfoListener;
41 40
 import com.dmdirc.interfaces.LifecycleController;
42 41
 import com.dmdirc.interfaces.NotificationListener;
42
+import com.dmdirc.interfaces.config.ConfigChangeListener;
43 43
 import com.dmdirc.logger.ErrorLevel;
44 44
 import com.dmdirc.logger.Logger;
45 45
 import com.dmdirc.ui.Colour;
46 46
 import com.dmdirc.ui.CoreUIUtils;
47
+import com.dmdirc.ui.WindowManager;
47 48
 import com.dmdirc.util.collections.ListenerList;
48 49
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
49 50
 
@@ -58,7 +59,6 @@ import javax.swing.ImageIcon;
58 59
 import javax.swing.JFrame;
59 60
 import javax.swing.JPanel;
60 61
 import javax.swing.JSplitPane;
61
-import javax.swing.MenuSelectionManager;
62 62
 import javax.swing.SwingUtilities;
63 63
 import javax.swing.WindowConstants;
64 64
 
@@ -71,7 +71,7 @@ import net.miginfocom.swing.MigLayout;
71 71
  * The main application frame.
72 72
  */
73 73
 @Slf4j
74
-public final class MainFrame extends JFrame implements WindowListener,
74
+public class MainFrame extends JFrame implements WindowListener,
75 75
         ConfigChangeListener, SwingWindowListener, FrameInfoListener,
76 76
         NotificationListener {
77 77
 
@@ -93,6 +93,8 @@ public final class MainFrame extends JFrame implements WindowListener,
93 93
     private final CtrlTabWindowManager frameManager;
94 94
     /** The listeners registered with this class. */
95 95
     private final ListenerList listeners = new ListenerList();
96
+    /** Window management. */
97
+    private final WindowManager windowManager;
96 98
     /** The main application icon. */
97 99
     private ImageIcon imageIcon;
98 100
     /** The frame manager that's being used. */
@@ -122,14 +124,17 @@ public final class MainFrame extends JFrame implements WindowListener,
122 124
      *
123 125
      * @param controller Swing controller
124 126
      * @param lifecycleController Controller to use to end the application.
127
+     * @param windowManager Window management
125 128
      */
126 129
     public MainFrame(
127 130
             final SwingController controller,
128
-            final LifecycleController lifecycleController) {
131
+            final LifecycleController lifecycleController,
132
+            final WindowManager windowManager) {
129 133
         super();
130 134
 
131 135
         this.controller = controller;
132 136
         this.lifecycleController = lifecycleController;
137
+        this.windowManager = windowManager;
133 138
 
134 139
         focusOrder = new QueuedLinkedHashSet<>();
135 140
         initComponents();
@@ -359,7 +364,7 @@ public final class MainFrame extends JFrame implements WindowListener,
359 364
                             + "manager, falling back to default.", ex);
360 365
                 } finally {
361 366
                     if (mainFrameManager == null) {
362
-                        mainFrameManager = new TreeFrameManager();
367
+                        mainFrameManager = new TreeFrameManager(windowManager);
363 368
                     }
364 369
                 }
365 370
                 mainFrameManager.setController(controller);

+ 9
- 4
src/com/dmdirc/addons/ui_swing/SwingController.java Bestand weergeven

@@ -184,6 +184,8 @@ public class SwingController extends BaseCommandPlugin implements UIController {
184 184
     /** Apple handler, deals with Mac specific code. */
185 185
     @Getter
186 186
     private final Apple apple;
187
+    /** Window Management. */
188
+    private final WindowManager windowManager;
187 189
 
188 190
     /**
189 191
      * Instantiates a new SwingController.
@@ -202,6 +204,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
202 204
      * @param aliasWrapper Alias wrapper to use for aliases.
203 205
      * @param themeManager Theme manager to use.
204 206
      * @param urlBuilder URL builder to use to resolve icons etc.
207
+     * @param windowManager Window management
205 208
      */
206 209
     public SwingController(
207 210
             final PluginInfo pluginInfo,
@@ -217,7 +220,8 @@ public class SwingController extends BaseCommandPlugin implements UIController {
217 220
             final PerformWrapper performWrapper,
218 221
             final AliasWrapper aliasWrapper,
219 222
             final ThemeManager themeManager,
220
-            final URLBuilder urlBuilder) {
223
+            final URLBuilder urlBuilder,
224
+            final WindowManager windowManager) {
221 225
         super(commandController);
222 226
         this.pluginInfo = pluginInfo;
223 227
         this.identityManager = identityManager;
@@ -231,6 +235,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
231 235
         this.performWrapper = performWrapper;
232 236
         this.aliasWrapper = aliasWrapper;
233 237
         this.themeManager = themeManager;
238
+        this.windowManager = windowManager;
234 239
 
235 240
         globalConfig = identityManager.getGlobalConfiguration();
236 241
         globalIdentity = identityManager.getUserSettings();
@@ -531,7 +536,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
531 536
             @Override
532 537
             public void run() {
533 538
                 initUISettings();
534
-                mainFrame = new MainFrame(SwingController.this, lifecycleController);
539
+                mainFrame = new MainFrame(SwingController.this, lifecycleController, windowManager);
535 540
                 getMainFrame().setVisible(true);
536 541
                 mainFrameCreated.set(true);
537 542
                 swingStatusBar = getMainFrame().getStatusBar();
@@ -545,7 +550,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
545 550
             throw new IllegalStateException(
546 551
                     "Main frame not created. Unable to continue.");
547 552
         }
548
-        WindowManager.getWindowManager().addListenerAndSync(windowFactory);
553
+        windowManager.addListenerAndSync(windowFactory);
549 554
         super.onLoad();
550 555
     }
551 556
 
@@ -553,7 +558,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
553 558
     @Override
554 559
     public void onUnload() {
555 560
         errorDialog.dispose();
556
-        WindowManager.getWindowManager().removeListener(windowFactory);
561
+        windowManager.removeListener(windowFactory);
557 562
         mainFrameCreated.set(false);
558 563
         getMainFrame().dispose();
559 564
         windowFactory.dispose();

+ 12
- 5
src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java Bestand weergeven

@@ -31,9 +31,9 @@ import com.dmdirc.addons.ui_swing.actions.CloseFrameContainerAction;
31 31
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
32 32
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
33 33
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
34
-import com.dmdirc.interfaces.config.ConfigChangeListener;
35 34
 import com.dmdirc.interfaces.FrameInfoListener;
36 35
 import com.dmdirc.interfaces.NotificationListener;
36
+import com.dmdirc.interfaces.config.ConfigChangeListener;
37 37
 import com.dmdirc.interfaces.ui.Window;
38 38
 import com.dmdirc.ui.Colour;
39 39
 import com.dmdirc.ui.WindowManager;
@@ -102,9 +102,16 @@ public final class ButtonBar implements FrameManager, ActionListener,
102 102
     private SwingWindowFactory windowFactory;
103 103
     /** UI Controller. */
104 104
     private SwingController controller;
105
+    /** Window management. */
106
+    private final WindowManager windowManager;
105 107
 
106
-    /** Creates a new instance of ButtonBar. */
107
-    public ButtonBar() {
108
+    /**
109
+     * Creates a new instance of ButtonBar.
110
+     *
111
+     * @param windowManager Window management
112
+     */
113
+    public ButtonBar(final WindowManager windowManager) {
114
+        this.windowManager = windowManager;
108 115
         scrollPane = new JScrollPane();
109 116
         scrollPane.setBorder(null);
110 117
         scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants
@@ -153,7 +160,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
153 160
                 parent.addComponentListener(ButtonBar.this);
154 161
                 ButtonBar.this.buttonWidth = position.isHorizontal()
155 162
                         ? 150 : (parent.getWidth() / NUM_CELLS);
156
-                initButtons(WindowManager.getWindowManager().getRootWindows());
163
+                initButtons(windowManager.getRootWindows());
157 164
                 if (controller.getMainFrame().getActiveFrame() != null) {
158 165
                     selectionChanged(controller.getMainFrame()
159 166
                             .getActiveFrame());
@@ -283,7 +290,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
283 290
         buttonPanel.removeAll();
284 291
 
285 292
         final ArrayList<FrameContainer> windowList = new
286
-                ArrayList<FrameContainer>(WindowManager.getWindowManager().getRootWindows());
293
+ ArrayList<FrameContainer>(windowManager.getRootWindows());
287 294
         if (sortRootWindows) {
288 295
             Collections.sort(windowList, new FrameContainerComparator());
289 296
         }

+ 12
- 6
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java Bestand weergeven

@@ -28,10 +28,10 @@ import com.dmdirc.addons.ui_swing.UIUtilities;
28 28
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
29 29
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
30 30
 import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
31
-import com.dmdirc.interfaces.config.ConfigChangeListener;
32 31
 import com.dmdirc.interfaces.FrameInfoListener;
33 32
 import com.dmdirc.interfaces.NotificationListener;
34 33
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
34
+import com.dmdirc.interfaces.config.ConfigChangeListener;
35 35
 import com.dmdirc.logger.ErrorLevel;
36 36
 import com.dmdirc.logger.Logger;
37 37
 import com.dmdirc.ui.Colour;
@@ -59,7 +59,7 @@ import net.miginfocom.swing.MigLayout;
59 59
 /**
60 60
  * Manages open windows in the application in a tree style view.
61 61
  */
62
-public final class TreeFrameManager implements FrameManager,
62
+public class TreeFrameManager implements FrameManager,
63 63
         Serializable, ConfigChangeListener, NotificationListener,
64 64
         FrameInfoListener {
65 65
 
@@ -77,9 +77,16 @@ public final class TreeFrameManager implements FrameManager,
77 77
     private TreeScroller scroller;
78 78
     /** Configuration manager. */
79 79
     private AggregateConfigProvider config;
80
+    /** Window manage. */
81
+    private final WindowManager windowManager;
80 82
 
81
-    /** creates a new instance of the TreeFrameManager. */
82
-    public TreeFrameManager() {
83
+    /**
84
+     * Creates a new instance of the TreeFrameManager.
85
+     *
86
+     * @param windowManager Window Management
87
+     */
88
+    public TreeFrameManager(final WindowManager windowManager) {
89
+        this.windowManager = windowManager;
83 90
         nodes = new HashMap<>();
84 91
     }
85 92
 
@@ -310,8 +317,7 @@ public final class TreeFrameManager implements FrameManager,
310 317
                 }
311 318
                 scroller = new TreeTreeScroller(controller, tree);
312 319
 
313
-                for (FrameContainer window
314
-                        : WindowManager.getWindowManager().getRootWindows()) {
320
+                for (FrameContainer window : windowManager.getRootWindows()) {
315 321
                     addWindow(null, window);
316 322
                     final Collection<FrameContainer> childWindows = window
317 323
                             .getChildren();

+ 6
- 2
src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java Bestand weergeven

@@ -27,6 +27,7 @@ import com.dmdirc.interfaces.config.IdentityController;
27 27
 import com.dmdirc.plugins.PluginInfo;
28 28
 import com.dmdirc.plugins.PluginManager;
29 29
 import com.dmdirc.plugins.implementations.BasePlugin;
30
+import com.dmdirc.ui.WindowManager;
30 31
 
31 32
 import lombok.Getter;
32 33
 import lombok.RequiredArgsConstructor;
@@ -51,6 +52,9 @@ public class WebInterfacePlugin extends BasePlugin {
51 52
     /** This plugin's information object. */
52 53
     private final PluginInfo pluginInfo;
53 54
 
55
+    /** Window management. */
56
+    private final WindowManager windowManager;
57
+
54 58
     /** The UI that we're using. */
55 59
     @Getter
56 60
     private WebInterfaceUI controller;
@@ -61,7 +65,7 @@ public class WebInterfacePlugin extends BasePlugin {
61 65
         if (controller == null) {
62 66
             controller = new WebInterfaceUI(getDomain(),
63 67
                     identityController, serverManager,
64
-                    pluginManager, pluginInfo);
68
+                    pluginManager, pluginInfo, windowManager);
65 69
         }
66 70
     }
67 71
 
@@ -73,7 +77,7 @@ public class WebInterfacePlugin extends BasePlugin {
73 77
     public void addWebHandler(final Handler newHandler) {
74 78
         if (controller == null) {
75 79
             controller = new WebInterfaceUI(getDomain(), identityController,
76
-                    serverManager, pluginManager, pluginInfo);
80
+                    serverManager, pluginManager, pluginInfo, windowManager);
77 81
         }
78 82
 
79 83
         controller.addWebHandler(newHandler);

+ 5
- 2
src/com/dmdirc/addons/ui_web/WebInterfaceUI.java Bestand weergeven

@@ -32,6 +32,7 @@ import com.dmdirc.interfaces.ui.UIController;
32 32
 import com.dmdirc.interfaces.ui.Window;
33 33
 import com.dmdirc.plugins.PluginInfo;
34 34
 import com.dmdirc.plugins.PluginManager;
35
+import com.dmdirc.ui.WindowManager;
35 36
 import com.dmdirc.ui.core.components.StatusBarManager;
36 37
 
37 38
 import java.net.URI;
@@ -76,13 +77,15 @@ public class WebInterfaceUI implements UIController {
76 77
      * @param serverManager The manager to use to find and create servers
77 78
      * @param pluginManager The manager to use to find other plugins
78 79
      * @param pluginInfo The information object for this UI's plugin.
80
+     * @param coreWindowManager Window management
79 81
      */
80 82
     public WebInterfaceUI(
81 83
             final String domain,
82 84
             final IdentityController identityController,
83 85
             final ServerManager serverManager,
84 86
             final PluginManager pluginManager,
85
-            final PluginInfo pluginInfo) {
87
+            final PluginInfo pluginInfo,
88
+            final WindowManager coreWindowManager) {
86 89
         super();
87 90
 
88 91
         this.pluginManager = pluginManager;
@@ -119,7 +122,7 @@ public class WebInterfaceUI implements UIController {
119 122
             // Break horribly!
120 123
         }
121 124
 
122
-        windowManager = new WebWindowManager(this);
125
+        windowManager = new WebWindowManager(this, coreWindowManager);
123 126
 
124 127
         StatusBarManager.getStatusBarManager().registerStatusBar(new WebStatusBar(handler));
125 128
     }

+ 2
- 2
src/com/dmdirc/addons/ui_web/WebWindowManager.java Bestand weergeven

@@ -88,10 +88,10 @@ public class WebWindowManager implements FrameListener {
88 88
      *
89 89
      * @param controller The Web UI controller that owns this manager
90 90
      */
91
-    public WebWindowManager(final WebInterfaceUI controller) {
91
+    public WebWindowManager(final WebInterfaceUI controller, final WindowManager windowManager) {
92 92
         this.controller = controller;
93 93
 
94
-        WindowManager.getWindowManager().addListenerAndSync(this);
94
+        windowManager.addListenerAndSync(this);
95 95
     }
96 96
 
97 97
     /**

+ 3
- 1
test/com/dmdirc/addons/redirect/RedirectCommandTest.java Bestand weergeven

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.parsers.CommandParser;
32 32
 import com.dmdirc.interfaces.CommandController;
33 33
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
34 34
 import com.dmdirc.interfaces.ui.InputWindow;
35
+import com.dmdirc.ui.WindowManager;
35 36
 
36 37
 import org.junit.Before;
37 38
 import org.junit.Test;
@@ -52,6 +53,7 @@ public class RedirectCommandTest {
52 53
     @Mock private WritableFrameContainer frameContainer;
53 54
     @Mock private AggregateConfigProvider configProvider;
54 55
     @Mock private CommandParser commandParser;
56
+    @Mock private WindowManager windowManager;
55 57
 
56 58
     @Before
57 59
     public void setup() {
@@ -65,7 +67,7 @@ public class RedirectCommandTest {
65 67
         doAnswer(new Answer<Void>() {
66 68
             @Override
67 69
             public Void answer(final InvocationOnMock invocation) throws Throwable {
68
-                new Echo(commandController).execute(
70
+                new Echo(commandController, windowManager).execute(
69 71
                         ((FrameContainer) invocation.getArguments()[0]),
70 72
                         new CommandArguments(commandController, "/echo test"),
71 73
                         null);

Laden…
Annuleren
Opslaan