Procházet zdrojové kódy

Intelligent command completion now includes context

Fixes issue 3869

Depends-On: Ib7f049ebe0c771bf7dc43334c6aed9568e0e8d72
Change-Id: I8d6b252b49ea7ae64d8bddd5c31dfb228465a4f6
Reviewed-on: http://gerrit.dmdirc.com/990
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4rc1
Chris Smith před 14 roky
rodič
revize
a72b699cb0
36 změnil soubory, kde provedl 158 přidání a 117 odebrání
  1. 52
    4
      src/com/dmdirc/commandparser/commands/IntelligentCommand.java
  2. 2
    3
      src/com/dmdirc/commandparser/commands/channel/Ban.java
  3. 2
    3
      src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java
  4. 2
    3
      src/com/dmdirc/commandparser/commands/channel/KickReason.java
  5. 2
    3
      src/com/dmdirc/commandparser/commands/channel/Mode.java
  6. 2
    3
      src/com/dmdirc/commandparser/commands/channel/Names.java
  7. 4
    4
      src/com/dmdirc/commandparser/commands/channel/SetNickColour.java
  8. 3
    4
      src/com/dmdirc/commandparser/commands/global/Active.java
  9. 4
    6
      src/com/dmdirc/commandparser/commands/global/AliasCommand.java
  10. 3
    4
      src/com/dmdirc/commandparser/commands/global/AllServers.java
  11. 2
    3
      src/com/dmdirc/commandparser/commands/global/Clear.java
  12. 5
    5
      src/com/dmdirc/commandparser/commands/global/Debug.java
  13. 3
    4
      src/com/dmdirc/commandparser/commands/global/Echo.java
  14. 2
    1
      src/com/dmdirc/commandparser/commands/global/Help.java
  15. 3
    4
      src/com/dmdirc/commandparser/commands/global/Ifplugin.java
  16. 2
    3
      src/com/dmdirc/commandparser/commands/global/Input.java
  17. 2
    3
      src/com/dmdirc/commandparser/commands/global/LoadPlugin.java
  18. 2
    2
      src/com/dmdirc/commandparser/commands/global/Notify.java
  19. 4
    4
      src/com/dmdirc/commandparser/commands/global/OpenWindow.java
  20. 7
    3
      src/com/dmdirc/commandparser/commands/global/ReloadActions.java
  21. 2
    3
      src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java
  22. 2
    3
      src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java
  23. 2
    3
      src/com/dmdirc/commandparser/commands/global/SaveConfig.java
  24. 3
    1
      src/com/dmdirc/commandparser/commands/global/Set.java
  25. 2
    3
      src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java
  26. 3
    4
      src/com/dmdirc/commandparser/commands/server/AllChannels.java
  27. 2
    3
      src/com/dmdirc/commandparser/commands/server/Back.java
  28. 2
    3
      src/com/dmdirc/commandparser/commands/server/Ctcp.java
  29. 4
    3
      src/com/dmdirc/commandparser/commands/server/Ignore.java
  30. 1
    1
      src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java
  31. 2
    3
      src/com/dmdirc/commandparser/commands/server/Message.java
  32. 2
    3
      src/com/dmdirc/commandparser/commands/server/Nick.java
  33. 2
    3
      src/com/dmdirc/commandparser/commands/server/Notice.java
  34. 2
    3
      src/com/dmdirc/commandparser/commands/server/OpenQuery.java
  35. 1
    1
      src/com/dmdirc/ui/input/InputHandler.java
  36. 18
    8
      src/com/dmdirc/ui/input/TabCompleter.java

+ 52
- 4
src/com/dmdirc/commandparser/commands/IntelligentCommand.java Zobrazit soubor

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import com.dmdirc.ui.input.AdditionalTabTargets;
26
+import com.dmdirc.ui.interfaces.InputWindow;
26 27
 
27 28
 import java.util.List;
28 29
 
