|
@@ -22,9 +22,8 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.actions.wrappers;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.GlobalWindow;
|
26
|
|
-import com.dmdirc.Server;
|
27
|
|
-import com.dmdirc.ServerManager;
|
|
25
|
+import com.dmdirc.FrameContainer;
|
|
26
|
+import com.dmdirc.WritableFrameContainer;
|
28
|
27
|
import com.dmdirc.actions.Action;
|
29
|
28
|
import com.dmdirc.actions.ActionCondition;
|
30
|
29
|
import com.dmdirc.actions.ActionGroup;
|
|
@@ -32,6 +31,7 @@ import com.dmdirc.actions.CoreActionType;
|
32
|
31
|
import com.dmdirc.interfaces.CommandController;
|
33
|
32
|
import com.dmdirc.logger.ErrorLevel;
|
34
|
33
|
import com.dmdirc.logger.Logger;
|
|
34
|
+import com.dmdirc.ui.WindowManager;
|
35
|
35
|
import com.dmdirc.ui.input.TabCompletionType;
|
36
|
36
|
|
37
|
37
|
import java.util.ArrayList;
|
|
@@ -52,24 +52,28 @@ public class AliasWrapper extends ActionGroup {
|
52
|
52
|
private final CommandController commandController;
|
53
|
53
|
|
54
|
54
|
/** Server Manager. */
|
55
|
|
- private final ServerManager serverManager;
|
|
55
|
+ private final WindowManager windowManager;
|
56
|
56
|
|
57
|
57
|
/**
|
58
|
58
|
* Creates a new instance of AliasWrapper.
|
59
|
59
|
*
|
60
|
60
|
* @param commandController Command controller to get command info from.
|
|
61
|
+ * @param windowManager The window manager to use to find root windows.
|
61
|
62
|
*/
|
62
|
|
- public AliasWrapper(final CommandController commandController, final ServerManager serverManager) {
|
|
63
|
+ public AliasWrapper(
|
|
64
|
+ final CommandController commandController,
|
|
65
|
+ final WindowManager windowManager) {
|
63
|
66
|
super("aliases");
|
64
|
67
|
|
65
|
68
|
this.commandController = commandController;
|
66
|
|
- this.serverManager = serverManager;
|
|
69
|
+ this.windowManager = windowManager;
|
67
|
70
|
}
|
68
|
71
|
|
69
|
72
|
/**
|
70
|
73
|
* Retrieves a singleton instance of this alias wrapper.
|
71
|
74
|
*
|
72
|
75
|
* @return A singleton instance of AliasWrapper
|
|
76
|
+ * @deprecated Global state is bad.
|
73
|
77
|
*/
|
74
|
78
|
@Deprecated
|
75
|
79
|
public static AliasWrapper getAliasWrapper() {
|
|
@@ -80,6 +84,7 @@ public class AliasWrapper extends ActionGroup {
|
80
|
84
|
* Sets the alias wrapper that will be used as a singleton instance.
|
81
|
85
|
*
|
82
|
86
|
* @param wrapper The wrapper to use as a singleton.
|
|
87
|
+ * @deprecated Global state is bad.
|
83
|
88
|
*/
|
84
|
89
|
@Deprecated
|
85
|
90
|
public static void setAliasWrapper(final AliasWrapper wrapper) {
|
|
@@ -106,13 +111,11 @@ public class AliasWrapper extends ActionGroup {
|
106
|
111
|
super.add(action);
|
107
|
112
|
aliases.add(commandName);
|
108
|
113
|
|
109
|
|
- if (GlobalWindow.getGlobalWindow() != null) {
|
110
|
|
- GlobalWindow.getGlobalWindow().getTabCompleter()
|
111
|
|
- .addEntry(TabCompletionType.COMMAND, commandName);
|
112
|
|
- }
|
113
|
|
-
|
114
|
|
- for (Server server : serverManager.getServers()) {
|
115
|
|
- server.getTabCompleter().addEntry(TabCompletionType.COMMAND, commandName);
|
|
114
|
+ for (FrameContainer root : windowManager.getRootWindows()) {
|
|
115
|
+ if (root instanceof WritableFrameContainer) {
|
|
116
|
+ ((WritableFrameContainer) root).getTabCompleter()
|
|
117
|
+ .addEntry(TabCompletionType.COMMAND, commandName);
|
|
118
|
+ }
|
116
|
119
|
}
|
117
|
120
|
} else {
|
118
|
121
|
Logger.userError(ErrorLevel.MEDIUM, "Invalid alias action (no name): "
|
|
@@ -134,8 +137,11 @@ public class AliasWrapper extends ActionGroup {
|
134
|
137
|
|
135
|
138
|
aliases.remove(commandName);
|
136
|
139
|
|
137
|
|
- for (Server server : serverManager.getServers()) {
|
138
|
|
- server.getTabCompleter().removeEntry(TabCompletionType.COMMAND, commandName);
|
|
140
|
+ for (FrameContainer root : windowManager.getRootWindows()) {
|
|
141
|
+ if (root instanceof WritableFrameContainer) {
|
|
142
|
+ ((WritableFrameContainer) root).getTabCompleter()
|
|
143
|
+ .removeEntry(TabCompletionType.COMMAND, commandName);
|
|
144
|
+ }
|
139
|
145
|
}
|
140
|
146
|
}
|
141
|
147
|
}
|