Browse Source

Merge pull request #40 from csmith/master

Remove some bits of PerformWrapper.
pull/63/head
Greg Holmes 9 years ago
parent
commit
0b02f39318

+ 1
- 9
src/com/dmdirc/ClientModule.java View File

@@ -25,7 +25,6 @@ package com.dmdirc;
25 25
 import com.dmdirc.actions.ActionFactory;
26 26
 import com.dmdirc.actions.ActionGroup;
27 27
 import com.dmdirc.actions.ActionManager;
28
-import com.dmdirc.actions.wrappers.PerformWrapper;
29 28
 import com.dmdirc.commandline.CommandLineOptionsModule;
30 29
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
31 30
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
@@ -125,12 +124,11 @@ public class ClientModule {
125 124
     public ActionManager getActionManager(
126 125
             final IdentityController identityController,
127 126
             final ActionFactory actionFactory,
128
-            final Provider<Set<ActionGroup>> actionWrappersProvider,
129 127
             final Provider<UpdateManager> updateManagerProvider,
130 128
             final DMDircMBassador eventBus,
131 129
             @Directory(DirectoryType.ACTIONS) final String directory) {
132 130
         final ActionManager actionManager = new ActionManager(identityController,
133
-                actionFactory, actionWrappersProvider, updateManagerProvider, eventBus, directory);
131
+                actionFactory, updateManagerProvider, eventBus, directory);
134 132
         ActionManager.setActionManager(actionManager);
135 133
         return actionManager;
136 134
     }
@@ -171,12 +169,6 @@ public class ClientModule {
171 169
         return manager;
172 170
     }
173 171
 
174
-    @Provides(type = Provides.Type.SET)
175
-    @Singleton
176
-    public ActionGroup getPerformWrapper(final PerformWrapper wrapper) {
177
-        return wrapper;
178
-    }
179
-
180 172
     @Provides
181 173
     @Singleton
182 174
     @GlobalConfig

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

@@ -54,7 +54,6 @@ import java.util.Collections;
54 54
 import java.util.HashMap;
55 55
 import java.util.List;
56 56
 import java.util.Map;
57
-import java.util.Set;
58 57
 
59 58
 import javax.inject.Provider;
60 59
 