@@ -34,12 +35,59 @@ import java.util.List;
34 35
 public interface IntelligentCommand {
35 36
 
36 37
     /**
37
-     * Returns a list of suggestions for the specified argument, given the list
38
-     * of previous arguments.
38
+     * Describes the context of an intelligent tab completion request.
39
+     *
40
+     * @since 0.6.4
41
+     */
42
+    public static class IntelligentCommandContext {
43
+
44
+        /** The window the command is being entered in. */
45
+        private final InputWindow window;
46
+
47
+        /** The previously supplied arguments, if any. */
48
+        private final List<String> previousArgs;
49
+
50
+        /**
51
+         * Creates a new context with the specified arguments.
52
+         *
53
+         * @param window The window the command is being entered in
54
+         * @param previousArgs The previously supplied arguments, if any
55
+         */
56
+        public IntelligentCommandContext(final InputWindow window,
57
+                final List<String> previousArgs) {
58
+            this.window = window;
59
+            this.previousArgs = previousArgs;
60
+        }
61
+
62
+        /**
63
+         * Retrieves the window that the command was entered in.
64
+         * 
65
+         * @return The command's input window
66
+         */
67
+        public InputWindow getWindow() {
68
+            return window;
69
+        }
70
+
71
+        /**
72
+         * Retrieves the previously supplied arguments.
73
+         *
74
+         * @return Any arguments supplied prior to the current one
75
+         */
76
+        public List<String> getPreviousArgs() {
77
+            return previousArgs;
78
+        }
79
+
80
+    }
81
+
82
+    /**
83
+     * Returns a list of suggestions for the specified argument, given the
84
+     * specified context.
85
+     *
39 86
      * @param arg The argument that is being completed
40
-     * @param previousArgs The contents of the previous arguments, if any
87
+     * @param context The context in which suggestions are being sought
41 88
      * @return A list of suggestions for the argument
89
+     * @since 0.6.4
42 90
      */
43
-    AdditionalTabTargets getSuggestions(int arg, List<String> previousArgs);
91
+    AdditionalTabTargets getSuggestions(int arg, IntelligentCommandContext context);
44 92
     
45 93
 }

+ 2
- 3
src/com/dmdirc/commandparser/commands/channel/Ban.java Zobrazit soubor

@@ -33,8 +33,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
33 33
 import com.dmdirc.ui.input.TabCompletionType;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35 35
 
36
-import java.util.List;
37
-
38 36
 /**
39 37
  * The kick command bans a specified user or host from the channel.
40 38
  * 
@@ -89,7 +87,8 @@ public final class Ban extends ChannelCommand implements IntelligentCommand {
89 87
 
90 88
     /** {@inheritDoc} */
91 89
     @Override
92
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
90
+    public AdditionalTabTargets getSuggestions(final int arg,
91
+            final IntelligentCommandContext context) {
93 92
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
94 93
         
95 94
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java Zobrazit soubor

@@ -33,8 +33,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35 35
 
36
-import java.util.List;
37
-
38 36
 /**
39 37
  * Opens the channel settings window for the channel.
40 38
  * @author chris
@@ -76,7 +74,8 @@ public final class ChannelSettings extends ChannelCommand implements Intelligent
76 74
 
77 75
     /** {@inheritDoc} */
78 76
     @Override
79
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
77
+    public AdditionalTabTargets getSuggestions(final int arg,
78
+            final IntelligentCommandContext context) {
80 79
         return new AdditionalTabTargets().excludeAll();
81 80
     }
82 81
 }

+ 2
- 3
src/com/dmdirc/commandparser/commands/channel/KickReason.java Zobrazit soubor

@@ -34,8 +34,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
34 34
 import com.dmdirc.ui.input.TabCompletionType;
35 35
 import com.dmdirc.ui.interfaces.InputWindow;
36 36
 
37
-import java.util.List;
38
-
39 37
 /**
40 38
  * The kick command kicks a specified user from the channel.
41 39
  * This version allows the user to specify a reason.
@@ -92,7 +90,8 @@ public final class KickReason extends ChannelCommand implements IntelligentComma
92 90
 
93 91
     /** {@inheritDoc} */
94 92
     @Override
