Sfoglia il codice sorgente

Make all core commands provide a controller.

Change-Id: Iaf2c2fbc2ccc32aa8b05fd1a309fad524b2baf94
Reviewed-on: http://gerrit.dmdirc.com/2724
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 anni fa
parent
commit
0620e3d432
52 ha cambiato i file con 371 aggiunte e 217 eliminazioni
  1. 3
    0
      src/com/dmdirc/commandparser/commands/Command.java
  2. 4
    2
      src/com/dmdirc/commandparser/commands/CommandModule.java
  3. 0
    2
      src/com/dmdirc/commandparser/commands/channel/Ban.java
  4. 8
    2
      src/com/dmdirc/commandparser/commands/channel/Cycle.java
  5. 8
    2
      src/com/dmdirc/commandparser/commands/channel/Invite.java
  6. 0
    2
      src/com/dmdirc/commandparser/commands/channel/KickReason.java
  7. 8
    2
      src/com/dmdirc/commandparser/commands/channel/Mode.java
  8. 8
    2
      src/com/dmdirc/commandparser/commands/channel/Names.java
  9. 8
    2
      src/com/dmdirc/commandparser/commands/channel/Part.java
  10. 0
    9
      src/com/dmdirc/commandparser/commands/channel/SetNickColour.java
  11. 8
    2
      src/com/dmdirc/commandparser/commands/channel/ShowTopic.java
  12. 8
    2
      src/com/dmdirc/commandparser/commands/chat/Me.java
  13. 0
    9
      src/com/dmdirc/commandparser/commands/global/AliasCommand.java
  14. 4
    1
      src/com/dmdirc/commandparser/commands/global/AllServers.java
  15. 8
    2
      src/com/dmdirc/commandparser/commands/global/Clear.java
  16. 0
    9
      src/com/dmdirc/commandparser/commands/global/Echo.java
  17. 6
    3
      src/com/dmdirc/commandparser/commands/global/Exit.java
  18. 10
    4
      src/com/dmdirc/commandparser/commands/global/Help.java
  19. 4
    1
      src/com/dmdirc/commandparser/commands/global/Ifplugin.java
  20. 4
    1
      src/com/dmdirc/commandparser/commands/global/LoadPlugin.java
  21. 5
    1
      src/com/dmdirc/commandparser/commands/global/NewServer.java
  22. 4
    1
      src/com/dmdirc/commandparser/commands/global/Notify.java
  23. 8
    2
      src/com/dmdirc/commandparser/commands/global/OpenWindow.java
  24. 8
    2
      src/com/dmdirc/commandparser/commands/global/ReloadActions.java
  25. 4
    1
      src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java
  26. 4
    1
      src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java
  27. 4
    1
      src/com/dmdirc/commandparser/commands/global/SaveConfig.java
  28. 4
    1
      src/com/dmdirc/commandparser/commands/global/SetCommand.java
  29. 4
    1
      src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java
  30. 8
    2
      src/com/dmdirc/commandparser/commands/server/AllChannels.java
  31. 8
    2
      src/com/dmdirc/commandparser/commands/server/Away.java
  32. 8
    2
      src/com/dmdirc/commandparser/commands/server/Back.java
  33. 8
    2
      src/com/dmdirc/commandparser/commands/server/ChangeServer.java
  34. 8
    2
      src/com/dmdirc/commandparser/commands/server/Ctcp.java
  35. 8
    2
      src/com/dmdirc/commandparser/commands/server/Disconnect.java
  36. 8
    2
      src/com/dmdirc/commandparser/commands/server/Ignore.java
  37. 6
    5
      src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java
  38. 8
    2
      src/com/dmdirc/commandparser/commands/server/Message.java
  39. 8
    2
      src/com/dmdirc/commandparser/commands/server/Nick.java
  40. 8
    2
      src/com/dmdirc/commandparser/commands/server/Notice.java
  41. 8
    2
      src/com/dmdirc/commandparser/commands/server/OpenQuery.java
  42. 8
    2
      src/com/dmdirc/commandparser/commands/server/Raw.java
  43. 4
    3
      src/com/dmdirc/commandparser/commands/server/RawServerCommand.java
  44. 8
    2
      src/com/dmdirc/commandparser/commands/server/Reconnect.java
  45. 8
    2
      src/com/dmdirc/commandparser/commands/server/Umode.java
  46. 18
    27
      test/com/dmdirc/commandparser/commands/channel/ModeTest.java
  47. 17
    17
      test/com/dmdirc/commandparser/commands/channel/NamesTest.java
  48. 12
    13
      test/com/dmdirc/commandparser/commands/channel/PartTest.java
  49. 12
    15
      test/com/dmdirc/commandparser/commands/chat/MeTest.java
  50. 9
    9
      test/com/dmdirc/commandparser/commands/global/IfpluginTest.java
  51. 11
    11
      test/com/dmdirc/commandparser/commands/global/NewServerTest.java
  52. 26
    19
      test/com/dmdirc/commandparser/commands/server/ChangeServerTest.java

+ 3
- 0
src/com/dmdirc/commandparser/commands/Command.java Vedi File

