Selaa lähdekoodia

Always specify an origin when parsing commands.

Where commands are executed globally, pass in a GlobalWindow.

Make the GlobalWindow a singleton that persists, and is simply
added/removed from the WindowManager when the user wants to
show/hide it.

Change-Id: Iac94848487442509bdbf8ec98f67983e313ed743
Reviewed-on: http://gerrit.dmdirc.com/3451
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 10 vuotta sitten
vanhempi
commit
09cb002be2

+ 4
- 3
src/com/dmdirc/FrameContainer.java Näytä tiedosto

362
     }
362
     }
363
 
363
 
364
     /**
364
     /**
365
-     * Closes this container (and it's associated frame).
365
+     * Closes this container (and its associated frame).
366
      */
366
      */
367
     public void close() {
367
     public void close() {
368
         for (FrameCloseListener listener : listeners.get(FrameCloseListener.class)) {
368
         for (FrameCloseListener listener : listeners.get(FrameCloseListener.class)) {
369
             listener.windowClosing(this);
369
             listener.windowClosing(this);
370
+            listeners.remove(FrameCloseListener.class, listener);
370
         }
371
         }
371
     }
372
     }
372
 
373
 
530
     }
531
     }
531
 
532
 
532
     /**
533
     /**
533
-     * Adds a close listener for this frame container.
534
+     * Adds a close listener for this frame container. Close listeners will only be called once,
535
+     * even if the container is closed, re-added, and closed again.
534
      *
536
      *
535
-     * @since 0.6.5
536
      * @param listener The listener to be added
537
      * @param listener The listener to be added
537
      */
538
      */
