Selaa lähdekoodia

Remove windows from commands

Change-Id: I5b6e7e2ca81d114028fef6cac0d88498def62ea0
Depends-On: I895be099fa526e4e4b566e7178120b5d1ad0912c
Reviewed-on: http://gerrit.dmdirc.com/2011
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.6b1
Greg Holmes 13 vuotta sitten
vanhempi
commit
935c21ebf8
31 muutettua tiedostoa jossa 124 lisäystä ja 254 poistoa
  1. 1
    7
      src/com/dmdirc/actions/ActionModel.java
  2. 0
    2
      src/com/dmdirc/commandparser/CommandManager.java
  3. 4
    4
      src/com/dmdirc/commandparser/commands/IntelligentCommand.java
  4. 3
    2
      src/com/dmdirc/commandparser/commands/ValidatingCommand.java
  5. 2
    2
      src/com/dmdirc/commandparser/commands/WrappableCommand.java
  6. 0
    63
      src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java
  7. 7
    6
      src/com/dmdirc/commandparser/commands/chat/Me.java
  8. 2
    2
      src/com/dmdirc/commandparser/commands/context/ChannelCommandContext.java
  9. 3
    3
      src/com/dmdirc/commandparser/commands/context/ChatCommandContext.java
  10. 4
    4
      src/com/dmdirc/commandparser/commands/context/CommandContext.java
  11. 5
    3
      src/com/dmdirc/commandparser/commands/context/QueryCommandContext.java
  12. 2
    2
      src/com/dmdirc/commandparser/commands/context/ServerCommandContext.java
  13. 1
    1
      src/com/dmdirc/commandparser/commands/global/AllServers.java
  14. 2
    3
      src/com/dmdirc/commandparser/commands/global/Echo.java
  15. 2
    2
      src/com/dmdirc/commandparser/commands/global/Ifplugin.java
  16. 4
    4
      src/com/dmdirc/commandparser/commands/global/Set.java
  17. 1
    1
      src/com/dmdirc/commandparser/commands/server/AllChannels.java
  18. 1
    1
      src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java
  19. 4
    3
      src/com/dmdirc/commandparser/commands/server/Message.java
  20. 7
    4
      src/com/dmdirc/commandparser/commands/server/OpenQuery.java
  21. 0
    65
      src/com/dmdirc/commandparser/commands/server/ServerSettings.java
  22. 5
    5
      src/com/dmdirc/commandparser/parsers/ChannelCommandParser.java
  23. 7
    6
      src/com/dmdirc/commandparser/parsers/ChatCommandParser.java
  24. 9
    10
      src/com/dmdirc/commandparser/parsers/CommandParser.java
  25. 3
    4
      src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java
  26. 5
    5
      src/com/dmdirc/commandparser/parsers/QueryCommandParser.java
  27. 4
    5
      src/com/dmdirc/commandparser/parsers/ServerCommandParser.java
  28. 13
    13
      src/com/dmdirc/ui/input/InputHandler.java
  29. 6
    4
      src/com/dmdirc/ui/input/TabCompleter.java
  30. 16
    16
      test/com/dmdirc/commandparser/parsers/CommandParserTest.java
  31. 1
    2
      test/com/dmdirc/harness/TestCommandParser.java

+ 1
- 7
src/com/dmdirc/actions/ActionModel.java Näytä tiedosto

28
 import com.dmdirc.actions.interfaces.ActionType;
28
 import com.dmdirc.actions.interfaces.ActionType;
29
 import com.dmdirc.commandparser.parsers.CommandParser;
29
 import com.dmdirc.commandparser.parsers.CommandParser;
30
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
30
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
31
-import com.dmdirc.ui.interfaces.Window;
32
 
31
 
33
 import java.util.ArrayList;
32
 import java.util.ArrayList;
34
 import java.util.Arrays;
33
 import java.util.Arrays;
141
             return false;
140
             return false;
142
         }
141
         }
143
 
142
 
144
-        Window window = null;
145
         WritableFrameContainer container = null;
143
         WritableFrameContainer container = null;
146
         CommandParser cp = null;
144
         CommandParser cp = null;
147
 
145
 
152
             container = ServerManager.getServerManager().getServers().get(0);
150
             container = ServerManager.getServerManager().getServers().get(0);
153
         }
151
         }
154
 
152
 
155
-        if (arguments.length > 0 && arguments[0] instanceof Window) {
156
-            window = (Window) arguments[0];
157
-        }
158
-
159
         if (container == null) {
153
         if (container == null) {
160
             cp = GlobalCommandParser.getGlobalCommandParser();
154
             cp = GlobalCommandParser.getGlobalCommandParser();
161
         } else {
155
         } else {
163
         }
157
         }
164
 
158
 
165
         for (String command : response) {
159
         for (String command : response) {
166
-            cp.parseCommand(container, window, sub.doSubstitution(command, arguments));
160
+            cp.parseCommand(container, sub.doSubstitution(command, arguments));
167
         }
161
         }
168
 
162
 
