浏览代码

Initial work in action error persistence

Also remove deprecated methods

Change-Id: Id3d1e92c7db813911b4bf4f27b92d4eff92bdd41
Depends-On: Ib20eb804c786b157a33c6d0610e9151200371400
Reviewed-on: http://gerrit.dmdirc.com/1963
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.6.6b1
Chris Smith 13 年前
父节点
当前提交
521daeca81

+ 41
- 40
src/com/dmdirc/actions/Action.java 查看文件

@@ -63,9 +63,6 @@ public class Action extends ActionModel implements ConfigChangeListener {
63 63
     /** The domain name for misc settings. */
64 64
     private static final String DOMAIN_MISC = "misc".intern();
65 65
 
66
-    /** Whether or not this action is disabled. */
67
-    protected boolean disabled;
68
-
69 66
     /** The config file we're using. */
70 67
     protected ConfigFile config;
71 68
 
@@ -88,13 +85,12 @@ public class Action extends ActionModel implements ConfigChangeListener {
88 85
             config = new ConfigFile(location);
89 86
             config.read();
90 87
             loadActionFromConfig();
88
+            ActionManager.getActionManager().addAction(this);
91 89
         } catch (InvalidConfigFileException ex) {
92 90
             // This isn't a valid config file. Maybe it's a properties file?
93
-            Logger.userError(ErrorLevel.MEDIUM, "Unable to parse action file: "
94
-                    + group + "/" + name + ": " + ex.getMessage());
91
+            error(ActionErrorType.FILE, "Unable to parse action file: " + ex.getMessage());
95 92
         } catch (IOException ex) {
96
-            Logger.userError(ErrorLevel.HIGH, "I/O error when loading action: "
97
-                    + group + "/" + name + ": " + ex.getMessage());
93
+            error(ActionErrorType.FILE, "I/O error when loading action: " + ex.getMessage());
98 94
         }
99 95
 
100 96
         IdentityManager.getGlobalConfig().addChangeListener("disable_action",
@@ -164,7 +160,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
164 160
                 return;
165 161
             }
166 162
         } else {
167
-            error("No trigger specified");
163
+            error(ActionErrorType.TRIGGERS, "No trigger specified");
168 164
             return;
169 165
         }
170 166
 
@@ -176,7 +172,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
176 172
                 response[i++] = line;
177 173
             }
178 174
         } else {
179
-            error("No response specified");
175
+            error(ActionErrorType.RESPONSE, "No response specified");
180 176
             return;
181 177
         }
182 178
 
@@ -197,12 +193,12 @@ public class Action extends ActionModel implements ConfigChangeListener {
197 193
                     config.getFlatDomain(DOMAIN_CONDITIONTREE).get(0));
198 194
 
199 195
             if (conditionTree == null) {
200
-                error("Unable to parse condition tree");
196
+                error(ActionErrorType.CONDITION_TREE, "Unable to parse condition tree");
201 197
                 return;
202 198
             }
203 199
 
