ソースを参照

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年前
コミット
05c552a0e3

+ 3
- 2
.idea/misc.xml ファイルの表示

2
 <project version="4">
2
 <project version="4">
3
   <component name="EntryPointsManager">
3
   <component name="EntryPointsManager">
4
     <entry_points version="2.0" />
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
     </list>
8
     </list>
8
   </component>
9
   </component>
9
   <component name="NullableNotNullManager">
10
   <component name="NullableNotNullManager">

+ 10
- 27
src/com/dmdirc/actions/Action.java ファイルの表示

23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
 import com.dmdirc.GlobalWindow;
25
 import com.dmdirc.GlobalWindow;
26
-import com.dmdirc.commandparser.parsers.GlobalCommandParser;
27
 import com.dmdirc.config.prefs.PreferencesSetting;
26
 import com.dmdirc.config.prefs.PreferencesSetting;
28
 import com.dmdirc.config.prefs.PreferencesType;
27
 import com.dmdirc.config.prefs.PreferencesType;
29
 import com.dmdirc.events.ActionCreatedEvent;
28
 import com.dmdirc.events.ActionCreatedEvent;
94
      *
93
      *
95
      * @param filesystem                  The file system to read/write actions to
94
      * @param filesystem                  The file system to read/write actions to
96
      * @param eventBus                    Event bus to post events to
95
      * @param eventBus                    Event bus to post events to
97
-     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
98
      * @param globalWindowProvider        Provider of global windows for triggering actions.
96
      * @param globalWindowProvider        Provider of global windows for triggering actions.
99
      * @param substitutorFactory          Factory to use to create action substitutors.
97
      * @param substitutorFactory          Factory to use to create action substitutors.
100
      * @param actionController            The controller that owns this action.
98
      * @param actionController            The controller that owns this action.
103
      * @param group                       The group the action belongs to
101
      * @param group                       The group the action belongs to
104
      * @param name                        The name of the action
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
             final Provider<GlobalWindow> globalWindowProvider,
105
             final Provider<GlobalWindow> globalWindowProvider,
111
             final ActionSubstitutorFactory substitutorFactory,
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
         this.filesystem = filesystem;
111
         this.filesystem = filesystem;
120
         this.eventBus = eventBus;
112
         this.eventBus = eventBus;
144
      *
136
      *
145
      * @param filesystem                  The file system to read/write actions to
137
      * @param filesystem                  The file system to read/write actions to
146
      * @param eventBus                    Event bus to post events to
138
      * @param eventBus                    Event bus to post events to
147
-     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
148
      * @param globalWindowProvider        Provider of global windows for triggering actions.
139
      * @param globalWindowProvider        Provider of global windows for triggering actions.
149
      * @param substitutorFactory          Factory to use to create action substitutors.
140
      * @param substitutorFactory          Factory to use to create action substitutors.
150
      * @param actionController            The controller that owns this action.
141
      * @param actionController            The controller that owns this action.
158
      * @param conditionTree               The condition tree to use
149
      * @param conditionTree               The condition tree to use
159
      * @param newFormat                   The new formatter to use
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
             final Provider<GlobalWindow> globalWindowProvider,
153
             final Provider<GlobalWindow> globalWindowProvider,
166
             final ActionSubstitutorFactory substitutorFactory,
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
             final String newFormat) {
159
             final String newFormat) {
177
-        super(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name,
160
+        super(globalWindowProvider, substitutorFactory, group, name,
178
                 triggers, response, conditions, conditionTree, newFormat);
161
                 triggers, response, conditions, conditionTree, newFormat);
179
 
162
 
180
         this.filesystem = filesystem;
163
         this.filesystem = filesystem;

+ 1
- 1
src/com/dmdirc/actions/ActionErrorType.java ファイルの表示

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

+ 3
- 16
src/com/dmdirc/actions/ActionFactory.java ファイルの表示

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

+ 2
- 2
src/com/dmdirc/actions/ActionManager.java ファイルの表示

319
     public void addAction(final Action action) {
319
     public void addAction(final Action action) {
320
         checkNotNull(action);
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
         if (action.getStatus() != ActionStatus.FAILED) {
325
         if (action.getStatus() != ActionStatus.FAILED) {
326
             for (ActionType trigger : action.getTriggers()) {
326
             for (ActionType trigger : action.getTriggers()) {

+ 2
- 11
src/com/dmdirc/actions/ActionModel.java ファイルの表示

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

+ 1
- 1
src/com/dmdirc/actions/ActionStatus.java ファイルの表示

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

+ 1
- 6
src/com/dmdirc/actions/ActionSubstitutor.java ファイルの表示

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

+ 59
- 0
src/com/dmdirc/actions/ActionSubstitutorFactory.java ファイルの表示

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 ファイルの表示

67
 
67
 
68
         @Override
68
         @Override
69
         public boolean test(final Object arg1, final Object arg2) {
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
         @Override
73
         @Override

+ 1
- 1
src/com/dmdirc/actions/ConditionTree.java ファイルの表示

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

+ 174
- 182
src/com/dmdirc/actions/CoreActionComparison.java ファイルの表示

34
 
34
 
35
     /** Compares a string to another using a regular expression. */
35
     /** Compares a string to another using a regular expression. */
36
     STRING_REGEX {
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
     STRING_EQUALS {
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
     STRING_NEQUALS {
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
     /** Checks if the string starts with another strings. */
94
     /** Checks if the string starts with another strings. */
96
     STRING_STARTSWITH {
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
     STRING_CONTAINS {
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
     STRING_NCONTAINS {
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
     /** Checks if two boolean values are equal. */
145
     /** Checks if two boolean values are equal. */
150
     BOOL_IS {
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
     /** Checks if the int is equals to another int. */
162
     /** Checks if the int is equals to another int. */
168
     INT_EQUALS {
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
     /** Checks if the int is larger than another int. */
183
     /** Checks if the int is larger than another int. */
190
     INT_GREATER {
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
     /** Checks if the int is smaller than another int. */
204
     /** Checks if the int is smaller than another int. */
212
     INT_LESS {
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
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 2
- 2
src/com/dmdirc/ui/input/AdditionalTabTargets.java ファイルの表示

27
 import java.util.List;
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
 public final class AdditionalTabTargets extends ArrayList<String> {
33
 public final class AdditionalTabTargets extends ArrayList<String> {
34
 
34
 

+ 8
- 8
test/com/dmdirc/actions/ActionModelTest.java ファイルの表示

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

+ 6
- 6
test/com/dmdirc/actions/ActionTest.java ファイルの表示

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

読み込み中…
キャンセル
保存