Преглед изворни кода

Introduce command contexts.

Fixes issue 4152
Fixes issue 4002

Change-Id: I664124ecb0994a808e2de359a38507c3b5f16452
Reviewed-on: http://gerrit.dmdirc.com/1250
Automatic-Compile: Shane Mc Cormack <shane@dmdirc.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.4rc1
Chris Smith пре 14 година
родитељ
комит
2edf699e02
85 измењених фајлова са 1858 додато и 923 уклоњено
  1. 1
    1
      src/com/dmdirc/Channel.java
  2. 3
    9
      src/com/dmdirc/GlobalWindow.java
  3. 1
    1
      src/com/dmdirc/Query.java
  4. 9
    1
      src/com/dmdirc/actions/ActionModel.java
  5. 70
    0
      src/com/dmdirc/commandparser/CommandInfoPair.java
  6. 2
    0
      src/com/dmdirc/commandparser/CommandType.java
  7. 4
    19
      src/com/dmdirc/commandparser/commands/ChannelCommand.java
  8. 3
    17
      src/com/dmdirc/commandparser/commands/ChatCommand.java
  9. 13
    0
      src/com/dmdirc/commandparser/commands/Command.java
  10. 2
    13
      src/com/dmdirc/commandparser/commands/GlobalCommand.java
  11. 2
    17
      src/com/dmdirc/commandparser/commands/QueryCommand.java
  12. 2
    15
      src/com/dmdirc/commandparser/commands/ServerCommand.java
  13. 28
    18
      src/com/dmdirc/commandparser/commands/channel/Ban.java
  14. 17
    8
      src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java
  15. 15
    6
      src/com/dmdirc/commandparser/commands/channel/Cycle.java
  16. 19
    8
      src/com/dmdirc/commandparser/commands/channel/KickReason.java
  17. 19
    7
      src/com/dmdirc/commandparser/commands/channel/Mode.java
  18. 19
    6
      src/com/dmdirc/commandparser/commands/channel/Names.java
  19. 15
    5
      src/com/dmdirc/commandparser/commands/channel/Part.java
  20. 21
    9
      src/com/dmdirc/commandparser/commands/channel/SetNickColour.java
  21. 19
    7
      src/com/dmdirc/commandparser/commands/channel/ShowTopic.java
  22. 105
    96
      src/com/dmdirc/commandparser/commands/chat/Me.java
  23. 61
    0
      src/com/dmdirc/commandparser/commands/context/ChannelCommandContext.java
  24. 61
    0
      src/com/dmdirc/commandparser/commands/context/ChatCommandContext.java
  25. 72
    0
      src/com/dmdirc/commandparser/commands/context/CommandContext.java
  26. 61
    0
      src/com/dmdirc/commandparser/commands/context/QueryCommandContext.java
  27. 62
    0
      src/com/dmdirc/commandparser/commands/context/ServerCommandContext.java
  28. 15
    5
      src/com/dmdirc/commandparser/commands/global/Active.java
  29. 19
    10
      src/com/dmdirc/commandparser/commands/global/AliasCommand.java
  30. 15
    5
      src/com/dmdirc/commandparser/commands/global/AllServers.java
  31. 14
    4
      src/com/dmdirc/commandparser/commands/global/Clear.java
  32. 28
    19
      src/com/dmdirc/commandparser/commands/global/Debug.java
  33. 19
    9
      src/com/dmdirc/commandparser/commands/global/Echo.java
  34. 13
    4
      src/com/dmdirc/commandparser/commands/global/Exit.java
  35. 177
    170
      src/com/dmdirc/commandparser/commands/global/Help.java
  36. 17
    7
      src/com/dmdirc/commandparser/commands/global/Ifplugin.java
  37. 19
    11
      src/com/dmdirc/commandparser/commands/global/Input.java
  38. 19
    9
      src/com/dmdirc/commandparser/commands/global/LoadPlugin.java
  39. 19
    9
      src/com/dmdirc/commandparser/commands/global/NewServer.java
  40. 16
    6
      src/com/dmdirc/commandparser/commands/global/Notify.java
  41. 18
    9
      src/com/dmdirc/commandparser/commands/global/OpenWindow.java
  42. 15
    5
      src/com/dmdirc/commandparser/commands/global/ReloadActions.java
  43. 15
    5
      src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java
  44. 21
    9
      src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java
  45. 15
    5
      src/com/dmdirc/commandparser/commands/global/SaveConfig.java
  46. 54
    45
      src/com/dmdirc/commandparser/commands/global/Set.java
  47. 18
    8
      src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java
  48. 17
    5
      src/com/dmdirc/commandparser/commands/server/AllChannels.java
  49. 15
    4
      src/com/dmdirc/commandparser/commands/server/Away.java
  50. 16
    11
      src/com/dmdirc/commandparser/commands/server/Back.java
  51. 17
    6
      src/com/dmdirc/commandparser/commands/server/ChangeServer.java
  52. 19
    13
      src/com/dmdirc/commandparser/commands/server/Ctcp.java
  53. 16
    11
      src/com/dmdirc/commandparser/commands/server/Disconnect.java
  54. 36
    30
      src/com/dmdirc/commandparser/commands/server/Ignore.java
  55. 18
    7
      src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java
  56. 20
    9
      src/com/dmdirc/commandparser/commands/server/Message.java
  57. 17
    5
      src/com/dmdirc/commandparser/commands/server/Nick.java
  58. 18
    6
      src/com/dmdirc/commandparser/commands/server/Notice.java
  59. 18
    7
      src/com/dmdirc/commandparser/commands/server/OpenQuery.java
  60. 16
    5
      src/com/dmdirc/commandparser/commands/server/Raw.java
  61. 15
    4
      src/com/dmdirc/commandparser/commands/server/RawServerCommand.java
  62. 15
    4
      src/com/dmdirc/commandparser/commands/server/Reconnect.java
  63. 16
    5
      src/com/dmdirc/commandparser/commands/server/Umode.java
  64. 18
    29
      src/com/dmdirc/commandparser/parsers/ChannelCommandParser.java
  65. 90
    0
      src/com/dmdirc/commandparser/parsers/ChatCommandParser.java
  66. 29
    20
      src/com/dmdirc/commandparser/parsers/CommandParser.java
  67. 8
    5
      src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java
  68. 17
    27
      src/com/dmdirc/commandparser/parsers/QueryCommandParser.java
  69. 14
    9
      src/com/dmdirc/commandparser/parsers/ServerCommandParser.java
  70. 2
    1
      src/com/dmdirc/ui/input/InputHandler.java
  71. 1
    1
      src/com/dmdirc/ui/input/TabCompleter.java
  72. 5
    1
      test/com/dmdirc/commandparser/commands/channel/BanTest.java
  73. 10
    4
      test/com/dmdirc/commandparser/commands/channel/KickReasonTest.java
  74. 8
    4
      test/com/dmdirc/commandparser/commands/channel/ModeTest.java
  75. 4
    1
      test/com/dmdirc/commandparser/commands/channel/NamesTest.java
  76. 5
    2
      test/com/dmdirc/commandparser/commands/channel/PartTest.java
  77. 16
    3
      test/com/dmdirc/commandparser/commands/channel/SetNickColourTest.java
  78. 15
    5
      test/com/dmdirc/commandparser/commands/chat/MeTest.java
  79. 7
    4
      test/com/dmdirc/commandparser/commands/global/AliasCommandTest.java
  80. 7
    4
      test/com/dmdirc/commandparser/commands/global/DebugTest.java
  81. 7
    4
      test/com/dmdirc/commandparser/commands/global/IfpluginTest.java
  82. 9
    4
      test/com/dmdirc/commandparser/commands/global/NewServerTest.java
  83. 30
    33
      test/com/dmdirc/commandparser/commands/server/ChangeServerTest.java
  84. 10
    10
      test/com/dmdirc/commandparser/parsers/CommandParserTest.java
  85. 5
    3
      test/com/dmdirc/harness/TestCommandParser.java

+ 1
- 1
src/com/dmdirc/Channel.java Прегледај датотеку

@@ -99,7 +99,7 @@ public class Channel extends MessageTarget<ChannelWindow> implements ConfigChang
99 99
                 ChannelWindow.class,
100 100
                 new ConfigManager(newServer.getProtocol(), newServer.getIrcd(),
101 101
                 newServer.getNetwork(), newServer.getAddress(), newChannelInfo.getName()),
102
-                new ChannelCommandParser());
102
+                new ChannelCommandParser(newServer));
103 103
 
104 104
         channelInfo = newChannelInfo;
105 105
         server = newServer;

+ 3
- 9
src/com/dmdirc/GlobalWindow.java Прегледај датотеку

@@ -94,10 +94,7 @@ public class GlobalWindow extends WritableFrameContainer<InputWindow> {
94 94
     /** {@inheritDoc} */
95 95
     @Override
96 96
     public void sendLine(final String line) {
97
-        if (!line.isEmpty()) {
98
-            GlobalCommandParser.getGlobalCommandParser().parseCommand(this,
99
-                    CommandManager.getCommandChar() + line);
100
-        }
97
+        addLine("commandError", "You may only enter commands in the global window.");
101 98
     }
102 99
 
103 100
     /** {@inheritDoc} */
@@ -106,11 +103,8 @@ public class GlobalWindow extends WritableFrameContainer<InputWindow> {
106 103
         return -1;
107 104
     }
108 105
 
109
-    /**
110
-     * Retrieves the tab completer used by this global window.
111
-     *
112
-     * @return This global window's tab completer.
113
-     */
106
+    /** {@inheritDoc} */
107
+    @Override
114 108
     public TabCompleter getTabCompleter() {
115 109
         return tabCompleter;
116 110
     }

+ 1
- 1
src/com/dmdirc/Query.java Прегледај датотеку

@@ -74,7 +74,7 @@ public class Query extends MessageTarget<QueryWindow> implements PrivateActionLi
74 74
         super("query", newServer.parseHostmask(newHost)[0],
75 75
                 newServer.parseHostmask(newHost)[0],
76 76
                 QueryWindow.class, newServer.getConfigManager(),
77
-                new QueryCommandParser());
77
+                new QueryCommandParser(newServer));
78 78
 
79 79
         this.server = newServer;
80 80
         this.host = newHost;

+ 9
- 1
src/com/dmdirc/actions/ActionModel.java Прегледај датотеку

@@ -30,6 +30,7 @@ import com.dmdirc.WritableFrameContainer;
30 30
 import com.dmdirc.commandparser.parsers.CommandParser;
31 31
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
32 32
 import com.dmdirc.ui.WindowManager;
33
+import com.dmdirc.ui.interfaces.Window;
33 34
 
34 35
 import java.util.ArrayList;
35 36
 import java.util.Arrays;
@@ -132,6 +133,7 @@ public class ActionModel {
132 133
         }
133 134
 
134 135
         final FrameContainer<?> active = WindowManager.getActiveWindow();
136
+        Window window = null;
135 137
         WritableFrameContainer<?> cw = null;
136 138
         CommandParser cp = null;
137 139
 
@@ -143,6 +145,12 @@ public class ActionModel {
143 145
             cw = ServerManager.getServerManager().getServers().get(0);
144 146
         }
145 147
 