@@ -52,7 +52,10 @@ public abstract class Command {
52 52
     /**
53 53
      * Creates a new instance of Command using the default CommandManager
54 54
      * provided by {@link CommandManager#getCommandManager()}.
55
+     *
56
+     * @deprecated All commands should provide a command controller.
55 57
      */
58
+    @Deprecated
56 59
     public Command() {
57 60
         this(CommandManager.getCommandManager());
58 61
     }

+ 4
- 2
src/com/dmdirc/commandparser/commands/CommandModule.java Vedi File

@@ -66,6 +66,7 @@ import com.dmdirc.commandparser.commands.server.Raw;
66 66
 import com.dmdirc.commandparser.commands.server.RawServerCommand;
67 67
 import com.dmdirc.commandparser.commands.server.Reconnect;
68 68
 import com.dmdirc.commandparser.commands.server.Umode;
69
+import com.dmdirc.interfaces.CommandController;
69 70
 import com.dmdirc.interfaces.CommandController.CommandDetails;
70 71
 
71 72
 import java.util.HashSet;
@@ -361,13 +362,14 @@ public class CommandModule {
361 362
     /**
362 363
      * Provides a set of raw commands.
363 364
      *
365
+     * @param controller The controller to use for command info.
364 366
      * @return A set of the commands' details.
365 367
      */
366 368
     @Provides(type = Provides.Type.SET_VALUES)
367
-    public Set<CommandDetails> getRawCommands() {
369
+    public Set<CommandDetails> getRawCommands(final CommandController controller) {
368 370
         final Set<CommandDetails> results = new HashSet<>();
369 371
         for (String name : new String[] { "lusers", "map", "motd", "oper", "whois", "who" }) {
370
-            final RawServerCommand rawCommand = new RawServerCommand(name);
372
+            final RawServerCommand rawCommand = new RawServerCommand(controller, name);
371 373
             results.add(new SimpleCommandDetails(rawCommand, rawCommand));
372 374
         }
373 375
         return results;

+ 0
- 2
src/com/dmdirc/commandparser/commands/channel/Ban.java Vedi File

@@ -38,12 +38,10 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
38 38
 import com.dmdirc.ui.input.TabCompletionType;
39 39
 
40 40
 import javax.inject.Inject;
41
-import lombok.NoArgsConstructor;
42 41
 
43 42
 /**
44 43
  * The kick command bans a specified user or host from the channel.
45 44
  */
46
-@NoArgsConstructor
47 45
 public class Ban extends Command implements IntelligentCommand {
48 46
 
49 47
     /** A command info object for this command. */

+ 8
- 2
src/com/dmdirc/commandparser/commands/channel/Cycle.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 
36 37
 import javax.inject.Inject;
37 38
 
@@ -46,9 +47,14 @@ public class Cycle extends Command {
46 47
             "cycle [message] - parts and rejoins the channel",
47 48
             CommandType.TYPE_CHANNEL);
48 49
 
49
-    /** Creates a new instance of this command. */
50
+    /**
51
+     * Creates a new instance of this command.
52
+     *
53
+     * @param controller The controller to use for command information.
54
+     */
50 55
     @Inject
51
-    public Cycle() {
56
+    public Cycle(final CommandController controller) {
57
+        super(controller);
52 58
     }
53 59
 
54 60
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/channel/Invite.java Vedi File

@@ -34,6 +34,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
34 34
 import com.dmdirc.commandparser.commands.ExternalCommand;
35 35
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
36 36
 import com.dmdirc.commandparser.commands.context.CommandContext;
37
+import com.dmdirc.interfaces.CommandController;
37 38
 import com.dmdirc.parser.interfaces.ChannelInfo;
38 39
 
39 40
 import javax.inject.Inject;
@@ -51,9 +52,14 @@ public class Invite extends Command implements ExternalCommand {
51 52
             "invite <user> - invites user to a channel",
52 53
             CommandType.TYPE_CHANNEL);
53 54
 
54
-    /** Creates a new instance of this command. */
55
+    /**
56
+     * Creates a new instance of this command.
57
+     *
58
+     * @param controller The controller to use for command information.
59
+     */
55 60
     @Inject
56
-    public Invite() {
61
+    public Invite(final CommandController controller) {
62
+        super(controller);
57 63
     }
58 64
 
59 65
     /** {@inheritDoc} */

+ 0
- 2
src/com/dmdirc/commandparser/commands/channel/KickReason.java Vedi File

@@ -39,13 +39,11 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
39 39
 import com.dmdirc.ui.input.TabCompletionType;
40 40
 
41 41
 import javax.inject.Inject;
42
-import lombok.NoArgsConstructor;
43 42
 
44 43
 /**
45 44
  * The kick command kicks a specified user from the channel.
46 45
  * This version allows the user to specify a reason.
47 46
  */
48
-@NoArgsConstructor
49 47
 @CommandOptions(allowOffline = false)
50 48
 public class KickReason extends Command implements IntelligentCommand {
51 49
 

+ 8
- 2
src/com/dmdirc/commandparser/commands/channel/Mode.java Vedi File

@@ -35,6 +35,7 @@ import com.dmdirc.commandparser.commands.ExternalCommand;
35 35
 import com.dmdirc.commandparser.commands.IntelligentCommand;
36 36
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
37 37
 import com.dmdirc.commandparser.commands.context.CommandContext;
38
+import com.dmdirc.interfaces.CommandController;
38 39
 import com.dmdirc.parser.interfaces.ChannelInfo;
39 40
 import com.dmdirc.ui.input.AdditionalTabTargets;
40 41
 import com.dmdirc.ui.input.TabCompletionType;
@@ -53,9 +54,14 @@ public class Mode extends Command implements IntelligentCommand,
53 54
             "mode [changes] - displays or changes the current channel modes",
54 55
             CommandType.TYPE_CHANNEL);
55 56
 
56
-    /** Creates a new instance of this command. */
57
+    /**
58
+     * Creates a new instance of this command.
59
+     *
60
+     * @param controller The controller to use for command information.
61
+     */
57 62
     @Inject
58
-    public Mode() {
63
+    public Mode(final CommandController controller) {
64
+        super(controller);
59 65
     }
60 66
 
61 67
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/channel/Names.java Vedi File

@@ -35,6 +35,7 @@ import com.dmdirc.commandparser.commands.ExternalCommand;
35 35
 import com.dmdirc.commandparser.commands.IntelligentCommand;
36 36
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
37 37
 import com.dmdirc.commandparser.commands.context.CommandContext;
38
+import com.dmdirc.interfaces.CommandController;
38 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
39 40
 
40 41
 import javax.inject.Inject;
@@ -51,9 +52,14 @@ public class Names extends Command implements IntelligentCommand,
51 52
             "names - Requests a list of users that are in the channel",
52 53
             CommandType.TYPE_CHANNEL);
53 54
 
54
-    /** Creates a new instance of this command. */
55
+    /**
56
+     * Creates a new instance of this command.
57
+     *
58
+     * @param controller The controller to use for command information.
59
+     */
55 60
     @Inject
56
-    public Names() {
61
+    public Names(final CommandController controller) {
62
+        super(controller);
57 63
     }
58 64
 
59 65
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/channel/Part.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 
36 37
 import javax.inject.Inject;
37 38
 
@@ -46,9 +47,14 @@ public class Part extends Command {
46 47
             "part [reason] - parts the channel",
47 48
             CommandType.TYPE_CHANNEL);
48 49
 
49
-    /** Creates a new instance of this command. */
50
+    /**
51
+     * Creates a new instance of this command.
52
+     *
53
+     * @param controller The controller to use for command information.
54
+     */
50 55
     @Inject
51
-    public Part() {
56
+    public Part(final CommandController controller) {
57
+        super(controller);
52 58
     }
53 59
 
54 60
     /** {@inheritDoc} */

+ 0
- 9
src/com/dmdirc/commandparser/commands/channel/SetNickColour.java Vedi File

@@ -56,15 +56,6 @@ public class SetNickColour extends Command implements IntelligentCommand {
56 56
     /** Manager to use to convert colours. */
57 57
     private final ColourManager colourManager;
58 58
 
59
-    /**
60
-     * Creates a new instance of the {@link SetNickColour} command.
61
-     *
62
-     * @param colourManager The colour manager to use to convert colours.
63
-     */
64
-    public SetNickColour(final ColourManager colourManager) {
65
-        this.colourManager = colourManager;
66
-    }
67
-
68 59
     /**
69 60
      * Creates a new instance of the {@link SetNickColour} command.
70 61
      *

+ 8
- 2
src/com/dmdirc/commandparser/commands/channel/ShowTopic.java Vedi File

@@ -34,6 +34,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
34 34
 import com.dmdirc.commandparser.commands.ExternalCommand;
35 35
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
36 36
 import com.dmdirc.commandparser.commands.context.CommandContext;
37
+import com.dmdirc.interfaces.CommandController;
37 38
 import com.dmdirc.parser.interfaces.ChannelInfo;
38 39
 
39 40
 import javax.inject.Inject;
@@ -49,9 +50,14 @@ public class ShowTopic extends Command implements ExternalCommand {
49 50
             "topic - displays the current topic\ntopic <newtopic> - sets the channel topic",
50 51
             CommandType.TYPE_CHANNEL);
51 52
 
52
-    /** Creates a new instance of this command. */
53
+    /**
54
+     * Creates a new instance of this command.
55
+     *
56
+     * @param controller The controller to use for command information.
57
+     */
53 58
     @Inject
54
-    public ShowTopic() {
59
+    public ShowTopic(final CommandController controller) {
60
+        super(controller);
55 61
     }
56 62
 
57 63
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/chat/Me.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.Command;
33 33
 import com.dmdirc.commandparser.commands.ValidatingCommand;
34 34
 import com.dmdirc.commandparser.commands.context.ChatCommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.CommandContext;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.util.validators.ValidationResponse;
37 38
 
38 39
 import javax.inject.Inject;
@@ -47,9 +48,14 @@ public class Me extends Command implements ValidatingCommand {
47 48
             "me <action> - sends the specified action",
48 49
             CommandType.TYPE_CHAT);
49 50
 
50
-    /** Creates a new instance of this command. */
51
+    /**
52
+     * Creates a new instance of {@link Ban} using the given command controller.
53
+     *
54
+     * @param controller The controller to use for command information.
55
+     */
51 56
     @Inject
52
-    public Me() {
57
+    public Me(final CommandController controller) {
58
+        super(controller);
53 59
     }
54 60
 
55 61
     /** {@inheritDoc} */

+ 0
- 9
src/com/dmdirc/commandparser/commands/global/AliasCommand.java Vedi File

@@ -53,15 +53,6 @@ public class AliasCommand extends Command implements IntelligentCommand {
53 53
     /** Wrapper to use to modify aliases. */
54 54
     private final AliasWrapper aliasWrapper;
55 55
 
56
-    /**
57
-     * Creates a new instance of {@link AliasCommand}.
58
-     *
59
-     * @param aliasWrapper The wrapper to use to modify aliases.
60
-     */
61
-    public AliasCommand(final AliasWrapper aliasWrapper) {
62
-        this.aliasWrapper = aliasWrapper;
63
-    }
64
-
65 56
     /**
66 57
      * Creates a new instance of {@link AliasCommand}.
67 58
      *

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/AllServers.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.CommandType;
32 32
 import com.dmdirc.commandparser.commands.Command;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
36 37
 import com.dmdirc.ui.input.TabCompleter;
37 38
 
@@ -53,10 +54,12 @@ public class AllServers extends Command implements IntelligentCommand {
53 54
     /**
54 55
      * Creates a new instance of the {@link AllServers} command.
55 56
      *
57
+     * @param controller The controller that owns this command.
56 58
      * @param serverManager The server manager to use to iterate servers.
57 59
      */
58 60
     @Inject
59
-    public AllServers(final ServerManager serverManager) {
61
+    public AllServers(final CommandController controller, final ServerManager serverManager) {
62
+        super(controller);
60 63
         this.serverManager = serverManager;
61 64
     }
62 65
 

+ 8
- 2
src/com/dmdirc/commandparser/commands/global/Clear.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 35
 
35 36
 import javax.inject.Inject;
@@ -44,9 +45,14 @@ public class Clear extends Command implements IntelligentCommand {
44 45
             "clear - clears the current window's text area",
45 46
             CommandType.TYPE_GLOBAL);
46 47
 
47
-    /** Creates a new instance of this command. */
48
+    /**
49
+     * Creates a new instance of this command.
50
+     *
51
+     * @param controller The controller to use for command information.
52
+     */
48 53
     @Inject
49
-    public Clear() {
54
+    public Clear(final CommandController controller) {
55
+        super(controller);
50 56
     }
51 57
 
52 58
     /** {@inheritDoc} */

+ 0
- 9
src/com/dmdirc/commandparser/commands/global/Echo.java Vedi File

@@ -63,15 +63,6 @@ public class Echo extends Command implements IntelligentCommand {
63 63
     /** The command flag handler for this command. */
64 64
     private final CommandFlagHandler handler;
65 65
 
66
-    /**
67
-     * Creates a new instance of Echo.
68
-     */
69
-    public Echo() {
70
-        super();
71
-
72
-        handler = new CommandFlagHandler(timeStampFlag, targetFlag);
73
-    }
74
-
75 66
     /**
76 67
      * Creates a new instance of Echo.
77 68
      *

+ 6
- 3
src/com/dmdirc/commandparser/commands/global/Exit.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandInfo;
30 30
 import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 
34 35
 import javax.inject.Inject;
35 36
 
@@ -51,11 +52,13 @@ public class Exit extends Command {
51 52
     /**
52 53
      * Creates a new instance of the {@link Exit} command.
53 54
      *
54
-     * @param controller The controller to use to quit the app.
55
+     * @param controller Command controller
56
+     * @param lifecycleController The controller to use to quit the app.
55 57
      */
56 58
     @Inject
57
-    public Exit(final LifecycleController controller) {
58
-        this.controller = controller;
59
+    public Exit(final CommandController controller, final LifecycleController lifecycleController) {
60
+        super(controller);
61
+        this.controller = lifecycleController;
59 62
     }
60 63
 
61 64
     /** {@inheritDoc} */

+ 10
- 4
src/com/dmdirc/commandparser/commands/global/Help.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 36
 import com.dmdirc.ui.input.TabCompletionType;
36 37
 import com.dmdirc.ui.messages.Styliser;
@@ -54,9 +55,14 @@ public class Help extends Command implements IntelligentCommand {
54 55
             "help [command] - shows client command help",
55 56
             CommandType.TYPE_GLOBAL);
56 57
 
57
-    /** Creates a new instance of this command. */
58
+    /**
59
+     * Creates a new instance of this command.
60
+     *
61
+     * @param controller The controller to use for command information.
62
+     */
58 63
     @Inject
59
-    public Help() {
64
+    public Help(final CommandController controller) {
65
+        super(controller);
60 66
     }
61 67
 
62 68
     /** {@inheritDoc} */
@@ -77,7 +83,7 @@ public class Help extends Command implements IntelligentCommand {
77 83
      * @param isSilent Whether this command has been silenced or not
78 84
      */
79 85
     private void showAllCommands(final FrameContainer origin, final boolean isSilent) {
80
-        final List<String> commands = new ArrayList<String>(((WritableFrameContainer) origin)
86
+        final List<String> commands = new ArrayList<>(((WritableFrameContainer) origin)
81 87
                 .getCommandParser().getCommands().keySet());
82 88
 
83 89
         Collections.sort(commands);
@@ -115,7 +121,7 @@ public class Help extends Command implements IntelligentCommand {
115 121
      */
116 122
     private void showCommand(final FrameContainer origin, final boolean isSilent,
117 123
             final String name) {
118
-        Map.Entry<CommandInfo, Command> command = null;
124
+        Map.Entry<CommandInfo, Command> command;
119 125
 
120 126
         if (name.length() > 0 && name.charAt(0) == getController().getCommandChar()) {
121 127
             command = getController().getCommand(name.substring(1));

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/Ifplugin.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.Command;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.plugins.PluginInfo;
37 38
 import com.dmdirc.plugins.PluginManager;
38 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -58,10 +59,12 @@ public class Ifplugin extends Command implements IntelligentCommand {
58 59
     /**
59 60
      * Creates a new instance of the {@link Ifplugin} command.
60 61
      *
62
+     * @param controller The controller to use for command information.
61 63
      * @param pluginManager The plugin manager to use to query plugins.
62 64
      */
63 65
     @Inject
64
-    public Ifplugin(final PluginManager pluginManager) {
66
+    public Ifplugin(final CommandController controller, final PluginManager pluginManager) {
67
+        super(controller);
65 68
         this.pluginManager = pluginManager;
66 69
     }
67 70
 

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.plugins.PluginInfo;
34 35
 import com.dmdirc.plugins.PluginManager;
35 36
 import com.dmdirc.plugins.PluginMetaData;
@@ -53,10 +54,12 @@ public class LoadPlugin extends Command implements IntelligentCommand {
53 54
     /**
54 55
      * Creates a new instance of the {@link LoadPlugin} command.
55 56
      *
57
+     * @param controller The controller to use for command information.
56 58
      * @param pluginManager The plugin manager to load plugins with.
57 59
      */
58 60
     @Inject
59
-    public LoadPlugin(final PluginManager pluginManager) {
61
+    public LoadPlugin(final CommandController controller, final PluginManager pluginManager) {
62
+        super(controller);
60 63
         this.pluginManager = pluginManager;
61 64
     }
62 65
 

+ 5
- 1
src/com/dmdirc/commandparser/commands/global/NewServer.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 import com.dmdirc.interfaces.IdentityController;
35 36
 import com.dmdirc.interfaces.ServerFactory;
36 37
 import com.dmdirc.logger.ErrorLevel;
@@ -69,15 +70,18 @@ public class NewServer extends Command implements IntelligentCommand {
69 70
      * Creates a new newserver command which will use the specified factory
70 71
      * to construct servers.
71 72
      *
72
-     * @param serverFactory The factory to use to construct servers
73
+     * @param controller The controller to use for command information.
74
+     * @param serverFactory The factory to use to construct servers.
73 75
      * @param pluginManager The plugin manager to use to query available services.
74 76
      * @param identityController Identity controller to use to find profiles.
75 77
      */
76 78
     @Inject
77 79
     public NewServer(
80
+            final CommandController controller,
78 81
             final ServerFactory serverFactory,
79 82
             final PluginManager pluginManager,
80 83
             final IdentityController identityController) {
84
+        super(controller);
81 85
         this.serverFactory = serverFactory;
82 86
         this.pluginManager = pluginManager;
83 87
         this.identityController = identityController;

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/Notify.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.ui.Colour;
34 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 36
 import com.dmdirc.ui.messages.ColourManager;
@@ -53,10 +54,12 @@ public class Notify extends Command implements IntelligentCommand {
53 54
     /**
54 55
      * Creates a new instance of the {@link Notify} command.
55 56
      *
57
+     * @param controller The controller to use for command information.
56 58
      * @param colourManager The colour manager to use to convert colours.
57 59
      */
58 60
     @Inject
59
-    public Notify(final ColourManager colourManager) {
61
+    public Notify(final CommandController controller, final ColourManager colourManager) {
62
+        super(controller);
60 63
         this.colourManager = colourManager;
61 64
     }
62 65
 

+ 8
- 2
src/com/dmdirc/commandparser/commands/global/OpenWindow.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 import com.dmdirc.ui.WindowManager;
35 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
36 37
 
@@ -47,9 +48,14 @@ public class OpenWindow extends Command implements IntelligentCommand {
47 48
             + "- opens a window with the specified name and title",
48 49
             CommandType.TYPE_GLOBAL);
49 50
 
50
-    /** Creates a new instance of this command. */
51
+    /**
52
+     * Creates a new instance of this command.
53
+     *
54
+     * @param controller The controller to use for command information.
55
+     */
51 56
     @Inject
52
-    public OpenWindow() {
57
+    public OpenWindow(final CommandController controller) {
58
+        super(controller);
53 59
     }
54 60
 
55 61
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/global/ReloadActions.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 36
 
36 37
 import javax.inject.Inject;
@@ -45,9 +46,14 @@ public final class ReloadActions extends Command implements IntelligentCommand {
45 46
             "reloadactions - reloads actions from disk",
46 47
             CommandType.TYPE_GLOBAL);
47 48
 
48
-    /** Creates a new instance of this command. */
49
+    /**
50
+     * Creates a new instance of this command.
51
+     *
52
+     * @param controller The controller to use for command information.
53
+     */
49 54
     @Inject
50
-    public ReloadActions() {
55
+    public ReloadActions(final CommandController controller) {
56
+        super(controller);
51 57
     }
52 58
 
53 59
     /** {@inheritDoc} */

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.interfaces.IdentityController;
34 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 36
 
@@ -51,10 +52,12 @@ public class ReloadIdentities extends Command implements IntelligentCommand {
51 52
     /**
52 53
      * Creates a new instance of the {@link ReloadIdentities} command.
53 54
      *
55
+     * @param controller The controller to use for command information.
54 56
      * @param identityController The controller to reload identities on.
55 57
      */
56 58
     @Inject
57
-    public ReloadIdentities(final IdentityController identityController) {
59
+    public ReloadIdentities(final CommandController controller, final IdentityController identityController) {
60
+        super(controller);
58 61
         this.identityController = identityController;
59 62
     }
60 63
 

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.plugins.PluginInfo;
34 35
 import com.dmdirc.plugins.PluginManager;
35 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -52,10 +53,12 @@ public class ReloadPlugin extends Command implements IntelligentCommand {
52 53
     /**
53 54
      * Creates a new instance of the {@link ReloadPlugin} command.
54 55
      *
56
+     * @param controller The controller to use for command information.
55 57
      * @param pluginManager The plugin manager to reload plugins with.
56 58
      */
57 59
     @Inject
58
-    public ReloadPlugin(final PluginManager pluginManager) {
60
+    public ReloadPlugin(final CommandController controller, final PluginManager pluginManager) {
61
+        super(controller);
59 62
         this.pluginManager = pluginManager;
60 63
     }
61 64
 

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/SaveConfig.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.interfaces.IdentityController;
34 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 36
 
@@ -51,10 +52,12 @@ public final class SaveConfig extends Command implements IntelligentCommand {
51 52
     /**
52 53
      * Creates a new instance of the {@link SaveConfig} command.
53 54
      *
55
+     * @param controller The controller to use for command information.
54 56
      * @param identityController The controller to save identities on.
55 57
      */
56 58
     @Inject
57
-    public SaveConfig(final IdentityController identityController) {
59
+    public SaveConfig(final CommandController controller, final IdentityController identityController) {
60
+        super(controller);
58 61
         this.identityController = identityController;
59 62
     }
60 63
 

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/SetCommand.java Vedi File

@@ -37,6 +37,7 @@ import com.dmdirc.commandparser.commands.flags.CommandFlagHandler;
37 37
 import com.dmdirc.commandparser.commands.flags.CommandFlagResult;
38 38
 import com.dmdirc.config.ConfigManager;
39 39
 import com.dmdirc.config.Identity;
40
+import com.dmdirc.interfaces.CommandController;
40 41
 import com.dmdirc.interfaces.IdentityController;
41 42
 import com.dmdirc.interfaces.IdentityFactory;
42 43
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -76,14 +77,16 @@ public class SetCommand extends Command implements IntelligentCommand {
76 77
     /**
77 78
      * Creates a new instance of Set.
78 79
      *
80
+     * @param controller The controller to use for command information.
79 81
      * @param identityController The controller to use to set settings.
80 82
      * @param identityFactory The factory to use to create new identities.
81 83
      */
82 84
     @Inject
83 85
     public SetCommand(
86
+            final CommandController controller,
84 87
             final IdentityController identityController,
85 88
             final IdentityFactory identityFactory) {
86
-        super();
89
+        super(controller);
87 90
 
88 91
         this.identityController = identityController;
89 92
         this.identityFactory = identityFactory;

+ 4
- 1
src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.interfaces.CommandController;
33 34
 import com.dmdirc.plugins.PluginInfo;
34 35
 import com.dmdirc.plugins.PluginManager;
35 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -52,10 +53,12 @@ public class UnloadPlugin extends Command implements IntelligentCommand {
52 53
     /**
53 54
      * Creates a new instance of the {@link UnloadPlugin} command.
54 55
      *
56
+     * @param controller The controller to use for command information.
55 57
      * @param pluginManager The plugin manager to unload plugins with.
56 58
      */
57 59
     @Inject
58
-    public UnloadPlugin(final PluginManager pluginManager) {
60
+    public UnloadPlugin(final CommandController controller, final PluginManager pluginManager) {
61
+        super(controller);
59 62
         this.pluginManager = pluginManager;
60 63
     }
61 64
 

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/AllChannels.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
36 37
 import com.dmdirc.ui.input.TabCompleter;
37 38
 
@@ -48,9 +49,14 @@ public class AllChannels extends Command implements IntelligentCommand {
48 49
            "allchannels <command> - executes the command as though it had"
49 50
             + " been entered on all channels", CommandType.TYPE_SERVER);
50 51
 
51
-    /** Creates a new instance of this command. */
52
+    /**
53
+     * Creates a new instance of this command.
54
+     *
55
+     * @param controller The controller to use for command information.
56
+     */
52 57
     @Inject
53
-    public AllChannels() {
58
+    public AllChannels(final CommandController controller) {
59
+        super(controller);
54 60
     }
55 61
 
56 62
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Away.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 
36 37
 import javax.inject.Inject;
37 38
 
@@ -45,9 +46,14 @@ public class Away extends Command {
45 46
     public static final CommandInfo INFO = new BaseCommandInfo("away",
46 47
            "away <reason> - marks you as away", CommandType.TYPE_SERVER);
47 48
 
48
-    /** Creates a new instance of this command. */
49
+    /**
50
+     * Creates a new instance of this command.
51
+     *
52
+     * @param controller The controller to use for command information.
53
+     */
49 54
     @Inject
50
-    public Away() {
55
+    public Away(final CommandController controller) {
56
+        super(controller);
51 57
     }
52 58
 
53 59
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Back.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 38
 
38 39
 import javax.inject.Inject;
@@ -47,9 +48,14 @@ public class Back extends Command implements IntelligentCommand {
47 48
     public static final CommandInfo INFO = new BaseCommandInfo("back",
48 49
            "back - unsets your away status", CommandType.TYPE_SERVER);
49 50
 
50
-    /** Creates a new instance of this command. */
51
+    /**
52
+     * Creates a new instance of this command.
53
+     *
54
+     * @param controller The controller to use for command information.
55
+     */
51 56
     @Inject
52
-    public Back() {
57
+    public Back(final CommandController controller) {
58
+        super(controller);
53 59
     }
54 60
 
55 61
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/ChangeServer.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34 34
 import com.dmdirc.commandparser.commands.global.NewServer;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 
36 37
 import java.net.URI;
37 38
 import java.net.URISyntaxException;
@@ -48,9 +49,14 @@ public class ChangeServer extends Command {
48 49
             "server <host[:[+]port]> [password] - connect to a different server",
49 50
             CommandType.TYPE_SERVER);
50 51
 
51
-    /** Creates a new instance of this command. */
52
+    /**
53
+     * Creates a new instance of this command.
54
+     *
55
+     * @param controller The controller to use for command information.
56
+     */
52 57
     @Inject
53
-    public ChangeServer() {
58
+    public ChangeServer(final CommandController controller) {
59
+        super(controller);
54 60
     }
55 61
 
56 62
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Ctcp.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 38
 import com.dmdirc.ui.input.TabCompletionType;
38 39
 
@@ -49,9 +50,14 @@ public class Ctcp extends Command implements IntelligentCommand {
49 50
             "ctcp <target> <type> [arguments] - sends a CTCP message",
50 51
             CommandType.TYPE_SERVER);
51 52
 
52
-    /** Creates a new instance of this command. */
53
+    /**
54
+     * Creates a new instance of this command.
55
+     *
56
+     * @param controller The controller to use for command information.
57
+     */
53 58
     @Inject
54
-    public Ctcp() {
59
+    public Ctcp(final CommandController controller) {
60
+        super(controller);
55 61
     }
56 62
 
57 63
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Disconnect.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 
35 36
 import javax.inject.Inject;
36 37
 
@@ -44,9 +45,14 @@ public class Disconnect extends Command {
44 45
             "disconnect [reason] - disconnect from this server",
45 46
             CommandType.TYPE_SERVER);
46 47
 
47
-    /** Creates a new instance of this command. */
48
+    /**
49
+     * Creates a new instance of this command.
50
+     *
51
+     * @param controller The controller to use for command information.
52
+     */
48 53
     @Inject
49
-    public Disconnect() {
54
+    public Disconnect(final CommandController controller) {
55
+        super(controller);
50 56
     }
51 57
 
52 58
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Ignore.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 import com.dmdirc.parser.common.IgnoreList;
36 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 38
 import com.dmdirc.ui.input.TabCompletionType;
@@ -52,9 +53,14 @@ public class Ignore extends Command implements IntelligentCommand {
52 53
             "ignore [--remove|--regex] [host] - manages the network's ignore list",
53 54
             CommandType.TYPE_SERVER);
54 55
 
55
-    /** Creates a new instance of this command. */
56
+    /**
57
+     * Creates a new instance of this command.
58
+     *
59
+     * @param controller The controller to use for command information.
60
+     */
56 61
     @Inject
57
-    public Ignore() {
62
+    public Ignore(final CommandController controller) {
63
+        super(controller);
58 64
     }
59 65
 
60 66
     /** {@inheritDoc} */

+ 6
- 5
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java Vedi File

@@ -35,6 +35,7 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 36
 import com.dmdirc.interfaces.ActionController;
37 37
 import com.dmdirc.interfaces.ActionListener;
38
+import com.dmdirc.interfaces.CommandController;
38 39
 import com.dmdirc.interfaces.actions.ActionType;
39 40
 import com.dmdirc.parser.common.ChannelJoinRequest;
40 41
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -65,13 +66,13 @@ public class JoinChannelCommand extends Command implements
65 66
     /**
66 67
      * Creates a new instance of the join channel command.
67 68
      *
68
-     * @param controller The action controller to register listeners with.
69
+     * @param controller The controller to use to retrieve command information.
70
+     * @param actionController The action controller to register listeners with.
69 71
      */
70 72
     @Inject
71
-    public JoinChannelCommand(final ActionController controller) {
72
-        super();
73
-
74
-        controller.registerListener(this, CoreActionType.CLIENT_LINE_ADDED);
73
+    public JoinChannelCommand(final CommandController controller, final ActionController actionController) {
74
+        super(controller);
75
+        actionController.registerListener(this, CoreActionType.CLIENT_LINE_ADDED);
75 76
     }
76 77
 
77 78
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Message.java Vedi File

@@ -35,6 +35,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
35 35
 import com.dmdirc.commandparser.commands.WrappableCommand;
36 36
 import com.dmdirc.commandparser.commands.context.CommandContext;
37 37
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
38
+import com.dmdirc.interfaces.CommandController;
38 39
 import com.dmdirc.parser.interfaces.Parser;
39 40
 import com.dmdirc.ui.input.AdditionalTabTargets;
40 41
 import com.dmdirc.ui.input.TabCompletionType;
@@ -53,9 +54,14 @@ public class Message extends Command implements IntelligentCommand,
53 54
             "msg <target> <message> - sends a private message",
54 55
             CommandType.TYPE_SERVER);
55 56
 
56
-    /** Creates a new instance of this command. */
57
+    /**
58
+     * Creates a new instance of this command.
59
+     *
60
+     * @param controller The controller to use for command information.
61
+     */
57 62
     @Inject
58
-    public Message() {
63
+    public Message(final CommandController controller) {
64
+        super(controller);
59 65
     }
60 66
 
61 67
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Nick.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 38
 import com.dmdirc.ui.input.TabCompletionType;
38 39
 
@@ -49,9 +50,14 @@ public class Nick extends Command implements IntelligentCommand {
49 50
             "nick <new nickname> - attempts to change your nickname to the one specified",
50 51
             CommandType.TYPE_SERVER);
51 52
 
52
-    /** Creates a new instance of this command. */
53
+    /**
54
+     * Creates a new instance of this command.
55
+     *
56
+     * @param controller The controller to use for command information.
57
+     */
53 58
     @Inject
54
-    public Nick() {
59
+    public Nick(final CommandController controller) {
60
+        super(controller);
55 61
     }
56 62
 
57 63
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Notice.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 38
 import com.dmdirc.ui.input.TabCompletionType;
38 39
 
@@ -49,9 +50,14 @@ public class Notice extends Command implements IntelligentCommand {
49 50
             "notice <target> <message> - sends a notice",
50 51
             CommandType.TYPE_SERVER);
51 52
 
52
-    /** Creates a new instance of this command. */
53
+    /**
54
+     * Creates a new instance of this command.
55
+     *
56
+     * @param controller The controller to use for command information.
57
+     */
53 58
     @Inject
54
-    public Notice() {
59
+    public Notice(final CommandController controller) {
60
+        super(controller);
55 61
     }
56 62
 
57 63
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/OpenQuery.java Vedi File

@@ -35,6 +35,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
35 35
 import com.dmdirc.commandparser.commands.WrappableCommand;
36 36
 import com.dmdirc.commandparser.commands.context.CommandContext;
37 37
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
38
+import com.dmdirc.interfaces.CommandController;
38 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
39 40
 import com.dmdirc.ui.input.TabCompletionType;
40 41
 import com.dmdirc.ui.messages.Styliser;
@@ -52,9 +53,14 @@ public class OpenQuery extends Command implements IntelligentCommand,
52 53
             "query <user> [message] - opens a query with the specified user",
53 54
             CommandType.TYPE_SERVER);
54 55
 
55
-    /** Creates a new instance of this command. */
56
+    /**
57
+     * Creates a new instance of this command.
58
+     *
59
+     * @param controller The controller to use for command information.
60
+     */
56 61
     @Inject
57
-    public OpenQuery() {
62
+    public OpenQuery(final CommandController controller) {
63
+        super(controller);
58 64
     }
59 65
 
60 66
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Raw.java Vedi File

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35
+import com.dmdirc.interfaces.CommandController;
35 36
 
36 37
 import javax.inject.Inject;
37 38
 
@@ -47,9 +48,14 @@ public class Raw extends Command {
47 48
             "raw <text> - sends the specified text directly to the server",
48 49
             CommandType.TYPE_SERVER);
49 50
 
50
-    /** Creates a new instance of this command. */
51
+    /**
52
+     * Creates a new instance of this command.
53
+     *
54
+     * @param controller The controller to use for command information.
55
+     */
51 56
     @Inject
52
-    public Raw() {
57
+    public Raw(final CommandController controller) {
58
+        super(controller);
53 59
     }
54 60
 
55 61
     /** {@inheritDoc} */

+ 4
- 3
src/com/dmdirc/commandparser/commands/server/RawServerCommand.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.CommandOptions;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 
35 36
 /**
36 37
  * Implements a raw server command (i.e., a command that is sent to the server
@@ -45,11 +46,11 @@ public class RawServerCommand extends Command implements CommandInfo {
45 46
     /**
46 47
      * Creates a new instance of RawServerCommand.
47 48
      *
49
+     * @param controller The controller to use for command info.
48 50
      * @param command The command name for this raw command
49 51
      */
50
-    public RawServerCommand(final String command) {
51
-        super();
52
-
52
+    public RawServerCommand(final CommandController controller, final String command) {
53
+        super(controller);
53 54
         myName = command;
54 55
     }
55 56
 

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Reconnect.java Vedi File

@@ -31,6 +31,7 @@ import com.dmdirc.commandparser.CommandType;
31 31
 import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34
+import com.dmdirc.interfaces.CommandController;
34 35
 
35 36
 import javax.inject.Inject;
36 37
 
@@ -44,9 +45,14 @@ public class Reconnect extends Command {
44 45
             "reconnect [reason] - reconnect to this server",
45 46
             CommandType.TYPE_SERVER);
46 47
 
47
-    /** Creates a new instance of this command. */
48
+    /**
49
+     * Creates a new instance of this command.
50
+     *
51
+     * @param controller The controller to use for command information.
52
+     */
48 53
     @Inject
49
-    public Reconnect() {
54
+    public Reconnect(final CommandController controller) {
55
+        super(controller);
50 56
     }
51 57
 
52 58
     /** {@inheritDoc} */

+ 8
- 2
src/com/dmdirc/commandparser/commands/server/Umode.java Vedi File

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.Command;
33 33
 import com.dmdirc.commandparser.commands.CommandOptions;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36
+import com.dmdirc.interfaces.CommandController;
36 37
 
37 38
 import javax.inject.Inject;
38 39
 
@@ -47,9 +48,14 @@ public class Umode extends Command {
47 48
             "umode [modes] - sets or displays your user modes",
48 49
             CommandType.TYPE_SERVER);
49 50
 
50
-    /** Creates a new instance of this command. */
51
+    /**
52
+     * Creates a new instance of this command.
53
+     *
54
+     * @param controller The controller to use for command information.
55
+     */
51 56
     @Inject
52
-    public Umode() {
57
+    public Umode(final CommandController controller) {
58
+        super(controller);
53 59
     }
54 60
 
55 61
     /** {@inheritDoc} */

+ 18
- 27
test/com/dmdirc/commandparser/commands/channel/ModeTest.java Vedi File

@@ -25,49 +25,46 @@ package com.dmdirc.commandparser.commands.channel;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28
-import com.dmdirc.TestMain;
29 28
 import com.dmdirc.commandparser.CommandArguments;
30 29
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
31 30
 import com.dmdirc.config.InvalidIdentityFileException;
32
-import com.dmdirc.parser.irc.IRCChannelInfo;
33
-import com.dmdirc.parser.irc.IRCParser;
31
+import com.dmdirc.interfaces.CommandController;
32
+import com.dmdirc.parser.interfaces.ChannelInfo;
33
+import com.dmdirc.parser.interfaces.Parser;
34 34
 
35 35
 import org.junit.Before;
36 36
 import org.junit.Test;
37
+import org.junit.runner.RunWith;
38
+import org.mockito.Mock;
39
+import org.mockito.runners.MockitoJUnitRunner;
37 40
 
38 41
 import static org.mockito.Mockito.*;
39 42
 
43
+@RunWith(MockitoJUnitRunner.class)
40 44
 public class ModeTest {
41 45
 
46
+    @Mock private FrameContainer origin;
47
+    @Mock private CommandController controller;
48
+    @Mock private ChannelInfo channelinfo;
49
+    @Mock private Channel channel;
50
+    @Mock private Server server;
51
+    @Mock private Parser parser;
42 52
     private Mode command;
43
-    private IRCChannelInfo channelinfo;
44
-    private Channel channel;
45
-    private Server server;
46
-    private IRCParser parser;
47 53
 
48 54
     @Before
49 55
     public void setUp() throws InvalidIdentityFileException {
50
-        TestMain.getTestMain();
51
-
52
-        parser = mock(IRCParser.class);
53
-        server = mock(Server.class);
54
-        channel = mock(Channel.class);
55
-        channelinfo = mock(IRCChannelInfo.class);
56
-
57 56
         when(channel.getServer()).thenReturn(server);
58 57
         when(server.getParser()).thenReturn(parser);
59 58
         when(channel.getChannelInfo()).thenReturn(channelinfo);
60 59
         when(channelinfo.getModes()).thenReturn("my mode string!");
61 60
         when(channelinfo.toString()).thenReturn("#chan");
62 61
 
63
-        command = new Mode();
62
+        command = new Mode(controller);
64 63
     }
65 64
 
66 65
     @Test
67 66
     public void testWithoutArgs() {
68
-        final FrameContainer origin = mock(FrameContainer.class);
69
-
70
-        command.execute(origin, new CommandArguments("/mode"),
67
+        command.execute(origin, new CommandArguments(controller, "/mode"),
71 68
                 new ChannelCommandContext(null, Mode.INFO, channel));
72 69
 
73 70
         verify(origin).addLine("channelModeDiscovered", "my mode string!", channelinfo);
@@ -75,9 +72,7 @@ public class ModeTest {
75 72
 
76 73
     @Test
77 74
     public void testWithArgs() {
78
-        final FrameContainer origin = mock(FrameContainer.class);
79
-
80
-        command.execute(origin, new CommandArguments("/mode +hello -bye"),
75
+        command.execute(origin, new CommandArguments(controller, "/mode +hello -bye"),
81 76
                 new ChannelCommandContext(null, Mode.INFO, channel));
82 77
 
83 78
         verify(parser).sendRawMessage("MODE #chan +hello -bye");
@@ -85,9 +80,7 @@ public class ModeTest {
85 80
 
86 81
     @Test
87 82
     public void testExternalWithArgs() {
88
-        final FrameContainer origin = mock(FrameContainer.class);
89
-
90
-        command.execute(origin, new CommandArguments("/mode +hello -bye"),
83
+        command.execute(origin, new CommandArguments(controller, "/mode +hello -bye"),
91 84
                 new ChannelCommandContext(null, Mode.INFO, channel));
92 85
 
93 86
         verify(parser).sendRawMessage("MODE #chan +hello -bye");
@@ -95,10 +88,8 @@ public class ModeTest {
95 88
 
96 89
     @Test
97 90
     public void testExternalWithoutArgs() {
98
-        final FrameContainer origin = mock(FrameContainer.class);
99
-
100 91
         command.execute(origin, server, "#chan", false,
101
-                new CommandArguments("/mode"));
92
+                new CommandArguments(controller,"/mode"));
102 93
 
103 94
         verify(parser).sendRawMessage("MODE #chan");
104 95
     }

+ 17
- 17
test/com/dmdirc/commandparser/commands/channel/NamesTest.java Vedi File

@@ -24,46 +24,45 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
-import com.dmdirc.TestMain;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
30 29
 import com.dmdirc.config.InvalidIdentityFileException;
31
-import com.dmdirc.parser.irc.IRCChannelInfo;
32
-import com.dmdirc.parser.irc.IRCParser;
30
+import com.dmdirc.interfaces.CommandController;
31
+import com.dmdirc.parser.interfaces.ChannelInfo;
32
+import com.dmdirc.parser.interfaces.Parser;
33 33
 
34 34
 import org.junit.Before;
35 35
 import org.junit.Test;
36
+import org.junit.runner.RunWith;
37
+import org.mockito.Mock;
38
+import org.mockito.runners.MockitoJUnitRunner;
36 39
 
37 40
 import static org.mockito.Mockito.*;
38 41
 
42
+@RunWith(MockitoJUnitRunner.class)
39 43
 public class NamesTest {
40 44
 
45
+    @Mock private CommandController controller;
46
+    @Mock private ChannelInfo channelinfo;
47
+    @Mock private Channel channel;
48
+    @Mock private Server server;
49
+    @Mock private Parser parser;
50
+
41 51
     private Names command;
42
-    private IRCChannelInfo channelinfo;
43
-    private Channel channel;
44
-    private Server server;
45
-    private IRCParser parser;
46 52
 
47 53
     @Before
48 54
     public void setUp() throws InvalidIdentityFileException {
49
-        TestMain.getTestMain();
50
-
51
-        parser = mock(IRCParser.class);
52
-        server = mock(Server.class);
53
-        channel = mock(Channel.class);
54
-        channelinfo = mock(IRCChannelInfo.class);
55
-
56 55
         when(channel.getServer()).thenReturn(server);
57 56
         when(server.getParser()).thenReturn(parser);
58 57
         when(channel.getChannelInfo()).thenReturn(channelinfo);
59 58
         when(channelinfo.getName()).thenReturn("#chan");
60 59
 
61
-        command = new Names();
60
+        command = new Names(controller);
62 61
     }
63 62
 
64 63
     @Test
65 64
     public void testNormal() {
66
-        command.execute(null, new CommandArguments("/names"),
65
+        command.execute(null, new CommandArguments(controller, "/names"),
67 66
                 new ChannelCommandContext(null, Names.INFO, channel));
68 67
 
69 68
         verify(parser).sendRawMessage("NAMES #chan");
@@ -71,7 +70,8 @@ public class NamesTest {
71 70
 
72 71
     @Test
73 72
     public void testExternal() {
74
-        command.execute(null, server, "#chan", false, new CommandArguments("/names #chan"));
73
+        command.execute(null, server, "#chan", false,
74
+                new CommandArguments(controller, "/names #chan"));
75 75
 
76 76
         verify(parser).sendRawMessage("NAMES #chan");
77 77
     }

+ 12
- 13
test/com/dmdirc/commandparser/commands/channel/PartTest.java Vedi File

@@ -22,43 +22,42 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.channel;
24 24
 
25
-import com.dmdirc.TestMain;
26 25
 import com.dmdirc.Channel;
27 26
 import com.dmdirc.FrameContainer;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
30 29
 import com.dmdirc.config.ConfigManager;
31 30
 import com.dmdirc.config.InvalidIdentityFileException;
31
+import com.dmdirc.interfaces.CommandController;
32 32
 
33 33
 import org.junit.Before;
34 34
 import org.junit.Test;
35
+import org.junit.runner.RunWith;
36
+import org.mockito.Mock;
37
+import org.mockito.runners.MockitoJUnitRunner;
35 38
 
36 39
 import static org.mockito.Mockito.*;
37 40
 
41
+@RunWith(MockitoJUnitRunner.class)
38 42
 public class PartTest {
39 43
 
44
+    @Mock private Channel channel;
45
+    @Mock private FrameContainer origin;
46
+    @Mock private ConfigManager manager;
47
+    @Mock private CommandController controller;
40 48
     private Part command;
41
-    private Channel channel;
42
-    private FrameContainer origin;
43
-    private ConfigManager manager;
44 49
 
45 50
     @Before
46 51
     public void setUp() throws InvalidIdentityFileException {
47
-        TestMain.getTestMain();
48
-
49
-        channel = mock(Channel.class);
50
-        origin = mock(FrameContainer.class);
51
-        manager = mock(ConfigManager.class);
52
-
53 52
         when(origin.getConfigManager()).thenReturn(manager);
54 53
         when(manager.getOption("general", "partmessage")).thenReturn("config part message");
55 54
 
56
-        command = new Part();
55
+        command = new Part(controller);
57 56
     }
58 57
 
59 58
     @Test
60 59
     public void testWithoutArgs() {
61
-        command.execute(origin, new CommandArguments("/part"),
60
+        command.execute(origin, new CommandArguments(controller, "/part"),
62 61
                 new ChannelCommandContext(null, Part.INFO, channel));
63 62
 
64 63
         verify(channel).part("config part message");
@@ -67,7 +66,7 @@ public class PartTest {
67 66
 
68 67
     @Test
69 68
     public void testWithArgs() {
70
-        command.execute(origin, new CommandArguments("/part custom part"),
69
+        command.execute(origin, new CommandArguments(controller, "/part custom part"),
71 70
                 new ChannelCommandContext(null, Part.INFO, channel));
72 71
 
73 72
         verify(channel).part("custom part");

+ 12
- 15
test/com/dmdirc/commandparser/commands/chat/MeTest.java Vedi File

@@ -21,45 +21,42 @@
21 21
  */
22 22
 package com.dmdirc.commandparser.commands.chat;
23 23
 
24
-import com.dmdirc.TestMain;
25
-import com.dmdirc.FrameContainer;
26 24
 import com.dmdirc.MessageTarget;
27 25
 import com.dmdirc.commandparser.CommandArguments;
28 26
 import com.dmdirc.commandparser.commands.context.ChatCommandContext;
27
+import com.dmdirc.interfaces.CommandController;
29 28
 
30 29
 import org.junit.Before;
31
-import org.junit.BeforeClass;
32 30
 import org.junit.Test;
31
+import org.junit.runner.RunWith;
32
+import org.mockito.Mock;
33
+import org.mockito.runners.MockitoJUnitRunner;
33 34
 
34 35
 import static org.mockito.Mockito.*;
35 36
 
37
+@RunWith(MockitoJUnitRunner.class)
36 38
 public class MeTest {
37 39
 
38
-    private final Me command = new Me();
39
-    private MessageTarget mtt;
40
-
41
-    @BeforeClass
42
-    public static void setUpClass() throws Exception {
43
-        TestMain.getTestMain();
44
-    }
40
+    @Mock private MessageTarget mtt;
41
+    @Mock private CommandController controller;
42
+    private Me command;
45 43
 
46 44
     @Before
47 45
     public void setUp() {
48
-        mtt = mock(MessageTarget.class);
46
+        command = new Me(controller);
49 47
     }
50 48
 
51 49
     @Test
52 50
     public void testUsage() {
53
-        final FrameContainer tiw = mock(FrameContainer.class);
54
-        command.execute(tiw, new CommandArguments("/foo"),
51
+        command.execute(mtt, new CommandArguments(controller, "/foo"),
55 52
                 new ChatCommandContext(null, Me.INFO, mtt));
56 53
 
57
-        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
54
+        verify(mtt).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
58 55
     }
59 56
 
60 57
     @Test
61 58
     public void testSend() {
62
-        command.execute(null, new CommandArguments("/foo hello meep moop"),
59
+        command.execute(null, new CommandArguments(controller, "/foo hello meep moop"),
63 60
                 new ChatCommandContext(null, Me.INFO, mtt));
64 61
 
65 62
         verify(mtt).sendAction("hello meep moop");

+ 9
- 9
test/com/dmdirc/commandparser/commands/global/IfpluginTest.java Vedi File

@@ -22,34 +22,35 @@
22 22
 package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25
-import com.dmdirc.TestMain;
26 25
 import com.dmdirc.commandparser.CommandArguments;
27 26
 import com.dmdirc.commandparser.commands.context.CommandContext;
27
+import com.dmdirc.interfaces.CommandController;
28 28
 import com.dmdirc.plugins.PluginManager;
29 29
 
30 30
 import org.junit.Before;
31 31
 import org.junit.Test;
32
+import org.junit.runner.RunWith;
32 33
 import org.mockito.Mock;
33
-import org.mockito.MockitoAnnotations;
34
+import org.mockito.runners.MockitoJUnitRunner;
34 35
 
35 36
 import static org.mockito.Mockito.*;
36 37
 
38
+@RunWith(MockitoJUnitRunner.class)
37 39
 public class IfpluginTest {
38 40
 
41
+    @Mock private CommandController controller;
39 42
     @Mock private PluginManager pluginManager;
43
+    @Mock private FrameContainer tiw;
40 44
     private Ifplugin command;
41 45
 
42 46
     @Before
43 47
     public void setUp() {
44
-        MockitoAnnotations.initMocks(this);
45
-        TestMain.getTestMain();
46
-        command = new Ifplugin(pluginManager);
48
+        command = new Ifplugin(controller, pluginManager);
47 49
     }
48 50
 
49 51
     @Test
50 52
     public void testUsageNoArgs() {
51
-        final FrameContainer tiw = mock(FrameContainer.class);
52
-        command.execute(tiw, new CommandArguments("/foo"),
53
+        command.execute(tiw, new CommandArguments(controller, "/foo"),
53 54
                 new CommandContext(null, Ifplugin.INFO));
54 55
 
55 56
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
@@ -57,8 +58,7 @@ public class IfpluginTest {
57 58
 
58 59
     @Test
59 60
     public void testUsageOneArg() {
60
-        final FrameContainer tiw = mock(FrameContainer.class);
61
-        command.execute(tiw, new CommandArguments("/foo bar"),
61
+        command.execute(tiw, new CommandArguments(controller, "/foo bar"),
62 62
                 new CommandContext(null, Ifplugin.INFO));
63 63
 
64 64
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());

+ 11
- 11
test/com/dmdirc/commandparser/commands/global/NewServerTest.java Vedi File

@@ -23,16 +23,17 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.Server;
26
-import com.dmdirc.TestMain;
27 26
 import com.dmdirc.commandparser.CommandArguments;
28 27
 import com.dmdirc.commandparser.commands.context.CommandContext;
29 28
 import com.dmdirc.config.Identity;
29
+import com.dmdirc.interfaces.CommandController;
30 30
 import com.dmdirc.interfaces.IdentityController;
31 31
 import com.dmdirc.interfaces.ServerFactory;
32 32
 import com.dmdirc.plugins.PluginManager;
33 33
 
34 34
 import java.net.URI;
35 35
 import java.net.URISyntaxException;
36
+import java.util.Arrays;
36 37
 
37 38
 import org.junit.Before;
38 39
 import org.junit.Test;
@@ -40,12 +41,12 @@ import org.junit.runner.RunWith;
40 41
 import org.mockito.Mock;
41 42
 import org.mockito.runners.MockitoJUnitRunner;
42 43
 
43
-import clover.retrotranslator.edu.emory.mathcs.backport.java.util.Arrays;
44 44
 import static org.mockito.Mockito.*;
45 45
 
46 46
 @RunWith(MockitoJUnitRunner.class)
47 47
 public class NewServerTest {
48 48
 
49
+    @Mock private CommandController controller;
49 50
     @Mock private IdentityController identityController;
50 51
     @Mock private Identity identity;
51 52
     @Mock private FrameContainer container;
@@ -56,15 +57,14 @@ public class NewServerTest {
56 57
 
57 58
     @Before
58 59
     public void setup() {
59
-        TestMain.getTestMain();
60 60
         when(factory.createServer(any(URI.class), any(Identity.class))).thenReturn(server);
61 61
         when(identityController.getIdentitiesByType("profile")).thenReturn(Arrays.asList(new Identity[] { identity }));
62
-        command = new NewServer(factory, pluginManager, identityController);
62
+        command = new NewServer(controller, factory, pluginManager, identityController);
63 63
     }
64 64
 
65 65
     @Test
66 66
     public void testBasicUsage() throws URISyntaxException {
67
-        command.execute(container, new CommandArguments("/foo irc.foo.com"),
67
+        command.execute(container, new CommandArguments(controller, "/foo irc.foo.com"),
68 68
                 new CommandContext(null, NewServer.INFO));
69 69
 
70 70
         verify(factory).createServer(eq(new URI("irc://irc.foo.com:6667")), any(Identity.class));
@@ -73,7 +73,7 @@ public class NewServerTest {
73 73
 
74 74
     @Test
75 75
     public void testPortUsage() throws URISyntaxException {
76
-        command.execute(container, new CommandArguments("/foo irc.foo.com:1234"),
76
+        command.execute(container, new CommandArguments(controller, "/foo irc.foo.com:1234"),
77 77
                 new CommandContext(null, NewServer.INFO));
78 78
 
79 79
         verify(factory).createServer(eq(new URI("irc://irc.foo.com:1234")), any(Identity.class));
@@ -82,7 +82,7 @@ public class NewServerTest {
82 82
 
83 83
     @Test
84 84
     public void testUriUsage() throws URISyntaxException {
85
-        command.execute(container, new CommandArguments("/foo otheruri://foo.com:123/blah"),
85
+        command.execute(container, new CommandArguments(controller, "/foo otheruri://foo.com:123/blah"),
86 86
                 new CommandContext(null, NewServer.INFO));
87 87
 
88 88
         verify(factory).createServer(eq(new URI("otheruri://foo.com:123/blah")), any(Identity.class));
@@ -91,7 +91,7 @@ public class NewServerTest {
91 91
 
92 92
     @Test
93 93
     public void testUsageNoArgs() {
94
-        command.execute(container, new CommandArguments("/foo"),
94
+        command.execute(container, new CommandArguments(controller, "/foo"),
95 95
                 new CommandContext(null, NewServer.INFO));
96 96
 
97 97
         verify(container).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
@@ -99,7 +99,7 @@ public class NewServerTest {
99 99
 
100 100
     @Test
101 101
     public void testInvalidPort() {
102
-        command.execute(container, new CommandArguments("/foo foo:abc"),
102
+        command.execute(container, new CommandArguments(controller, "/foo foo:abc"),
103 103
                 new CommandContext(null, NewServer.INFO));
104 104
 
105 105
         verify(container).addLine(eq("commandError"), anyString());
@@ -107,7 +107,7 @@ public class NewServerTest {
107 107
 
108 108
     @Test
109 109
     public void testOutOfRangePort1() {
110
-        command.execute(container, new CommandArguments("/foo foo:0"),
110
+        command.execute(container, new CommandArguments(controller, "/foo foo:0"),
111 111
                 new CommandContext(null, NewServer.INFO));
112 112
 
113 113
         verify(container).addLine(eq("commandError"), anyString());
@@ -115,7 +115,7 @@ public class NewServerTest {
115 115
 
116 116
     @Test
117 117
     public void testOutOfRangePort2() {
118
-        command.execute(container, new CommandArguments("/foo foo:65537"),
118
+        command.execute(container, new CommandArguments(controller, "/foo foo:65537"),
119 119
                 new CommandContext(null, NewServer.INFO));
120 120
 
121 121
         verify(container).addLine(eq("commandError"), anyString());

+ 26
- 19
test/com/dmdirc/commandparser/commands/server/ChangeServerTest.java Vedi File

@@ -21,45 +21,52 @@
21 21
  */
22 22
 package com.dmdirc.commandparser.commands.server;
23 23
 
24
-import com.dmdirc.TestMain;
25 24
 import com.dmdirc.FrameContainer;
26 25
 import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.CommandArguments;
28 27
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
29 28
 import com.dmdirc.config.Identity;
29
+import com.dmdirc.interfaces.CommandController;
30
+import com.dmdirc.logger.ErrorManager;
31
+import com.dmdirc.logger.Logger;
30 32
 
31 33
 import java.net.URI;
32 34
 import java.net.URISyntaxException;
33 35
 
34 36
 import org.junit.Before;
35
-import org.junit.BeforeClass;
36 37
 import org.junit.Test;
38
+import org.junit.runner.RunWith;
39
+import org.mockito.Mock;
40
+import org.mockito.runners.MockitoJUnitRunner;
37 41
 
38 42
 import static org.mockito.Mockito.*;
39 43
 
44
+@RunWith(MockitoJUnitRunner.class)
40 45
 public class ChangeServerTest {
41 46
 
42
-    private final ChangeServer command = new ChangeServer();
43
-    private FrameContainer tiw;
44
-    private Identity profile;
45
-    private Server server;
46
-
47
-    @BeforeClass
48
-    public static void setUpClass() throws Exception {
49
-        TestMain.getTestMain();
50
-    }
47
+    @Mock private ErrorManager errorManager;
48
+    @Mock private CommandController controller;
49
+    @Mock private FrameContainer tiw;
50
+    @Mock private Identity profile;
51
+    @Mock private Server server;
52
+    private ChangeServer command;
51 53
 
52 54
     @Before
53 55
     public void setUp() {
56
+        Logger.setErrorManager(errorManager);
57
+
54 58
         tiw = mock(FrameContainer.class);
55 59
         profile = mock(Identity.class);
56 60
         server = mock(Server.class);
61
+
57 62
         when(server.getProfile()).thenReturn(profile);
63
+
64
+        command = new ChangeServer(controller);
58 65
     }
59 66
 
60 67
     @Test
61 68
     public void testUsageNoArgs() {
62
-        command.execute(tiw, new CommandArguments("/server"),
69
+        command.execute(tiw, new CommandArguments(controller, "/server"),
63 70
                 new ServerCommandContext(null, ChangeServer.INFO, server));
64 71
 
65 72
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
@@ -67,7 +74,7 @@ public class ChangeServerTest {
67 74
 
68 75
     @Test
69 76
     public void testInvalidPort() {
70
-        command.execute(tiw, new CommandArguments("/server foo:abc"),
77
+        command.execute(tiw, new CommandArguments(controller, "/server foo:abc"),
71 78
                 new ServerCommandContext(null, ChangeServer.INFO, server));
72 79
 
73 80
         verify(tiw).addLine(eq("commandError"), anyString());
@@ -75,7 +82,7 @@ public class ChangeServerTest {
75 82
 
76 83
     @Test
77 84
     public void testOutOfRangePort1() {
78
-        command.execute(tiw, new CommandArguments("/server foo:0"),
85
+        command.execute(tiw, new CommandArguments(controller, "/server foo:0"),
79 86
                 new ServerCommandContext(null, ChangeServer.INFO, server));
80 87
 
81 88
         verify(tiw).addLine(eq("commandError"), anyString());
@@ -83,7 +90,7 @@ public class ChangeServerTest {
83 90
 
84 91
     @Test
85 92
     public void testOutOfRangePort2() {
86
-        command.execute(tiw, new CommandArguments("/server foo:65537"),
93
+        command.execute(tiw, new CommandArguments(controller, "/server foo:65537"),
87 94
                 new ServerCommandContext(null, ChangeServer.INFO, server));
88 95
 
89 96
         verify(tiw).addLine(eq("commandError"), anyString());
@@ -91,7 +98,7 @@ public class ChangeServerTest {
91 98
 
92 99
     @Test
93 100
     public void testExecuteBasic() throws URISyntaxException {
94
-        command.execute(tiw, new CommandArguments("/server foo:1234"),
101
+        command.execute(tiw, new CommandArguments(controller, "/server foo:1234"),
95 102
                 new ServerCommandContext(null, ChangeServer.INFO, server));
96 103
 
97 104
         verify(server).connect(eq(new URI("irc://foo:1234")), same(profile));
@@ -99,7 +106,7 @@ public class ChangeServerTest {
99 106
 
100 107
     @Test
101 108
     public void testExecuteNoPort() throws URISyntaxException {
102
-        command.execute(tiw, new CommandArguments("/server foo"),
109
+        command.execute(tiw, new CommandArguments(controller, "/server foo"),
103 110
                 new ServerCommandContext(null, ChangeServer.INFO, server));
104 111
 
105 112
         verify(server).connect(eq(new URI("irc://foo:6667")), same(profile));
@@ -107,7 +114,7 @@ public class ChangeServerTest {
107 114
 
108 115
     @Test
109 116
     public void testDeprecatedSSL() throws URISyntaxException {
110
-        command.execute(tiw, new CommandArguments("/server --ssl foo"),
117
+        command.execute(tiw, new CommandArguments(controller, "/server --ssl foo"),
111 118
                 new ServerCommandContext(null, ChangeServer.INFO, server));
112 119
 
113 120
         verify(server).connect(eq(new URI("ircs://foo:6667")), same(profile));
@@ -115,7 +122,7 @@ public class ChangeServerTest {
115 122
 
116 123
     @Test
117 124
     public void testExecuteComplex() throws URISyntaxException {
118
-        command.execute(tiw, new CommandArguments("/server foo:+1234 password"),
125
+        command.execute(tiw, new CommandArguments(controller, "/server foo:+1234 password"),
119 126
                 new ServerCommandContext(null, ChangeServer.INFO, server));
120 127
 
121 128
         verify(server).connect(eq(new URI("ircs://password@foo:1234")), same(profile));

Loading…
Annulla
Salva