Browse Source

Actions tidying.

Change-Id: I77c22319367b42840431e18ee998011a730ac6af
Reviewed-on: http://gerrit.dmdirc.com/3695
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 10 years ago
parent
commit
05c552a0e3

+ 3
- 2
.idea/misc.xml View File

@@ -2,8 +2,9 @@
2 2
 <project version="4">
3 3
   <component name="EntryPointsManager">
4 4
     <entry_points version="2.0" />
5
-    <list size="1">
6
-      <item index="0" class="java.lang.String" itemvalue="dagger.Provides" />
5
+    <list size="2">
6
+      <item index="0" class="java.lang.String" itemvalue="com.google.common.eventbus.Subscribe" />
7
+      <item index="1" class="java.lang.String" itemvalue="dagger.Provides" />
7 8
     </list>
8 9
   </component>
9 10
   <component name="NullableNotNullManager">

+ 10
- 27
src/com/dmdirc/actions/Action.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.GlobalWindow;
26
-import com.dmdirc.commandparser.parsers.GlobalCommandParser;
27 26
 import com.dmdirc.config.prefs.PreferencesSetting;
28 27
 import com.dmdirc.config.prefs.PreferencesType;
29 28
 import com.dmdirc.events.ActionCreatedEvent;
@@ -94,7 +93,6 @@ public class Action extends ActionModel implements ConfigChangeListener {
94 93
      *
95 94
      * @param filesystem                  The file system to read/write actions to
96 95
      * @param eventBus                    Event bus to post events to
97
-     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
98 96
      * @param globalWindowProvider        Provider of global windows for triggering actions.
99 97
      * @param substitutorFactory          Factory to use to create action substitutors.
100 98
      * @param actionController            The controller that owns this action.
@@ -103,18 +101,12 @@ public class Action extends ActionModel implements ConfigChangeListener {
103 101
      * @param group                       The group the action belongs to
104 102
      * @param name                        The name of the action
105 103
      */
106
-    public Action(
107
-            final FileSystem filesystem,
108
-            final EventBus eventBus,
109
-            final Provider<GlobalCommandParser> globalCommandParserProvider,
104
+    public Action(final FileSystem filesystem, final EventBus eventBus,
110 105
             final Provider<GlobalWindow> globalWindowProvider,
111 106
             final ActionSubstitutorFactory substitutorFactory,
112
-            final ActionController actionController,
113
-            final IdentityController identityController,
114
-            final String actionsDirectory,
115
-            final String group,
116
-            final String name) {
117
-        super(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name);
107
+            final ActionController actionController, final IdentityController identityController,
108
+            final String actionsDirectory, final String group, final String name) {
109
+        super(globalWindowProvider, substitutorFactory, group, name);
118 110
 
119 111
         this.filesystem = filesystem;
120 112
         this.eventBus = eventBus;
@@ -144,7 +136,6 @@ public class Action extends ActionModel implements ConfigChangeListener {
144 136
      *
145 137
      * @param filesystem                  The file system to read/write actions to
146 138
      * @param eventBus                    Event bus to post events to
147
-     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
148 139
      * @param globalWindowProvider        Provider of global windows for triggering actions.
149 140
      * @param substitutorFactory          Factory to use to create action substitutors.
150 141
      * @param actionController            The controller that owns this action.
@@ -158,23 +149,15 @@ public class Action extends ActionModel implements ConfigChangeListener {
158 149
      * @param conditionTree               The condition tree to use
159 150
      * @param newFormat                   The new formatter to use
160 151
      */
161
-    public Action(
162
-            final FileSystem filesystem,
163
-            final EventBus eventBus,
164
-            final Provider<GlobalCommandParser> globalCommandParserProvider,
152
+    public Action(final FileSystem filesystem, final EventBus eventBus,
165 153
             final Provider<GlobalWindow> globalWindowProvider,
166 154
             final ActionSubstitutorFactory substitutorFactory,
167
-            final ActionController actionController,
168
-            final IdentityController identityController,
169
-            final String actionsDirectory,
170
-            final String group,
171
-            final String name,
172
-            final ActionType[] triggers,
173
-            final String[] response,
174
-            final List<ActionCondition> conditions,
175
-            final ConditionTree conditionTree,
155
+            final ActionController actionController, final IdentityController identityController,
156
+            final String actionsDirectory, final String group, final String name,
157
+            final ActionType[] triggers, final String[] response,
158
+            final List<ActionCondition> conditions, final ConditionTree conditionTree,
176 159
             final String newFormat) {
177
-        super(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name,
160
+        super(globalWindowProvider, substitutorFactory, group, name,
178 161
                 triggers, response, conditions, conditionTree, newFormat);
179 162
 
180 163
         this.filesystem = filesystem;

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

@@ -38,6 +38,6 @@ public enum ActionErrorType {
38 38
     /** A problem with the action's condition tree. */
39 39
     CONDITION_TREE,
40 40
     /** A problem with the action's conditions. */
41
-    CONDITIONS;
41
+    CONDITIONS
42 42
 
43 43
 }

+ 3
- 16
src/com/dmdirc/actions/ActionFactory.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.actions;
25 25
 import com.dmdirc.GlobalWindow;
26 26
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
27 27
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
28
-import com.dmdirc.commandparser.parsers.GlobalCommandParser;
29 28
 import com.dmdirc.interfaces.ActionController;
30 29
 import com.dmdirc.interfaces.actions.ActionType;
31 30
 import com.dmdirc.interfaces.config.IdentityController;
@@ -46,8 +45,6 @@ import javax.inject.Singleton;
46 45
 @Singleton
47 46
 public class ActionFactory {
48 47
 
49
-    /** Provider of global command parsers. */
50
-    private final Provider<GlobalCommandParser> globalCommandParserProvider;
51 48
     /** The controller that will own actions. */
52 49
     private final Provider<ActionController> actionController;
53 50
     /** The controller to use to retrieve and update settings. */
@@ -69,18 +66,13 @@ public class ActionFactory {
69 66
      * @param eventBus                    The event bus to post events on.
70 67
      * @param actionController            The controller that will own actions.
71 68
      * @param identityController          The controller to use to retrieve and update settings.
72
-     * @param globalCommandParserProvider The global command parser to use for actions without
73
-     *                                    windows.
74 69
      * @param globalWindowProvider        The global window to use for actions without windows.
75 70
      * @param substitutorFactory          The factory to use to create substitutors.
76 71
      * @param actionsDirectory            The base directory to store actions in.
77 72
      */
78 73
     @Inject
79
-    public ActionFactory(
80
-            final EventBus eventBus,
81
-            final Provider<ActionController> actionController,
74
+    public ActionFactory(final EventBus eventBus, final Provider<ActionController> actionController,
82 75
             final Provider<IdentityController> identityController,
83
-            final Provider<GlobalCommandParser> globalCommandParserProvider,
84 76
             final Provider<GlobalWindow> globalWindowProvider,
85 77
             final ActionSubstitutorFactory substitutorFactory,
86 78
             @Directory(DirectoryType.ACTIONS) final String actionsDirectory) {
@@ -88,7 +80,6 @@ public class ActionFactory {
88 80
         this.eventBus = eventBus;
89 81
         this.actionController = actionController;
90 82
         this.identityController = identityController;
91
-        this.globalCommandParserProvider = globalCommandParserProvider;
92 83
         this.globalWindowProvider = globalWindowProvider;
93 84
         this.substitutorFactory = substitutorFactory;
94 85
         this.actionsDirectory = actionsDirectory;
@@ -106,9 +97,7 @@ public class ActionFactory {
106 97
     public Action getAction(final String group, final String name) {
107 98
         return new Action(
108 99
                 filesystem,
109
-                eventBus,
110
-                globalCommandParserProvider,
111
-                globalWindowProvider,
100
+                eventBus, globalWindowProvider,
112 101
                 substitutorFactory,
113 102
                 actionController.get(),
114 103
                 identityController.get(),
@@ -136,9 +125,7 @@ public class ActionFactory {
136 125
             final ConditionTree conditionTree, final String newFormat) {
137 126
         return new Action(
138 127
                 filesystem,
139
-                eventBus,
140
-                globalCommandParserProvider,
141
-                globalWindowProvider,
128
+                eventBus, globalWindowProvider,
142 129
                 substitutorFactory,
143 130
                 actionController.get(),
144 131
                 identityController.get(),

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

@@ -319,8 +319,8 @@ public class ActionManager implements ActionController {
319 319
     public void addAction(final Action action) {
320 320
         checkNotNull(action);
321 321
 
322
-        LOG.debug("Registering action: {}/{} (status: {})",
323
-                new Object[]{action.getGroup(), action.getName(), action.getStatus()});
322
+        LOG.debug("Registering action: {}/{} (status: {})", action.getGroup(), action.getName(),
323
+                action.getStatus());
324 324
 
325 325
         if (action.getStatus() != ActionStatus.FAILED) {
326 326
             for (ActionType trigger : action.getTriggers()) {

+ 2
- 11
src/com/dmdirc/actions/ActionModel.java View File

@@ -26,7 +26,6 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.GlobalWindow;
27 27
 import com.dmdirc.Precondition;
28 28
 import com.dmdirc.commandparser.parsers.CommandParser;
29
-import com.dmdirc.commandparser.parsers.GlobalCommandParser;
30 29
 import com.dmdirc.interfaces.actions.ActionType;
31 30
 
32 31
 import java.util.ArrayList;
@@ -43,8 +42,6 @@ public class ActionModel {
43 42
 
44 43
     // TODO: Sort out the mess of protected fields here.
45 44
 
46
-    /** Provider of global command parsers, for use when triggering window-less actions. */
47
-    private final Provider<GlobalCommandParser> globalCommandParserProvider;
48 45
     /** Provider of global windows for global actions. */
49 46
     private final Provider<GlobalWindow> globalWindowProvider;
50 47
     /** Factory to use to creator substitutors. */
@@ -79,19 +76,16 @@ public class ActionModel {
79 76
     /**
80 77
      * Creates a new instance of ActionModel with the specified properties.
81 78
      *
82
-     * @param globalCommandParserProvider Provider of global command parsers for global actions.
83 79
      * @param globalWindowProvider        Provider of global windows for global actions.
84 80
      * @param substitutorFactory          Factory to use to create action substitutors.
85 81
      * @param group                       The group the action belongs to
86 82
      * @param name                        The name of the action
87 83
      */
88 84
     public ActionModel(
89
-            final Provider<GlobalCommandParser> globalCommandParserProvider,
90 85
             final Provider<GlobalWindow> globalWindowProvider,
91 86
             final ActionSubstitutorFactory substitutorFactory,
92 87
             final String group,
93 88
             final String name) {
94
-        this.globalCommandParserProvider = globalCommandParserProvider;
95 89
         this.globalWindowProvider = globalWindowProvider;
96 90
         this.substitutorFactory = substitutorFactory;
97 91
         this.group = group;
@@ -100,9 +94,7 @@ public class ActionModel {
100 94
 
101 95
     /**
102 96
      * Creates a new instance of ActionModel with the specified properties.
103
-     *
104
-     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
105
-     * @param globalWindowProvider        Provider of global windows for global actions.
97
+     *  @param globalWindowProvider        Provider of global windows for global actions.
106 98
      * @param substitutorFactory          Factory to use to create action substitutors.
107 99
      * @param group                       The group the action belongs to
108 100
      * @param name                        The name of the action
@@ -113,14 +105,13 @@ public class ActionModel {
113 105
      * @param newFormat                   The new formatter to use
114 106
      */
115 107
     public ActionModel(
116
-            final Provider<GlobalCommandParser> globalCommandParserProvider,
117 108
             final Provider<GlobalWindow> globalWindowProvider,
118 109
             final ActionSubstitutorFactory substitutorFactory,
119 110
             final String group, final String name,
120 111
             final ActionType[] triggers, final String[] response,
121 112
             final List<ActionCondition> conditions,
122 113
             final ConditionTree conditionTree, final String newFormat) {
123
-        this(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name);
114
+        this(globalWindowProvider, substitutorFactory, group, name);
124 115
         this.triggers = triggers.clone();
125 116
         this.response = response.clone();
126 117
         this.conditions = conditions;

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

@@ -34,6 +34,6 @@ public enum ActionStatus {
34 34
     /** The action is disabled by the user. */
35 35
     DISABLED,
36 36
     /** The action has failed to load. */
37
-    FAILED;
37
+    FAILED
38 38
 
39 39
 }

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

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
-import com.dmdirc.ClientModule.GlobalConfig;
26 25
 import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.Precondition;
28 27
 import com.dmdirc.ServerState;
@@ -34,8 +33,6 @@ import com.dmdirc.interfaces.actions.ActionComponent;
34 33
 import com.dmdirc.interfaces.actions.ActionType;
35 34
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
36 35
 import com.dmdirc.interfaces.ui.Window;
37
-import com.dmdirc.util.annotations.factory.Factory;
38
-import com.dmdirc.util.annotations.factory.Unbound;
39 36
 
40 37
 import java.util.Arrays;
41 38
 import java.util.HashMap;
@@ -47,7 +44,6 @@ import java.util.regex.Pattern;
47 44
 /**
48 45
  * Handles the substitution of variables into action targets and responses.
49 46
  */
50
-@Factory(inject = true, providers = true, singleton = true)
51 47
 public class ActionSubstitutor {
52 48
 
53 49
     /** Substitution to use when a component requires a connected server. */
@@ -93,9 +89,8 @@ public class ActionSubstitutor {
93 89
     public ActionSubstitutor(
94 90
             final ActionController actionController,
95 91
             final CommandController commandController,
96
-            @SuppressWarnings("qualifiers") @GlobalConfig
97 92
             final AggregateConfigProvider globalConfig,
98
-            @Unbound final ActionType type) {
93
+            final ActionType type) {
99 94
         this.actionController = actionController;
100 95
         this.globalConfig = globalConfig;
101 96
         this.commandController = commandController;

+ 59
- 0
src/com/dmdirc/actions/ActionSubstitutorFactory.java View File

@@ -0,0 +1,59 @@
1
+/*
2
+ * Copyright (c) 2006-2014 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
+
23
+package com.dmdirc.actions;
24
+
25
+import com.dmdirc.ClientModule;
26
+import com.dmdirc.interfaces.ActionController;
27
+import com.dmdirc.interfaces.CommandController;
28
+import com.dmdirc.interfaces.actions.ActionType;
29
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
+
31
+import javax.inject.Inject;
32
+import javax.inject.Provider;
33
+import javax.inject.Singleton;
34
+
35
+/**
36
+ * Factory for {@link ActionSubstitutor}s.
37
+ */
38
+@Singleton
39
+public class ActionSubstitutorFactory {
40
+
41
+    private final Provider<ActionController> actionController;
42
+    private final CommandController commandController;
43
+    private final AggregateConfigProvider globalConfig;
44
+
45
+    @Inject
46
+    public ActionSubstitutorFactory(
47
+            final Provider<ActionController> actionController,
48
+            final CommandController commandController,
49
+            @ClientModule.GlobalConfig final AggregateConfigProvider globalConfig) {
50
+        this.actionController = actionController;
51
+        this.commandController = commandController;
52
+        this.globalConfig = globalConfig;
53
+    }
54
+
55
+    public ActionSubstitutor getActionSubstitutor(final ActionType type) {
56
+        return new ActionSubstitutor(actionController.get(), commandController, globalConfig, type);
57
+    }
58
+
59
+}

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

@@ -67,8 +67,7 @@ public class ColourActionComparison {
67 67
 
68 68
         @Override
69 69
         public boolean test(final Object arg1, final Object arg2) {
70
-            return ((Colour) arg1).equals(colourManager.get().getColourFromString((String) arg2,
71
-                    null));
70
+            return arg1.equals(colourManager.get().getColourFromString((String) arg2, null));
72 71
         }
73 72
 
74 73
         @Override

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

@@ -138,7 +138,7 @@ public final class ConditionTree {
138 138
     @Override
139 139
     public boolean equals(final Object obj) {
140 140
         return obj instanceof ConditionTree
141
-                && toString().equals(((ConditionTree) obj).toString());
141
+                && toString().equals(obj.toString());
142 142
     }
143 143
 
144 144
     @Override

+ 174
- 182
src/com/dmdirc/actions/CoreActionComparison.java View File

@@ -34,201 +34,193 @@ public enum CoreActionComparison implements ActionComparison {
34 34
 
35 35
     /** Compares a string to another using a regular expression. */
36 36
     STRING_REGEX {
37
-
38
-                @Override
39
-                public boolean test(final Object arg1, final Object arg2) {
40
-                    try {
41
-                        return ((String) arg1).matches((String) arg2);
42
-                    } catch (PatternSyntaxException pse) {
43
-                        return false;
44
-                    }
45
-                }
46
-
47
-                @Override
48
-                public Class<?> appliesTo() {
49
-                    return String.class;
50
-                }
51
-
52
-                @Override
53
-                public String getName() {
54
-                    return "matches regex";
55
-                }
56
-            },
57
-    /** Compares if two strings content are
58
-     * the same, case insensitive. */
37
+        @Override
38
+        public boolean test(final Object arg1, final Object arg2) {
39
+            try {
40
+                return ((String) arg1).matches((String) arg2);
41
+            } catch (PatternSyntaxException pse) {
42
+                return false;
43
+            }
44
+        }
45
+
46
+        @Override
47
+        public Class<?> appliesTo() {
48
+            return String.class;
49
+        }
50
+
51
+        @Override
52
+        public String getName() {
53
+            return "matches regex";
54
+        }
55
+    },
56
+    /**
57
+     * Compares if two strings content are the same, case insensitive.
58
+     */
59 59
     STRING_EQUALS {
60
-
61
-                @Override
62
-                public boolean test(final Object arg1, final Object arg2) {
63
-                    return ((String) arg1).equalsIgnoreCase((String) arg2);
64
-                }
65
-
66
-                @Override
67
-                public Class<?> appliesTo() {
68
-                    return String.class;
69
-                }
70
-
71
-                @Override
72
-                public String getName() {
73
-                    return "equals";
74
-                }
75
-            },
76
-    /** Compares if two strings content aren't the same, case
77
-     * insensitive. */
60
+        @Override
61
+        public boolean test(final Object arg1, final Object arg2) {
62
+            return ((String) arg1).equalsIgnoreCase((String) arg2);
63
+        }
64
+
65
+        @Override
66
+        public Class<?> appliesTo() {
67
+            return String.class;
68
+        }
69
+
70
+        @Override
71
+        public String getName() {
72
+            return "equals";
73
+        }
74
+    },
75
+    /**
76
+     * Compares if two strings content aren't the same, case insensitive.
77
+     */
78 78
     STRING_NEQUALS {
79
-
80
-                @Override
81
-                public boolean test(final Object arg1, final Object arg2) {
82
-                    return !STRING_EQUALS.test(arg1, arg2);
83
-                }
84
-
85
-                @Override
86
-                public Class<?> appliesTo() {
87
-                    return String.class;
88
-                }
89
-
90
-                @Override
91
-                public String getName() {
92
-                    return "does not equal";
93
-                }
94
-            },
79
+        @Override
80
+        public boolean test(final Object arg1, final Object arg2) {
81
+            return !STRING_EQUALS.test(arg1, arg2);
82
+        }
83
+
84
+        @Override
85
+        public Class<?> appliesTo() {
86
+            return String.class;
87
+        }
88
+
89
+        @Override
90
+        public String getName() {
91
+            return "does not equal";
92
+        }
93
+    },
95 94
     /** Checks if the string starts with another strings. */
96 95
     STRING_STARTSWITH {
97
-
98
-                @Override
99
-                public boolean test(final Object arg1, final Object arg2) {
100
-                    return ((String) arg1).startsWith((String) arg2);
101
-                }
102
-
103
-                @Override
104
-                public Class<?> appliesTo() {
105
-                    return String.class;
106
-                }
107
-
108
-                @Override
109
-                public String getName() {
110
-                    return "starts with";
111
-                }
112
-            },
113
-    /** Checks if the string containts another string. */
96
+        @Override
97
+        public boolean test(final Object arg1, final Object arg2) {
98
+            return ((String) arg1).startsWith((String) arg2);
99
+        }
100
+
101
+        @Override
102
+        public Class<?> appliesTo() {
103
+            return String.class;
104
+        }
105
+
106
+        @Override
107
+        public String getName() {
108
+            return "starts with";
109
+        }
110
+    },
111
+    /** Checks if the string contains another string. */
114 112
     STRING_CONTAINS {
115
-
116
-                @Override
117
-                public boolean test(final Object arg1, final Object arg2) {
118
-                    return ((String) arg1).indexOf((String) arg2) != -1;
119
-                }
120
-
121
-                @Override
122
-                public Class<?> appliesTo() {
123
-                    return String.class;
124
-                }
125
-
126
-                @Override
127
-                public String getName() {
128
-                    return "contains";
129
-                }
130
-            },
131
-    /** Checks if the string doesn't containt another string. */
113
+        @Override
114
+        public boolean test(final Object arg1, final Object arg2) {
115
+            return ((String) arg1).contains((String) arg2);
116
+        }
117
+
118
+        @Override
119
+        public Class<?> appliesTo() {
120
+            return String.class;
121
+        }
122
+
123
+        @Override
124
+        public String getName() {
125
+            return "contains";
126
+        }
127
+    },
128
+    /** Checks if the string doesn't contain another string. */
132 129
     STRING_NCONTAINS {
133
-
134
-                @Override
135
-                public boolean test(final Object arg1, final Object arg2) {
136
-                    return ((String) arg1).indexOf((String) arg2) == -1;
137
-                }
138
-
139
-                @Override
140
-                public Class<?> appliesTo() {
141
-                    return String.class;
142
-                }
143
-
144
-                @Override
145
-                public String getName() {
146
-                    return "doesn't contain";
147
-                }
148
-            },
130
+        @Override
131
+        public boolean test(final Object arg1, final Object arg2) {
132
+            return !((String) arg1).contains((String) arg2);
133
+        }
134
+
135
+        @Override
136
+        public Class<?> appliesTo() {
137
+            return String.class;
138
+        }
139
+
140
+        @Override
141
+        public String getName() {
142
+            return "doesn't contain";
143
+        }
144
+    },
149 145
     /** Checks if two boolean values are equal. */
150 146
     BOOL_IS {
151
-
152
-                @Override
153
-                public boolean test(final Object arg1, final Object arg2) {
154
-                    return ((Boolean) arg1).equals(Boolean.valueOf((String) arg2));
155
-                }
156
-
157
-                @Override
158
-                public Class<?> appliesTo() {
159
-                    return Boolean.class;
160
-                }
161
-
162
-                @Override
163
-                public String getName() {
164
-                    return "is";
165
-                }
166
-            },
147
+        @Override
148
+        public boolean test(final Object arg1, final Object arg2) {
149
+            return arg1.equals(Boolean.valueOf((String) arg2));
150
+        }
151
+
152
+        @Override
153
+        public Class<?> appliesTo() {
154
+            return Boolean.class;
155
+        }
156
+
157
+        @Override
158
+        public String getName() {
159
+            return "is";
160
+        }
161
+    },
167 162
     /** Checks if the int is equals to another int. */
168 163
     INT_EQUALS {
169
-
170
-                @Override
171
-                public boolean test(final Object arg1, final Object arg2) {
172
-                    try {
173
-                        return 0 == ((Integer) arg1).compareTo(Integer.parseInt((String) arg2));
174
-                    } catch (NumberFormatException ex) {
175
-                        return false;
176
-                    }
177
-                }
178
-
179
-                @Override
180
-                public Class<?> appliesTo() {
181
-                    return Integer.class;
182
-                }
183
-
184
-                @Override
185
-                public String getName() {
186
-                    return "equals";
187
-                }
188
-            },
164
+        @Override
165
+        public boolean test(final Object arg1, final Object arg2) {
166
+            try {
167
+                return 0 == ((Integer) arg1).compareTo(Integer.parseInt((String) arg2));
168
+            } catch (NumberFormatException ex) {
169
+                return false;
170
+            }
171
+        }
172
+
173
+        @Override
174
+        public Class<?> appliesTo() {
175
+            return Integer.class;
176
+        }
177
+
178
+        @Override
179
+        public String getName() {
180
+            return "equals";
181
+        }
182
+    },
189 183
     /** Checks if the int is larger than another int. */
190 184
     INT_GREATER {
191
-
192
-                @Override
193
-                public boolean test(final Object arg1, final Object arg2) {
194
-                    try {
195
-                        return 0 < ((Integer) arg1).compareTo(Integer.parseInt((String) arg2));
196
-                    } catch (NumberFormatException ex) {
197
-                        return false;
198
-                    }
199
-                }
200
-
201
-                @Override
202
-                public Class<?> appliesTo() {
203
-                    return Integer.class;
204
-                }
205
-
206
-                @Override
207
-                public String getName() {
208
-                    return "is greater than";
209
-                }
210
-            },
185
+        @Override
186
+        public boolean test(final Object arg1, final Object arg2) {
187
+            try {
188
+                return 0 < ((Integer) arg1).compareTo(Integer.parseInt((String) arg2));
189
+            } catch (NumberFormatException ex) {
190
+                return false;
191
+            }
192
+        }
193
+
194
+        @Override
195
+        public Class<?> appliesTo() {
196
+            return Integer.class;
197
+        }
198
+
199
+        @Override
200
+        public String getName() {
201
+            return "is greater than";
202
+        }
203
+    },
211 204
     /** Checks if the int is smaller than another int. */
212 205
     INT_LESS {
213
-
214
-                @Override
215
-                public boolean test(final Object arg1, final Object arg2) {
216
-                    try {
217
-                        return 0 > ((Integer) arg1).compareTo(Integer.parseInt((String) arg2));
218
-                    } catch (NumberFormatException ex) {
219
-                        return false;
220
-                    }
221
-                }
222
-
223
-                @Override
224
-                public Class<?> appliesTo() {
225
-                    return Integer.class;
226
-                }
227
-
228
-                @Override
229
-                public String getName() {
230
-                    return "is less than";
231
-                }
232
-            };
206
+        @Override
207
+        public boolean test(final Object arg1, final Object arg2) {
208
+            try {
209
+                return 0 > ((Integer) arg1).compareTo(Integer.parseInt((String) arg2));
210
+            } catch (NumberFormatException ex) {
211
+                return false;
212
+            }
213
+        }
214
+
215
+        @Override
216
+        public Class<?> appliesTo() {
217
+            return Integer.class;
218
+        }
219
+
220
+        @Override
221
+        public String getName() {
222
+            return "is less than";
223
+        }
224
+    }
233 225
 
234 226
 }

+ 595
- 623
src/com/dmdirc/actions/CoreActionComponent.java
File diff suppressed because it is too large
View File


+ 2
- 2
src/com/dmdirc/ui/input/AdditionalTabTargets.java View File

@@ -27,8 +27,8 @@ import java.util.Arrays;
27 27
 import java.util.List;
28 28
 
29 29
 /**
30
- * The AdditionalTabTargets class is a basic wrapper around an arraylist that adds an additional
31
- * property to determine what types of results to include.
30
+ * The AdditionalTabTargets class is a basic wrapper around an {@link ArrayList} that adds an
31
+ * additional property to determine what types of results to include.
32 32
  */
33 33
 public final class AdditionalTabTargets extends ArrayList<String> {
34 34
 

+ 8
- 8
test/com/dmdirc/actions/ActionModelTest.java View File

@@ -57,7 +57,7 @@ public class ActionModelTest {
57 57
 
58 58
     @Test
59 59
     public void testConditions() {
60
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
60
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
61 61
                 "group", "name");
62 62
 
63 63
         assertTrue("ActionModel must start with no conditions",
@@ -73,7 +73,7 @@ public class ActionModelTest {
73 73
 
74 74
     @Test
75 75
     public void testTriggers() {
76
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
76
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
77 77
                 "group", "name");
78 78
 
79 79
         assertNull("ActionModel must start with null triggers",
@@ -89,7 +89,7 @@ public class ActionModelTest {
89 89
 
90 90
     @Test
91 91
     public void testNewFormat() {
92
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
92
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
93 93
                 "group", "name");
94 94
 
95 95
         assertNull("ActionModel must start with null format",
@@ -108,7 +108,7 @@ public class ActionModelTest {
108 108
 
109 109
     @Test
110 110
     public void testResponse() {
111
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
111
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
112 112
                 "group", "name");
113 113
 
114 114
         assertNull("ActionModel must start with null response",
@@ -124,7 +124,7 @@ public class ActionModelTest {
124 124
 
125 125
     @Test
126 126
     public void testGroup() {
127
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
127
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
128 128
                 "group", "name");
129 129
 
130 130
         assertEquals("ActionModel constructor must set group",
@@ -138,7 +138,7 @@ public class ActionModelTest {
138 138
 
139 139
     @Test
140 140
     public void testName() {
141
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
141
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
142 142
                 "group", "name");
143 143
 
144 144
         assertEquals("ActionModel constructor must set name",
@@ -152,7 +152,7 @@ public class ActionModelTest {
152 152
 
153 153
     @Test
154 154
     public void testTest() {
155
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
155
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
156 156
                 "group", "name",
157 157
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
158 158
                 new String[0], Arrays.asList(new ActionCondition[]{
@@ -174,7 +174,7 @@ public class ActionModelTest {
174 174
 
175 175
     @Test
176 176
     public void testTestNoCondTree() {
177
-        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
177
+        final ActionModel model = new ActionModel(gwProvider, substitutorFactory,
178 178
                 "group", "name",
179 179
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
180 180
                 new String[0], Arrays.asList(new ActionCondition[]{

+ 6
- 6
test/com/dmdirc/actions/ActionTest.java View File

@@ -112,7 +112,7 @@ public class ActionTest {
112 112
 
113 113
     @Test
114 114
     public void testSave() {
115
-        new Action(filesystem, eventBus, gcpProvider, gwProvider, substitutorFactory,
115
+        new Action(filesystem, eventBus, gwProvider, substitutorFactory,
116 116
                 actionController, identityController, getTempDirectory(), "unit-test", "test1",
117 117
                 new ActionType[0], new String[0], new ArrayList<ActionCondition>(),
118 118
                 ConditionTree.createConjunction(0), null);
@@ -123,7 +123,7 @@ public class ActionTest {
123 123
 
124 124
     @Test
125 125
     public void testSetGroup() {
126
-        Action action = new Action(filesystem, eventBus, gcpProvider, gwProvider,
126
+        Action action = new Action(filesystem, eventBus, gwProvider,
127 127
                 substitutorFactory, actionController, identityController, getTempDirectory(),
128 128
                 "unit-test", "test1", new ActionType[0],
129 129
                 new String[0], new ArrayList<ActionCondition>(),
@@ -138,7 +138,7 @@ public class ActionTest {
138 138
 
139 139
     @Test
140 140
     public void testSetName() {
141
-        Action action = new Action(filesystem, eventBus, gcpProvider, gwProvider,
141
+        Action action = new Action(filesystem, eventBus, gwProvider,
142 142
                 substitutorFactory, actionController, identityController, getTempDirectory(),
143 143
                 "unit-test", "test1", new ActionType[0], new String[0],
144 144
                 new ArrayList<ActionCondition>(), ConditionTree.createConjunction(0), null);
@@ -152,7 +152,7 @@ public class ActionTest {
152 152
 
153 153
     @Test
154 154
     public void testDelete() {
155
-        Action action = new Action(filesystem, eventBus, gcpProvider, gwProvider,
155
+        Action action = new Action(filesystem, eventBus, gwProvider,
156 156
                 substitutorFactory, actionController, identityController, getTempDirectory(),
157 157
                 "unit-test", "test1", new ActionType[0],
158 158
                 new String[0], new ArrayList<ActionCondition>(),
@@ -165,7 +165,7 @@ public class ActionTest {
165 165
 
166 166
     @Test
167 167
     public void testRead() throws IOException, InvalidConfigFileException {
168
-        Action action = new Action(filesystem, eventBus, gcpProvider, gwProvider,
168
+        Action action = new Action(filesystem, eventBus, gwProvider,
169 169
                 substitutorFactory, actionController, identityController, getTempDirectory(),
170 170
                 "unit-test", "doesn't_exist");
171 171
         action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
@@ -184,7 +184,7 @@ public class ActionTest {
184 184
 
185 185
     @Test
186 186
     public void testMultipleGroups() throws IOException, InvalidConfigFileException {
187
-        Action action = new Action(filesystem, eventBus, gcpProvider, gwProvider,
187
+        Action action = new Action(filesystem, eventBus, gwProvider,
188 188
                 substitutorFactory, actionController, identityController, getTempDirectory(),
189 189
                 "unit-test", "doesn't_exist");
190 190
         action.config = new ConfigFile(getClass().getResourceAsStream("action_multisettings"));

Loading…
Cancel
Save