소스 검색

Added some initial support for silent commands

git-svn-id: http://svn.dmdirc.com/trunk@1267 00569f92-eb28-0410-84fd-f71c24880f
tags/0.4
Chris Smith 17 년 전
부모
커밋
afdb7f3822

+ 3
- 8
src/uk/org/ownage/dmdirc/commandparser/ChannelCommandParser.java 파일 보기

@@ -60,20 +60,15 @@ public final class ChannelCommandParser extends CommandParser {
60 60
         CommandManager.loadChannelCommands(this);
61 61
     }
62 62
     
63
-    /**
64
-     * Executes the specified command with the given arguments.
65
-     * @param origin The window in which the command was typed
66
-     * @param command The command to be executed
67
-     * @param args The arguments to the command
68
-     */
63
+    /** {@inheritDoc} */
69 64
     protected void executeCommand(final CommandWindow origin,
70
-            final Command command, final String... args) {
65
+            final boolean isSilent, final Command command, final String... args) {
71 66
         if (command instanceof ChannelCommand) {
72 67
             ((ChannelCommand) command).execute(origin, server, channel, args);
73 68
         } else if (command instanceof ServerCommand) {
74 69
             ((ServerCommand) command).execute(origin, server, args);
75 70
         } else {
76
-            ((GlobalCommand) command).execute(origin, args);
71
+            ((GlobalCommand) command).execute(origin, isSilent, args);
77 72
         }
78 73
     }
79 74
     

+ 14
- 0
src/uk/org/ownage/dmdirc/commandparser/Command.java 파일 보기

@@ -99,6 +99,20 @@ public abstract class Command implements Comparable<Command> {
99 99
         return implodeArgs(0, args);
100 100
     } 
101 101
     
102
+    /**
103
+     * Sends a line, if appropriate, to the specified target.
104
+     * @param target The command window to send the line to
105
+     * @param isSilent Whether this command is being silenced or not
106
+     * @param type The type of message to send
107
+     * @param args The arguments of the message
108
+     */
109
+    protected final void sendLine(final CommandWindow target,
110
+            final boolean isSilent, final String type, final Object ... args) {
111
+        if (!isSilent && target != null) {
112
+            target.addLine(type, args);
113
+        }
114
+    }
115
+    
102 116
     /** {@inheritDoc} */