169
         if (newFormat != null && format != null) {
163
         if (newFormat != null && format != null) {

+ 0
- 2
src/com/dmdirc/commandparser/CommandManager.java Näytä tiedosto

229
 
229
 
230
         // Channel commands
230
         // Channel commands
231
         registerCommand(new Ban(), Ban.INFO);
231
         registerCommand(new Ban(), Ban.INFO);
232
-        registerCommand(new ChannelSettings(), ChannelSettings.INFO);
233
         registerCommand(new Cycle(), Cycle.INFO);
232
         registerCommand(new Cycle(), Cycle.INFO);
234
         registerCommand(new Invite(), Invite.INFO);
233
         registerCommand(new Invite(), Invite.INFO);
235
         registerCommand(new KickReason(), KickReason.INFO);
234
         registerCommand(new KickReason(), KickReason.INFO);
254
         registerCommand(new OpenQuery(), OpenQuery.INFO);
253
         registerCommand(new OpenQuery(), OpenQuery.INFO);
255
         registerCommand(new Raw(), Raw.INFO);
254
         registerCommand(new Raw(), Raw.INFO);
256
         registerCommand(new Reconnect(), Reconnect.INFO);
255
         registerCommand(new Reconnect(), Reconnect.INFO);
257
-        registerCommand(new ServerSettings(), ServerSettings.INFO);
258
         registerCommand(new Umode(), Umode.INFO);
256
         registerCommand(new Umode(), Umode.INFO);
259
 
257
 
260
         registerCommand(new RawServerCommand("lusers"));
258
         registerCommand(new RawServerCommand("lusers"));

+ 4
- 4
src/com/dmdirc/commandparser/commands/IntelligentCommand.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.commandparser.commands;
23
 package com.dmdirc.commandparser.commands;
24
 
24
 
25
+import com.dmdirc.WritableFrameContainer;
25
 import com.dmdirc.ui.input.AdditionalTabTargets;
26
 import com.dmdirc.ui.input.AdditionalTabTargets;
26
-import com.dmdirc.ui.interfaces.InputWindow;
27
 
27
 
28
 import java.util.List;
28
 import java.util.List;
29
 
29
 
52
     class IntelligentCommandContext {
52
     class IntelligentCommandContext {
53
 
53
 
54
         /** The window the command is being entered in. */
54
         /** The window the command is being entered in. */
55
-        private final InputWindow window;
55
+        private final WritableFrameContainer window;
56
 
56
 
57
         /** The previously supplied arguments, if any. */
57
         /** The previously supplied arguments, if any. */
58
         private final List<String> previousArgs;
58
         private final List<String> previousArgs;
67
          * @param previousArgs The previously supplied arguments, if any
67
          * @param previousArgs The previously supplied arguments, if any
68
          * @param partial The partially-typed word being completed
68
          * @param partial The partially-typed word being completed
69
          */
69
          */
70
-        public IntelligentCommandContext(final InputWindow window,
70
+        public IntelligentCommandContext(final WritableFrameContainer window,
71
                 final List<String> previousArgs, final String partial) {
71
                 final List<String> previousArgs, final String partial) {
72
             this.window = window;
72
             this.window = window;
73
             this.previousArgs = previousArgs;
73
             this.previousArgs = previousArgs;
79
          *
79
          *
80
          * @return The command's input window
80
          * @return The command's input window
81
          */
81
          */
82
-        public InputWindow getWindow() {
82
+        public WritableFrameContainer getWindow() {
83
             return window;
83
             return window;
84
         }
84
         }
85
 
85
 

+ 3
- 2
src/com/dmdirc/commandparser/commands/ValidatingCommand.java Näytä tiedosto

21
  */
21
  */
22
 package com.dmdirc.commandparser.commands;
22
 package com.dmdirc.commandparser.commands;
23
 
23
 
24
+import com.dmdirc.WritableFrameContainer;
24
 import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.CommandArguments;
25
-import com.dmdirc.ui.interfaces.InputWindow;
26
 import com.dmdirc.util.validators.ValidationResponse;
26
 import com.dmdirc.util.validators.ValidationResponse;
27
 
27
 
28
 /**
28
 /**
39
      * @return A validation response indicating the validity of the arguments
39
      * @return A validation response indicating the validity of the arguments
40
      * @since 0.6.3m1
40
      * @since 0.6.3m1
41
      */
41
      */
42
-    ValidationResponse validateArguments(InputWindow origin, CommandArguments arguments);
42
+    ValidationResponse validateArguments(WritableFrameContainer origin,
43
+            CommandArguments arguments);
43
 
44
 
44
 }
45
 }

+ 2
- 2
src/com/dmdirc/commandparser/commands/WrappableCommand.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.commandparser.commands;
23
 package com.dmdirc.commandparser.commands;
24
 
24
 
25
+import com.dmdirc.WritableFrameContainer;
25
 import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandArguments;
26
-import com.dmdirc.ui.interfaces.InputWindow;
27
 
27
 
28
 /**
28
 /**
29
  * Wrapping commands are commands whose arguments may be wrapped into multiple
29
  * Wrapping commands are commands whose arguments may be wrapped into multiple
42
      * @return The number of lines that the arguments will result in
42
      * @return The number of lines that the arguments will result in
43
      * @since 0.6.3m1
43
      * @since 0.6.3m1
44
      */
44
      */
45
-    int getLineCount(InputWindow origin, CommandArguments arguments);
45
+    int getLineCount(WritableFrameContainer origin, CommandArguments arguments);
46
 
46
 
47
 }
47
 }

+ 0
- 63
src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java Näytä tiedosto

1
-/*
2
- * Copyright (c) 2006-2011 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.channel;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.commandparser.BaseCommandInfo;
27
-import com.dmdirc.commandparser.CommandArguments;
28
-import com.dmdirc.commandparser.CommandInfo;
29
-import com.dmdirc.commandparser.CommandType;
30
-import com.dmdirc.commandparser.commands.Command;
31
-import com.dmdirc.commandparser.commands.CommandOptions;
32
-import com.dmdirc.commandparser.commands.IntelligentCommand;
33
-import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
-import com.dmdirc.commandparser.commands.context.CommandContext;
35
-import com.dmdirc.ui.input.AdditionalTabTargets;
36
-
37
-/**
38
- * Opens the channel settings window for the channel.
39
- */
40
-@CommandOptions(allowOffline = false)
41
-public class ChannelSettings extends Command implements
42
-        IntelligentCommand {
43
-
44
-    /** A command info object for this command. */
45
-    public static final CommandInfo INFO = new BaseCommandInfo("channelsettings",
46
-            "channelsettings - opens the channel settings window",
47
-            CommandType.TYPE_CHANNEL);
48
-
49
-    /** {@inheritDoc} */
50
-    @Override
51
-    public void execute(final FrameContainer origin,
52
-            final CommandArguments args, final CommandContext context) {
53
-        context.getSource().getController().showChannelSettingsDialog(
54
-                ((ChannelCommandContext) context).getChannel());
55
-    }
56
-
57
-    /** {@inheritDoc} */
58
-    @Override
59
-    public AdditionalTabTargets getSuggestions(final int arg,
60
-            final IntelligentCommandContext context) {
61
-        return new AdditionalTabTargets().excludeAll();
62
-    }
63
-}

+ 7
- 6
src/com/dmdirc/commandparser/commands/chat/Me.java Näytä tiedosto

25
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.MessageTarget;
26
 import com.dmdirc.MessageTarget;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
28
+import com.dmdirc.WritableFrameContainer;
28
 import com.dmdirc.commandparser.CommandArguments;
29
 import com.dmdirc.commandparser.CommandArguments;
29
 import com.dmdirc.commandparser.CommandInfo;
30
 import com.dmdirc.commandparser.CommandInfo;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.CommandType;
32
 import com.dmdirc.commandparser.commands.ValidatingCommand;
33
 import com.dmdirc.commandparser.commands.ValidatingCommand;
33
 import com.dmdirc.commandparser.commands.context.ChatCommandContext;
34
 import com.dmdirc.commandparser.commands.context.ChatCommandContext;
34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
-import com.dmdirc.ui.interfaces.InputWindow;
36
 import com.dmdirc.util.validators.ValidationResponse;
36
 import com.dmdirc.util.validators.ValidationResponse;
37
 
37
 
38
 /**
38
 /**
59
 
59
 
60
     /** {@inheritDoc} */
60
     /** {@inheritDoc} */
61
     @Override
61
     @Override
62
-    public ValidationResponse validateArguments(final InputWindow origin,
62
+    public ValidationResponse validateArguments(
63
+            final WritableFrameContainer origin,
63
             final CommandArguments arguments) {
64
             final CommandArguments arguments) {
64
-        if (origin.getContainer().getServer() == null
65
-                || origin.getContainer().getServer().getParser() == null) {
65
+        if (origin.getServer() == null
66
+                || origin.getServer().getParser() == null) {
66
             return new ValidationResponse();
67
             return new ValidationResponse();
67
         }
68
         }
68
 
69
 
69
         final int length = 2 + arguments.getArgumentsAsString().length();
70
         final int length = 2 + arguments.getArgumentsAsString().length();
70
 
71
 
71
-        if (origin.getContainer().getServer().getParser().getMaxLength("PRIVMSG",
72
-                origin.getContainer().getName()) <= length) {
72
+        if (origin.getServer().getParser().getMaxLength("PRIVMSG",
73
+                origin.getName()) <= length) {
73
             return new ValidationResponse("Too long");
74
             return new ValidationResponse("Too long");
74
         } else {
75
         } else {
75
             return new ValidationResponse();
76
             return new ValidationResponse();

+ 2
- 2
src/com/dmdirc/commandparser/commands/context/ChannelCommandContext.java Näytä tiedosto

23
 package com.dmdirc.commandparser.commands.context;
23
 package com.dmdirc.commandparser.commands.context;
24
 
24
 
25
 import com.dmdirc.Channel;
25
 import com.dmdirc.Channel;
26
+import com.dmdirc.FrameContainer;
26
 import com.dmdirc.commandparser.CommandInfo;
27
 import com.dmdirc.commandparser.CommandInfo;
27
-import com.dmdirc.ui.interfaces.Window;
28
 
28
 
29
 /**
29
 /**
30
  * A specialised {@link CommandContext} for commands executed in channels.
30
  * A specialised {@link CommandContext} for commands executed in channels.
44
      * with the input
44
      * with the input
45
      * @param channel The channel associated with the command
45
      * @param channel The channel associated with the command
46
      */
46
      */
47
-    public ChannelCommandContext(final Window source,
47
+    public ChannelCommandContext(final FrameContainer source,
48
             final CommandInfo commandInfo, final Channel channel) {
48
             final CommandInfo commandInfo, final Channel channel) {
49
         super(source, commandInfo, channel);
49
         super(source, commandInfo, channel);
50
         this.channel = channel;
50
         this.channel = channel;

+ 3
- 3
src/com/dmdirc/commandparser/commands/context/ChatCommandContext.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.commandparser.commands.context;
23
 package com.dmdirc.commandparser.commands.context;
24
 
24
 
25
+import com.dmdirc.FrameContainer;
25
 import com.dmdirc.MessageTarget;
26
 import com.dmdirc.MessageTarget;
26
 import com.dmdirc.commandparser.CommandInfo;
27
 import com.dmdirc.commandparser.CommandInfo;
27
-import com.dmdirc.ui.interfaces.Window;
28
 
28
 
29
 /**
29
 /**
30
  * A command context specific to chat windows.
30
  * A command context specific to chat windows.
43
      * @param commandInfo The command info object which associated the command with the input
43
      * @param commandInfo The command info object which associated the command with the input
44
      * @param chat The chat container associated with the command
44
      * @param chat The chat container associated with the command
45
      */
45
      */
46
-    public ChatCommandContext(final Window source, final CommandInfo commandInfo,
47
-            final MessageTarget chat) {
46
+    public ChatCommandContext(final FrameContainer source,
47
+            final CommandInfo commandInfo, final MessageTarget chat) {
48
         super(source, commandInfo, chat.getServer());
48
         super(source, commandInfo, chat.getServer());
49
         this.chat = chat;
49
         this.chat = chat;
50
     }
50
     }

+ 4
- 4
src/com/dmdirc/commandparser/commands/context/CommandContext.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.commandparser.commands.context;
23
 package com.dmdirc.commandparser.commands.context;
24
 
24
 
25
+import com.dmdirc.FrameContainer;
25
 import com.dmdirc.commandparser.CommandInfo;
26
 import com.dmdirc.commandparser.CommandInfo;
26
-import com.dmdirc.ui.interfaces.Window;
27
 
27
 
28
 /**
28
 /**
29
  * Provides information relating to the context that a command was executed in.
29
  * Provides information relating to the context that a command was executed in.
36
     protected final CommandInfo commandInfo;
36
     protected final CommandInfo commandInfo;
37
 
37
 
38
     /** The source of this command. */
38
     /** The source of this command. */
39
-    protected final Window source;
39
+    protected final FrameContainer source;
40
 
40
 
41
     /**
41
     /**
42
      * Creates a new command context.
42
      * Creates a new command context.
44
      * @param source The source of the command
44
      * @param source The source of the command
45
      * @param commandInfo The command info object which associated the command with the input
45
      * @param commandInfo The command info object which associated the command with the input
46
      */
46
      */
47
-    public CommandContext(final Window source, final CommandInfo commandInfo) {
47
+    public CommandContext(final FrameContainer source, final CommandInfo commandInfo) {
48
         this.source = source;
48
         this.source = source;
49
         this.commandInfo = commandInfo;
49
         this.commandInfo = commandInfo;
50
     }
50
     }
64
      *
64
      *
65
      * @return The window the command came from, or null
65
      * @return The window the command came from, or null
66
      */
66
      */
67
-    public Window getSource() {
67
+    public FrameContainer getSource() {
68
         return source;
68
         return source;
69
     }
69
     }
70
 
70
 

+ 5
- 3
src/com/dmdirc/commandparser/commands/context/QueryCommandContext.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.commandparser.commands.context;
23
 package com.dmdirc.commandparser.commands.context;
24
 
24
 
25
+import com.dmdirc.FrameContainer;
25
 import com.dmdirc.Query;
26
 import com.dmdirc.Query;
26
 import com.dmdirc.commandparser.CommandInfo;
27
 import com.dmdirc.commandparser.CommandInfo;
27
-import com.dmdirc.ui.interfaces.Window;
28
 
28
 
29
 /**
29
 /**
30
  * A query-specific command context.
30
  * A query-specific command context.
41
      * Creates a new query command context.
41
      * Creates a new query command context.
42
      *
42
      *
43
      * @param source The source of the command
43
      * @param source The source of the command
44
-     * @param commandInfo The command info object which associated the command with the input
44
+     * @param commandInfo The command info object which associated the command
45
+     * with the input
45
      * @param query The query associated with the command
46
      * @param query The query associated with the command
46
      */
47
      */
47
-    public QueryCommandContext(final Window source, final CommandInfo commandInfo, final Query query) {
48
+    public QueryCommandContext(final FrameContainer source,
49
+            final CommandInfo commandInfo, final Query query) {
48
         super(source, commandInfo, query);
50
         super(source, commandInfo, query);
49
         this.query = query;
51
         this.query = query;
50
     }
52
     }

+ 2
- 2
src/com/dmdirc/commandparser/commands/context/ServerCommandContext.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.commandparser.commands.context;
23
 package com.dmdirc.commandparser.commands.context;
24
 
24
 
25
+import com.dmdirc.FrameContainer;
25
 import com.dmdirc.Server;
26
 import com.dmdirc.Server;
26
 import com.dmdirc.commandparser.CommandInfo;
27
 import com.dmdirc.commandparser.CommandInfo;
27
-import com.dmdirc.ui.interfaces.Window;
28
 
28
 
29
 /**
29
 /**
30
  * A command context for server commands.
30
  * A command context for server commands.
44
      * @param commandInfo The command info object which associated the command with the input
44
      * @param commandInfo The command info object which associated the command with the input
45
      * @param server The server associated with the command
45
      * @param server The server associated with the command
46
      */
46
      */
47
-    public ServerCommandContext(final Window source, final CommandInfo commandInfo,
47
+    public ServerCommandContext(final FrameContainer source, final CommandInfo commandInfo,
48
             final Server server) {
48
             final Server server) {
49
         super(source, commandInfo);
49
         super(source, commandInfo);
50
         this.server = server;
50
         this.server = server;

+ 1
- 1
src/com/dmdirc/commandparser/commands/global/AllServers.java Näytä tiedosto

52
         final String command = args.getArgumentsAsString();
52
         final String command = args.getArgumentsAsString();
53
 
53
 
54
         for (Server target : ServerManager.getServerManager().getServers()) {
54
         for (Server target : ServerManager.getServerManager().getServers()) {
55
-            target.getCommandParser().parseCommand(target, context.getSource(), command);
55
+            target.getCommandParser().parseCommand(target, command);
56
         }
56
         }
57
     }
57
     }
58
 
58
 

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

128
                 && context.getPreviousArgs().get(0).equals("--ts"))) {
128
                 && context.getPreviousArgs().get(0).equals("--ts"))) {
129
 
129
 
130
             final List<FrameContainer> windowList = new ArrayList<FrameContainer>();
130
             final List<FrameContainer> windowList = new ArrayList<FrameContainer>();
131
-            final Server currentServer = context.getWindow().getContainer()
132
-                    .getServer();
131
+            final Server currentServer = context.getWindow().getServer();
133
 
132
 
134
             //Active window's Children
133
             //Active window's Children
135
-            windowList.addAll(context.getWindow().getContainer().getChildren());
134
+            windowList.addAll(context.getWindow().getChildren());
136
 
135
 
137
             //Children of Current Window's server
136
             //Children of Current Window's server
138
             if (currentServer != null) {
137
             if (currentServer != null) {

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

73
         if (result != negative) {
73
         if (result != negative) {
74
             if (origin == null) {
74
             if (origin == null) {
75
                 GlobalCommandParser.getGlobalCommandParser().parseCommand(null,
75
                 GlobalCommandParser.getGlobalCommandParser().parseCommand(null,
76
-                        context.getSource(), args.getArgumentsAsString(1));
76
+                        args.getArgumentsAsString(1));
77
             } else {
77
             } else {
78
                 ((WritableFrameContainer) origin).getCommandParser()
78
                 ((WritableFrameContainer) origin).getCommandParser()
79
-                        .parseCommand(origin, context.getSource(), args.getArgumentsAsString(1));
79
+                        .parseCommand(origin, args.getArgumentsAsString(1));
80
             }
80
             }
81
         }
81
         }
82
     }
82
     }

+ 4
- 4
src/com/dmdirc/commandparser/commands/global/Set.java Näytä tiedosto

289
         final AdditionalTabTargets res = new AdditionalTabTargets();
289
         final AdditionalTabTargets res = new AdditionalTabTargets();
290
 
290
 
291
         if (arg == 0) {
291
         if (arg == 0) {
292
-            res.addAll(context.getWindow().getContainer().getConfigManager()
292
+            res.addAll(context.getWindow().getConfigManager()
293
                     .getDomains());
293
                     .getDomains());
294
             res.add("--unset");
294
             res.add("--unset");
295
             res.add("--append");
295
             res.add("--append");
301
                     || previousArgs.get(0).equalsIgnoreCase("--append")
301
                     || previousArgs.get(0).equalsIgnoreCase("--append")
302
                     || previousArgs.get(0).equalsIgnoreCase("--server")
302
                     || previousArgs.get(0).equalsIgnoreCase("--server")
303
                     || previousArgs.get(0).equalsIgnoreCase("--channel")) {
303
                     || previousArgs.get(0).equalsIgnoreCase("--channel")) {
304
-                res.addAll(context.getWindow().getContainer().getConfigManager()
304
+                res.addAll(context.getWindow().getConfigManager()
305
                         .getDomains());
305
                         .getDomains());
306
             } else {
306
             } else {
307
-                res.addAll(context.getWindow().getContainer().getConfigManager()
307
+                res.addAll(context.getWindow().getConfigManager()
308
                         .getOptions(previousArgs.get(0)).keySet());
308
                         .getOptions(previousArgs.get(0)).keySet());
309
             }
309
             }
310
             res.excludeAll();
310
             res.excludeAll();
312
                 || previousArgs.get(0).equalsIgnoreCase("--append")
312
                 || previousArgs.get(0).equalsIgnoreCase("--append")
313
                 || previousArgs.get(0).equalsIgnoreCase("--server")
313
                 || previousArgs.get(0).equalsIgnoreCase("--server")
314
                 || previousArgs.get(0).equalsIgnoreCase("--channel"))) {
314
                 || previousArgs.get(0).equalsIgnoreCase("--channel"))) {
315
-            res.addAll(context.getWindow().getContainer().getConfigManager()
315
+            res.addAll(context.getWindow().getConfigManager()
316
                     .getOptions(previousArgs.get(1)).keySet());
316
                     .getOptions(previousArgs.get(1)).keySet());
317
             res.excludeAll();
317
             res.excludeAll();
318
         }
318
         }

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/AllChannels.java Näytä tiedosto

55
 
55
 
56
         for (String channel : server.getChannels()) {
56
         for (String channel : server.getChannels()) {
57
             server.getChannel(channel).getCommandParser()
57
             server.getChannel(channel).getCommandParser()
58
-                    .parseCommand(server.getChannel(channel), context.getSource(), command);
58
+                    .parseCommand(server.getChannel(channel), command);
59
         }
59
         }
60
     }
60
     }
