|
@@ -41,7 +41,9 @@ import com.dmdirc.util.WeakMapList;
|
41
|
41
|
import java.io.File;
|
42
|
42
|
import java.io.IOException;
|
43
|
43
|
import java.util.ArrayList;
|
|
44
|
+import java.util.HashMap;
|
44
|
45
|
import java.util.List;
|
|
46
|
+import java.util.Map;
|
45
|
47
|
|
46
|
48
|
/**
|
47
|
49
|
* Manages all actions for the client.
|
|
@@ -71,8 +73,8 @@ public final class ActionManager {
|
71
|
73
|
= new MapList<ActionType, Action>();
|
72
|
74
|
|
73
|
75
|
/** A map linking groups and a list of actions that're in them. */
|
74
|
|
- private final static MapList<String, Action> groups
|
75
|
|
- = new MapList<String, Action>();
|
|
76
|
+ private final static Map<String, ActionGroup> groups
|
|
77
|
+ = new HashMap<String, ActionGroup>();
|
76
|
78
|
|
77
|
79
|
/** A map of the action type groups to the action types within. */
|
78
|
80
|
private final static MapList<String, ActionType> actionTypeGroups
|
|
@@ -178,7 +180,7 @@ public final class ActionManager {
|
178
|
180
|
*
|
179
|
181
|
* @return a map of groups to action lists
|
180
|
182
|
*/
|
181
|
|
- public static MapList<String, Action> getGroups() {
|
|
183
|
+ public static Map<String, ActionGroup> getGroups() {
|
182
|
184
|
return groups;
|
183
|
185
|
}
|
184
|
186
|
|
|
@@ -291,10 +293,25 @@ public final class ActionManager {
|
291
|
293
|
if (isWrappedGroup(action.getGroup())) {
|
292
|
294
|
getWrapper(action.getGroup()).registerAction(action);
|
293
|
295
|
} else {
|
294
|
|
- groups.add(action.getGroup(), action);
|
|
296
|
+ getGroup(action.getGroup()).add(action);
|
295
|
297
|
}
|
296
|
298
|
}
|
297
|
299
|
|
|
300
|
+ /**
|
|
301
|
+ * Retrieves the action group with the specified name. A new group is
|
|
302
|
+ * created if it doesn't already exist.
|
|
303
|
+ *
|
|
304
|
+ * @param name The name of the group to retrieve
|
|
305
|
+ * @return The corresponding ActionGroup
|
|
306
|
+ */
|
|
307
|
+ public static ActionGroup getGroup(final String name) {
|
|
308
|
+ if (!groups.containsKey(name)) {
|
|
309
|
+ groups.put(name, new ActionGroup(name));
|
|
310
|
+ }
|
|
311
|
+
|
|
312
|
+ return groups.get(name);
|
|
313
|
+ }
|
|
314
|
+
|
298
|
315
|
/**
|
299
|
316
|
* Unregisters an action with the manager.
|
300
|
317
|
*
|
|
@@ -305,7 +322,7 @@ public final class ActionManager {
|
305
|
322
|
assert(action != null);
|
306
|
323
|
|
307
|
324
|
actions.removeFromAll(action);
|
308
|
|
- groups.removeFromAll(action);
|
|
325
|
+ getGroup(action.getGroup()).remove(action);
|
309
|
326
|
}
|
310
|
327
|
|
311
|
328
|
/**
|
|
@@ -407,7 +424,7 @@ public final class ActionManager {
|
407
|
424
|
assert(!groups.containsKey(group));
|
408
|
425
|
|
409
|
426
|
if (new File(getDirectory() + group).mkdir()) {
|
410
|
|
- groups.add(group);
|
|
427
|
+ groups.put(group, new ActionGroup(group));
|
411
|
428
|
}
|
412
|
429
|
}
|
413
|
430
|
|
|
@@ -423,7 +440,7 @@ public final class ActionManager {
|
423
|
440
|
public static void removeGroup(final String group) {
|
424
|
441
|
assert(group != null);
|
425
|
442
|
assert(!group.isEmpty());
|
426
|
|
- assert(groups.containsKey(group));
|
|
443
|
+ assert(groups.containsKey(group));
|
427
|
444
|
|
428
|
445
|
for (Action action : new ArrayList<Action>(groups.get(group))) {
|
429
|
446
|
unregisterAction(action);
|
|
@@ -474,10 +491,10 @@ public final class ActionManager {
|
474
|
491
|
|
475
|
492
|
for (Action action : groups.get(oldName)) {
|
476
|
493
|
action.setGroup(newName);
|
477
|
|
- groups.add(newName, action);
|
|
494
|
+ getGroup(newName).add(action);
|
478
|
495
|
}
|
479
|
496
|
|
480
|
|
- groups.clear(oldName);
|
|
497
|
+ groups.remove(oldName);
|
481
|
498
|
|
482
|
499
|
removeGroup(oldName);
|
483
|
500
|
}
|