Browse Source

Adds custom windows to tab completion for echo --target

Fixes issue 3873

Change-Id: I2d9506836649e16e4b25448d44704d42dd936f40
Reviewed-on: http://gerrit.dmdirc.com/1008
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.4rc1
Simon Mott 14 years ago
parent
commit
436ec62bfc
1 changed files with 32 additions and 4 deletions
  1. 32
    4
      src/com/dmdirc/commandparser/commands/global/Echo.java

+ 32
- 4
src/com/dmdirc/commandparser/commands/global/Echo.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.CustomWindow;
26
+import com.dmdirc.Server;
25 27
 import com.dmdirc.commandparser.CommandArguments;
26 28
 import com.dmdirc.commandparser.CommandManager;
27 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
@@ -31,9 +33,13 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
31 33
 import com.dmdirc.ui.interfaces.InputWindow;
32 34
 import com.dmdirc.ui.interfaces.Window;
33 35
 
36
+import java.util.ArrayList;
37
+import java.util.Arrays;
38
+import java.util.List;
39
+
34 40
 /**
35 41
  * The echo commands simply echos text to the current window.
36
- * 
42
+ *
37 43
  * @author chris
38 44
  */
39 45
 public final class Echo extends GlobalCommand implements IntelligentCommand {
@@ -107,15 +113,37 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
107 113
     public AdditionalTabTargets getSuggestions(final int arg,
108 114
             final IntelligentCommandContext context) {
109 115
         final AdditionalTabTargets targets = new AdditionalTabTargets();
110
-        
116
+
111 117
         if (arg == 0) {
112 118
             targets.add("--active");
113 119
             targets.add("--target");
114 120
         } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--target")) {
121
+
122
+            final List<Window> windowList = new ArrayList<Window>();
123
+            final Server currentServer = context.getWindow().getContainer()
124
+                    .getServer();
125
+
126
+            //Active window's Children
127
+            windowList.addAll(Arrays.asList(WindowManager.getChildren(context
128
+                    .getWindow())));
129
+
130
+            //Children of Current Window's server
131
+            if (currentServer != null) {
132
+                windowList.addAll(Arrays.asList(WindowManager.getChildren(
133
+                        currentServer.getFrame())));
134
+            }
135
+
136
+            //Global Windows
137
+            windowList.addAll(Arrays.asList(WindowManager.getRootWindows()));
138
+            for (Window customWindow : windowList) {
139
+                if (customWindow.getContainer() instanceof CustomWindow) {
140
+                    targets.add(customWindow.getTitle());
141
+                }
142
+            }
143
+
115 144
             targets.excludeAll();
116
-            // TODO: Include window names
117 145
         }
118
-        
146
+
119 147
         return targets;
120 148
     }
121 149
 

Loading…
Cancel
Save