@@ -78,8 +77,6 @@ public class ActionManager implements ActionController {
78 77
     private final IdentityController identityManager;
79 78
     /** The factory to use to create actions. */
80 79
     private final ActionFactory factory;
81
-    /** Provider for action wrappers. */
82
-    private final Provider<Set<ActionGroup>> actionWrappersProvider;
83 80
     /** Provider of an update manager. */
84 81
     private final Provider<UpdateManager> updateManagerProvider;
85 82
     /** A list of registered action types. */
@@ -109,7 +106,6 @@ public class ActionManager implements ActionController {
109 106
      *
110 107
      * @param identityManager        The IdentityManager to load configuration from.
111 108
      * @param factory                The factory to use to create new actions.
112
-     * @param actionWrappersProvider Provider of action wrappers.
113 109
      * @param updateManagerProvider  Provider of an update manager, to register components.
114 110
      * @param eventBus               The global event bus to monitor.
115 111
      * @param directory              The directory to load and save actions in.
@@ -117,13 +113,11 @@ public class ActionManager implements ActionController {
117 113
     public ActionManager(
118 114
             final IdentityController identityManager,
119 115
             final ActionFactory factory,
120
-            final Provider<Set<ActionGroup>> actionWrappersProvider,
121 116
             final Provider<UpdateManager> updateManagerProvider,
122 117
             final DMDircMBassador eventBus,
123 118
             final String directory) {
124 119
         this.identityManager = identityManager;
125 120
         this.factory = factory;
126
-        this.actionWrappersProvider = actionWrappersProvider;
127 121
         this.updateManagerProvider = updateManagerProvider;
128 122
         this.eventBus = eventBus;
129 123
         this.directory = directory;
@@ -166,10 +160,6 @@ public class ActionManager implements ActionController {
166 160
         registerComparisons(colourComparisons.getComparisons());
167 161
         registerComponents(CoreActionComponent.values());
168 162
 
169
-        for (ActionGroup wrapper : actionWrappersProvider.get()) {
170
-            addGroup(wrapper);
171
-        }
172
-
173 163
         new WhoisNumericFormatter(identityManager.getAddonSettings(), eventBus).register();
174 164
 
175 165
         eventBus.subscribe(this);

+ 8
- 69
src/com/dmdirc/actions/wrappers/PerformWrapper.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.actions.wrappers;
24 24
 
25
-import com.dmdirc.DMDircMBassador;
26 25
 import com.dmdirc.actions.Action;
27 26
 import com.dmdirc.actions.ActionComponentChain;
28 27
 import com.dmdirc.actions.ActionCondition;
@@ -33,11 +32,11 @@ import com.dmdirc.actions.ConditionTree;
33 32
 import com.dmdirc.actions.CoreActionComparison;
34 33
 import com.dmdirc.actions.CoreActionComponent;
35 34
 import com.dmdirc.actions.CoreActionType;
36
-import com.dmdirc.events.UserErrorEvent;
35
+import com.dmdirc.commandparser.auto.AutoCommand;
36
+import com.dmdirc.commandparser.auto.AutoCommandManager;
37 37
 import com.dmdirc.interfaces.Connection;
38 38
 import com.dmdirc.interfaces.actions.ActionComponent;
39 39
 import com.dmdirc.interfaces.actions.ActionType;
40
-import com.dmdirc.logger.ErrorLevel;
41 40
 
42 41
 import java.util.ArrayList;
43 42
 import java.util.List;
@@ -47,61 +46,28 @@ import javax.inject.Singleton;
47 46
 
48 47
 /**
49 48
  * An action wrapper for performs.
49
+ *
50
+ * @deprecated Use {@link AutoCommandManager}
50 51
  */
51 52
 @Singleton
53
+@Deprecated
52 54
 public class PerformWrapper extends ActionGroup {
53 55
 
54 56
     /** The component name for per-profile perform conditions. */
55 57
     private static final String PP_COMP_NAME = "SERVER_PROFILE.IDENTITY_NAME";
56 58
     /** Factory to use for actions. */
57 59
     private final ActionFactory actionFactory;
58
-    /** The event bus to post events to. */
59
-    private final DMDircMBassador eventBus;
60 60
 
61 61
     /**
62 62
      * Creates a new instance of PerformWrapper.
63 63
      *
64 64
      * @param actionFactory Factory to use to create actions.
65
-     * @param eventBus      The event bus to post events to.
66 65
      */
67 66
     @Inject
68
-    public PerformWrapper(final ActionFactory actionFactory,
69
-            final DMDircMBassador eventBus) {
67
+    public PerformWrapper(final ActionFactory actionFactory) {
70 68
         super("performs");
71 69
 
72 70
         this.actionFactory = actionFactory;
73
-        this.eventBus = eventBus;
74
-    }
75
-
76
-    @Override
77
-    public void add(final Action action) {
78
-        if (action.getTriggers().length != 1) {
79
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, null,
80
-                    "Invalid perform action: " + action.getName(),
81
-                    "Perform actions may only have one trigger"));
82
-        } else if (action.getTriggers()[0] != CoreActionType.SERVER_CONNECTED) {
83
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, null,
84
-                    "Invalid perform action: " + action.getName(),
85
-                    "Perform actions must be triggered when a server connects"));
86
-        } else if (!checkConditions(action.getConditions())) {
87
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, null,
88
-                    "Invalid perform action: " + action.getName(),
89
-                    "Perform actions must have exactly one or two conditions, "
90
-                    + "one may target the server's name or network, and one may "
91
-                    + "target the server's profile name. No other targets are "
92
-                    + "allowed."));
93
-        } else {
94
-            synchronized (this) {
95
-                super.add(action);
96
-            }
97
-        }
98
-    }
99
-
100
-    @Override
101
-    public void deleteAction(final Action action) {
102
-        synchronized (this) {
103
-            super.deleteAction(action);
104
-        }
105 71
     }
106 72
 
107 73
     /**
@@ -187,35 +153,6 @@ public class PerformWrapper extends ActionGroup {
187 153
         return true;
188 154
     }
189 155
 
190
-    /**
191
-     * Checks that the specified conditions are valid for a perform action.
192
-     *
193
-     * @param conditions The conditions to be checked
194
-     *
195
-     * @since 0.6.3m2
196
-     * @return True if the conditions are valid, false otherwise
197
-     */
198
-    protected boolean checkConditions(final Iterable<ActionCondition> conditions) {
199
-        boolean target = false;
200
-        boolean profile = false;
201
-
202
-        for (ActionCondition condition : conditions) {
203
-            if ((condition.getComponent() == CoreActionComponent.SERVER_NETWORK
204
-                    || condition.getComponent() == CoreActionComponent.SERVER_NAME)
205
-                    && !target) {
206
-                target = true;
207
-            } else if (condition.getComponent() instanceof ActionComponentChain
208
-                    && PP_COMP_NAME.equals(condition.getComponent().toString())
209
-                    && !profile) {
210
-                profile = true;
211
-            } else {
212
-                return false;
213
-            }
214
-        }
215
-
216
-        return target || profile;
217
-    }
218
-
219 156
     /**
220 157
      * Creates a new, empty, perform wrapper for the specified server or network. Note that both
221 158
      * server and network must be specified, and exactly one of them must be empty.
@@ -304,7 +241,9 @@ public class PerformWrapper extends ActionGroup {
304 241
      * Describes one specific perform.
305 242
      *
306 243
      * @since 0.6.4
244
+     * @deprecated See {@link AutoCommand}
307 245
      */
246
+    @Deprecated
308 247
     public static class PerformDescription {
309 248
 
310 249
         /** The type of the perform being described. */

+ 0
- 5
src/com/dmdirc/plugins/PluginInjectorInitialiser.java View File

@@ -27,7 +27,6 @@ import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.actions.ActionFactory;
28 28
 import com.dmdirc.actions.ActionManager;
29 29
 import com.dmdirc.actions.ActionSubstitutorFactory;
30
-import com.dmdirc.actions.wrappers.PerformWrapper;
31 30
 import com.dmdirc.commandparser.CommandManager;
32 31
 import com.dmdirc.config.prefs.PreferencesManager;
33 32
 import com.dmdirc.interfaces.ConnectionManager;
@@ -62,7 +61,6 @@ public class PluginInjectorInitialiser {
62 61
     private final WindowManager windowManager;
63 62
     private final StatusBarManager statusBarManager;
64 63
     private final PreferencesManager preferencesManager;
65
-    private final PerformWrapper performWrapper;
66 64
     private final LifecycleController lifecycleController;
67 65
     private final CorePluginExtractor corePluginExtractor;
68 66
     private final URLBuilder urlBuilder;
@@ -83,7 +81,6 @@ public class PluginInjectorInitialiser {
83 81
             final WindowManager windowManager,
84 82
             final StatusBarManager statusBarManager,
85 83
             final PreferencesManager preferencesManager,
86
-            final PerformWrapper performWrapper,
87 84
             final LifecycleController lifecycleController,
88 85
             final CorePluginExtractor corePluginExtractor,
89 86
             final URLBuilder urlBuilder,
@@ -102,7 +99,6 @@ public class PluginInjectorInitialiser {
102 99
         this.windowManager = windowManager;
103 100
         this.statusBarManager = statusBarManager;
104 101
         this.preferencesManager = preferencesManager;
105
-        this.performWrapper = performWrapper;
106 102
         this.lifecycleController = lifecycleController;
107 103
         this.corePluginExtractor = corePluginExtractor;
108 104
         this.urlBuilder = urlBuilder;
@@ -127,7 +123,6 @@ public class PluginInjectorInitialiser {
127 123
         injector.addParameter(WindowManager.class, windowManager);
128 124
         injector.addParameter(statusBarManager);
129 125
         injector.addParameter(PreferencesManager.class, preferencesManager);
130
-        injector.addParameter(PerformWrapper.class, performWrapper);
131 126
         injector.addParameter(LifecycleController.class, lifecycleController);
132 127
         injector.addParameter(corePluginExtractor);
133 128
         injector.addParameter(actionFactory);

Loading…
Cancel
Save