95
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
93
+    public AdditionalTabTargets getSuggestions(final int arg,
94
+            final IntelligentCommandContext context) {
96 95
         final AdditionalTabTargets res = new AdditionalTabTargets();
97 96
         
98 97
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/channel/Mode.java Zobrazit soubor

@@ -35,8 +35,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
35 35
 import com.dmdirc.ui.input.TabCompletionType;
36 36
 import com.dmdirc.ui.interfaces.InputWindow;
37 37
 
38
-import java.util.List;
39
-
40 38
 /**
41 39
  * The mode command allows the user to inspect and change channel modes.
42 40
  * @author chris
@@ -96,7 +94,8 @@ public final class Mode extends ChannelCommand implements IntelligentCommand,
96 94
 
97 95
     /** {@inheritDoc} */
98 96
     @Override
99
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
97
+    public AdditionalTabTargets getSuggestions(final int arg,
98
+            final IntelligentCommandContext context) {
100 99
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
101 100
 
102 101
         if (arg > 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/channel/Names.java Zobrazit soubor

@@ -33,8 +33,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35 35
 
36
-import java.util.List;
37
-
38 36
 /**
39 37
  * Sends a names request.
40 38
  * 
@@ -87,7 +85,8 @@ public class Names extends ChannelCommand implements IntelligentCommand, Externa
87 85
 
88 86
     /** {@inheritDoc} */
89 87
     @Override
90
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
88
+    public AdditionalTabTargets getSuggestions(final int arg,
89
+            final IntelligentCommandContext context) {
91 90
         return new AdditionalTabTargets().excludeAll();
92 91
     } 
93 92
 

+ 4
- 4
src/com/dmdirc/commandparser/commands/channel/SetNickColour.java Zobrazit soubor

@@ -37,7 +37,6 @@ import com.dmdirc.ui.interfaces.InputWindow;
37 37
 import com.dmdirc.ui.messages.ColourManager;
38 38
 
39 39
 import java.awt.Color;
40
-import java.util.List;
41 40
 
42 41
 /**
43 42
  * Allows the user to set a nickname on the channel to use a custom colour.
@@ -129,7 +128,8 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
129 128
 
130 129
     /** {@inheritDoc} */
131 130
     @Override
132
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
131
+    public AdditionalTabTargets getSuggestions(final int arg,
132
+            final IntelligentCommandContext context) {
133 133
         final AdditionalTabTargets targets = new AdditionalTabTargets();
134 134
         targets.excludeAll();
135 135
         
@@ -137,8 +137,8 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
137 137
             targets.include(TabCompletionType.CHANNEL_NICK);
138 138
             targets.add("--nicklist");
139 139
             targets.add("--text");
140
-        } else if (arg == 1 && (previousArgs.get(0).equals("--text")
141
-                || previousArgs.get(0).equals("--nicklist"))) {
140
+        } else if (arg == 1 && (context.getPreviousArgs().get(0).equals("--text")
141
+                || context.getPreviousArgs().get(0).equals("--nicklist"))) {
142 142
             targets.include(TabCompletionType.CHANNEL_NICK);            
143 143
         }
144 144
         

+ 3
- 4
src/com/dmdirc/commandparser/commands/global/Active.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.input.TabCompleter;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * The Active command issues a command to the active window.
38 36
  * @author chris
@@ -83,8 +81,9 @@ public final class Active extends GlobalCommand implements IntelligentCommand {
83 81
 
84 82
     /** {@inheritDoc} */
85 83
     @Override
86
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
87
-        return TabCompleter.getIntelligentResults(arg, previousArgs, 0);
84
+    public AdditionalTabTargets getSuggestions(final int arg,
85
+            final IntelligentCommandContext context) {
86
+        return TabCompleter.getIntelligentResults(arg, context, 0);
88 87
     }
89 88
     
90 89
 }

+ 4
- 6
src/com/dmdirc/commandparser/commands/global/AliasCommand.java Zobrazit soubor

@@ -34,8 +34,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
34 34
 import com.dmdirc.ui.input.TabCompleter;
35 35
 import com.dmdirc.ui.interfaces.InputWindow;
36 36
 
37
-import java.util.List;
38
-
39 37
 /**
40 38
  * The alias command allows users to create aliases on-the-fly.
41 39
  * 
@@ -139,17 +137,17 @@ public final class AliasCommand extends GlobalCommand implements
139 137
     /** {@inheritDoc} */
140 138
     @Override
141 139
     public AdditionalTabTargets getSuggestions(final int arg,
142
-                                               final List<String> previousArgs) {
140
+            final IntelligentCommandContext context) {
143 141
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
144 142
 
145 143
         if (arg == 0) {
146 144
             res.add("--remove");
147
-        } else if (arg == 1 && previousArgs.get(0).equals("--remove")) {
145
+        } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--remove")) {
148 146
             for (Action alias : AliasWrapper.getAliasWrapper()) {
149 147
                 res.add(AliasWrapper.getCommandName(alias));
150 148
             }
151
-        } else if (arg >= 1 && !previousArgs.get(0).equals("--remove")) {
152
-            return TabCompleter.getIntelligentResults(arg, previousArgs, 1);
149
+        } else if (arg >= 1 && !context.getPreviousArgs().get(0).equals("--remove")) {
150
+            return TabCompleter.getIntelligentResults(arg, context, 1);
153 151
         }
154 152
 
155 153
         return res;

+ 3
- 4
src/com/dmdirc/commandparser/commands/global/AllServers.java Zobrazit soubor

@@ -32,8 +32,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.input.TabCompleter;
33 33
 import com.dmdirc.ui.interfaces.InputWindow;
34 34
 
35
-import java.util.List;
36
-
37 35
 /**
38 36
  * The AllServers command allows users to issue commands to all servers.
39 37
  * @author chris
@@ -82,8 +80,9 @@ public final class AllServers extends GlobalCommand implements IntelligentComman
82 80
 
83 81
     /** {@inheritDoc} */
84 82
     @Override
85
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
86
-        return TabCompleter.getIntelligentResults(arg, previousArgs, 0);
83
+    public AdditionalTabTargets getSuggestions(final int arg,
84
+            final IntelligentCommandContext context) {
85
+        return TabCompleter.getIntelligentResults(arg, context, 0);
87 86
     }
88 87
     
89 88
 }

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/Clear.java Zobrazit soubor

@@ -29,8 +29,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
29 29
 import com.dmdirc.ui.input.AdditionalTabTargets;
30 30
 import com.dmdirc.ui.interfaces.InputWindow;
31 31
 
32
-import java.util.List;
33
-
34 32
 /**
35 33
  * The clear command clears the main text area of the current window.
36 34
  * 
@@ -75,7 +73,8 @@ public final class Clear extends GlobalCommand implements IntelligentCommand {
75 73
 
76 74
     /** {@inheritDoc} */
77 75
     @Override
78
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
76
+    public AdditionalTabTargets getSuggestions(final int arg,
77
+            final IntelligentCommandContext context) {
79 78
         return new AdditionalTabTargets().excludeAll();
80 79
     } 
81 80
     

+ 5
- 5
src/com/dmdirc/commandparser/commands/global/Debug.java Zobrazit soubor

@@ -43,7 +43,6 @@ import com.dmdirc.updater.UpdateChecker;
43 43
 
44 44
 import java.io.Serializable;
45 45
 import java.util.Comparator;
46
-import java.util.List;
47 46
 import java.util.Map;
48 47
 import java.util.Map.Entry;
49 48
 import java.util.SortedSet;
@@ -476,7 +475,8 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
476 475
     
477 476
     /** {@inheritDoc} */
478 477
     @Override
479
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
478
+    public AdditionalTabTargets getSuggestions(final int arg,
479
+            final IntelligentCommandContext context) {
480 480
         final AdditionalTabTargets res = new AdditionalTabTargets();
481 481
         
482 482
         res.excludeAll();
@@ -499,12 +499,12 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
499 499
             res.add("migration");
500 500
             res.add("notify");
501 501
             res.add("services");
502
-        } else if (arg == 1 && "error".equals(previousArgs.get(0))) {
502
+        } else if (arg == 1 && "error".equals(context.getPreviousArgs().get(0))) {
503 503
             res.add("user");
504 504
             res.add("app");
505
-        } else if (arg == 1 && "services".equals(previousArgs.get(0))) {
505
+        } else if (arg == 1 && "services".equals(context.getPreviousArgs().get(0))) {
506 506
             res.add("full");
507
-        } else if (arg == 2 && "error".equals(previousArgs.get(0))) {
507
+        } else if (arg == 2 && "error".equals(context.getPreviousArgs().get(0))) {
508 508
             res.add("low");
509 509
             res.add("medium");
510 510
             res.add("high");

+ 3
- 4
src/com/dmdirc/commandparser/commands/global/Echo.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
32 32
 import com.dmdirc.ui.interfaces.Window;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * The echo commands simply echos text to the current window.
38 36
  * 
@@ -106,13 +104,14 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
106 104
 
107 105
     /** {@inheritDoc} */
108 106
     @Override
109
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
107
+    public AdditionalTabTargets getSuggestions(final int arg,
108
+            final IntelligentCommandContext context) {
110 109
         final AdditionalTabTargets targets = new AdditionalTabTargets();
111 110
         
112 111
         if (arg == 0) {
113 112
             targets.add("--active");
114 113
             targets.add("--target");
115
-        } else if (arg == 1 && previousArgs.get(0).equals("--target")) {
114
+        } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--target")) {
116 115
             targets.excludeAll();
117 116
             // TODO: Include window names
118 117
         }

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/Help.java Zobrazit soubor

@@ -155,7 +155,8 @@ public final class Help extends GlobalCommand implements IntelligentCommand {
155 155
 
156 156
     /** {@inheritDoc} */
157 157
     @Override
158
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
158
+    public AdditionalTabTargets getSuggestions(final int arg,
159
+            final IntelligentCommandContext context) {
159 160
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
160 161
 
161 162
         if (arg == 0) {

+ 3
- 4
src/com/dmdirc/commandparser/commands/global/Ifplugin.java Zobrazit soubor

@@ -33,8 +33,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
33 33
 import com.dmdirc.ui.input.TabCompleter;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35 35
 
36
-import java.util.List;
37
-
38 36
 /**
39 37
  * The if plugin command allows the user to execute commands based on whether
40 38
  * or not a plugin is loaded.
@@ -104,7 +102,8 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
104 102
 
105 103
     /** {@inheritDoc} */
106 104
     @Override
107
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
105
+    public AdditionalTabTargets getSuggestions(final int arg,
106
+            final IntelligentCommandContext context) {
108 107
         AdditionalTabTargets res;
109 108
         
110 109
         if (arg == 0) {
@@ -116,7 +115,7 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
116 115
                 res.add("!" + possPlugin.getName());
117 116
             }            
118 117
         } else {
119
-            res = TabCompleter.getIntelligentResults(arg, previousArgs, 1);
118
+            res = TabCompleter.getIntelligentResults(arg, context, 1);
120 119
         }
121 120
         
122 121
         return res;

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/Input.java Zobrazit soubor

@@ -30,8 +30,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
30 30
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
32 32
 
33
-import java.util.List;
34
-
35 33
 /**
36 34
  * The input command allows you to maniplulate text in a windows inputField.
37 35
  *
@@ -87,7 +85,8 @@ public class Input extends GlobalCommand implements IntelligentCommand {
87 85
 
88 86
     /** {@inheritDoc} */
89 87
     @Override
90
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
88
+    public AdditionalTabTargets getSuggestions(final int arg,
89
+            final IntelligentCommandContext context) {
91 90
         final AdditionalTabTargets res = new AdditionalTabTargets();
92 91
         
93 92
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.plugins.PluginManager;
31 31
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * Allows the user to load a plugin.
38 36
  * @author chris
@@ -99,7 +97,8 @@ public final class LoadPlugin extends GlobalCommand implements IntelligentComman
99 97
 
100 98
     /** {@inheritDoc} */
101 99
     @Override
102
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
100
+    public AdditionalTabTargets getSuggestions(final int arg,
101
+            final IntelligentCommandContext context) {
103 102
         final AdditionalTabTargets res = new AdditionalTabTargets();
104 103
 
105 104
         res.excludeAll();

+ 2
- 2
src/com/dmdirc/commandparser/commands/global/Notify.java Zobrazit soubor

@@ -31,7 +31,6 @@ import com.dmdirc.ui.interfaces.InputWindow;
31 31
 import com.dmdirc.ui.messages.ColourManager;
32 32
 
33 33
 import java.awt.Color;
34
-import java.util.List;
35 34
 
36 35
 /**
37 36
  * The notify command allows the user to set the notification colour for a
@@ -92,7 +91,8 @@ public final class Notify extends GlobalCommand implements IntelligentCommand {
92 91
 
93 92
     /** {@inheritDoc} */
94 93
     @Override
95
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
94
+    public AdditionalTabTargets getSuggestions(final int arg,
95
+            final IntelligentCommandContext context) {
96 96
         return new AdditionalTabTargets().excludeAll();
97 97
     } 
98 98
     

+ 4
- 4
src/com/dmdirc/commandparser/commands/global/OpenWindow.java Zobrazit soubor

@@ -32,11 +32,10 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 import com.dmdirc.ui.interfaces.Window;
34 34
 
35
-import java.util.List;
36
-
37 35
 /**
38
- * @author chris
36
+ * Opens a new window.
39 37
  * 
38
+ * @author chris
40 39
  */
41 40
 public class OpenWindow extends GlobalCommand implements IntelligentCommand {
42 41
     
@@ -117,7 +116,8 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
117 116
 
118 117
     /** {@inheritDoc} */
119 118
     @Override
120
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
119
+    public AdditionalTabTargets getSuggestions(final int arg,
120
+            final IntelligentCommandContext context) {
121 121
         final AdditionalTabTargets res = new AdditionalTabTargets();
122 122
         
123 123
         if (arg == 0) {

+ 7
- 3
src/com/dmdirc/commandparser/commands/global/ReloadActions.java Zobrazit soubor

@@ -30,10 +30,9 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
30 30
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
32 32
 
33
-import java.util.List;
34
-
35 33
 /**
36 34
  * Allows the user to reload actions.
35
+ *
37 36
  * @author chris
38 37
  */
39 38
 public final class ReloadActions extends GlobalCommand implements IntelligentCommand {
@@ -48,6 +47,7 @@ public final class ReloadActions extends GlobalCommand implements IntelligentCom
48 47
     }
49 48
     
50 49
     /** {@inheritDoc} */
50
+    @Override
51 51
     public void execute(final InputWindow origin, final boolean isSilent,
52 52
             final CommandArguments args) {
53 53
         ActionManager.loadActions();
@@ -56,23 +56,27 @@ public final class ReloadActions extends GlobalCommand implements IntelligentCom
56 56
     
57 57
     
58 58
     /** {@inheritDoc}. */
59
+    @Override
59 60
     public String getName() {
60 61
         return "reloadactions";
61 62
     }
62 63
     
63 64
     /** {@inheritDoc}. */
65
+    @Override
64 66
     public boolean showInHelp() {
65 67
         return true;
66 68
     }
67 69
     
68 70
     /** {@inheritDoc}. */
71
+    @Override
69 72
     public String getHelp() {
70 73
         return "reloadactions - reloads actions from disk";
71 74
     }
72 75
 
73 76
     /** {@inheritDoc} */
74 77
     @Override
75
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
78
+    public AdditionalTabTargets getSuggestions(final int arg,
79
+            final IntelligentCommandContext context) {
76 80
         return new AdditionalTabTargets().excludeAll();
77 81
     }
78 82
     

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java Zobrazit soubor

@@ -30,8 +30,6 @@ import com.dmdirc.config.IdentityManager;
30 30
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
32 32
 
33
-import java.util.List;
34
-
35 33
 /**
36 34
  * Allows the user to reload identities.
37 35
  * 
@@ -75,7 +73,8 @@ public class ReloadIdentities extends GlobalCommand implements IntelligentComman
75 73
 
76 74
     /** {@inheritDoc} */
77 75
     @Override
78
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
76
+    public AdditionalTabTargets getSuggestions(final int arg,
77
+            final IntelligentCommandContext context) {
79 78
         return new AdditionalTabTargets().excludeAll();
80 79
     } 
81 80
 

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.plugins.PluginManager;
31 31
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * Allows the user to reload a plugin.
38 36
  * 
@@ -88,7 +86,8 @@ public final class ReloadPlugin extends GlobalCommand implements IntelligentComm
88 86
 
89 87
     /** {@inheritDoc} */
90 88
     @Override
91
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
89
+    public AdditionalTabTargets getSuggestions(final int arg,
90
+            final IntelligentCommandContext context) {
92 91
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
93 92
         
94 93
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/SaveConfig.java Zobrazit soubor

@@ -30,8 +30,6 @@ import com.dmdirc.config.IdentityManager;
30 30
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
32 32
 
33
-import java.util.List;
34
-
35 33
 /**
36 34
  * Allows the user to save the config file.
37 35
  * 
@@ -78,7 +76,8 @@ public final class SaveConfig extends GlobalCommand implements IntelligentComman
78 76
 
79 77
     /** {@inheritDoc} */
80 78
     @Override
81
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
79
+    public AdditionalTabTargets getSuggestions(final int arg,
80
+            final IntelligentCommandContext context) {
82 81
         return new AdditionalTabTargets().excludeAll();
83 82
     } 
84 83
     

+ 3
- 1
src/com/dmdirc/commandparser/commands/global/Set.java Zobrazit soubor

@@ -246,7 +246,9 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
246 246
     
247 247
     /** {@inheritDoc} */
248 248
     @Override
249
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
249
+    public AdditionalTabTargets getSuggestions(final int arg,
250
+            final IntelligentCommandContext context) {
251
+        final List<String> previousArgs = context.getPreviousArgs();
250 252
         final AdditionalTabTargets res = new AdditionalTabTargets();
251 253
         
252 254
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.plugins.PluginManager;
31 31
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * Allows the user to unload a plugin.
38 36
  * 
@@ -90,7 +88,8 @@ public final class UnloadPlugin extends GlobalCommand implements IntelligentComm
90 88
 
91 89
     /** {@inheritDoc} */
92 90
     @Override
93
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
91
+    public AdditionalTabTargets getSuggestions(final int arg,
92
+            final IntelligentCommandContext context) {
94 93
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
95 94
         
96 95
         if (arg == 0) {            

+ 3
- 4
src/com/dmdirc/commandparser/commands/server/AllChannels.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.input.TabCompleter;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * The AllChannels command allows the user to issue a command to all channels
38 36
  * on a server.
@@ -82,8 +80,9 @@ public final class AllChannels extends ServerCommand implements IntelligentComma
82 80
 
83 81
     /** {@inheritDoc} */
84 82
     @Override
85
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
86
-        return TabCompleter.getIntelligentResults(arg, previousArgs, 0);
83
+    public AdditionalTabTargets getSuggestions(final int arg,
84
+            final IntelligentCommandContext context) {
85
+        return TabCompleter.getIntelligentResults(arg, context, 0);
87 86
     }
88 87
     
89 88
 }

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/Back.java Zobrazit soubor

@@ -31,8 +31,6 @@ import com.dmdirc.commandparser.commands.ServerCommand;
31 31
 import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33 33
 
34
-import java.util.List;
35
-
36 34
 /**
37 35
  * The back command allows the user to unset their away status.
38 36
  * @author chris
@@ -83,7 +81,8 @@ public final class Back extends ServerCommand implements IntelligentCommand {
83 81
 
84 82
     /** {@inheritDoc} */
85 83
     @Override
86
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
84
+    public AdditionalTabTargets getSuggestions(final int arg,
85
+            final IntelligentCommandContext context) {
87 86
         return new AdditionalTabTargets().excludeAll();
88 87
     }
89 88
     

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/Ctcp.java Zobrazit soubor

@@ -32,8 +32,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.input.TabCompletionType;
33 33
 import com.dmdirc.ui.interfaces.InputWindow;
34 34
 
35
-import java.util.List;
36
-
37 35
 /**
38 36
  * Allows the user to send CTCP messages.
39 37
  * @author chris
@@ -91,7 +89,8 @@ public final class Ctcp extends ServerCommand implements IntelligentCommand {
91 89
     
92 90
     /** {@inheritDoc} */
93 91
     @Override
94
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
92
+    public AdditionalTabTargets getSuggestions(final int arg,
93
+            final IntelligentCommandContext context) {
95 94
         final AdditionalTabTargets res = new AdditionalTabTargets();
96 95
         
97 96
         if (arg == 0) {

+ 4
- 3
src/com/dmdirc/commandparser/commands/server/Ignore.java Zobrazit soubor

@@ -180,7 +180,8 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
180 180
 
181 181
     /** {@inheritDoc} */
182 182
     @Override
183
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
183
+    public AdditionalTabTargets getSuggestions(final int arg,
184
+            final IntelligentCommandContext context) {
184 185
         final AdditionalTabTargets targets = new AdditionalTabTargets();
185 186
         targets.excludeAll();
186 187
         
@@ -189,10 +190,10 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
189 190
             targets.add("--remove");
190 191
             targets.include(TabCompletionType.CHANNEL_NICK);
191 192
             targets.include(TabCompletionType.QUERY_NICK);
192
-        } else if (arg == 1 && previousArgs.get(0).equals("--regex")) {
193
+        } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--regex")) {
193 194
             targets.include(TabCompletionType.CHANNEL_NICK);
194 195
             targets.include(TabCompletionType.QUERY_NICK);
195
-        } else if (arg == 1 && previousArgs.get(0).equals("--remove")) {
196
+        } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--remove")) {
196 197
             // TODO: If/when passed a server, include known ignore list entries
197 198
         }
198 199
         

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java Zobrazit soubor

@@ -114,7 +114,7 @@ public final class JoinChannelCommand extends ServerCommand implements
114 114
     /** {@inheritDoc} */
115 115
     @Override
116 116
     public AdditionalTabTargets getSuggestions(final int arg,
117
-            final List<String> previousArgs) {
117
+            final IntelligentCommandContext context) {
118 118
         return new AdditionalTabTargets();
119 119
     }
120 120
     

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/Message.java Zobrazit soubor

@@ -33,8 +33,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
33 33
 import com.dmdirc.ui.input.TabCompletionType;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35 35
 
36
-import java.util.List;
37
-
38 36
 /**
39 37
  * Allows the user to send privmsgs.
40 38
  * @author chris
@@ -96,7 +94,8 @@ public final class Message extends ServerCommand implements IntelligentCommand,
96 94
 
97 95
     /** {@inheritDoc} */
98 96
     @Override
99
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
97
+    public AdditionalTabTargets getSuggestions(final int arg,
98
+            final IntelligentCommandContext context) {
100 99
         final AdditionalTabTargets res = new AdditionalTabTargets();
101 100
         
102 101
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/Nick.java Zobrazit soubor

@@ -32,8 +32,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.input.TabCompletionType;
33 33
 import com.dmdirc.ui.interfaces.InputWindow;
34 34
 
35
-import java.util.List;
36
-
37 35
 /**
38 36
  * Allows the user to change nickname.
39 37
  * @author chris
@@ -83,7 +81,8 @@ public final class Nick extends ServerCommand implements IntelligentCommand {
83 81
 
84 82
     /** {@inheritDoc} */
85 83
     @Override
86
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
84
+    public AdditionalTabTargets getSuggestions(final int arg,
85
+            final IntelligentCommandContext context) {
87 86
         final AdditionalTabTargets res = new AdditionalTabTargets();
88 87
         
89 88
         res.exclude(TabCompletionType.COMMAND);

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/Notice.java Zobrazit soubor

@@ -32,8 +32,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
32 32
 import com.dmdirc.ui.input.TabCompletionType;
33 33
 import com.dmdirc.ui.interfaces.InputWindow;
34 34
 
35
-import java.util.List;
36
-
37 35
 /**
38 36
  * Allows the user to send notices.
39 37
  * @author chris
@@ -85,7 +83,8 @@ public final class Notice extends ServerCommand implements IntelligentCommand {
85 83
 
86 84
     /** {@inheritDoc} */
87 85
     @Override
88
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
86
+    public AdditionalTabTargets getSuggestions(final int arg,
87
+            final IntelligentCommandContext context) {
89 88
         final AdditionalTabTargets targets = new AdditionalTabTargets();
90 89
         
91 90
         if (arg == 0) {

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/OpenQuery.java Zobrazit soubor

@@ -33,8 +33,6 @@ import com.dmdirc.ui.input.TabCompletionType;
33 33
 import com.dmdirc.ui.interfaces.InputWindow;
34 34
 import com.dmdirc.ui.messages.Styliser;
35 35
 
36
-import java.util.List;
37
-
38 36
 /**
39 37
  * Allows the user to open a query dialog with another user.
40 38
  * @author chris
@@ -103,7 +101,8 @@ public final class OpenQuery extends ServerCommand implements
103 101
     
104 102
     /** {@inheritDoc} */
105 103
     @Override
106
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
104
+    public AdditionalTabTargets getSuggestions(final int arg,
105
+            final IntelligentCommandContext context) {
107 106
         final AdditionalTabTargets targets = new AdditionalTabTargets();
108 107
         
109 108
         if (arg == 0) {

+ 1
- 1
src/com/dmdirc/ui/input/InputHandler.java Zobrazit soubor

@@ -459,7 +459,7 @@ public abstract class InputHandler implements ConfigChangeListener {
459 459
     private void doCommandTabCompletion(final String text, final int start,
460 460
             final int end, final boolean shiftPressed) {
461 461
         doNormalTabCompletion(text, start, end, shiftPressed,
462
-                TabCompleter.getIntelligentResults(text.substring(0, start)));
462
+                TabCompleter.getIntelligentResults(parentWindow, text.substring(0, start)));
463 463
     }
464 464
 
465 465
     /**

+ 18
- 8
src/com/dmdirc/ui/input/TabCompleter.java Zobrazit soubor

@@ -28,7 +28,9 @@ import com.dmdirc.commandparser.CommandManager;
28 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
29 29
 import com.dmdirc.commandparser.commands.Command;
30 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
+import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
31 32
 import com.dmdirc.config.IdentityManager;
33
+import com.dmdirc.ui.interfaces.InputWindow;
32 34
 import com.dmdirc.util.MapList;
33 35
 
34 36
 import java.util.Arrays;
@@ -211,25 +213,29 @@ public class TabCompleter {
211 213
      * @return Additional tab targets for the text, or null if none are available
212 214
      */
213 215
     public static AdditionalTabTargets getIntelligentResults(final int arg,
214
-            final List<String> previousArgs, final int offset) {
216
+            final IntelligentCommandContext context, final int offset) {
215 217
         if (arg == offset) {
216 218
             final AdditionalTabTargets targets = new AdditionalTabTargets().excludeAll();
217 219
             targets.include(TabCompletionType.COMMAND);
218 220
             return targets;
219 221
         } else {
220
-            return getIntelligentResults(
221
-                    new CommandArguments(previousArgs.subList(offset, previousArgs.size())));
222
+            return getIntelligentResults(context.getWindow(),
223
+                    new CommandArguments(context.getPreviousArgs().subList(offset,
224
+                    context.getPreviousArgs().size())));
222 225
         }        
223 226
     }
224 227
     
225 228
     /**
226 229
      * Retrieves the intelligent results for the command and its arguments
227 230
      * formed from args.
228
-     * 
231
+     *
232
+     * @param window The input window the results are required for
229 233
      * @param args The input arguments
230 234
      * @return Additional tab targets for the text, or null if none are available
235
+     * @since 0.6.4
231 236
      */
232
-    private static AdditionalTabTargets getIntelligentResults(final CommandArguments args) {
237
+    private static AdditionalTabTargets getIntelligentResults(final InputWindow window,
238
+            final CommandArguments args) {
233 239
         if (!args.isCommand()) {
234 240
             return null;
235 241
         }
@@ -243,7 +249,8 @@ public class TabCompleter {
243 249
             if (command.getValue() instanceof IntelligentCommand) {
244 250
                 targets = ((IntelligentCommand) command.getValue())
245 251
                         .getSuggestions(args.getArguments().length,
246
-                        Arrays.asList(args.getArguments()));
252
+                        new IntelligentCommandContext(window,
253
+                        Arrays.asList(args.getArguments())));
247 254
             }
248 255
 
249 256
             if (command.getValue() instanceof ChannelCommand) {
@@ -261,10 +268,13 @@ public class TabCompleter {
261 268
     /**
262 269
      * Handles potentially intelligent tab completion.
263 270
      *
271
+     * @param window The input window the results are required for
264 272
      * @param text The text that is being completed
265 273
      * @return Additional tab targets for the text, or null if none are available
274
+     * @since 0.6.4
266 275
      */
267
-    public static AdditionalTabTargets getIntelligentResults(final String text) {
268
-        return getIntelligentResults(new CommandArguments(text));
276
+    public static AdditionalTabTargets getIntelligentResults(final InputWindow window,
277
+            final String text) {
278
+        return getIntelligentResults(window, new CommandArguments(text));
269 279
     }
270 280
 }

Načítá se…
Zrušit
Uložit