Browse Source

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 10 years ago
parent
commit
0c43d2a21e

+ 4
- 3
src/com/dmdirc/Channel.java View File

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

+ 1
- 1
src/com/dmdirc/ClientModule.java View File

374
      */
374
      */
375
     @Provides
375
     @Provides
376
     public WindowManager getWindowManager() {
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 View File

43
     public CustomWindow(final String name, final String title,
43
     public CustomWindow(final String name, final String title,
44
             final FrameContainer parent) {
44
             final FrameContainer parent) {
45
         super("custom", name, title, parent.getConfigManager(),
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
      *
53
      *
54
      * @param name The name of this custom window
54
      * @param name The name of this custom window
55
      * @param title The parent of this custom window
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
         super("custom", name, title,
59
         super("custom", name, title,
59
                 IdentityManager.getIdentityManager().getGlobalConfiguration(),
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
     /** {@inheritDoc} */
66
     /** {@inheritDoc} */

+ 9
- 2
src/com/dmdirc/FrameContainer.java View File

110
     @Getter
110
     @Getter
111
     private final IconManager iconManager;
111
     private final IconManager iconManager;
112
 
112
 
113
+    /** Window management. */
114
+    @Getter
115
+    private final WindowManager windowManager;
116
+
113
     /**
117
     /**
114
      * Instantiate new frame container.
118
      * Instantiate new frame container.
115
      *
119
      *
118
      * @param title The title of this container
122
      * @param title The title of this container
119
      * @param config The config manager for this container
123
      * @param config The config manager for this container
120
      * @param components The UI components that this frame requires
124
      * @param components The UI components that this frame requires
125
+     * @param windowManager Window manager to register from
121
      * @since 0.6.4
126
      * @since 0.6.4
122
      */
127
      */
123
     protected FrameContainer(
128
     protected FrameContainer(
124
             final String icon, final String name,
129
             final String icon, final String name,
125
             final String title, final AggregateConfigProvider config,
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
         this.configManager = config;
134
         this.configManager = config;
128
         this.name = name;
135
         this.name = name;
129
         this.title = title;
136
         this.title = title;
292
 
299
 
293
         windowClosing();
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 View File

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

+ 5
- 2
src/com/dmdirc/MessageTarget.java View File

24
 
24
 
25
 import com.dmdirc.commandparser.parsers.CommandParser;
25
 import com.dmdirc.commandparser.parsers.CommandParser;
26
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
26
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
+import com.dmdirc.ui.WindowManager;
27
 
28
 
28
 import java.util.Collection;
29
 import java.util.Collection;
29
 
30
 
42
      * @param config The config manager to use for this target
43
      * @param config The config manager to use for this target
43
      * @param parser The command parser for this container
44
      * @param parser The command parser for this container
44
      * @param components The UI components that this frame requires
45
      * @param components The UI components that this frame requires
46
+     * @param windowManager Window manager
45
      * @since 0.6.4
47
      * @since 0.6.4
46
      */
48
      */
47
     public MessageTarget(final String icon, final String name,
49
     public MessageTarget(final String icon, final String name,
48
             final String title, final AggregateConfigProvider config,
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 View File

72
      *
72
      *
73
      * @param newHost host of the remove client
73
      * @param newHost host of the remove client
74
      * @param newServer The server object that this Query belongs to
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
      * @param newHost host of the remove client
84
      * @param newHost host of the remove client
84
      * @param newServer The server object that this Query belongs to
85
      * @param newServer The server object that this Query belongs to
85
      * @param focus Should we focus the query on open?
86
      * @param focus Should we focus the query on open?
87
+     * @param windowManager Window management
86
      */
88
      */
87
     public Query(final Server newServer, final String newHost,
89
     public Query(final Server newServer, final String newHost,
88
-            final boolean focus) {
90
+            final boolean focus, final WindowManager windowManager) {
89
         super("query", newServer.parseHostmask(newHost)[0],
91
         super("query", newServer.parseHostmask(newHost)[0],
90
                 newServer.parseHostmask(newHost)[0],
92
                 newServer.parseHostmask(newHost)[0],
91
                 newServer.getConfigManager(), new QueryCommandParser(newServer),
93
                 newServer.getConfigManager(), new QueryCommandParser(newServer),
92
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
94
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
93
-                WindowComponent.INPUTFIELD.getIdentifier()));
95
+                        WindowComponent.INPUTFIELD.getIdentifier()), windowManager);
94
 
96
 
95
         this.server = newServer;
97
         this.server = newServer;
96
         this.host = newHost;
98
         this.host = newHost;
97
         this.nickname = server.parseHostmask(host)[0];
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
         ActionManager.getActionManager().triggerEvent(
103
         ActionManager.getActionManager().triggerEvent(
102
                 CoreActionType.QUERY_OPENED, null, this);
104
                 CoreActionType.QUERY_OPENED, null, this);

+ 5
- 4
src/com/dmdirc/Raw.java View File

40
  * Handles the raw window (which shows the user raw data being sent and
40
  * Handles the raw window (which shows the user raw data being sent and
41
  * received to/from the server).
41
  * received to/from the server).
42
  */
42
  */
43
-public final class Raw extends WritableFrameContainer
43
+public class Raw extends WritableFrameContainer
44
         implements DataInListener, DataOutListener {
44
         implements DataInListener, DataOutListener {
45
 
45
 
46
     /** The server object that's being monitored. */
46
     /** The server object that's being monitored. */
50
      * Creates a new instance of Raw.
50
      * Creates a new instance of Raw.
51
      *
51
      *
52
      * @param newServer the server to monitor
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
         super("raw", "Raw", "(Raw log)", newServer.getConfigManager(),
56
         super("raw", "Raw", "(Raw log)", newServer.getConfigManager(),
56
                 new ServerCommandParser(newServer.getConfigManager()),
57
                 new ServerCommandParser(newServer.getConfigManager()),
57
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
58
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
58
-                WindowComponent.INPUTFIELD.getIdentifier()));
59
+                        WindowComponent.INPUTFIELD.getIdentifier()), windowManager);
59
 
60
 
60
         this.server = newServer;
61
         this.server = newServer;
61
 
62
 
62
         getCommandParser().setOwner(server);
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 View File

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

+ 1
- 0
src/com/dmdirc/ServerManager.java View File

113
                 tabCompleterFactory,
113
                 tabCompleterFactory,
114
                 commandController.get(),
114
                 commandController.get(),
115
                 identityFactory,
115
                 identityFactory,
116
+                windowManager,
116
                 uri,
117
                 uri,
117
                 profile);
118
                 profile);
118
         registerServer(server);
119
         registerServer(server);

+ 5
- 2
src/com/dmdirc/WritableFrameContainer.java View File

28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29
 import com.dmdirc.messages.MessageSinkManager;
29
 import com.dmdirc.messages.MessageSinkManager;
30
 import com.dmdirc.parser.common.CompositionState;
30
 import com.dmdirc.parser.common.CompositionState;
31
+import com.dmdirc.ui.WindowManager;
31
 import com.dmdirc.ui.input.TabCompleter;
32
 import com.dmdirc.ui.input.TabCompleter;
32
 
33
 
33
 import java.util.ArrayList;
34
 import java.util.ArrayList;
60
      * @param config The config manager for this container
61
      * @param config The config manager for this container
61
      * @param parser The command parser for this container
62
      * @param parser The command parser for this container
62
      * @param components The UI components that this frame requires
63
      * @param components The UI components that this frame requires
64
+     * @param windowManager For window management
63
      * @since 0.6.4
65
      * @since 0.6.4
64
      */
66
      */
65
     public WritableFrameContainer(final String icon, final String name,
67
     public WritableFrameContainer(final String icon, final String name,
66
             final String title, final AggregateConfigProvider config,
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
         this.commandParser = parser;
73
         this.commandParser = parser;
71
         parser.setOwner(this);
74
         parser.setOwner(this);

+ 8
- 4
src/com/dmdirc/commandparser/commands/global/Echo.java View File

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

+ 9
- 4
src/com/dmdirc/commandparser/commands/global/OpenWindow.java View File

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

+ 12
- 2
src/com/dmdirc/messages/CustomWindowMessageSink.java View File

38
 
38
 
39
     /** The pattern to use to match this sink. */
39
     /** The pattern to use to match this sink. */
40
     private static final Pattern PATTERN = Pattern.compile("window:(.*)");
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
     /** {@inheritDoc} */
53
     /** {@inheritDoc} */
43
     @Override
54
     @Override
51
             final WritableFrameContainer source,
62
             final WritableFrameContainer source,
52
             final String[] patternMatches, final Date date,
63
             final String[] patternMatches, final Date date,
53
             final String messageType, final Object... args) {
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
         if (targetWindow == null) {
67
         if (targetWindow == null) {
58
             targetWindow = new CustomWindow(patternMatches[0],
68
             targetWindow = new CustomWindow(patternMatches[0],

+ 2
- 1
src/com/dmdirc/messages/MessageSinkManager.java View File

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

+ 6
- 2
test/com/dmdirc/ServerTest.java View File

27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
 import com.dmdirc.interfaces.config.ConfigProvider;
28
 import com.dmdirc.interfaces.config.ConfigProvider;
29
 import com.dmdirc.interfaces.config.IdentityFactory;
29
 import com.dmdirc.interfaces.config.IdentityFactory;
30
+import com.dmdirc.ui.WindowManager;
30
 import com.dmdirc.ui.input.TabCompleterFactory;
31
 import com.dmdirc.ui.input.TabCompleterFactory;
31
 
32
 
32
 import java.net.URI;
33
 import java.net.URI;
36
 import org.mockito.Mock;
37
 import org.mockito.Mock;
37
 import org.mockito.MockitoAnnotations;
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
 public class ServerTest {
44
 public class ServerTest {
43
 
45
 
49
     @Mock private IdentityFactory identityFactory;
51
     @Mock private IdentityFactory identityFactory;
50
     @Mock private TabCompleterFactory tabCompleterFactory;
52
     @Mock private TabCompleterFactory tabCompleterFactory;
51
     @Mock private CommandController commandController;
53
     @Mock private CommandController commandController;
54
+    @Mock private WindowManager windowManager;
52
 
55
 
53
     private Server server;
56
     private Server server;
54
 
57
 
66
                 tabCompleterFactory,
69
                 tabCompleterFactory,
67
                 commandController,
70
                 commandController,
68
                 identityFactory,
71
                 identityFactory,
72
+                windowManager,
69
                 new URI("irc-test://255.255.255.255"),
73
                 new URI("irc-test://255.255.255.255"),
70
                 profile);
74
                 profile);
71
     }
75
     }

+ 4
- 2
test/com/dmdirc/WritableFrameContainerTest.java View File

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

+ 3
- 1
test/com/dmdirc/commandparser/parsers/CommandParserTest.java View File

28
 import com.dmdirc.config.InvalidIdentityFileException;
28
 import com.dmdirc.config.InvalidIdentityFileException;
29
 import com.dmdirc.harness.TestCommandParser;
29
 import com.dmdirc.harness.TestCommandParser;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
+import com.dmdirc.ui.WindowManager;
31
 
32
 
32
 import org.junit.Before;
33
 import org.junit.Before;
33
 import org.junit.Test;
34
 import org.junit.Test;
41
 
42
 
42
     @Mock private ServerManager serverManager;
43
     @Mock private ServerManager serverManager;
43
     @Mock private AggregateConfigProvider cm;
44
     @Mock private AggregateConfigProvider cm;
45
+    @Mock private WindowManager windowManager;
44
     private CommandManager commands;
46
     private CommandManager commands;
45
 
47
 
46
     @Before
48
     @Before
53
         when(cm.getBinder()).thenReturn(binder);
55
         when(cm.getBinder()).thenReturn(binder);
54
         commands = new CommandManager(serverManager);
56
         commands = new CommandManager(serverManager);
55
         commands.initialise(cm);
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
     @Test
61
     @Test

+ 4
- 2
test/com/dmdirc/harness/TestWritableFrameContainer.java View File

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

Loading…
Cancel
Save