Procházet zdrojové kódy

Remove most singleton uses of WindowManager.

Change-Id: Idd97b752328310b4f829a45a43de5fdf6f5712a5
Depends-On: I1f054c7423106afe3fc49db8dc44613ec11c35bb
Reviewed-on: http://gerrit.dmdirc.com/2816
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8rc1
Greg Holmes před 10 roky
rodič
revize
0c43d2a21e

+ 4
- 3
src/com/dmdirc/Channel.java Zobrazit soubor

@@ -101,9 +101,10 @@ public class Channel extends MessageTarget implements ConfigChangeListener {
101 101
      * @param newChannelInfo The parser's channel object that corresponds to
102 102
      * this channel
103 103
      * @param focus Whether or not to focus this channel
104
+     * @param windowManager Window management
104 105
      */
105 106
     public Channel(final Server newServer, final ChannelInfo newChannelInfo,
106
-            final boolean focus) {
107
+            final boolean focus, final WindowManager windowManager) {
107 108
         super("channel-inactive", newChannelInfo.getName(),
108 109
                 Styliser.stipControlCodes(newChannelInfo.getName()),
109 110
                 new ConfigManager(newServer.getProtocol(), newServer.getIrcd(),
@@ -112,7 +113,7 @@ public class Channel extends MessageTarget implements ConfigChangeListener {
112 113
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
113 114
                 WindowComponent.INPUTFIELD.getIdentifier(),
114 115
                 WindowComponent.TOPICBAR.getIdentifier(),
115
-                WindowComponent.USERLIST.getIdentifier()));
116
+                        WindowComponent.USERLIST.getIdentifier()), windowManager);
116 117
 
117 118
         channelInfo = newChannelInfo;
118 119
         server = newServer;
@@ -133,7 +134,7 @@ public class Channel extends MessageTarget implements ConfigChangeListener {
133 134
         tabCompleter.addEntries(TabCompletionType.COMMAND,
134 135
                 CommandManager.getCommandManager().getCommandNames(CommandType.TYPE_CHAT));
135 136
 
136
-        WindowManager.getWindowManager().addWindow(server, this, focus);
137
+        windowManager.addWindow(server, this, focus);
137 138
 
138 139
         eventHandler = new ChannelEventHandler(this);
139 140
 

+ 1
- 1
src/com/dmdirc/ClientModule.java Zobrazit soubor

@@ -374,7 +374,7 @@ public class ClientModule {
374 374
      */
375 375
     @Provides
376 376
     public WindowManager getWindowManager() {
377
-        return WindowManager.getWindowManager();
377
+        return new WindowManager();
378 378
     }
379 379
 
380 380
     /**

+ 6
- 5
src/com/dmdirc/CustomWindow.java Zobrazit soubor

@@ -43,9 +43,9 @@ public class CustomWindow extends FrameContainer {
43 43
     public CustomWindow(final String name, final String title,
44 44
             final FrameContainer parent) {
45 45
         super("custom", name, title, parent.getConfigManager(),
46
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
46
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), parent.getWindowManager());
47 47
 
48
-        WindowManager.getWindowManager().addWindow(parent, this);
48
+        parent.getWindowManager().addWindow(parent, this);
49 49
     }
50 50
 
51 51
     /**
@@ -53,13 +53,14 @@ public class CustomWindow extends FrameContainer {
53 53
      *
54 54
      * @param name The name of this custom window
55 55
      * @param title The parent of this custom window
56
+     * @param windowManager For window management
56 57
      */
57
-    public CustomWindow(final String name, final String title) {
58
+    public CustomWindow(final String name, final String title, final WindowManager windowManager) {
58 59
         super("custom", name, title,
59 60
                 IdentityManager.getIdentityManager().getGlobalConfiguration(),
60
-                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
61
+                Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()), windowManager);
61 62
 
62
-        WindowManager.getWindowManager().addWindow(this);
63
+        windowManager.addWindow(this);
63 64
     }
64 65
 
65 66
     /** {@inheritDoc} */

+ 9
- 2
src/com/dmdirc/FrameContainer.java Zobrazit soubor

@@ -110,6 +110,10 @@ public abstract class FrameContainer {
110 110
     @Getter
111 111
     private final IconManager iconManager;
112 112
 
113
+    /** Window management. */
114
+    @Getter
115
+    private final WindowManager windowManager;
116
+
113 117
     /**
114 118
      * Instantiate new frame container.
115 119
      *
@@ -118,12 +122,15 @@ public abstract class FrameContainer {
118 122
      * @param title The title of this container
119 123
      * @param config The config manager for this container
120 124
      * @param components The UI components that this frame requires
125
+     * @param windowManager Window manager to register from
121 126
      * @since 0.6.4
122 127
      */
123 128
     protected FrameContainer(
124 129
             final String icon, final String name,
125 130
             final String title, final AggregateConfigProvider config,
126
-            final Collection<String> components) {
131
+            final Collection<String> components,
132
+            final WindowManager windowManager) {
133
+        this.windowManager = windowManager;
127 134
         this.configManager = config;
128 135
         this.name = name;
129 136
         this.title = title;
@@ -292,7 +299,7 @@ public abstract class FrameContainer {
292 299
 
293 300
         windowClosing();
294 301
 
295
-        WindowManager.getWindowManager().removeWindow(this);
302
+        windowManager.removeWindow(this);
296 303
     }
297 304
 
298 305
     /**

+ 6
- 4
src/com/dmdirc/GlobalWindow.java Zobrazit soubor

@@ -57,12 +57,14 @@ public class GlobalWindow extends WritableFrameContainer {
57 57
      *
58 58
      * @param config The ConfigManager to retrieve settings from.
59 59
      * @param parser The command parser to use to parse input.
60
+     * @param windowManager Window management
60 61
      */
61
-    public GlobalWindow(final AggregateConfigProvider config, final CommandParser parser) {
62
+    public GlobalWindow(final AggregateConfigProvider config, final CommandParser parser,
63
+            final WindowManager windowManager) {
62 64
         super("icon", "Global", "(Global)",
63 65
                 config, parser,
64 66
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
65
-                WindowComponent.INPUTFIELD.getIdentifier()));
67
+                        WindowComponent.INPUTFIELD.getIdentifier()), windowManager);
66 68
 
67 69
         tabCompleter = new TabCompleter(config);
68 70
         tabCompleter.addEntries(TabCompletionType.COMMAND,
@@ -70,7 +72,7 @@ public class GlobalWindow extends WritableFrameContainer {
70 72
         tabCompleter.addEntries(TabCompletionType.COMMAND,
71 73
                 AliasWrapper.getAliasWrapper().getAliases());
72 74
 
73
-        WindowManager.getWindowManager().addWindow(this);
75
+        windowManager.addWindow(this);
74 76
     }
75 77
 
76 78
     /** {@inheritDoc} */
@@ -137,7 +139,7 @@ public class GlobalWindow extends WritableFrameContainer {
137 139
                 if (globalWindow == null) {
138 140
                     globalWindow = new GlobalWindow(configManager,
139 141
                             new GlobalCommandParser(configManager,
140
-                            CommandManager.getCommandManager()));
142
+                                    CommandManager.getCommandManager()), WindowManager.getWindowManager());
141 143
                 }
142 144
             } else {
143 145
                 if (globalWindow != null) {

+ 5
- 2
src/com/dmdirc/MessageTarget.java Zobrazit soubor

@@ -24,6 +24,7 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.commandparser.parsers.CommandParser;
26 26
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
+import com.dmdirc.ui.WindowManager;
27 28
 
28 29
 import java.util.Collection;
29 30
 
@@ -42,12 +43,14 @@ public abstract class MessageTarget extends WritableFrameContainer {
42 43
      * @param config The config manager to use for this target
43 44
      * @param parser The command parser for this container
44 45
      * @param components The UI components that this frame requires
46
+     * @param windowManager Window manager
45 47
      * @since 0.6.4
46 48
      */
47 49
     public MessageTarget(final String icon, final String name,
48 50
             final String title, final AggregateConfigProvider config,
49
-            final CommandParser parser, final Collection<String> components) {
50
-        super(icon, name, title, config, parser, components);
51
+            final CommandParser parser, final Collection<String> components,
52
+            final WindowManager windowManager) {
53
+        super(icon, name, title, config, parser, components, windowManager);
51 54
     }
52 55
 
53 56
     /**

+ 7
- 5
src/com/dmdirc/Query.java Zobrazit soubor

@@ -72,9 +72,10 @@ public class Query extends MessageTarget implements PrivateActionListener,
72 72
      *
73 73
      * @param newHost host of the remove client
74 74
      * @param newServer The server object that this Query belongs to
75
+     * @param windowManager Window management
75 76
      */
76
-    public Query(final Server newServer, final String newHost) {
77
-        this(newServer, newHost, false);
77
+    public Query(final Server newServer, final String newHost, final WindowManager windowManager) {
78
+        this(newServer, newHost, false, windowManager);
78 79
     }
79 80
 
80 81
     /**
@@ -83,20 +84,21 @@ public class Query extends MessageTarget implements PrivateActionListener,
83 84
      * @param newHost host of the remove client
84 85
      * @param newServer The server object that this Query belongs to
85 86
      * @param focus Should we focus the query on open?
87
+     * @param windowManager Window management
86 88
      */
87 89
     public Query(final Server newServer, final String newHost,
88
-            final boolean focus) {
90
+            final boolean focus, final WindowManager windowManager) {
89 91
         super("query", newServer.parseHostmask(newHost)[0],
90 92
                 newServer.parseHostmask(newHost)[0],
91 93
                 newServer.getConfigManager(), new QueryCommandParser(newServer),
92 94
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
93
-                WindowComponent.INPUTFIELD.getIdentifier()));
95
+                        WindowComponent.INPUTFIELD.getIdentifier()), windowManager);
94 96
 
95 97
         this.server = newServer;
96 98
         this.host = newHost;
97 99
         this.nickname = server.parseHostmask(host)[0];
98 100
 
99
-        WindowManager.getWindowManager().addWindow(server, this, focus);
101
+        windowManager.addWindow(server, this, focus);
100 102
 
101 103
         ActionManager.getActionManager().triggerEvent(
102 104
                 CoreActionType.QUERY_OPENED, null, this);

+ 5
- 4
src/com/dmdirc/Raw.java Zobrazit soubor

@@ -40,7 +40,7 @@ import java.util.Date;
40 40
  * Handles the raw window (which shows the user raw data being sent and
41 41
  * received to/from the server).
42 42
  */
43
-public final class Raw extends WritableFrameContainer
43
+public class Raw extends WritableFrameContainer
44 44
         implements DataInListener, DataOutListener {
45 45
 
46 46
     /** The server object that's being monitored. */
@@ -50,18 +50,19 @@ public final class Raw extends WritableFrameContainer
50 50
      * Creates a new instance of Raw.
51 51
      *
52 52
      * @param newServer the server to monitor
53
+     * @param windowManager Window management
53 54
      */
54
-    public Raw(final Server newServer) {
55
+    public Raw(final Server newServer, final WindowManager windowManager) {
55 56
         super("raw", "Raw", "(Raw log)", newServer.getConfigManager(),
56 57
                 new ServerCommandParser(newServer.getConfigManager()),
57 58
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
58
-                WindowComponent.INPUTFIELD.getIdentifier()));
59
+                        WindowComponent.INPUTFIELD.getIdentifier()), windowManager);
59 60
 
60 61
         this.server = newServer;
61 62
 
62 63
         getCommandParser().setOwner(server);
63 64
 
64
-        WindowManager.getWindowManager().addWindow(server, this);
65
+        windowManager.addWindow(server, this);
65 66
     }
66 67
 
67 68
     /**

+ 11
- 4
src/com/dmdirc/Server.java Zobrazit soubor

@@ -52,6 +52,7 @@ import com.dmdirc.parser.interfaces.StringConverter;
52 52
 import com.dmdirc.tls.CertificateManager;
53 53
 import com.dmdirc.tls.CertificateProblemListener;
54 54
 import com.dmdirc.ui.StatusMessage;
55
+import com.dmdirc.ui.WindowManager;
55 56
 import com.dmdirc.ui.core.components.StatusBarManager;
56 57
 import com.dmdirc.ui.core.components.WindowComponent;
57 58
 import com.dmdirc.ui.input.TabCompleter;
@@ -185,6 +186,9 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
185 186
     /** Factory to use to create new identities. */
186 187
     private final IdentityFactory identityFactory;
187 188
 
189
+    /** Window manager to pas to children. */
190
+    private final WindowManager windowManager;
191
+
188 192
     // </editor-fold>
189 193
 
190 194
     // </editor-fold>
@@ -203,6 +207,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
203 207
      * @param tabCompleterFactory The factory to use for tab completers.
204 208
      * @param commandController The controller to use to retrieve commands.
205 209
      * @param identityFactory The factory to use to create identities.
210
+     * @param windowManager Window Manager
206 211
      * @param uri The address of the server to connect to
207 212
      * @param profile The profile to use
208 213
      */
@@ -214,6 +219,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
214 219
             final TabCompleterFactory tabCompleterFactory,
215 220
             final CommandController commandController,
216 221
             final IdentityFactory identityFactory,
222
+            final WindowManager windowManager,
217 223
             final URI uri,
218 224
             final ConfigProvider profile) {
219 225
         super("server-disconnected",
@@ -223,11 +229,12 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
223 229
                 commandParser,
224 230
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
225 231
                 WindowComponent.INPUTFIELD.getIdentifier(),
226
-                WindowComponent.CERTIFICATE_VIEWER.getIdentifier()));
232
+                        WindowComponent.CERTIFICATE_VIEWER.getIdentifier()), windowManager);
227 233
 
228 234
         this.manager = manager;
229 235
         this.parserFactory = parserFactory;
230 236
         this.identityFactory = identityFactory;
237
+        this.windowManager = windowManager;
231 238
         setConnectionDetails(uri, profile);
232 239
 
233 240
         tabCompleter = tabCompleterFactory.getTabCompleter(configManager,
@@ -541,7 +548,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
541 548
         final String lnick = converter.toLowerCase(nick);
542 549
 
543 550
         if (!queries.containsKey(lnick)) {
544
-            final Query newQuery = new Query(this, host, focus);
551
+            final Query newQuery = new Query(this, host, focus, windowManager);
545 552
 
546 553
             tabCompleter.addEntry(TabCompletionType.QUERY_NICK, nick);
547 554
             queries.put(lnick, newQuery);
@@ -577,7 +584,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
577 584
     @Override
578 585
     public void addRaw() {
579 586
         if (raw == null) {
580
-            raw = new Raw(this);
587
+            raw = new Raw(this, windowManager);
581 588
 
582 589
             try {
583 590
                 parserLock.readLock().lock();
@@ -633,7 +640,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
633 640
             getChannel(chan.getName()).setChannelInfo(chan);
634 641
             getChannel(chan.getName()).selfJoin();
635 642
         } else {
636
-            final Channel newChan = new Channel(this, chan, focus);
643
+            final Channel newChan = new Channel(this, chan, focus, windowManager);
637 644
 
638 645
             tabCompleter.addEntry(TabCompletionType.CHANNEL, chan.getName());
639 646
             channels.put(converter.toLowerCase(chan.getName()), newChan);

+ 1
- 0
src/com/dmdirc/ServerManager.java Zobrazit soubor

@@ -113,6 +113,7 @@ public class ServerManager implements ServerFactory {
113 113
                 tabCompleterFactory,
114 114
                 commandController.get(),
115 115
                 identityFactory,
116
+                windowManager,
116 117
                 uri,
117 118
                 profile);
118 119
         registerServer(server);

+ 5
- 2
src/com/dmdirc/WritableFrameContainer.java Zobrazit soubor

@@ -28,6 +28,7 @@ import com.dmdirc.interfaces.actions.ActionType;
28 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.messages.MessageSinkManager;
30 30
 import com.dmdirc.parser.common.CompositionState;
31
+import com.dmdirc.ui.WindowManager;
31 32
 import com.dmdirc.ui.input.TabCompleter;
32 33
 
33 34
 import java.util.ArrayList;
@@ -60,12 +61,14 @@ public abstract class WritableFrameContainer extends FrameContainer {
60 61
      * @param config The config manager for this container
61 62
      * @param parser The command parser for this container
62 63
      * @param components The UI components that this frame requires
64
+     * @param windowManager For window management
63 65
      * @since 0.6.4
64 66
      */
65 67
     public WritableFrameContainer(final String icon, final String name,
66 68
             final String title, final AggregateConfigProvider config,
67
-            final CommandParser parser, final Collection<String> components) {
68
-        super(icon, name, title, config, components);
69
+            final CommandParser parser, final Collection<String> components,
70
+            final WindowManager windowManager) {
71
+        super(icon, name, title, config, components, windowManager);
69 72
 
70 73
         this.commandParser = parser;
71 74
         parser.setOwner(this);

+ 8
- 4
src/com/dmdirc/commandparser/commands/global/Echo.java Zobrazit soubor

@@ -62,16 +62,20 @@ public class Echo extends Command implements IntelligentCommand {
62 62
     private final CommandFlag targetFlag = new CommandFlag("target", true, 1, 0);
63 63
     /** The command flag handler for this command. */
64 64
     private final CommandFlagHandler handler;
65
+    /** Window management. */
66
+    private final WindowManager windowManager;
65 67
 
66 68
     /**
67 69
      * Creates a new instance of Echo.
68 70
      *
69 71
      * @param controller Command controller
72
+     * @param windowManager Window management
70 73
      */
71 74
     @Inject
72
-    public Echo(final CommandController controller) {
75
+    public Echo(final CommandController controller, final WindowManager windowManager) {
73 76
         super(controller);
74 77
 
78
+        this.windowManager = windowManager;
75 79
         handler = new CommandFlagHandler(timeStampFlag, targetFlag);
76 80
     }
77 81
 
@@ -100,13 +104,13 @@ public class Echo extends Command implements IntelligentCommand {
100 104
             FrameContainer target = origin;
101 105
 
102 106
             while (frame == null && target != null) {
103
-                frame = WindowManager.getWindowManager().findCustomWindow(target,
107
+                frame = windowManager.findCustomWindow(target,
104 108
                         results.getArgumentsAsString(targetFlag));
105 109
                 target = target.getParent();
106 110
             }
107 111
 
108 112
             if (frame == null) {
109
-                frame = WindowManager.getWindowManager().findCustomWindow(results.getArgumentsAsString(targetFlag));
113
+                frame = windowManager.findCustomWindow(results.getArgumentsAsString(targetFlag));
110 114
             }
111 115
 
112 116
             if (frame == null) {
@@ -145,7 +149,7 @@ public class Echo extends Command implements IntelligentCommand {
145 149
             }
146 150
 
147 151
             //Global Windows
148
-            windowList.addAll(WindowManager.getWindowManager().getRootWindows());
152
+            windowList.addAll(windowManager.getRootWindows());
149 153
             for (FrameContainer customWindow : windowList) {
150 154
                 if (customWindow instanceof CustomWindow) {
151 155
                     targets.add(customWindow.getName());

+ 9
- 4
src/com/dmdirc/commandparser/commands/global/OpenWindow.java Zobrazit soubor

@@ -47,15 +47,20 @@ public class OpenWindow extends Command implements IntelligentCommand {
47 47
             "openwindow [--server|--child] <name> [title] "
48 48
             + "- opens a window with the specified name and title",
49 49
             CommandType.TYPE_GLOBAL);
50
+    /** Window management. */
51
+    private final WindowManager windowManager;
50 52
 
51 53
     /**
52 54
      * Creates a new instance of this command.
53 55
      *
54 56
      * @param controller The controller to use for command information.
57
+     * @param windowManager Window management
55 58
      */
56 59
     @Inject
57
-    public OpenWindow(final CommandController controller) {
60
+    public OpenWindow(final CommandController controller, final WindowManager windowManager) {
58 61
         super(controller);
62
+
63
+        this.windowManager = windowManager;
59 64
     }
60 65
 
61 66
     /** {@inheritDoc} */
@@ -86,9 +91,9 @@ public class OpenWindow extends Command implements IntelligentCommand {
86 91
             final FrameContainer window;
87 92
 
88 93
             if (parent == null) {
89
-                window = WindowManager.getWindowManager().findCustomWindow(args.getArguments()[start]);
94
+                window = windowManager.findCustomWindow(args.getArguments()[start]);
90 95
             } else {
91
-                window = WindowManager.getWindowManager().findCustomWindow(parent, args.getArguments()[start]);
96
+                window = windowManager.findCustomWindow(parent, args.getArguments()[start]);
92 97
             }
93 98
 
94 99
             final String title = args.getArguments().length > start + 1
@@ -96,7 +101,7 @@ public class OpenWindow extends Command implements IntelligentCommand {
96 101
 
97 102
             if (window == null) {
98 103
                 if (parent == null) {
99
-                    new CustomWindow(args.getArguments()[start], title);
104
+                    new CustomWindow(args.getArguments()[start], title, windowManager);
100 105
                 } else {
101 106
                     new CustomWindow(args.getArguments()[start], title, parent);
102 107
                 }

+ 12
- 2
src/com/dmdirc/messages/CustomWindowMessageSink.java Zobrazit soubor

@@ -38,6 +38,17 @@ public class CustomWindowMessageSink implements MessageSink {
38 38
 
39 39
     /** The pattern to use to match this sink. */
40 40
     private static final Pattern PATTERN = Pattern.compile("window:(.*)");
41
+    /** Window management. */
42
+    private final WindowManager windowManager;
43
+
44
+    /**
45
+     * Creates a new custom window message sink.
46
+     *
47
+     * @param windowManager Window management
48
+     */
49
+    public CustomWindowMessageSink(final WindowManager windowManager) {
50
+        this.windowManager = windowManager;
51
+    }
41 52
 
42 53
     /** {@inheritDoc} */
43 54
     @Override
@@ -51,8 +62,7 @@ public class CustomWindowMessageSink implements MessageSink {
51 62
             final WritableFrameContainer source,
52 63
             final String[] patternMatches, final Date date,
53 64
             final String messageType, final Object... args) {
54
-        FrameContainer targetWindow = WindowManager.getWindowManager()
55
-                .findCustomWindow(source.getServer(), patternMatches[0]);
65
+        FrameContainer targetWindow = windowManager.findCustomWindow(source.getServer(), patternMatches[0]);
56 66
 
57 67
         if (targetWindow == null) {
58 68
             targetWindow = new CustomWindow(patternMatches[0],

+ 2
- 1
src/com/dmdirc/messages/MessageSinkManager.java Zobrazit soubor

@@ -25,6 +25,7 @@ package com.dmdirc.messages;
25 25
 import com.dmdirc.WritableFrameContainer;
26 26
 import com.dmdirc.logger.ErrorLevel;
27 27
 import com.dmdirc.logger.Logger;
28
+import com.dmdirc.ui.WindowManager;
28 29
 import com.dmdirc.ui.core.components.StatusBarManager;
29 30
 
30 31
 import java.util.ArrayList;
@@ -133,7 +134,7 @@ public class MessageSinkManager {
133 134
         addSink(new AllMessageSink());
134 135
         addSink(new ChannelMessageSink());
135 136
         addSink(new CommonChanelsMessageSink());
136
-        addSink(new CustomWindowMessageSink());
137
+        addSink(new CustomWindowMessageSink(WindowManager.getWindowManager()));
137 138
         addSink(new ForkMessageSink());
138 139
         addSink(new FormatMessageSink());
139 140
         addSink(new GroupMessageSink());

+ 6
- 2
test/com/dmdirc/ServerTest.java Zobrazit soubor

@@ -27,6 +27,7 @@ import com.dmdirc.interfaces.CommandController;
27 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28 28
 import com.dmdirc.interfaces.config.ConfigProvider;
29 29
 import com.dmdirc.interfaces.config.IdentityFactory;
30
+import com.dmdirc.ui.WindowManager;
30 31
 import com.dmdirc.ui.input.TabCompleterFactory;
31 32
 
32 33
 import java.net.URI;
@@ -36,8 +37,9 @@ import org.junit.Test;
36 37
 import org.mockito.Mock;
37 38
 import org.mockito.MockitoAnnotations;
38 39
 
39
-import static org.junit.Assert.*;
40
-import static org.mockito.Mockito.*;
40
+import static org.junit.Assert.assertEquals;
41
+import static org.mockito.Matchers.anyString;
42
+import static org.mockito.Mockito.when;
41 43
 
42 44
 public class ServerTest {
43 45
 
@@ -49,6 +51,7 @@ public class ServerTest {
49 51
     @Mock private IdentityFactory identityFactory;
50 52
     @Mock private TabCompleterFactory tabCompleterFactory;
51 53
     @Mock private CommandController commandController;
54
+    @Mock private WindowManager windowManager;
52 55
 
53 56
     private Server server;
54 57
 
@@ -66,6 +69,7 @@ public class ServerTest {
66 69
                 tabCompleterFactory,
67 70
                 commandController,
68 71
                 identityFactory,
72
+                windowManager,
69 73
                 new URI("irc-test://255.255.255.255"),
70 74
                 profile);
71 75
     }

+ 4
- 2
test/com/dmdirc/WritableFrameContainerTest.java Zobrazit soubor

@@ -26,6 +26,7 @@ import com.dmdirc.commandparser.CommandManager;
26 26
 import com.dmdirc.config.ConfigBinder;
27 27
 import com.dmdirc.harness.TestWritableFrameContainer;
28 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29
+import com.dmdirc.ui.WindowManager;
29 30
 
30 31
 import java.util.Arrays;
31 32
 
@@ -41,6 +42,7 @@ public class WritableFrameContainerTest {
41 42
 
42 43
     @Mock private AggregateConfigProvider acp;
43 44
     @Mock private ServerManager serverManager;
45
+    @Mock private WindowManager windowManager;
44 46
     private CommandManager commands;
45 47
 
46 48
     @Before
@@ -57,7 +59,7 @@ public class WritableFrameContainerTest {
57 59
     @Test
58 60
     public void testGetNumLines() {
59 61
         final WritableFrameContainer container10
60
-                = new TestWritableFrameContainer(10, acp, commands);
62
+                = new TestWritableFrameContainer(10, acp, commands, windowManager);
61 63
 
62 64
         final int res0a = container10.getNumLines("");
63 65
         final int res0b = container10.getNumLines("\r");
@@ -87,7 +89,7 @@ public class WritableFrameContainerTest {
87 89
     @Test
88 90
     public void testSplitLine() {
89 91
         final WritableFrameContainer container10
90
-                = new TestWritableFrameContainer(10, acp, commands);
92
+                = new TestWritableFrameContainer(10, acp, commands, windowManager);
91 93
         final String[][][] tests = new String[][][]{
92 94
             {{""}, {""}},
93 95
             {{"0123456789"}, {"0123456789"}},

+ 3
- 1
test/com/dmdirc/commandparser/parsers/CommandParserTest.java Zobrazit soubor

@@ -28,6 +28,7 @@ import com.dmdirc.config.ConfigBinder;
28 28
 import com.dmdirc.config.InvalidIdentityFileException;
29 29
 import com.dmdirc.harness.TestCommandParser;
30 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
+import com.dmdirc.ui.WindowManager;
31 32
 
32 33
 import org.junit.Before;
33 34
 import org.junit.Test;
@@ -41,6 +42,7 @@ public class CommandParserTest {
41 42
 
42 43
     @Mock private ServerManager serverManager;
43 44
     @Mock private AggregateConfigProvider cm;
45
+    @Mock private WindowManager windowManager;
44 46
     private CommandManager commands;
45 47
 
46 48
     @Before
@@ -53,7 +55,7 @@ public class CommandParserTest {
53 55
         when(cm.getBinder()).thenReturn(binder);
54 56
         commands = new CommandManager(serverManager);
55 57
         commands.initialise(cm);
56
-        commands.registerCommand(new Echo(commands), Echo.INFO);
58
+        commands.registerCommand(new Echo(commands, windowManager), Echo.INFO);
57 59
     }
58 60
 
59 61
     @Test

+ 4
- 2
test/com/dmdirc/harness/TestWritableFrameContainer.java Zobrazit soubor

@@ -27,6 +27,7 @@ import com.dmdirc.WritableFrameContainer;
27 27
 import com.dmdirc.commandparser.CommandManager;
28 28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
29 29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
+import com.dmdirc.ui.WindowManager;
30 31
 import com.dmdirc.ui.input.TabCompleter;
31 32
 
32 33
 import java.util.Collections;
@@ -36,10 +37,11 @@ public class TestWritableFrameContainer extends WritableFrameContainer {
36 37
     private final int lineLength;
37 38
 
38 39
     public TestWritableFrameContainer(final int lineLength,
39
-            final AggregateConfigProvider cm, final CommandManager commandManager) {
40
+            final AggregateConfigProvider cm, final CommandManager commandManager,
41
+            final WindowManager windowManager) {
40 42
         super("raw", "Raw", "(Raw)", cm,
41 43
                 new GlobalCommandParser(cm, commandManager),
42
-                Collections.<String>emptySet());
44
+                Collections.<String>emptySet(), windowManager);
43 45
 
44 46
         this.lineLength = lineLength;
45 47
     }

Načítá se…
Zrušit
Uložit