103 117
     public int compareTo(final Command o) {
104 118
         return getSignature().compareTo(o.getSignature());

+ 4
- 3
src/uk/org/ownage/dmdirc/commandparser/CommandParser.java 파일 보기

@@ -116,9 +116,9 @@ public abstract class CommandParser {
116 116
             // have error handlers if there are too few arguments (e.g., msg/0 and
117 117
             // msg/1 would return errors, so msg only gets called with 2+ args).
118 118
             if (commands.containsKey(signature.toLowerCase())) {
119
-                executeCommand(origin, commands.get(signature.toLowerCase()), comargs);
119
+                executeCommand(origin, false, commands.get(signature.toLowerCase()), comargs);
120 120
             } else if (commands.containsKey(command.toLowerCase())) {
121
-                executeCommand(origin, commands.get(command.toLowerCase()), comargs);
121
+                executeCommand(origin, false, commands.get(command.toLowerCase()), comargs);
122 122
             } else {
123 123
                 handleInvalidCommand(origin, command, comargs);
124 124
             }
@@ -149,11 +149,12 @@ public abstract class CommandParser {
149 149
     /**
150 150
      * Executes the specified command with the given arguments.
151 151
      * @param origin The window in which the command was typed
152
+     * @param isSilent Whether the command is being silenced or not
152 153
      * @param command The command to be executed
153 154
      * @param args The arguments to the command
154 155
      */
155 156
     protected abstract void executeCommand(final CommandWindow origin,
156
-            final Command command, final String... args);
157
+            final boolean isSilent, final Command command, final String... args);
157 158
     
158 159
     /**
159 160
      * Called when the user attempted to issue a command (i.e., used the command

+ 2
- 1
src/uk/org/ownage/dmdirc/commandparser/GlobalCommand.java 파일 보기

@@ -33,7 +33,8 @@ public abstract class GlobalCommand extends Command {
33 33
      * Executes this command. Note that for global commands, origin may be
34 34
      * null.
35 35
      * @param origin The window in which the command was typed
36
+     * @param isSilent Whetehr this command is silenced or not
36 37
      * @param args Arguments passed to this command
37 38
      */
38
-    public abstract void execute(CommandWindow origin, String ... args);
39
+    public abstract void execute(CommandWindow origin, boolean isSilent, String ... args);
39 40
 }

+ 4
- 9
src/uk/org/ownage/dmdirc/commandparser/GlobalCommandParser.java 파일 보기

@@ -48,7 +48,7 @@ public final class GlobalCommandParser extends CommandParser {
48 48
      * Retrieves a singleton instance of the global command parser.
49 49
      * @return A GlobalCommandParser
50 50
      */
51
-    public static synchronized  GlobalCommandParser getGlobalCommandParser() {
51
+    public static synchronized GlobalCommandParser getGlobalCommandParser() {
52 52
         if (me == null) {
53 53
             me = new GlobalCommandParser();
54 54
         }
@@ -61,15 +61,10 @@ public final class GlobalCommandParser extends CommandParser {
61 61
         CommandManager.loadGlobalCommands(this);
62 62
     }
63 63
     
64
-    /**
65
-     * Executes the specified command with the given arguments.
66
-     * @param origin The window in which the command was typed
67
-     * @param command The command to be executed
68
-     * @param args The arguments to the command
69
-     */
64
+    /** {@inheritDoc} */
70 65
     protected void executeCommand(final CommandWindow origin,
71
-            final Command command, final String... args) {
72
-        ((GlobalCommand) command).execute(origin, args);
66
+            final boolean isSilent, final Command command, final String... args) {
67
+        ((GlobalCommand) command).execute(origin, isSilent, args);
73 68
     }
74 69
     
75 70
     /**

+ 3
- 8
src/uk/org/ownage/dmdirc/commandparser/QueryCommandParser.java 파일 보기

@@ -60,20 +60,15 @@ public final class QueryCommandParser extends CommandParser {
60 60
         CommandManager.loadQueryCommands(this);
61 61
     }
62 62
     
63
-    /**
64
-     * Executes the specified command with the given arguments.
65
-     * @param origin The window in which the command was typed
66
-     * @param command The command to be executed
67
-     * @param args The arguments to the command
68
-     */
63
+    /** {@inheritDoc} */
69 64
     protected void executeCommand(final CommandWindow origin,
70
-            final Command command, final String... args) {
65
+            final boolean isSilent, final Command command, final String... args) {
71 66
         if (command instanceof QueryCommand) {
72 67
             ((QueryCommand) command).execute(origin, server, query, args);
73 68
         } else if (command instanceof ServerCommand) {
74 69
             ((ServerCommand) command).execute(origin, server, args);
75 70
         } else {
76
-            ((GlobalCommand) command).execute(origin, args);
71
+            ((GlobalCommand) command).execute(origin, isSilent, args);
77 72
         }
78 73
     }
79 74
     

+ 3
- 8
src/uk/org/ownage/dmdirc/commandparser/ServerCommandParser.java 파일 보기

@@ -51,18 +51,13 @@ public final class ServerCommandParser extends CommandParser {
51 51
         CommandManager.loadServerCommands(this);
52 52
     }
53 53
     
54
-    /**
55
-     * Executes the specified command with the given arguments.
56
-     * @param origin The window in which the command was typed
57
-     * @param command The command to be executed
58
-     * @param args The arguments to the command
59
-     */
54
+    /** {@inheritDoc} */
60 55
     protected void executeCommand(final CommandWindow origin,
61
-            final Command command, final String... args) {
56
+            final boolean isSilent, final Command command, final String... args) {
62 57
         if (command instanceof ServerCommand) {
63 58
             ((ServerCommand) command).execute(origin, server, args);
64 59
         } else {
65
-            ((GlobalCommand) command).execute(origin, args);
60
+            ((GlobalCommand) command).execute(origin, isSilent, args);
66 61
         }
67 62
     }
68 63
     

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/AllServers.java 파일 보기

@@ -41,12 +41,9 @@ public class AllServers extends GlobalCommand {
41 41
         CommandManager.registerCommand(this);
42 42
     }
43 43
     
44
-    /**
45
-     * Executes this command.
46
-     * @param origin The frame in which this command was issued
47
-     * @param args The user supplied arguments
48
-     */
49
-    public void execute(final CommandWindow origin, final String... args) {
44
+    /** {@inheritDoc} */
45
+    public void execute(final CommandWindow origin, final boolean isSilent,
46
+            final String... args) {
50 47
         final String command = implodeArgs(args);
51 48
         CommandWindow window;
52 49
         

+ 3
- 2
src/uk/org/ownage/dmdirc/commandparser/commands/global/Exit.java 파일 보기

@@ -44,8 +44,9 @@ public final class Exit extends GlobalCommand {
44 44
         CommandManager.registerCommand(this);
45 45
     }
46 46
     
47
-    /** {@inheritDoc}  */
48
-    public void execute(final CommandWindow origin, final String... args) {
47
+    /** {@inheritDoc} */
48
+    public void execute(final CommandWindow origin, final boolean isSilent,
49
+            final String... args) {
49 50
         Main.quit(implodeArgs(args));
50 51
     }
51 52
     

+ 4
- 3
src/uk/org/ownage/dmdirc/commandparser/commands/global/ExitDefault.java 파일 보기

@@ -44,8 +44,9 @@ public final class ExitDefault extends GlobalCommand {
44 44
         CommandManager.registerCommand(this);
45 45
     }
46 46
     
47
-    /** {@inheritDoc}  */
48
-    public void execute(final CommandWindow origin, final String... args) {
47
+    /** {@inheritDoc} */
48
+    public void execute(final CommandWindow origin, final boolean isSilent,
49
+            final String... args) {
49 50
         String def;
50 51
         
51 52
         if (origin == null) {
@@ -54,7 +55,7 @@ public final class ExitDefault extends GlobalCommand {
54 55
             def = origin.getConfigManager().getOption("general", "closemessage");
55 56
         }
56 57
         
57
-        CommandManager.getGlobalCommand("exit").execute(origin, def);
58
+        CommandManager.getGlobalCommand("exit").execute(origin, isSilent, def);
58 59
     }
59 60
     
60 61
     

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/LoadFormatter.java 파일 보기

@@ -42,12 +42,9 @@ public final class LoadFormatter extends GlobalCommand {
42 42
         CommandManager.registerCommand(this);
43 43
     }
44 44
     
45
-    /**
46
-     * Executes this command.
47
-     * @param origin The frame in which this command was issued
48
-     * @param args The user supplied arguments
49
-     */
50
-    public void execute(final CommandWindow origin, final String... args) {
45
+    /** {@inheritDoc} */
46
+    public void execute(final CommandWindow origin, final boolean isSilent,
47
+            final String... args) {
51 48
         if (Formatter.loadFile(args[0])) {
52 49
             origin.addLine("commandOutput", "Formatter loaded.");
53 50
         } else {

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/LoadPlugin.java 파일 보기

@@ -42,12 +42,9 @@ public final class LoadPlugin extends GlobalCommand {
42 42
         CommandManager.registerCommand(this);
43 43
     }
44 44
     
45
-    /**
46
-     * Executes this command.
47
-     * @param origin The frame in which this command was issued
48
-     * @param args The user supplied arguments
49
-     */
50
-    public void execute(final CommandWindow origin, final String... args) {
45
+    /** {@inheritDoc} */
46
+    public void execute(final CommandWindow origin, final boolean isSilent,
47
+            final String... args) {
51 48
         if (PluginManager.getPluginManager().addPlugin(args[0])) {
52 49
             PluginManager.getPluginManager().getPlugin(args[0]).setActive(true);
53 50
             origin.addLine("commandOutput", "Plugin loaded.");

+ 3
- 2
src/uk/org/ownage/dmdirc/commandparser/commands/global/NewServer.java 파일 보기

@@ -45,8 +45,9 @@ public final class NewServer extends GlobalCommand {
45 45
         CommandManager.registerCommand(this);
46 46
     }
47 47
     
48
-    /** {@inheritDoc}  */
49
-    public void execute(final CommandWindow origin, final String... args) {
48
+    /** {@inheritDoc} */
49
+    public void execute(final CommandWindow origin, final boolean isSilent,
50
+            final String... args) {
50 51
         if (args.length == 0) {
51 52
             origin.addLine("commandUsage", Config.getCommandChar(), "newserver",
52 53
                     "[--ssl] <host[:port]> [password]");

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/ReloadActions.java 파일 보기

@@ -42,12 +42,9 @@ public final class ReloadActions extends GlobalCommand {
42 42
         CommandManager.registerCommand(this);
43 43
     }
44 44
     
45
-    /**
46
-     * Executes this command.
47
-     * @param origin The frame in which this command was issued
48
-     * @param args The user supplied arguments
49
-     */
50
-    public void execute(final CommandWindow origin, final String... args) {
45
+    /** {@inheritDoc} */
46
+    public void execute(final CommandWindow origin, final boolean isSilent,
47
+            final String... args) {
51 48
         ActionManager.loadActions();
52 49
         origin.addLine("commandOutput", "Actions reloaded.");
53 50
     }

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/ReloadFormatter.java 파일 보기

@@ -42,12 +42,9 @@ public final class ReloadFormatter extends GlobalCommand {
42 42
         CommandManager.registerCommand(this);
43 43
     }
44 44
     
45
-    /**
46
-     * Executes this command.
47
-     * @param origin The frame in which this command was issued
48
-     * @param args The user supplied arguments
49
-     */
50
-    public void execute(final CommandWindow origin, final String... args) {
45
+    /** {@inheritDoc} */
46
+    public void execute(final CommandWindow origin, final boolean isSilent,
47
+            final String... args) {
51 48
         Formatter.reload();
52 49
         origin.addLine("commandOutput", "Formatter reloaded.");
53 50
     }

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/ReloadPlugin.java 파일 보기

@@ -43,12 +43,9 @@ public final class ReloadPlugin extends GlobalCommand {
43 43
         CommandManager.registerCommand(this);
44 44
     }
45 45
     
46
-    /**
47
-     * Executes this command.
48
-     * @param origin The frame in which this command was issued
49
-     * @param args The user supplied arguments
50
-     */
51
-    public void execute(final CommandWindow origin, final String... args) {
46
+    /** {@inheritDoc} */
47
+    public void execute(final CommandWindow origin, final boolean isSilent,
48
+            final String... args) {
52 49
         Plugin plugin = PluginManager.getPluginManager().getPlugin(args[0]);
53 50
         if (plugin != null) {
54 51
             boolean isActive = plugin.isActive();

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/SaveFormatter.java 파일 보기

@@ -42,12 +42,9 @@ public final class SaveFormatter extends GlobalCommand {
42 42
         CommandManager.registerCommand(this);
43 43
     }
44 44
     
45
-    /**
46
-     * Executes this command.
47
-     * @param origin The frame in which this command was issued
48
-     * @param args The user supplied arguments
49
-     */
50
-    public void execute(final CommandWindow origin, final String... args) {
45
+    /** {@inheritDoc} */
46
+    public void execute(final CommandWindow origin, final boolean isSilent,
47
+            final String... args) {
51 48
         if (Formatter.saveAs(args[0])) {
52 49
             origin.addLine("commandOutput", "Formatter saved.");
53 50
         } else {

+ 3
- 6
src/uk/org/ownage/dmdirc/commandparser/commands/global/Set.java 파일 보기

@@ -42,12 +42,9 @@ public final class Set extends GlobalCommand {
42 42
         CommandManager.registerCommand(this);
43 43
     }
44 44
     
45
-    /**
46
-     * Executes this command.
47
-     * @param origin The frame in which this command was issued
48
-     * @param args The user supplied arguments
49
-     */
50
-    public void execute(final CommandWindow origin, final String... args) {
45
+    /** {@inheritDoc} */
46
+    public void execute(final CommandWindow origin, final boolean isSilent,
47
+            final String... args) {
51 48
         switch (args.length) {
52 49
             case 0:
53 50
                 doDomainList(origin);

Loading…
취소
저장