Parcourir la source

Tidy up ActionTableModel.

Change-Id: I570ae93cd47ab4c77b42b2e20cbec89c62679867
Reviewed-on: http://gerrit.dmdirc.com/3830
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/30/3830/3
Greg Holmes il y a 9 ans
Parent
révision
0a768e802f

+ 9
- 19
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionTableModel.java Voir le fichier

@@ -27,6 +27,7 @@ import com.dmdirc.actions.ActionGroup;
27 27
 import com.dmdirc.interfaces.actions.ActionType;
28 28
 
29 29
 import java.util.ArrayList;
30
+import java.util.Collection;
30 31
 import java.util.List;
31 32
 
32 33
 import javax.swing.table.AbstractTableModel;
@@ -39,27 +40,17 @@ public class ActionTableModel extends AbstractTableModel {
39 40
     /** A version number for this class. */
40 41
     private static final long serialVersionUID = 1;
41 42
     /** Action list. */
42
-    private List<Action> actions;
43
-
44
-    /**
45
-     * Instantiates a new table model.
46
-     */
47
-    public ActionTableModel() {
48
-        this(new ArrayList<Action>());
49
-    }
43
+    private final List<Action> actions;
50 44
 
51 45
     /**
52 46
      * Instantiates a new table model.
53 47
      *
54 48
      * @param actions Actions to show
55 49
      */
56
-    public ActionTableModel(final List<Action> actions) {
57
-        super();
58
-
59
-        if (actions == null) {
60
-            this.actions = new ArrayList<>();
61
-        } else {
62
-            this.actions = actions;
50
+    public ActionTableModel(final Collection<Action> actions) {
51
+        this.actions = new ArrayList<>();
52
+        if (actions != null) {
53
+            actions.addAll(actions);
63 54
         }
64 55
     }
65 56
 
@@ -152,10 +143,9 @@ public class ActionTableModel extends AbstractTableModel {
152 143
      */
153 144
     public void setActionGroup(final ActionGroup group) {
154 145
         synchronized (actions) {
155
-            if (group == null) {
156
-                actions = new ArrayList<>();
157
-            } else {
158
-                actions = group.getActions();
146
+            actions.clear();
147
+            if (group != null) {
148
+                actions.addAll(group.getActions());
159 149
             }
160 150
             fireTableDataChanged();
161 151
         }

Chargement…
Annuler
Enregistrer