204 200
             if (conditionTree.getMaximumArgument() >= conditions.size()) {
205
-                error("Condition tree references condition "
201
+                error(ActionErrorType.CONDITION_TREE, "Condition tree references condition "
206 202
                         + conditionTree.getMaximumArgument() + " but there are"
207 203
                         + " only " + conditions.size() + " conditions");
208 204
                 return;
@@ -219,7 +215,9 @@ public class Action extends ActionModel implements ConfigChangeListener {
219 215
             setStopping(Boolean.parseBoolean(config.getKeyDomain(DOMAIN_MISC).get("stopping")));
220 216
         }
221 217
 
222
-        ActionManager.getActionManager().addAction(this);
218
+        if (status == ActionStatus.DISABLED) {
219
+            status = ActionStatus.ACTIVE;
220
+        }
223 221
 
224 222
         checkMetaData();
225 223
     }
@@ -285,10 +283,10 @@ public class Action extends ActionModel implements ConfigChangeListener {
285 283
             triggers[i] = ActionManager.getActionManager().getType(newTriggers.get(i));
286 284
 
287 285
             if (triggers[i] == null) {
288
-                error("Invalid trigger specified: " + newTriggers.get(i));
286
+                error(ActionErrorType.TRIGGERS, "Invalid trigger specified: " + newTriggers.get(i));
289 287
                 return false;
290 288
             } else if (i != 0 && !triggers[i].getType().equals(triggers[0].getType())) {
291
-                error("Triggers are not compatible");
289
+                error(ActionErrorType.TRIGGERS, "Triggers are not compatible");
292 290
                 return false;
293 291
             }
294 292
         }
@@ -308,6 +306,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
308 306
 
309 307
         final List<String> triggerNames = new ArrayList<String>();
310 308
         final List<String> responseLines = new ArrayList<String>();
309
+        responseLines.addAll(Arrays.asList(response));
311 310
 
312 311
         for (ActionType trigger : triggers) {
313 312
             if (trigger == null) {
@@ -320,10 +319,6 @@ public class Action extends ActionModel implements ConfigChangeListener {
320 319
             triggerNames.add(trigger.toString());
321 320
         }
322 321
 
323
-        for (String line : response) {
324
-            responseLines.add(line);
325
-        }
326
-
327 322
         newConfig.addDomain(DOMAIN_TRIGGERS, triggerNames);
328 323
         newConfig.addDomain(DOMAIN_RESPONSE, responseLines);
329 324
 
@@ -407,12 +402,13 @@ public class Action extends ActionModel implements ConfigChangeListener {
407 402
         try {
408 403
             arg = Integer.parseInt(data.get("argument"));
409 404
         } catch (NumberFormatException ex) {
410
-            error("Invalid argument number specified: " + data.get("argument"));
405
+            error(ActionErrorType.CONDITIONS,
406
+                    "Invalid argument number specified: " + data.get("argument"));
411 407
             return false;
412 408
         }
413 409
 
414 410
         if (arg < -1 || arg >= triggers[0].getType().getArity()) {
415
-            error("Invalid argument number specified: " + arg);
411
+            error(ActionErrorType.CONDITIONS, "Invalid argument number specified: " + arg);
416 412
             return false;
417 413
         }
418 414
 
@@ -422,7 +418,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
422 418
             starget = data.get("starget");
423 419
 
424 420
             if (starget == null) {
425
-                error("No starget specified");
421
+                error(ActionErrorType.CONDITIONS, "No starget specified");
426 422
                 return false;
427 423
             }
428 424
         } else {
@@ -436,13 +432,15 @@ public class Action extends ActionModel implements ConfigChangeListener {
436 432
 
437 433
         comparison = ActionManager.getActionManager().getComparison(data.get("comparison"));
438 434
         if (comparison == null) {
439
-            error("Invalid comparison specified: " + data.get("comparison"));
435
+            error(ActionErrorType.CONDITIONS, "Invalid comparison specified: "
436
+                    + data.get("comparison"));
440 437
             return false;
441 438
         }
442 439
 
443 440
         if ((arg != -1 && !comparison.appliesTo().equals(component.getType()))
444 441
             || (arg == -1 && !comparison.appliesTo().equals(String.class))) {
445
-            error("Comparison cannot be applied to specified component: " + data.get("comparison"));
442
+            error(ActionErrorType.CONDITIONS,
443
+                    "Comparison cannot be applied to specified component: " + data.get("comparison"));
446 444
             return false;
447 445
         }
448 446
 
@@ -451,7 +449,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
451 449
         target = data.get("target");
452 450
 
453 451
         if (target == null) {
454
-            error("No target specified for condition");
452
+            error(ActionErrorType.CONDITIONS, "No target specified for condition");
455 453
             return false;
456 454
         }
457 455
 
@@ -483,18 +481,19 @@ public class Action extends ActionModel implements ConfigChangeListener {
483 481
                 component = new ActionComponentChain(triggers[0].getType().getArgTypes()[arg],
484 482
                         componentName);
485 483
             } catch (IllegalArgumentException iae) {
486
-                error(iae.getMessage());
484
+                error(ActionErrorType.CONDITIONS, iae.getMessage());
487 485
                 return null;
488 486
             }
489 487
         }
490 488
 
491 489
         if (component == null) {
492
-            error("Unknown component: " + componentName);
490
+            error(ActionErrorType.CONDITIONS, "Unknown component: " + componentName);
493 491
             return null;
494 492
         }
495 493
 
496 494
         if (!component.appliesTo().equals(triggers[0].getType().getArgTypes()[arg])) {
497
-            error("Component cannot be applied to specified arg in condition: " + componentName);
495
+            error(ActionErrorType.CONDITIONS,
496
+                    "Component cannot be applied to specified arg in condition: " + componentName);
498 497
             return null;
499 498
         }
500 499
 
@@ -506,7 +505,11 @@ public class Action extends ActionModel implements ConfigChangeListener {
506 505
      *
507 506
      * @param message The message to be raised
508 507
      */
509
-    private void error(final String message) {
508
+    private void error(final ActionErrorType type, final String message) {
509
+        this.error = message;
510
+        this.errorType = type;
511
+        this.status = ActionStatus.FAILED;
512
+
510 513
         Logger.userError(ErrorLevel.LOW, "Error when parsing action: "
511 514
                 + group + "/" + name + ": " + message);
512 515
     }
@@ -567,20 +570,28 @@ public class Action extends ActionModel implements ConfigChangeListener {
567 570
      * @since 0.6.3
568 571
      */
569 572
     protected void checkDisabled() {
570
-        disabled = IdentityManager.getGlobalConfig().hasOptionBool("disable_action",
573
+        boolean disabled = IdentityManager.getGlobalConfig().hasOptionBool("disable_action",
571 574
                 (group + "/" + name).replace(' ', '.'))
572 575
                 && IdentityManager.getGlobalConfig().getOptionBool("disable_action",
573 576
                 (group + "/" + name).replace(' ', '.'));
577
+
578
+        if (disabled && status == ActionStatus.ACTIVE) {
579
+            status = ActionStatus.DISABLED;
580
+        } else if (!disabled && status == ActionStatus.DISABLED) {
581
+            status = ActionStatus.ACTIVE;
582
+        }
574 583
     }
575 584
 
576 585
     /**
577 586
      * Determines whether this action is enabled or not.
578 587
      *
579 588
      * @since 0.6.4
589
+     * @deprecated Use {@link #getStatus()} instead
580 590
      * @return True if the action is enabled, false otherwise
581 591
      */
592
+    @Deprecated
582 593
     public boolean isEnabled() {
583
-        return !disabled;
594
+        return status == ActionStatus.ACTIVE;
584 595
     }
585 596
 
586 597
     /**
@@ -598,14 +609,4 @@ public class Action extends ActionModel implements ConfigChangeListener {
598 609
         }
599 610
     }
600 611
 
601
-    /** {@inheritDoc} */
602
-    @Override
603
-    public boolean trigger(final StringBuffer format, final Object... arguments) {
604
-        if (!disabled) {
605
-            return super.trigger(format, arguments);
606
-        }
607
-
608
-        return false;
609
-    }
610
-
611 612
 }

+ 47
- 0
src/com/dmdirc/actions/ActionErrorType.java 查看文件

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
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
+
23
+package com.dmdirc.actions;
24
+
25
+/**
26
+ * An enumeration of possible types of error an action may encounter.
27
+ *
28
+ * @since 0.6.6
29
+ */
30
+public enum ActionErrorType {
31
+
32
+    /** A low-level problem occurred trying to read the action's file. */
33
+    FILE,
34
+
35
+    /** A problem with the action's triggers. */
36
+    TRIGGERS,
37
+
38
+    /** A problem with the action's response. */
39
+    RESPONSE,
40
+
41
+    /** A problem with the action's condition tree. */
42
+    CONDITION_TREE,
43
+
44
+    /** A problem with the action's conditions. */
45
+    CONDITIONS;
46
+
47
+}

+ 1
- 1
src/com/dmdirc/actions/ActionGroup.java 查看文件

@@ -263,7 +263,7 @@ public class ActionGroup implements Iterable<Action> {
263 263
         Logger.assertTrue(action != null);
264 264
         Logger.assertTrue(actions.contains(action));
265 265
 
266
-        ActionManager.deleteAction(action);
266
+        ActionManager.getActionManager().removeAction(action);
267 267
     }
268 268
 
269 269
     /**

+ 37
- 397
src/com/dmdirc/actions/ActionManager.java 查看文件

@@ -45,6 +45,7 @@ import java.util.ArrayList;
45 45
 import java.util.HashMap;
46 46
 import java.util.List;
47 47
 import java.util.Map;
48
+import java.util.logging.Level;
48 49
 
49 50
 /**
50 51
  * Manages all actions for the client.
@@ -54,6 +55,10 @@ public final class ActionManager {
54 55
     /** A singleton instance of the ActionManager. */
55 56
     private static final ActionManager INSTANCE = new ActionManager();
56 57
 
58
+    /** A logger for the action manager to use. */
59
+    private static final java.util.logging.Logger LOGGER
60
+            = java.util.logging.Logger.getLogger(ActionManager.class.getName());
61
+
57 62
     /** A list of registered action types. */
58 63
     private final List<ActionType> types
59 64
             = new ArrayList<ActionType>();
@@ -104,35 +109,26 @@ public final class ActionManager {
104 109
         return INSTANCE;
105 110
     }
106 111
 
107
-    /**
108
-     * Initialises the action manager.
109
-     * @deprecated Use {@link #getActionManager()} and non-static methods
110
-     */
111
-    @Deprecated
112
-    public static void init() {
113
-        INSTANCE.initialise();
114
-    }
115
-
116 112
     /**
117 113
      * Initialises the action manager.
118 114
      */
119 115
     public void initialise() {
120
-        registerActionTypes(CoreActionType.values());
121
-        registerActionComparisons(CoreActionComparison.values());
122
-        registerActionComponents(CoreActionComponent.values());
116
+        registerTypes(CoreActionType.values());
117
+        registerComparisons(CoreActionComparison.values());
118
+        registerComponents(CoreActionComponent.values());
123 119
 
124
-        registerGroup(AliasWrapper.getAliasWrapper());
125
-        registerGroup(PerformWrapper.getPerformWrapper());
120
+        addGroup(AliasWrapper.getAliasWrapper());
121
+        addGroup(PerformWrapper.getPerformWrapper());
126 122
 
127 123
         new WhoisNumericFormatter(IdentityManager.getAddonIdentity()).register();
128 124
 
129 125
         // Register a listener for the closing event, so we can save actions
130
-        addListener(new ActionListener() {
126
+        registerListener(new ActionListener() {
131 127
             /** {@inheritDoc} */
132 128
             @Override
133 129
             public void processEvent(final ActionType type, final StringBuffer format,
134 130
                     final Object... arguments) {
135
-                saveActions();
131
+                saveAllActions();
136 132
             }
137 133
         }, CoreActionType.CLIENT_CLOSED);
138 134
 
@@ -148,15 +144,6 @@ public final class ActionManager {
148 144
         });
149 145
     }
150 146
 
151
-    /**
152
-     * Saves all actions.
153
-     * @deprecated Use {@link #getActionManager()} and non-static methods
154
-     */
155
-    @Deprecated
156
-    public static void saveActions() {
157
-        INSTANCE.saveAllActions();
158
-    }
159
-
160 147
     /**
161 148
      * Saves all actions.
162 149
      */
@@ -168,18 +155,6 @@ public final class ActionManager {
168 155
         }
169 156
     }
170 157
 
171
-    /**
172
-     * Registers the specified default setting for actions.
173
-     *
174
-     * @param name The name of the setting to be registered
175
-     * @param value The default value for the setting
176
-     * @deprecated Use {@link #getActionManager()} and non-static methods
177
-     */
178
-    @Deprecated
179
-    public static void registerDefault(final String name, final String value) {
180
-        INSTANCE.registerSetting(name, value);
181
-    }
182
-
183 158
     /**
184 159
      * Registers the specified default setting for actions.
185 160
      *
@@ -190,17 +165,6 @@ public final class ActionManager {
190 165
         IdentityManager.getAddonIdentity().setOption("actions", name, value);
191 166
     }
192 167
 
193
-    /**
194
-     * Registers the specified group of actions with the manager.
195
-     *
196
-     * @param group The group of actions to be registered
197
-     * @deprecated Use {@link #getActionManager()} and non-static methods
198
-     */
199
-    @Deprecated
200
-    public static void registerGroup(final ActionGroup group) {
201
-        INSTANCE.addGroup(group);
202
-    }
203
-
204 168
     /**
205 169
      * Registers the specified group of actions with the manager.
206 170
      *
@@ -211,19 +175,7 @@ public final class ActionManager {
211 175
     }
212 176
 
213 177
     /**
214
-     * Registers a set of actiontypes with the manager.
215
-     *
216
-     * @param types An array of ActionTypes to be registered
217
-     * @deprecated Use {@link #getActionManager()} and non-static methods
218
-     */
219
-    @Deprecated
220
-    @Precondition("None of the specified ActionTypes are null")
221
-    public static void registerActionTypes(final ActionType[] types) {
222
-        INSTANCE.registerTypes(types);
223
-    }
224
-
225
-    /**
226
-     * Registers a set of actiontypes with the manager.
178
+     * Registers a set of action types with the manager.
227 179
      *
228 180
      * @param newTypes An array of ActionTypes to be registered
229 181
      */
@@ -233,24 +185,13 @@ public final class ActionManager {
233 185
             Logger.assertTrue(type != null);
234 186
 
235 187
             if (!types.contains(type)) {
188
+                LOGGER.log(Level.FINEST, "Registering action type: {0}", type);
236 189
                 types.add(type);
237 190
                 typeGroups.add(type.getType().getGroup(), type);
238 191
             }
239 192
         }
240 193
     }
241 194
 
242
-    /**
243
-     * Registers a set of action components with the manager.
244
-     *
245
-     * @param comps An array of ActionComponents to be registered
246
-     * @deprecated Use {@link #getActionManager()} and non-static methods
247
-     */
248
-    @Deprecated
249
-    @Precondition("None of the specified ActionComponents are null")
250
-    public static void registerActionComponents(final ActionComponent[] comps) {
251
-        INSTANCE.registerComponents(comps);
252
-    }
253
-
254 195
     /**
255 196
      * Registers a set of action components with the manager.
256 197
      *
@@ -261,22 +202,11 @@ public final class ActionManager {
261 202
         for (ActionComponent comp : comps) {
262 203
             Logger.assertTrue(comp != null);
263 204
 
205
+            LOGGER.log(Level.FINEST, "Registering action component: {0}", comp);
264 206
             components.add(comp);
265 207
         }
266 208
     }
267 209
 
268
-    /**
269
-     * Registers a set of action comparisons with the manager.
270
-     *
271
-     * @param comps An array of ActionComparisons to be registered
272
-     * @deprecated Use {@link #getActionManager()} and non-static methods
273
-     */
274
-    @Deprecated
275
-    @Precondition("None of the specified ActionComparisons are null")
276
-    public static void registerActionComparisons(final ActionComparison[] comps) {
277
-        INSTANCE.registerComparisons(comps);
278
-    }
279
-
280 210
     /**
281 211
      * Registers a set of action comparisons with the manager.
282 212
      *
@@ -287,21 +217,11 @@ public final class ActionManager {
287 217
         for (ActionComparison comp : comps) {
288 218
             Logger.assertTrue(comp != null);
289 219
 
220
+            LOGGER.log(Level.FINEST, "Registering action comparison: {0}", comp);
290 221
             comparisons.add(comp);
291 222
         }
292 223
     }
293 224
 
294
-    /**
295
-     * Returns a map of groups to action lists.
296
-     *
297
-     * @return a map of groups to action lists
298
-     * @deprecated Use {@link #getActionManager()} and non-static methods
299
-     */
300
-    @Deprecated
301
-    public static Map<String, ActionGroup> getGroups() {
302
-        return INSTANCE.getGroupsMap();
303
-    }
304
-
305 225
     /**
306 226
      * Returns a map of groups to action lists.
307 227
      *
@@ -311,17 +231,6 @@ public final class ActionManager {
311 231
         return groups;
312 232
     }
313 233
 
314
-    /**
315
-     * Returns a map of type groups to types.
316
-     *
317
-     * @return A map of type groups to types
318
-     * @deprecated Use {@link #getActionManager()} and non-static methods
319
-     */
320
-    @Deprecated
321
-    public static MapList<String, ActionType> getTypeGroups() {
322
-        return INSTANCE.getGroupedTypes();
323
-    }
324
-
325 234
     /**
326 235
      * Returns a map of type groups to types.
327 236
      *
@@ -331,15 +240,6 @@ public final class ActionManager {
331 240
         return typeGroups;
332 241
     }
333 242
 
334
-    /**
335
-     * Loads actions from the user's directory.
336
-     * @deprecated Use {@link #getActionManager()} and non-static methods
337
-     */
338
-    @Deprecated
339
-    public static void loadActions() {
340
-        INSTANCE.loadUserActions();
341
-    }
342
-
343 243
     /**
344 244
      * Loads actions from the user's directory.
345 245
      */
@@ -394,6 +294,8 @@ public final class ActionManager {
394 294
         Logger.assertTrue(dir != null);
395 295
         Logger.assertTrue(dir.isDirectory());
396 296
 
297
+        LOGGER.log(Level.FINER, "Loading actions from directory: {0}", dir.getAbsolutePath());
298
+
397 299
         if (!groups.containsKey(dir.getName())) {
398 300
             groups.put(dir.getName(), new ActionGroup(dir.getName()));
399 301
         }
@@ -403,18 +305,6 @@ public final class ActionManager {
403 305
         }
404 306
     }
405 307
 
406
-    /**
407
-     * Registers an action with the manager.
408
-     *
409
-     * @param action The action to be registered
410
-     * @deprecated Use {@link #getActionManager()} and non-static methods
411
-     */
412
-    @Deprecated
413
-    @Precondition("The specified action is not null")
414
-    public static void registerAction(final Action action) {
415
-        INSTANCE.addAction(action);
416
-    }
417
-
418 308
     /**
419 309
      * Registers an action with the manager.
420 310
      *
@@ -424,24 +314,17 @@ public final class ActionManager {
424 314
     public void addAction(final Action action) {
425 315
         Logger.assertTrue(action != null);
426 316
 
427
-        for (ActionType trigger : action.getTriggers()) {
428
-            actions.add(trigger, action);
429
-        }
317
+        LOGGER.log(Level.FINE, "Registering action: {0}/{1} (status: {2})",
318
+                new Object[] { action.getGroup(), action.getName(), action.getStatus() });
430 319
 
431
-        getGroup(action.getGroup()).add(action);
432
-    }
320
+        if (action.getStatus() != ActionStatus.FAILED) {
321
+            for (ActionType trigger : action.getTriggers()) {
322
+                LOGGER.log(Level.FINER, "Action has trigger {0}", trigger);
323
+                actions.add(trigger, action);
324
+            }
325
+        }
433 326
 
434
-    /**
435
-     * Retrieves the action group with the specified name. A new group is
436
-     * created if it doesn't already exist.
437
-     *
438
-     * @param name The name of the group to retrieve
439
-     * @return The corresponding ActionGroup
440
-     * @deprecated Use {@link #getActionManager()} and non-static methods
441
-     */
442
-    @Deprecated
443
-    public static ActionGroup getGroup(final String name) {
444
-        return INSTANCE.getOrCreateGroup(name);
327
+        getOrCreateGroup(action.getGroup()).add(action);
445 328
     }
446 329
 
447 330
     /**
@@ -459,18 +342,6 @@ public final class ActionManager {
459 342
         return groups.get(name);
460 343
     }
461 344
 
462
-    /**
463
-     * Unregisters an action with the manager.
464
-     *
465
-     * @param action The action to be unregistered
466
-     * @deprecated Use {@link #getActionManager()} and non-static methods
467
-     */
468
-    @Deprecated
469
-    @Precondition("The specified action is not null")
470
-    public static void unregisterAction(final Action action) {
471
-        INSTANCE.removeAction(action);
472
-    }
473
-
474 345
     /**
475 346
      * Unregisters an action with the manager.
476 347
      *
@@ -481,7 +352,7 @@ public final class ActionManager {
481 352
         Logger.assertTrue(action != null);
482 353
 
483 354
         actions.removeFromAll(action);
484
-        getGroup(action.getGroup()).remove(action);
355
+        getOrCreateGroup(action.getGroup()).remove(action);
485 356
     }
486 357
 
487 358
     /**
@@ -489,50 +360,10 @@ public final class ActionManager {
489 360
      * triggers change.
490 361
      *
491 362
      * @param action The action to be reregistered
492
-     * @deprecated Use {@link #getActionManager()} and non-static methods
493
-     */
494
-    @Deprecated
495
-    public static void reregisterAction(final Action action) {
496
-        unregisterAction(action);
497
-        registerAction(action);
498
-    }
499
-
500
-    /**
501
-     * Deletes the specified action.
502
-     *
503
-     * @param action The action to be deleted
504
-     * @deprecated Use {@link ActionGroup#deleteAction(com.dmdirc.actions.Action)} instead.
505
-     */
506
-    @Precondition("The specified Action is not null")
507
-    @Deprecated
508
-    public static void deleteAction(final Action action) {
509
-        Logger.assertTrue(action != null);
510
-
511
-        unregisterAction(action);
512
-
513
-        action.delete();
514
-    }
515
-
516
-    /**
517
-     * Processes an event of the specified type.
518
-     *
519
-     * @param type The type of the event to process
520
-     * @param format The format of the message that's going to be displayed for
521
-     * the event. Actions may change this format.
522
-     * @param arguments The arguments for the event
523
-     * @return True if the event should be processed, or false if an action
524
-     * listener has requested the event be skipped.
525
-     * @deprecated Use {@link #getActionManager()} and non-static methods
526 363
      */
527
-    @Deprecated
528
-    @Precondition({
529
-        "The specified ActionType is not null",
530
-        "The specified ActionType has a valid ActionMetaType",
531
-        "The length of the arguments array equals the arity of the ActionType's ActionMetaType"
532
-    })
533
-    public static boolean processEvent(final ActionType type,
534
-            final StringBuffer format, final Object ... arguments) {
535
-        return INSTANCE.triggerEvent(type, format, arguments);
364
+    public void reregisterAction(final Action action) {
365
+        removeAction(action);
366
+        addAction(action);
536 367
     }
537 368
 
538 369
     /**
@@ -631,23 +462,6 @@ public final class ActionManager {
631 462
         return Main.getConfigDir() + "actions" + System.getProperty("file.separator");
632 463
     }
633 464
 
634
-    /**
635
-     * Creates a new group with the specified name.
636
-     *
637
-     * @param group The group to be created
638
-     *
639
-     * @return The newly created group
640
-     * @deprecated Use {@link #getActionManager()} and non-static methods
641
-     */
642
-    @Deprecated
643
-    @Precondition({
644
-        "The specified group is non-null and not empty",
645
-        "The specified group is not an existing group"
646
-    })
647
-    public static ActionGroup makeGroup(final String group) {
648
-        return INSTANCE.createGroup(group);
649
-    }
650
-
651 465
     /**
652 466
      * Creates a new group with the specified name.
653 467
      *
@@ -675,21 +489,6 @@ public final class ActionManager {
675 489
         }
676 490
     }
677 491
 
678
-    /**
679
-     * Removes the group with the specified name.
680
-     *
681
-     * @param group The group to be removed
682
-     * @deprecated Use {@link #getActionManager()} and non-static methods
683
-     */
684
-    @Deprecated
685
-    @Precondition({
686
-        "The specified group is non-null and not empty",
687
-        "The specified group is an existing group"
688
-    })
689
-    public static void removeGroup(final String group) {
690
-        INSTANCE.deleteGroup(group);
691
-    }
692
-
693 492
     /**
694 493
      * Removes the group with the specified name.
695 494
      *
@@ -705,7 +504,7 @@ public final class ActionManager {
705 504
         Logger.assertTrue(groups.containsKey(group));
706 505
 
707 506
         for (Action action : groups.get(group).getActions()) {
708
-            unregisterAction(action);
507
+            removeAction(action);
709 508
         }
710 509
 
711 510
         final File dir = new File(getDirectory() + group);
@@ -729,25 +528,6 @@ public final class ActionManager {
729 528
         groups.remove(group);
730 529
     }
731 530
 
732
-    /**
733
-     * Renames the specified group.
734
-     *
735
-     * @param oldName The old name of the group
736
-     * @param newName The new name of the group
737
-     * @deprecated Use {@link #getActionManager()} and non-static methods
738
-     */
739
-    @Deprecated
740
-    @Precondition({
741
-        "The old name is non-null and not empty",
742
-        "The old name is an existing group",
743
-        "The new name is non-null and not empty",
744
-        "The new name is not an existing group",
745
-        "The old name does not equal the new name"
746
-    })
747
-    public static void renameGroup(final String oldName, final String newName) {
748
-        INSTANCE.changeGroupName(oldName, newName);
749
-    }
750
-
751 531
     /**
752 532
      * Renames the specified group.
753 533
      *
@@ -770,28 +550,15 @@ public final class ActionManager {
770 550
         Logger.assertTrue(!groups.containsKey(newName));
771 551
         Logger.assertTrue(!newName.equals(oldName));
772 552
 
773
-        makeGroup(newName);
553
+        createGroup(newName);
774 554
 
775 555
         for (Action action : groups.get(oldName).getActions()) {
776 556
             action.setGroup(newName);
777
-            getGroup(oldName).remove(action);
778
-            getGroup(newName).add(action);
557
+            getOrCreateGroup(oldName).remove(action);
558
+            getOrCreateGroup(newName).add(action);
779 559
         }
780 560
 
781
-        removeGroup(oldName);
782
-    }
783
-
784
-    /**
785
-     * Returns the action comparison specified by the given string, or null if it
786
-     * doesn't match a valid registered action comparison.
787
-     *
788
-     * @param type The name of the action comparison to try and find
789
-     * @return The type with the specified name, or null on failure
790
-     * @deprecated Use {@link #getActionManager()} and non-static methods
791
-     */
792
-    @Deprecated
793
-    public static ActionType getActionType(final String type) {
794
-        return INSTANCE.getType(type);
561
+        deleteGroup(oldName);
795 562
     }
796 563
 
797 564
     /**
@@ -815,20 +582,6 @@ public final class ActionManager {
815 582
         return null;
816 583
     }
817 584
 
818
-    /**
819
-     * Returns a list of action types that are compatible with the one
820
-     * specified.
821
-     *
822
-     * @param type The type to be checked against
823
-     * @return A list of compatible action types
824
-     * @deprecated Use {@link #getActionManager()} and non-static methods
825
-     */
826
-    @Deprecated
827
-    @Precondition("The specified type is not null")
828
-    public static List<ActionType> getCompatibleTypes(final ActionType type) {
829
-        return INSTANCE.findCompatibleTypes(type);
830
-    }
831
-
832 585
     /**
833 586
      * Returns a list of action types that are compatible with the one
834 587
      * specified.
@@ -850,20 +603,6 @@ public final class ActionManager {
850 603
         return res;
851 604
     }
852 605
 
853
-    /**
854
-     * Returns a list of action components that are compatible with the
855
-     * specified class.
856
-     *
857
-     * @param target The class to be tested
858
-     * @return A list of compatible action components
859
-     * @deprecated Use {@link #getActionManager()} and non-static methods
860
-     */
861
-    @Deprecated
862
-    @Precondition("The specified target is not null")
863
-    public static List<ActionComponent> getCompatibleComponents(final Class<?> target) {
864
-        return INSTANCE.findCompatibleComponents(target);
865
-    }
866
-
867 606
     /**
868 607
      * Returns a list of action components that are compatible with the
869 608
      * specified class.
@@ -885,20 +624,6 @@ public final class ActionManager {
885 624
         return res;
886 625
     }
887 626
 
888
-    /**
889
-     * Returns a list of action comparisons that are compatible with the
890
-     * specified class.
891
-     *
892
-     * @param target The class to be tested
893
-     * @return A list of compatible action comparisons
894
-     * @deprecated Use {@link #getActionManager()} and non-static methods
895
-     */
896
-    @Deprecated
897
-    @Precondition("The specified target is not null")
898
-    public static List<ActionComparison> getCompatibleComparisons(final Class<?> target) {
899
-        return INSTANCE.findCompatibleComparisons(target);
900
-    }
901
-
902 627
     /**
903 628
      * Returns a list of action comparisons that are compatible with the
904 629
      * specified class.
@@ -920,17 +645,6 @@ public final class ActionManager {
920 645
         return res;
921 646
     }
922 647
 
923
-    /**
924
-     * Returns a list of all the action types registered by this manager.
925
-     *
926
-     * @return A list of registered action types
927
-     * @deprecated Use {@link #getActionManager()} and non-static methods
928
-     */
929
-    @Deprecated
930
-    public static List<ActionType> getTypes() {
931
-        return INSTANCE.getAllTypes();
932
-    }
933
-
934 648
     /**
935 649
      * Returns a list of all the action types registered by this manager.
936 650
      *
@@ -940,17 +654,6 @@ public final class ActionManager {
940 654
         return types;
941 655
     }
942 656
 
943
-    /**
944
-     * Returns a list of all the action types registered by this manager.
945
-     *
946
-     * @return A list of registered action comparisons
947
-     * @deprecated Use {@link #getActionManager()} and non-static methods
948
-     */
949
-    @Deprecated
950
-    public static List<ActionComparison> getComparisons() {
951
-        return INSTANCE.getAllComparisons();
952
-    }
953
-
954 657
     /**
955 658
      * Returns a list of all the action types registered by this manager.
956 659
      *
@@ -960,20 +663,6 @@ public final class ActionManager {
960 663
         return comparisons;
961 664
     }
962 665
 
963
-    /**
964
-     * Returns the action component specified by the given string, or null if it
965
-     * doesn't match a valid registered action component.
966
-     *
967
-     * @param type The name of the action component to try and find
968
-     * @return The actioncomponent with the specified name, or null on failure
969
-     * @deprecated Use {@link #getActionManager()} and non-static methods
970
-     */
971
-    @Deprecated
972
-    @Precondition("The specified type is non-null and not empty")
973
-    public static ActionComponent getActionComponent(final String type) {
974
-        return INSTANCE.getComponent(type);
975
-    }
976
-
977 666
     /**
978 667
      * Returns the action component specified by the given string, or null if it
979 668
      * doesn't match a valid registered action component.
@@ -995,20 +684,6 @@ public final class ActionManager {
995 684
         return null;
996 685
     }
997 686
 
998
-    /**
999
-     * Returns the action type specified by the given string, or null if it
1000
-     * doesn't match a valid registered action type.
1001
-     *
1002
-     * @param type The name of the action type to try and find
1003
-     * @return The actiontype with the specified name, or null on failure
1004
-     * @deprecated Use {@link #getActionManager()} and non-static methods
1005
-     */
1006
-    @Deprecated
1007
-    @Precondition("The specified type is non-null and not empty")
1008
-    public static ActionComparison getActionComparison(final String type) {
1009
-        return INSTANCE.getComparison(type);
1010
-    }
1011
-
1012 687
     /**
1013 688
      * Returns the action type specified by the given string, or null if it
1014 689
      * doesn't match a valid registered action type.
@@ -1041,23 +716,11 @@ public final class ActionManager {
1041 716
 
1042 717
         ziprm.extractResources("", getDirectory());
1043 718
 
1044
-        loadActions();
719
+        getActionManager().loadUserActions();
1045 720
 
1046 721
         new File(path).delete();
1047 722
     }
1048 723
 
1049
-    /**
1050
-     * Adds a new listener for the specified action type.
1051
-     *
1052
-     * @param types The action types that are to be listened for
1053
-     * @param listener The listener to be added
1054
-     * @deprecated Use {@link #getActionManager()} and non-static methods
1055
-     */
1056
-    @Deprecated
1057
-    public static void addListener(final ActionListener listener, final ActionType ... types) {
1058
-        INSTANCE.registerListener(listener, types);
1059
-    }
1060
-
1061 724
     /**
1062 725
      * Adds a new listener for the specified action type.
1063 726
      *
@@ -1070,18 +733,6 @@ public final class ActionManager {
1070 733
         }
1071 734
     }
1072 735
 
1073
-    /**
1074
-     * Removes a listener for the specified action type.
1075
-     *
1076
-     * @param types The action types that were being listened for
1077
-     * @param listener The listener to be removed
1078
-     * @deprecated Use {@link #getActionManager()} and non-static methods
1079
-     */
1080
-    @Deprecated
1081
-    public static void removeListener(final ActionListener listener, final ActionType ... types) {
1082
-        INSTANCE.unregisterListener(listener, types);
1083
-    }
1084
-
1085 736
     /**
1086 737
      * Removes a listener for the specified action type.
1087 738
      *
@@ -1094,17 +745,6 @@ public final class ActionManager {
1094 745
         }
1095 746
     }
1096 747
 
1097
-    /**
1098
-     * Removes a listener for all action types.
1099
-     *
1100
-     * @param listener The listener to be removed
1101
-     * @deprecated Use {@link #getActionManager()} and non-static methods
1102
-     */
1103
-    @Deprecated
1104
-    public static void removeListener(final ActionListener listener) {
1105
-        INSTANCE.unregisterListener(listener);
1106
-    }
1107
-
1108 748
     /**
1109 749
      * Removes a listener for all action types.
1110 750
      *

+ 45
- 2
src/com/dmdirc/actions/ActionModel.java 查看文件

@@ -70,6 +70,15 @@ public class ActionModel {
70 70
     /** The concurrency group this action belongs to, if any. */
71 71
     protected String concurrencyGroup;
72 72
 
73
+    /** The status of this action. */
74
+    protected ActionStatus status = ActionStatus.ACTIVE;
75
+
76
+    /** A description of any error that occurs while creating the action. */
77
+    protected String error;
78
+
79
+    /** The type of error that occurred, if any. */
80
+    protected ActionErrorType errorType;
81
+
73 82
     /**
74 83
      * Creates a new instance of ActionModel with the specified properties.
75 84
      *
@@ -96,8 +105,7 @@ public class ActionModel {
96 105
             final ActionType[] triggers, final String[] response,
97 106
             final List<ActionCondition> conditions,
98 107
             final ConditionTree conditionTree, final String newFormat) {
99
-        this.group = group;
100
-        this.name = name;
108
+        this(group, name);
101 109
         this.triggers = triggers.clone();
102 110
         this.response = response.clone();
103 111
         this.conditions = conditions;
@@ -123,6 +131,10 @@ public class ActionModel {
123 131
         assert triggers.length > 0;
124 132
         assert triggers[0] != null;
125 133
 
134
+        if (status != ActionStatus.ACTIVE) {
135
+            return false;
136
+        }
137
+
126 138
         final ActionSubstitutor sub = new ActionSubstitutor(triggers[0]);
127 139
 
128 140
         if (!test(sub, arguments)) {
@@ -200,6 +212,37 @@ public class ActionModel {
200 212
         this.modified = true;
201 213
     }
202 214
 
215
+    /**
216
+     * Retrieves the status of this action.
217
+     *
218
+     * @since 0.6.5
219
+     * @return This action's current status
220
+     */
221
+    public ActionStatus getStatus() {
222
+        return status;
223
+    }
224
+
225
+    /**
226
+     * Retrieves a plain text description of any error that occurred while
227
+     * loading this action.
228
+     *
229
+     * @since 0.6.5
230
+     * @return This action's error message, or null if no error was encountered
231
+     */
232
+    public String getError() {
233
+        return error;
234
+    }
235
+
236
+    /**
237
+     * Retrieves the type of the error that occurred while loading this action.
238
+     *
239
+     * @since 0.6.5
240
+     * @return This action's error's type, or null if no error was encountered
241
+     */
242
+    public ActionErrorType getErrorType() {
243
+        return errorType;
244
+    }
245
+
203 246
     /**
204 247
      * Retrieves this action's triggers.
205 248
      *

+ 39
- 0
src/com/dmdirc/actions/ActionStatus.java 查看文件

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
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
+
23
+package com.dmdirc.actions;
24
+
25
+/**
26
+ * An enumeration of possible statuses for actions.
27
+ *
28
+ * @since 0.6.6
29
+ */
30
+public enum ActionStatus {
31
+
32
+    /** The action is active and will run if triggered. */
33
+    ACTIVE,
34
+    /** The action is disabled by the user. */
35
+    DISABLED,
36
+    /** The action has failed to load. */
37
+    FAILED;
38
+
39
+}

+ 1
- 1
test/com/dmdirc/actions/ActionComponentChainTest.java 查看文件

@@ -34,7 +34,7 @@ public class ActionComponentChainTest {
34 34
     @BeforeClass
35 35
     public static void setUp() throws Exception {
36 36
         IdentityManager.load();
37
-        ActionManager.init();
37
+        ActionManager.getActionManager().initialise();
38 38
     }
39 39
 
40 40
     @Test

+ 1
- 1
test/com/dmdirc/actions/ActionConditionTest.java 查看文件

@@ -33,7 +33,7 @@ public class ActionConditionTest {
33 33
     @BeforeClass
34 34
     public static void setUp() throws Exception {
35 35
         IdentityManager.load();
36
-        ActionManager.init();
36
+        ActionManager.getActionManager().initialise();
37 37
     }
38 38
 
39 39
     @Test

+ 15
- 15
test/com/dmdirc/actions/ActionManagerTest.java 查看文件

@@ -36,26 +36,26 @@ public class ActionManagerTest {
36 36
     @BeforeClass
37 37
     public static void setUpClass() throws Exception {
38 38
         IdentityManager.load();
39
-        ActionManager.init();
40
-        ActionManager.loadActions();
39
+        ActionManager.getActionManager().initialise();
40
+        ActionManager.getActionManager().loadUserActions();
41 41
 
42 42
         tearDownClass();
43 43
     }
44 44
 
45 45
     @AfterClass
46 46
     public static void tearDownClass() throws Exception {
47
-        if (ActionManager.getGroups().containsKey("unit-test")) {
48
-            ActionManager.removeGroup("unit-test");
47
+        if (ActionManager.getActionManager().getGroupsMap().containsKey("unit-test")) {
48
+            ActionManager.getActionManager().deleteGroup("unit-test");
49 49
         }
50 50
 
51
-        if (ActionManager.getGroups().containsKey("unit-test-two")) {
52
-            ActionManager.removeGroup("unit-test-two");
51
+        if (ActionManager.getActionManager().getGroupsMap().containsKey("unit-test-two")) {
52
+            ActionManager.getActionManager().deleteGroup("unit-test-two");
53 53
         }
54 54
     }
55 55
 
56 56
     @Test
57 57
     public void testMakeGroup() {
58
-        ActionManager.makeGroup("unit-test");
58
+        ActionManager.getActionManager().createGroup("unit-test");
59 59
 
60 60
         assertTrue("makeGroup must create the group directory",
61 61
                 new File(ActionManager.getDirectory() + "unit-test").isDirectory());
@@ -63,7 +63,7 @@ public class ActionManagerTest {
63 63
 
64 64
     @Test
65 65
     public void testGetGroup() {
66
-        final ActionGroup group = ActionManager.getGroup("unit-test");
66
+        final ActionGroup group = ActionManager.getActionManager().getOrCreateGroup("unit-test");
67 67
 
68 68
         assertEquals("getGroup must return an ActionGroup with the right name",
69 69
                 "unit-test", group.getName());
@@ -71,7 +71,7 @@ public class ActionManagerTest {
71 71
 
72 72
     @Test
73 73
     public void testRenameGroup() {
74
-        ActionManager.renameGroup("unit-test", "unit-test-two");
74
+        ActionManager.getActionManager().changeGroupName("unit-test", "unit-test-two");
75 75
         assertFalse("renameGroup must unlink the old directory",
76 76
                 new File(ActionManager.getDirectory() + "unit-test").isDirectory());
77 77
         assertTrue("renameGroup must create the target directory",
@@ -83,26 +83,26 @@ public class ActionManagerTest {
83 83
         final Action action = new Action("unit-test-two", "test1", new ActionType[0],
84 84
                 new String[0], new ArrayList<ActionCondition>(), null);
85 85
         assertSame("Creating a new action must add it to the correct group",
86
-                action, ActionManager.getGroup("unit-test-two").get(0));
86
+                action, ActionManager.getActionManager().getOrCreateGroup("unit-test-two").get(0));
87 87
 
88
-        ActionManager.renameGroup("unit-test-two", "unit-test");
88
+        ActionManager.getActionManager().changeGroupName("unit-test-two", "unit-test");
89 89
         assertFalse("renameGroup must unlink the old directory",
90 90
                 new File(ActionManager.getDirectory() + "unit-test-two").isDirectory());
91 91
         assertTrue("renameGroup must create the target directory",
92 92
                 new File(ActionManager.getDirectory() + "unit-test").isDirectory());
93 93
         assertSame("renameGroup must move actions to new group",
94
-                action, ActionManager.getGroup("unit-test").get(0));
94
+                action, ActionManager.getActionManager().getOrCreateGroup("unit-test").get(0));
95 95
         assertEquals("renameGroup must remove actions from old group",
96
-                0, ActionManager.getGroup("unit-test-two").size());
96
+                0, ActionManager.getActionManager().getOrCreateGroup("unit-test-two").size());
97 97
     }
98 98
 
99 99
     @Test
100 100
     public void testRemoveGroup() {
101
-        ActionManager.removeGroup("unit-test");
101
+        ActionManager.getActionManager().deleteGroup("unit-test");
102 102
         assertFalse("removeGroup must unlink directory",
103 103
                 new File(ActionManager.getDirectory() + "unit-test").isDirectory());
104 104
 
105
-        ActionManager.saveActions();
105
+        ActionManager.getActionManager().saveAllActions();
106 106
         assertFalse("saveActions must not restore removed groups",
107 107
                 new File(ActionManager.getDirectory() + "unit-test").isDirectory());
108 108
     }

+ 1
- 1
test/com/dmdirc/actions/ActionSubstitutorTest.java 查看文件

@@ -55,7 +55,7 @@ public class ActionSubstitutorTest {
55 55
     @BeforeClass
56 56
     public static void setup() throws InvalidIdentityFileException {
57 57
         IdentityManager.load();
58
-        ActionManager.init();
58
+        ActionManager.getActionManager().initialise();
59 59
 
60 60
         SETTINGS.put("alpha", "A");
61 61
         SETTINGS.put("bravo", "$alpha");

+ 3
- 3
test/com/dmdirc/actions/ActionTest.java 查看文件

@@ -44,7 +44,7 @@ public class ActionTest {
44 44
     @BeforeClass
45 45
     public static void setUp() throws Exception {
46 46
         IdentityManager.load();
47
-        ActionManager.init();
47
+        ActionManager.getActionManager().initialise();
48 48
     }
49 49
 
50 50
     private static Action action;
@@ -115,9 +115,9 @@ public class ActionTest {
115 115
         action.config.read();
116 116
         action.loadActionFromConfig();
117 117
 
118
-        assertEquals(1, ActionManager.getGroup("unit-test").getSettings().size());
118
+        assertEquals(1, ActionManager.getActionManager().getOrCreateGroup("unit-test").getSettings().size());
119 119
 
120
-        final PreferencesSetting setting = ActionManager.getGroup("unit-test")
120
+        final PreferencesSetting setting = ActionManager.getActionManager().getOrCreateGroup("unit-test")
121 121
                 .getSettings().values().iterator().next();
122 122
         assertEquals(PreferencesType.TEXT, setting.getType());
123 123
         assertEquals("Highlight Regex", setting.getTitle());

+ 1
- 2
test/com/dmdirc/actions/validators/ActionGroupValidatorTest.java 查看文件

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.actions.validators;
24 24
 
25
-import com.dmdirc.actions.validators.ActionGroupValidator;
26 25
 import com.dmdirc.actions.ActionManager;
27 26
 import com.dmdirc.config.IdentityManager;
28 27
 import org.junit.BeforeClass;
@@ -34,12 +33,12 @@ public class ActionGroupValidatorTest {
34 33
     @BeforeClass
35 34
     public static void setUpClass() throws Exception {
36 35
         IdentityManager.load();
36
+        ActionManager.getActionManager().initialise();
37 37
     }
38 38
 
39 39
     @Test
40 40
     public void testValidate() {
41 41
         final ActionGroupValidator rv = new ActionGroupValidator();
42
-        ActionManager.init();
43 42
 
44 43
         assertFalse(rv.validate("filename").isFailure());
45 44
         assertTrue(rv.validate("aliases").isFailure());

+ 4
- 4
test/com/dmdirc/config/prefs/PreferencesManagerTest.java 查看文件

@@ -124,8 +124,8 @@ public class PreferencesManagerTest {
124 124
     public void testOpenAction() {
125 125
         final ActionListener tal = mock(ActionListener.class);
126 126
 
127
-        ActionManager.init();
128
-        ActionManager.addListener(tal, CoreActionType.CLIENT_PREFS_OPENED);
127
+        ActionManager.getActionManager().initialise();
128
+        ActionManager.getActionManager().registerListener(tal, CoreActionType.CLIENT_PREFS_OPENED);
129 129
 
130 130
         final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
131 131
 
@@ -137,8 +137,8 @@ public class PreferencesManagerTest {
137 137
     public void testCloseAction() {
138 138
         final ActionListener tal = mock(ActionListener.class);
139 139
 
140
-        ActionManager.init();
141
-        ActionManager.addListener(tal, CoreActionType.CLIENT_PREFS_CLOSED);
140
+        ActionManager.getActionManager().initialise();
141
+        ActionManager.getActionManager().registerListener(tal, CoreActionType.CLIENT_PREFS_CLOSED);
142 142
 
143 143
         final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
144 144
         pm.close();

正在加载...
取消
保存