Browse Source

Remove ActionComponentArgument.

This only exists to pass around global state, and is only used
by one plugin. It's nicer for now if that plugin just accesses
a singleton/static state directly until it can be injected,
rather than make lots of classes and tests depend on Main.

Change-Id: I8ed6e4c90b9c6bdbcaeb01fc276df5819cb47e1a
Depends-On: I4ec47f958b40eb0a03ab50d4a5611e00b0c83f39
Reviewed-on: http://gerrit.dmdirc.com/2656
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 years ago
parent
commit
29c0c560b6

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

72
     private String configdir;
72
     private String configdir;
73
 
73
 
74
     /** Instance of main, protected to allow subclasses direct access. */
74
     /** Instance of main, protected to allow subclasses direct access. */
75
-    protected static Main mainInstance;
75
+    @Deprecated
76
+    public static Main mainInstance;
76
 
77
 
77
     /** Instance of pluginmanager used by this Main. */
78
     /** Instance of pluginmanager used by this Main. */
78
     protected PluginManager pluginManager;
79
     protected PluginManager pluginManager;

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

24
 
24
 
25
 import com.dmdirc.Precondition;
25
 import com.dmdirc.Precondition;
26
 import com.dmdirc.interfaces.actions.ActionComponent;
26
 import com.dmdirc.interfaces.actions.ActionComponent;
27
-import com.dmdirc.interfaces.actions.ActionComponentArgument;
28
 import com.dmdirc.logger.Logger;
27
 import com.dmdirc.logger.Logger;
29
 
28
 
30
 import java.util.ArrayList;
29
 import java.util.ArrayList;
82
 
81
 
83
     /** {@inheritDoc} */
82
     /** {@inheritDoc} */
84
     @Override
83
     @Override
