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

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

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

Loading…
Cancel
Save