Sfoglia il codice sorgente

Changes for intelligent command completion

Depends-On: I8d6b252b49ea7ae64d8bddd5c31dfb228465a4f6
Change-Id: Ib7f049ebe0c771bf7dc43334c6aed9568e0e8d72
Reviewed-on: http://gerrit.dmdirc.com/989
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4
Chris Smith 14 anni fa
parent
commit
e5bd6abd73

+ 2
- 2
src/com/dmdirc/addons/dcc/DCCCommand.java Vedi File

@@ -38,7 +38,6 @@ import com.dmdirc.ui.input.TabCompletionType;
38 38
 import com.dmdirc.ui.interfaces.InputWindow;
39 39
 
40 40
 import java.io.File;
41
-import java.util.List;
42 41
 
43 42
 import javax.swing.JFileChooser;
44 43
 import javax.swing.JFrame;
@@ -240,7 +239,8 @@ public final class DCCCommand extends ServerCommand implements IntelligentComman
240 239
 
241 240
     /** {@inheritDoc} */
242 241
     @Override
243
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
242
+    public AdditionalTabTargets getSuggestions(final int arg,
243
+            final IntelligentCommandContext context) {
244 244
         final AdditionalTabTargets res = new AdditionalTabTargets();
245 245
 
246 246
         if (arg == 0) {

+ 2
- 2
src/com/dmdirc/addons/logging/LoggingCommand.java Vedi File

@@ -32,7 +32,6 @@ import com.dmdirc.plugins.PluginInfo;
32 32
 import com.dmdirc.plugins.PluginManager;
33 33
 import com.dmdirc.ui.input.AdditionalTabTargets;
34 34
 import com.dmdirc.ui.interfaces.InputWindow;
35
-import java.util.List;
36 35
 
37 36
 /**
38 37
  * The dcop command retrieves information from a dcop application.
@@ -99,7 +98,8 @@ public final class LoggingCommand extends ServerCommand implements IntelligentCo
99 98
      * @return A list of suggestions for the argument
100 99
      */
101 100
     @Override
102
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
101
+    public AdditionalTabTargets getSuggestions(final int arg,
102
+            final IntelligentCommandContext context) {
103 103
         final AdditionalTabTargets res = new AdditionalTabTargets();
104 104
         if (arg == 0) {
105 105
             res.add("reload");

+ 8
- 8
src/com/dmdirc/addons/nowplaying/NowPlayingCommand.java Vedi File

@@ -171,16 +171,16 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
171 171
     
172 172
     /** {@inheritDoc} */
173 173
     @Override
174
-    public AdditionalTabTargets getSuggestions(final int arg, 
175
-            final List<String> previousArgs) {
174
+    public AdditionalTabTargets getSuggestions(final int arg,
175
+            final IntelligentCommandContext context) {
176 176
 
177 177
         if (arg == 0) {
178 178
             final AdditionalTabTargets res = TabCompleter.
179
-                    getIntelligentResults(arg, previousArgs, 0);
179
+                    getIntelligentResults(arg, context, 0);
180 180
             res.add("--sources");
181 181
             res.add("--source");
182 182
             return res;
183
-        } else if (arg == 1 && previousArgs.get(0).equalsIgnoreCase("--source")) {
183
+        } else if (arg == 1 && context.getPreviousArgs().get(0).equalsIgnoreCase("--source")) {
184 184
             final AdditionalTabTargets res = new AdditionalTabTargets();
185 185
             res.excludeAll();
186 186
             for (MediaSource source : parent.getSources()) {
@@ -189,11 +189,11 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
189 189
                 }
190 190
             }
191 191
             return res;
192
-        } else if (arg > 1 && previousArgs.get(0).equalsIgnoreCase("--source")) {
193
-            return TabCompleter.getIntelligentResults(arg, previousArgs, 2);
192
+        } else if (arg > 1 && context.getPreviousArgs().get(0).equalsIgnoreCase("--source")) {
193
+            return TabCompleter.getIntelligentResults(arg, context, 2);
194 194
         } else {
195
-            return TabCompleter.getIntelligentResults(arg, previousArgs,
196
-                    previousArgs.get(0).equalsIgnoreCase("--sources") ? 1 : 0);
195
+            return TabCompleter.getIntelligentResults(arg, context,
196
+                    context.getPreviousArgs().get(0).equalsIgnoreCase("--sources") ? 1 : 0);
197 197
         }
198 198
     }
199 199
 }

+ 3
- 4
src/com/dmdirc/addons/osd/OsdCommand.java Vedi File

@@ -28,9 +28,7 @@ import com.dmdirc.commandparser.commands.GlobalCommand;
28 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29 29
 import com.dmdirc.ui.input.AdditionalTabTargets;
30 30
 import com.dmdirc.ui.interfaces.InputWindow;
31
-
32 31
 import com.dmdirc.ui.messages.Styliser;
33
-import java.util.List;
34 32
 
35 33
 /**
36 34
  * The osd command shows an on screen message.
@@ -103,12 +101,13 @@ public final class OsdCommand extends GlobalCommand implements IntelligentComman
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 res = new AdditionalTabTargets();
108 107
         
109 108
         if (arg == 0) {
110 109
             res.add("--close");
111
-        } else if (arg > 0 && previousArgs.get(0).equals("--close")) {
110
+        } else if (arg > 0 && context.getPreviousArgs().get(0).equals("--close")) {
112 111
             res.excludeAll();
113 112
         }
114 113
         

+ 3
- 3
src/com/dmdirc/addons/redirect/RedirectCommand.java Vedi File

@@ -30,7 +30,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
30 30
 import com.dmdirc.ui.input.AdditionalTabTargets;
31 31
 import com.dmdirc.ui.input.TabCompleter;
32 32
 import com.dmdirc.ui.interfaces.InputWindow;
33
-import java.util.List;
34 33
 
35 34
 /**
36 35
  * The redirect command allows the user to redirect the output from another
@@ -72,8 +71,9 @@ public class RedirectCommand extends ChatCommand implements IntelligentCommand {
72 71
 
73 72
     /** {@inheritDoc} */
74 73
     @Override
75
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
76
-        return TabCompleter.getIntelligentResults(arg, previousArgs, 0);
74
+    public AdditionalTabTargets getSuggestions(final int arg,
75
+            final IntelligentCommandContext context) {
76
+        return TabCompleter.getIntelligentResults(arg, context, 0);
77 77
     }
78 78
     
79 79
 }

+ 4
- 5
src/com/dmdirc/addons/scriptplugin/ScriptCommand.java Vedi File

@@ -29,7 +29,6 @@ import com.dmdirc.commandparser.commands.GlobalCommand;
29 29
 import com.dmdirc.ui.interfaces.InputWindow;
30 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31 31
 import com.dmdirc.ui.input.AdditionalTabTargets;
32
-import com.dmdirc.ui.input.TabCompletionType;
33 32
 
34 33
 import java.util.LinkedList;
35 34
 import java.util.List;
@@ -37,7 +36,6 @@ import java.util.Map;
37 36
 import java.io.File;
38 37
 import java.io.FileWriter;
39 38
 import java.io.IOException;
40
-
41 39
 import java.lang.reflect.Method;
42 40
 
43 41
 /**
@@ -188,7 +186,8 @@ public final class ScriptCommand extends GlobalCommand implements IntelligentCom
188 186
      * @return A list of suggestions for the argument
189 187
      */
190 188
     @Override
191
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
189
+    public AdditionalTabTargets getSuggestions(final int arg,
190
+            final IntelligentCommandContext context) {
192 191
         final AdditionalTabTargets res = new AdditionalTabTargets();
193 192
         
194 193
         res.excludeAll();
@@ -202,11 +201,11 @@ public final class ScriptCommand extends GlobalCommand implements IntelligentCom
202 201
             res.add("savetobasefile");
203 202
         } else if (arg == 1) {
204 203
             final Map<String,ScriptEngineWrapper> scripts = myPlugin.getScripts();
205
-            if (previousArgs.get(0).equalsIgnoreCase("load")) {
204
+            if (context.getPreviousArgs().get(0).equalsIgnoreCase("load")) {
206 205
                 for (String filename : getPossibleScripts()) {
207 206
                     res.add(filename);
208 207
                 }
209
-            } else if (previousArgs.get(0).equalsIgnoreCase("unload")) {
208
+            } else if (context.getPreviousArgs().get(0).equalsIgnoreCase("unload")) {
210 209
                 for (String filename : scripts.keySet()) {
211 210
                     res.add(filename);
212 211
                 }

+ 3
- 3
src/com/dmdirc/addons/time/TimerCommand.java Vedi File

@@ -29,7 +29,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
29 29
 import com.dmdirc.ui.input.AdditionalTabTargets;
30 30
 import com.dmdirc.ui.input.TabCompleter;
31 31
 import com.dmdirc.ui.interfaces.InputWindow;
32
-import java.util.List;
33 32
 
34 33
 /**
35 34
  * The timer command allows users to schedule commands to occur after a certain
@@ -99,13 +98,14 @@ public final class TimerCommand extends GlobalCommand implements IntelligentComm
99 98
 
100 99
     /** {@inheritDoc} */
101 100
     @Override
102
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
101
+    public AdditionalTabTargets getSuggestions(final int arg,
102
+            final IntelligentCommandContext context) {
103 103
         AdditionalTabTargets res;
104 104
         
105 105
         if (arg <= 1) {
106 106
             res = new AdditionalTabTargets().excludeAll();
107 107
         } else {
108
-            res = TabCompleter.getIntelligentResults(arg, previousArgs, 2);
108
+            res = TabCompleter.getIntelligentResults(arg, context, 2);
109 109
         }
110 110
         
111 111
         return res;

+ 3
- 2
src/com/dmdirc/addons/urlcatcher/UrlListCommand.java Vedi File

@@ -27,7 +27,7 @@ import com.dmdirc.commandparser.commands.GlobalCommand;
27 27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 28
 import com.dmdirc.ui.input.AdditionalTabTargets;
29 29
 import com.dmdirc.ui.interfaces.InputWindow;
30
-import java.util.List;
30
+
31 31
 import java.util.Map;
32 32
 
33 33
 /**
@@ -78,7 +78,8 @@ public class UrlListCommand extends GlobalCommand implements IntelligentCommand
78 78
 
79 79
     /** {@inheritDoc} */
80 80
     @Override
81
-    public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
81
+    public AdditionalTabTargets getSuggestions(final int arg,
82
+            final IntelligentCommandContext context) {
82 83
         return new AdditionalTabTargets().excludeAll();
83 84
     } 
84 85
 

Loading…
Annulla
Salva