538
     public void addCloseListener(final FrameCloseListener listener) {
539
     public void addCloseListener(final FrameCloseListener listener) {

+ 28
- 53
src/com/dmdirc/GlobalWindow.java Näytä tiedosto

24
 
24
 
25
 import com.dmdirc.ClientModule.GlobalConfig;
25
 import com.dmdirc.ClientModule.GlobalConfig;
26
 import com.dmdirc.commandparser.CommandType;
26
 import com.dmdirc.commandparser.CommandType;
27
-import com.dmdirc.commandparser.parsers.CommandParser;
28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
27
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
29
 import com.dmdirc.interfaces.Connection;
28
 import com.dmdirc.interfaces.Connection;
30
 import com.dmdirc.interfaces.FrameCloseListener;
29
 import com.dmdirc.interfaces.FrameCloseListener;
47
 /**
46
 /**
48
  * A window which can be used to execute global commands.
47
  * A window which can be used to execute global commands.
49
  */
48
  */
49
+@Singleton
50
 public class GlobalWindow extends FrameContainer {
50
 public class GlobalWindow extends FrameContainer {
51
 
51
 
52
     /**
52
     /**
59
      * @param urlBuilder          The URL builder to use when finding icons.
59
      * @param urlBuilder          The URL builder to use when finding icons.
60
      * @param eventBus            The bus to despatch events on.
60
      * @param eventBus            The bus to despatch events on.
61
      */
61
      */
62
+    @Inject
62
     public GlobalWindow(
63
     public GlobalWindow(
63
-            final AggregateConfigProvider config,
64
-            final CommandParser parser,
64
+            @GlobalConfig final AggregateConfigProvider config,
65
+            final GlobalCommandParser parser,
65
             final TabCompleterFactory tabCompleterFactory,
66
             final TabCompleterFactory tabCompleterFactory,
66
             final MessageSinkManager messageSinkManager,
67
             final MessageSinkManager messageSinkManager,
67
             final URLBuilder urlBuilder,
68
             final URLBuilder urlBuilder,
93
     @Singleton
94
     @Singleton
94
     public static class GlobalWindowManager implements ConfigChangeListener {
95
     public static class GlobalWindowManager implements ConfigChangeListener {
95
 
96
 
97
+        /** Provider to use to obtain global window instances. */
98
+        private final Provider<GlobalWindow> globalWindowProvider;
96
         /** The global configuration to read settings from. */
99
         /** The global configuration to read settings from. */
97
         private final AggregateConfigProvider globalConfig;
100
         private final AggregateConfigProvider globalConfig;
98
-        /** The factory to use to create tab completers. */
99
-        private final TabCompleterFactory tabCompleterFactory;
100
         /** The provider to use to retrieve a window manager. */
101
         /** The provider to use to retrieve a window manager. */
101
         private final Provider<WindowManager> windowManagerProvider;
102
         private final Provider<WindowManager> windowManagerProvider;
102
-        /** The provider to use to retrieve message sink managers. */
103
-        private final Provider<MessageSinkManager> messageSinkManagerProvider;
104
-        /** The provider to use to retrieve a global command parser. */
105
-        private final Provider<GlobalCommandParser> globalCommandParserProvider;
106
-        /** The URL builder to use when finding icons. */
107
-        private final URLBuilder urlBuilder;
108
-        /** The bus to despatch events on. */
109
-        private final EventBus eventBus;
110
-        /** The global window that's in use, if any. */
111
-        private GlobalWindow globalWindow;
112
 
103
 
113
         /**
104
         /**
114
          * Creates a new instance of {@link GlobalWindowManager}.
105
          * Creates a new instance of {@link GlobalWindowManager}.
115
          *
106
          *
116
-         * @param globalConfig                Configuration provider to read settings from.
117
-         * @param tabCompleterFactory         Factory to use to create tab completers.
118
-         * @param windowManagerProvider       The provider to use to retrieve a window manager.
119
-         * @param messageSinkManagerProvider  The provider to use to retrieve a sink manager.
120
-         * @param globalCommandParserProvider The provider to use to retrieve a global command
121
-         *                                    parser.
122
-         * @param urlBuilder                  The URL builder to use when finding icons.
123
-         * @param eventBus                    The bus to despatch events on.
107
+         * @param globalWindowProvider  The provider to use to obtain global windows.
108
+         * @param globalConfig          Configuration provider to read settings from.
109
+         * @param windowManagerProvider The provider to use to retrieve a window manager.
124
          */
110
          */
125
         @Inject
111
         @Inject
126
         public GlobalWindowManager(
112
         public GlobalWindowManager(
113
+                final Provider<GlobalWindow> globalWindowProvider,
127
                 @GlobalConfig final AggregateConfigProvider globalConfig,
114
                 @GlobalConfig final AggregateConfigProvider globalConfig,
128
-                final TabCompleterFactory tabCompleterFactory,
129
-                final Provider<WindowManager> windowManagerProvider,
130
-                final Provider<MessageSinkManager> messageSinkManagerProvider,
131
-                final Provider<GlobalCommandParser> globalCommandParserProvider,
132
-                final URLBuilder urlBuilder,
133
-                final EventBus eventBus) {
115
+                final Provider<WindowManager> windowManagerProvider) {
116
+            this.globalWindowProvider = globalWindowProvider;
134
             this.globalConfig = globalConfig;
117
             this.globalConfig = globalConfig;
135
-            this.tabCompleterFactory = tabCompleterFactory;
136
             this.windowManagerProvider = windowManagerProvider;
118
             this.windowManagerProvider = windowManagerProvider;
137
-            this.messageSinkManagerProvider = messageSinkManagerProvider;
138
-            this.globalCommandParserProvider = globalCommandParserProvider;
139
-            this.urlBuilder = urlBuilder;
140
-            this.eventBus = eventBus;
141
         }
119
         }
142
 
120
 
143
         @Override
121
         @Override
158
          * setting.
136
          * setting.
159
          */
137
          */
160
         protected void updateWindowState() {
138
         protected void updateWindowState() {
161
-            synchronized (GlobalWindow.class) {
162
-                if (globalConfig.getOptionBool("general", "showglobalwindow")) {
163
-                    if (globalWindow == null) {
164
-                        globalWindow = new GlobalWindow(globalConfig,
165
-                                globalCommandParserProvider.get(),
166
-                                tabCompleterFactory,
167
-                                messageSinkManagerProvider.get(),
168
-                                urlBuilder,
169
-                                eventBus);
170
-                        addCloseListener(globalWindow);
171
-                        windowManagerProvider.get().addWindow(globalWindow);
172
-                    }
173
-                } else {
174
-                    if (globalWindow != null) {
175
-                        globalWindow.close();
176
-                    }
139
+            final WindowManager windowManager = windowManagerProvider.get();
140
+            final GlobalWindow globalWindow = globalWindowProvider.get();
141
+            final boolean globalWindowExists = windowManager.getRootWindows()
142
+                    .contains(globalWindow);
143
+
144
+            if (globalConfig.getOptionBool("general", "showglobalwindow")) {
145
+                if (!globalWindowExists) {
146
+                    addCloseListener(globalWindow);
147
+                    windowManager.addWindow(globalWindow);
148
+                }
149
+            } else {
150
+                if (globalWindowExists) {
151
+                    globalWindow.close();
177
                 }
152
                 }
178
             }
153
             }
179
         }
154
         }
181
         /**
156
         /**
182
          * Adds a {@link FrameCloseListener} to the specified window to update the global window
157
          * Adds a {@link FrameCloseListener} to the specified window to update the global window
183
          * state if the user closes it from the UI.
158
          * state if the user closes it from the UI.
159
+         *
160
+         * @param window The window to add a listener to.
184
          */
161
          */
185
         private void addCloseListener(final GlobalWindow window) {
162
         private void addCloseListener(final GlobalWindow window) {
186
             window.addCloseListener(new FrameCloseListener() {
163
             window.addCloseListener(new FrameCloseListener() {
187
                 @Override
164
                 @Override
188
                 public void windowClosing(final FrameContainer container) {
165
                 public void windowClosing(final FrameContainer container) {
189
-                    synchronized (GlobalWindow.class) {
190
-                        globalWindow = null;
191
-                    }
166
+                    container.removeCloseListener(this);
192
                 }
167
                 }
193
             });
168
             });
194
         }
169
         }

+ 8
- 3
src/com/dmdirc/actions/Action.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
+import com.dmdirc.GlobalWindow;
25
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
26
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
26
 import com.dmdirc.config.prefs.PreferencesSetting;
27
 import com.dmdirc.config.prefs.PreferencesSetting;
27
 import com.dmdirc.config.prefs.PreferencesType;
28
 import com.dmdirc.config.prefs.PreferencesType;
82
      * a valid action already saved to disk.
83
      * a valid action already saved to disk.
83
      *
84
      *
84
      * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
85
      * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
86
+     * @param globalWindowProvider        Provider of global windows for triggering actions.
85
      * @param substitutorFactory          Factory to use to create action substitutors.
87
      * @param substitutorFactory          Factory to use to create action substitutors.
86
      * @param actionController            The controller that owns this action.
88
      * @param actionController            The controller that owns this action.
87
      * @param identityController          The controller to use to retrieve and update settings.
89
      * @param identityController          The controller to use to retrieve and update settings.
91
      */
93
      */
92
     public Action(
94
     public Action(
93
             final Provider<GlobalCommandParser> globalCommandParserProvider,
95
             final Provider<GlobalCommandParser> globalCommandParserProvider,
96
+            final Provider<GlobalWindow> globalWindowProvider,
94
             final ActionSubstitutorFactory substitutorFactory,
97
             final ActionSubstitutorFactory substitutorFactory,
95
             final ActionController actionController,
98
             final ActionController actionController,
96
             final IdentityController identityController,
99
             final IdentityController identityController,
97
             final String actionsDirectory,
100
             final String actionsDirectory,
98
             final String group,
101
             final String group,
99
             final String name) {
102
             final String name) {
100
-        super(globalCommandParserProvider, substitutorFactory, group, name);
103
+        super(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name);
101
 
104
 
102
         this.actionController = actionController;
105
         this.actionController = actionController;
103
         this.identityController = identityController;
106
         this.identityController = identityController;
124
      * Creates a new instance of Action with the specified properties and saves it to disk.
127
      * Creates a new instance of Action with the specified properties and saves it to disk.
125
      *
128
      *
126
      * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
129
      * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
130
+     * @param globalWindowProvider        Provider of global windows for triggering actions.
127
      * @param substitutorFactory          Factory to use to create action substitutors.
131
      * @param substitutorFactory          Factory to use to create action substitutors.
128
      * @param actionController            The controller that owns this action.
132
      * @param actionController            The controller that owns this action.
129
      * @param identityController          The controller to use to retrieve and update settings.
133
      * @param identityController          The controller to use to retrieve and update settings.
138
      */
142
      */
139
     public Action(
143
     public Action(
140
             final Provider<GlobalCommandParser> globalCommandParserProvider,
144
             final Provider<GlobalCommandParser> globalCommandParserProvider,
145
+            final Provider<GlobalWindow> globalWindowProvider,
141
             final ActionSubstitutorFactory substitutorFactory,
146
             final ActionSubstitutorFactory substitutorFactory,
142
             final ActionController actionController,
147
             final ActionController actionController,
143
             final IdentityController identityController,
148
             final IdentityController identityController,
149
             final List<ActionCondition> conditions,
154
             final List<ActionCondition> conditions,
150
             final ConditionTree conditionTree,
155
             final ConditionTree conditionTree,
151
             final String newFormat) {
156
             final String newFormat) {
152
-        super(globalCommandParserProvider, substitutorFactory, group, name, triggers, response,
153
-                conditions, conditionTree, newFormat);
157
+        super(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name,
158
+                triggers, response, conditions, conditionTree, newFormat);
154
 
159
 
155
         this.actionController = actionController;
160
         this.actionController = actionController;
156
         this.identityController = identityController;
161
         this.identityController = identityController;

+ 29
- 5
src/com/dmdirc/actions/ActionFactory.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
+import com.dmdirc.GlobalWindow;
25
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
26
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
26
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
27
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
27
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
47
     private final Provider<ActionController> actionController;
48
     private final Provider<ActionController> actionController;
48
     /** The controller to use to retrieve and update settings. */
49
     /** The controller to use to retrieve and update settings. */
49
     private final Provider<IdentityController> identityController;
50
     private final Provider<IdentityController> identityController;
51
+    /** The global window to use for actions without windows. */
52
+    private final Provider<GlobalWindow> globalWindowProvider;
50
     /** The factory to use to create substitutors. */
53
     /** The factory to use to create substitutors. */
51
     private final ActionSubstitutorFactory substitutorFactory;
54
     private final ActionSubstitutorFactory substitutorFactory;
52
     /** The base directory to store actions in. */
55
     /** The base directory to store actions in. */
59
      * @param identityController          The controller to use to retrieve and update settings.
62
      * @param identityController          The controller to use to retrieve and update settings.
60
      * @param globalCommandParserProvider The global command parser to use for actions without
63
      * @param globalCommandParserProvider The global command parser to use for actions without
61
      *                                    windows.
64
      *                                    windows.
65
+     * @param globalWindowProvider        The global window to use for actions without windows.
62
      * @param substitutorFactory          The factory to use to create substitutors.
66
      * @param substitutorFactory          The factory to use to create substitutors.
63
      * @param actionsDirectory            The base directory to store actions in.
67
      * @param actionsDirectory            The base directory to store actions in.
64
      */
68
      */
67
             final Provider<ActionController> actionController,
71
             final Provider<ActionController> actionController,
68
             final Provider<IdentityController> identityController,
72
             final Provider<IdentityController> identityController,
69
             final Provider<GlobalCommandParser> globalCommandParserProvider,
73
             final Provider<GlobalCommandParser> globalCommandParserProvider,
74
+            final Provider<GlobalWindow> globalWindowProvider,
70
             final ActionSubstitutorFactory substitutorFactory,
75
             final ActionSubstitutorFactory substitutorFactory,
71
             @Directory(DirectoryType.ACTIONS) final String actionsDirectory) {
76
             @Directory(DirectoryType.ACTIONS) final String actionsDirectory) {
72
         this.actionController = actionController;
77
         this.actionController = actionController;
73
         this.identityController = identityController;
78
         this.identityController = identityController;
74
         this.globalCommandParserProvider = globalCommandParserProvider;
79
         this.globalCommandParserProvider = globalCommandParserProvider;
80
+        this.globalWindowProvider = globalWindowProvider;
75
         this.substitutorFactory = substitutorFactory;
81
         this.substitutorFactory = substitutorFactory;
76
         this.actionsDirectory = actionsDirectory;
82
         this.actionsDirectory = actionsDirectory;
77
     }
83
     }
86
      * @return A relevant action.
92
      * @return A relevant action.
87
      */
93
      */
88
     public Action getAction(final String group, final String name) {
94
     public Action getAction(final String group, final String name) {
89
-        return new Action(globalCommandParserProvider, substitutorFactory, actionController.get(),
90
-                identityController.get(), actionsDirectory, group, name);
95
+        return new Action(
96
+                globalCommandParserProvider,
97
+                globalWindowProvider,
98
+                substitutorFactory,
99
+                actionController.get(),
100
+                identityController.get(),
101
+                actionsDirectory,
102
+                group,
103
+                name);
91
     }
104
     }
92
 
105
 
93
     /**
106
     /**
107
             final ActionType[] triggers, final String[] response,
120
             final ActionType[] triggers, final String[] response,
108
             final List<ActionCondition> conditions,
121
             final List<ActionCondition> conditions,
109
             final ConditionTree conditionTree, final String newFormat) {
122
             final ConditionTree conditionTree, final String newFormat) {
110
-        return new Action(globalCommandParserProvider, substitutorFactory, actionController.get(),
111
-                identityController.get(), actionsDirectory, group,
112
-                name, triggers, response, conditions, conditionTree, newFormat);
123
+        return new Action(
124
+                globalCommandParserProvider,
125
+                globalWindowProvider,
126
+                substitutorFactory,
127
+                actionController.get(),
128
+                identityController.get(),
129
+                actionsDirectory,
130
+                group,
131
+                name,
132
+                triggers,
133
+                response,
134
+                conditions,
135
+                conditionTree,
136
+                newFormat);
113
     }
137
     }
114
 
138
 
115
 }
139
 }

+ 15
- 12
src/com/dmdirc/actions/ActionModel.java Näytä tiedosto

23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
26
+import com.dmdirc.GlobalWindow;
26
 import com.dmdirc.Precondition;
27
 import com.dmdirc.Precondition;
27
 import com.dmdirc.ServerManager;
28
 import com.dmdirc.ServerManager;
28
 import com.dmdirc.commandparser.parsers.CommandParser;
29
 import com.dmdirc.commandparser.parsers.CommandParser;
41
  */
42
  */
42
 public class ActionModel {
43
 public class ActionModel {
43
 
44
 
45
+    // TODO: Sort out the mess of protected fields here.
46
+
44
     /** Provider of global command parsers, for use when triggering window-less actions. */
47
     /** Provider of global command parsers, for use when triggering window-less actions. */
45
     private final Provider<GlobalCommandParser> globalCommandParserProvider;
48
     private final Provider<GlobalCommandParser> globalCommandParserProvider;
49
+    /** Provider of global windows for global actions. */
50
+    private final Provider<GlobalWindow> globalWindowProvider;
46
     /** Factory to use to creator substitutors. */
51
     /** Factory to use to creator substitutors. */
47
     private final ActionSubstitutorFactory substitutorFactory;
52
     private final ActionSubstitutorFactory substitutorFactory;
48
     /** The group this action belongs to. */
53
     /** The group this action belongs to. */
75
     /**
80
     /**
76
      * Creates a new instance of ActionModel with the specified properties.
81
      * Creates a new instance of ActionModel with the specified properties.
77
      *
82
      *
78
-     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
83
+     * @param globalCommandParserProvider Provider of global command parsers for global actions.
84
+     * @param globalWindowProvider        Provider of global windows for global actions.
79
      * @param substitutorFactory          Factory to use to create action substitutors.
85
      * @param substitutorFactory          Factory to use to create action substitutors.
80
      * @param group                       The group the action belongs to
86
      * @param group                       The group the action belongs to
81
      * @param name                        The name of the action
87
      * @param name                        The name of the action
82
      */
88
      */
83
     public ActionModel(
89
     public ActionModel(
84
             final Provider<GlobalCommandParser> globalCommandParserProvider,
90
             final Provider<GlobalCommandParser> globalCommandParserProvider,
91
+            final Provider<GlobalWindow> globalWindowProvider,
85
             final ActionSubstitutorFactory substitutorFactory,
92
             final ActionSubstitutorFactory substitutorFactory,
86
             final String group,
93
             final String group,
87
             final String name) {
94
             final String name) {
88
         this.globalCommandParserProvider = globalCommandParserProvider;
95
         this.globalCommandParserProvider = globalCommandParserProvider;
96
+        this.globalWindowProvider = globalWindowProvider;
89
         this.substitutorFactory = substitutorFactory;
97
         this.substitutorFactory = substitutorFactory;
90
         this.group = group;
98
         this.group = group;
91
         this.name = name;
99
         this.name = name;
95
      * Creates a new instance of ActionModel with the specified properties.
103
      * Creates a new instance of ActionModel with the specified properties.
96
      *
104
      *
97
      * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
105
      * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
106
+     * @param globalWindowProvider        Provider of global windows for global actions.
98
      * @param substitutorFactory          Factory to use to create action substitutors.
107
      * @param substitutorFactory          Factory to use to create action substitutors.
99
      * @param group                       The group the action belongs to
108
      * @param group                       The group the action belongs to
100
      * @param name                        The name of the action
109
      * @param name                        The name of the action
106
      */
115
      */
107
     public ActionModel(
116
     public ActionModel(
108
             final Provider<GlobalCommandParser> globalCommandParserProvider,
117
             final Provider<GlobalCommandParser> globalCommandParserProvider,
118
+            final Provider<GlobalWindow> globalWindowProvider,
109
             final ActionSubstitutorFactory substitutorFactory,
119
             final ActionSubstitutorFactory substitutorFactory,
110
             final String group, final String name,
120
             final String group, final String name,
111
             final ActionType[] triggers, final String[] response,
121
             final ActionType[] triggers, final String[] response,
112
             final List<ActionCondition> conditions,
122
             final List<ActionCondition> conditions,
113
             final ConditionTree conditionTree, final String newFormat) {
123
             final ConditionTree conditionTree, final String newFormat) {
114
-        this(globalCommandParserProvider, substitutorFactory, group, name);
124
+        this(globalCommandParserProvider, globalWindowProvider, substitutorFactory, group, name);
115
         this.triggers = triggers.clone();
125
         this.triggers = triggers.clone();
116
         this.response = response.clone();
126
         this.response = response.clone();
117
         this.conditions = conditions;
127
         this.conditions = conditions;
149
             return false;
159
             return false;
150
         }
160
         }
151
 
161
 
152
-        FrameContainer container = null;
153
-        CommandParser cp;
154
-
162
+        final FrameContainer container;
155
         if (arguments.length > 0 && arguments[0] instanceof FrameContainer
163
         if (arguments.length > 0 && arguments[0] instanceof FrameContainer
156
                 && ((FrameContainer) arguments[0]).isWritable()) {
164
                 && ((FrameContainer) arguments[0]).isWritable()) {
157
             container = (FrameContainer) arguments[0];
165
             container = (FrameContainer) arguments[0];
158
-        } else if (serverManager.numServers() > 0) {
159
-            container = serverManager.getServers().get(0);
160
-        }
161
-
162
-        if (container == null) {
163
-            cp = globalCommandParserProvider.get();
164
         } else {
166
         } else {
165
-            cp = container.getCommandParser();
167
+            container = globalWindowProvider.get();
166
         }
168
         }
167
 
169
 
170
+        final CommandParser cp = container.getCommandParser();
168
         for (String command : response) {
171
         for (String command : response) {
169
             cp.parseCommand(container, sub.doSubstitution(command, arguments));
172
             cp.parseCommand(container, sub.doSubstitution(command, arguments));
170
         }
173
         }

+ 8
- 2
src/com/dmdirc/commandparser/commands/global/Ifplugin.java Näytä tiedosto

23
 package com.dmdirc.commandparser.commands.global;
23
 package com.dmdirc.commandparser.commands.global;
24
 
24
 
25
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
26
+import com.dmdirc.GlobalWindow;
26
 import com.dmdirc.commandparser.BaseCommandInfo;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
27
 import com.dmdirc.commandparser.CommandArguments;
28
 import com.dmdirc.commandparser.CommandArguments;
28
 import com.dmdirc.commandparser.CommandInfo;
29
 import com.dmdirc.commandparser.CommandInfo;
55
     private final PluginManager pluginManager;
56
     private final PluginManager pluginManager;
56
     /** Provider of global command parsers. */
57
     /** Provider of global command parsers. */
57
     private final Provider<GlobalCommandParser> globalCommandParserProvider;
58
     private final Provider<GlobalCommandParser> globalCommandParserProvider;
59
+    /** Proivder of global windows. */
60
+    private final Provider<GlobalWindow> globalWindowProvider;
58
 
61
 
59
     /**
62
     /**
60
      * Creates a new instance of the {@link Ifplugin} command.
63
      * Creates a new instance of the {@link Ifplugin} command.
62
      * @param controller                  The controller to use for command information.
65
      * @param controller                  The controller to use for command information.
63
      * @param pluginManager               The plugin manager to use to query plugins.
66
      * @param pluginManager               The plugin manager to use to query plugins.
64
      * @param globalCommandParserProvider Provider to use to retrieve a global command parser.
67
      * @param globalCommandParserProvider Provider to use to retrieve a global command parser.
68
+     * @param globalWindowProvider        Provider to use to retrieve a global window.
65
      */
69
      */
66
     @Inject
70
     @Inject
67
     public Ifplugin(
71
     public Ifplugin(
68
             final CommandController controller,
72
             final CommandController controller,
69
             final PluginManager pluginManager,
73
             final PluginManager pluginManager,
70
-            final Provider<GlobalCommandParser> globalCommandParserProvider) {
74
+            final Provider<GlobalCommandParser> globalCommandParserProvider,
75
+            final Provider<GlobalWindow> globalWindowProvider) {
71
         super(controller);
76
         super(controller);
72
         this.pluginManager = pluginManager;
77
         this.pluginManager = pluginManager;
73
         this.globalCommandParserProvider = globalCommandParserProvider;
78
         this.globalCommandParserProvider = globalCommandParserProvider;
79
+        this.globalWindowProvider = globalWindowProvider;
74
     }
80
     }
75
 
81
 
76
     @Override
82
     @Override
96
         if (result != negative) {
102
         if (result != negative) {
97
             if (origin == null || !origin.isWritable()) {
103
             if (origin == null || !origin.isWritable()) {
98
                 globalCommandParserProvider.get()
104
                 globalCommandParserProvider.get()
99
-                        .parseCommand(null, args.getArgumentsAsString(1));
105
+                        .parseCommand(globalWindowProvider.get(), args.getArgumentsAsString(1));
100
             } else {
106
             } else {
101
                 origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(1));
107
                 origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(1));
102
             }
108
             }

+ 11
- 6
src/com/dmdirc/commandparser/parsers/CommandParser.java Näytä tiedosto

44
 import java.util.HashMap;
44
 import java.util.HashMap;
45
 import java.util.Map;
45
 import java.util.Map;
46
 
46
 
47
+import javax.annotation.Nonnull;
48
+
49
+import static com.google.common.base.Preconditions.checkNotNull;
50
+
47
 /**
51
 /**
48
  * Represents a generic command parser. A command parser takes a line of input from the user,
52
  * Represents a generic command parser. A command parser takes a line of input from the user,
49
  * determines if it is an attempt at executing a command (based on the character at the start of the
53
  * determines if it is an attempt at executing a command (based on the character at the start of the
135
      *
139
      *
136
      * @since 0.6.4
140
      * @since 0.6.4
137
      */
141
      */
138
-    public final void parseCommand(final FrameContainer origin,
139
-            final String line, final boolean parseChannel) {
140
-        final CommandArguments args = new CommandArguments(commandManager, line);
142
+    public final void parseCommand(@Nonnull final FrameContainer origin, final String line,
143
+            final boolean parseChannel) {
144
+        checkNotNull(origin);
141
 
145
 
146
+        final CommandArguments args = new CommandArguments(commandManager, line);
142
         if (args.isCommand()) {
147
         if (args.isCommand()) {
143
             if (handleChannelCommand(origin, args, parseChannel)) {
148
             if (handleChannelCommand(origin, args, parseChannel)) {
144
                 return;
149
                 return;
170
      *
175
      *
171
      * @return True iff the command was handled, false otherwise
176
      * @return True iff the command was handled, false otherwise
172
      */
177
      */
173
-    protected boolean handleChannelCommand(final FrameContainer origin,
178
+    protected boolean handleChannelCommand(@Nonnull final FrameContainer origin,
174
             final CommandArguments args, final boolean parseChannel) {
179
             final CommandArguments args, final boolean parseChannel) {
175
         final boolean silent = args.isSilent();
180
         final boolean silent = args.isSilent();
176
         final String command = args.getCommandName();
181
         final String command = args.getCommandName();
177
         final String[] cargs = args.getArguments();
182
         final String[] cargs = args.getArguments();
178
 
183
 
179
-        if (cargs.length == 0 || !parseChannel || origin == null
184
+        if (cargs.length == 0 || !parseChannel
180
                 || origin.getConnection() == null
185
                 || origin.getConnection() == null
181
                 || !commandManager.isChannelCommand(command)) {
186
                 || !commandManager.isChannelCommand(command)) {
182
             return false;
187
             return false;
265
      *
270
      *
266
      * @since 0.6.4
271
      * @since 0.6.4
267
      */
272
      */
268
-    public void parseCommand(final FrameContainer origin, final String line) {
273
+    public void parseCommand(@Nonnull final FrameContainer origin, final String line) {
269
         parseCommand(origin, line, true);
274
         parseCommand(origin, line, true);
270
     }
275
     }
271
 
276
 

+ 22
- 9
test/com/dmdirc/actions/ActionModelTest.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
+import com.dmdirc.GlobalWindow;
25
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
26
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
26
 import com.dmdirc.interfaces.ActionController;
27
 import com.dmdirc.interfaces.ActionController;
27
 import com.dmdirc.interfaces.CommandController;
28
 import com.dmdirc.interfaces.CommandController;
39
 import org.mockito.Mock;
40
 import org.mockito.Mock;
40
 import org.mockito.runners.MockitoJUnitRunner;
41
 import org.mockito.runners.MockitoJUnitRunner;
41
 
42
 
42
-import static org.junit.Assert.*;
43
+import static org.junit.Assert.assertEquals;
44
+import static org.junit.Assert.assertFalse;
45
+import static org.junit.Assert.assertNull;
46
+import static org.junit.Assert.assertTrue;
43
 
47
 
44
 @RunWith(MockitoJUnitRunner.class)
48
 @RunWith(MockitoJUnitRunner.class)
45
 public class ActionModelTest {
49
 public class ActionModelTest {
46
 
50
 
47
     @Mock private Provider<GlobalCommandParser> gcpProvider;
51
     @Mock private Provider<GlobalCommandParser> gcpProvider;
52
+    @Mock private Provider<GlobalWindow> gwProvider;
48
     @Mock private ActionSubstitutorFactory substitutorFactory;
53
     @Mock private ActionSubstitutorFactory substitutorFactory;
49
     @Mock private ActionController actionController;
54
     @Mock private ActionController actionController;
50
     @Mock private CommandController commandController;
55
     @Mock private CommandController commandController;
52
 
57
 
53
     @Test
58
     @Test
54
     public void testConditions() {
59
     public void testConditions() {
55
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name");
60
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
61
+                "group", "name");
56
 
62
 
57
         assertTrue("ActionModel must start with no conditions",
63
         assertTrue("ActionModel must start with no conditions",
58
                 model.getConditions().isEmpty());
64
                 model.getConditions().isEmpty());
67
 
73
 
68
     @Test
74
     @Test
69
     public void testTriggers() {
75
     public void testTriggers() {
70
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name");
76
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
77
+                "group", "name");
71
 
78
 
72
         assertNull("ActionModel must start with null triggers",
79
         assertNull("ActionModel must start with null triggers",
73
                 model.getTriggers());
80
                 model.getTriggers());
82
 
89
 
83
     @Test
90
     @Test
84
     public void testNewFormat() {
91
     public void testNewFormat() {
85
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name");
92
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
93
+                "group", "name");
86
 
94
 
87
         assertNull("ActionModel must start with null format",
95
         assertNull("ActionModel must start with null format",
88
                 model.getNewFormat());
96
                 model.getNewFormat());
100
 
108
 
101
     @Test
109
     @Test
102
     public void testResponse() {
110
     public void testResponse() {
103
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name");
111
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
112
+                "group", "name");
104
 
113
 
105
         assertNull("ActionModel must start with null response",
114
         assertNull("ActionModel must start with null response",
106
                 model.getResponse());
115
                 model.getResponse());
115
 
124
 
116
     @Test
125
     @Test
117
     public void testGroup() {
126
     public void testGroup() {
118
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name");
127
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
128
+                "group", "name");
119
 
129
 
120
         assertEquals("ActionModel constructor must set group",
130
         assertEquals("ActionModel constructor must set group",
121
                 "group", model.getGroup());
131
                 "group", model.getGroup());
128
 
138
 
129
     @Test
139
     @Test
130
     public void testName() {
140
     public void testName() {
131
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name");
141
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
142
+                "group", "name");
132
 
143
 
133
         assertEquals("ActionModel constructor must set name",
144
         assertEquals("ActionModel constructor must set name",
134
                 "name", model.getName());
145
                 "name", model.getName());
141
 
152
 
142
     @Test
153
     @Test
143
     public void testTest() {
154
     public void testTest() {
144
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name",
155
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
156
+                "group", "name",
145
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
157
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
146
                 new String[0], Arrays.asList(new ActionCondition[]{
158
                 new String[0], Arrays.asList(new ActionCondition[]{
147
                     new ActionCondition(2, CoreActionComponent.STRING_STRING,
159
                     new ActionCondition(2, CoreActionComponent.STRING_STRING,
162
 
174
 
163
     @Test
175
     @Test
164
     public void testTestNoCondTree() {
176
     public void testTestNoCondTree() {
165
-        final ActionModel model = new ActionModel(gcpProvider, substitutorFactory, "group", "name",
177
+        final ActionModel model = new ActionModel(gcpProvider, gwProvider, substitutorFactory,
178
+                "group", "name",
166
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
179
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
167
                 new String[0], Arrays.asList(new ActionCondition[]{
180
                 new String[0], Arrays.asList(new ActionCondition[]{
168
                     new ActionCondition(2, CoreActionComponent.STRING_STRING,
181
                     new ActionCondition(2, CoreActionComponent.STRING_STRING,

+ 9
- 7
test/com/dmdirc/actions/ActionTest.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
+import com.dmdirc.GlobalWindow;
25
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
26
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
26
 import com.dmdirc.config.prefs.PreferencesSetting;
27
 import com.dmdirc.config.prefs.PreferencesSetting;
27
 import com.dmdirc.config.prefs.PreferencesType;
28
 import com.dmdirc.config.prefs.PreferencesType;
68
     @Rule public final TemporaryFolder folder = new TemporaryFolder();
69
     @Rule public final TemporaryFolder folder = new TemporaryFolder();
69
 
70
 
70
     @Mock private Provider<GlobalCommandParser> gcpProvider;
71
     @Mock private Provider<GlobalCommandParser> gcpProvider;
72
+    @Mock private Provider<GlobalWindow> gwProvider;
71
     @Mock private ActionSubstitutorFactory substitutorFactory;
73
     @Mock private ActionSubstitutorFactory substitutorFactory;
72
     @Mock private ActionController actionController;
74
     @Mock private ActionController actionController;
73
     @Mock private ActionGroup actionGroup;
75
     @Mock private ActionGroup actionGroup;
103
 
105
 
104
     @Test
106
     @Test
105
     public void testSave() {
107
     public void testSave() {
106
-        new Action(gcpProvider, substitutorFactory, actionController, identityController,
107
-                getTempDirectory(), "unit-test", "test1", new ActionType[0],
108
+        new Action(gcpProvider, gwProvider, substitutorFactory, actionController,
109
+                identityController, getTempDirectory(), "unit-test", "test1", new ActionType[0],
108
                 new String[0], new ArrayList<ActionCondition>(),
110
                 new String[0], new ArrayList<ActionCondition>(),
109
                 ConditionTree.createConjunction(0), null);
111
                 ConditionTree.createConjunction(0), null);
110
         assertTrue("Action constructor must create new file",
112
         assertTrue("Action constructor must create new file",
114
 
116
 
115
     @Test
117
     @Test
116
     public void testSetGroup() {
118
     public void testSetGroup() {
117
-        Action action = new Action(gcpProvider, substitutorFactory, actionController,
119
+        Action action = new Action(gcpProvider, gwProvider, substitutorFactory, actionController,
118
                 identityController, getTempDirectory(),
120
                 identityController, getTempDirectory(),
119
                 "unit-test", "test1", new ActionType[0],
121
                 "unit-test", "test1", new ActionType[0],
120
                 new String[0], new ArrayList<ActionCondition>(),
122
                 new String[0], new ArrayList<ActionCondition>(),
131
 
133
 
132
     @Test
134
     @Test
133
     public void testSetName() {
135
     public void testSetName() {
134
-        Action action = new Action(gcpProvider, substitutorFactory, actionController,
136
+        Action action = new Action(gcpProvider, gwProvider, substitutorFactory, actionController,
135
                 identityController, getTempDirectory(),
137
                 identityController, getTempDirectory(),
136
                 "unit-test", "test1", new ActionType[0],
138
                 "unit-test", "test1", new ActionType[0],
137
                 new String[0], new ArrayList<ActionCondition>(),
139
                 new String[0], new ArrayList<ActionCondition>(),
148
 
150
 
149
     @Test
151
     @Test
150
     public void testDelete() {
152
     public void testDelete() {
151
-        Action action = new Action(gcpProvider, substitutorFactory, actionController,
153
+        Action action = new Action(gcpProvider, gwProvider, substitutorFactory, actionController,
152
                 identityController, getTempDirectory(),
154
                 identityController, getTempDirectory(),
153
                 "unit-test", "test1", new ActionType[0],
155
                 "unit-test", "test1", new ActionType[0],
154
                 new String[0], new ArrayList<ActionCondition>(),
156
                 new String[0], new ArrayList<ActionCondition>(),
162
 
164
 
163
     @Test
165
     @Test
164
     public void testRead() throws IOException, InvalidConfigFileException {
166
     public void testRead() throws IOException, InvalidConfigFileException {
165
-        Action action = new Action(gcpProvider, substitutorFactory, actionController,
167
+        Action action = new Action(gcpProvider, gwProvider, substitutorFactory, actionController,
166
                 identityController, getTempDirectory(),
168
                 identityController, getTempDirectory(),
167
                 "unit-test", "doesn't_exist");
169
                 "unit-test", "doesn't_exist");
168
         action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
170
         action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
181
 
183
 
182
     @Test
184
     @Test
183
     public void testMultipleGroups() throws IOException, InvalidConfigFileException {
185
     public void testMultipleGroups() throws IOException, InvalidConfigFileException {
184
-        Action action = new Action(gcpProvider, substitutorFactory, actionController,
186
+        Action action = new Action(gcpProvider, gwProvider, substitutorFactory, actionController,
185
                 identityController, getTempDirectory(),
187
                 identityController, getTempDirectory(),
186
                 "unit-test", "doesn't_exist");
188
                 "unit-test", "doesn't_exist");
187
         action.config = new ConfigFile(getClass().getResourceAsStream("action_multisettings"));
189
         action.config = new ConfigFile(getClass().getResourceAsStream("action_multisettings"));

+ 8
- 2
test/com/dmdirc/commandparser/commands/global/IfpluginTest.java Näytä tiedosto

22
 package com.dmdirc.commandparser.commands.global;
22
 package com.dmdirc.commandparser.commands.global;
23
 
23
 
24
 import com.dmdirc.FrameContainer;
24
 import com.dmdirc.FrameContainer;
25
+import com.dmdirc.GlobalWindow;
25
 import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.commands.context.CommandContext;
27
 import com.dmdirc.commandparser.commands.context.CommandContext;
27
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
29
 import com.dmdirc.plugins.PluginManager;
30
 import com.dmdirc.plugins.PluginManager;
30
 
31
 
31
 import javax.inject.Provider;
32
 import javax.inject.Provider;
33
+
32
 import org.junit.Before;
34
 import org.junit.Before;
33
 import org.junit.Test;
35
 import org.junit.Test;
34
 import org.junit.runner.RunWith;
36
 import org.junit.runner.RunWith;
35
 import org.mockito.Mock;
37
 import org.mockito.Mock;
36
 import org.mockito.runners.MockitoJUnitRunner;
38
 import org.mockito.runners.MockitoJUnitRunner;
37
 
39
 
38
-import static org.mockito.Mockito.*;
40
+import static org.mockito.Matchers.anyChar;
41
+import static org.mockito.Matchers.anyString;
42
+import static org.mockito.Matchers.eq;
43
+import static org.mockito.Mockito.verify;
39
 
44
 
40
 @RunWith(MockitoJUnitRunner.class)
45
 @RunWith(MockitoJUnitRunner.class)
41
 public class IfpluginTest {
46
 public class IfpluginTest {
42
 
47
 
48
+    @Mock private Provider<GlobalWindow> gwProvider;
43
     @Mock private Provider<GlobalCommandParser> gcpProvider;
49
     @Mock private Provider<GlobalCommandParser> gcpProvider;
44
     @Mock private CommandController controller;
50
     @Mock private CommandController controller;
45
     @Mock private PluginManager pluginManager;
51
     @Mock private PluginManager pluginManager;
48
 
54
 
49
     @Before
55
     @Before
50
     public void setUp() {
56
     public void setUp() {
51
-        command = new Ifplugin(controller, pluginManager, gcpProvider);
57
+        command = new Ifplugin(controller, pluginManager, gcpProvider, gwProvider);
52
     }
58
     }
53
 
59
 
54
     @Test
60
     @Test

+ 11
- 11
test/com/dmdirc/commandparser/parsers/CommandParserTest.java Näytä tiedosto

88
 
88
 
89
     @Test
89
     @Test
90
     public void testParseCommandWithArguments() {
90
     public void testParseCommandWithArguments() {
91
-        commandParser.parseCommand(null, "/command this is a test");
91
+        commandParser.parseCommand(container, "/command this is a test");
92
 
92
 
93
         assertNull(commandParser.nonCommandLine);
93
         assertNull(commandParser.nonCommandLine);
94
         assertNull(commandParser.invalidCommand);
94
         assertNull(commandParser.invalidCommand);
99
 
99
 
100
     @Test
100
     @Test
101
     public void testParseCommandWithoutArguments() {
101
     public void testParseCommandWithoutArguments() {
102
-        commandParser.parseCommand(null, "/command");
102
+        commandParser.parseCommand(container, "/command");
103
 
103
 
104
         assertNull(commandParser.nonCommandLine);
104
         assertNull(commandParser.nonCommandLine);
105
         assertNull(commandParser.invalidCommand);
105
         assertNull(commandParser.invalidCommand);
110
 
110
 
111
     @Test
111
     @Test
112
     public void testParseSilentCommandWithoutArguments() {
112
     public void testParseSilentCommandWithoutArguments() {
113
-        commandParser.parseCommand(null, "/.command");
113
+        commandParser.parseCommand(container, "/.command");
114
 
114
 
115
         assertNull(commandParser.nonCommandLine);
115
         assertNull(commandParser.nonCommandLine);
116
         assertNull(commandParser.invalidCommand);
116
         assertNull(commandParser.invalidCommand);
121
 
121
 
122
     @Test
122
     @Test
123
     public void testParseSilentCommandWithArguments() {
123
     public void testParseSilentCommandWithArguments() {
124
-        commandParser.parseCommand(null, "/.command this is a test");
124
+        commandParser.parseCommand(container, "/.command this is a test");
125
 
125
 
126
         assertNull(commandParser.nonCommandLine);
126
         assertNull(commandParser.nonCommandLine);
127
         assertNull(commandParser.invalidCommand);
127
         assertNull(commandParser.invalidCommand);
132
 
132
 
133
     @Test
133
     @Test
134
     public void testParseUnknownCommand() {
134
     public void testParseUnknownCommand() {
135
-        commandParser.parseCommand(null, "/foobar moo bar");
135
+        commandParser.parseCommand(container, "/foobar moo bar");
136
 
136
 
137
         assertNull(commandParser.nonCommandLine);
137
         assertNull(commandParser.nonCommandLine);
138
         assertEquals("foobar", commandParser.invalidCommand);
138
         assertEquals("foobar", commandParser.invalidCommand);
142
 
142
 
143
     @Test
143
     @Test
144
     public void testParseEmptyCommand() {
144
     public void testParseEmptyCommand() {
145
-        commandParser.parseCommand(null, "/ moo bar");
145
+        commandParser.parseCommand(container, "/ moo bar");
146
 
146
 
147
         assertNull(commandParser.nonCommandLine);
147
         assertNull(commandParser.nonCommandLine);
148
         assertEquals("", commandParser.invalidCommand);
148
         assertEquals("", commandParser.invalidCommand);
152
 
152
 
153
     @Test
153
     @Test
154
     public void testParseEmptySilenceCommand() {
154
     public void testParseEmptySilenceCommand() {
155
-        commandParser.parseCommand(null, "/. moo bar");
155
+        commandParser.parseCommand(container, "/. moo bar");
156
 
156
 
157
         assertNull(commandParser.nonCommandLine);
157
         assertNull(commandParser.nonCommandLine);
158
         assertEquals("", commandParser.invalidCommand);
158
         assertEquals("", commandParser.invalidCommand);
162
 
162
 
163
     @Test
163
     @Test
164
     public void testParseNonCommand() {
164
     public void testParseNonCommand() {
165
-        commandParser.parseCommand(null, "Foobar baz");
165
+        commandParser.parseCommand(container, "Foobar baz");
166
 
166
 
167
         assertEquals("Foobar baz", commandParser.nonCommandLine);
167
         assertEquals("Foobar baz", commandParser.nonCommandLine);
168
         assertNull(commandParser.invalidCommand);
168
         assertNull(commandParser.invalidCommand);
172
 
172
 
173
     @Test
173
     @Test
174
     public void testGetCommandTime() {
174
     public void testGetCommandTime() {
175
-        commandParser.parseCommand(null, "/command this is a test");
175
+        commandParser.parseCommand(container, "/command this is a test");
176
 
176
 
177
         final long time1 = commandParser.getCommandTime("command this is a test");
177
         final long time1 = commandParser.getCommandTime("command this is a test");
178
         assertTrue(time1 > 0);
178
         assertTrue(time1 > 0);
179
 
179
 
180
-        commandParser.parseCommand(null, "/command this is a test");
180
+        commandParser.parseCommand(container, "/command this is a test");
181
         final long time2 = commandParser.getCommandTime("command this is a test");
181
         final long time2 = commandParser.getCommandTime("command this is a test");
182
         assertTrue(time2 > 0);
182
         assertTrue(time2 > 0);
183
         assertTrue(time2 >= time1);
183
         assertTrue(time2 >= time1);
236
     @Test
236
     @Test
237
     public void testParseUnregisterCommand() {
237
     public void testParseUnregisterCommand() {
238
         commandParser.unregisterCommand(commandInfo);
238
         commandParser.unregisterCommand(commandInfo);
239
-        commandParser.parseCommand(null, "/command test 123");
239
+        commandParser.parseCommand(container, "/command test 123");
240
 
240
 
241
         assertNull(commandParser.nonCommandLine);
241
         assertNull(commandParser.nonCommandLine);
242
         assertEquals("command", commandParser.invalidCommand);
242
         assertEquals("command", commandParser.invalidCommand);

Loading…
Peruuta
Tallenna