Selaa lähdekoodia

Don't pass WindowManagers to FrameContainers.

Change-Id: I0f60ac23438313cab49cdb86c089938f5ee44abc
Depends-On: Iadbca8a28f7ef3372df7fda722a3cbba2a0fbad6
Reviewed-on: http://gerrit.dmdirc.com/2843
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8
Chris Smith 10 vuotta sitten
vanhempi
commit
c4c7c42298

+ 4
- 9
src/com/dmdirc/addons/dcc/ChatContainer.java Näytä tiedosto

@@ -27,7 +27,6 @@ import com.dmdirc.addons.dcc.actions.DCCActions;
27 27
 import com.dmdirc.addons.dcc.io.DCCChat;
28 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.messages.MessageSinkManager;
30
-import com.dmdirc.ui.WindowManager;
31 30
 import com.dmdirc.ui.core.components.WindowComponent;
32 31
 
33 32
 import java.util.Arrays;
@@ -47,22 +46,20 @@ public class ChatContainer extends DCCFrameContainer implements DCCChatHandler {
47 46
     /**
48 47
      * Creates a new instance of DCCChatWindow with a given DCCChat object.
49 48
      *
50
-     * @param plugin the DCC Plugin responsible for this window
51 49
      * @param dcc The DCCChat object this window wraps around
52 50
      * @param configManager Config manager
53 51
      * @param title The title of this window
54 52
      * @param nick My Current Nickname
55 53
      * @param targetNick Nickname of target
56 54
      * @param messageSinkManager The sink manager to use to despatch messages.
57
-     * @param windowManager Window Management
58 55
      */
59
-    public ChatContainer(final DCCPlugin plugin, final DCCChat dcc,
56
+    public ChatContainer(final DCCChat dcc,
60 57
             final AggregateConfigProvider configManager, final String title,
61
-            final String nick, final String targetNick, final MessageSinkManager messageSinkManager,
62
-            final WindowManager windowManager) {
58
+            final String nick, final String targetNick,
59
+            final MessageSinkManager messageSinkManager) {
63 60
         super(title, "dcc-chat-inactive", configManager,
64 61
                 new DCCCommandParser(configManager),
65
-                messageSinkManager, windowManager,
62
+                messageSinkManager,
66 63
                 Arrays.asList(
67 64
                     WindowComponent.TEXTAREA.getIdentifier(),
68 65
                     WindowComponent.INPUTFIELD.getIdentifier()));
@@ -70,8 +67,6 @@ public class ChatContainer extends DCCFrameContainer implements DCCChatHandler {
70 67
         dcc.setHandler(this);
71 68
         nickname = nick;
72 69
         otherNickname = targetNick;
73
-
74
-        windowManager.addWindow(plugin.getContainer(), this);
75 70
     }
76 71
 
77 72
     /**

+ 9
- 7
src/com/dmdirc/addons/dcc/DCCCommand.java Näytä tiedosto

@@ -157,9 +157,9 @@ public class DCCCommand extends Command implements IntelligentCommand {
157 157
             final String target, final boolean isSilent) {
158 158
         final DCCChat chat = new DCCChat();
159 159
         if (myPlugin.listen(chat)) {
160
-            final ChatContainer window = new ChatContainer(myPlugin, chat,
161
-                    origin.getConfigManager(),
162
-                    "*Chat: " + target, myNickname, target, messageSinkManager, windowManager);
160
+            final ChatContainer window = new ChatContainer(chat, origin.getConfigManager(),
161
+                    "*Chat: " + target, myNickname, target, messageSinkManager);
162
+            windowManager.addWindow(myPlugin.getContainer(), window);
163 163
             parser.sendCTCP(target, "DCC", "CHAT chat " + DCC.ipToLong(
164 164
                     myPlugin.getListenIP(parser)) + " " + chat.getPort());
165 165
             ActionManager.getActionManager().triggerEvent(
@@ -235,9 +235,10 @@ public class DCCCommand extends Command implements IntelligentCommand {
235 235
                 if (origin.getConfigManager().getOptionBool(
236 236
                         myPlugin.getDomain(), "send.reverse")) {
237 237
                     final Parser parser = server.getParser();
238
-                    new TransferContainer(myPlugin, send,
238
+                    final TransferContainer container = new TransferContainer(myPlugin, send,
239 239
                             origin.getConfigManager(), "Send: " + target,
240
-                            target, server, windowManager);
240
+                            target, server);
241
+                    windowManager.addWindow(myPlugin.getContainer(), container);
241 242
                     parser.sendCTCP(target, "DCC", "SEND \""
242 243
                             + selectedFile.getName() + "\" "
243 244
                             + DCC.ipToLong(myPlugin.getListenIP(parser))
@@ -247,9 +248,10 @@ public class DCCCommand extends Command implements IntelligentCommand {
247 248
                 } else {
248 249
                     final Parser parser = server.getParser();
249 250
                     if (myPlugin.listen(send)) {
250
-                        new TransferContainer(myPlugin, send,
251
+                        final TransferContainer container = new TransferContainer(myPlugin, send,
251 252
                                 origin.getConfigManager(), "*Send: "
252
-                                + target, target, server, windowManager);
253
+                                + target, target, server);
254
+                        windowManager.addWindow(myPlugin.getContainer(), container);
253 255
                         parser.sendCTCP(target, "DCC", "SEND \""
254 256
                                 + selectedFile.getName() + "\" "
255 257
                                 + DCC.ipToLong(myPlugin.getListenIP(parser))

+ 2
- 4
src/com/dmdirc/addons/dcc/DCCFrameContainer.java Näytä tiedosto

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

+ 10
- 7
src/com/dmdirc/addons/dcc/DCCPlugin.java Näytä tiedosto

@@ -184,8 +184,9 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
184 184
                 }
185 185
                 final boolean resume = handleResume(jc);
186 186
                 if (reverse && !token.isEmpty()) {
187
-                    new TransferContainer(DCCPlugin.this, send, config,
188
-                            "*Receive: " + nickname, nickname, null, windowManager);
187
+                    TransferContainer container = new TransferContainer(DCCPlugin.this, send,
188
+                            config, "*Receive: " + nickname, nickname, null);
189
+                    windowManager.addWindow(getContainer(), container);
189 190
                     send.setToken(token);
190 191
                     if (resume) {
191 192
                         if (config.getOptionBool(getDomain(),
@@ -209,8 +210,9 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
209 210
                         }
210 211
                     }
211 212
                 } else {
212
-                    new TransferContainer(DCCPlugin.this, send, config,
213
-                            "Receive: " + nickname, nickname, null, windowManager);
213
+                    TransferContainer container = new TransferContainer(DCCPlugin.this, send,
214
+                            config, "Receive: " + nickname, nickname, null);
215
+                    windowManager.addWindow(getContainer(), container);
214 216
                     if (resume) {
215 217
                         parser.sendCTCP(nickname, "DCC", "RESUME "
216 218
                                 + send.getShortFileName() + " "
@@ -393,8 +395,9 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
393 395
             }
394 396
             final String myNickname = ((Server) arguments[0]).getParser()
395 397
                     .getLocalClient().getNickname();
396
-            final DCCFrameContainer f = new ChatContainer(this, chat, config,
397
-                    "Chat: " + nickname, myNickname, nickname, messageSinkManager, windowManager);
398
+            final DCCFrameContainer f = new ChatContainer(chat, config,
399
+                    "Chat: " + nickname, myNickname, nickname, messageSinkManager);
400
+            windowManager.addWindow(getContainer(), f);
398 401
             f.addLine("DCCChatStarting", nickname, chat.getHost(),
399 402
                     chat.getPort());
400 403
             chat.connect();
@@ -642,7 +645,7 @@ public class DCCPlugin extends BaseCommandPlugin implements ActionListener {
642 645
      * Create the container window.
643 646
      */
644 647
     protected void createContainer() {
645
-        container = new PlaceholderContainer(this, config, controller, windowManager);
648
+        container = new PlaceholderContainer(this, config, controller);
646 649
         windowManager.addWindow(container);
647 650
     }
648 651
 

+ 2
- 5
src/com/dmdirc/addons/dcc/PlaceholderContainer.java Näytä tiedosto

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

+ 2
- 7
src/com/dmdirc/addons/dcc/TransferContainer.java Näytä tiedosto

@@ -32,7 +32,6 @@ import com.dmdirc.addons.dcc.io.DCCTransfer;
32 32
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
33 33
 import com.dmdirc.parser.interfaces.Parser;
34 34
 import com.dmdirc.parser.interfaces.callbacks.SocketCloseListener;
35
-import com.dmdirc.ui.WindowManager;
36 35
 
37 36
 import java.awt.Desktop;
38 37
 import java.io.File;
@@ -91,16 +90,14 @@ public class TransferContainer extends FrameContainer implements
91 90
      * @param title The title of this window
92 91
      * @param targetNick Nickname of target
93 92
      * @param server The server that initiated this send
94
-     * @param windowManager Window Management
95 93
      */
96 94
     public TransferContainer(final DCCPlugin plugin, final DCCTransfer dcc,
97 95
             final AggregateConfigProvider config, final String title,
98
-            final String targetNick, final Server server,
99
-            final WindowManager windowManager) {
96
+            final String targetNick, final Server server) {
100 97
         super(dcc.getType() == DCCTransfer.TransferType.SEND
101 98
                 ? "dcc-send-inactive" : "dcc-receive-inactive",
102 99
                 title, title, config,
103
-                Arrays.asList("com.dmdirc.addons.dcc.ui.TransferPanel"), windowManager);
100
+                Arrays.asList("com.dmdirc.addons.dcc.ui.TransferPanel"));
104 101
         this.plugin = plugin;
105 102
         this.dcc = dcc;
106 103
         this.server = server;
@@ -115,8 +112,6 @@ public class TransferContainer extends FrameContainer implements
115 112
         dcc.addHandler(this);
116 113
 
117 114
         otherNickname = targetNick;
118
-
119
-        windowManager.addWindow(plugin.getContainer(), this);
120 115
     }
121 116
 
122 117
     /** {@inheritDoc} */

+ 1
- 3
src/com/dmdirc/addons/logging/HistoryWindow.java Näytä tiedosto

@@ -45,9 +45,7 @@ public class HistoryWindow extends FrameContainer {
45 45
     public HistoryWindow(final String title, final ReverseFileReader reader,
46 46
                          final FrameContainer parent, final int numLines) {
47 47
         super("raw", title, title, parent.getConfigManager(),
48
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), parent.getWindowManager());
49
-
50
-        parent.getWindowManager().addWindow(parent, this);
48
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
51 49
 
52 50
         final int frameBufferSize = parent.getConfigManager().getOptionInt(
53 51
                 "ui", "frameBufferSize");

+ 9
- 2
src/com/dmdirc/addons/logging/LoggingPlugin.java Näytä tiedosto

@@ -48,6 +48,7 @@ import com.dmdirc.parser.interfaces.ClientInfo;
48 48
 import com.dmdirc.parser.interfaces.Parser;
49 49
 import com.dmdirc.plugins.PluginInfo;
50 50
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
51
+import com.dmdirc.ui.WindowManager;
51 52
 import com.dmdirc.ui.messages.Styliser;
52 53
 import com.dmdirc.util.io.ReverseFileReader;
53 54
 import com.dmdirc.util.io.StreamUtils;
@@ -95,6 +96,8 @@ public class LoggingPlugin extends BaseCommandPlugin implements ActionListener,
95 96
     private final ConfigProvider identity;
96 97
     /** Parent Identity Manager. */
97 98
     private final IdentityController identityController;
99
+    /** The manager to add history windows to. */
100
+    private final WindowManager windowManager;
98 101
 
99 102
     /** Timer used to close idle files. */
100 103
     protected Timer idleFileTimer;
@@ -113,13 +116,16 @@ public class LoggingPlugin extends BaseCommandPlugin implements ActionListener,
113 116
      * @param actionController The action controller to register listeners with
114 117
      * @param identityController The Identity Manager that controls the current config
115 118
      * @param commandController Command controller to register commands
119
+     * @param windowManager The manager to add history windows to.
116 120
      */
117 121
     public LoggingPlugin(final PluginInfo pluginInfo,
118 122
             final ActionController actionController,
119 123
             final IdentityController identityController,
120
-            final CommandController commandController) {
124
+            final CommandController commandController,
125
+            final WindowManager windowManager) {
121 126
         super(commandController);
122 127
         this.identityController = identityController;
128
+        this.windowManager = windowManager;
123 129
 
124 130
         this.pluginInfo = pluginInfo;
125 131
         this.actionController = actionController;
@@ -865,7 +871,8 @@ public class LoggingPlugin extends BaseCommandPlugin implements ActionListener,
865 871
             return false;
866 872
         }
867 873
 
868
-        new HistoryWindow("History", reader, target, historyLines);
874
+        HistoryWindow window = new HistoryWindow("History", reader, target, historyLines);
875
+        windowManager.addWindow(target, window);
869 876
 
870 877
         return true;
871 878
     }

+ 2
- 5
src/com/dmdirc/addons/parserdebug/DebugWindow.java Näytä tiedosto

@@ -26,7 +26,6 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.parser.interfaces.Parser;
28 28
 import com.dmdirc.parser.interfaces.callbacks.DebugInfoListener;
29
-import com.dmdirc.ui.WindowManager;
30 29
 import com.dmdirc.ui.core.components.WindowComponent;
31 30
 
32 31
 import java.util.Arrays;
@@ -52,14 +51,12 @@ public class DebugWindow extends FrameContainer {
52 51
      * @param server The Server window this is a child of
53 52
      * @param windowManager Window management
54 53
      */
55
-    public DebugWindow(final DebugPlugin plugin, final String title, final Parser parser, final Server server, final WindowManager windowManager) {
54
+    public DebugWindow(final DebugPlugin plugin, final String title, final Parser parser, final Server server) {
56 55
         super("raw", "Parser Debug", title, server.getConfigManager(),
57
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), windowManager);
56
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
58 57
         this.plugin = plugin;
59 58
         this.parser = parser;
60 59
         this.server = server;
61
-
62
-        windowManager.addWindow(server, this);
63 60
     }
64 61
 
65 62
     /**

+ 2
- 1
src/com/dmdirc/addons/parserdebug/ParserDebugCommand.java Näytä tiedosto

@@ -98,7 +98,8 @@ public final class ParserDebugCommand extends Command {
98 98
             try {
99 99
                 parser.getCallbackManager().addCallback(DebugInfoListener.class, myPlugin);
100 100
                 final DebugWindow window = new DebugWindow(myPlugin,
101
-                        "Parser Debug", parser, origin.getServer(), windowManager);
101
+                        "Parser Debug", parser, origin.getServer());
102
+                windowManager.addWindow(origin.getServer(), window);
102 103
                 myPlugin.registeredParsers.put(parser, window);
103 104
                 sendLine(origin, isSilent, FORMAT_OUTPUT, "Adding callback ok");
104 105
                 window.addLine("======================", true);

+ 1
- 1
src/com/dmdirc/addons/redirect/FakeWriteableFrameContainer.java Näytä tiedosto

@@ -52,7 +52,7 @@ public class FakeWriteableFrameContainer extends WritableFrameContainer {
52 52
             final MessageSinkManager messageSinkManager) {
53 53
         super(target.getIcon(), target.getName(), target.getTitle(),
54 54
                 target.getConfigManager(), target.getCommandParser(),
55
-                messageSinkManager, target.getWindowManager(), Collections.<String>emptyList());
55
+                messageSinkManager, Collections.<String>emptyList());
56 56
         this.target = target;
57 57
     }
58 58
 

+ 4
- 2
src/com/dmdirc/addons/swingdebug/SwingDebugPlugin.java Näytä tiedosto

@@ -104,7 +104,8 @@ public class SwingDebugPlugin extends BasePlugin implements ActionListener {
104 104
         if (e.getSource() == showSysOut) {
105 105
             if (showSysOut.isSelected()) {
106 106
                 sysoutFrame = new SystemStreamContainer(SystemStreamType.Out,
107
-                        controller.getGlobalConfig(), this, windowManager);
107
+                        controller.getGlobalConfig(), this);
108
+                windowManager.addWindow(sysoutFrame);
108 109
             } else {
109 110
                 sysoutFrame.close();
110 111
             }
@@ -113,7 +114,8 @@ public class SwingDebugPlugin extends BasePlugin implements ActionListener {
113 114
         if (e.getSource() == showSysErr) {
114 115
             if (showSysErr.isSelected()) {
115 116
                 syserrFrame = new SystemStreamContainer(SystemStreamType.Error,
116
-                        controller.getGlobalConfig(), this, windowManager);
117
+                        controller.getGlobalConfig(), this);
118
+                windowManager.addWindow(syserrFrame);
117 119
             } else {
118 120
                 syserrFrame.close();
119 121
             }

+ 2
- 5
src/com/dmdirc/addons/swingdebug/SystemStreamContainer.java Näytä tiedosto

@@ -25,7 +25,6 @@ package com.dmdirc.addons.swingdebug;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
-import com.dmdirc.ui.WindowManager;
29 28
 import com.dmdirc.ui.core.components.WindowComponent;
30 29
 
31 30
 import java.io.IOException;
@@ -47,20 +46,18 @@ public class SystemStreamContainer extends FrameContainer {
47 46
      * @param stream Stream to wrap
48 47
      * @param config Config to wrap
49 48
      * @param plugin Parent plugin
50
-     * @param windowManager Window management
51 49
      */
52 50
     public SystemStreamContainer(final SystemStreamType stream,
53 51
             final AggregateConfigProvider config,
54
-            final SwingDebugPlugin plugin, final WindowManager windowManager) {
52
+            final SwingDebugPlugin plugin) {
55 53
         super("dmdirc", stream.toString(), stream.toString(), config,
56
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), windowManager);
54
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
57 55
         this.plugin = plugin;
58 56
         try {
59 57
             thread = new SystemStreamRedirectThread(stream, getDocument());
60 58
             thread.start();
61 59
         } catch (IOException ex) {
62 60
         }
63
-        windowManager.addWindow(this);
64 61
     }
65 62
 
66 63
     /** {@inheritDoc} */

Loading…
Peruuta
Tallenna