148
+        if (arguments.length > 0 && arguments[0] instanceof Window) {
149
+            window = (Window) arguments[0];
150
+        } else {
151
+            window = cw.getFrame();
152
+        }
153
+
146 154
         if (cw == null) {
147 155
             cp = GlobalCommandParser.getGlobalCommandParser();
148 156
         } else {
@@ -150,7 +158,7 @@ public class ActionModel {
150 158
         }
151 159
 
152 160
         for (String command : response) {
153
-            cp.parseCommand(cw, sub.doSubstitution(command, arguments));
161
+            cp.parseCommand(cw, window, sub.doSubstitution(command, arguments));
154 162
         }
155 163
 
156 164
         if (newFormat != null && format != null) {

+ 70
- 0
src/com/dmdirc/commandparser/CommandInfoPair.java Прегледај датотеку

@@ -0,0 +1,70 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser;
24
+
25
+import com.dmdirc.commandparser.commands.Command;
26
+
27
+/**
28
+ * A combination of a {@link Command} and the {@link CommandInfo} which
29
+ * triggered it.
30
+ *
31
+ * @since 0.6.4
32
+ * @author chris
33
+ */
34
+public class CommandInfoPair {
35
+
36
+    /** The command info which caused the command to be triggered. */
37
+    private final CommandInfo commandInfo;
38
+    /** The command in question. */
39
+    private final Command command;
40
+
41
+    /**
42
+     * Creates a new CommandInfoPair.
43
+     *
44
+     * @param commandInfo The command info associated with the command
45
+     * @param command The command
46
+     */
47
+    public CommandInfoPair(final CommandInfo commandInfo, final Command command) {
48
+        this.commandInfo = commandInfo;
49
+        this.command = command;
50
+    }
51
+
52
+    /**
53
+     * Retrieves the command part of this pair.
54
+     *
55
+     * @return This pair's command
56
+     */
57
+    public Command getCommand() {
58
+        return command;
59
+    }
60
+
61
+    /**
62
+     * Retrieves the commandinfo part of this pair.
63
+     *
64
+     * @return This pair's commandinfo
65
+     */
66
+    public CommandInfo getCommandInfo() {
67
+        return commandInfo;
68
+    }
69
+
70
+}

+ 2
- 0
src/com/dmdirc/commandparser/CommandType.java Прегледај датотеку

@@ -53,7 +53,9 @@ public enum CommandType {
53 53
      * 
54 54
      * @param command The command to look up
55 55
      * @return The type of the specified command
56
+     * @deprecated Shouldn't be required any longer
56 57
      */
58
+    @Deprecated
57 59
     public static CommandType fromCommand(final Command command) {
58 60
         if (command instanceof GlobalCommand) {
59 61
             return TYPE_GLOBAL;

+ 4
- 19
src/com/dmdirc/commandparser/commands/ChannelCommand.java Прегледај датотеку

@@ -22,37 +22,22 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
-import com.dmdirc.Channel;
26
-import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28
-import com.dmdirc.commandparser.CommandArguments;
29 25
 import com.dmdirc.commandparser.CommandInfo;
30 26
 import com.dmdirc.commandparser.CommandType;
31
-import com.dmdirc.ui.interfaces.InputWindow;
32 27
 
33 28
 /**
34 29
  * Represents a command which can be performed only in the context of a channel.
30
+ *
31
+ * @deprecated Commands should extend {@link Command} directly
35 32
  * @author chris
36 33
  */
34
+@Deprecated
37 35
 public abstract class ChannelCommand extends Command implements CommandInfo {
38
-    
39
-    /**
40
-     * Executes this command.
41
-     *
42
-     * @param origin The window in which the command was typed
43
-     * @param server The server instance that this command is being executed on
44
-     * @param channel The channel instance that this command is being executed on
45
-     * @param isSilent Whether this command is silenced or not
46
-     * @param args Arguments passed to this command
47
-     * @since 0.6.3m1
48
-     */
49
-    public abstract void execute(FrameContainer<?> origin, Server server, Channel channel,
50
-            boolean isSilent, CommandArguments args);
51 36
 
52 37
     /** {@inheritDoc} */
53 38
     @Override
54 39
     public CommandType getType() {
55 40
         return CommandType.TYPE_CHANNEL;
56 41
     }
57
-    
42
+
58 43
 }

+ 3
- 17
src/com/dmdirc/commandparser/commands/ChatCommand.java Прегледај датотеку

@@ -22,10 +22,6 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.MessageTarget;
27
-import com.dmdirc.Server;
28
-import com.dmdirc.commandparser.CommandArguments;
29 25
 import com.dmdirc.commandparser.CommandInfo;
30 26
 import com.dmdirc.commandparser.CommandType;
31 27
 
@@ -33,26 +29,16 @@ import com.dmdirc.commandparser.CommandType;
33 29
  * Represents a command that can be performed in the context of a "chat" window
34 30
  * (i.e., a channel or a query).
35 31
  *
32
+ * @deprecated Commands should extend {@link Command} directly
36 33
  * @author Chris
37 34
  */
35
+@Deprecated
38 36
 public abstract class ChatCommand extends Command implements CommandInfo {
39
-    
40
-    /**
41
-     * Executes this command.
42
-     * 
43
-     * @param origin The window in which the command was typed
44
-     * @param server The server instance that this command is being executed on
45
-     * @param target The target of this command
46
-     * @param isSilent Whether this command is silenced or not
47
-     * @param args Arguments passed to this command
48
-     * @since 0.6.3m1
49
-     */
50
-    public abstract void execute(FrameContainer<?> origin, Server server, MessageTarget<?> target,
51
-            boolean isSilent, CommandArguments args);
52 37
 
53 38
     /** {@inheritDoc} */
54 39
     @Override
55 40
     public CommandType getType() {
56 41
         return CommandType.TYPE_CHAT;
57 42
     }
43
+
58 44
 }

+ 13
- 0
src/com/dmdirc/commandparser/commands/Command.java Прегледај датотеку

@@ -23,7 +23,9 @@
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
28
+import com.dmdirc.commandparser.commands.context.CommandContext;
27 29
 import com.dmdirc.ui.messages.Styliser;
28 30
 
29 31
 /**
@@ -122,4 +124,15 @@ public abstract class Command {
122 124
         }
123 125
     }
124 126
 
127
+    /**
128
+     * Executes this command.
129
+     *
130
+     * @param origin The container which received the command
131
+     * @param args Arguments passed to this command
132
+     * @param context The context the command was executed in
133
+     * @since 0.6.4
134
+     */
135
+    public abstract void execute(FrameContainer<?> origin,
136
+            CommandArguments args, CommandContext context);
137
+
125 138
 }

+ 2
- 13
src/com/dmdirc/commandparser/commands/GlobalCommand.java Прегледај датотеку

@@ -22,8 +22,6 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.commandparser.CommandArguments;
27 25
 import com.dmdirc.commandparser.CommandInfo;
28 26
 import com.dmdirc.commandparser.CommandType;
29 27
 
@@ -31,21 +29,12 @@ import com.dmdirc.commandparser.CommandType;
31 29
  * Represents a generic global command. Global commands are associated with
32 30
  * no servers.
33 31
  *
32
+ * @deprecated Commands should extend {@link Command} directly
34 33
  * @author chris
35 34
  */
35
+@Deprecated
36 36
 public abstract class GlobalCommand extends Command implements CommandInfo {
37 37
         
38
-    /**
39
-     * Executes this command. Note that for global commands, origin may be
40
-     * null.
41
-     *
42
-     * @param origin The window in which the command was typed
43
-     * @param isSilent Whether this command is silenced or not
44
-     * @param args Arguments passed to this command
45
-     * @since 0.6.3m1
46
-     */
47
-    public abstract void execute(FrameContainer<?> origin, boolean isSilent, CommandArguments args);
48
-
49 38
     /** {@inheritDoc} */
50 39
     @Override
51 40
     public CommandType getType() {

+ 2
- 17
src/com/dmdirc/commandparser/commands/QueryCommand.java Прегледај датотеку

@@ -22,33 +22,18 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Query;
27
-import com.dmdirc.Server;
28
-import com.dmdirc.commandparser.CommandArguments;
29 25
 import com.dmdirc.commandparser.CommandInfo;
30 26
 import com.dmdirc.commandparser.CommandType;
31 27
 
32 28
 /**
33 29
  * Represents a command which can be performed only in the context of a query.
34 30
  *
31
+ * @deprecated Commands should extend {@link Command} directly
35 32
  * @author chris
36 33
  */
34
+@Deprecated
37 35
 public abstract class QueryCommand extends Command implements CommandInfo {
38 36
         
39
-    /**
40
-     * Executes this command.
41
-     *
42
-     * @param origin The window in which the command was typed
43
-     * @param server The server instance that this command is being executed on
44
-     * @param query The query object that the commadparser is associated with
45
-     * @param isSilent Whether this command is silenced or not
46
-     * @param args Arguments passed to this command
47
-     * @since 0.6.3m1
48
-     */
49
-    public abstract void execute(FrameContainer<?> origin, Server server, Query query,
50
-            boolean isSilent, CommandArguments args);
51
-
52 37
     /** {@inheritDoc} */
53 38
     @Override
54 39
     public CommandType getType() {

+ 2
- 15
src/com/dmdirc/commandparser/commands/ServerCommand.java Прегледај датотеку

@@ -22,9 +22,6 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27
-import com.dmdirc.commandparser.CommandArguments;
28 25
 import com.dmdirc.commandparser.CommandInfo;
29 26
 import com.dmdirc.commandparser.CommandType;
30 27
 
@@ -32,22 +29,12 @@ import com.dmdirc.commandparser.CommandType;
32 29
  * Represents a generic server command. Server commands are associated with
33 30
  * a server instance.
34 31
  *
32
+ * @deprecated Commands should extend {@link Command} directly
35 33
  * @author chris
36 34
  */
35
+@Deprecated
37 36
 public abstract class ServerCommand extends Command implements CommandInfo {
38 37
     
39
-    /**
40
-     * Executes this command.
41
-     *
42
-     * @param origin The window in which the command was typed
43
-     * @param server The server instance that this command is being executed on
44
-     * @param isSilent Whether this command is silenced or not
45
-     * @param args Arguments passed to this command
46
-     * @since 0.6.3m1
47
-     */
48
-    public abstract void execute(FrameContainer<?> origin, Server server,
49
-            boolean isSilent, CommandArguments args);
50
-
51 38
     /** {@inheritDoc} */
52 39
     @Override
53 40
     public CommandType getType() {

+ 28
- 18
src/com/dmdirc/commandparser/commands/channel/Ban.java Прегледај датотеку

@@ -24,61 +24,72 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChannelCommand;
28
+import com.dmdirc.commandparser.CommandInfo;
30 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
31 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
33 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 37
 import com.dmdirc.ui.input.TabCompletionType;
35 38
 
36 39
 /**
37 40
  * The kick command bans a specified user or host from the channel.
38
- * 
41
+ *
39 42
  * @author chris
40 43
  */
41
-public final class Ban extends ChannelCommand implements IntelligentCommand {
42
-    
44
+public final class Ban extends Command implements IntelligentCommand, CommandInfo {
45
+
43 46
     /** Creates a new instance of Ban. */
44 47
     public Ban() {
45 48
         super();
46
-        
49
+
47 50
         CommandManager.registerCommand(this);
48 51
     }
49
-    
52
+
50 53
     /** {@inheritDoc} */
51 54
     @Override
52
-    public void execute(final FrameContainer<?> origin, final Server server,
53
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
55
+    public void execute(final FrameContainer<?> origin,
56
+            final CommandArguments args, final CommandContext context) {
57
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
58
+
54 59
         if (args.getArguments().length == 0) {
55
-            showUsage(origin, isSilent, "ban", "<user|host>");
60
+            showUsage(origin, args.isSilent(), "ban", "<user|host>");
56 61
             return;
57 62
         }
58
-        
63
+
59 64
         String host = args.getArguments()[0];
60 65
         final ChannelClientInfo user = channel.getChannelInfo().getChannelClient(host);
61 66
         if (user != null && !user.getClient().getHostname().isEmpty()) {
62 67
             // TODO: Customisable ban masks, somehow.
63 68
             host = "*!*@" + user.getClient().getHostname();
64 69
         }
65
-        
70
+
66 71
         channel.getChannelInfo().alterMode(true, 'b', host);
67 72
         channel.getChannelInfo().flushModes();
68 73
     }
69
-    
74
+
70 75
     /** {@inheritDoc} */
71 76
     @Override
72 77
     public String getName() {
73 78
         return "ban";
74 79
     }
75
-    
80
+
76 81
     /** {@inheritDoc} */
77 82
     @Override
78 83
     public boolean showInHelp() {
79 84
         return true;
80 85
     }
81
-    
86
+
87
+    /** {@inheritDoc} */
88
+    @Override
89
+    public CommandType getType() {
90
+        return CommandType.TYPE_CHANNEL;
91
+    }
92
+
82 93
     /** {@inheritDoc} */
83 94
     @Override
84 95
     public String getHelp() {
@@ -90,12 +101,11 @@ public final class Ban extends ChannelCommand implements IntelligentCommand {
90 101
     public AdditionalTabTargets getSuggestions(final int arg,
91 102
             final IntelligentCommandContext context) {
92 103
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
93
-        
104
+
94 105
         if (arg == 0) {
95 106
             res.include(TabCompletionType.CHANNEL_NICK);
96 107
         }
97
-        
108
+
98 109
         return res;
99 110
     }
100
-    
101 111
 }

+ 17
- 8
src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java Прегледај датотеку

@@ -22,15 +22,16 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.channel;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Main;
28
-import com.dmdirc.Server;
29 26
 import com.dmdirc.commandparser.CommandArguments;
30
-import com.dmdirc.commandparser.commands.ChannelCommand;
27
+import com.dmdirc.commandparser.CommandInfo;
31 28
 import com.dmdirc.commandparser.CommandManager;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
32 31
 import com.dmdirc.commandparser.commands.CommandOptions;
33 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
34 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 36
 
36 37
 /**
@@ -38,7 +39,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
38 39
  * @author chris
39 40
  */
40 41
 @CommandOptions(allowOffline=false)
41
-public final class ChannelSettings extends ChannelCommand implements IntelligentCommand {
42
+public final class ChannelSettings extends Command implements
43
+        IntelligentCommand, CommandInfo {
42 44
     
43 45
     /** Creates a new instance of ChannelSettings. */
44 46
     public ChannelSettings() {
@@ -49,9 +51,10 @@ public final class ChannelSettings extends ChannelCommand implements Intelligent
49 51
     
50 52
     /** {@inheritDoc} */
51 53
     @Override
52
-    public void execute(final FrameContainer<?> origin, final Server server,
53
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
54
-        Main.getUI().showChannelSettingsDialog(channel);
54
+    public void execute(final FrameContainer<?> origin,
55
+            final CommandArguments args, final CommandContext context) {
56
+        context.getSource().getController().showChannelSettingsDialog(
57
+                ((ChannelCommandContext) context).getChannel());
55 58
     }
56 59
     
57 60
     /** {@inheritDoc} */
@@ -65,6 +68,12 @@ public final class ChannelSettings extends ChannelCommand implements Intelligent
65 68
     public boolean showInHelp() {
66 69
         return true;
67 70
     }
71
+
72
+    /** {@inheritDoc} */
73
+    @Override
74
+    public CommandType getType() {
75
+        return CommandType.TYPE_CHANNEL;
76
+    }
68 77
     
69 78
     /** {@inheritDoc} */
70 79
     @Override

+ 15
- 6
src/com/dmdirc/commandparser/commands/channel/Cycle.java Прегледај датотеку

@@ -24,11 +24,14 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChannelCommand;
28
+import com.dmdirc.commandparser.CommandInfo;
29
+import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.CommandManager;
31
+import com.dmdirc.commandparser.commands.Command;
31 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 
33 36
 /**
34 37
  * The cycle command allows users to rapidly part and rejoin a channel.
@@ -36,7 +39,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
36 39
  * @author chris
37 40
  */
38 41
 @CommandOptions(allowOffline=false)
39
-public final class Cycle extends ChannelCommand {
42
+public final class Cycle extends Command implements CommandInfo {
40 43
     
41 44
     /** Creates a new instance of Cycle. */
42 45
     public Cycle() {
@@ -47,8 +50,9 @@ public final class Cycle extends ChannelCommand {
47 50
     
48 51
     /** {@inheritDoc} */
49 52
     @Override
50
-    public void execute(final FrameContainer<?> origin, final Server server,
51
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
53
+    public void execute(final FrameContainer<?> origin,
54
+            final CommandArguments args, final CommandContext context) {
55
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
52 56
         channel.part(args.getArguments().length > 0 ? args.getArgumentsAsString()
53 57
                 : origin.getConfigManager().getOption("general", "cyclemessage"));
54 58
         channel.join();
@@ -65,11 +69,16 @@ public final class Cycle extends ChannelCommand {
65 69
     public boolean showInHelp() {
66 70
         return true;
67 71
     }
72
+
73
+    /** {@inheritDoc} */
74
+    @Override
75
+    public CommandType getType() {
76
+        return CommandType.TYPE_CHANNEL;
77
+    }
68 78
     
69 79
     /** {@inheritDoc} */
70 80
     @Override
71 81
     public String getHelp() {
72 82
         return "cycle [message] - parts and rejoins the channel";
73 83
     }
74
-    
75 84
 }

+ 19
- 8
src/com/dmdirc/commandparser/commands/channel/KickReason.java Прегледај датотеку

@@ -24,12 +24,15 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChannelCommand;
28
+import com.dmdirc.commandparser.CommandInfo;
30 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
31 32
 import com.dmdirc.commandparser.commands.CommandOptions;
32 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
35
+import com.dmdirc.commandparser.commands.context.CommandContext;
33 36
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
34 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
 import com.dmdirc.ui.input.TabCompletionType;
@@ -40,7 +43,8 @@ import com.dmdirc.ui.input.TabCompletionType;
40 43
  * @author chris
41 44
  */
42 45
 @CommandOptions(allowOffline=false)
43
-public final class KickReason extends ChannelCommand implements IntelligentCommand {
46
+public final class KickReason extends Command implements IntelligentCommand,
47
+        CommandInfo {
44 48
     
45 49
     /** Creates a new instance of KickReason. */
46 50
     public KickReason() {
@@ -51,10 +55,11 @@ public final class KickReason extends ChannelCommand implements IntelligentComma
51 55
     
52 56
     /** {@inheritDoc} */
53 57
     @Override
54
-    public void execute(final FrameContainer<?> origin, final Server server,
55
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
58
+    public void execute(final FrameContainer<?> origin,
59
+            final CommandArguments args, final CommandContext context) {
60
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
56 61
         if (args.getArguments().length == 0) {
57
-            showUsage(origin, isSilent, "kick", "<user> [reason]");
62
+            showUsage(origin, args.isSilent(), "kick", "<user> [reason]");
58 63
             return;
59 64
         }
60 65
         
@@ -62,7 +67,7 @@ public final class KickReason extends ChannelCommand implements IntelligentComma
62 67
                 .getArguments()[0]);
63 68
         
64 69
         if (victim == null) {
65
-            sendLine(origin, isSilent, FORMAT_ERROR, "User not found: "
70
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "User not found: "
66 71
                     + args.getArguments()[0]);
67 72
         } else {
68 73
             victim.kick(args.getArguments().length > 1 ? args.getArgumentsAsString(1) :
@@ -81,6 +86,12 @@ public final class KickReason extends ChannelCommand implements IntelligentComma
81 86
     public boolean showInHelp() {
82 87
         return true;
83 88
     }
89
+
90
+    /** {@inheritDoc} */
91
+    @Override
92
+    public CommandType getType() {
93
+        return CommandType.TYPE_CHANNEL;
94
+    }
84 95
     
85 96
     /** {@inheritDoc} */
86 97
     @Override
@@ -100,6 +111,6 @@ public final class KickReason extends ChannelCommand implements IntelligentComma
100 111
         }
101 112
         
102 113
         return res;
103
-    }    
114
+    }
104 115
     
105 116
 }

+ 19
- 7
src/com/dmdirc/commandparser/commands/channel/Mode.java Прегледај датотеку

@@ -26,11 +26,15 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChannelCommand;
29
+import com.dmdirc.commandparser.CommandInfo;
30
+import com.dmdirc.commandparser.CommandType;
30 31
 import com.dmdirc.commandparser.CommandManager;
32
+import com.dmdirc.commandparser.commands.Command;
31 33
 import com.dmdirc.commandparser.commands.CommandOptions;
32 34
 import com.dmdirc.commandparser.commands.ExternalCommand;
33 35
 import com.dmdirc.commandparser.commands.IntelligentCommand;
36
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
37
+import com.dmdirc.commandparser.commands.context.CommandContext;
34 38
 import com.dmdirc.parser.interfaces.ChannelInfo;
35 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
36 40
 import com.dmdirc.ui.input.TabCompletionType;
@@ -40,8 +44,8 @@ import com.dmdirc.ui.input.TabCompletionType;
40 44
  * @author chris
41 45
  */
42 46
 @CommandOptions(allowOffline=false)
43
-public final class Mode extends ChannelCommand implements IntelligentCommand,
44
-        ExternalCommand {
47
+public final class Mode extends Command implements IntelligentCommand,
48
+        ExternalCommand, CommandInfo {
45 49
 
46 50
     /** Creates a new instance of Mode. */
47 51
     public Mode() {
@@ -52,14 +56,16 @@ public final class Mode extends ChannelCommand implements IntelligentCommand,
52 56
 
53 57
     /** {@inheritDoc} */
54 58
     @Override
55
-    public void execute(final FrameContainer<?> origin, final Server server,
56
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
59
+    public void execute(final FrameContainer<?> origin,
60
+            final CommandArguments args, final CommandContext context) {
61
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
57 62
         final ChannelInfo cChannel = channel.getChannelInfo();
58 63
 
59 64
         if (args.getArguments().length == 0) {
60
-            sendLine(origin, isSilent, "channelModeDiscovered", cChannel.getModes(), cChannel);
65
+            sendLine(origin, args.isSilent(), "channelModeDiscovered", cChannel.getModes(), cChannel);
61 66
         } else {
62
-            server.getParser().sendRawMessage("MODE " + cChannel + " " + args.getArgumentsAsString());
67
+            channel.getServer().getParser().sendRawMessage("MODE "
68
+                    + cChannel + " " + args.getArgumentsAsString());
63 69
         }
64 70
     }
65 71
 
@@ -86,6 +92,12 @@ public final class Mode extends ChannelCommand implements IntelligentCommand,
86 92
         return true;
87 93
     }
88 94
 
95
+    /** {@inheritDoc} */
96
+    @Override
97
+    public CommandType getType() {
98
+        return CommandType.TYPE_CHANNEL;
99
+    }
100
+
89 101
     /** {@inheritDoc} */
90 102
     @Override
91 103
     public String getHelp() {

+ 19
- 6
src/com/dmdirc/commandparser/commands/channel/Names.java Прегледај датотеку

@@ -26,11 +26,15 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
29 30
 import com.dmdirc.commandparser.CommandManager;
30
-import com.dmdirc.commandparser.commands.ChannelCommand;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
31 33
 import com.dmdirc.commandparser.commands.CommandOptions;
32 34
 import com.dmdirc.commandparser.commands.ExternalCommand;
33 35
 import com.dmdirc.commandparser.commands.IntelligentCommand;
36
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
37
+import com.dmdirc.commandparser.commands.context.CommandContext;
34 38
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 39
 
36 40
 /**
@@ -39,7 +43,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
39 43
  * @author chris
40 44
  */
41 45
 @CommandOptions(allowOffline=false)
42
-public class Names extends ChannelCommand implements IntelligentCommand, ExternalCommand {
46
+public class Names extends Command implements IntelligentCommand, 
47
+        ExternalCommand, CommandInfo {
43 48
     
44 49
     /**
45 50
      * Creates a new instance of Names.
@@ -52,9 +57,11 @@ public class Names extends ChannelCommand implements IntelligentCommand, Externa
52 57
 
53 58
     /** {@inheritDoc} */
54 59
     @Override
55
-    public void execute(final FrameContainer<?> origin, final Server server,
56
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
57
-        server.getParser().sendRawMessage("NAMES " + channel.getChannelInfo().getName());
60
+    public void execute(final FrameContainer<?> origin,
61
+            final CommandArguments args, final CommandContext context) {
62
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
63
+        channel.getServer().getParser().sendRawMessage("NAMES "
64
+                + channel.getChannelInfo().getName());
58 65
     }
59 66
     
60 67
 
@@ -77,6 +84,12 @@ public class Names extends ChannelCommand implements IntelligentCommand, Externa
77 84
         return true;
78 85
     }
79 86
 
87
+    /** {@inheritDoc} */
88
+    @Override
89
+    public CommandType getType() {
90
+        return CommandType.TYPE_CHANNEL;
91
+    }
92
+
80 93
     /** {@inheritDoc} */
81 94
     @Override
82 95
     public String getHelp() {
@@ -88,6 +101,6 @@ public class Names extends ChannelCommand implements IntelligentCommand, Externa
88 101
     public AdditionalTabTargets getSuggestions(final int arg,
89 102
             final IntelligentCommandContext context) {
90 103
         return new AdditionalTabTargets().excludeAll();
91
-    } 
104
+    }
92 105
 
93 106
 }

+ 15
- 5
src/com/dmdirc/commandparser/commands/channel/Part.java Прегледај датотеку

@@ -24,18 +24,21 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChannelCommand;
28
+import com.dmdirc.commandparser.CommandInfo;
30 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
31 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 
33 36
 /**
34 37
  * The part command parts the current channel with a specified part message.
35 38
  * @author chris
36 39
  */
37 40
 @CommandOptions(allowOffline=false)
38
-public final class Part extends ChannelCommand {
41
+public final class Part extends Command implements CommandInfo {
39 42
     
40 43
     /** Creates a new instance of Part. */
41 44
     public Part() {
@@ -46,8 +49,9 @@ public final class Part extends ChannelCommand {
46 49
     
47 50
     /** {@inheritDoc} */
48 51
     @Override
49
-    public void execute(final FrameContainer<?> origin, final Server server,
50
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
52
+    public void execute(final FrameContainer<?> origin,
53
+            final CommandArguments args, final CommandContext context) {
54
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
51 55
         channel.part(args.getArguments().length > 0 ? args.getArgumentsAsString()
52 56
                 : origin.getConfigManager().getOption("general", "partmessage"));
53 57
         channel.close();
@@ -64,6 +68,12 @@ public final class Part extends ChannelCommand {
64 68
     public boolean showInHelp() {
65 69
         return true;
66 70
     }
71
+
72
+    /** {@inheritDoc} */
73
+    @Override
74
+    public CommandType getType() {
75
+        return CommandType.TYPE_CHANNEL;
76
+    }
67 77
     
68 78
     /** {@inheritDoc} */
69 79
     @Override

+ 21
- 9
src/com/dmdirc/commandparser/commands/channel/SetNickColour.java Прегледај датотеку

@@ -25,11 +25,14 @@ package com.dmdirc.commandparser.commands.channel;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.ChannelClientProperty;
27 27
 import com.dmdirc.FrameContainer;
28
-import com.dmdirc.Server;
29 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
30 30
 import com.dmdirc.commandparser.CommandManager;
31
-import com.dmdirc.commandparser.commands.ChannelCommand;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
32 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
35
+import com.dmdirc.commandparser.commands.context.CommandContext;
33 36
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
34 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
 import com.dmdirc.ui.input.TabCompletionType;
@@ -42,7 +45,8 @@ import java.awt.Color;
42 45
  * Allows the user to set a nickname on the channel to use a custom colour.
43 46
  * @author chris
44 47
  */
45
-public final class SetNickColour extends ChannelCommand implements IntelligentCommand {
48
+public final class SetNickColour extends Command implements IntelligentCommand,
49
+        CommandInfo {
46 50
     
47 51
     /** Creates a new instance of SetNickColour. */
48 52
     public SetNickColour() {
@@ -52,9 +56,11 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
52 56
     }
53 57
     
54 58
     /** {@inheritDoc} */
55
-    @SuppressWarnings("unchecked") @Override
56
-    public void execute(final FrameContainer<?> origin, final Server server,
57
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
59
+    @SuppressWarnings("unchecked")
60
+    @Override
61
+    public void execute(final FrameContainer<?> origin,
62
+            final CommandArguments args, final CommandContext context) {
63
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
58 64
         
59 65
         int offset = 0;
60 66
         boolean nicklist = true;
@@ -71,7 +77,7 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
71 77
         }
72 78
         
73 79
         if (args.getArguments().length <= offset) {
74
-            showUsage(origin, isSilent, "setnickcolour", "[--nicklist|--text] <nick> [colour]");
80
+            showUsage(origin, args.isSilent(), "setnickcolour", "[--nicklist|--text] <nick> [colour]");
75 81
             return;
76 82
         }
77 83
         
@@ -80,7 +86,7 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
80 86
         offset++;
81 87
         
82 88
         if (target == null) {
83
-            sendLine(origin, isSilent, FORMAT_ERROR, "No such nickname ("
89
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "No such nickname ("
84 90
                     + args.getArguments()[offset - 1] + ")!");
85 91
         } else if (args.getArguments().length <= offset) {
86 92
             // We're removing the colour
@@ -98,7 +104,7 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
98 104
             // We're setting the colour
99 105
             final Color newColour = ColourManager.parseColour(args.getArguments()[offset], null);
100 106
             if (newColour == null) {
101
-                sendLine(origin, isSilent, FORMAT_ERROR, "Invalid colour specified.");
107
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "Invalid colour specified.");
102 108
                 return;
103 109
             }
104 110
 
@@ -127,6 +133,12 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
127 133
     public boolean showInHelp() {
128 134
         return true;
129 135
     }
136
+
137
+    /** {@inheritDoc} */
138
+    @Override
139
+    public CommandType getType() {
140
+        return CommandType.TYPE_CHANNEL;
141
+    }
130 142
     
131 143
     /** {@inheritDoc} */
132 144
     @Override

+ 19
- 7
src/com/dmdirc/commandparser/commands/channel/ShowTopic.java Прегледај датотеку

@@ -26,10 +26,14 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChannelCommand;
29
+import com.dmdirc.commandparser.CommandInfo;
30 30
 import com.dmdirc.commandparser.CommandManager;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
31 33
 import com.dmdirc.commandparser.commands.CommandOptions;
32 34
 import com.dmdirc.commandparser.commands.ExternalCommand;
35
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
36
+import com.dmdirc.commandparser.commands.context.CommandContext;
33 37
 import com.dmdirc.parser.interfaces.ChannelInfo;
34 38
 
35 39
 /**
@@ -37,7 +41,8 @@ import com.dmdirc.parser.interfaces.ChannelInfo;
37 41
  * @author chris
38 42
  */
39 43
 @CommandOptions(allowOffline=false)
40
-public final class ShowTopic extends ChannelCommand implements ExternalCommand {
44
+public final class ShowTopic extends Command implements ExternalCommand,
45
+        CommandInfo {
41 46
 
42 47
     /** Creates a new instance of ShowTopic. */
43 48
     public ShowTopic() {
@@ -48,17 +53,18 @@ public final class ShowTopic extends ChannelCommand implements ExternalCommand {
48 53
 
49 54
     /** {@inheritDoc} */
50 55
     @Override
51
-    public void execute(final FrameContainer<?> origin, final Server server,
52
-            final Channel channel, final boolean isSilent, final CommandArguments args) {
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
58
+        final Channel channel = ((ChannelCommandContext) context).getChannel();
53 59
         if (args.getArguments().length == 0) {
54 60
             final ChannelInfo cChannel = channel.getChannelInfo();
55 61
 
56 62
             if (cChannel.getTopic().isEmpty()) {
57
-                sendLine(origin, isSilent, "channelNoTopic", cChannel);
63
+                sendLine(origin, args.isSilent(), "channelNoTopic", cChannel);
58 64
             } else {
59
-                final String[] parts = server.parseHostmask(cChannel.getTopicSetter());
65
+                final String[] parts = channel.getServer().parseHostmask(cChannel.getTopicSetter());
60 66
 
61
-                sendLine(origin, isSilent, "channelTopicDiscovered",
67
+                sendLine(origin, args.isSilent(), "channelTopicDiscovered",
62 68
                         "", parts[0], parts[1], parts[2], cChannel.getTopic(),
63 69
                         1000 * cChannel.getTopicTime(), cChannel);
64 70
             }
@@ -90,6 +96,12 @@ public final class ShowTopic extends ChannelCommand implements ExternalCommand {
90 96
         return true;
91 97
     }
92 98
 
99
+    /** {@inheritDoc} */
100
+    @Override
101
+    public CommandType getType() {
102
+        return CommandType.TYPE_CHANNEL;
103
+    }
104
+
93 105
     /** {@inheritDoc} */
94 106
     @Override
95 107
     public String getHelp() {

+ 105
- 96
src/com/dmdirc/commandparser/commands/chat/Me.java Прегледај датотеку

@@ -1,96 +1,105 @@
1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.commandparser.commands.chat;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.MessageTarget;
27
-import com.dmdirc.Server;
28
-import com.dmdirc.commandparser.CommandArguments;
29
-import com.dmdirc.commandparser.commands.ChatCommand;
30
-import com.dmdirc.commandparser.CommandManager;
31
-import com.dmdirc.commandparser.commands.ValidatingCommand;
32
-import com.dmdirc.config.prefs.validator.ValidationResponse;
33
-import com.dmdirc.ui.interfaces.InputWindow;
34
-
35
-/**
36
- * The me command sends a CTCP action to the current channel.
37
- * @author chris
38
- */
39
-public final class Me extends ChatCommand implements ValidatingCommand {
40
-    
41
-    /** Creates a new instance of Me. */
42
-    public Me() {
43
-        super();
44
-        
45
-        CommandManager.registerCommand(this);
46
-    }
47
-    
48
-    /** {@inheritDoc} */
49
-    @Override
50
-    public void execute(final FrameContainer<?> origin, final Server server,
51
-            final MessageTarget<?> target, final boolean isSilent, final CommandArguments args) {
52
-        if (args.getArguments().length == 0) {
53
-            showUsage(origin, isSilent, "me", "<action>");
54
-        } else {
55
-            target.sendAction(args.getArgumentsAsString());
56
-        }
57
-    }
58
-    
59
-    /** {@inheritDoc} */
60
-    @Override
61
-    public String getName() {
62
-        return "me";
63
-    }
64
-    
65
-    /** {@inheritDoc} */
66
-    @Override
67
-    public boolean showInHelp() {
68
-        return true;
69
-    }
70
-    
71
-    /** {@inheritDoc} */
72
-    @Override
73
-    public String getHelp() {
74
-        return "me <action> - sends the specified action";
75
-    }
76
-
77
-    /** {@inheritDoc} */
78
-    @Override
79
-    public ValidationResponse validateArguments(final InputWindow origin, 
80
-            final CommandArguments arguments) {
81
-        if (origin.getContainer().getServer() == null
82
-                || origin.getContainer().getServer().getParser() == null) {
83
-            return new ValidationResponse();
84
-        }
85
-        
86
-        final int length = 2 + arguments.getArgumentsAsString().length();
87
-        
88
-        if (origin.getContainer().getServer().getParser().getMaxLength("PRIVMSG",
89
-                origin.getContainer().toString()) <= length) {
90
-            return new ValidationResponse("Too long");
91
-        } else {
92
-            return new ValidationResponse();
93
-        }
94
-    }
95
-    
96
-}
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.chat;
24
+
25
+import com.dmdirc.FrameContainer;
26
+import com.dmdirc.MessageTarget;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
29
+import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.ValidatingCommand;
33
+import com.dmdirc.commandparser.commands.context.ChatCommandContext;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.config.prefs.validator.ValidationResponse;
36
+import com.dmdirc.ui.interfaces.InputWindow;
37
+
38
+/**
39
+ * The me command sends a CTCP action to the current channel.
40
+ * @author chris
41
+ */
42
+public final class Me extends Command implements ValidatingCommand, CommandInfo {
43
+
44
+    /** Creates a new instance of Me. */
45
+    public Me() {
46
+        super();
47
+
48
+        CommandManager.registerCommand(this);
49
+    }
50
+
51
+    /** {@inheritDoc} */
52
+    @Override
53
+    public void execute(final FrameContainer<?> origin,
54
+            final CommandArguments args, final CommandContext context) {
55
+        final MessageTarget<?> target = ((ChatCommandContext) context).getChat();
56
+        if (args.getArguments().length == 0) {
57
+            showUsage(origin, args.isSilent(), "me", "<action>");
58
+        } else {
59
+            target.sendAction(args.getArgumentsAsString());
60
+        }
61
+    }
62
+
63
+    /** {@inheritDoc} */
64
+    @Override
65
+    public String getName() {
66
+        return "me";
67
+    }
68
+
69
+    /** {@inheritDoc} */
70
+    @Override
71
+    public boolean showInHelp() {
72
+        return true;
73
+    }
74
+
75
+    /** {@inheritDoc} */
76
+    @Override
77
+    public CommandType getType() {
78
+        return CommandType.TYPE_CHAT;
79
+    }
80
+
81
+    /** {@inheritDoc} */
82
+    @Override
83
+    public String getHelp() {
84
+        return "me <action> - sends the specified action";
85
+    }
86
+
87
+    /** {@inheritDoc} */
88
+    @Override
89
+    public ValidationResponse validateArguments(final InputWindow origin,
90
+            final CommandArguments arguments) {
91
+        if (origin.getContainer().getServer() == null
92
+                || origin.getContainer().getServer().getParser() == null) {
93
+            return new ValidationResponse();
94
+        }
95
+
96
+        final int length = 2 + arguments.getArgumentsAsString().length();
97
+
98
+        if (origin.getContainer().getServer().getParser().getMaxLength("PRIVMSG",
99
+                origin.getContainer().toString()) <= length) {
100
+            return new ValidationResponse("Too long");
101
+        } else {
102
+            return new ValidationResponse();
103
+        }
104
+    }
105
+}

+ 61
- 0
src/com/dmdirc/commandparser/commands/context/ChannelCommandContext.java Прегледај датотеку

@@ -0,0 +1,61 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.context;
24
+
25
+import com.dmdirc.Channel;
26
+import com.dmdirc.commandparser.CommandInfo;
27
+import com.dmdirc.ui.interfaces.Window;
28
+
29
+/**
30
+ * A specialised {@link CommandContext} for commands executed in channels.
31
+ *
32
+ * @since 0.6.4
33
+ * @author chris
34
+ */
35
+public class ChannelCommandContext extends ChatCommandContext {
36
+
37
+    /** The channel associated with the command. */
38
+    private final Channel channel;
39
+
40
+    /**
41
+     * Creates a new channel command context.
42
+     *
43
+     * @param source The source of the command
44
+     * @param commandInfo The command info object which associated the command with the input
45
+     * @param channel The channel associated with the command
46
+     */
47
+    public ChannelCommandContext(Window source, CommandInfo commandInfo, Channel channel) {
48
+        super(source, commandInfo, channel);
49
+        this.channel = channel;
50
+    }
51
+
52
+    /**
53
+     * Retrieves the channel associated with this context.
54
+     *
55
+     * @return This context's channel
56
+     */
57
+    public Channel getChannel() {
58
+        return channel;
59
+    }
60
+
61
+}

+ 61
- 0
src/com/dmdirc/commandparser/commands/context/ChatCommandContext.java Прегледај датотеку

@@ -0,0 +1,61 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.context;
24
+
25
+import com.dmdirc.MessageTarget;
26
+import com.dmdirc.commandparser.CommandInfo;
27
+import com.dmdirc.ui.interfaces.Window;
28
+
29
+/**
30
+ * A command context specific to chat windows.
31
+ *
32
+ * @since 0.6.4
33
+ * @author chris
34
+ */
35
+public class ChatCommandContext extends ServerCommandContext {
36
+
37
+    /** The chat container associated with this context. */
38
+    private final MessageTarget<?> chat;
39
+
40
+    /**
41
+     * Creates a new chat command context.
42
+     *
43
+     * @param source The source of the command
44
+     * @param commandInfo The command info object which associated the command with the input
45
+     * @param chat The chat container associated with the command
46
+     */
47
+    public ChatCommandContext(final Window source, final CommandInfo commandInfo,
48
+            final MessageTarget<?> chat) {
49
+        super(source, commandInfo, chat.getServer());
50
+        this.chat = chat;
51
+    }
52
+
53
+    /**
54
+     * Retrieves the chat container's associated with the command.
55
+     *
56
+     * @return This context's associated container
57
+     */
58
+    public MessageTarget<?> getChat() {
59
+        return chat;
60
+    }
61
+}

+ 72
- 0
src/com/dmdirc/commandparser/commands/context/CommandContext.java Прегледај датотеку

@@ -0,0 +1,72 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.context;
24
+
25
+import com.dmdirc.commandparser.CommandInfo;
26
+import com.dmdirc.ui.interfaces.Window;
27
+
28
+/**
29
+ * Provides information relating to the context that a command was executed in.
30
+ *
31
+ * @since 0.6.4
32
+ * @author chris
33
+ */
34
+public class CommandContext {
35
+
36
+    /** The command info object which associated the command with the input. */
37
+    protected final CommandInfo commandInfo;
38
+
39
+    /** The source of this command. */
40
+    protected final Window source;
41
+
42
+    /**
43
+     * Creates a new command context.
44
+     *
45
+     * @param source The source of the command
46
+     * @param commandInfo The command info object which associated the command with the input
47
+     */
48
+    public CommandContext(final Window source, final CommandInfo commandInfo) {
49
+        this.source = source;
50
+        this.commandInfo = commandInfo;
51
+    }
52
+
53
+    /**
54
+     * Retrieves the command information object which caused the command to
55
+     * be selected in response to the user's input.
56
+     *
57
+     * @return The relevant command info object
58
+     */
59
+    public CommandInfo getCommandInfo() {
60
+        return commandInfo;
61
+    }
62
+
63
+    /**
64
+     * Retrieves the window, if any, where the command was entered.
65
+     *
66
+     * @return The window the command came from, or null
67
+     */
68
+    public Window getSource() {
69
+        return source;
70
+    }
71
+
72
+}

+ 61
- 0
src/com/dmdirc/commandparser/commands/context/QueryCommandContext.java Прегледај датотеку

@@ -0,0 +1,61 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.context;
24
+
25
+import com.dmdirc.Query;
26
+import com.dmdirc.commandparser.CommandInfo;
27
+import com.dmdirc.ui.interfaces.Window;
28
+
29
+/**
30
+ * A query-specific command context.
31
+ *
32
+ * @since 0.6.4
33
+ * @author chris
34
+ */
35
+public class QueryCommandContext extends ChatCommandContext {
36
+
37
+    /** The query the command was executed for. */
38
+    private final Query query;
39
+
40
+    /**
41
+     * Creates a new query command context.
42
+     *
43
+     * @param source The source of the command
44
+     * @param commandInfo The command info object which associated the command with the input
45
+     * @param query The query associated with the command
46
+     */
47
+    public QueryCommandContext(final Window source, final CommandInfo commandInfo, final Query query) {
48
+        super(source, commandInfo, query);
49
+        this.query = query;
50
+    }
51
+
52
+    /**
53
+     * Retrieves the query associated with this context.
54
+     *
55
+     * @return This context's query
56
+     */
57
+    public Query getQuery() {
58
+        return query;
59
+    }
60
+
61
+}

+ 62
- 0
src/com/dmdirc/commandparser/commands/context/ServerCommandContext.java Прегледај датотеку

@@ -0,0 +1,62 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.context;
24
+
25
+import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandInfo;
27
+import com.dmdirc.ui.interfaces.Window;
28
+
29
+/**
30
+ * A command context for server commands.
31
+ *
32
+ * @since 0.6.4
33
+ * @author chris
34
+ */
35
+public class ServerCommandContext extends CommandContext {
36
+
37
+    /** The server the command was executed for. */
38
+    private final Server server;
39
+
40
+    /**
41
+     * Creates a new server command context.
42
+     *
43
+     * @param source The source of the command
44
+     * @param commandInfo The command info object which associated the command with the input
45
+     * @param server The server associated with the command
46
+     */
47
+    public ServerCommandContext(final Window source, final CommandInfo commandInfo,
48
+            final Server server) {
49
+        super(source, commandInfo);
50
+        this.server = server;
51
+    }
52
+
53
+    /**
54
+     * Retrieves the server associated with this context.
55
+     *
56
+     * @return This context's server
57
+     */
58
+    public Server getServer() {
59
+        return server;
60
+    }
61
+
62
+}

+ 15
- 5
src/com/dmdirc/commandparser/commands/global/Active.java Прегледај датотеку

@@ -25,9 +25,12 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.WritableFrameContainer;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
30 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
31 34
 import com.dmdirc.ui.WindowManager;
32 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 36
 import com.dmdirc.ui.input.TabCompleter;
@@ -36,7 +39,8 @@ import com.dmdirc.ui.input.TabCompleter;
36 39
  * The Active command issues a command to the active window.
37 40
  * @author chris
38 41
  */
39
-public final class Active extends GlobalCommand implements IntelligentCommand {
42
+public final class Active extends Command implements IntelligentCommand,
43
+        CommandInfo {
40 44
     
41 45
     /**
42 46
      * Creates a new instance of Active.
@@ -49,15 +53,15 @@ public final class Active extends GlobalCommand implements IntelligentCommand {
49 53
     
50 54
     /** {@inheritDoc} */
51 55
     @Override
52
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
53
-            final CommandArguments args) {
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
54 58
         final String command = args.getArgumentsAsString();
55 59
         
56 60
         final FrameContainer<?> window = WindowManager.getActiveWindow();
57 61
         
58 62
         if (window != null && window instanceof WritableFrameContainer<?>) {
59 63
             ((WritableFrameContainer<?>) window).getCommandParser()
60
-                    .parseCommand(window, command);
64
+                    .parseCommand(window, context.getSource(), command);
61 65
         }
62 66
     }
63 67
     
@@ -73,6 +77,12 @@ public final class Active extends GlobalCommand implements IntelligentCommand {
73 77
     public boolean showInHelp() {
74 78
         return true;
75 79
     }
80
+
81
+    /** {@inheritDoc} */
82
+    @Override
83
+    public CommandType getType() {
84
+        return CommandType.TYPE_GLOBAL;
85
+    }
76 86
     
77 87
     /** {@inheritDoc} */
78 88
     @Override

+ 19
- 10
src/com/dmdirc/commandparser/commands/global/AliasCommand.java Прегледај датотеку

@@ -28,9 +28,12 @@ import com.dmdirc.actions.ActionManager;
28 28
 import com.dmdirc.actions.wrappers.Alias;
29 29
 import com.dmdirc.actions.wrappers.AliasWrapper;
30 30
 import com.dmdirc.commandparser.CommandArguments;
31
+import com.dmdirc.commandparser.CommandInfo;
31 32
 import com.dmdirc.commandparser.CommandManager;
32
-import com.dmdirc.commandparser.commands.GlobalCommand;
33
+import com.dmdirc.commandparser.CommandType;
34
+import com.dmdirc.commandparser.commands.Command;
33 35
 import com.dmdirc.commandparser.commands.IntelligentCommand;
36
+import com.dmdirc.commandparser.commands.context.CommandContext;
34 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
 import com.dmdirc.ui.input.TabCompleter;
36 39
 
@@ -39,8 +42,8 @@ import com.dmdirc.ui.input.TabCompleter;
39 42
  * 
40 43
  * @author chris
41 44
  */
42
-public final class AliasCommand extends GlobalCommand implements
43
-        IntelligentCommand {
45
+public final class AliasCommand extends Command implements
46
+        IntelligentCommand, CommandInfo {
44 47
 
45 48
     /**
46 49
      * Creates a new instance of Active.
@@ -53,10 +56,10 @@ public final class AliasCommand extends GlobalCommand implements
53 56
 
54 57
     /** {@inheritDoc} */
55 58
     @Override
56
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
57
-                        final CommandArguments args) {
59
+    public void execute(final FrameContainer<?> origin,
60
+            final CommandArguments args, final CommandContext context) {
58 61
         if (args.getArguments().length < 2) {
59
-            showUsage(origin, isSilent, "alias", "[--remove] <name> [command]");
62
+            showUsage(origin, args.isSilent(), "alias", "[--remove] <name> [command]");
60 63
             return;
61 64
         }
62 65
 
@@ -66,10 +69,10 @@ public final class AliasCommand extends GlobalCommand implements
66 69
                     ? args.getArguments()[1].substring(1) : args.getArguments()[1];
67 70
 
68 71
             if (doRemove(name)) {
69
-                sendLine(origin, isSilent, FORMAT_OUTPUT, "Alias '" + name +
72
+                sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Alias '" + name +
70 73
                          "' removed.");
71 74
             } else {
72
-                sendLine(origin, isSilent, FORMAT_ERROR, "Alias '" + name +
75
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "Alias '" + name +
73 76
                          "' not found.");
74 77
             }
75 78
 
@@ -82,7 +85,7 @@ public final class AliasCommand extends GlobalCommand implements
82 85
         for (Action alias : AliasWrapper.getAliasWrapper()) {
83 86
             if (AliasWrapper.getCommandName(alias).substring(1).equalsIgnoreCase(
84 87
                     name)) {
85
-                sendLine(origin, isSilent, FORMAT_ERROR, "Alias '" + name +
88
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "Alias '" + name +
86 89
                          "' already exists.");
87 90
                 return;
88 91
             }
@@ -92,7 +95,7 @@ public final class AliasCommand extends GlobalCommand implements
92 95
         myAlias.setResponse(new String[]{args.getArgumentsAsString(1)});
93 96
         myAlias.createAction().save();
94 97
 
95
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Alias '" + name +
98
+        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Alias '" + name +
96 99
                  "' created.");
97 100
     }
98 101
 
@@ -128,6 +131,12 @@ public final class AliasCommand extends GlobalCommand implements
128 131
         return true;
129 132
     }
130 133
 
134
+    /** {@inheritDoc} */
135
+    @Override
136
+    public CommandType getType() {
137
+        return CommandType.TYPE_GLOBAL;
138
+    }
139
+
131 140
     /** {@inheritDoc} */
132 141
     @Override
133 142
     public String getHelp() {

+ 15
- 5
src/com/dmdirc/commandparser/commands/global/AllServers.java Прегледај датотеку

@@ -26,9 +26,12 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.ServerManager;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
29 30
 import com.dmdirc.commandparser.CommandManager;
30
-import com.dmdirc.commandparser.commands.GlobalCommand;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
31 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 36
 import com.dmdirc.ui.input.TabCompleter;
34 37
 
@@ -36,7 +39,8 @@ import com.dmdirc.ui.input.TabCompleter;
36 39
  * The AllServers command allows users to issue commands to all servers.
37 40
  * @author chris
38 41
  */
39
-public final class AllServers extends GlobalCommand implements IntelligentCommand {
42
+public final class AllServers extends Command implements IntelligentCommand,
43
+        CommandInfo{
40 44
     
41 45
     /** Creates a new instance of AllServers. */
42 46
     public AllServers() {
@@ -47,12 +51,12 @@ public final class AllServers extends GlobalCommand implements IntelligentComman
47 51
     
48 52
     /** {@inheritDoc} */
49 53
     @Override
50
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
51
-            final CommandArguments args) {
54
+    public void execute(final FrameContainer<?> origin,
55
+            final CommandArguments args, final CommandContext context) {
52 56
         final String command = args.getArgumentsAsString();
53 57
         
54 58
         for (Server target : ServerManager.getServerManager().getServers()) {
55
-            target.getCommandParser().parseCommand(target, command);
59
+            target.getCommandParser().parseCommand(target, context.getSource(), command);
56 60
         }
57 61
     }
58 62
     
@@ -68,6 +72,12 @@ public final class AllServers extends GlobalCommand implements IntelligentComman
68 72
     public boolean showInHelp() {
69 73
         return true;
70 74
     }
75
+
76
+    /** {@inheritDoc} */
77
+    @Override
78
+    public CommandType getType() {
79
+        return CommandType.TYPE_GLOBAL;
80
+    }
71 81
     
72 82
     /** {@inheritDoc} */
73 83
     @Override

+ 14
- 4
src/com/dmdirc/commandparser/commands/global/Clear.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 34
 
32 35
 /**
@@ -34,7 +37,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
34 37
  * 
35 38
  * @author chris
36 39
  */
37
-public final class Clear extends GlobalCommand implements IntelligentCommand {
40
+public final class Clear extends Command implements IntelligentCommand,
41
+        CommandInfo {
38 42
     
39 43
     /**
40 44
      * Creates a new instance of Clear.
@@ -47,8 +51,8 @@ public final class Clear extends GlobalCommand implements IntelligentCommand {
47 51
     
48 52
     /** {@inheritDoc} */
49 53
     @Override
50
-    public void execute(final FrameContainer origin, final boolean isSilent, 
51
-            final CommandArguments args) {
54
+    public void execute(final FrameContainer<?> origin,
55
+            final CommandArguments args, final CommandContext context) {
52 56
         origin.getDocument().clear();
53 57
     }
54 58
     
@@ -64,6 +68,12 @@ public final class Clear extends GlobalCommand implements IntelligentCommand {
64 68
     public boolean showInHelp() {
65 69
         return true;
66 70
     }
71
+
72
+    /** {@inheritDoc} */
73
+    @Override
74
+    public CommandType getType() {
75
+        return CommandType.TYPE_GLOBAL;
76
+    }
67 77
     
68 78
     /** {@inheritDoc} */
69 79
     @Override

+ 28
- 19
src/com/dmdirc/commandparser/commands/global/Debug.java Прегледај датотеку

@@ -26,9 +26,12 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Main;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
29 30
 import com.dmdirc.commandparser.CommandManager;
30
-import com.dmdirc.commandparser.commands.GlobalCommand;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
31 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 import com.dmdirc.config.ConfigManager;
33 36
 import com.dmdirc.config.Identity;
34 37
 import com.dmdirc.config.IdentityManager;
@@ -53,7 +56,7 @@ import java.util.TreeSet;
53 56
  *
54 57
  * @author Chris
55 58
  */
56
-public class Debug extends GlobalCommand implements IntelligentCommand {
59
+public class Debug extends Command implements IntelligentCommand, CommandInfo {
57 60
     
58 61
     /**
59 62
      * Creates a new instance of Debug.
@@ -64,47 +67,47 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
64 67
     
65 68
     /** {@inheritDoc} */
66 69
     @Override
67
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
68
-            final CommandArguments args) {
70
+    public void execute(final FrameContainer<?> origin,
71
+            final CommandArguments args, final CommandContext context) {
69 72
         if (args.getArguments().length == 0) {
70
-            showUsage(origin, isSilent, "debug", "<debug command> [options]");
73
+            showUsage(origin, args.isSilent(), "debug", "<debug command> [options]");
71 74
         } else if ("error".equals(args.getArguments()[0])) {
72 75
             doError(args.getArguments());
73 76
         } else if ("showraw".equals(args.getArguments()[0])) {
74
-            doShowRaw(origin, isSilent);
77
+            doShowRaw(origin, args.isSilent());
75 78
         } else if ("configstats".equals(args.getArguments()[0])) {
76
-            doConfigStats(origin, isSilent, args.getArguments());
79
+            doConfigStats(origin, args.isSilent(), args.getArguments());
77 80
         } else if ("configinfo".equals(args.getArguments()[0])) {
78
-            doConfigInfo(origin, isSilent);
81
+            doConfigInfo(origin, args.isSilent());
79 82
         } else if ("globalconfiginfo".equals(args.getArguments()[0])) {
80
-            doGlobalConfigInfo(origin, isSilent);
83
+            doGlobalConfigInfo(origin, args.isSilent());
81 84
         } else if ("colourspam".equals(args.getArguments()[0])) {
82
-            doColourSpam(origin, isSilent);
85
+            doColourSpam(origin, args.isSilent());
83 86
         } else if ("meminfo".equals(args.getArguments()[0])) {
84
-            doMemInfo(origin, isSilent);
87
+            doMemInfo(origin, args.isSilent());
85 88
         } else if ("rungc".equals(args.getArguments()[0])) {
86
-            doGarbage(origin, isSilent);
89
+            doGarbage(origin, args.isSilent());
87 90
         } else if ("threads".equals(args.getArguments()[0])) {
88
-            doThreads(origin, isSilent);
91
+            doThreads(origin, args.isSilent());
89 92
         } else if ("forceupdate".equals(args.getArguments()[0])) {
90
-            doForceUpdate(origin, isSilent);
93
+            doForceUpdate(origin, args.isSilent());
91 94
         } else if ("serverinfo".equals(args.getArguments()[0])) {
92
-            doServerInfo(origin, isSilent);
95
+            doServerInfo(origin, args.isSilent());
93 96
         } else if ("serverstate".equals(args.getArguments()[0])) {
94
-            doServerState(origin, isSilent);
97
+            doServerState(origin, args.isSilent());
95 98
         } else if ("benchmark".equals(args.getArguments()[0])) {
96 99
             doBenchmark(origin);
97 100
         } else if ("services".equals(args.getArguments()[0])) {
98
-            doServices(origin, isSilent, args.getArguments());
101
+            doServices(origin, args.isSilent(), args.getArguments());
99 102
         } else if ("firstrun".equals(args.getArguments()[0])) {
100 103
             Main.getUI().showFirstRunWizard();
101 104
         } else if ("migration".equals(args.getArguments()[0])) {
102 105
             Main.getUI().showMigrationWizard();
103 106
         } else if ("notify".equals(args.getArguments()[0])) {
104
-            sendLine(origin, isSilent, FORMAT_OUTPUT, "Current notification colour is: "
107
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Current notification colour is: "
105 108
                     + origin.getNotification());
106 109
         } else {
107
-            sendLine(origin, isSilent, FORMAT_ERROR, "Unknown debug action.");
110
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Unknown debug action.");
108 111
         }
109 112
     }
110 113
     
@@ -465,6 +468,12 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
465 468
     public boolean showInHelp() {
466 469
         return false;
467 470
     }
471
+
472
+    /** {@inheritDoc} */
473
+    @Override
474
+    public CommandType getType() {
475
+        return CommandType.TYPE_GLOBAL;
476
+    }
468 477
     
469 478
     /** {@inheritDoc} */
470 479
     @Override

+ 19
- 9
src/com/dmdirc/commandparser/commands/global/Echo.java Прегледај датотеку

@@ -26,9 +26,12 @@ import com.dmdirc.CustomWindow;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
29 30
 import com.dmdirc.commandparser.CommandManager;
30
-import com.dmdirc.commandparser.commands.GlobalCommand;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
31 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 import com.dmdirc.ui.WindowManager;
33 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 37
 
@@ -41,7 +44,8 @@ import java.util.List;
41 44
  *
42 45
  * @author chris
43 46
  */
44
-public final class Echo extends GlobalCommand implements IntelligentCommand {
47
+public final class Echo extends Command implements IntelligentCommand,
48
+        CommandInfo {
45 49
 
46 50
     /**
47 51
      * Creates a new instance of Echo.
@@ -54,8 +58,8 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
54 58
 
55 59
     /** {@inheritDoc} */
56 60
     @Override
57
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
58
-            final CommandArguments args) {
61
+    public void execute(final FrameContainer<?> origin,
62
+            final CommandArguments args, final CommandContext context) {
59 63
         int offset = 0;
60 64
         Date time = new Date();
61 65
 
@@ -64,7 +68,7 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
64 68
             try {
65 69
                 time = new Date(Long.parseLong(args.getWordsAsString(2, 2)));
66 70
             } catch (NumberFormatException ex) {
67
-                sendLine(origin, isSilent, FORMAT_ERROR, "Unable to process timestamp");
71
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "Unable to process timestamp");
68 72
                 return;
69 73
             }
70 74
 
@@ -73,7 +77,7 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
73 77
 
74 78
         if (args.getArguments().length > offset
75 79
                 && args.getArguments()[offset].equalsIgnoreCase("--active")) {
76
-            if (!isSilent) {
80
+            if (!args.isSilent()) {
77 81
                 final FrameContainer<?> frame = WindowManager.getActiveWindow();
78 82
                 frame.addLine(FORMAT_OUTPUT, time, args.getArgumentsAsString(offset + 1));
79 83
             }
@@ -91,13 +95,13 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
91 95
             }
92 96
 
93 97
             if (frame == null) {
94
-                sendLine(origin, isSilent, FORMAT_ERROR,
98
+                sendLine(origin, args.isSilent(), FORMAT_ERROR,
95 99
                         "Unable to find target window");
96
-            } else if (!isSilent) {
100
+            } else if (!args.isSilent()) {
97 101
                 frame.addLine(FORMAT_OUTPUT, time, args.getArgumentsAsString(offset + 2));
98 102
             }
99 103
 
100
-        } else if (origin != null && !isSilent) {
104
+        } else if (origin != null && !args.isSilent()) {
101 105
             origin.addLine(FORMAT_OUTPUT, time, args.getArgumentsAsString(offset));
102 106
         }
103 107
     }
@@ -114,6 +118,12 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
114 118
         return true;
115 119
     }
116 120
 
121
+    /** {@inheritDoc} */
122
+    @Override
123
+    public CommandType getType() {
124
+        return CommandType.TYPE_GLOBAL;
125
+    }
126
+
117 127
     /** {@inheritDoc} */
118 128
     @Override
119 129
     public String getHelp() {

+ 13
- 4
src/com/dmdirc/commandparser/commands/global/Exit.java Прегледај датотеку

@@ -25,8 +25,11 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Main;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 
31 34
 /**
32 35
  * The exit command allows the user to quit DMDirc with a custom quit message.
@@ -34,7 +37,7 @@ import com.dmdirc.commandparser.commands.GlobalCommand;
34 37
  * supplied) and saves the config file.
35 38
  * @author chris
36 39
  */
37
-public final class Exit extends GlobalCommand {
40
+public final class Exit extends Command implements CommandInfo {
38 41
     
39 42
     /**
40 43
      * Creates a new instance of Exit.
@@ -47,8 +50,8 @@ public final class Exit extends GlobalCommand {
47 50
     
48 51
     /** {@inheritDoc} */
49 52
     @Override
50
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
51
-            final CommandArguments args) {
53
+    public void execute(final FrameContainer<?> origin,
54
+            final CommandArguments args, final CommandContext context) {
52 55
         Main.quit(args.getArguments().length > 0 ? args.getArgumentsAsString()
53 56
                 : origin.getConfigManager().getOption("general", "closemessage"));
54 57
     }
@@ -65,6 +68,12 @@ public final class Exit extends GlobalCommand {
65 68
     public boolean showInHelp() {
66 69
         return true;
67 70
     }
71
+
72
+    /** {@inheritDoc} */
73
+    @Override
74
+    public CommandType getType() {
75
+        return CommandType.TYPE_GLOBAL;
76
+    }
68 77
         
69 78
     /** {@inheritDoc}. */
70 79
     @Override

+ 177
- 170
src/com/dmdirc/commandparser/commands/global/Help.java Прегледај датотеку

@@ -1,170 +1,177 @@
1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.commandparser.commands.global;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.WritableFrameContainer;
27
-import com.dmdirc.commandparser.CommandArguments;
28
-import com.dmdirc.commandparser.CommandInfo;
29
-import com.dmdirc.commandparser.CommandManager;
30
-import com.dmdirc.commandparser.commands.Command;
31
-import com.dmdirc.commandparser.commands.GlobalCommand;
32
-import com.dmdirc.commandparser.commands.IntelligentCommand;
33
-import com.dmdirc.ui.input.AdditionalTabTargets;
34
-import com.dmdirc.ui.input.TabCompletionType;
35
-import com.dmdirc.ui.messages.Styliser;
36
-
37
-import java.util.ArrayList;
38
-import java.util.Collections;
39
-import java.util.List;
40
-import java.util.Map;
41
-
42
-/**
43
- * The help command shows the user a list of available commands, along with
44
- * their arguments, and a description. It is context-aware, so channel commands
45
- * are only displayed when in a channel window, for example.
46
- * @author chris
47
- */
48
-public final class Help extends GlobalCommand implements IntelligentCommand {
49
-    
50
-    /**
51
-     * Creates a new instance of Help.
52
-     */
53
-    public Help() {
54
-        super();
55
-        
56
-        CommandManager.registerCommand(this);
57
-    }
58
-    
59
-    /** {@inheritDoc} */
60
-    @Override
61
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
62
-            final CommandArguments args) {
63
-        if (args.getArguments().length == 0) {
64
-            showAllCommands(origin, isSilent);
65
-        } else {
66
-            showCommand(origin, isSilent, args.getArguments()[0]);
67
-        }
68
-    }
69
-    
70
-    /**
71
-     * Shows a list of all commands valid for the current window.
72
-     * 
73
-     * @param origin The window the command was executed in
74
-     * @param isSilent Whether this command has been silenced or not
75
-     */
76
-    private void showAllCommands(final FrameContainer<?> origin, final boolean isSilent) {
77
-        final List<String> commands = new ArrayList<String>(((WritableFrameContainer<?>) origin)
78
-                .getCommandParser().getCommands().keySet());
79
-
80
-        Collections.sort(commands);
81
-        
82
-        sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
83
-                + "----------------------- Available commands -------");
84
-        
85
-        final StringBuilder builder = new StringBuilder();
86
-        
87
-        for (String command : commands) {
88
-            if (builder.length() + command.length() + 1 > 50) {
89
-                sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED + builder.toString());
90
-                builder.delete(0, builder.length());
91
-            } else if (builder.length() > 0) {
92
-                builder.append(' ');
93
-            }
94
-            
95
-            builder.append(command);
96
-        }
97
-        
98
-        if (builder.length() > 0) {
99
-            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED + builder.toString());
100
-        }
101
-        
102
-        sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
103
-                + "--------------------------------------------------");
104
-    }
105
-    
106
-    /**
107
-     * Shows information about the specified command.
108
-     * 
109
-     * @param origin The window the command was executed in
110
-     * @param isSilent Whether this command has been silenced or not
111
-     * @param name The name of the command to display info for
112
-     */
113
-    private void showCommand(final FrameContainer<?> origin, final boolean isSilent,
114
-            final String name) {
115
-        Map.Entry<CommandInfo, Command> command = null;
116
-
117
-        if (name.length() > 0 && name.charAt(0) == CommandManager.getCommandChar()) {
118
-            command = CommandManager.getCommand(name.substring(1));
119
-        } else {
120
-            command = CommandManager.getCommand(name);
121
-        }
122
-        
123
-        if (command == null) {
124
-            sendLine(origin, isSilent, FORMAT_ERROR, "Command '" + name + "' not found.");
125
-        } else {
126
-            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
127
-                    + "---------------------- Command information -------");            
128
-            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
129
-                    + " Name: " + name);
130
-            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
131
-                    + " Type: " + command.getKey().getType());
132
-            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
133
-                    + "Usage: " + command.getKey().getHelp());
134
-            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
135
-                    + "--------------------------------------------------");            
136
-        }
137
-    }
138
-    
139
-    /** {@inheritDoc}. */
140
-    @Override
141
-    public String getName() {
142
-        return "help";
143
-    }
144
-    
145
-    /** {@inheritDoc}. */
146
-    @Override
147
-    public boolean showInHelp() {
148
-        return true;
149
-    }
150
-    
151
-    /** {@inheritDoc}. */
152
-    @Override
153
-    public String getHelp() {
154
-        return "help [command] - shows client command help";
155
-    }
156
-
157
-    /** {@inheritDoc} */
158
-    @Override
159
-    public AdditionalTabTargets getSuggestions(final int arg,
160
-            final IntelligentCommandContext context) {
161
-        final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
162
-
163
-        if (arg == 0) {
164
-            res.include(TabCompletionType.COMMAND);
165
-        }
166
-        
167
-        return res;
168
-    } 
169
-    
170
-}
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.global;
24
+
25
+import com.dmdirc.FrameContainer;
26
+import com.dmdirc.WritableFrameContainer;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
29
+import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.ui.input.AdditionalTabTargets;
35
+import com.dmdirc.ui.input.TabCompletionType;
36
+import com.dmdirc.ui.messages.Styliser;
37
+
38
+import java.util.ArrayList;
39
+import java.util.Collections;
40
+import java.util.List;
41
+import java.util.Map;
42
+
43
+/**
44
+ * The help command shows the user a list of available commands, along with
45
+ * their arguments, and a description. It is context-aware, so channel commands
46
+ * are only displayed when in a channel window, for example.
47
+ * @author chris
48
+ */
49
+public final class Help extends Command implements IntelligentCommand, CommandInfo {
50
+
51
+    /**
52
+     * Creates a new instance of Help.
53
+     */
54
+    public Help() {
55
+        super();
56
+
57
+        CommandManager.registerCommand(this);
58
+    }
59
+
60
+    /** {@inheritDoc} */
61
+    @Override
62
+    public void execute(final FrameContainer<?> origin,
63
+            final CommandArguments args, final CommandContext context) {
64
+        if (args.getArguments().length == 0) {
65
+            showAllCommands(origin, args.isSilent());
66
+        } else {
67
+            showCommand(origin, args.isSilent(), args.getArguments()[0]);
68
+        }
69
+    }
70
+
71
+    /**
72
+     * Shows a list of all commands valid for the current window.
73
+     *
74
+     * @param origin The window the command was executed in
75
+     * @param isSilent Whether this command has been silenced or not
76
+     */
77
+    private void showAllCommands(final FrameContainer<?> origin, final boolean isSilent) {
78
+        final List<String> commands = new ArrayList<String>(((WritableFrameContainer<?>) origin)
79
+                .getCommandParser().getCommands().keySet());
80
+
81
+        Collections.sort(commands);
82
+
83
+        sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
84
+                + "----------------------- Available commands -------");
85
+
86
+        final StringBuilder builder = new StringBuilder();
87
+
88
+        for (String command : commands) {
89
+            if (builder.length() + command.length() + 1 > 50) {
90
+                sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED + builder.toString());
91
+                builder.delete(0, builder.length());
92
+            } else if (builder.length() > 0) {
93
+                builder.append(' ');
94
+            }
95
+
96
+            builder.append(command);
97
+        }
98
+
99
+        if (builder.length() > 0) {
100
+            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED + builder.toString());
101
+        }
102
+
103
+        sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
104
+                + "--------------------------------------------------");
105
+    }
106
+
107
+    /**
108
+     * Shows information about the specified command.
109
+     *
110
+     * @param origin The window the command was executed in
111
+     * @param isSilent Whether this command has been silenced or not
112
+     * @param name The name of the command to display info for
113
+     */
114
+    private void showCommand(final FrameContainer<?> origin, final boolean isSilent,
115
+            final String name) {
116
+        Map.Entry<CommandInfo, Command> command = null;
117
+
118
+        if (name.length() > 0 && name.charAt(0) == CommandManager.getCommandChar()) {
119
+            command = CommandManager.getCommand(name.substring(1));
120
+        } else {
121
+            command = CommandManager.getCommand(name);
122
+        }
123
+
124
+        if (command == null) {
125
+            sendLine(origin, isSilent, FORMAT_ERROR, "Command '" + name + "' not found.");
126
+        } else {
127
+            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
128
+                    + "---------------------- Command information -------");
129
+            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
130
+                    + " Name: " + name);
131
+            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
132
+                    + " Type: " + command.getKey().getType());
133
+            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
134
+                    + "Usage: " + command.getKey().getHelp());
135
+            sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
136
+                    + "--------------------------------------------------");
137
+        }
138
+    }
139
+
140
+    /** {@inheritDoc}. */
141
+    @Override
142
+    public String getName() {
143
+        return "help";
144
+    }
145
+
146
+    /** {@inheritDoc}. */
147
+    @Override
148
+    public boolean showInHelp() {
149
+        return true;
150
+    }
151
+
152
+    /** {@inheritDoc} */
153
+    @Override
154
+    public CommandType getType() {
155
+        return CommandType.TYPE_GLOBAL;
156
+    }
157
+
158
+    /** {@inheritDoc}. */
159
+    @Override
160
+    public String getHelp() {
161
+        return "help [command] - shows client command help";
162
+    }
163
+
164
+    /** {@inheritDoc} */
165
+    @Override
166
+    public AdditionalTabTargets getSuggestions(final int arg,
167
+            final IntelligentCommandContext context) {
168
+        final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
169
+
170
+        if (arg == 0) {
171
+            res.include(TabCompletionType.COMMAND);
172
+        }
173
+
174
+        return res;
175
+    }
176
+
177
+}

+ 17
- 7
src/com/dmdirc/commandparser/commands/global/Ifplugin.java Прегледај датотеку

@@ -25,10 +25,13 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.WritableFrameContainer;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
30 32
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
31 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 35
 import com.dmdirc.plugins.PluginInfo;
33 36
 import com.dmdirc.plugins.PluginManager;
34 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -40,7 +43,8 @@ import com.dmdirc.ui.input.TabCompleter;
40 43
  *
41 44
  * @author chris
42 45
  */
43
-public final class Ifplugin extends GlobalCommand implements IntelligentCommand {
46
+public final class Ifplugin extends Command implements IntelligentCommand,
47
+        CommandInfo {
44 48
     
45 49
     /**
46 50
      * Creates a new instance of Ifplugin.
@@ -53,10 +57,10 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
53 57
     
54 58
     /** {@inheritDoc} */
55 59
     @Override
56
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
57
-            final CommandArguments args) {
60
+    public void execute(final FrameContainer<?> origin,
61
+            final CommandArguments args, final CommandContext context) {
58 62
         if (args.getArguments().length <= 1) {
59
-            showUsage(origin, isSilent, "ifplugin", "<[!]plugin> <command>");
63
+            showUsage(origin, args.isSilent(), "ifplugin", "<[!]plugin> <command>");
60 64
             return;
61 65
         }
62 66
         
@@ -75,10 +79,10 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
75 79
         if (result != negative) {
76 80
             if (origin == null) {
77 81
                 GlobalCommandParser.getGlobalCommandParser().parseCommand(null,
78
-                        args.getArgumentsAsString(1));
82
+                        context.getSource(), args.getArgumentsAsString(1));
79 83
             } else {
80 84
                 ((WritableFrameContainer<?>) origin).getCommandParser()
81
-                        .parseCommand(origin, args.getArgumentsAsString(1));
85
+                        .parseCommand(origin, context.getSource(), args.getArgumentsAsString(1));
82 86
             }
83 87
         }
84 88
     }
@@ -94,6 +98,12 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
94 98
     public boolean showInHelp() {
95 99
         return true;
96 100
     }
101
+
102
+    /** {@inheritDoc} */
103
+    @Override
104
+    public CommandType getType() {
105
+        return CommandType.TYPE_GLOBAL;
106
+    }
97 107
     
98 108
     /** {@inheritDoc} */
99 109
     @Override

+ 19
- 11
src/com/dmdirc/commandparser/commands/global/Input.java Прегледај датотеку

@@ -24,12 +24,15 @@
24 24
 package com.dmdirc.commandparser.commands.global;
25 25
 
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.WritableFrameContainer;
28 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
29 29
 import com.dmdirc.commandparser.CommandManager;
30
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
31 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
32 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
35
+import com.dmdirc.ui.interfaces.InputWindow;
33 36
 
34 37
 /**
35 38
  * The input command allows you to maniplulate text in a windows inputField.
@@ -37,7 +40,7 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
37 40
  * @author Simon
38 41
  * @since 0.6.4
39 42
  */
40
-public class Input extends GlobalCommand implements IntelligentCommand {
43
+public class Input extends Command implements IntelligentCommand, CommandInfo {
41 44
 
42 45
     /**
43 46
      * Creates a new instance of Input.
@@ -50,20 +53,19 @@ public class Input extends GlobalCommand implements IntelligentCommand {
50 53
 
51 54
     /** {@inheritDoc} */
52 55
     @Override
53
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
54
-            final CommandArguments args) {
55
-
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
56 58
         if (args.getArguments().length == 0) {
57
-            showUsage(origin, isSilent, "input",
59
+            showUsage(origin, args.isSilent(), "input",
58 60
                     "[--clear] <text to insert into inputfield");
59 61
             return;
60 62
         } else if (args.getArguments().length == 1
61 63
                 && "--clear".equals(args.getArgumentsAsString(0))) {
62
-            ((WritableFrameContainer<?>) origin).getFrame()
63
-                    .getInputHandler().clearInputField();
64
+            ((InputWindow) context.getSource()).getInputHandler()
65
+                    .clearInputField();
64 66
         } else {
65
-            ((WritableFrameContainer<?>) origin).getFrame()
66
-                    .getInputHandler().addToInputField(args.getArgumentsAsString());
67
+            ((InputWindow) context.getSource()).getInputHandler()
68
+                    .addToInputField(args.getArgumentsAsString());
67 69
         }
68 70
     }
69 71
 
@@ -79,6 +81,12 @@ public class Input extends GlobalCommand implements IntelligentCommand {
79 81
         return true;
80 82
     }
81 83
 
84
+    /** {@inheritDoc} */
85
+    @Override
86
+    public CommandType getType() {
87
+        return CommandType.TYPE_GLOBAL;
88
+    }
89
+
82 90
     /** {@inheritDoc} */
83 91
     @Override
84 92
     public String getHelp() {

+ 19
- 9
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.plugins.PluginInfo;
31 34
 import com.dmdirc.plugins.PluginManager;
32 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -35,7 +38,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
  * Allows the user to load a plugin.
36 39
  * @author chris
37 40
  */
38
-public final class LoadPlugin extends GlobalCommand implements IntelligentCommand {
41
+public final class LoadPlugin extends Command implements IntelligentCommand,
42
+        CommandInfo {
39 43
 
40 44
     /**
41 45
      * Creates a new instance of LoadPlugin.
@@ -48,10 +52,10 @@ public final class LoadPlugin extends GlobalCommand implements IntelligentComman
48 52
 
49 53
     /** {@inheritDoc} */
50 54
     @Override
51
-    public void execute(final FrameContainer origin, final boolean isSilent,
52
-            final CommandArguments args) {
55
+    public void execute(final FrameContainer<?> origin,
56
+            final CommandArguments args, final CommandContext context) {
53 57
         if (args.getArguments().length == 0) {
54
-            showUsage(origin, isSilent, "loadplugin", "<plugin>");
58
+            showUsage(origin, args.isSilent(), "loadplugin", "<plugin>");
55 59
             return;
56 60
         }
57 61
 
@@ -61,16 +65,16 @@ public final class LoadPlugin extends GlobalCommand implements IntelligentComman
61 65
                 .getPluginInfo(args.getArguments()[0]);
62 66
         
63 67
         if (plugin == null) {
64
-            sendLine(origin, isSilent, FORMAT_ERROR, "Plugin loading failed");
68
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin loading failed");
65 69
         } else if (plugin.isLoaded()) {
66
-            sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin already loaded.");
70
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Plugin already loaded.");
67 71
         } else {
68 72
             plugin.loadPlugin();
69 73
             if (plugin.isLoaded()) {
70
-                sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin loaded.");
74
+                sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Plugin loaded.");
71 75
                 PluginManager.getPluginManager().updateAutoLoad(plugin);
72 76
             } else {
73
-                sendLine(origin, isSilent, FORMAT_OUTPUT, "Loading plugin failed. ("
77
+                sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Loading plugin failed. ("
74 78
                         + plugin.getLastError() + ")");
75 79
             }
76 80
         }
@@ -89,6 +93,12 @@ public final class LoadPlugin extends GlobalCommand implements IntelligentComman
89 93
         return true;
90 94
     }
91 95
 
96
+    /** {@inheritDoc} */
97
+    @Override
98
+    public CommandType getType() {
99
+        return CommandType.TYPE_GLOBAL;
100
+    }
101
+
92 102
     /** {@inheritDoc} */
93 103
     @Override
94 104
     public String getHelp() {

+ 19
- 9
src/com/dmdirc/commandparser/commands/global/NewServer.java Прегледај датотеку

@@ -25,9 +25,12 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
30 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
31 34
 import com.dmdirc.config.IdentityManager;
32 35
 import com.dmdirc.logger.ErrorLevel;
33 36
 import com.dmdirc.logger.Logger;
@@ -45,7 +48,8 @@ import java.util.regex.Pattern;
45 48
  * 
46 49
  * @author chris
47 50
  */
48
-public final class NewServer extends GlobalCommand implements IntelligentCommand {
51
+public final class NewServer extends Command implements IntelligentCommand,
52
+        CommandInfo {
49 53
 
50 54
     /**
51 55
      * Creates a new instance of NewServer.
@@ -58,12 +62,12 @@ public final class NewServer extends GlobalCommand implements IntelligentCommand
58 62
 
59 63
     /** {@inheritDoc} */
60 64
     @Override
61
-    public void execute(final FrameContainer origin, final boolean isSilent,
62
-            final CommandArguments args) {
65
+    public void execute(final FrameContainer<?> origin,
66
+            final CommandArguments args, final CommandContext context) {
63 67
         URI address = null;
64 68
 
65 69
         if (args.getArguments().length == 0) {
66
-            showUsage(origin, isSilent, "newserver",
70
+            showUsage(origin, args.isSilent(), "newserver",
67 71
                     "<host[:[+]port]> [password]");
68 72
             address = null;
69 73
             return;
@@ -77,7 +81,7 @@ public final class NewServer extends GlobalCommand implements IntelligentCommand
77 81
             }
78 82
         }
79 83
         if (address == null) {
80
-            address = parseInput(origin, isSilent, args);
84
+            address = parseInput(origin, args.isSilent(), args);
81 85
         }
82 86
 
83 87
         if (address == null) {
@@ -137,7 +141,7 @@ public final class NewServer extends GlobalCommand implements IntelligentCommand
137 141
      *
138 142
      * @return URI is input was valid
139 143
      */
140
-    public static URI parseInput(final FrameContainer origin, final boolean isSilent,
144
+    public static URI parseInput(final FrameContainer<?> origin, final boolean isSilent,
141 145
             final CommandArguments args) {
142 146
 
143 147
         boolean ssl = false;
@@ -192,7 +196,7 @@ public final class NewServer extends GlobalCommand implements IntelligentCommand
192 196
                 if (origin == null) {
193 197
                     Logger.userError(ErrorLevel.LOW, "Port must be between 1 " +
194 198
                             "and 65535 in newserver command");
195
-                } else if (!isSilent) {
199
+                } else if (!args.isSilent()) {
196 200
                     origin.addLine(FORMAT_ERROR, "Port must be between 1 and 65535");
197 201
                 }
198 202
 
@@ -213,7 +217,7 @@ public final class NewServer extends GlobalCommand implements IntelligentCommand
213 217
             if (origin == null) {
214 218
                 Logger.userError(ErrorLevel.LOW, "Invalid address provided to "
215 219
                         + "newserver command. Host: " + host + ", Port: " + port, ex);
216
-            } else if (!isSilent) {
220
+            } else if (!args.isSilent()) {
217 221
                 origin.addLine(FORMAT_ERROR, "Invalid address specified.");
218 222
             }
219 223
 
@@ -233,6 +237,12 @@ public final class NewServer extends GlobalCommand implements IntelligentCommand
233 237
         return true;
234 238
     }
235 239
 
240
+    /** {@inheritDoc} */
241
+    @Override
242
+    public CommandType getType() {
243
+        return CommandType.TYPE_GLOBAL;
244
+    }
245
+
236 246
     /** {@inheritDoc} */
237 247
     @Override
238 248
     public String getHelp() {

+ 16
- 6
src/com/dmdirc/commandparser/commands/global/Notify.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 34
 import com.dmdirc.ui.messages.ColourManager;
32 35
 
@@ -38,7 +41,8 @@ import java.awt.Color;
38 41
  * 
39 42
  * @author chris
40 43
  */
41
-public final class Notify extends GlobalCommand implements IntelligentCommand {
44
+public final class Notify extends Command implements IntelligentCommand,
45
+        CommandInfo {
42 46
     
43 47
     /**
44 48
      * Creates a new instance of Notify.
@@ -51,17 +55,17 @@ public final class Notify extends GlobalCommand implements IntelligentCommand {
51 55
     
52 56
     /** {@inheritDoc} */
53 57
     @Override
54
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
55
-            final CommandArguments args) {
58
+    public void execute(final FrameContainer<?> origin,
59
+            final CommandArguments args, final CommandContext context) {
56 60
         if (args.getArguments().length == 0) {
57
-            showUsage(origin, isSilent, "notify", "<colour>");
61
+            showUsage(origin, args.isSilent(), "notify", "<colour>");
58 62
             return;
59 63
         }
60 64
         
61 65
         final Color colour = ColourManager.parseColour(args.getArguments()[0], null);
62 66
         
63 67
         if (colour == null) {
64
-            showUsage(origin, isSilent, "notify",
68
+            showUsage(origin, args.isSilent(), "notify",
65 69
                     "<colour> - colour must be an IRC colour code (0-15) or a " +
66 70
                     "hex string (e.g. FFFF00).");
67 71
         } else if (origin != null) {            
@@ -82,6 +86,12 @@ public final class Notify extends GlobalCommand implements IntelligentCommand {
82 86
     public boolean showInHelp() {
83 87
         return false;
84 88
     }
89
+
90
+    /** {@inheritDoc} */
91
+    @Override
92
+    public CommandType getType() {
93
+        return CommandType.TYPE_GLOBAL;
94
+    }
85 95
     
86 96
     /** {@inheritDoc} */
87 97
     @Override

+ 18
- 9
src/com/dmdirc/commandparser/commands/global/OpenWindow.java Прегледај датотеку

@@ -25,9 +25,12 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.CustomWindow;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
30 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
31 34
 import com.dmdirc.ui.WindowManager;
32 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 36
 
@@ -36,7 +39,7 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
36 39
  * 
37 40
  * @author chris
38 41
  */
39
-public class OpenWindow extends GlobalCommand implements IntelligentCommand {
42
+public class OpenWindow extends Command implements IntelligentCommand, CommandInfo {
40 43
     
41 44
     /**
42 45
      * Creates a new instance of OpenWindow.
@@ -47,14 +50,14 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
47 50
 
48 51
     /** {@inheritDoc} */
49 52
     @Override
50
-    public void execute(final FrameContainer origin, final boolean isSilent,
51
-            final CommandArguments args) {
53
+    public void execute(final FrameContainer<?> origin,
54
+            final CommandArguments args, final CommandContext context) {
52 55
         int start = 0;
53
-        FrameContainer parent = null;
56
+        FrameContainer<?> parent = null;
54 57
 
55 58
         if (args.getArguments().length > 0 && "--server".equals(args.getArguments()[0])) {
56 59
             if (origin.getServer() == null) {
57
-                sendLine(origin, isSilent, FORMAT_ERROR,
60
+                sendLine(origin, args.isSilent(), FORMAT_ERROR,
58 61
                         "This window doesn't have an associated server.");
59 62
                 return;
60 63
             }
@@ -67,10 +70,10 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
67 70
         }
68 71
 
69 72
         if (args.getArguments().length == start || args.getArguments()[start].isEmpty()) {
70
-            showUsage(origin, isSilent, "openwindow",
73
+            showUsage(origin, args.isSilent(), "openwindow",
71 74
                     "[--server|--child] <name> [title]");
72 75
         } else {
73
-            FrameContainer window;
76
+            FrameContainer<?> window;
74 77
             
75 78
             if (parent == null) {
76 79
                 window = WindowManager.findCustomWindow(args.getArguments()[start]);
@@ -88,7 +91,7 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
88 91
                     new CustomWindow(args.getArguments()[start], title, parent);
89 92
                 }
90 93
             } else {
91
-                sendLine(origin, isSilent, FORMAT_ERROR,
94
+                sendLine(origin, args.isSilent(), FORMAT_ERROR,
92 95
                 "A custom window by that name already exists.");
93 96
             }
94 97
         }
@@ -107,6 +110,12 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
107 110
         return "openwindow";
108 111
     }
109 112
 
113
+    /** {@inheritDoc} */
114
+    @Override
115
+    public CommandType getType() {
116
+        return CommandType.TYPE_GLOBAL;
117
+    }
118
+
110 119
     /** {@inheritDoc} */
111 120
     @Override
112 121
     public boolean showInHelp() {

+ 15
- 5
src/com/dmdirc/commandparser/commands/global/ReloadActions.java Прегледај датотеку

@@ -25,9 +25,12 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.actions.ActionManager;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.GlobalCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
30 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
31 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 35
 
33 36
 /**
@@ -35,7 +38,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
  *
36 39
  * @author chris
37 40
  */
38
-public final class ReloadActions extends GlobalCommand implements IntelligentCommand {
41
+public final class ReloadActions extends Command implements IntelligentCommand,
42
+        CommandInfo {
39 43
     
40 44
     /**
41 45
      * Creates a new instance of ReloadActions.
@@ -48,10 +52,10 @@ public final class ReloadActions extends GlobalCommand implements IntelligentCom
48 52
     
49 53
     /** {@inheritDoc} */
50 54
     @Override
51
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
52
-            final CommandArguments args) {
55
+    public void execute(final FrameContainer<?> origin,
56
+            final CommandArguments args, final CommandContext context) {
53 57
         ActionManager.loadActions();
54
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Actions reloaded.");
58
+        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Actions reloaded.");
55 59
     }
56 60
     
57 61
     
@@ -66,6 +70,12 @@ public final class ReloadActions extends GlobalCommand implements IntelligentCom
66 70
     public boolean showInHelp() {
67 71
         return true;
68 72
     }
73
+
74
+    /** {@inheritDoc} */
75
+    @Override
76
+    public CommandType getType() {
77
+        return CommandType.TYPE_GLOBAL;
78
+    }
69 79
     
70 80
     /** {@inheritDoc}. */
71 81
     @Override

+ 15
- 5
src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.config.IdentityManager;
31 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 35
 
@@ -35,7 +38,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
  * 
36 39
  * @author chris
37 40
  */
38
-public class ReloadIdentities extends GlobalCommand implements IntelligentCommand {
41
+public class ReloadIdentities extends Command implements IntelligentCommand,
42
+        CommandInfo {
39 43
     
40 44
     /**
41 45
      * Creates a new instance of ReloadIdentities.
@@ -46,11 +50,11 @@ public class ReloadIdentities extends GlobalCommand implements IntelligentComman
46 50
 
47 51
     /** {@inheritDoc} */
48 52
     @Override    
49
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
50
-            final CommandArguments args) {
53
+    public void execute(final FrameContainer<?> origin,
54
+            final CommandArguments args, final CommandContext context) {
51 55
         IdentityManager.loadUser();
52 56
         
53
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Identities reloaded.");
57
+        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Identities reloaded.");
54 58
     }
55 59
 
56 60
     /** {@inheritDoc} */
@@ -65,6 +69,12 @@ public class ReloadIdentities extends GlobalCommand implements IntelligentComman
65 69
         return true;
66 70
     }
67 71
 
72
+    /** {@inheritDoc} */
73
+    @Override
74
+    public CommandType getType() {
75
+        return CommandType.TYPE_GLOBAL;
76
+    }
77
+
68 78
     /** {@inheritDoc} */
69 79
     @Override
70 80
     public String getHelp() {

+ 21
- 9
src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.plugins.PluginInfo;
31 34
 import com.dmdirc.plugins.PluginManager;
32 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -36,7 +39,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
36 39
  * 
37 40
  * @author chris
38 41
  */
39
-public final class ReloadPlugin extends GlobalCommand implements IntelligentCommand {
42
+public final class ReloadPlugin extends Command implements IntelligentCommand,
43
+        CommandInfo {
40 44
     
41 45
     /**
42 46
      * Creates a new instance of ReloadPlugin.
@@ -49,20 +53,22 @@ public final class ReloadPlugin extends GlobalCommand implements IntelligentComm
49 53
     
50 54
     /** {@inheritDoc} */
51 55
     @Override
52
-    public void execute(final FrameContainer origin, final boolean isSilent,
53
-            final CommandArguments args) {
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
54 58
         if (args.getArguments().length == 0) {
55
-            showUsage(origin, isSilent, "reloadplugin", "<plugin>");
59
+            showUsage(origin, args.isSilent(), "reloadplugin", "<plugin>");
56 60
             return;
57 61
         }
58 62
         
59
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args.getArguments()[0]);
63
+        final PluginInfo plugin = PluginManager.getPluginManager()
64
+                .getPluginInfoByName(args.getArguments()[0]);
60 65
         if (plugin == null) {
61
-            sendLine(origin, isSilent, FORMAT_ERROR, "Plugin Reloading failed - Plugin not loaded");
66
+            sendLine(origin, args.isSilent(), FORMAT_ERROR,
67
+                    "Plugin Reloading failed - Plugin not loaded");
62 68
         } else if (PluginManager.getPluginManager().reloadPlugin(plugin.getRelativeFilename())) {
63
-            sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin Reloaded.");
69
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Plugin Reloaded.");
64 70
         } else {
65
-            sendLine(origin, isSilent, FORMAT_ERROR, "Plugin Reloading failed");
71
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin Reloading failed");
66 72
         }
67 73
     }
68 74
     
@@ -77,6 +83,12 @@ public final class ReloadPlugin extends GlobalCommand implements IntelligentComm
77 83
     public boolean showInHelp() {
78 84
         return true;
79 85
     }
86
+
87
+    /** {@inheritDoc} */
88
+    @Override
89
+    public CommandType getType() {
90
+        return CommandType.TYPE_GLOBAL;
91
+    }
80 92
     
81 93
     /** {@inheritDoc} */
82 94
     @Override

+ 15
- 5
src/com/dmdirc/commandparser/commands/global/SaveConfig.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.config.IdentityManager;
31 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 35
 
@@ -35,7 +38,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
35 38
  * 
36 39
  * @author chris
37 40
  */
38
-public final class SaveConfig extends GlobalCommand implements IntelligentCommand {
41
+public final class SaveConfig extends Command implements IntelligentCommand,
42
+        CommandInfo {
39 43
     
40 44
     /**
41 45
      * Creates a new instance of SaveConfig.
@@ -48,11 +52,11 @@ public final class SaveConfig extends GlobalCommand implements IntelligentComman
48 52
     
49 53
     /** {@inheritDoc} */
50 54
     @Override
51
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
52
-            final CommandArguments args) {
55
+    public void execute(final FrameContainer<?> origin,
56
+            final CommandArguments args, final CommandContext context) {
53 57
         IdentityManager.save();
54 58
         
55
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Configuration file saved.");
59
+        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Configuration file saved.");
56 60
     }
57 61
     
58 62
     
@@ -67,6 +71,12 @@ public final class SaveConfig extends GlobalCommand implements IntelligentComman
67 71
     public boolean showInHelp() {
68 72
         return true;
69 73
     }
74
+
75
+    /** {@inheritDoc} */
76
+    @Override
77
+    public CommandType getType() {
78
+        return CommandType.TYPE_GLOBAL;
79
+    }
70 80
     
71 81
     /** {@inheritDoc} */
72 82
     @Override

+ 54
- 45
src/com/dmdirc/commandparser/commands/global/Set.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.config.ConfigManager;
31 34
 import com.dmdirc.config.Identity;
32 35
 import com.dmdirc.config.IdentityManager;
@@ -39,26 +42,26 @@ import java.util.List;
39 42
  *
40 43
  * @author chris
41 44
  */
42
-public final class Set extends GlobalCommand implements IntelligentCommand {
43
-    
45
+public final class Set extends Command implements IntelligentCommand, CommandInfo {
46
+
44 47
     /**
45 48
      * Creates a new instance of Set.
46 49
      */
47 50
     public Set() {
48 51
         super();
49
-        
52
+
50 53
         CommandManager.registerCommand(this);
51 54
     }
52
-    
55
+
53 56
     /** {@inheritDoc} */
54 57
     @Override
55
-    public void execute(final FrameContainer origin, final boolean isSilent,
56
-            final CommandArguments args) {
58
+    public void execute(final FrameContainer<?> origin,
59
+            final CommandArguments args, final CommandContext context) {
57 60
         int i = 0;
58
-        
61
+
59 62
         Identity identity = IdentityManager.getConfigIdentity();
60 63
         ConfigManager manager = IdentityManager.getGlobalConfig();
61
-        
64
+
62 65
         if (args.getArguments().length > 0
63 66
                 && "--server".equalsIgnoreCase(args.getArguments()[0]) && origin != null
64 67
                 && origin.getServer() != null) {
@@ -66,34 +69,34 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
66 69
             identity = origin.getServer().getServerIdentity();
67 70
             manager = origin.getServer().getConfigManager();
68 71
         }
69
-        
72
+
70 73
         switch (args.getArguments().length - i) {
71 74
         case 0:
72
-            doDomainList(origin, isSilent, manager);
75
+            doDomainList(origin, args.isSilent(), manager);
73 76
             break;
74 77
         case 1:
75
-            doOptionsList(origin, isSilent, manager, args.getArguments()[i]);
78
+            doOptionsList(origin, args.isSilent(), manager, args.getArguments()[i]);
76 79
             break;
77 80
         case 2:
78
-            doShowOption(origin, isSilent, manager, args.getArguments()[i],
81
+            doShowOption(origin, args.isSilent(), manager, args.getArguments()[i],
79 82
                     args.getArguments()[1 + i]);
80 83
             break;
81 84
         default:
82 85
             if (args.getArguments()[i].equalsIgnoreCase("--unset")) {
83
-                doUnsetOption(origin, isSilent, identity, args.getArguments()[1 + i],
86
+                doUnsetOption(origin, args.isSilent(), identity, args.getArguments()[1 + i],
84 87
                         args.getArguments()[2 + i]);
85 88
             } else if (args.getArguments()[i].equalsIgnoreCase("--append")
86 89
                     && args.getArguments().length > 3 + i) {
87
-                doAppendOption(origin, isSilent, identity, manager, 
90
+                doAppendOption(origin, args.isSilent(), identity, manager,
88 91
                         args.getArguments()[1 + i], args.getArguments()[2 + i],
89 92
                         args.getArgumentsAsString(3 + i));
90 93
             } else {
91
-                doSetOption(origin, isSilent, identity, args.getArguments()[i],
94
+                doSetOption(origin, args.isSilent(), identity, args.getArguments()[i],
92 95
                         args.getArguments()[1 + i], args.getArgumentsAsString(2 + i));
93 96
             }
94 97
         }
95 98
     }
96
-    
99
+
97 100
     /**
98 101
      * Shows the user a list of valid domains.
99 102
      *
@@ -101,22 +104,22 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
101 104
      * @param isSilent Whether or not the command is being silenced or not
102 105
      * @param manager The config manager to use to retrieve data
103 106
      */
104
-    private void doDomainList(final FrameContainer origin, final boolean isSilent,
107
+    private void doDomainList(final FrameContainer<?> origin, final boolean isSilent,
105 108
             final ConfigManager manager) {
106 109
         final StringBuffer output = new StringBuffer(67);
107
-        
110
+
108 111
         output.append("Valid domains (use ");
109 112
         output.append(CommandManager.getCommandChar());
110 113
         output.append("set <domain> to see options within a domain): ");
111
-        
114
+
112 115
         for (String domain : manager.getDomains()) {
113 116
             output.append(domain);
114 117
             output.append(", ");
115 118
         }
116
-        
119
+
117 120
         sendLine(origin, isSilent, FORMAT_OUTPUT, output.substring(0, output.length() - 2));
118 121
     }
119
-    
122
+
120 123
     /**
121 124
      * Shows the user a list of valid options within a domain.
122 125
      *
@@ -125,30 +128,30 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
125 128
      * @param manager The config manager to use to retrieve data
126 129
      * @param domain The domain to be inspected
127 130
      */
128
-    private void doOptionsList(final FrameContainer origin,
131
+    private void doOptionsList(final FrameContainer<?> origin,
129 132
             final boolean isSilent, final ConfigManager manager, final String domain) {
130 133
         final StringBuffer output = new StringBuffer(24);
131
-        
134
+
132 135
         output.append("Options in domain '");
133 136
         output.append(domain);
134 137
         output.append("': ");
135
-        
138
+
136 139
         boolean found = false;
137
-        
140
+
138 141
         for (String option : manager.getOptions(domain).keySet()) {
139 142
             output.append(option);
140 143
             output.append(", ");
141 144
             found = true;
142 145
         }
143
-        
146
+
144 147
         if (found) {
145 148
             sendLine(origin, isSilent, FORMAT_OUTPUT, output.substring(0, output.length() - 2));
146 149
         } else {
147
-            sendLine(origin, isSilent, FORMAT_ERROR, 
150
+            sendLine(origin, isSilent, FORMAT_ERROR,
148 151
                     "There are no options in the domain '" + domain + "'.");
149 152
         }
150 153
     }
151
-    
154
+
152 155
     /**
153 156
      * Shows the user the current value of one option.
154 157
      *
@@ -158,7 +161,7 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
158 161
      * @param domain The domain of the option
159 162
      * @param option The name of the option
160 163
      */
161
-    private void doShowOption(final FrameContainer origin,
164
+    private void doShowOption(final FrameContainer<?> origin,
162 165
             final boolean isSilent, final ConfigManager manager,
163 166
             final String domain, final String option) {
164 167
         if (manager.hasOptionString(domain, option)) {
@@ -168,7 +171,7 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
168 171
             sendLine(origin, isSilent, FORMAT_ERROR, "Option not found: " + domain + "." + option);
169 172
         }
170 173
     }
171
-    
174
+
172 175
     /**
173 176
      * Sets the value of the specified option.
174 177
      *
@@ -179,15 +182,15 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
179 182
      * @param option The name of the option
180 183
      * @param newvalue The value the option should be set to
181 184
      */
182
-    private void doSetOption(final FrameContainer origin,
185
+    private void doSetOption(final FrameContainer<?> origin,
183 186
             final boolean isSilent, final Identity identity,
184 187
             final String domain, final String option, final String newvalue) {
185 188
         identity.setOption(domain, option, newvalue);
186
-        
189
+
187 190
         sendLine(origin, isSilent, FORMAT_OUTPUT, domain + "." + option +
188 191
                 " has been set to: " + newvalue);
189 192
     }
190
-    
193
+
191 194
     /**
192 195
      * Appends data to the specified option.
193 196
      *
@@ -199,14 +202,14 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
199 202
      * @param option The name of the option
200 203
      * @param data The data to be appended
201 204
      */
202
-    private void doAppendOption(final FrameContainer origin,
205
+    private void doAppendOption(final FrameContainer<?> origin,
203 206
             final boolean isSilent, final Identity identity, final ConfigManager manager,
204 207
             final String domain,final String option, final String data) {
205 208
         doSetOption(origin, isSilent, identity, domain, option,
206 209
                 (manager.hasOptionString(domain, option) ?
207 210
                     manager.getOption(domain, option) : "") + data);
208 211
     }
209
-    
212
+
210 213
     /**
211 214
      * Unsets the specified option.
212 215
      *
@@ -216,26 +219,32 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
216 219
      * @param domain The domain of the option
217 220
      * @param option The name of the option
218 221
      */
219
-    private void doUnsetOption(final FrameContainer origin,
222
+    private void doUnsetOption(final FrameContainer<?> origin,
220 223
             final boolean isSilent, final Identity identity, final String domain,
221 224
             final String option) {
222 225
         identity.unsetOption(domain, option);
223
-        
226
+
224 227
         sendLine(origin, isSilent, FORMAT_OUTPUT, domain + "." + option + " has been unset.");
225 228
     }
226
-    
229
+
227 230
     /** {@inheritDoc} */
228 231
     @Override
229 232
     public String getName() {
230 233
         return "set";
231 234
     }
232
-    
235
+
233 236
     /** {@inheritDoc} */
234 237
     @Override
235 238
     public boolean showInHelp() {
236 239
         return true;
237 240
     }
238
-    
241
+
242
+    /** {@inheritDoc} */
243
+    @Override
244
+    public CommandType getType() {
245
+        return CommandType.TYPE_GLOBAL;
246
+    }
247
+
239 248
     /** {@inheritDoc} */
240 249
     @Override
241 250
     public String getHelp() {
@@ -243,14 +252,14 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
243 252
                 + "\nset [--server] --append <domain> <option> <data> - appends data to the specified option"
244 253
                 + "\nset [--server] --unset <domain> <option> - unsets the specified option";
245 254
     }
246
-    
255
+
247 256
     /** {@inheritDoc} */
248 257
     @Override
249 258
     public AdditionalTabTargets getSuggestions(final int arg,
250 259
             final IntelligentCommandContext context) {
251 260
         final List<String> previousArgs = context.getPreviousArgs();
252 261
         final AdditionalTabTargets res = new AdditionalTabTargets();
253
-        
262
+
254 263
         if (arg == 0) {
255 264
             res.addAll(context.getWindow().getContainer().getConfigManager()
256 265
                     .getDomains());
@@ -276,8 +285,8 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
276 285
                     .getOptions(previousArgs.get(1)).keySet());
277 286
             res.excludeAll();
278 287
         }
279
-        
288
+
280 289
         return res;
281 290
     }
282
-    
291
+
283 292
 }

+ 18
- 8
src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java Прегледај датотеку

@@ -24,9 +24,12 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28
-import com.dmdirc.commandparser.commands.GlobalCommand;
29
+import com.dmdirc.commandparser.CommandType;
30
+import com.dmdirc.commandparser.commands.Command;
29 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
30 33
 import com.dmdirc.plugins.PluginInfo;
31 34
 import com.dmdirc.plugins.PluginManager;
32 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -36,7 +39,8 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
36 39
  * 
37 40
  * @author chris
38 41
  */
39
-public final class UnloadPlugin extends GlobalCommand implements IntelligentCommand {
42
+public final class UnloadPlugin extends Command implements IntelligentCommand,
43
+        CommandInfo {
40 44
     
41 45
     /**
42 46
      * Creates a new instance of UnloadPlugin.
@@ -49,22 +53,22 @@ public final class UnloadPlugin extends GlobalCommand implements IntelligentComm
49 53
     
50 54
     /** {@inheritDoc} */
51 55
     @Override
52
-    public void execute(final FrameContainer<?> origin, final boolean isSilent,
53
-            final CommandArguments args) {
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
54 58
         if (args.getArguments().length == 0) {
55
-            showUsage(origin, isSilent, "unloadplugin", "<plugin>");
59
+            showUsage(origin, args.isSilent(), "unloadplugin", "<plugin>");
56 60
             return;
57 61
         }
58 62
         
59 63
         final PluginInfo plugin = PluginManager.getPluginManager()
60 64
                 .getPluginInfoByName(args.getArguments()[0]);
61 65
         if (plugin == null) {
62
-            sendLine(origin, isSilent, FORMAT_ERROR, "Plugin unloading failed - Plugin not loaded");
66
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin unloading failed - Plugin not loaded");
63 67
         } else if (PluginManager.getPluginManager().delPlugin(plugin.getRelativeFilename())) {
64
-            sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin Unloaded.");
68
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Plugin Unloaded.");
65 69
             PluginManager.getPluginManager().updateAutoLoad(plugin);
66 70
         } else {
67
-            sendLine(origin, isSilent, FORMAT_ERROR, "Plugin Unloading failed");
71
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin Unloading failed");
68 72
         }
69 73
     }
70 74
     
@@ -79,6 +83,12 @@ public final class UnloadPlugin extends GlobalCommand implements IntelligentComm
79 83
     public boolean showInHelp() {
80 84
         return true;
81 85
     }
86
+
87
+    /** {@inheritDoc} */
88
+    @Override
89
+    public CommandType getType() {
90
+        return CommandType.TYPE_GLOBAL;
91
+    }
82 92
     
83 93
     /** {@inheritDoc} */
84 94
     @Override

+ 17
- 5
src/com/dmdirc/commandparser/commands/server/AllChannels.java Прегледај датотеку

@@ -25,9 +25,13 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
30
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
31 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 36
 import com.dmdirc.ui.input.TabCompleter;
33 37
 
@@ -36,7 +40,8 @@ import com.dmdirc.ui.input.TabCompleter;
36 40
  * on a server.
37 41
  * @author chris
38 42
  */
39
-public final class AllChannels extends ServerCommand implements IntelligentCommand {
43
+public final class AllChannels extends Command implements IntelligentCommand,
44
+        CommandInfo {
40 45
     
41 46
     /** Creates a new instance of AllChannels. */
42 47
     public AllChannels() {
@@ -47,13 +52,14 @@ public final class AllChannels extends ServerCommand implements IntelligentComma
47 52
     
48 53
     /** {@inheritDoc} */
49 54
     @Override
50
-    public void execute(final FrameContainer<?> origin, final Server server,
51
-            final boolean isSilent, final CommandArguments args) {
55
+    public void execute(final FrameContainer<?> origin,
56
+            final CommandArguments args, final CommandContext context) {
57
+        final Server server = ((ServerCommandContext) context).getServer();
52 58
         final String command = args.getArgumentsAsString();
53 59
         
54 60
         for (String channel : server.getChannels()) {
55 61
             server.getChannel(channel).getCommandParser()
56
-                    .parseCommand(server.getChannel(channel), command);
62
+                    .parseCommand(server.getChannel(channel), context.getSource(), command);
57 63
         }
58 64
     }
59 65
     
@@ -69,6 +75,12 @@ public final class AllChannels extends ServerCommand implements IntelligentComma
69 75
     public boolean showInHelp() {
70 76
         return true;
71 77
     }
78
+
79
+    /** {@inheritDoc} */
80
+    @Override
81
+    public CommandType getType() {
82
+        return CommandType.TYPE_SERVER;
83
+    }
72 84
     
73 85
     /** {@inheritDoc} */
74 86
     @Override

+ 15
- 4
src/com/dmdirc/commandparser/commands/server/Away.java Прегледај датотеку

@@ -25,16 +25,20 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
31 35
 
32 36
 /**
33 37
  * The away command allows the user to set their away message.
34 38
  * @author chris
35 39
  */
36 40
 @CommandOptions(allowOffline=false)
37
-public final class Away extends ServerCommand {
41
+public final class Away extends Command implements CommandInfo {
38 42
     
39 43
     /**
40 44
      * Creates a new instance of Away.
@@ -47,8 +51,9 @@ public final class Away extends ServerCommand {
47 51
     
48 52
     /** {@inheritDoc} */
49 53
     @Override
50
-    public void execute(final FrameContainer origin, final Server server,
51
-            final boolean isSilent, final CommandArguments args) {
54
+    public void execute(final FrameContainer<?> origin,
55
+            final CommandArguments args, final CommandContext context) {
56
+        final Server server = ((ServerCommandContext) context).getServer();
52 57
         final String line = args.getArgumentsAsString();
53 58
 
54 59
         server.getParser().getLocalClient().setAway(line);
@@ -66,6 +71,12 @@ public final class Away extends ServerCommand {
66 71
     public boolean showInHelp() {
67 72
         return true;
68 73
     }
74
+
75
+    /** {@inheritDoc} */
76
+    @Override
77
+    public CommandType getType() {
78
+        return CommandType.TYPE_SERVER;
79
+    }
69 80
     
70 81
     /** {@inheritDoc} */
71 82
     @Override

+ 16
- 11
src/com/dmdirc/commandparser/commands/server/Back.java Прегледај датотеку

@@ -25,10 +25,14 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
-import com.dmdirc.commandparser.commands.ServerCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 37
 
34 38
 /**
@@ -36,7 +40,7 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
36 40
  * @author chris
37 41
  */
38 42
 @CommandOptions(allowOffline=false)
39
-public final class Back extends ServerCommand implements IntelligentCommand {
43
+public final class Back extends Command implements IntelligentCommand, CommandInfo {
40 44
     
41 45
     /**
42 46
      * Creates a new instance of Back.
@@ -47,16 +51,11 @@ public final class Back extends ServerCommand implements IntelligentCommand {
47 51
         CommandManager.registerCommand(this);
48 52
     }
49 53
     
50
-    /**
51
-     * Executes this command.
52
-     * @param origin The frame in which this command was issued
53
-     * @param server The server object that this command is associated with
54
-     * @param isSilent Whether this command is silenced or not
55
-     * @param args The user supplied arguments
56
-     */
54
+    /** {@inheritDoc} */
57 55
     @Override
58
-    public void execute(final FrameContainer origin, final Server server,
59
-            final boolean isSilent, final CommandArguments args) {        
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
58
+        final Server server = ((ServerCommandContext) context).getServer();
60 59
         server.getParser().getLocalClient().setBack();
61 60
     }
62 61
     
@@ -72,6 +71,12 @@ public final class Back extends ServerCommand implements IntelligentCommand {
72 71
     public boolean showInHelp() {
73 72
         return true;
74 73
     }
74
+
75
+    /** {@inheritDoc} */
76
+    @Override
77
+    public CommandType getType() {
78
+        return CommandType.TYPE_SERVER;
79
+    }
75 80
     
76 81
     /** {@inheritDoc}. */
77 82
     @Override

+ 17
- 6
src/com/dmdirc/commandparser/commands/server/ChangeServer.java Прегледај датотеку

@@ -25,8 +25,12 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.ServerCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
30 34
 import com.dmdirc.commandparser.commands.global.NewServer;
31 35
 
32 36
 import java.net.URI;
@@ -37,7 +41,7 @@ import java.net.URISyntaxException;
37 41
  * 
38 42
  * @author chris
39 43
  */
40
-public final class ChangeServer extends ServerCommand {
44
+public final class ChangeServer extends Command implements CommandInfo {
41 45
     
42 46
     /**
43 47
      * Creates a new instance of ChangeServer.
@@ -50,11 +54,12 @@ public final class ChangeServer extends ServerCommand {
50 54
     
51 55
     /** {@inheritDoc} */
52 56
     @Override
53
-    public void execute(final FrameContainer origin,  final Server server,
54
-            final boolean isSilent, final CommandArguments args) {
57
+    public void execute(final FrameContainer<?> origin,
58
+            final CommandArguments args, final CommandContext context) {
59
+        final Server server = ((ServerCommandContext) context).getServer();
55 60
         URI address = null;
56 61
         if (args.getArguments().length == 0) {
57
-            showUsage(origin, isSilent, "server", "<host[:[+]port]> [password]");
62
+            showUsage(origin, args.isSilent(), "server", "<host[:[+]port]> [password]");
58 63
             address = null;
59 64
             return;
60 65
         } else if (args.getArguments().length == 1
@@ -66,7 +71,7 @@ public final class ChangeServer extends ServerCommand {
66 71
             }
67 72
         }
68 73
         if (address == null) {
69
-            address = NewServer.parseInput(origin, isSilent, args);
74
+            address = NewServer.parseInput(origin, args.isSilent(), args);
70 75
         }
71 76
 
72 77
         if (address == null) {
@@ -87,6 +92,12 @@ public final class ChangeServer extends ServerCommand {
87 92
     public boolean showInHelp() {
88 93
         return true;
89 94
     }
95
+
96
+    /** {@inheritDoc} */
97
+    @Override
98
+    public CommandType getType() {
99
+        return CommandType.TYPE_SERVER;
100
+    }
90 101
     
91 102
     /** {@inheritDoc} */
92 103
     @Override

+ 19
- 13
src/com/dmdirc/commandparser/commands/server/Ctcp.java Прегледај датотеку

@@ -25,10 +25,14 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
-import com.dmdirc.commandparser.commands.ServerCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 37
 import com.dmdirc.ui.input.TabCompletionType;
34 38
 
@@ -37,7 +41,8 @@ import com.dmdirc.ui.input.TabCompletionType;
37 41
  * @author chris
38 42
  */
39 43
 @CommandOptions(allowOffline=false)
40
-public final class Ctcp extends ServerCommand implements IntelligentCommand {
44
+public final class Ctcp extends Command implements IntelligentCommand,
45
+        CommandInfo {
41 46
     
42 47
     /**
43 48
      * Creates a new instance of Ctcp.
@@ -48,22 +53,17 @@ public final class Ctcp extends ServerCommand implements IntelligentCommand {
48 53
         CommandManager.registerCommand(this);
49 54
     }
50 55
     
51
-    /**
52
-     * Executes this command.
53
-     * @param origin The frame in which this command was issued
54
-     * @param server The server object that this command is associated with
55
-     * @param isSilent Whether this command is silenced or not
56
-     * @param args The user supplied arguments
57
-     */
56
+    /** {@inheritDoc} */
58 57
     @Override
59
-    public void execute(final FrameContainer origin, final Server server,
60
-            final boolean isSilent, final CommandArguments args) {
58
+    public void execute(final FrameContainer<?> origin,
59
+            final CommandArguments args, final CommandContext context) {
60
+        final Server server = ((ServerCommandContext) context).getServer();
61 61
         if (args.getArguments().length < 2) {
62
-            showUsage(origin, isSilent, "ctcp", "<target> <type> [arguments]");
62
+            showUsage(origin, args.isSilent(), "ctcp", "<target> <type> [arguments]");
63 63
         } else {
64 64
             server.getParser().sendCTCP(args.getArguments()[0],
65 65
                     args.getArguments()[1], args.getArgumentsAsString(2));
66
-            sendLine(origin, isSilent, "selfCTCP", args.getArguments()[0],
66
+            sendLine(origin, args.isSilent(), "selfCTCP", args.getArguments()[0],
67 67
                     args.getArgumentsAsString(1));
68 68
         }
69 69
     }
@@ -80,6 +80,12 @@ public final class Ctcp extends ServerCommand implements IntelligentCommand {
80 80
     public boolean showInHelp() {
81 81
         return true;
82 82
     }
83
+
84
+    /** {@inheritDoc} */
85
+    @Override
86
+    public CommandType getType() {
87
+        return CommandType.TYPE_SERVER;
88
+    }
83 89
     
84 90
     /** {@inheritDoc}. */
85 91
     @Override

+ 16
- 11
src/com/dmdirc/commandparser/commands/server/Disconnect.java Прегледај датотеку

@@ -25,14 +25,18 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.ServerCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
30 34
 
31 35
 /**
32 36
  * The disconnect command disconnects from the current server.
33 37
  * @author chris
34 38
  */
35
-public final class Disconnect extends ServerCommand {
39
+public final class Disconnect extends Command implements CommandInfo {
36 40
     
37 41
     /**
38 42
      * Creates a new instance of Disconnect.
@@ -43,16 +47,11 @@ public final class Disconnect extends ServerCommand {
43 47
         CommandManager.registerCommand(this);
44 48
     }
45 49
     
46
-    /**
47
-     * Executes this command.
48
-     * @param origin The frame in which this command was issued
49
-     * @param server The server object that this command is associated with
50
-     * @param isSilent Whether this command is silenced or not
51
-     * @param args The user supplied arguments
52
-     */
50
+    /** {@inheritDoc} */
53 51
     @Override
54
-    public void execute(final FrameContainer origin, final Server server,
55
-            final boolean isSilent, final CommandArguments args) {
52
+    public void execute(final FrameContainer<?> origin,
53
+            final CommandArguments args, final CommandContext context) {
54
+        final Server server = ((ServerCommandContext) context).getServer();
56 55
         String line;
57 56
         
58 57
         if (args.getArguments().length == 0) {
@@ -76,6 +75,12 @@ public final class Disconnect extends ServerCommand {
76 75
     public boolean showInHelp() {
77 76
         return true;
78 77
     }
78
+
79
+    /** {@inheritDoc} */
80
+    @Override
81
+    public CommandType getType() {
82
+        return CommandType.TYPE_SERVER;
83
+    }
79 84
     
80 85
     /** {@inheritDoc} */
81 86
     @Override

+ 36
- 30
src/com/dmdirc/commandparser/commands/server/Ignore.java Прегледај датотеку

@@ -25,9 +25,13 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
30
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
31 35
 import com.dmdirc.parser.common.IgnoreList;
32 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 37
 import com.dmdirc.ui.input.TabCompletionType;
@@ -40,7 +44,8 @@ import java.util.regex.PatternSyntaxException;
40 44
  * Allows the user to add/view/delete ignores.
41 45
  * @author chris
42 46
  */
43
-public final class Ignore extends ServerCommand implements IntelligentCommand {
47
+public final class Ignore extends Command implements IntelligentCommand,
48
+        CommandInfo{
44 49
     
45 50
     /**
46 51
      * Creates a new instance of Ignore.
@@ -51,34 +56,29 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
51 56
         CommandManager.registerCommand(this);
52 57
     }
53 58
     
54
-    /**
55
-     * Executes this command.
56
-     * @param origin The frame in which this command was issued
57
-     * @param server The server object that this command is associated with
58
-     * @param isSilent Whether this command is silenced or not
59
-     * @param args The user supplied arguments
60
-     */
59
+    /** {@inheritDoc} */
61 60
     @Override
62
-    public void execute(final FrameContainer origin, final Server server,
63
-            final boolean isSilent, final CommandArguments args) {
61
+    public void execute(final FrameContainer<?> origin,
62
+            final CommandArguments args, final CommandContext context) {
63
+        final Server server = ((ServerCommandContext) context).getServer();
64 64
 
65 65
         if (args.getArguments().length == 0) {
66
-            executeView(origin, server, isSilent, args, false);
66
+            executeView(origin, server, args.isSilent(), args, false);
67 67
         } else if ("--remove".equalsIgnoreCase(args.getArguments()[0])) {
68
-            executeRemove(origin, server, isSilent, args);
68
+            executeRemove(origin, server, args.isSilent(), args);
69 69
         } else if ("--regex".equalsIgnoreCase(args.getArguments()[0])) {
70
-            executeRegex(origin, server, isSilent, args);
70
+            executeRegex(origin, server, args.isSilent(), args);
71 71
         } else {
72
-            executeAdd(origin, server, isSilent, args);
72
+            executeAdd(origin, server, args.isSilent(), args);
73 73
         }
74 74
     }
75 75
 
76
-    protected void executeView(final FrameContainer origin, final Server server,
76
+    protected void executeView(final FrameContainer<?> origin, final Server server,
77 77
             final boolean isSilent, final CommandArguments args, final boolean forceRegex) {
78 78
         final IgnoreList ignoreList = server.getIgnoreList();
79 79
 
80 80
         if (ignoreList.count() == 0) {
81
-            sendLine(origin, isSilent, FORMAT_ERROR, "No ignore list entries for this network.");
81
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "No ignore list entries for this network.");
82 82
             return;
83 83
         }
84 84
 
@@ -87,7 +87,7 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
87 87
             entries = ignoreList.getSimpleList();
88 88
         } else {
89 89
             if (!forceRegex) {
90
-                sendLine(origin, isSilent, FORMAT_ERROR,
90
+                sendLine(origin, args.isSilent(), FORMAT_ERROR,
91 91
                         "Unable to convert ignore list to simple format");
92 92
             }
93 93
             entries = ignoreList.getRegexList();
@@ -96,24 +96,24 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
96 96
         int i = 0;
97 97
         for (String line : entries) {
98 98
             i++;
99
-            sendLine(origin, isSilent, FORMAT_OUTPUT, i + ". " + line);
99
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, i + ". " + line);
100 100
         }
101 101
     }
102 102
 
103
-    protected void executeAdd(final FrameContainer origin, final Server server,
103
+    protected void executeAdd(final FrameContainer<?> origin, final Server server,
104 104
             final boolean isSilent, final CommandArguments args) {
105 105
         final IgnoreList ignoreList = server.getIgnoreList();
106 106
         final String target = args.getArgumentsAsString();
107 107
 
108 108
         ignoreList.addSimple(target);
109 109
         server.saveIgnoreList();
110
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Added " + target + " to the ignore list.");
110
+        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Added " + target + " to the ignore list.");
111 111
     }
112 112
 
113
-    protected void executeRegex(final FrameContainer origin, final Server server,
113
+    protected void executeRegex(final FrameContainer<?> origin, final Server server,
114 114
             final boolean isSilent, final CommandArguments args) {
115 115
         if (args.getArguments().length == 1) {
116
-            executeView(origin, server, isSilent, args, true);
116
+            executeView(origin, server, args.isSilent(), args, true);
117 117
             return;
118 118
         }
119 119
 
@@ -123,20 +123,20 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
123 123
         try {
124 124
             Pattern.compile(target);
125 125
         } catch (PatternSyntaxException ex) {
126
-            sendLine(origin, isSilent, FORMAT_ERROR, "Unable to compile regex: "
126
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Unable to compile regex: "
127 127
                     + ex.getDescription());
128 128
             return;
129 129
         }
130 130
 
131 131
         ignoreList.add(target);
132 132
         server.saveIgnoreList();
133
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Added " + target + " to the ignore list.");
133
+        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Added " + target + " to the ignore list.");
134 134
     }
135 135
 
136
-    protected void executeRemove(final FrameContainer origin, final Server server,
136
+    protected void executeRemove(final FrameContainer<?> origin, final Server server,
137 137
             final boolean isSilent, final CommandArguments args) {
138 138
         if (args.getArguments().length == 1) {
139
-            showUsage(origin, isSilent, "ignore", "--remove <host>");
139
+            showUsage(origin, args.isSilent(), "ignore", "--remove <host>");
140 140
             return;
141 141
         }
142 142
 
@@ -146,18 +146,18 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
146 146
         if (ignoreList.canConvert() && ignoreList.getSimpleList().contains(host)) {
147 147
             ignoreList.remove(ignoreList.getSimpleList().indexOf(host));
148 148
             server.saveIgnoreList();
149
-            sendLine(origin, isSilent, FORMAT_OUTPUT, "Removed " + host + " from the ignore list.");
149
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Removed " + host + " from the ignore list.");
150 150
             return;
151 151
         }
152 152
 
153 153
         if (ignoreList.getRegexList().contains(host)) {
154 154
             ignoreList.remove(ignoreList.getRegexList().indexOf(host));
155 155
             server.saveIgnoreList();
156
-            sendLine(origin, isSilent, FORMAT_OUTPUT, "Removed " + host + " from the ignore list.");
156
+            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Removed " + host + " from the ignore list.");
157 157
             return;
158 158
         }
159 159
 
160
-        sendLine(origin, isSilent, FORMAT_ERROR, "Ignore list doesn't contain '" + host + "'.");
160
+        sendLine(origin, args.isSilent(), FORMAT_ERROR, "Ignore list doesn't contain '" + host + "'.");
161 161
     }
162 162
     
163 163
     /** {@inheritDoc} */
@@ -171,6 +171,12 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
171 171
     public boolean showInHelp() {
172 172
         return true;
173 173
     }
174
+
175
+    /** {@inheritDoc} */
176
+    @Override
177
+    public CommandType getType() {
178
+        return CommandType.TYPE_SERVER;
179
+    }
174 180
     
175 181
     /** {@inheritDoc} */
176 182
     @Override

+ 18
- 7
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java Прегледај датотеку

@@ -28,9 +28,13 @@ import com.dmdirc.actions.ActionManager;
28 28
 import com.dmdirc.actions.CoreActionType;
29 29
 import com.dmdirc.actions.interfaces.ActionType;
30 30
 import com.dmdirc.commandparser.CommandArguments;
31
+import com.dmdirc.commandparser.CommandInfo;
31 32
 import com.dmdirc.commandparser.CommandManager;
33
+import com.dmdirc.commandparser.CommandType;
34
+import com.dmdirc.commandparser.commands.Command;
32 35
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
-import com.dmdirc.commandparser.commands.ServerCommand;
36
+import com.dmdirc.commandparser.commands.context.CommandContext;
37
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34 38
 import com.dmdirc.interfaces.ActionListener;
35 39
 import com.dmdirc.parser.common.ChannelJoinRequest;
36 40
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -46,8 +50,8 @@ import java.util.List;
46 50
  * @since 0.6.3m1
47 51
  * @author chris
48 52
  */
49
-public final class JoinChannelCommand extends ServerCommand implements
50
-        ActionListener, IntelligentCommand {
53
+public final class JoinChannelCommand extends Command implements
54
+        ActionListener, IntelligentCommand, CommandInfo {
51 55
 
52 56
     /** A map of channel name mentions. */
53 57
     private final MapList<FrameContainer<?>, String> mentions
@@ -65,10 +69,11 @@ public final class JoinChannelCommand extends ServerCommand implements
65 69
     
66 70
     /** {@inheritDoc} */
67 71
     @Override
68
-    public void execute(final FrameContainer<?> origin, final Server server,
69
-            final boolean isSilent, final CommandArguments args) {
72
+    public void execute(final FrameContainer<?> origin,
73
+            final CommandArguments args, final CommandContext context) {
74
+        final Server server = ((ServerCommandContext) context).getServer();
70 75
         if (args.getArguments().length == 0) {
71
-            showUsage(origin, isSilent, "join", "join <channel [key]>[,channel [key]...]");
76
+            showUsage(origin, args.isSilent(), "join", "join <channel [key]>[,channel [key]...]");
72 77
             return;
73 78
         }
74 79
 
@@ -85,7 +90,7 @@ public final class JoinChannelCommand extends ServerCommand implements
85 90
             }
86 91
         }
87 92
 
88
-        server.join(!isSilent, channels.toArray(new ChannelJoinRequest[0]));
93
+        server.join(!args.isSilent(), channels.toArray(new ChannelJoinRequest[0]));
89 94
     }
90 95
     
91 96
     
@@ -100,6 +105,12 @@ public final class JoinChannelCommand extends ServerCommand implements
100 105
     public boolean showInHelp() {
101 106
         return true;
102 107
     }
108
+
109
+    /** {@inheritDoc} */
110
+    @Override
111
+    public CommandType getType() {
112
+        return CommandType.TYPE_SERVER;
113
+    }
103 114
     
104 115
     /** {@inheritDoc} */
105 116
     @Override

+ 20
- 9
src/com/dmdirc/commandparser/commands/server/Message.java Прегледај датотеку

@@ -25,11 +25,15 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
-import com.dmdirc.commandparser.commands.ServerCommand;
32 34
 import com.dmdirc.commandparser.commands.WrappableCommand;
35
+import com.dmdirc.commandparser.commands.context.CommandContext;
36
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
33 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 38
 import com.dmdirc.ui.input.TabCompletionType;
35 39
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -39,8 +43,8 @@ import com.dmdirc.ui.interfaces.InputWindow;
39 43
  * @author chris
40 44
  */
41 45
 @CommandOptions(allowOffline=false)
42
-public final class Message extends ServerCommand implements IntelligentCommand,
43
-        WrappableCommand {
46
+public final class Message extends Command implements IntelligentCommand,
47
+        WrappableCommand, CommandInfo {
44 48
     
45 49
     /**
46 50
      * Creates a new instance of Message.
@@ -53,20 +57,21 @@ public final class Message extends ServerCommand implements IntelligentCommand,
53 57
     
54 58
     /** {@inheritDoc} */
55 59
     @Override
56
-    public void execute(final FrameContainer origin, final Server server,
57
-            final boolean isSilent, final CommandArguments args) {
60
+    public void execute(final FrameContainer<?> origin,
61
+            final CommandArguments args, final CommandContext context) {
62
+        final Server server = ((ServerCommandContext) context).getServer();
58 63
         if (args.getArguments().length < 2) {
59
-            showUsage(origin, isSilent, "msg", "<target> <message>");
64
+            showUsage(origin, args.isSilent(), "msg", "<target> <message>");
60 65
         } else {
61 66
             final String target = args.getArguments()[0];
62 67
             final String message = args.getArgumentsAsString(1);
63
-            sendLine(origin, isSilent, "selfMessage", target, message);
68
+            sendLine(origin, args.isSilent(), "selfMessage", target, message);
64 69
 
65 70
             // If this is a known server or channel, and this is not a silent
66 71
             // invokation, use sendLine, else send it raw to the parser.
67
-            if (!isSilent && server.hasChannel(target)) {
72
+            if (!args.isSilent() && server.hasChannel(target)) {
68 73
                 server.getChannel(target).sendLine(message);
69
-            } else if (!isSilent && server.hasQuery(target)) {
74
+            } else if (!args.isSilent() && server.hasQuery(target)) {
70 75
                 server.getQuery(target).sendLine(message);
71 76
             } else {
72 77
                 server.getParser().sendMessage(target, message);
@@ -86,6 +91,12 @@ public final class Message extends ServerCommand implements IntelligentCommand,
86 91
     public boolean showInHelp() {
87 92
         return true;
88 93
     }
94
+
95
+    /** {@inheritDoc} */
96
+    @Override
97
+    public CommandType getType() {
98
+        return CommandType.TYPE_SERVER;
99
+    }
89 100
     
90 101
     /** {@inheritDoc} */
91 102
     @Override

+ 17
- 5
src/com/dmdirc/commandparser/commands/server/Nick.java Прегледај датотеку

@@ -25,10 +25,14 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
-import com.dmdirc.commandparser.commands.ServerCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 37
 import com.dmdirc.ui.input.TabCompletionType;
34 38
 
@@ -37,7 +41,8 @@ import com.dmdirc.ui.input.TabCompletionType;
37 41
  * @author chris
38 42
  */
39 43
 @CommandOptions(allowOffline=false)
40
-public final class Nick extends ServerCommand implements IntelligentCommand {
44
+public final class Nick extends Command implements IntelligentCommand,
45
+        CommandInfo {
41 46
     
42 47
     /**
43 48
      * Creates a new instance of Nick.
@@ -50,10 +55,11 @@ public final class Nick extends ServerCommand implements IntelligentCommand {
50 55
     
51 56
     /** {@inheritDoc} */
52 57
     @Override
53
-    public void execute(final FrameContainer origin, final Server server,
54
-            final boolean isSilent, final CommandArguments args) {
58
+    public void execute(final FrameContainer<?> origin,
59
+            final CommandArguments args, final CommandContext context) {
60
+        final Server server = ((ServerCommandContext) context).getServer();
55 61
         if (args.getArguments().length == 0) {
56
-            showUsage(origin, isSilent, "nick", "<new nickname>");
62
+            showUsage(origin, args.isSilent(), "nick", "<new nickname>");
57 63
             return;
58 64
         }
59 65
         
@@ -72,6 +78,12 @@ public final class Nick extends ServerCommand implements IntelligentCommand {
72 78
     public boolean showInHelp() {
73 79
         return true;
74 80
     }
81
+
82
+    /** {@inheritDoc} */
83
+    @Override
84
+    public CommandType getType() {
85
+        return CommandType.TYPE_SERVER;
86
+    }
75 87
     
76 88
     /** {@inheritDoc} */
77 89
     @Override

+ 18
- 6
src/com/dmdirc/commandparser/commands/server/Notice.java Прегледај датотеку

@@ -25,10 +25,14 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
-import com.dmdirc.commandparser.commands.ServerCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 37
 import com.dmdirc.ui.input.TabCompletionType;
34 38
 
@@ -37,7 +41,8 @@ import com.dmdirc.ui.input.TabCompletionType;
37 41
  * @author chris
38 42
  */
39 43
 @CommandOptions(allowOffline=false)
40
-public final class Notice extends ServerCommand implements IntelligentCommand {
44
+public final class Notice extends Command implements IntelligentCommand,
45
+        CommandInfo {
41 46
     
42 47
     /**
43 48
      * Creates a new instance of Notice.
@@ -50,14 +55,15 @@ public final class Notice extends ServerCommand implements IntelligentCommand {
50 55
     
51 56
     /** {@inheritDoc} */
52 57
     @Override
53
-    public void execute(final FrameContainer origin, final Server server,
54
-            final boolean isSilent, final CommandArguments args) {
58
+    public void execute(final FrameContainer<?> origin,
59
+            final CommandArguments args, final CommandContext context) {
60
+        final Server server = ((ServerCommandContext) context).getServer();
55 61
         if (args.getArguments().length < 2) {
56
-            showUsage(origin, isSilent, "notice", "<target> <message>");
62
+            showUsage(origin, args.isSilent(), "notice", "<target> <message>");
57 63
         } else {
58 64
             server.getParser().sendNotice(args.getArguments()[0],
59 65
                     args.getArgumentsAsString(1));
60
-            sendLine(origin, isSilent, "selfNotice", args.getArguments()[0],
66
+            sendLine(origin, args.isSilent(), "selfNotice", args.getArguments()[0],
61 67
                     args.getArgumentsAsString(1));
62 68
         }
63 69
     }
@@ -74,6 +80,12 @@ public final class Notice extends ServerCommand implements IntelligentCommand {
74 80
     public boolean showInHelp() {
75 81
         return true;
76 82
     }
83
+
84
+    /** {@inheritDoc} */
85
+    @Override
86
+    public CommandType getType() {
87
+        return CommandType.TYPE_SERVER;
88
+    }
77 89
     
78 90
     /** {@inheritDoc} */
79 91
     @Override

+ 18
- 7
src/com/dmdirc/commandparser/commands/server/OpenQuery.java Прегледај датотеку

@@ -25,10 +25,14 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
30
-import com.dmdirc.commandparser.commands.ServerCommand;
31 33
 import com.dmdirc.commandparser.commands.WrappableCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 37
 import com.dmdirc.ui.input.TabCompletionType;
34 38
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -38,8 +42,8 @@ import com.dmdirc.ui.messages.Styliser;
38 42
  * Allows the user to open a query dialog with another user.
39 43
  * @author chris
40 44
  */
41
-public final class OpenQuery extends ServerCommand implements
42
-        IntelligentCommand, WrappableCommand {
45
+public final class OpenQuery extends Command implements IntelligentCommand,
46
+        WrappableCommand, CommandInfo {
43 47
     
44 48
     /**
45 49
      * Creates a new instance of Query.
@@ -52,15 +56,16 @@ public final class OpenQuery extends ServerCommand implements
52 56
     
53 57
     /** {@inheritDoc} */
54 58
     @Override
55
-    public void execute(final FrameContainer<?> origin, final Server server,
56
-            final boolean isSilent, final CommandArguments args) {
59
+    public void execute(final FrameContainer<?> origin,
60
+            final CommandArguments args, final CommandContext context) {
61
+        final Server server = ((ServerCommandContext) context).getServer();
57 62
         if (args.getArguments().length == 0) {
58
-            showUsage(origin, isSilent, "query", "<target> <message>");
63
+            showUsage(origin, args.isSilent(), "query", "<target> <message>");
59 64
             return;
60 65
         }
61 66
             
62 67
         if (server.getParser().isValidChannelName(args.getArguments()[0])) {
63
-            sendLine(origin, isSilent, FORMAT_ERROR, "You can't open a query "
68
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "You can't open a query "
64 69
                     + "with a channel; maybe you meant " + Styliser.CODE_FIXED
65 70
                     + Styliser.CODE_BOLD + CommandManager.getCommandChar()
66 71
                     + (args.getArguments().length > 1 ? "msg" : "join") + " "
@@ -92,6 +97,12 @@ public final class OpenQuery extends ServerCommand implements
92 97
     public boolean showInHelp() {
93 98
         return true;
94 99
     }
100
+
101
+    /** {@inheritDoc} */
102
+    @Override
103
+    public CommandType getType() {
104
+        return CommandType.TYPE_SERVER;
105
+    }
95 106
     
96 107
     /** {@inheritDoc} */
97 108
     @Override

+ 16
- 5
src/com/dmdirc/commandparser/commands/server/Raw.java Прегледај датотеку

@@ -25,9 +25,13 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
31 35
 
32 36
 /**
33 37
  * The raw command allows the user to send a raw line of text directly to the
@@ -35,7 +39,7 @@ import com.dmdirc.commandparser.commands.ServerCommand;
35 39
  * @author chris
36 40
  */
37 41
 @CommandOptions(allowOffline=false)
38
-public final class Raw extends ServerCommand {
42
+public final class Raw extends Command implements CommandInfo {
39 43
     
40 44
     /**
41 45
      * Creates a new instance of Raw.
@@ -48,12 +52,13 @@ public final class Raw extends ServerCommand {
48 52
     
49 53
     /** {@inheritDoc} */
50 54
     @Override
51
-    public void execute(final FrameContainer origin, final Server server,
52
-            final boolean isSilent, final CommandArguments args) {
55
+    public void execute(final FrameContainer<?> origin,
56
+            final CommandArguments args, final CommandContext context) {
57
+        final Server server = ((ServerCommandContext) context).getServer();
53 58
         final String line = args.getArgumentsAsString();
54 59
         
55 60
         server.getParser().sendRawMessage(line);
56
-        sendLine(origin, isSilent, "rawCommand", line);
61
+        sendLine(origin, args.isSilent(), "rawCommand", line);
57 62
     }
58 63
     
59 64
     
@@ -68,6 +73,12 @@ public final class Raw extends ServerCommand {
68 73
     public boolean showInHelp() {
69 74
         return true;
70 75
     }
76
+
77
+    /** {@inheritDoc} */
78
+    @Override
79
+    public CommandType getType() {
80
+        return CommandType.TYPE_SERVER;
81
+    }
71 82
     
72 83
     /** {@inheritDoc} */
73 84
     @Override

+ 15
- 4
src/com/dmdirc/commandparser/commands/server/RawServerCommand.java Прегледај датотеку

@@ -25,9 +25,13 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
29 32
 import com.dmdirc.commandparser.commands.CommandOptions;
30
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.CommandContext;
34
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
31 35
 
32 36
 /**
33 37
  * Implements a raw server command (i.e., a command that is sent to the server
@@ -36,7 +40,7 @@ import com.dmdirc.commandparser.commands.ServerCommand;
36 40
  * @author chris
37 41
  */
38 42
 @CommandOptions(allowOffline=false)
39
-public final class RawServerCommand extends ServerCommand {
43
+public final class RawServerCommand extends Command implements CommandInfo {
40 44
     
41 45
     /** The name of this raw command. */
42 46
     private final String myName;
@@ -56,8 +60,9 @@ public final class RawServerCommand extends ServerCommand {
56 60
     
57 61
     /** {@inheritDoc} */
58 62
     @Override
59
-    public void execute(final FrameContainer origin, final Server server,
60
-            final boolean isSilent, final CommandArguments args) {
63
+    public void execute(final FrameContainer<?> origin,
64
+            final CommandArguments args, final CommandContext context) {
65
+        final Server server = ((ServerCommandContext) context).getServer();
61 66
         server.getParser().sendRawMessage(myName.toUpperCase() + " " + args.getArgumentsAsString());
62 67
     }
63 68
     
@@ -73,6 +78,12 @@ public final class RawServerCommand extends ServerCommand {
73 78
     public boolean showInHelp() {
74 79
         return true;
75 80
     }
81
+
82
+    /** {@inheritDoc} */
83
+    @Override
84
+    public CommandType getType() {
85
+        return CommandType.TYPE_SERVER;
86
+    }
76 87
     
77 88
     /** {@inheritDoc} */
78 89
     @Override

+ 15
- 4
src/com/dmdirc/commandparser/commands/server/Reconnect.java Прегледај датотеку

@@ -25,14 +25,18 @@ package com.dmdirc.commandparser.commands.server;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
28 29
 import com.dmdirc.commandparser.CommandManager;
29
-import com.dmdirc.commandparser.commands.ServerCommand;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
30 34
 
31 35
 /**
32 36
  * The reconnect command reconnects to the current server.
33 37
  * @author chris
34 38
  */
35
-public final class Reconnect extends ServerCommand {
39
+public final class Reconnect extends Command implements CommandInfo {
36 40
     
37 41
     /**
38 42
      * Creates a new instance of Reconnect.
@@ -45,8 +49,9 @@ public final class Reconnect extends ServerCommand {
45 49
     
46 50
     /** {@inheritDoc} */
47 51
     @Override
48
-    public void execute(final FrameContainer origin, final Server server,
49
-            final boolean isSilent, final CommandArguments args) {
52
+    public void execute(final FrameContainer<?> origin,
53
+            final CommandArguments args, final CommandContext context) {
54
+        final Server server = ((ServerCommandContext) context).getServer();
50 55
         String line;
51 56
         
52 57
         if (args.getArguments().length == 0) {
@@ -70,6 +75,12 @@ public final class Reconnect extends ServerCommand {
70 75
     public boolean showInHelp() {
71 76
         return true;
72 77
     }
78
+
79
+    /** {@inheritDoc} */
80
+    @Override
81
+    public CommandType getType() {
82
+        return CommandType.TYPE_SERVER;
83
+    }
73 84
     
74 85
     /** {@inheritDoc} */
75 86
     @Override

+ 16
- 5
src/com/dmdirc/commandparser/commands/server/Umode.java Прегледај датотеку

@@ -26,9 +26,13 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.ServerState;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
29 30
 import com.dmdirc.commandparser.CommandManager;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
30 33
 import com.dmdirc.commandparser.commands.CommandOptions;
31
-import com.dmdirc.commandparser.commands.ServerCommand;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32 36
 
33 37
 /**
34 38
  * Allows the user to change user modes.
@@ -36,7 +40,7 @@ import com.dmdirc.commandparser.commands.ServerCommand;
36 40
  * @author chris
37 41
  */
38 42
 @CommandOptions(allowOffline=false)
39
-public class Umode extends ServerCommand {
43
+public class Umode extends Command implements CommandInfo {
40 44
     
41 45
     /**
42 46
      * Creates a new instance of Umode.
@@ -49,10 +53,11 @@ public class Umode extends ServerCommand {
49 53
 
50 54
     /** {@inheritDoc} */
51 55
     @Override
52
-    public void execute(final FrameContainer origin, final Server server, 
53
-            final boolean isSilent, final CommandArguments args) {
56
+    public void execute(final FrameContainer<?> origin,
57
+            final CommandArguments args, final CommandContext context) {
58
+        final Server server = ((ServerCommandContext) context).getServer();
54 59
         if (server.getState() != ServerState.CONNECTED) {
55
-            sendLine(origin, isSilent, FORMAT_ERROR, "Not connected");
60
+            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Not connected");
56 61
             return;
57 62
         }
58 63
 
@@ -73,6 +78,12 @@ public class Umode extends ServerCommand {
73 78
         return true;
74 79
     }
75 80
 
81
+    /** {@inheritDoc} */
82
+    @Override
83
+    public CommandType getType() {
84
+        return CommandType.TYPE_SERVER;
85
+    }
86
+
76 87
     /** {@inheritDoc} */
77 88
     @Override
78 89
     public String getHelp() {

+ 18
- 29
src/com/dmdirc/commandparser/parsers/ChannelCommandParser.java Прегледај датотеку

@@ -24,21 +24,21 @@ package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
+import com.dmdirc.Server;
27 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
28 30
 import com.dmdirc.commandparser.CommandManager;
29 31
 import com.dmdirc.commandparser.CommandType;
30
-import com.dmdirc.commandparser.commands.ChannelCommand;
31
-import com.dmdirc.commandparser.commands.ChatCommand;
32 32
 import com.dmdirc.commandparser.commands.Command;
33
-import com.dmdirc.commandparser.commands.GlobalCommand;
34
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
+import com.dmdirc.ui.interfaces.Window;
35 35
 
36 36
 /**
37
- * A command parser that is tailored for use in a channel environment. Handles
38
- * both channel and server commands.
37
+ * A command parser that is tailored for use in a channel environment.
38
+ * 
39 39
  * @author chris
40 40
  */
41
-public final class ChannelCommandParser extends CommandParser {
41
+public class ChannelCommandParser extends ChatCommandParser {
42 42
     
43 43
     /**
44 44
      * A version number for this class. It should be changed whenever the class
@@ -54,9 +54,11 @@ public final class ChannelCommandParser extends CommandParser {
54 54
     
55 55
     /**
56 56
      * Creates a new instance of ChannelCommandParser.
57
+     *
58
+     * @param server The server this parser's query belongs to
57 59
      */
58
-    public ChannelCommandParser() {
59
-        super();
60
+    public ChannelCommandParser(final Server server) {
61
+        super(server);
60 62
     }
61 63
 
62 64
     /** {@inheritDoc} */
@@ -65,6 +67,8 @@ public final class ChannelCommandParser extends CommandParser {
65 67
         if (channel == null) {
66 68
             channel = (Channel) owner;
67 69
         }
70
+
71
+        super.setOwner(owner);
68 72
     }
69 73
     
70 74
     /** {@inheritDoc} */
@@ -77,28 +81,13 @@ public final class ChannelCommandParser extends CommandParser {
77 81
     /** {@inheritDoc} */
78 82
     @Override
79 83
     protected void executeCommand(final FrameContainer<?> origin,
80
-            final boolean isSilent, final Command command, final CommandArguments args) {
81
-        if (command instanceof ChannelCommand) {
82
-            ((ChannelCommand) command).execute(origin, channel.getServer(), channel, isSilent, args);
83
-        } else if (command instanceof ChatCommand) {
84
-            ((ChatCommand) command).execute(origin, channel.getServer(), channel, isSilent, args);
85
-        } else if (command instanceof ServerCommand) {
86
-            ((ServerCommand) command).execute(origin, channel.getServer(), isSilent, args);
84
+            final Window window, final CommandInfo commandInfo,
85
+            final Command command, final CommandArguments args) {
86
+        if (commandInfo.getType() == CommandType.TYPE_CHANNEL) {
87
+            command.execute(origin, args, new ChannelCommandContext(window, commandInfo, channel));
87 88
         } else {
88
-            ((GlobalCommand) command).execute(origin, isSilent, args);
89
+            super.executeCommand(origin, window, commandInfo, command, args);
89 90
         }
90 91
     }
91 92
     
92
-    /**
93
-     * Called when the input was a line of text that was not a command. This normally
94
-     * means it is sent to the server/channel/user as-is, with no further processing.
95
-     *
96
-     * @param origin The window in which the command was typed
97
-     * @param line The line input by the user
98
-     */
99
-    @Override
100
-    protected void handleNonCommand(final FrameContainer<?> origin, final String line) {
101
-        channel.sendLine(line);
102
-    }
103
-    
104 93
 }

+ 90
- 0
src/com/dmdirc/commandparser/parsers/ChatCommandParser.java Прегледај датотеку

@@ -0,0 +1,90 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.parsers;
24
+
25
+import com.dmdirc.FrameContainer;
26
+import com.dmdirc.MessageTarget;
27
+import com.dmdirc.Server;
28
+import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.context.ChatCommandContext;
33
+import com.dmdirc.ui.interfaces.Window;
34
+
35
+/**
36
+ * A command parser which implements common functionality for chat windows
37
+ * (queries and channels).
38
+ * 
39
+ * @since 0.6.4
40
+ * @author chris
41
+ */
42
+public class ChatCommandParser extends ServerCommandParser {
43
+
44
+    /**
45
+     * A version number for this class. It should be changed whenever the class
46
+     * structure is changed (or anything else that would prevent serialized
47
+     * objects being unserialized with the new class).
48
+     */
49
+    private static final long serialVersionUID = 1;
50
+
51
+    /** The container that owns this parser. */
52
+    private MessageTarget<?> owner;
53
+
54
+    /**
55
+     * Creates a new chat command parser that belongs to a child of the
56
+     * specified server.
57
+     *
58
+     * @param server The server which owns this parser's container
59
+     */
60
+    public ChatCommandParser(final Server server) {
61
+        super.setOwner(server);
62
+    }
63
+
64
+    /** {@inheritDoc} */
65
+    @Override
66
+    public void setOwner(final FrameContainer<?> owner) {
67
+        if (this.owner == null) {
68
+            this.owner = (MessageTarget<?>) owner;
69
+        }
70
+    }
71
+
72
+    /** {@inheritDoc} */
73
+    @Override
74
+    protected void executeCommand(final FrameContainer<?> origin,
75
+            final Window window, final CommandInfo commandInfo,
76
+            final Command command, final CommandArguments args) {
77
+        if (commandInfo.getType() == CommandType.TYPE_CHAT) {
78
+            command.execute(origin, args, new ChatCommandContext(window, commandInfo, owner));
79
+        } else {
80
+            super.executeCommand(origin, window, commandInfo, command, args);
81
+        }
82
+    }
83
+
84
+    /** {@inheritDoc} */
85
+    @Override
86
+    protected void handleNonCommand(final FrameContainer<?> origin, final String line) {
87
+        owner.sendLine(line);
88
+    }
89
+
90
+}

+ 29
- 20
src/com/dmdirc/commandparser/parsers/CommandParser.java Прегледај датотеку

@@ -28,6 +28,7 @@ import com.dmdirc.actions.ActionManager;
28 28
 import com.dmdirc.actions.CoreActionType;
29 29
 import com.dmdirc.commandparser.CommandArguments;
30 30
 import com.dmdirc.commandparser.CommandInfo;
31
+import com.dmdirc.commandparser.CommandInfoPair;
31 32
 import com.dmdirc.commandparser.CommandManager;
32 33
 import com.dmdirc.commandparser.CommandType;
33 34
 import com.dmdirc.commandparser.commands.Command;
@@ -35,6 +36,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
35 36
 import com.dmdirc.commandparser.commands.ExternalCommand;
36 37
 import com.dmdirc.commandparser.commands.PreviousCommand;
37 38
 import com.dmdirc.config.IdentityManager;
39
+import com.dmdirc.ui.interfaces.Window;
38 40
 import com.dmdirc.util.RollingList;
39 41
 
40 42
 import java.io.Serializable;
@@ -61,7 +63,7 @@ public abstract class CommandParser implements Serializable {
61 63
     /**
62 64
      * Commands that are associated with this parser.
63 65
      */
64
-    private final Map<String, Command> commands;
66
+    private final Map<String, CommandInfoPair> commands;
65 67
 
66 68
     /**
67 69
      * A history of commands that have been entered into this parser.
@@ -70,7 +72,7 @@ public abstract class CommandParser implements Serializable {
70 72
 
71 73
     /** Creates a new instance of CommandParser. */
72 74
     public CommandParser() {
73
-        commands = new Hashtable<String, Command>();
75
+        commands = new Hashtable<String, CommandInfoPair>();
74 76
         history = new RollingList<PreviousCommand>(
75 77
                 IdentityManager.getGlobalConfig().getOptionInt("general",
76 78
                     "commandhistory"));
@@ -96,7 +98,7 @@ public abstract class CommandParser implements Serializable {
96 98
      * @param info The information the command should be registered with
97 99
      */
98 100
     public final void registerCommand(final Command command, final CommandInfo info) {
99
-        commands.put(info.getName().toLowerCase(), command);
101
+        commands.put(info.getName().toLowerCase(), new CommandInfoPair(info, command));
100 102
     }
101 103
 
102 104
     /**
@@ -115,31 +117,33 @@ public abstract class CommandParser implements Serializable {
115 117
      * @since 0.6.3m1
116 118
      * @return A map of commands known to this parser
117 119
      */
118
-    public Map<String, Command> getCommands() {
119
-        return new HashMap<String, Command>(commands);
120
+    public Map<String, CommandInfoPair> getCommands() {
121
+        return new HashMap<String, CommandInfoPair>(commands);
120 122
     }
121 123
 
122 124
     /**
123 125
      * Parses the specified string as a command.
124 126
      *
125
-     * @param origin The window in which the command was typed
127
+     * @param origin The container which received the command
128
+     * @param window The window in which the line was typed
126 129
      * @param line The line to be parsed
127 130
      * @param parseChannel Whether or not to try and parse the first argument
128 131
      * as a channel name
132
+     * @since 0.6.4
129 133
      */
130 134
     public final void parseCommand(final FrameContainer<?> origin,
131
-            final String line, final boolean parseChannel) {
135
+            final Window window, final String line, final boolean parseChannel) {
132 136
         final CommandArguments args = new CommandArguments(line);
133 137
 
134 138
         if (args.isCommand()) {
135
-            if (handleChannelCommand(origin, args, parseChannel)) {
139
+            if (handleChannelCommand(origin, window, args, parseChannel)) {
136 140
                 return;
137 141
             }
138 142
 
139 143
             if (commands.containsKey(args.getCommandName().toLowerCase())) {
144
+                final CommandInfoPair pair = commands.get(args.getCommandName().toLowerCase());
140 145
                 addHistory(args.getStrippedLine());
141
-                executeCommand(origin, args.isSilent(),
142
-                        commands.get(args.getCommandName().toLowerCase()), args);
146
+                executeCommand(origin, window, pair.getCommandInfo(), pair.getCommand(), args);
143 147
             } else {
144 148
                 handleInvalidCommand(origin, args);
145 149
             }
@@ -156,13 +160,14 @@ public abstract class CommandParser implements Serializable {
156 160
      * to handle the command, and will return true. If the command is not
157 161
      * handled, the method returns false.
158 162
      *
159
-     * @param origin The window the command was entered in
163
+     * @param origin The container which received the command
164
+     * @param window The window in which the command was typed
160 165
      * @param args The command and its arguments
161 166
      * @param parseChannel Whether or not to try parsing channel names
162 167
      * @return True iff the command was handled, false otherwise
163 168
      */
164 169
     protected boolean handleChannelCommand(final FrameContainer<?> origin,
165
-            final CommandArguments args, final boolean parseChannel) {
170
+            final Window window, final CommandArguments args, final boolean parseChannel) {
166 171
         final boolean silent = args.isSilent();
167 172
         final String command = args.getCommandName();
168 173
         final String[] cargs = args.getArguments();
@@ -189,7 +194,7 @@ public abstract class CommandParser implements Serializable {
189 194
 
190 195
                 if (server.hasChannel(channel)) {
191 196
                     server.getChannel(channel).getCommandParser()
192
-                            .parseCommand(origin, CommandManager.getCommandChar()
197
+                            .parseCommand(origin, window, CommandManager.getCommandChar()
193 198
                             + args.getCommandName() + " " + args.getWordsAsString(2), false);
194 199
                 } else {
195 200
                     final Map.Entry<CommandInfo, Command> actCommand
@@ -247,12 +252,14 @@ public abstract class CommandParser implements Serializable {
247 252
     /**
248 253
      * Parses the specified string as a command.
249 254
      *
250
-     * @param origin The window in which the command was typed
255
+     * @param origin The container which received the command
256
+     * @param window The window in which the command was typed
251 257
      * @param line The line to be parsed
258
+     * @since 0.6.4
252 259
      */
253 260
     public final void parseCommand(final FrameContainer<?> origin,
254
-            final String line) {
255
-        parseCommand(origin, line, true);
261
+            final Window window, final String line) {
262
+        parseCommand(origin, window, line, true);
256 263
     }
257 264
 
258 265
     /**
@@ -268,14 +275,16 @@ public abstract class CommandParser implements Serializable {
268 275
     /**
269 276
      * Executes the specified command with the given arguments.
270 277
      *
271
-     * @param origin The window in which the command was typed
272
-     * @param isSilent Whether the command is being silenced or not
278
+     * @param origin The container which received the command
279
+     * @param window The window in which the command was typed
280
+     * @param commandInfo The command information object matched by the command
273 281
      * @param command The command to be executed
274 282
      * @param args The arguments to the command
275
-     * @since 0.6.3m1
283
+     * @since 0.6.4
276 284
      */
277 285
     protected abstract void executeCommand(final FrameContainer<?> origin,
278
-            final boolean isSilent, final Command command, final CommandArguments args);
286
+            final Window window, final CommandInfo commandInfo,
287
+            final Command command, final CommandArguments args);
279 288
 
280 289
     /**
281 290
      * Called when the user attempted to issue a command (i.e., used the command

+ 8
- 5
src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java Прегледај датотеку

@@ -24,18 +24,20 @@ package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.CommandType;
29 30
 import com.dmdirc.commandparser.commands.Command;
30
-import com.dmdirc.commandparser.commands.GlobalCommand;
31
+import com.dmdirc.commandparser.commands.context.CommandContext;
31 32
 import com.dmdirc.logger.ErrorLevel;
32 33
 import com.dmdirc.logger.Logger;
34
+import com.dmdirc.ui.interfaces.Window;
33 35
 
34 36
 /**
35 37
  * The command parser used for global commands.
36 38
  * @author chris
37 39
  */
38
-public final class GlobalCommandParser extends CommandParser {
40
+public class GlobalCommandParser extends CommandParser {
39 41
     
40 42
     /**
41 43
      * A version number for this class. It should be changed whenever the class
@@ -52,7 +54,7 @@ public final class GlobalCommandParser extends CommandParser {
52 54
     /**
53 55
      * Creates a new instance of the GlobalCommandParser.
54 56
      */
55
-    private GlobalCommandParser() {
57
+    public GlobalCommandParser() {
56 58
         super();
57 59
     }
58 60
 
@@ -83,8 +85,9 @@ public final class GlobalCommandParser extends CommandParser {
83 85
     /** {@inheritDoc} */
84 86
     @Override
85 87
     protected void executeCommand(final FrameContainer<?> origin,
86
-            final boolean isSilent, final Command command, final CommandArguments args) {
87
-        ((GlobalCommand) command).execute(origin, isSilent, args);
88
+            final Window window, final CommandInfo commandInfo,
89
+            final Command command, final CommandArguments args) {
90
+        command.execute(origin, args, new CommandContext(window, commandInfo));
88 91
     }
89 92
     
90 93
     /**

+ 17
- 27
src/com/dmdirc/commandparser/parsers/QueryCommandParser.java Прегледај датотеку

@@ -24,21 +24,21 @@ package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Query;
27
+import com.dmdirc.Server;
27 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
28 30
 import com.dmdirc.commandparser.CommandManager;
29 31
 import com.dmdirc.commandparser.CommandType;
30
-import com.dmdirc.commandparser.commands.ChatCommand;
31 32
 import com.dmdirc.commandparser.commands.Command;
32
-import com.dmdirc.commandparser.commands.GlobalCommand;
33
-import com.dmdirc.commandparser.commands.QueryCommand;
34
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.QueryCommandContext;
34
+import com.dmdirc.ui.interfaces.Window;
35 35
 
36 36
 /**
37 37
  * A command parser that is tailored for use in a query environment. Handles
38 38
  * both query and server commands.
39 39
  * @author chris
40 40
  */
41
-public final class QueryCommandParser extends CommandParser {
41
+public class QueryCommandParser extends ChatCommandParser {
42 42
     
43 43
     /**
44 44
      * A version number for this class. It should be changed whenever the class
@@ -51,12 +51,14 @@ public final class QueryCommandParser extends CommandParser {
51 51
      * The query instance that this parser is attached to.
52 52
      */
53 53
     private Query query;
54
-    
54
+
55 55
     /**
56 56
      * Creates a new instance of QueryCommandParser.
57
+     *
58
+     * @param server The server this parser's query belongs to
57 59
      */
58
-    public QueryCommandParser() {
59
-        super();
60
+    public QueryCommandParser(final Server server) {
61
+        super(server);
60 62
     }
61 63
 
62 64
     /** {@inheritDoc} */
@@ -65,6 +67,8 @@ public final class QueryCommandParser extends CommandParser {
65 67
         if (query == null) {
66 68
             query = (Query) owner;
67 69
         }
70
+
71
+        super.setOwner(query);
68 72
     }
69 73
     
70 74
     /** Loads the relevant commands into the parser. */
@@ -77,27 +81,13 @@ public final class QueryCommandParser extends CommandParser {
77 81
     /** {@inheritDoc} */
78 82
     @Override
79 83
     protected void executeCommand(final FrameContainer<?> origin,
80
-            final boolean isSilent, final Command command, final CommandArguments args) {
81
-        if (command instanceof QueryCommand) {
82
-            ((QueryCommand) command).execute(origin, query.getServer(), query, isSilent, args);
83
-        } else if (command instanceof ChatCommand) {
84
-            ((ChatCommand) command).execute(origin, query.getServer(), query, isSilent, args);
85
-        } else if (command instanceof ServerCommand) {
86
-            ((ServerCommand) command).execute(origin, query.getServer(), isSilent, args);
84
+            final Window window, final CommandInfo commandInfo,
85
+            final Command command, final CommandArguments args) {
86
+        if (commandInfo.getType() == CommandType.TYPE_QUERY) {
87
+            command.execute(origin, args, new QueryCommandContext(window, commandInfo, query));
87 88
         } else {
88
-            ((GlobalCommand) command).execute(origin, isSilent, args);
89
+            super.executeCommand(origin, window, commandInfo, command, args);
89 90
         }
90 91
     }
91 92
     
92
-    /**
93
-     * Called when the input was a line of text that was not a command. This normally
94
-     * means it is sent to the server/channel/user as-is, with no further processing.
95
-     * @param origin The window in which the command was typed
96
-     * @param line The line input by the user
97
-     */
98
-    @Override
99
-    protected void handleNonCommand(final FrameContainer<?> origin, final String line) {
100
-        query.sendLine(line);
101
-    }
102
-    
103 93
 }

+ 14
- 9
src/com/dmdirc/commandparser/parsers/ServerCommandParser.java Прегледај датотеку

@@ -26,17 +26,19 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.ServerState;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
29 30
 import com.dmdirc.commandparser.CommandManager;
30 31
 import com.dmdirc.commandparser.CommandType;
31 32
 import com.dmdirc.commandparser.commands.Command;
32
-import com.dmdirc.commandparser.commands.GlobalCommand;
33
-import com.dmdirc.commandparser.commands.ServerCommand;
33
+import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34
+import com.dmdirc.ui.interfaces.Window;
34 35
 
35 36
 /**
36 37
  * A command parser used in the context of a server.
38
+ * 
37 39
  * @author chris
38 40
  */
39
-public class ServerCommandParser extends CommandParser {
41
+public class ServerCommandParser extends GlobalCommandParser {
40 42
     
41 43
     /**
42 44
      * A version number for this class. It should be changed whenever the class
@@ -63,6 +65,8 @@ public class ServerCommandParser extends CommandParser {
63 65
         if (server == null && owner instanceof Server) {
64 66
             server = (Server) owner;
65 67
         }
68
+
69
+        super.setOwner(owner);
66 70
     }
67 71
     
68 72
     /** Loads the relevant commands into the parser. */
@@ -74,20 +78,21 @@ public class ServerCommandParser extends CommandParser {
74 78
     /** {@inheritDoc} */
75 79
     @Override
76 80
     protected void executeCommand(final FrameContainer<?> origin,
77
-            final boolean isSilent, final Command command, final CommandArguments args) {
78
-        if (command instanceof ServerCommand) {
81
+            final Window window, final CommandInfo commandInfo,
82
+            final Command command, final CommandArguments args) {
83
+        if (commandInfo.getType() == CommandType.TYPE_SERVER) {
79 84
             if (hasCommandOptions(command) && !getCommandOptions(command).allowOffline()
80
-                    && ((server.getState() != ServerState.CONNECTED
85
+                    && (server == null || (server.getState() != ServerState.CONNECTED
81 86
                     && server.getState() != ServerState.CONNECTING)
82 87
                     || server.getParser() == null)) {
83
-                if (!isSilent) {
88
+                if (!args.isSilent()) {
84 89
                     origin.addLine("commandError", "You must be connected to use this command");
85 90
                 }
86 91
             } else {
87
-                ((ServerCommand) command).execute(origin, server, isSilent, args);
92
+                command.execute(origin, args, new ServerCommandContext(window, commandInfo, server));
88 93
             }
89 94
         } else {
90
-            ((GlobalCommand) command).execute(origin, isSilent, args);
95
+            super.executeCommand(origin, window, commandInfo, command, args);
91 96
         }
92 97
     }
93 98
     

+ 2
- 1
src/com/dmdirc/ui/input/InputHandler.java Прегледај датотеку

@@ -498,7 +498,8 @@ public abstract class InputHandler implements ConfigChangeListener {
498 498
 
499 499
             addToBuffer(thisBuffer.toString());
500 500
 
501
-            commandParser.parseCommand(parentWindow.getContainer(), thisBuffer.toString());
501
+            commandParser.parseCommand(parentWindow.getContainer(),
502
+                    parentWindow, thisBuffer.toString());
502 503
         }
503 504
         fireLineWrap(0);
504 505
         fireCommandPassed();

+ 1
- 1
src/com/dmdirc/ui/input/TabCompleter.java Прегледај датотеку

@@ -207,7 +207,7 @@ public class TabCompleter {
207 207
      * Retrieves intelligent results for a deferred command.
208 208
      * 
209 209
      * @param arg The argument number that is being requested
210
-     * @param previousArgs The full list of previous arguments
210
+     * @param context Intelligent tab completion context
211 211
      * @param offset The number of arguments our command used before deferring
212 212
      * to this method
213 213
      * @return Additional tab targets for the text, or null if none are available

+ 5
- 1
test/com/dmdirc/commandparser/commands/channel/BanTest.java Прегледај датотеку

@@ -22,9 +22,11 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.channel;
24 24
 
25
+import com.dmdirc.Channel;
25 26
 import com.dmdirc.FrameContainer;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
28 30
 
29 31
 import org.junit.BeforeClass;
30 32
 import org.junit.Test;
@@ -42,7 +44,9 @@ public class BanTest {
42 44
     @Test
43 45
     public void testUsage() {
44 46
         final FrameContainer<?> tiw = mock(FrameContainer.class);
45
-        command.execute(tiw, null, null, false, new CommandArguments("/ban"));
47
+        final Channel channel = mock(Channel.class);
48
+        command.execute(tiw, new CommandArguments("/ban"), 
49
+                new ChannelCommandContext(null, command, channel));
46 50
         
47 51
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
48 52
     }

+ 10
- 4
test/com/dmdirc/commandparser/commands/channel/KickReasonTest.java Прегледај датотеку

@@ -26,6 +26,7 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.config.IdentityManager;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
29 30
 import com.dmdirc.config.ConfigManager;
30 31
 import com.dmdirc.parser.irc.IRCChannelClientInfo;
31 32
 import com.dmdirc.parser.irc.IRCChannelInfo;
@@ -46,7 +47,9 @@ public class KickReasonTest {
46 47
     @Test
47 48
     public void testUsage() {
48 49
         final FrameContainer<?> tiw = mock(FrameContainer.class);
49
-        command.execute(tiw, null, null, false, new CommandArguments("/kick"));
50
+        final Channel channel = mock(Channel.class);
51
+        command.execute(tiw, new CommandArguments("/kick"),
52
+                new ChannelCommandContext(null, command, channel));
50 53
         
51 54
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
52 55
     }
@@ -60,7 +63,8 @@ public class KickReasonTest {
60 63
         when(channel.getChannelInfo()).thenReturn(channelInfo);
61 64
         when(channelInfo.getChannelClient(anyString())).thenReturn(null);
62 65
 
63
-        command.execute(tiw, null, channel, false, new CommandArguments("/kick user1"));
66
+        command.execute(tiw, new CommandArguments("/kick user1"),
67
+                new ChannelCommandContext(null, command, channel));
64 68
 
65 69
         verify(tiw).addLine(eq("commandError"), matches(".*user1"));
66 70
     }
@@ -75,7 +79,8 @@ public class KickReasonTest {
75 79
         when(channel.getChannelInfo()).thenReturn(channelInfo);
76 80
         when(channelInfo.getChannelClient("user1")).thenReturn(cci);
77 81
 
78
-        command.execute(tiw, null, channel, false, new CommandArguments("/kick user1 reason here"));
82
+        command.execute(tiw, new CommandArguments("/kick user1 reason here"),
83
+                new ChannelCommandContext(null, command, channel));
79 84
 
80 85
         verify(cci).kick("reason here");
81 86
     }
@@ -93,7 +98,8 @@ public class KickReasonTest {
93 98
         when(channelInfo.getChannelClient("user1")).thenReturn(cci);
94 99
         when(manager.getOption("general", "kickmessage")).thenReturn("reason here");
95 100
 
96
-        command.execute(tiw, null, channel, false, new CommandArguments("/kick user1"));
101
+        command.execute(tiw, new CommandArguments("/kick user1"),
102
+                new ChannelCommandContext(null, command, channel));
97 103
 
98 104
         verify(cci).kick("reason here");
99 105
     }

+ 8
- 4
test/com/dmdirc/commandparser/commands/channel/ModeTest.java Прегледај датотеку

@@ -26,6 +26,7 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
29 30
 import com.dmdirc.config.IdentityManager;
30 31
 import com.dmdirc.config.InvalidIdentityFileException;
31 32
 import com.dmdirc.parser.irc.IRCChannelInfo;
@@ -58,6 +59,7 @@ public class ModeTest {
58 59
         channel = mock(Channel.class);
59 60
         channelinfo = mock(IRCChannelInfo.class);
60 61
 
62
+        when(channel.getServer()).thenReturn(server);
61 63
         when(server.getParser()).thenReturn(parser);
62 64
         when(channel.getChannelInfo()).thenReturn(channelinfo);
63 65
         when(channelinfo.getModes()).thenReturn("my mode string!");
@@ -68,7 +70,8 @@ public class ModeTest {
68 70
     public void testWithoutArgs() {
69 71
         final FrameContainer<?> origin = mock(FrameContainer.class);
70 72
         
71
-        command.execute(origin, server, channel, false, new CommandArguments("/mode"));
73
+        command.execute(origin, new CommandArguments("/mode"),
74
+                new ChannelCommandContext(null, command, channel));
72 75
 
73 76
         verify(origin).addLine("channelModeDiscovered", "my mode string!", channelinfo);
74 77
     }
@@ -77,7 +80,8 @@ public class ModeTest {
77 80
     public void testWithArgs() {
78 81
         final FrameContainer<?> origin = mock(FrameContainer.class);
79 82
 
80
-        command.execute(origin, server, channel, false, new CommandArguments("/mode +hello -bye"));
83
+        command.execute(origin, new CommandArguments("/mode +hello -bye"),
84
+                new ChannelCommandContext(null, command, channel));
81 85
 
82 86
         verify(parser).sendRawMessage("MODE #chan +hello -bye");
83 87
     }
@@ -86,8 +90,8 @@ public class ModeTest {
86 90
     public void testExternalWithArgs() {
87 91
         final FrameContainer<?> origin = mock(FrameContainer.class);
88 92
 
89
-        command.execute(origin, server, "#chan", false,
90
-                new CommandArguments("/mode +hello -bye"));
93
+        command.execute(origin, new CommandArguments("/mode +hello -bye"),
94
+                new ChannelCommandContext(null, command, channel));
91 95
 
92 96
         verify(parser).sendRawMessage("MODE #chan +hello -bye");
93 97
     }

+ 4
- 1
test/com/dmdirc/commandparser/commands/channel/NamesTest.java Прегледај датотеку

@@ -25,6 +25,7 @@ package com.dmdirc.commandparser.commands.channel;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
28 29
 import com.dmdirc.config.IdentityManager;
29 30
 import com.dmdirc.config.InvalidIdentityFileException;
30 31
 import com.dmdirc.parser.irc.IRCChannelInfo;
@@ -57,6 +58,7 @@ public class NamesTest {
57 58
         channel = mock(Channel.class);
58 59
         channelinfo = mock(IRCChannelInfo.class);
59 60
 
61
+        when(channel.getServer()).thenReturn(server);
60 62
         when(server.getParser()).thenReturn(parser);
61 63
         when(channel.getChannelInfo()).thenReturn(channelinfo);
62 64
         when(channelinfo.getName()).thenReturn("#chan");
@@ -64,7 +66,8 @@ public class NamesTest {
64 66
 
65 67
     @Test
66 68
     public void testNormal() {
67
-        command.execute(null, server, channel, false, new CommandArguments("/names"));
69
+        command.execute(null, new CommandArguments("/names"),
70
+                new ChannelCommandContext(null, command, channel));
68 71
 
69 72
         verify(parser).sendRawMessage("NAMES #chan");
70 73
     }

+ 5
- 2
test/com/dmdirc/commandparser/commands/channel/PartTest.java Прегледај датотеку

@@ -25,6 +25,7 @@ package com.dmdirc.commandparser.commands.channel;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
28 29
 import com.dmdirc.config.ConfigManager;
29 30
 import com.dmdirc.config.IdentityManager;
30 31
 import com.dmdirc.config.InvalidIdentityFileException;
@@ -60,7 +61,8 @@ public class PartTest {
60 61
 
61 62
     @Test
62 63
     public void testWithoutArgs() {
63
-        command.execute(origin, null, channel, false, new CommandArguments("/part"));
64
+        command.execute(origin, new CommandArguments("/part"),
65
+                new ChannelCommandContext(null, command, channel));
64 66
 
65 67
         verify(channel).part("config part message");
66 68
         verify(channel).close();
@@ -68,7 +70,8 @@ public class PartTest {
68 70
 
69 71
     @Test
70 72
     public void testWithArgs() {
71
-        command.execute(origin, null, channel, false, new CommandArguments("/part custom part"));
73
+        command.execute(origin, new CommandArguments("/part custom part"),
74
+                new ChannelCommandContext(null, command, channel));
72 75
 
73 76
         verify(channel).part("custom part");
74 77
         verify(channel).close();

+ 16
- 3
test/com/dmdirc/commandparser/commands/channel/SetNickColourTest.java Прегледај датотеку

@@ -21,9 +21,12 @@
21 21
  */
22 22
 package com.dmdirc.commandparser.commands.channel;
23 23
 
24
+import com.dmdirc.Channel;
24 25
 import com.dmdirc.FrameContainer;
25 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
26 28
 import com.dmdirc.config.IdentityManager;
29
+import org.junit.Before;
27 30
 
28 31
 import org.junit.BeforeClass;
29 32
 import org.junit.Test;
@@ -31,17 +34,25 @@ import static org.mockito.Mockito.*;
31 34
 
32 35
 public class SetNickColourTest {
33 36
 
37
+    private Channel channel;
38
+
34 39
     @BeforeClass
35 40
     public static void setUpClass() throws Exception {
36 41
         IdentityManager.load();
37 42
     }
43
+
44
+    @Before
45
+    public void setUp() {
46
+        channel = mock(Channel.class);
47
+    }
38 48
     
39 49
     private final SetNickColour command = new SetNickColour();
40 50
 
41 51
     @Test
42 52
     public void testUsageNoArgs() {
43 53
         final FrameContainer<?> tiw = mock(FrameContainer.class);
44
-        command.execute(tiw, null, null, false, new CommandArguments("/foo"));
54
+        command.execute(tiw, new CommandArguments("/foo"),
55
+                new ChannelCommandContext(null, command, channel));
45 56
         
46 57
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
47 58
     }
@@ -49,7 +60,8 @@ public class SetNickColourTest {
49 60
     @Test
50 61
     public void testUsageNicklist() {
51 62
         final FrameContainer<?> tiw = mock(FrameContainer.class);
52
-        command.execute(tiw, null, null, false, new CommandArguments("/foo --nicklist"));
63
+        command.execute(tiw, new CommandArguments("/foo --nicklist"),
64
+                new ChannelCommandContext(null, command, channel));
53 65
         
54 66
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
55 67
     }    
@@ -57,7 +69,8 @@ public class SetNickColourTest {
57 69
     @Test
58 70
     public void testUsageText() {
59 71
         final FrameContainer<?> tiw = mock(FrameContainer.class);
60
-        command.execute(tiw, null, null, false, new CommandArguments("/foo --text"));
72
+        command.execute(tiw, new CommandArguments("/foo --text"),
73
+                new ChannelCommandContext(null, command, channel));
61 74
         
62 75
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
63 76
     }       

+ 15
- 5
test/com/dmdirc/commandparser/commands/chat/MeTest.java Прегледај датотеку

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

+ 7
- 4
test/com/dmdirc/commandparser/commands/global/AliasCommandTest.java Прегледај датотеку

@@ -23,6 +23,7 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.commandparser.CommandArguments;
26
+import com.dmdirc.commandparser.commands.context.CommandContext;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 
28 29
 import org.junit.BeforeClass;
@@ -31,18 +32,19 @@ import static org.mockito.Mockito.*;
31 32
 
32 33
 public class AliasCommandTest {
33 34
 
35
+    private final AliasCommand command = new AliasCommand();
36
+    
34 37
     @BeforeClass
35 38
     public static void setUpClass() throws Exception {
36 39
         IdentityManager.load();
37 40
     }
38 41
 
39
-    private final AliasCommand command = new AliasCommand();
40
-
41 42
     @Test
42 43
     public void testUsageNoArgs() {
43 44
         final FrameContainer<?> tiw = mock(FrameContainer.class);
44 45
 
45
-        command.execute(tiw, false, new CommandArguments("/foo"));
46
+        command.execute(tiw, new CommandArguments("/foo"),
47
+                new CommandContext(null, command));
46 48
         
47 49
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
48 50
     }
@@ -51,7 +53,8 @@ public class AliasCommandTest {
51 53
     public void testUsageOneArg() {
52 54
         final FrameContainer<?> tiw = mock(FrameContainer.class);
53 55
         
54
-        command.execute(tiw, false, new CommandArguments("/foo --remove"));
56
+        command.execute(tiw, new CommandArguments("/foo --remove"),
57
+                new CommandContext(null, command));
55 58
         
56 59
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
57 60
     }    

+ 7
- 4
test/com/dmdirc/commandparser/commands/global/DebugTest.java Прегледај датотеку

@@ -23,6 +23,7 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.commandparser.CommandArguments;
26
+import com.dmdirc.commandparser.commands.context.CommandContext;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 import org.junit.BeforeClass;
28 29
 import org.junit.Test;
@@ -30,18 +31,19 @@ import static org.mockito.Mockito.*;
30 31
 
31 32
 public class DebugTest {
32 33
 
34
+    private final Debug command = new Debug();
35
+    
33 36
     @BeforeClass
34 37
     public static void setUpClass() throws Exception {
35 38
         IdentityManager.load();
36 39
     }
37
-    
38
-    private final Debug command = new Debug();
39 40
 
40 41
     @Test
41 42
     public void testUsage() {
42 43
         final FrameContainer<?> tiw = mock(FrameContainer.class);
43 44
 
44
-        command.execute(tiw, false, new CommandArguments("/foo"));
45
+        command.execute(tiw, new CommandArguments("/foo"),
46
+                new CommandContext(null, command));
45 47
         
46 48
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
47 49
     }
@@ -50,7 +52,8 @@ public class DebugTest {
50 52
     public void testInvalidArg() {
51 53
         final FrameContainer<?> tiw = mock(FrameContainer.class);
52 54
 
53
-        command.execute(tiw, false, new CommandArguments("/foo flubadee"));
55
+        command.execute(tiw, new CommandArguments("/foo flubadee"),
56
+                new CommandContext(null, command));
54 57
         
55 58
         verify(tiw).addLine(eq("commandError"), anyString());
56 59
     }    

+ 7
- 4
test/com/dmdirc/commandparser/commands/global/IfpluginTest.java Прегледај датотеку

@@ -23,6 +23,7 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.commandparser.CommandArguments;
26
+import com.dmdirc.commandparser.commands.context.CommandContext;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 
28 29
 import org.junit.BeforeClass;
@@ -31,17 +32,18 @@ import static org.mockito.Mockito.*;
31 32
 
32 33
 public class IfpluginTest {
33 34
 
35
+    private final Ifplugin command = new Ifplugin();
36
+    
34 37
     @BeforeClass
35 38
     public static void setUpClass() throws Exception {
36 39
         IdentityManager.load();
37 40
     }
38
-    
39
-    private final Ifplugin command = new Ifplugin();
40 41
 
41 42
     @Test
42 43
     public void testUsageNoArgs() {
43 44
         final FrameContainer<?> tiw = mock(FrameContainer.class);
44
-        command.execute(tiw, false, new CommandArguments("/foo"));
45
+        command.execute(tiw, new CommandArguments("/foo"),
46
+                new CommandContext(null, command));
45 47
         
46 48
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
47 49
     }
@@ -49,7 +51,8 @@ public class IfpluginTest {
49 51
     @Test
50 52
     public void testUsageOneArg() {
51 53
         final FrameContainer<?> tiw = mock(FrameContainer.class);
52
-        command.execute(tiw, false, new CommandArguments("/foo bar"));
54
+        command.execute(tiw, new CommandArguments("/foo bar"),
55
+                new CommandContext(null, command));
53 56
         
54 57
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
55 58
     }    

+ 9
- 4
test/com/dmdirc/commandparser/commands/global/NewServerTest.java Прегледај датотеку

@@ -23,6 +23,7 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.commandparser.CommandArguments;
26
+import com.dmdirc.commandparser.commands.context.CommandContext;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 
28 29
 import org.junit.BeforeClass;
@@ -41,7 +42,8 @@ public class NewServerTest {
41 42
     @Test
42 43
     public void testUsageNoArgs() {
43 44
         final FrameContainer<?> tiw = mock(FrameContainer.class);
44
-        command.execute(tiw, false, new CommandArguments("/foo"));
45
+        command.execute(tiw, new CommandArguments("/foo"),
46
+                new CommandContext(null, command));
45 47
         
46 48
         verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
47 49
     }
@@ -49,7 +51,8 @@ public class NewServerTest {
49 51
     @Test
50 52
     public void testInvalidPort() {
51 53
         final FrameContainer<?> tiw = mock(FrameContainer.class);
52
-        command.execute(tiw, false, new CommandArguments("/foo foo:abc"));
54
+        command.execute(tiw, new CommandArguments("/foo foo:abc"),
55
+                new CommandContext(null, command));
53 56
         
54 57
         verify(tiw).addLine(eq("commandError"), anyString());
55 58
     }
@@ -57,7 +60,8 @@ public class NewServerTest {
57 60
     @Test
58 61
     public void testOutOfRangePort1() {
59 62
         final FrameContainer<?> tiw = mock(FrameContainer.class);
60
-        command.execute(tiw, false, new CommandArguments("/foo foo:0"));
63
+        command.execute(tiw, new CommandArguments("/foo foo:0"),
64
+                new CommandContext(null, command));
61 65
         
62 66
         verify(tiw).addLine(eq("commandError"), anyString());
63 67
     }
@@ -65,7 +69,8 @@ public class NewServerTest {
65 69
     @Test
66 70
     public void testOutOfRangePort2() {
67 71
         final FrameContainer<?> tiw = mock(FrameContainer.class);
68
-        command.execute(tiw, false, new CommandArguments("/foo foo:65537"));
72
+        command.execute(tiw, new CommandArguments("/foo foo:65537"),
73
+                new CommandContext(null, command));
69 74
         
70 75
         verify(tiw).addLine(eq("commandError"), anyString());
71 76
     }

+ 30
- 33
test/com/dmdirc/commandparser/commands/server/ChangeServerTest.java Прегледај датотеку

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

+ 10
- 10
test/com/dmdirc/commandparser/parsers/CommandParserTest.java Прегледај датотеку

@@ -45,7 +45,7 @@ public class CommandParserTest {
45 45
     @Test
46 46
     public void testBasicCommand() {
47 47
         final TestCommandParser tcp = new TestCommandParser();
48
-        tcp.parseCommand(null, "/echo this is a test");
48
+        tcp.parseCommand(null, null, "/echo this is a test");
49 49
 
50 50
         assertNull(tcp.nonCommandLine);
51 51
         assertNull(tcp.invalidCommand);
@@ -57,7 +57,7 @@ public class CommandParserTest {
57 57
     @Test
58 58
     public void testBasicNoArgs() {
59 59
         final TestCommandParser tcp = new TestCommandParser();
60
-        tcp.parseCommand(null, "/echo");
60
+        tcp.parseCommand(null, null, "/echo");
61 61
 
62 62
         assertNull(tcp.nonCommandLine);
63 63
         assertNull(tcp.invalidCommand);
@@ -69,7 +69,7 @@ public class CommandParserTest {
69 69
     @Test
70 70
     public void testSilentNoArgs() {
71 71
         final TestCommandParser tcp = new TestCommandParser();
72
-        tcp.parseCommand(null, "/.echo");
72
+        tcp.parseCommand(null, null, "/.echo");
73 73
 
74 74
         assertNull(tcp.nonCommandLine);
75 75
         assertNull(tcp.invalidCommand);
@@ -81,7 +81,7 @@ public class CommandParserTest {
81 81
     @Test
82 82
     public void testSilentCommand() {
83 83
         final TestCommandParser tcp = new TestCommandParser();
84
-        tcp.parseCommand(null, "/.echo this is a test");
84
+        tcp.parseCommand(null, null, "/.echo this is a test");
85 85
 
86 86
         assertNull(tcp.nonCommandLine);
87 87
         assertNull(tcp.invalidCommand);
@@ -93,7 +93,7 @@ public class CommandParserTest {
93 93
     @Test
94 94
     public void testNonExistantCommand() {
95 95
         final TestCommandParser tcp = new TestCommandParser();
96
-        tcp.parseCommand(null, "/foobar moo bar");
96
+        tcp.parseCommand(null, null, "/foobar moo bar");
97 97
 
98 98
         assertNull(tcp.nonCommandLine);
99 99
         assertEquals("foobar", tcp.invalidCommand);
@@ -105,7 +105,7 @@ public class CommandParserTest {
105 105
     @Test
106 106
     public void testEmptyCommand() {
107 107
         final TestCommandParser tcp = new TestCommandParser();
108
-        tcp.parseCommand(null, "/ moo bar");
108
+        tcp.parseCommand(null, null, "/ moo bar");
109 109
 
110 110
         assertNull(tcp.nonCommandLine);
111 111
         assertEquals("", tcp.invalidCommand);
@@ -117,7 +117,7 @@ public class CommandParserTest {
117 117
     @Test
118 118
     public void testEmptySilentCommand() {
119 119
         final TestCommandParser tcp = new TestCommandParser();
120
-        tcp.parseCommand(null, "/. moo bar");
120
+        tcp.parseCommand(null, null, "/. moo bar");
121 121
 
122 122
         assertNull(tcp.nonCommandLine);
123 123
         assertEquals("", tcp.invalidCommand);
@@ -129,7 +129,7 @@ public class CommandParserTest {
129 129
     @Test
130 130
     public void testNonCommand() {
131 131
         final TestCommandParser tcp = new TestCommandParser();
132
-        tcp.parseCommand(null, "Foobar baz");
132
+        tcp.parseCommand(null, null, "Foobar baz");
133 133
 
134 134
         assertNotNull(tcp.nonCommandLine);
135 135
         assertEquals("Foobar baz", tcp.nonCommandLine);
@@ -141,12 +141,12 @@ public class CommandParserTest {
141 141
     @Test
142 142
     public void testCommandHistory() {
143 143
         final TestCommandParser tcp = new TestCommandParser();
144
-        tcp.parseCommand(null, "/echo this is a test");
144
+        tcp.parseCommand(null, null, "/echo this is a test");
145 145
 
146 146
         final long time1 = tcp.getCommandTime("echo this is a test");
147 147
         assertTrue(time1 > 0);
148 148
         
149
-        tcp.parseCommand(null, "/echo this is a test");
149
+        tcp.parseCommand(null, null, "/echo this is a test");
150 150
         final long time2 = tcp.getCommandTime("echo this is a test");
151 151
         assertTrue(time2 > 0);
152 152
         assertTrue(time2 >= time1);

+ 5
- 3
test/com/dmdirc/harness/TestCommandParser.java Прегледај датотеку

@@ -24,11 +24,13 @@ package com.dmdirc.harness;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
27 28
 import com.dmdirc.commandparser.parsers.*;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.CommandType;
30 31
 import com.dmdirc.commandparser.commands.Command;
31 32
 import com.dmdirc.ui.interfaces.InputWindow;
33
+import com.dmdirc.ui.interfaces.Window;
32 34
 
33 35
 public class TestCommandParser extends CommandParser {
34 36
     private static final long serialVersionUID = 7073002401375438532L;
@@ -49,10 +51,10 @@ public class TestCommandParser extends CommandParser {
49 51
     }
50 52
 
51 53
     @Override
52
-    protected void executeCommand(FrameContainer<?> origin, boolean isSilent,
53
-                                  Command command, CommandArguments args) {
54
+    protected void executeCommand(FrameContainer<?> origin, Window window,
55
+            CommandInfo commandInfo, Command command, CommandArguments args) {
54 56
         executedCommand = command;
55
-        wasSilent = isSilent;
57
+        wasSilent = args.isSilent();
56 58
         commandArgs = args;
57 59
     }
58 60
 

Loading…
Откажи
Сачувај