85
-    public Object get(final ActionComponentArgument arg) {
86
-        Object res = arg.getObject();
84
+    public Object get(final Object arg) {
85
+        Object res = arg;
87
 
86
 
88
         for (ActionComponent component : components) {
87
         for (ActionComponent component : components) {
89
             if (res == null) {
88
             if (res == null) {
90
                 return null;
89
                 return null;
91
             }
90
             }
92
 
91
 
93
-            res = component.get(new ActionComponentArgument(arg.getMain(), res));
92
+            res = component.get(res);
94
         }
93
         }
95
 
94
 
96
         return res;
95
         return res;
165
         for (ActionComponent component : components) {
164
         for (ActionComponent component : components) {
166
             try {
165
             try {
167
                 final ComponentOptions options = component.getClass()
166
                 final ComponentOptions options = component.getClass()
168
-                        .getMethod("get", ActionComponentArgument.class).getAnnotation(ComponentOptions.class);
167
+                        .getMethod("get", Object.class).getAnnotation(ComponentOptions.class);
169
                 if (options != null) {
168
                 if (options != null) {
170
                     res |= options.requireConnected();
169
                     res |= options.requireConnected();
171
                 }
170
                 }

+ 1
- 2
src/com/dmdirc/actions/ActionCondition.java View File

24
 
24
 
25
 import com.dmdirc.interfaces.actions.ActionComparison;
25
 import com.dmdirc.interfaces.actions.ActionComparison;
26
 import com.dmdirc.interfaces.actions.ActionComponent;
26
 import com.dmdirc.interfaces.actions.ActionComponent;
27
-import com.dmdirc.interfaces.actions.ActionComponentArgument;
28
 
27
 
29
 /**
28
 /**
30
  * An action condition represents one condition within an action.
29
  * An action condition represents one condition within an action.
96
             final String thisStarget = sub.doSubstitution(starget, args);
95
             final String thisStarget = sub.doSubstitution(starget, args);
97
             return getComparison().test(thisStarget, thisTarget);
96
             return getComparison().test(thisStarget, thisTarget);
98
         } else {
97
         } else {
99
-            return getComparison().test(getComponent().get(new ActionComponentArgument(ActionManager.getActionManager().getMain(), args[getArg()])), thisTarget);
98
+            return getComparison().test(getComponent().get(args[getArg()]), thisTarget);
100
         }
99
         }
101
     }
100
     }
102
 
101
 

+ 1
- 2
src/com/dmdirc/actions/ActionSubstitutor.java View File

30
 import com.dmdirc.config.ConfigManager;
30
 import com.dmdirc.config.ConfigManager;
31
 import com.dmdirc.config.IdentityManager;
31
 import com.dmdirc.config.IdentityManager;
32
 import com.dmdirc.interfaces.actions.ActionComponent;
32
 import com.dmdirc.interfaces.actions.ActionComponent;
33
-import com.dmdirc.interfaces.actions.ActionComponentArgument;
34
 import com.dmdirc.interfaces.actions.ActionType;
33
 import com.dmdirc.interfaces.actions.ActionType;
35
 import com.dmdirc.interfaces.ui.Window;
34
 import com.dmdirc.interfaces.ui.Window;
36
 
35
 
297
         if ((chain.requiresConnection() && args[0] instanceof FrameContainer
296
         if ((chain.requiresConnection() && args[0] instanceof FrameContainer
298
                     && ((FrameContainer) args[0]).getServer().getState()
297
                     && ((FrameContainer) args[0]).getServer().getState()
299
                     == ServerState.CONNECTED) || !chain.requiresConnection()) {
298
                     == ServerState.CONNECTED) || !chain.requiresConnection()) {
300
-            final Object res = chain.get(new ActionComponentArgument(ActionManager.getActionManager().getMain(), argument));
299
+            final Object res = chain.get(argument);
301
             return res == null ? ERR_NULL_CHAIN : res.toString();
300
             return res == null ? ERR_NULL_CHAIN : res.toString();
302
         }
301
         }
303
 
302
 

+ 36
- 37
src/com/dmdirc/actions/CoreActionComponent.java View File

28
 import com.dmdirc.Server;
28
 import com.dmdirc.Server;
29
 import com.dmdirc.config.Identity;
29
 import com.dmdirc.config.Identity;
30
 import com.dmdirc.interfaces.actions.ActionComponent;
30
 import com.dmdirc.interfaces.actions.ActionComponent;
31
-import com.dmdirc.interfaces.actions.ActionComponentArgument;
32
 import com.dmdirc.interfaces.ui.Window;
31
 import com.dmdirc.interfaces.ui.Window;
33
 import com.dmdirc.logger.ErrorLevel;
32
 import com.dmdirc.logger.ErrorLevel;
34
 import com.dmdirc.logger.Logger;
33
 import com.dmdirc.logger.Logger;
53
     SERVER_NAME {
52
     SERVER_NAME {
54
         /** {@inheritDoc} */
53
         /** {@inheritDoc} */
55
         @Override
54
         @Override
56
-        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getAddress(); }
55
+        public Object get(final Object arg) { return ((Server) arg).getAddress(); }
57
         /** {@inheritDoc} */
56
         /** {@inheritDoc} */
58
         @Override
57
         @Override
59
         public Class<?> appliesTo() { return Server.class; }
58
         public Class<?> appliesTo() { return Server.class; }
70
         /** {@inheritDoc} */
69
         /** {@inheritDoc} */
71
         @Override
70
         @Override
72
         @ComponentOptions(requireConnected = true)
71
         @ComponentOptions(requireConnected = true)
73
-        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getNetwork(); }
72
+        public Object get(final Object arg) { return ((Server) arg).getNetwork(); }
74
         /** {@inheritDoc} */
73
         /** {@inheritDoc} */
75
         @Override
74
         @Override
76
         public Class<?> appliesTo() { return Server.class; }
75
         public Class<?> appliesTo() { return Server.class; }
90
     SERVER_PROTOCOL {
89
     SERVER_PROTOCOL {
91
         /** {@inheritDoc} */
90
         /** {@inheritDoc} */
92
         @Override
91
         @Override
93
-        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getProtocol(); }
92
+        public Object get(final Object arg) { return ((Server) arg).getProtocol(); }
94
         /** {@inheritDoc} */
93
         /** {@inheritDoc} */
95
         @Override
94
         @Override
96
         public Class<?> appliesTo() { return Server.class; }
95
         public Class<?> appliesTo() { return Server.class; }
106
     SERVER_MYAWAYREASON {
105
     SERVER_MYAWAYREASON {
107
         /** {@inheritDoc} */
106
         /** {@inheritDoc} */
108
         @Override
107
         @Override
109
-        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getAwayMessage(); }
108
+        public Object get(final Object arg) { return ((Server) arg).getAwayMessage(); }
110
         /** {@inheritDoc} */
109
         /** {@inheritDoc} */
111
         @Override
110
         @Override
112
         public Class<?> appliesTo() { return Server.class; }
111
         public Class<?> appliesTo() { return Server.class; }
123
         /** {@inheritDoc} */
122
         /** {@inheritDoc} */
124
         @Override
123
         @Override
125
         @ComponentOptions(requireConnected = true)
124
         @ComponentOptions(requireConnected = true)
126
-        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getParser().getChannelUserModes(); }
125
+        public Object get(final Object arg) { return ((Server) arg).getParser().getChannelUserModes(); }
127
         /** {@inheritDoc} */
126
         /** {@inheritDoc} */
128
         @Override
127
         @Override
129
         public Class<?> appliesTo() { return Server.class; }
128
         public Class<?> appliesTo() { return Server.class; }
140
         /** {@inheritDoc} */
139
         /** {@inheritDoc} */
141
         @Override
140
         @Override
142
         @ComponentOptions(requireConnected = true)
141
         @ComponentOptions(requireConnected = true)
143
-        public Object get(final ActionComponentArgument arg) {
144
-            final Server server = (Server) arg.getObject();
142
+        public Object get(final Object arg) {
143
+            final Server server = (Server) arg;
145
 
144
 
146
             if (server == null || server.getParser() == null) {
145
             if (server == null || server.getParser() == null) {
147
                 Logger.appError(ErrorLevel.LOW, "SERVER_MYNICKNAME.get() called with null element",
146
                 Logger.appError(ErrorLevel.LOW, "SERVER_MYNICKNAME.get() called with null element",
171
     SERVER_PROFILE {
170
     SERVER_PROFILE {
172
         /** {@inheritDoc} */
171
         /** {@inheritDoc} */
173
         @Override
172
         @Override
174
-        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getProfile(); }
173
+        public Object get(final Object arg) { return ((Server) arg).getProfile(); }
175
         /** {@inheritDoc} */
174
         /** {@inheritDoc} */
176
         @Override
175
         @Override
177
         public Class<?> appliesTo() { return Server.class; }
176
         public Class<?> appliesTo() { return Server.class; }
187
     CHANNEL_NAME {
186
     CHANNEL_NAME {
188
         /** {@inheritDoc} */
187
         /** {@inheritDoc} */
189
         @Override
188
         @Override
190
-        public Object get(final ActionComponentArgument arg) { return ((Channel) arg.getObject()).getChannelInfo().getName(); }
189
+        public Object get(final Object arg) { return ((Channel) arg).getChannelInfo().getName(); }
191
         /** {@inheritDoc} */
190
         /** {@inheritDoc} */
192
         @Override
191
         @Override
193
         public Class<?> appliesTo() { return Channel.class; }
192
         public Class<?> appliesTo() { return Channel.class; }
203
     CHANNEL_COLOUR {
202
     CHANNEL_COLOUR {
204
         /** {@inheritDoc} */
203
         /** {@inheritDoc} */
205
         @Override
204
         @Override
206
-        public Object get(final ActionComponentArgument arg) { return ((Channel) arg.getObject()).getNotification(); }
205
+        public Object get(final Object arg) { return ((Channel) arg).getNotification(); }
207
         /** {@inheritDoc} */
206
         /** {@inheritDoc} */
208
         @Override
207
         @Override
209
         public Class<?> appliesTo() { return Channel.class; }
208
         public Class<?> appliesTo() { return Channel.class; }
219
     CLIENT_NAME {
218
     CLIENT_NAME {
220
         /** {@inheritDoc} */
219
         /** {@inheritDoc} */
221
         @Override
220
         @Override
222
-        public Object get(final ActionComponentArgument arg) { return ((ClientInfo) arg.getObject()).getNickname(); }
221
+        public Object get(final Object arg) { return ((ClientInfo) arg).getNickname(); }
223
         /** {@inheritDoc} */
222
         /** {@inheritDoc} */
224
         @Override
223
         @Override
225
         public Class<?> appliesTo() { return ClientInfo.class; }
224
         public Class<?> appliesTo() { return ClientInfo.class; }
235
     CLIENT_HOST {
234
     CLIENT_HOST {
236
         /** {@inheritDoc} */
235
         /** {@inheritDoc} */
237
         @Override
236
         @Override
238
-        public Object get(final ActionComponentArgument arg) { return ((ClientInfo) arg.getObject()).getHostname(); }
237
+        public Object get(final Object arg) { return ((ClientInfo) arg).getHostname(); }
239
         /** {@inheritDoc} */
238
         /** {@inheritDoc} */
240
         @Override
239
         @Override
241
         public Class<?> appliesTo() { return ClientInfo.class; }
240
         public Class<?> appliesTo() { return ClientInfo.class; }
251
     USER_NAME {
250
     USER_NAME {
252
         /** {@inheritDoc} */
251
         /** {@inheritDoc} */
253
         @Override
252
         @Override
254
-        public Object get(final ActionComponentArgument arg) { return ((ChannelClientInfo) arg.getObject()).getClient().getNickname(); }
253
+        public Object get(final Object arg) { return ((ChannelClientInfo) arg).getClient().getNickname(); }
255
         /** {@inheritDoc} */
254
         /** {@inheritDoc} */
256
         @Override
255
         @Override
257
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
256
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
267
     USER_MODES {
266
     USER_MODES {
268
         /** {@inheritDoc} */
267
         /** {@inheritDoc} */
269
         @Override
268
         @Override
270
-        public Object get(final ActionComponentArgument arg) { return ((ChannelClientInfo) arg.getObject()).getAllModes(); }
269
+        public Object get(final Object arg) { return ((ChannelClientInfo) arg).getAllModes(); }
271
         /** {@inheritDoc} */
270
         /** {@inheritDoc} */
272
         @Override
271
         @Override
273
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
272
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
283
     USER_HOST {
282
     USER_HOST {
284
         /** {@inheritDoc} */
283
         /** {@inheritDoc} */
285
         @Override
284
         @Override
286
-        public Object get(final ActionComponentArgument arg) { return ((ChannelClientInfo) arg.getObject()).getClient().getHostname(); }
285
+        public Object get(final Object arg) { return ((ChannelClientInfo) arg).getClient().getHostname(); }
287
         /** {@inheritDoc} */
286
         /** {@inheritDoc} */
288
         @Override
287
         @Override
289
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
288
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
299
     USER_COMCHANS {
298
     USER_COMCHANS {
300
         /** {@inheritDoc} */
299
         /** {@inheritDoc} */
301
         @Override
300
         @Override
302
-        public Object get(final ActionComponentArgument arg) { return Integer.valueOf(((ChannelClientInfo) arg.getObject()).getClient().getChannelCount()); }
301
+        public Object get(final Object arg) { return Integer.valueOf(((ChannelClientInfo) arg).getClient().getChannelCount()); }
303
         /** {@inheritDoc} */
302
         /** {@inheritDoc} */
304
         @Override
303
         @Override
305
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
304
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
315
     STRING_STRING {
314
     STRING_STRING {
316
         /** {@inheritDoc} */
315
         /** {@inheritDoc} */
317
         @Override
316
         @Override
318
-        public Object get(final ActionComponentArgument arg) { return arg.getObject(); }
317
+        public Object get(final Object arg) { return arg; }
319
         /** {@inheritDoc} */
318
         /** {@inheritDoc} */
320
         @Override
319
         @Override
321
         public Class<?> appliesTo() { return String.class; }
320
         public Class<?> appliesTo() { return String.class; }
331
     STRING_STRIPPED {
330
     STRING_STRIPPED {
332
         /** {@inheritDoc} */
331
         /** {@inheritDoc} */
333
         @Override
332
         @Override
334
-        public Object get(final ActionComponentArgument arg) { return Styliser.stipControlCodes((String) arg.getObject()); }
333
+        public Object get(final Object arg) { return Styliser.stipControlCodes((String) arg); }
335
         /** {@inheritDoc} */
334
         /** {@inheritDoc} */
336
         @Override
335
         @Override
337
         public Class<?> appliesTo() { return String.class; }
336
         public Class<?> appliesTo() { return String.class; }
347
     STRING_LENGTH {
346
     STRING_LENGTH {
348
         /** {@inheritDoc} */
347
         /** {@inheritDoc} */
349
         @Override
348
         @Override
350
-        public Object get(final ActionComponentArgument arg) { return ((String) arg.getObject()).length(); }
349
+        public Object get(final Object arg) { return ((String) arg).length(); }
351
         /** {@inheritDoc} */
350
         /** {@inheritDoc} */
352
         @Override
351
         @Override
353
         public Class<?> appliesTo() { return String.class; }
352
         public Class<?> appliesTo() { return String.class; }
363
     STRINGARRAY_LENGTH {
362
     STRINGARRAY_LENGTH {
364
         /** {@inheritDoc} */
363
         /** {@inheritDoc} */
365
         @Override
364
         @Override
366
-        public Object get(final ActionComponentArgument arg) { return Integer.valueOf(((String[]) arg.getObject()).length); }
365
+        public Object get(final Object arg) { return Integer.valueOf(((String[]) arg).length); }
367
         /** {@inheritDoc} */
366
         /** {@inheritDoc} */
368
         @Override
367
         @Override
369
         public Class<?> appliesTo() { return String[].class; }
368
         public Class<?> appliesTo() { return String[].class; }
379
     CALENDAR_FULLSTRING {
378
     CALENDAR_FULLSTRING {
380
         /** {@inheritDoc} */
379
         /** {@inheritDoc} */
381
         @Override
380
         @Override
382
-        public Object get(final ActionComponentArgument arg) { return ((GregorianCalendar) arg.getObject()).getTime().toString(); }
381
+        public Object get(final Object arg) { return ((GregorianCalendar) arg).getTime().toString(); }
383
         /** {@inheritDoc} */
382
         /** {@inheritDoc} */
384
         @Override
383
         @Override
385
         public Class<?> appliesTo() { return Calendar.class; }
384
         public Class<?> appliesTo() { return Calendar.class; }
395
     KEYEVENT_KEYNAME {
394
     KEYEVENT_KEYNAME {
396
         /** {@inheritDoc} */
395
         /** {@inheritDoc} */
397
         @Override
396
         @Override
398
-        public Object get(final ActionComponentArgument arg) { return KeyEvent.getKeyText(((KeyStroke) arg.getObject()).getKeyCode()); }
397
+        public Object get(final Object arg) { return KeyEvent.getKeyText(((KeyStroke) arg).getKeyCode()); }
399
         /** {@inheritDoc} */
398
         /** {@inheritDoc} */
400
         @Override
399
         @Override
401
         public Class<?> appliesTo() { return KeyStroke.class; }
400
         public Class<?> appliesTo() { return KeyStroke.class; }
411
     KEYEVENT_CTRLSTATE {
410
     KEYEVENT_CTRLSTATE {
412
         /** {@inheritDoc} */
411
         /** {@inheritDoc} */
413
         @Override
412
         @Override
414
-        public Object get(final ActionComponentArgument arg) {
415
-            return Boolean.valueOf((((KeyStroke) arg.getObject()).getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0);
413
+        public Object get(final Object arg) {
414
+            return Boolean.valueOf((((KeyStroke) arg).getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0);
416
         }
415
         }
417
         /** {@inheritDoc} */
416
         /** {@inheritDoc} */
418
         @Override
417
         @Override
429
     KEYEVENT_SHIFTSTATE {
428
     KEYEVENT_SHIFTSTATE {
430
         /** {@inheritDoc} */
429
         /** {@inheritDoc} */
431
         @Override
430
         @Override
432
-        public Object get(final ActionComponentArgument arg) {
433
-            return Boolean.valueOf((((KeyStroke) arg.getObject()).getModifiers() & KeyEvent.SHIFT_DOWN_MASK) != 0);
431
+        public Object get(final Object arg) {
432
+            return Boolean.valueOf((((KeyStroke) arg).getModifiers() & KeyEvent.SHIFT_DOWN_MASK) != 0);
434
         }
433
         }
435
         /** {@inheritDoc} */
434
         /** {@inheritDoc} */
436
         @Override
435
         @Override
447
     KEYEVENT_ALTSTATE {
446
     KEYEVENT_ALTSTATE {
448
         /** {@inheritDoc} */
447
         /** {@inheritDoc} */
449
         @Override
448
         @Override
450
-        public Object get(final ActionComponentArgument arg) {
451
-            return Boolean.valueOf((((KeyStroke) arg.getObject()).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0);
449
+        public Object get(final Object arg) {
450
+            return Boolean.valueOf((((KeyStroke) arg).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0);
452
         }
451
         }
453
         /** {@inheritDoc} */
452
         /** {@inheritDoc} */
454
         @Override
453
         @Override
465
     QUERY_HOST {
464
     QUERY_HOST {
466
         /** {@inheritDoc} */
465
         /** {@inheritDoc} */
467
         @Override
466
         @Override
468
-        public Object get(final ActionComponentArgument arg) { return ((Query) arg.getObject()).getHost(); }
467
+        public Object get(final Object arg) { return ((Query) arg).getHost(); }
469
         /** {@inheritDoc} */
468
         /** {@inheritDoc} */
470
         @Override
469
         @Override
471
         public Class<?> appliesTo() { return Query.class; }
470
         public Class<?> appliesTo() { return Query.class; }
481
     QUERY_NICK {
480
     QUERY_NICK {
482
         /** {@inheritDoc} */
481
         /** {@inheritDoc} */
483
         @Override
482
         @Override
484
-        public Object get(final ActionComponentArgument arg) { return ((Query) arg.getObject()).getName(); }
483
+        public Object get(final Object arg) { return ((Query) arg).getName(); }
485
         /** {@inheritDoc} */
484
         /** {@inheritDoc} */
486
         @Override
485
         @Override
487
         public Class<?> appliesTo() { return Query.class; }
486
         public Class<?> appliesTo() { return Query.class; }
497
     QUERY_COLOUR {
496
     QUERY_COLOUR {
498
         /** {@inheritDoc} */
497
         /** {@inheritDoc} */
499
         @Override
498
         @Override
500
-        public Object get(final ActionComponentArgument arg) { return ((Query) arg.getObject()).getNotification(); }
499
+        public Object get(final Object arg) { return ((Query) arg).getNotification(); }
501
         /** {@inheritDoc} */
500
         /** {@inheritDoc} */
502
         @Override
501
         @Override
503
         public Class<?> appliesTo() { return Query.class; }
502
         public Class<?> appliesTo() { return Query.class; }
513
     WINDOW_NAME {
512
     WINDOW_NAME {
514
         /** {@inheritDoc} */
513
         /** {@inheritDoc} */
515
         @Override
514
         @Override
516
-        public Object get(final ActionComponentArgument arg) { return ((FrameContainer) arg.getObject()).getName(); }
515
+        public Object get(final Object arg) { return ((FrameContainer) arg).getName(); }
517
         /** {@inheritDoc} */
516
         /** {@inheritDoc} */
518
         @Override
517
         @Override
519
         public Class<?> appliesTo() { return FrameContainer.class; }
518
         public Class<?> appliesTo() { return FrameContainer.class; }
529
     WINDOW_COLOUR {
528
     WINDOW_COLOUR {
530
         /** {@inheritDoc} */
529
         /** {@inheritDoc} */
531
         @Override
530
         @Override
532
-        public Object get(final ActionComponentArgument arg) { return ((FrameContainer) arg.getObject()).getNotification(); }
531
+        public Object get(final Object arg) { return ((FrameContainer) arg).getNotification(); }
533
         /** {@inheritDoc} */
532
         /** {@inheritDoc} */
534
         @Override
533
         @Override
535
         public Class<?> appliesTo() { return FrameContainer.class; }
534
         public Class<?> appliesTo() { return FrameContainer.class; }
549
     WINDOW_SERVER {
548
     WINDOW_SERVER {
550
         /** {@inheritDoc} */
549
         /** {@inheritDoc} */
551
         @Override
550
         @Override
552
-        public Object get(final ActionComponentArgument arg) { return ((Window) arg.getObject())
551
+        public Object get(final Object arg) { return ((Window) arg)
553
                 .getContainer().getServer(); }
552
                 .getContainer().getServer(); }
554
         /** {@inheritDoc} */
553
         /** {@inheritDoc} */
555
         @Override
554
         @Override
566
     IDENTITY_NAME {
565
     IDENTITY_NAME {
567
         /** {@inheritDoc} */
566
         /** {@inheritDoc} */
568
         @Override
567
         @Override
569
-        public Object get(final ActionComponentArgument arg) { return ((Identity) arg.getObject()).getName(); }
568
+        public Object get(final Object arg) { return ((Identity) arg).getName(); }
570
         /** {@inheritDoc} */
569
         /** {@inheritDoc} */
571
         @Override
570
         @Override
572
         public Class<?> appliesTo() { return Identity.class; }
571
         public Class<?> appliesTo() { return Identity.class; }
582
     INTEGER_VALUE {
581
     INTEGER_VALUE {
583
         /** {@inheritDoc} */
582
         /** {@inheritDoc} */
584
         @Override
583
         @Override
585
-        public Object get(final ActionComponentArgument arg) { return (Integer) arg.getObject(); }
584
+        public Object get(final Object arg) { return (Integer) arg; }
586
         /** {@inheritDoc} */
585
         /** {@inheritDoc} */
587
         @Override
586
         @Override
588
         public Class<?> appliesTo() { return Integer.class; }
587
         public Class<?> appliesTo() { return Integer.class; }

+ 1
- 1
src/com/dmdirc/interfaces/actions/ActionComponent.java View File

57
      * @param arg The object to retrieve the component from
57
      * @param arg The object to retrieve the component from
58
      * @return The relevant component of the object
58
      * @return The relevant component of the object
59
      */
59
      */
60
-    Object get(ActionComponentArgument arg);
60
+    Object get(Object arg);
61
 
61
 
62
     /**
62
     /**
63
      * Retrieves the type of class that this component applies to.
63
      * Retrieves the type of class that this component applies to.

+ 0
- 41
src/com/dmdirc/interfaces/actions/ActionComponentArgument.java View File

1
-/*
2
- * Copyright (c) 2006-2013 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-package com.dmdirc.interfaces.actions;
23
-
24
-import com.dmdirc.Main;
25
-import lombok.Getter;
26
-import lombok.RequiredArgsConstructor;
27
-
28
-/**
29
- * Represents an argument for an ActionComponent
30
- */
31
-@RequiredArgsConstructor
32
-@SuppressWarnings("PMD.UnusedPrivateField")
33
-public class ActionComponentArgument {
34
-    /** Instance of main that ActionComponents may wish to use. */
35
-    @Getter
36
-    private final Main main;
37
-
38
-    /** The object this argument wraps. */
39
-    @Getter
40
-    private final Object object;
41
-}

+ 2
- 3
test/com/dmdirc/actions/ActionComponentChainTest.java View File

25
 import com.dmdirc.TestMain;
25
 import com.dmdirc.TestMain;
26
 import com.dmdirc.Server;
26
 import com.dmdirc.Server;
27
 
27
 
28
-import com.dmdirc.interfaces.actions.ActionComponentArgument;
29
 import org.junit.BeforeClass;
28
 import org.junit.BeforeClass;
30
 import org.junit.Test;
29
 import org.junit.Test;
31
 
30
 
41
     @Test
40
     @Test
42
     public void testSingle() {
41
     public void testSingle() {
43
         final ActionComponentChain chain = new ActionComponentChain(String.class, "STRING_STRING");
42
         final ActionComponentChain chain = new ActionComponentChain(String.class, "STRING_STRING");
44
-        assertEquals(chain.get(new ActionComponentArgument(TestMain.getTestMain(), "foo bar baz")), "foo bar baz");
43
+        assertEquals(chain.get("foo bar baz"), "foo bar baz");
45
         assertEquals("STRING_STRING", chain.toString());
44
         assertEquals("STRING_STRING", chain.toString());
46
     }
45
     }
47
 
46
 
49
     public void testDouble() {
48
     public void testDouble() {
50
         final ActionComponentChain chain = new ActionComponentChain(String.class,
49
         final ActionComponentChain chain = new ActionComponentChain(String.class,
51
                 "STRING_STRING.STRING_STRING");
50
                 "STRING_STRING.STRING_STRING");
52
-        assertEquals(chain.get(new ActionComponentArgument(TestMain.getTestMain(), "foo bar baz")), "foo bar baz");
51
+        assertEquals(chain.get("foo bar baz"), "foo bar baz");
53
         assertEquals("STRING_STRING.STRING_STRING", chain.toString());
52
         assertEquals("STRING_STRING.STRING_STRING", chain.toString());
54
     }
53
     }
55
 
54
 

+ 0
- 5
test/com/dmdirc/actions/ActionConditionTest.java View File

31
 
31
 
32
 public class ActionConditionTest {
32
 public class ActionConditionTest {
33
 
33
 
34
-    @BeforeClass
35
-    public static void setUp() throws Exception {
36
-        TestMain.getTestMain();
37
-    }
38
-
39
     @Test
34
     @Test
40
     public void testConstructor1() {
35
     public void testConstructor1() {
41
         final ActionCondition ac = new ActionCondition(1, CoreActionComponent.STRING_STRING,
36
         final ActionCondition ac = new ActionCondition(1, CoreActionComponent.STRING_STRING,

Loading…
Cancel
Save