Bladeren bron

Action wrappers now extend action groups

Groups now encapsulate instead of extending their ArrayLists, to limit the number of ways it can be modified
Various resulting tweaks
Fixes issue 631

git-svn-id: http://svn.dmdirc.com/trunk@3859 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 jaren geleden
bovenliggende
commit
ffe8575500

+ 1
- 1
src/com/dmdirc/Main.java Bestand weergeven

@@ -53,7 +53,7 @@ public final class Main {
53 53
     public static final String VERSION = "SVN";
54 54
 
55 55
     /** The SVN revision that this build was made from. */
56
-    public static final int SVN_REVISION = 3628; // 3601;
56
+    public static final int SVN_REVISION = 3853; // 3853; // 3853; // 3853; // 3628; // 3601;
57 57
 
58 58
     /** Stores the update channel that this version came from, if any. */
59 59
     public static final UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE;

+ 79
- 1
src/com/dmdirc/actions/ActionGroup.java Bestand weergeven

@@ -23,15 +23,19 @@
23 23
 package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.config.prefs.PreferencesSetting;
26
+
26 27
 import java.util.ArrayList;
28
+import java.util.Collection;
29
+import java.util.Iterator;
27 30
 import java.util.List;
31
+import java.util.ListIterator;
28 32
 
29 33
 /**
30 34
  * Represents a group of actions, along with their meta-data.
31 35
  * 
32 36
  * @author chris
33 37
  */
34
-public class ActionGroup extends ArrayList<Action> {
38
+public class ActionGroup implements Iterable<Action> {
35 39
     
36 40
     /**
37 41
      * A version number for this class. It should be changed whenever the class
@@ -40,6 +44,9 @@ public class ActionGroup extends ArrayList<Action> {
40 44
      */
41 45
     private static final long serialVersionUID = 1;    
42 46
     
47
+    /** The actions in this group. */
48
+    private final List<Action> actions = new ArrayList<Action>();
49
+    
43 50
     /** The name of this action group. */
44 51
     private final String name;
45 52
     
@@ -159,5 +166,76 @@ public class ActionGroup extends ArrayList<Action> {
159 166
     public void setComponent(final int component) {
160 167
         this.component = component;
161 168
     }
169
+    
170
+    /**
171
+     * Determines the size of this group.
172
+     * 
173
+     * @return The size of this group
174
+     */
175
+    public int size() {
176
+        return actions.size();
177
+    }
178
+
179
+    /**
180
+     * Removes the specified action from this group.
181
+     * 
182
+     * @param action The action to be removed
183
+     */
184
+    public void remove(final Action action) {
185
+        actions.remove(action);
186
+    }
187
+
188
+    /** {@inheritDoc} */
189
+    @Override
190
+    public Iterator<Action> iterator() {
191
+        return actions.iterator();
192
+    }
193
+
194
+    /**
195
+     * Retrieves the action at the specified index.
196
+     * 
197
+     * @param index The index of the action to return
198
+     * @return The action at the specified index
199
+     */
200
+    public Action get(final int index) {
201
+        return actions.get(index);
202
+    }
162 203
 
204
+    /**
205
+     * Determines if this group contains the specified action.
206
+     * 
207
+     * @param action The action to search for
208
+     * @return True if the action is contained in this list, false otherwise
209
+     */
210
+    public boolean contains(final Action action) {
211
+        return actions.contains(action);
212
+    }
213
+
214
+    /**
215
+     * Removes all actions from this group.
216
+     */
217
+    public void clear() {
218
+        for (Action action : new ArrayList<Action>(actions)) {
219
+            remove(action);
220
+        }
221
+    }
222
+
223
+    /**
224
+     * Adds the specified action to this group.
225
+     * 
226
+     * @param action The action to be added
227
+     */
228
+    public void add(final Action action) {
229
+        actions.add(action);
230
+    }
231
+    
232
+    /**
233
+     * Retrieves a copy of the list of all actions in this group.
234
+     * 
235
+     * @return A list of actions in this group
236
+     */
237
+    public List<Action> getActions() {
238
+        return new ArrayList<Action>(actions);
239
+    }
240
+    
163 241
 }

+ 14
- 65
src/com/dmdirc/actions/ActionManager.java Bestand weergeven

@@ -27,7 +27,6 @@ import com.dmdirc.Precondition;
27 27
 import com.dmdirc.actions.interfaces.ActionComparison;
28 28
 import com.dmdirc.actions.interfaces.ActionComponent;
29 29
 import com.dmdirc.actions.interfaces.ActionType;
30
-import com.dmdirc.actions.wrappers.ActionWrapper;
31 30
 import com.dmdirc.actions.wrappers.AliasWrapper;
32 31
 import com.dmdirc.actions.wrappers.PerformWrapper;
33 32
 import com.dmdirc.config.IdentityManager;
@@ -65,10 +64,6 @@ public final class ActionManager {
65 64
     private final static List<ActionComparison> actionComparisons
66 65
             = new ArrayList<ActionComparison>();
67 66
 
68
-    /** A list of all action wrappers that have registered with us. */
69
-    private final static List<ActionWrapper> actionWrappers
70
-            = new ArrayList<ActionWrapper>();
71
-
72 67
     /** A map linking types and a list of actions that're registered for them. */
73 68
     private final static MapList<ActionType, Action> actions
74 69
             = new MapList<ActionType, Action>();
@@ -102,8 +97,8 @@ public final class ActionManager {
102 97
         registerActionComparisons(CoreActionComparison.values());
103 98
         registerActionComponents(CoreActionComponent.values());
104 99
 
105
-        registerWrapper(AliasWrapper.getAliasWrapper());
106
-        registerWrapper(PerformWrapper.getPerformWrapper());
100
+        registerGroup(AliasWrapper.getAliasWrapper());
101
+        registerGroup(PerformWrapper.getPerformWrapper());
107 102
        
108 103
         // Register a listener for the closing event, so we can save actions
109 104
         addListener(new ActionListener() {
@@ -150,20 +145,12 @@ public final class ActionManager {
150 145
     }
151 146
 
152 147
     /**
153
-     * Registers the specified action wrapper with the manager.
148
+     * Registers the specified group of actions with the manager.
154 149
      *
155
-     * @param wrapper The wrapper to be registered
150
+     * @param group The group of actions to be registered
156 151
      */
157
-    @Precondition({
158
-        "The specified wrapper is not null",
159
-        "The specified wrapper's group name is non-null and not empty"
160
-    })
161
-    public static void registerWrapper(final ActionWrapper wrapper) {
162
-        Logger.assertTrue(wrapper != null);
163
-        Logger.assertTrue(wrapper.getGroupName() != null);
164
-        Logger.assertTrue(!wrapper.getGroupName().isEmpty());
165
-
166
-        actionWrappers.add(wrapper);
152
+    public static void registerGroup(final ActionGroup group) {
153
+        groups.put(group.getName(), group);
167 154
     }
168 155
 
169 156
     /**
@@ -232,10 +219,9 @@ public final class ActionManager {
232 219
      */
233 220
     public static void loadActions() {
234 221
         actions.clear();
235
-        groups.clear();
236 222
 
237
-        for (ActionWrapper wrapper : actionWrappers) {
238
-            wrapper.clearActions();
223
+        for (ActionGroup group : groups.values()) {
224
+            group.clear();
239 225
         }
240 226
 
241 227
         final File dir = new File(getDirectory());
@@ -272,41 +258,6 @@ public final class ActionManager {
272 258
         }
273 259
     }
274 260
 
275
-    /**
276
-     * Retrieves the action wrapper with the specified group name.
277
-     *
278
-     * @param name The group name to find
279
-     * @return An ActionWrapper with the specified group name, or null
280
-     */
281
-    @Precondition("The specified name is non-null and not empty")
282
-    private static ActionWrapper getWrapper(final String name) {
283
-        Logger.assertTrue(name != null);
284
-        Logger.assertTrue(!name.isEmpty());
285
-
286
-        for (ActionWrapper wrapper : actionWrappers) {
287
-            if (name.equals(wrapper.getGroupName())) {
288
-                return wrapper;
289
-            }
290
-        }
291
-
292
-        return null;
293
-    }
294
-
295
-    /**
296
-     * Determines whether the specified group name is one used by an action
297
-     * wrapper.
298
-     *
299
-     * @param name The group name to test
300
-     * @return True if the group is part of a wrapper, false otherwise
301
-     */
302
-    @Precondition("The specified name is non-null and not empty")
303
-    private static boolean isWrappedGroup(final String name) {
304
-        Logger.assertTrue(name != null);
305
-        Logger.assertTrue(!name.isEmpty());
306
-
307
-        return getWrapper(name) != null;
308
-    }
309
-
310 261
     /**
311 262
      * Loads action files from a specified group directory.
312 263
      *
@@ -317,7 +268,9 @@ public final class ActionManager {
317 268
         Logger.assertTrue(dir != null);
318 269
         Logger.assertTrue(dir.isDirectory());
319 270
         
320
-        groups.put(dir.getName(), new ActionGroup(dir.getName()));
271
+        if (!groups.containsKey(dir.getName())) {
272
+            groups.put(dir.getName(), new ActionGroup(dir.getName()));
273
+        }
321 274
 
322 275
         for (File file : dir.listFiles()) {
323 276
             new Action(dir.getName(), file.getName());
@@ -337,11 +290,7 @@ public final class ActionManager {
337 290
             actions.add(trigger, action);
338 291
         }
339 292
 
340
-        if (isWrappedGroup(action.getGroup())) {
341
-            getWrapper(action.getGroup()).registerAction(action);
342
-        } else {
343
-            getGroup(action.getGroup()).add(action);
344
-        }
293
+        getGroup(action.getGroup()).add(action);
345 294
     }
346 295
 
347 296
     /**
@@ -494,7 +443,7 @@ public final class ActionManager {
494 443
         Logger.assertTrue(!group.isEmpty());
495 444
         Logger.assertTrue(groups.containsKey(group));
496 445
 
497
-        for (Action action : new ArrayList<Action>(groups.get(group))) {
446
+        for (Action action : groups.get(group).getActions()) {
498 447
             unregisterAction(action);
499 448
         }
500 449
 
@@ -541,7 +490,7 @@ public final class ActionManager {
541 490
 
542 491
         makeGroup(newName);
543 492
 
544
-        for (Action action : new ArrayList<Action>(groups.get(oldName))) {
493
+        for (Action action : groups.get(oldName).getActions()) {
545 494
             action.setGroup(newName);
546 495
             getGroup(oldName).remove(action);
547 496
             getGroup(newName).add(action);

+ 0
- 82
src/com/dmdirc/actions/wrappers/ActionWrapper.java Bestand weergeven

@@ -1,82 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2008 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.wrappers;
24
-
25
-import com.dmdirc.actions.Action;
26
-
27
-import java.util.ArrayList;
28
-import java.util.List;
29
-
30
-/**
31
- * An action wrapper deals with a specific group of actions in order to provide
32
- * an even more user-friendly experience.
33
- * 
34
- * @author chris
35
- */
36
-public abstract class ActionWrapper {
37
-    
38
-    /** A list of registered actions. */
39
-    protected final List<Action> actions = new ArrayList<Action>();
40
-
41
-    /**
42
-     * Registers the specified action with this manager.
43
-     * 
44
-     * @param action The action to be registered
45
-     */
46
-    public void registerAction(final Action action) {
47
-        actions.add(action);
48
-    }
49
-    
50
-    /**
51
-     * Unregisters the specified action with this manager.
52
-     * 
53
-     * @param action The action to be unregistered
54
-     */
55
-    public void unregisterAction(final Action action) {
56
-        actions.remove(action);
57
-    }
58
-    
59
-    /**
60
-     * Removes all actions from this manager.
61
-     */
62
-    public void clearActions() {
63
-        actions.clear();
64
-    }
65
-    
66
-    /**
67
-     * Retrieves a list of actions registered with this wrapper.
68
-     * 
69
-     * @return A list of registered actions
70
-     */
71
-    public List<Action> getActions() {
72
-        return actions;
73
-    }
74
-    
75
-    /**
76
-     * Retrieve the group name that this wrapper is using.
77
-     * 
78
-     * @return This wrapper's group name
79
-     */
80
-    public abstract String getGroupName();
81
-    
82
-}

+ 1
- 1
src/com/dmdirc/actions/wrappers/Alias.java Bestand weergeven

@@ -227,7 +227,7 @@ public final class Alias implements Serializable {
227 227
      */
228 228
     public Action createAction() {
229 229
         return new Action(
230
-                AliasWrapper.getAliasWrapper().getGroupName(),
230
+                AliasWrapper.getAliasWrapper().getName(),
231 231
                 getName(),
232 232
                 new ActionType[] {CoreActionType.UNKNOWN_COMMAND, },
233 233
                 getResponse(),

+ 8
- 13
src/com/dmdirc/actions/wrappers/AliasWrapper.java Bestand weergeven

@@ -26,12 +26,13 @@ import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerManager;
27 27
 import com.dmdirc.actions.Action;
28 28
 import com.dmdirc.actions.ActionCondition;
29
+import com.dmdirc.actions.ActionGroup;
29 30
 import com.dmdirc.actions.CoreActionType;
30 31
 import com.dmdirc.commandparser.CommandManager;
31 32
 import com.dmdirc.logger.ErrorLevel;
32 33
 import com.dmdirc.logger.Logger;
33
-
34 34
 import com.dmdirc.ui.input.TabCompletionType;
35
+
35 36
 import java.util.ArrayList;
36 37
 import java.util.List;
37 38
 
@@ -40,7 +41,7 @@ import java.util.List;
40 41
  *
41 42
  * @author chris
42 43
  */
43
-public final class AliasWrapper extends ActionWrapper {
44
+public final class AliasWrapper extends ActionGroup {
44 45
     
45 46
     /** Singleton instance of the alias wrapper. */
46 47
     private static AliasWrapper me;
@@ -52,7 +53,7 @@ public final class AliasWrapper extends ActionWrapper {
52 53
      * Creates a new instance of AliasWrapper.
53 54
      */
54 55
     private AliasWrapper() {
55
-        super();
56
+        super("aliases");
56 57
     }
57 58
     
58 59
     /**
@@ -79,9 +80,9 @@ public final class AliasWrapper extends ActionWrapper {
79 80
     
80 81
     /** {@inheritDoc} */
81 82
     @Override
82
-    public void registerAction(final Action action) {
83
+    public void add(final Action action) {
83 84
         if (action.getTriggers()[0].equals(CoreActionType.UNKNOWN_COMMAND)) {
84
-            super.registerAction(action);
85
+            super.add(action);
85 86
             
86 87
             final String commandName = getCommandName(action);
87 88
             
@@ -97,9 +98,9 @@ public final class AliasWrapper extends ActionWrapper {
97 98
     
98 99
     /** {@inheritDoc} */
99 100
     @Override
100
-    public void unregisterAction(final Action action) {
101
+    public void remove(final Action action) {
101 102
         if (action.getTriggers()[0].equals(CoreActionType.UNKNOWN_COMMAND)) {
102
-            super.unregisterAction(action);
103
+            super.remove(action);
103 104
             
104 105
             final String commandName = getCommandName(action);
105 106
             
@@ -111,12 +112,6 @@ public final class AliasWrapper extends ActionWrapper {
111 112
         }
112 113
     }
113 114
     
114
-    /** {@inheritDoc} */
115
-    @Override
116
-    public String getGroupName() {
117
-        return "aliases";
118
-    }
119
-    
120 115
     /**
121 116
      * Retrieves the command name of the specified alias action.
122 117
      *

+ 7
- 11
src/com/dmdirc/actions/wrappers/PerformWrapper.java Bestand weergeven

@@ -25,6 +25,7 @@ package com.dmdirc.actions.wrappers;
25 25
 import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.actions.interfaces.ActionComponent;
27 27
 import com.dmdirc.actions.ActionCondition;
28
+import com.dmdirc.actions.ActionGroup;
28 29
 import com.dmdirc.actions.interfaces.ActionType;
29 30
 import com.dmdirc.actions.CoreActionComparison;
30 31
 import com.dmdirc.actions.CoreActionComponent;
@@ -40,7 +41,7 @@ import java.util.List;
40 41
  *
41 42
  * @author Chris
42 43
  */
43
-public class PerformWrapper extends ActionWrapper {
44
+public class PerformWrapper extends ActionGroup {
44 45
     
45 46
     /** A singleton instance of the Perform Wrapper. */
46 47
     private static PerformWrapper me = new PerformWrapper();
@@ -49,7 +50,7 @@ public class PerformWrapper extends ActionWrapper {
49 50
      * Creates a new instance of PerformWrapper.
50 51
      */
51 52
     private PerformWrapper() {
52
-        super();
53
+        super("performs");
53 54
     }
54 55
     
55 56
     /**
@@ -61,20 +62,15 @@ public class PerformWrapper extends ActionWrapper {
61 62
         return me;
62 63
     }
63 64
     
64
-    /** {@inheritDoc} */
65
-    public String getGroupName() {
66
-        return "performs";
67
-    }
68
-    
69 65
     /** {@inheritDoc} */
70 66
     @Override
71
-    public void registerAction(final Action action) {
67
+    public void add(final Action action) {
72 68
         if (action.getTriggers().length == 1
73 69
                 && action.getTriggers()[0] == CoreActionType.SERVER_CONNECTED
74 70
                 && action.getConditions().size() == 1
75 71
                 && (action.getConditions().get(0).getComponent() == CoreActionComponent.SERVER_NETWORK
76 72
                 || action.getConditions().get(0).getComponent() == CoreActionComponent.SERVER_NAME)) {
77
-            super.registerAction(action);
73
+            super.add(action);
78 74
         } else {
79 75
             Logger.userError(ErrorLevel.MEDIUM, "Invalid perform action: " + action.getName());
80 76
         }
@@ -138,7 +134,7 @@ public class PerformWrapper extends ActionWrapper {
138 134
         
139 135
         conditions.add(new ActionCondition(0, component, CoreActionComparison.STRING_EQUALS, server + network));
140 136
         
141
-        return new Action(getGroupName(), server + network, new ActionType[]{CoreActionType.SERVER_CONNECTED},
137
+        return new Action(getName(), server + network, new ActionType[]{CoreActionType.SERVER_CONNECTED},
142 138
                 new String[0], conditions, null);
143 139
     }
144 140
     
@@ -151,7 +147,7 @@ public class PerformWrapper extends ActionWrapper {
151 147
      * @return The matching action if one exists, or null
152 148
      */    
153 149
     private Action getAction(final ActionComponent component, final String target) {
154
-        for (Action action : actions) {
150
+        for (Action action : this) {
155 151
             if (action.getConditions().get(0).getComponent() == component
156 152
                     && action.getConditions().get(0).getTarget().equalsIgnoreCase(target)) {
157 153
                 return action;

+ 3
- 3
src/com/dmdirc/commandparser/commands/global/AliasCommand.java Bestand weergeven

@@ -68,7 +68,7 @@ public final class AliasCommand extends GlobalCommand implements IntelligentComm
68 68
             return;
69 69
         }
70 70
         
71
-        for (Action alias : AliasWrapper.getAliasWrapper().getActions()) {
71
+        for (Action alias : AliasWrapper.getAliasWrapper()) {
72 72
             if (AliasWrapper.getCommandName(alias).substring(1).equalsIgnoreCase(args[0])) {
73 73
                 sendLine(origin, isSilent, FORMAT_ERROR, "Alias '" + args[0] + "' already exists.");
74 74
                 return;
@@ -89,7 +89,7 @@ public final class AliasCommand extends GlobalCommand implements IntelligentComm
89 89
      * @return True if the alias was deleted, false otherwise
90 90
      */
91 91
     private boolean doRemove(final String name) {
92
-        for (Action alias : AliasWrapper.getAliasWrapper().getActions()) {
92
+        for (Action alias : AliasWrapper.getAliasWrapper()) {
93 93
             if (AliasWrapper.getCommandName(alias).substring(1).equalsIgnoreCase(name)) {
94 94
                 alias.delete();
95 95
                 ActionManager.unregisterAction(alias);
@@ -128,7 +128,7 @@ public final class AliasCommand extends GlobalCommand implements IntelligentComm
128 128
             res.add("--remove");
129 129
             res.excludeAll();
130 130
         } else if (arg == 1 && previousArgs.get(0).equals("--remove")) {
131
-            for (Action alias : AliasWrapper.getAliasWrapper().getActions()) {
131
+            for (Action alias : AliasWrapper.getAliasWrapper()) {
132 132
                 res.add(alias.getName());
133 133
             }   
134 134
         } else if (arg >= 1 && !previousArgs.get(0).equals("--remove")) {

+ 2
- 3
src/com/dmdirc/ui/swing/dialogs/actionseditor/ActionsEditorDialog.java Bestand weergeven

@@ -24,6 +24,7 @@ package com.dmdirc.ui.swing.dialogs.actionseditor;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.actions.Action;
27
+import com.dmdirc.actions.ActionGroup;
27 28
 import com.dmdirc.actions.ActionManager;
28 29
 import com.dmdirc.actions.interfaces.ActionType;
29 30
 import com.dmdirc.ui.swing.MainFrame;
@@ -324,9 +325,7 @@ public final class ActionsEditorDialog extends StandardDialog implements
324 325
      * @return true iif there are duplicate names
325 326
      */
326 327
     private boolean checkDuplicateName(final String name) {
327
-        final List<Action> actions = ActionManager.getGroups().get(group);
328
-
329
-        for (Action loopAction : actions) {
328
+        for (Action loopAction : ActionManager.getGroups().get(group)) {
330 329
             if (loopAction.getName().equals(name) && !loopAction.equals(action)) {
331 330
                 return true;
332 331
             }

+ 1
- 1
src/com/dmdirc/ui/swing/dialogs/actionsmanager/ActionTableModel.java Bestand weergeven

@@ -167,7 +167,7 @@ public class ActionTableModel extends AbstractTableModel {
167 167
             if (group == null) {
168 168
                 actions = new ArrayList<Action>();
169 169
             } else {
170
-                actions = new ArrayList<Action>(group);
170
+                actions = group.getActions();
171 171
             }
172 172
             fireTableDataChanged();
173 173
         }

+ 2
- 1
src/com/dmdirc/ui/swing/dialogs/actionsmanager/ActionsGroupPanel.java Bestand weergeven

@@ -35,6 +35,7 @@ import java.awt.event.ActionListener;
35 35
 import java.awt.event.MouseAdapter;
36 36
 import java.awt.event.MouseEvent;
37 37
 
38
+import java.util.ArrayList;
38 39
 import javax.swing.JButton;
39 40
 import javax.swing.JOptionPane;
40 41
 import javax.swing.JPanel;
@@ -123,7 +124,7 @@ public final class ActionsGroupPanel extends JPanel implements ActionListener,
123 124
      */
124 125
     private void initComponents() {
125 126
         scrollPane = new JScrollPane();
126
-        model = new ActionTableModel(group);
127
+        model = new ActionTableModel(group == null ? new ArrayList<Action>() : group.getActions());
127 128
         table = new PackingTable(model, false, scrollPane, false) {
128 129
 
129 130
             /**

+ 3
- 6
src/com/dmdirc/ui/swing/dialogs/aliases/AliasManagerDialog.java Bestand weergeven

@@ -192,9 +192,8 @@ public final class AliasManagerDialog extends StandardDialog implements
192 192
      */
193 193
     private List<Alias> getTableData() {
194 194
         final List<Alias> aliases = new ArrayList<Alias>();
195
-        final List<Action> actions = AliasWrapper.getAliasWrapper().getActions();
196 195
         
197
-        for (Action loopAction : actions) {
196
+        for (Action loopAction : AliasWrapper.getAliasWrapper()) {
198 197
             final List<ActionCondition> arguments = loopAction.getConditions();
199 198
             
200 199
             ActionCondition argument;
@@ -326,8 +325,7 @@ public final class AliasManagerDialog extends StandardDialog implements
326 325
     
327 326
     /** Saves the aliases. */
328 327
     private void save() {
329
-        final List<Action> actions = new ArrayList<Action>(
330
-                AliasWrapper.getAliasWrapper().getActions());
328
+        final List<Action> actions = AliasWrapper.getAliasWrapper().getActions();
331 329
         final List<Alias> aliases = tableModel.getAliases();
332 330
         
333 331
         final List<Alias> newAliases = new ArrayList<Alias>();
@@ -395,8 +393,7 @@ public final class AliasManagerDialog extends StandardDialog implements
395 393
      * @return Corresponding action or null if none found
396 394
      */
397 395
     private Action getAction(final Alias alias) {
398
-        final List<Action> actions = new ArrayList<Action>(
399
-                AliasWrapper.getAliasWrapper().getActions());
396
+        final List<Action> actions = AliasWrapper.getAliasWrapper().getActions();
400 397
         Action action = null;
401 398
         
402 399
         for (Action loopAction : actions) {

+ 2
- 2
test/com/dmdirc/actions/ActionManagerTest.java Bestand weergeven

@@ -77,8 +77,8 @@ public class ActionManagerTest extends junit.framework.TestCase {
77 77
                 new File(ActionManager.getDirectory() + "unit-test").isDirectory());        
78 78
         assertSame("renameGroup must move actions to new group",
79 79
                 action, ActionManager.getGroup("unit-test").get(0));
80
-        assertTrue("renameGroup must remove actions from old group",
81
-                ActionManager.getGroup("unit-test-two").isEmpty());
80
+        assertEquals("renameGroup must remove actions from old group",
81
+                0, ActionManager.getGroup("unit-test-two").size());
82 82
     }
83 83
     
84 84
     @Test

Laden…
Annuleren
Opslaan