61
 
61
 

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java Näytä tiedosto

118
     @Override
118
     @Override
119
     public AdditionalTabTargets getSuggestions(final int arg,
119
     public AdditionalTabTargets getSuggestions(final int arg,
120
             final IntelligentCommandContext context) {
120
             final IntelligentCommandContext context) {
121
-        final FrameContainer source = context.getWindow().getContainer();
121
+        final FrameContainer source = context.getWindow();
122
         final Server server = source.getServer();
122
         final Server server = source.getServer();
123
         final List<String> results = checkSource(source, true, true);
123
         final List<String> results = checkSource(source, true, true);
124
 
124
 

+ 4
- 3
src/com/dmdirc/commandparser/commands/server/Message.java Näytä tiedosto

25
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.Server;
26
 import com.dmdirc.Server;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
28
+import com.dmdirc.WritableFrameContainer;
28
 import com.dmdirc.commandparser.CommandArguments;
29
 import com.dmdirc.commandparser.CommandArguments;
29
 import com.dmdirc.commandparser.CommandInfo;
30
 import com.dmdirc.commandparser.CommandInfo;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.CommandType;
37
 import com.dmdirc.parser.interfaces.Parser;
38
 import com.dmdirc.parser.interfaces.Parser;
38
 import com.dmdirc.ui.input.AdditionalTabTargets;
39
 import com.dmdirc.ui.input.AdditionalTabTargets;
39
 import com.dmdirc.ui.input.TabCompletionType;
40
 import com.dmdirc.ui.input.TabCompletionType;
40
-import com.dmdirc.ui.interfaces.InputWindow;
41
 
41
 
42
 /**
42
 /**
43
  * Allows the user to send privmsgs.
43
  * Allows the user to send privmsgs.
103
 
103
 
104
     /** {@inheritDoc} */
104
     /** {@inheritDoc} */
105
     @Override
105
     @Override
106
-    public int getLineCount(final InputWindow origin, final CommandArguments arguments) {
106
+    public int getLineCount(final WritableFrameContainer origin,
107
+            final CommandArguments arguments) {
107
         if (arguments.getArguments().length >= 2) {
108
         if (arguments.getArguments().length >= 2) {
108
             final String target = arguments.getArguments()[0];
109
             final String target = arguments.getArguments()[0];
109
-            return origin.getContainer().getServer().getNumLines("PRIVMSG "
110
+            return origin.getServer().getNumLines("PRIVMSG "
110
                     + target + " :" + arguments.getArgumentsAsString(1));
111
                     + target + " :" + arguments.getArgumentsAsString(1));
111
         } else {
112
         } else {
112
             return 1;
113
             return 1;

+ 7
- 4
src/com/dmdirc/commandparser/commands/server/OpenQuery.java Näytä tiedosto

26
 import com.dmdirc.Query;
26
 import com.dmdirc.Query;
27
 import com.dmdirc.Server;
27
 import com.dmdirc.Server;
28
 import com.dmdirc.commandparser.BaseCommandInfo;
28
 import com.dmdirc.commandparser.BaseCommandInfo;
29
+import com.dmdirc.WritableFrameContainer;
29
 import com.dmdirc.commandparser.CommandArguments;
30
 import com.dmdirc.commandparser.CommandArguments;
30
 import com.dmdirc.commandparser.CommandInfo;
31
 import com.dmdirc.commandparser.CommandInfo;
31
 import com.dmdirc.commandparser.CommandManager;
32
 import com.dmdirc.commandparser.CommandManager;
37
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
38
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
38
 import com.dmdirc.ui.input.AdditionalTabTargets;
39
 import com.dmdirc.ui.input.AdditionalTabTargets;
39
 import com.dmdirc.ui.input.TabCompletionType;
40
 import com.dmdirc.ui.input.TabCompletionType;
40
-import com.dmdirc.ui.interfaces.InputWindow;
41
 import com.dmdirc.ui.messages.Styliser;
41
 import com.dmdirc.ui.messages.Styliser;
42
 
42
 
43
 /**
43
 /**
79
         }
79
         }
80
 
80
 
81
         if (!args.isSilent()) {
81
         if (!args.isSilent()) {
82
-            context.getSource().getController().requestWindowFocus(query);
82
+            //TODO how are we going to handle focusing an existing query?
83
+            //context.getSource().getController().requestWindowFocus(query);
84
+            return; //NOPMD
83
         }
85
         }
84
     }
86
     }
85
 
87
 
99
 
101
 
100
     /** {@inheritDoc} */
102
     /** {@inheritDoc} */
101
     @Override
103
     @Override
102
-    public int getLineCount(final InputWindow origin, final CommandArguments arguments) {
104
+    public int getLineCount(final WritableFrameContainer origin,
105
+            final CommandArguments arguments) {
103
         if (arguments.getArguments().length >= 2) {
106
         if (arguments.getArguments().length >= 2) {
104
             final String target = arguments.getArguments()[0];
107
             final String target = arguments.getArguments()[0];
105
-            return origin.getContainer().getServer().getNumLines("PRIVMSG "
108
+            return origin.getServer().getNumLines("PRIVMSG "
106
                     + target + " :" + arguments.getArgumentsAsString(1));
109
                     + target + " :" + arguments.getArgumentsAsString(1));
107
         } else {
110
         } else {
108
             return 1;
111
             return 1;

+ 0
- 65
src/com/dmdirc/commandparser/commands/server/ServerSettings.java Näytä tiedosto

1
-/*
2
- * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes,
3
- * Simon Mott
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6
- * of this software and associated documentation files (the "Software"), to deal
7
- * in the Software without restriction, including without limitation the rights
8
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the Software is
10
- * furnished to do so, subject to the following conditions:
11
- *
12
- * The above copyright notice and this permission notice shall be included in
13
- * all copies or substantial portions of the Software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- * SOFTWARE.
22
- */
23
-
24
-package com.dmdirc.commandparser.commands.server;
25
-
26
-import com.dmdirc.FrameContainer;
27
-import com.dmdirc.commandparser.BaseCommandInfo;
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.CommandOptions;
33
-import com.dmdirc.commandparser.commands.IntelligentCommand;
34
-import com.dmdirc.commandparser.commands.context.CommandContext;
35
-import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36
-import com.dmdirc.ui.input.AdditionalTabTargets;
37
-
38
-/**
39
- * Opens the server settings window for the server.
40
- *
41
- * @since 0.6.4
42
- */
43
-@CommandOptions(allowOffline=false)
44
-public class ServerSettings extends Command implements IntelligentCommand {
45
-
46
-    /** A command info object for this command. */
47
-    public static final CommandInfo INFO = new BaseCommandInfo("serversettings",
48
-            "serversettings - opens the server settings window",
49
-            CommandType.TYPE_SERVER);
50
-
51
-    /** {@inheritDoc} */
52
-    @Override
53
-    public void execute(final FrameContainer origin,
54
-            final CommandArguments args, final CommandContext context) {
55
-        context.getSource().getController().showServerSettingsDialog(
56
-                ((ServerCommandContext) context).getServer());
57
-    }
58
-
59
-    /** {@inheritDoc} */
60
-    @Override
61
-    public AdditionalTabTargets getSuggestions(final int arg,
62
-            final IntelligentCommandContext context) {
63
-        return new AdditionalTabTargets().excludeAll();
64
-    }
65
-}

+ 5
- 5
src/com/dmdirc/commandparser/parsers/ChannelCommandParser.java Näytä tiedosto

30
 import com.dmdirc.commandparser.CommandType;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.commands.Command;
31
 import com.dmdirc.commandparser.commands.Command;
32
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
32
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
33
-import com.dmdirc.ui.interfaces.Window;
34
 
33
 
35
 /**
34
 /**
36
  * A command parser that is tailored for use in a channel environment.
35
  * A command parser that is tailored for use in a channel environment.
78
     /** {@inheritDoc} */
77
     /** {@inheritDoc} */
79
     @Override
78
     @Override
80
     protected void executeCommand(final FrameContainer origin,
79
     protected void executeCommand(final FrameContainer origin,
81
-            final Window window, final CommandInfo commandInfo,
82
-            final Command command, final CommandArguments args) {
80
+            final CommandInfo commandInfo, final Command command,
81
+            final CommandArguments args) {
83
         if (commandInfo.getType() == CommandType.TYPE_CHANNEL) {
82
         if (commandInfo.getType() == CommandType.TYPE_CHANNEL) {
84
-            command.execute(origin, args, new ChannelCommandContext(window, commandInfo, channel));
83
+            command.execute(origin, args, new ChannelCommandContext(origin,
84
+                    commandInfo, channel));
85
         } else {
85
         } else {
86
-            super.executeCommand(origin, window, commandInfo, command, args);
86
+            super.executeCommand(origin, commandInfo, command, args);
87
         }
87
         }
88
     }
88
     }
89
 
89
 

+ 7
- 6
src/com/dmdirc/commandparser/parsers/ChatCommandParser.java Näytä tiedosto

30
 import com.dmdirc.commandparser.CommandType;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.commands.Command;
31
 import com.dmdirc.commandparser.commands.Command;
32
 import com.dmdirc.commandparser.commands.context.ChatCommandContext;
32
 import com.dmdirc.commandparser.commands.context.ChatCommandContext;
33
-import com.dmdirc.ui.interfaces.Window;
34
 
33
 
35
 /**
34
 /**
36
  * A command parser which implements common functionality for chat windows
35
  * A command parser which implements common functionality for chat windows
71
     /** {@inheritDoc} */
70
     /** {@inheritDoc} */
72
     @Override
71
     @Override
73
     protected void executeCommand(final FrameContainer origin,
72
     protected void executeCommand(final FrameContainer origin,
74
-            final Window window, final CommandInfo commandInfo,
75
-            final Command command, final CommandArguments args) {
73
+            final CommandInfo commandInfo, final Command command,
74
+            final CommandArguments args) {
76
         if (commandInfo.getType() == CommandType.TYPE_CHAT) {
75
         if (commandInfo.getType() == CommandType.TYPE_CHAT) {
77
-            command.execute(origin, args, new ChatCommandContext(window, commandInfo, owner));
76
+            command.execute(origin, args, new ChatCommandContext(origin,
77
+                    commandInfo, owner));
78
         } else {
78
         } else {
79
-            super.executeCommand(origin, window, commandInfo, command, args);
79
+            super.executeCommand(origin, commandInfo, command, args);
80
         }
80
         }
81
     }
81
     }
82
 
82
 
83
     /** {@inheritDoc} */
83
     /** {@inheritDoc} */
84
     @Override
84
     @Override
85
-    protected void handleNonCommand(final FrameContainer origin, final String line) {
85
+    protected void handleNonCommand(final FrameContainer origin,
86
+            final String line) {
86
         owner.sendLine(line);
87
         owner.sendLine(line);
87
     }
88
     }
88
 
89
 

+ 9
- 10
src/com/dmdirc/commandparser/parsers/CommandParser.java Näytä tiedosto

36
 import com.dmdirc.commandparser.commands.ExternalCommand;
36
 import com.dmdirc.commandparser.commands.ExternalCommand;
37
 import com.dmdirc.commandparser.commands.PreviousCommand;
37
 import com.dmdirc.commandparser.commands.PreviousCommand;
38
 import com.dmdirc.config.IdentityManager;
38
 import com.dmdirc.config.IdentityManager;
39
-import com.dmdirc.ui.interfaces.Window;
40
 import com.dmdirc.util.RollingList;
39
 import com.dmdirc.util.RollingList;
41
 
40
 
42
 import java.io.Serializable;
41
 import java.io.Serializable;
132
      * @since 0.6.4
131
      * @since 0.6.4
133
      */
132
      */
134
     public final void parseCommand(final FrameContainer origin,
133
     public final void parseCommand(final FrameContainer origin,
135
-            final Window window, final String line, final boolean parseChannel) {
134
+            final String line, final boolean parseChannel) {
136
         final CommandArguments args = new CommandArguments(line);
135
         final CommandArguments args = new CommandArguments(line);
137
 
136
 
138
         if (args.isCommand()) {
137
         if (args.isCommand()) {
139
-            if (handleChannelCommand(origin, window, args, parseChannel)) {
138
+            if (handleChannelCommand(origin, args, parseChannel)) {
140
                 return;
139
                 return;
141
             }
140
             }
142
 
141
 
143
             if (commands.containsKey(args.getCommandName().toLowerCase())) {
142
             if (commands.containsKey(args.getCommandName().toLowerCase())) {
144
                 final CommandInfoPair pair = commands.get(args.getCommandName().toLowerCase());
143
                 final CommandInfoPair pair = commands.get(args.getCommandName().toLowerCase());
145
                 addHistory(args.getStrippedLine());
144
                 addHistory(args.getStrippedLine());
146
-                executeCommand(origin, window, pair.getCommandInfo(), pair.getCommand(), args);
145
+                executeCommand(origin, pair.getCommandInfo(), pair.getCommand(), args);
147
             } else {
146
             } else {
148
                 handleInvalidCommand(origin, args);
147
                 handleInvalidCommand(origin, args);
149
             }
148
             }
167
      * @return True iff the command was handled, false otherwise
166
      * @return True iff the command was handled, false otherwise
168
      */
167
      */
169
     protected boolean handleChannelCommand(final FrameContainer origin,
168
     protected boolean handleChannelCommand(final FrameContainer origin,
170
-            final Window window, final CommandArguments args, final boolean parseChannel) {
169
+            final CommandArguments args, final boolean parseChannel) {
171
         final boolean silent = args.isSilent();
170
         final boolean silent = args.isSilent();
172
         final String command = args.getCommandName();
171
         final String command = args.getCommandName();
173
         final String[] cargs = args.getArguments();
172
         final String[] cargs = args.getArguments();
194
 
193
 
195
                 if (server.hasChannel(channel)) {
194
                 if (server.hasChannel(channel)) {
196
                     server.getChannel(channel).getCommandParser()
195
                     server.getChannel(channel).getCommandParser()
197
-                            .parseCommand(origin, window, commandManager.getCommandChar()
196
+                            .parseCommand(origin, commandManager.getCommandChar()
198
                             + args.getCommandName() + " " + args.getWordsAsString(2), false);
197
                             + args.getCommandName() + " " + args.getWordsAsString(2), false);
199
                 } else {
198
                 } else {
200
                     final Map.Entry<CommandInfo, Command> actCommand
199
                     final Map.Entry<CommandInfo, Command> actCommand
258
      * @since 0.6.4
257
      * @since 0.6.4
259
      */
258
      */
260
     public final void parseCommand(final FrameContainer origin,
259
     public final void parseCommand(final FrameContainer origin,
261
-            final Window window, final String line) {
262
-        parseCommand(origin, window, line, true);
260
+            final String line) {
261
+        parseCommand(origin, line, true);
263
     }
262
     }
264
 
263
 
265
     /**
264
     /**
283
      * @since 0.6.4
282
      * @since 0.6.4
284
      */
283
      */
285
     protected abstract void executeCommand(final FrameContainer origin,
284
     protected abstract void executeCommand(final FrameContainer origin,
286
-            final Window window, final CommandInfo commandInfo,
287
-            final Command command, final CommandArguments args);
285
+            final CommandInfo commandInfo, final Command command,
286
+            final CommandArguments args);
288
 
287
 
289
     /**
288
     /**
290
      * Called when the user attempted to issue a command (i.e., used the command
289
      * Called when the user attempted to issue a command (i.e., used the command

+ 3
- 4
src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java Näytä tiedosto

30
 import com.dmdirc.commandparser.commands.context.CommandContext;
30
 import com.dmdirc.commandparser.commands.context.CommandContext;
31
 import com.dmdirc.logger.ErrorLevel;
31
 import com.dmdirc.logger.ErrorLevel;
32
 import com.dmdirc.logger.Logger;
32
 import com.dmdirc.logger.Logger;
33
-import com.dmdirc.ui.interfaces.Window;
34
 
33
 
35
 /**
34
 /**
36
  * The command parser used for global commands.
35
  * The command parser used for global commands.
76
     /** {@inheritDoc} */
75
     /** {@inheritDoc} */
77
     @Override
76
     @Override
78
     protected void executeCommand(final FrameContainer origin,
77
     protected void executeCommand(final FrameContainer origin,
79
-            final Window window, final CommandInfo commandInfo,
80
-            final Command command, final CommandArguments args) {
81
-        command.execute(origin, args, new CommandContext(window, commandInfo));
78
+            final CommandInfo commandInfo, final Command command,
79
+            final CommandArguments args) {
80
+        command.execute(origin, args, new CommandContext(origin, commandInfo));
82
     }
81
     }
83
 
82
 
84
     /**
83
     /**

+ 5
- 5
src/com/dmdirc/commandparser/parsers/QueryCommandParser.java Näytä tiedosto

30
 import com.dmdirc.commandparser.CommandType;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.commands.Command;
31
 import com.dmdirc.commandparser.commands.Command;
32
 import com.dmdirc.commandparser.commands.context.QueryCommandContext;
32
 import com.dmdirc.commandparser.commands.context.QueryCommandContext;
33
-import com.dmdirc.ui.interfaces.Window;
34
 
33
 
35
 /**
34
 /**
36
  * A command parser that is tailored for use in a query environment. Handles
35
  * A command parser that is tailored for use in a query environment. Handles
79
     /** {@inheritDoc} */
78
     /** {@inheritDoc} */
80
     @Override
79
     @Override
81
     protected void executeCommand(final FrameContainer origin,
80
     protected void executeCommand(final FrameContainer origin,
82
-            final Window window, final CommandInfo commandInfo,
83
-            final Command command, final CommandArguments args) {
81
+            final CommandInfo commandInfo, final Command command,
82
+            final CommandArguments args) {
84
         if (commandInfo.getType() == CommandType.TYPE_QUERY) {
83
         if (commandInfo.getType() == CommandType.TYPE_QUERY) {
85
-            command.execute(origin, args, new QueryCommandContext(window, commandInfo, query));
84
+            command.execute(origin, args, new QueryCommandContext(origin,
85
+                    commandInfo, query));
86
         } else {
86
         } else {
87
-            super.executeCommand(origin, window, commandInfo, command, args);
87
+            super.executeCommand(origin, commandInfo, command, args);
88
         }
88
         }
89
     }
89
     }
90
 
90
 

+ 4
- 5
src/com/dmdirc/commandparser/parsers/ServerCommandParser.java Näytä tiedosto

30
 import com.dmdirc.commandparser.CommandType;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.commands.Command;
31
 import com.dmdirc.commandparser.commands.Command;
32
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
32
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
33
-import com.dmdirc.ui.interfaces.Window;
34
 
33
 
35
 /**
34
 /**
36
  * A command parser used in the context of a server.
35
  * A command parser used in the context of a server.
68
     /** {@inheritDoc} */
67
     /** {@inheritDoc} */
69
     @Override
68
     @Override
70
     protected void executeCommand(final FrameContainer origin,
69
     protected void executeCommand(final FrameContainer origin,
71
-            final Window window, final CommandInfo commandInfo,
72
-            final Command command, final CommandArguments args) {
70
+            final CommandInfo commandInfo, final Command command,
71
+            final CommandArguments args) {
73
         if (commandInfo.getType() == CommandType.TYPE_SERVER) {
72
         if (commandInfo.getType() == CommandType.TYPE_SERVER) {
74
             if (hasCommandOptions(command) && !getCommandOptions(command).allowOffline()
73
             if (hasCommandOptions(command) && !getCommandOptions(command).allowOffline()
75
                     && (server == null || (server.getState() != ServerState.CONNECTED
74
                     && (server == null || (server.getState() != ServerState.CONNECTED
79
                     origin.addLine("commandError", "You must be connected to use this command");
78
                     origin.addLine("commandError", "You must be connected to use this command");
80
                 }
79
                 }
81
             } else {
80
             } else {
82
-                command.execute(origin, args, new ServerCommandContext(window, commandInfo, server));
81
+                command.execute(origin, args, new ServerCommandContext(origin, commandInfo, server));
83
             }
82
             }
84
         } else {
83
         } else {
85
-            super.executeCommand(origin, window, commandInfo, command, args);
84
+            super.executeCommand(origin, commandInfo, command, args);
86
         }
85
         }
87
     }
86
     }
88
 
87
 

+ 13
- 13
src/com/dmdirc/ui/input/InputHandler.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.ui.input;
23
 package com.dmdirc.ui.input;
24
 
24
 
25
+import com.dmdirc.WritableFrameContainer;
25
 import com.dmdirc.actions.ActionManager;
26
 import com.dmdirc.actions.ActionManager;
26
 import com.dmdirc.actions.CoreActionType;
27
 import com.dmdirc.actions.CoreActionType;
27
 import com.dmdirc.commandparser.CommandArguments;
28
 import com.dmdirc.commandparser.CommandArguments;
37
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
38
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
38
 import com.dmdirc.ui.interfaces.InputField;
39
 import com.dmdirc.ui.interfaces.InputField;
39
 import com.dmdirc.ui.interfaces.InputValidationListener;
40
 import com.dmdirc.ui.interfaces.InputValidationListener;
40
-import com.dmdirc.ui.interfaces.InputWindow;
41
 import com.dmdirc.ui.messages.Styliser;
41
 import com.dmdirc.ui.messages.Styliser;
42
 import com.dmdirc.util.ListenerList;
42
 import com.dmdirc.util.ListenerList;
43
 import com.dmdirc.util.RollingList;
43
 import com.dmdirc.util.RollingList;
93
     /** The CommandParser to use for our input. */
93
     /** The CommandParser to use for our input. */
94
     protected final CommandParser commandParser;
94
     protected final CommandParser commandParser;
95
     /** The frame that we belong to. */
95
     /** The frame that we belong to. */
96
-    protected final InputWindow parentWindow;
96
+    protected final WritableFrameContainer parentWindow;
97
     /** The tab completion style. */
97
     /** The tab completion style. */
98
     protected TabCompletionStyle style;
98
     protected TabCompletionStyle style;
99
     /** Our listener list. */
99
     /** Our listener list. */
109
      */
109
      */
110
     public InputHandler(final InputField thisTarget,
110
     public InputHandler(final InputField thisTarget,
111
             final CommandParser thisCommandParser,
111
             final CommandParser thisCommandParser,
112
-            final InputWindow thisParentWindow) {
112
+            final WritableFrameContainer thisParentWindow) {
113
 
113
 
114
-        buffer = new RollingList<String>(thisParentWindow.getContainer()
115
-                .getConfigManager().getOptionInt("ui", "inputbuffersize"), "");
114
+        buffer = new RollingList<String>(thisParentWindow.getConfigManager()
115
+                .getOptionInt("ui", "inputbuffersize"), "");
116
 
116
 
117
         this.commandParser = thisCommandParser;
117
         this.commandParser = thisCommandParser;
118
         this.parentWindow = thisParentWindow;
118
         this.parentWindow = thisParentWindow;
120
 
120
 
121
         setStyle();
121
         setStyle();
122
 
122
 
123
-        parentWindow.getContainer().getConfigManager().addChangeListener(
123
+        parentWindow.getConfigManager().addChangeListener(
124
                 "tabcompletion", "style", this);
124
                 "tabcompletion", "style", this);
125
 
125
 
126
         addUpHandler();
126
         addUpHandler();
177
      */
177
      */
178
     private void setStyle() {
178
     private void setStyle() {
179
         style = (TabCompletionStyle) PluginManager.getPluginManager()
179
         style = (TabCompletionStyle) PluginManager.getPluginManager()
180
-                .getServiceProvider("tabcompletion", parentWindow.getContainer()
180
+                .getServiceProvider("tabcompletion", parentWindow
181
                 .getConfigManager().getOption("tabcompletion", "style"))
181
                 .getConfigManager().getOption("tabcompletion", "style"))
182
-                .getExportedService("getCompletionStyle").execute(tabCompleter, parentWindow);
182
+                .getExportedService("getCompletionStyle").execute(tabCompleter,
183
+                parentWindow);
183
     }
184
     }
184
 
185
 
185
     /**
186
     /**
240
                 fireLineWrap(count);
241
                 fireLineWrap(count);
241
             }
242
             }
242
         } else {
243
         } else {
243
-            final int lines = parentWindow.getContainer().getNumLines(text);
244
+            final int lines = parentWindow.getNumLines(text);
244
                 fireLineWrap(lines);
245
                 fireLineWrap(lines);
245
         }
246
         }
246
     }
247
     }
330
 
331
 
331
             case KeyEvent.VK_ENTER:
332
             case KeyEvent.VK_ENTER:
332
                 if ((flags & HANDLE_RETURN) != 0 && !line.isEmpty()) {
333
                 if ((flags & HANDLE_RETURN) != 0 && !line.isEmpty()) {
333
-                    commandParser.parseCommandCtrl(parentWindow.getContainer(), line);
334
+                    commandParser.parseCommandCtrl(parentWindow, line);
334
                     addToBuffer(line);
335
                     addToBuffer(line);
335
                 }
336
                 }
336
                 break;
337
                 break;
486
 
487
 
487
             ActionManager.getActionManager().triggerEvent(
488
             ActionManager.getActionManager().triggerEvent(
488
                     CoreActionType.CLIENT_USER_INPUT, null,
489
                     CoreActionType.CLIENT_USER_INPUT, null,
489
-                    parentWindow.getContainer(), thisBuffer);
490
+                    parentWindow, thisBuffer);
490
 
491
 
491
             addToBuffer(thisBuffer.toString());
492
             addToBuffer(thisBuffer.toString());
492
 
493
 
493
-            commandParser.parseCommand(parentWindow.getContainer(),
494
-                    parentWindow, thisBuffer.toString());
494
+            commandParser.parseCommand(parentWindow, thisBuffer.toString());
495
         }
495
         }
496
         fireLineWrap(0);
496
         fireLineWrap(0);
497
         fireCommandPassed();
497
         fireCommandPassed();

+ 6
- 4
src/com/dmdirc/ui/input/TabCompleter.java Näytä tiedosto

22
 
22
 
23
 package com.dmdirc.ui.input;
23
 package com.dmdirc.ui.input;
24
 
24
 
25
+import com.dmdirc.WritableFrameContainer;
25
 import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandInfo;
27
 import com.dmdirc.commandparser.CommandInfo;
27
 import com.dmdirc.commandparser.CommandManager;
28
 import com.dmdirc.commandparser.CommandManager;
30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
 import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
32
 import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
32
 import com.dmdirc.config.IdentityManager;
33
 import com.dmdirc.config.IdentityManager;
33
-import com.dmdirc.ui.interfaces.InputWindow;
34
 import com.dmdirc.util.MapList;
34
 import com.dmdirc.util.MapList;
35
 
35
 
36
 import java.util.Arrays;
36
 import java.util.Arrays;
234
      * @return Additional tab targets for the text, or null if none are available
234
      * @return Additional tab targets for the text, or null if none are available
235
      * @since 0.6.4
235
      * @since 0.6.4
236
      */
236
      */
237
-    private static AdditionalTabTargets getIntelligentResults(final InputWindow window,
237
+    private static AdditionalTabTargets getIntelligentResults(
238
+            final WritableFrameContainer window,
238
             final CommandArguments args, final String partial) {
239
             final CommandArguments args, final String partial) {
239
         if (!args.isCommand()) {
240
         if (!args.isCommand()) {
240
             return null;
241
             return null;
274
      * @return Additional tab targets for the text, or null if none are available
275
      * @return Additional tab targets for the text, or null if none are available
275
      * @since 0.6.4
276
      * @since 0.6.4
276
      */
277
      */
277
-    public static AdditionalTabTargets getIntelligentResults(final InputWindow window,
278
-            final String text, final String partial) {
278
+    public static AdditionalTabTargets getIntelligentResults(
279
+            final WritableFrameContainer window, final String text,
280
+            final String partial) {
279
         return getIntelligentResults(window, new CommandArguments(text), partial);
281
         return getIntelligentResults(window, new CommandArguments(text), partial);
280
     }
282
     }
281
 }
283
 }

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

41
     @Test
41
     @Test
42
     public void testBasicCommand() {
42
     public void testBasicCommand() {
43
         final TestCommandParser tcp = new TestCommandParser();
43
         final TestCommandParser tcp = new TestCommandParser();
44
-        tcp.parseCommand(null, null, "/echo this is a test");
44
+        tcp.parseCommand(null, "/echo this is a test");
45
 
45
 
46
         assertNull(tcp.nonCommandLine);
46
         assertNull(tcp.nonCommandLine);
47
         assertNull(tcp.invalidCommand);
47
         assertNull(tcp.invalidCommand);
53
     @Test
53
     @Test
54
     public void testBasicNoArgs() {
54
     public void testBasicNoArgs() {
55
         final TestCommandParser tcp = new TestCommandParser();
55
         final TestCommandParser tcp = new TestCommandParser();
56
-        tcp.parseCommand(null, null, "/echo");
56
+        tcp.parseCommand(null, "/echo");
57
 
57
 
58
         assertNull(tcp.nonCommandLine);
58
         assertNull(tcp.nonCommandLine);
59
         assertNull(tcp.invalidCommand);
59
         assertNull(tcp.invalidCommand);
65
     @Test
65
     @Test
66
     public void testSilentNoArgs() {
66
     public void testSilentNoArgs() {
67
         final TestCommandParser tcp = new TestCommandParser();
67
         final TestCommandParser tcp = new TestCommandParser();
68
-        tcp.parseCommand(null, null, "/.echo");
68
+        tcp.parseCommand(null, "/.echo");
69
 
69
 
70
         assertNull(tcp.nonCommandLine);
70
         assertNull(tcp.nonCommandLine);
71
         assertNull(tcp.invalidCommand);
71
         assertNull(tcp.invalidCommand);
77
     @Test
77
     @Test
78
     public void testSilentCommand() {
78
     public void testSilentCommand() {
79
         final TestCommandParser tcp = new TestCommandParser();
79
         final TestCommandParser tcp = new TestCommandParser();
80
-        tcp.parseCommand(null, null, "/.echo this is a test");
80
+        tcp.parseCommand(null, "/.echo this is a test");
81
 
81
 
82
         assertNull(tcp.nonCommandLine);
82
         assertNull(tcp.nonCommandLine);
83
         assertNull(tcp.invalidCommand);
83
         assertNull(tcp.invalidCommand);
89
     @Test
89
     @Test
90
     public void testNonExistantCommand() {
90
     public void testNonExistantCommand() {
91
         final TestCommandParser tcp = new TestCommandParser();
91
         final TestCommandParser tcp = new TestCommandParser();
92
-        tcp.parseCommand(null, null, "/foobar moo bar");
92
+        tcp.parseCommand(null, "/foobar moo bar");
93
 
93
 
94
         assertNull(tcp.nonCommandLine);
94
         assertNull(tcp.nonCommandLine);
95
         assertEquals("foobar", tcp.invalidCommand);
95
         assertEquals("foobar", tcp.invalidCommand);
101
     @Test
101
     @Test
102
     public void testEmptyCommand() {
102
     public void testEmptyCommand() {
103
         final TestCommandParser tcp = new TestCommandParser();
103
         final TestCommandParser tcp = new TestCommandParser();
104
-        tcp.parseCommand(null, null, "/ moo bar");
104
+        tcp.parseCommand(null, "/ moo bar");
105
 
105
 
106
         assertNull(tcp.nonCommandLine);
106
         assertNull(tcp.nonCommandLine);
107
         assertEquals("", tcp.invalidCommand);
107
         assertEquals("", tcp.invalidCommand);
109
         assertNull(tcp.executedCommand);
109
         assertNull(tcp.executedCommand);
110
         assertFalse(tcp.wasSilent);
110
         assertFalse(tcp.wasSilent);
111
     }
111
     }
112
-    
112
+
113
     @Test
113
     @Test
114
     public void testEmptySilentCommand() {
114
     public void testEmptySilentCommand() {
115
         final TestCommandParser tcp = new TestCommandParser();
115
         final TestCommandParser tcp = new TestCommandParser();
116
-        tcp.parseCommand(null, null, "/. moo bar");
116
+        tcp.parseCommand(null, "/. moo bar");
117
 
117
 
118
         assertNull(tcp.nonCommandLine);
118
         assertNull(tcp.nonCommandLine);
119
         assertEquals("", tcp.invalidCommand);
119
         assertEquals("", tcp.invalidCommand);
121
         assertNull(tcp.executedCommand);
121
         assertNull(tcp.executedCommand);
122
         assertFalse(tcp.wasSilent);
122
         assertFalse(tcp.wasSilent);
123
     }
123
     }
124
-    
124
+
125
     @Test
125
     @Test
126
     public void testNonCommand() {
126
     public void testNonCommand() {
127
         final TestCommandParser tcp = new TestCommandParser();
127
         final TestCommandParser tcp = new TestCommandParser();
128
-        tcp.parseCommand(null, null, "Foobar baz");
128
+        tcp.parseCommand(null, "Foobar baz");
129
 
129
 
130
         assertNotNull(tcp.nonCommandLine);
130
         assertNotNull(tcp.nonCommandLine);
131
         assertEquals("Foobar baz", tcp.nonCommandLine);
131
         assertEquals("Foobar baz", tcp.nonCommandLine);
133
         assertNull(tcp.executedCommand);
133
         assertNull(tcp.executedCommand);
134
         assertFalse(tcp.wasSilent);
134
         assertFalse(tcp.wasSilent);
135
     }
135
     }
136
-    
136
+
137
     @Test
137
     @Test
138
     public void testCommandHistory() {
138
     public void testCommandHistory() {
139
         final TestCommandParser tcp = new TestCommandParser();
139
         final TestCommandParser tcp = new TestCommandParser();
140
-        tcp.parseCommand(null, null, "/echo this is a test");
140
+        tcp.parseCommand(null, "/echo this is a test");
141
 
141
 
142
         final long time1 = tcp.getCommandTime("echo this is a test");
142
         final long time1 = tcp.getCommandTime("echo this is a test");
143
         assertTrue(time1 > 0);
143
         assertTrue(time1 > 0);
144
-        
145
-        tcp.parseCommand(null, null, "/echo this is a test");
144
+
145
+        tcp.parseCommand( null, "/echo this is a test");
146
         final long time2 = tcp.getCommandTime("echo this is a test");
146
         final long time2 = tcp.getCommandTime("echo this is a test");
147
         assertTrue(time2 > 0);
147
         assertTrue(time2 > 0);
148
         assertTrue(time2 >= time1);
148
         assertTrue(time2 >= time1);
149
-        
149
+
150
         assertEquals(0L, tcp.getCommandTime("echo"));
150
         assertEquals(0L, tcp.getCommandTime("echo"));
151
-    }    
151
+    }
152
 
152
 
153
 }
153
 }

+ 1
- 2
test/com/dmdirc/harness/TestCommandParser.java Näytä tiedosto

29
 import com.dmdirc.commandparser.CommandManager;
29
 import com.dmdirc.commandparser.CommandManager;
30
 import com.dmdirc.commandparser.CommandType;
30
 import com.dmdirc.commandparser.CommandType;
31
 import com.dmdirc.commandparser.commands.Command;
31
 import com.dmdirc.commandparser.commands.Command;
32
-import com.dmdirc.ui.interfaces.Window;
33
 
32
 
34
 public class TestCommandParser extends CommandParser {
33
 public class TestCommandParser extends CommandParser {
35
     private static final long serialVersionUID = 7073002401375438532L;
34
     private static final long serialVersionUID = 7073002401375438532L;
50
     }
49
     }
51
 
50
 
52
     @Override
51
     @Override
53
-    protected void executeCommand(FrameContainer origin, Window window,
52
+    protected void executeCommand(FrameContainer origin,
54
             CommandInfo commandInfo, Command command, CommandArguments args) {
53
             CommandInfo commandInfo, Command command, CommandArguments args) {
55
         executedCommand = command;
54
         executedCommand = command;
56
         wasSilent = args.isSilent();
55
         wasSilent = args.isSilent();

Loading…
Peruuta
Tallenna