Browse Source

Inject StatusBarManager, instead of singletonning.

Change-Id: If4bf7c53ade24b6cc3b637aa9ac92410a0b64889
Reviewed-on: http://gerrit.dmdirc.com/2926
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 years ago
parent
commit
e0de4ea4dc
2 changed files with 10 additions and 1 deletions
  1. 7
    1
      src/com/dmdirc/Server.java
  2. 3
    0
      test/com/dmdirc/ServerTest.java

+ 7
- 1
src/com/dmdirc/Server.java View File

@@ -199,6 +199,9 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
199 199
     /** The config provider to write user settings to. */
200 200
     private final ConfigProvider userSettings;
201 201
 
202
+    /** The manager to use to add status bar messages. */
203
+    private final StatusBarManager statusBarManager;
204
+
202 205
     /**
203 206
      * Creates a new server which will connect to the specified URL with
204 207
      * the specified profile.
@@ -211,6 +214,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
211 214
      * @param tabCompleterFactory The factory to use for tab completers.
212 215
      * @param identityFactory The factory to use to create identities.
213 216
      * @param messageSinkManager The sink manager to use to despatch messages.
217
+     * @param statusBarManager The manager to use to add status bar messages.
214 218
      * @param windowManager Window Manager
215 219
      * @param channelFactory The factory to use to create channels.
216 220
      * @param queryFactory The factory to use to create queries.
@@ -227,6 +231,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
227 231
             final TabCompleterFactory tabCompleterFactory,
228 232
             final IdentityFactory identityFactory,
229 233
             final MessageSinkManager messageSinkManager,
234
+            final StatusBarManager statusBarManager,
230 235
             final WindowManager windowManager,
231 236
             final ChannelFactory channelFactory,
232 237
             final QueryFactory queryFactory,
@@ -254,6 +259,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
254 259
         this.queryFactory = queryFactory;
255 260
         this.rawFactory = rawFactory;
256 261
         this.userSettings = userSettings;
262
+        this.statusBarManager = statusBarManager;
257 263
 
258 264
         setConnectionDetails(uri, profile);
259 265
 
@@ -1420,7 +1426,7 @@ public class Server extends WritableFrameContainer implements ConfigChangeListen
1420 1426
      * Called when we fail to receive a ping reply within a set period of time.
1421 1427
      */
1422 1428
     public void onPingFailed() {
1423
-        StatusBarManager.getStatusBarManager().setMessage(new StatusMessage(
1429
+        statusBarManager.setMessage(new StatusMessage(
1424 1430
                 "No ping reply from " + getName() + " for over "
1425 1431
                 + ((int) (Math.floor(parser.getPingTime() / 1000.0)))
1426 1432
                 + " seconds.", getConfigManager()));

+ 3
- 0
test/com/dmdirc/ServerTest.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.interfaces.config.ConfigProviderMigrator;
29 29
 import com.dmdirc.interfaces.config.IdentityFactory;
30 30
 import com.dmdirc.messages.MessageSinkManager;
31 31
 import com.dmdirc.ui.WindowManager;
32
+import com.dmdirc.ui.core.components.StatusBarManager;
32 33
 import com.dmdirc.ui.input.TabCompleterFactory;
33 34
 
34 35
 import java.net.URI;
@@ -58,6 +59,7 @@ public class ServerTest {
58 59
     @Mock private ChannelFactory channelFactory;
59 60
     @Mock private QueryFactory queryFactory;
60 61
     @Mock private RawFactory rawFactory;
62
+    @Mock private StatusBarManager statusBarManager;
61 63
 
62 64
     private Server server;
63 65
 
@@ -75,6 +77,7 @@ public class ServerTest {
75 77
                 tabCompleterFactory,
76 78
                 identityFactory,
77 79
                 messageSinkManager,
80
+                statusBarManager,
78 81
                 windowManager,
79 82
                 channelFactory,
80 83
                 queryFactory,

Loading…
Cancel
Save