|
@@ -22,20 +22,18 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.actions.wrappers.AliasWrapper;
|
26
|
|
-import com.dmdirc.commandparser.CommandManager;
|
|
25
|
+import com.dmdirc.ClientModule.GlobalConfig;
|
27
|
26
|
import com.dmdirc.commandparser.CommandType;
|
28
|
27
|
import com.dmdirc.commandparser.parsers.CommandParser;
|
29
|
28
|
import com.dmdirc.commandparser.parsers.GlobalCommandParser;
|
30
|
29
|
import com.dmdirc.interfaces.CommandController;
|
31
|
30
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
32
|
31
|
import com.dmdirc.interfaces.config.ConfigChangeListener;
|
33
|
|
-import com.dmdirc.interfaces.config.IdentityController;
|
34
|
32
|
import com.dmdirc.messages.MessageSinkManager;
|
35
|
33
|
import com.dmdirc.ui.WindowManager;
|
36
|
34
|
import com.dmdirc.ui.core.components.WindowComponent;
|
37
|
35
|
import com.dmdirc.ui.input.TabCompleter;
|
38
|
|
-import com.dmdirc.ui.input.TabCompletionType;
|
|
36
|
+import com.dmdirc.ui.input.TabCompleterFactory;
|
39
|
37
|
|
40
|
38
|
import java.util.Arrays;
|
41
|
39
|
|
|
@@ -55,6 +53,7 @@ public class GlobalWindow extends WritableFrameContainer {
|
55
|
53
|
|
56
|
54
|
/** The tab completer we use. */
|
57
|
55
|
@Getter
|
|
56
|
+ @SuppressWarnings("PMD.UnusedPrivateField")
|
58
|
57
|
private final TabCompleter tabCompleter;
|
59
|
58
|
|
60
|
59
|
/**
|
|
@@ -63,23 +62,21 @@ public class GlobalWindow extends WritableFrameContainer {
|
63
|
62
|
* @param config The ConfigManager to retrieve settings from.
|
64
|
63
|
* @param parser The command parser to use to parse input.
|
65
|
64
|
* @param windowManager The window manager.
|
|
65
|
+ * @param tabCompleterFactory The factory to use to create tab completers.
|
66
|
66
|
* @param messageSinkManager The sink manager to use to despatch messages.
|
67
|
67
|
*/
|
68
|
68
|
public GlobalWindow(
|
69
|
69
|
final AggregateConfigProvider config,
|
70
|
70
|
final CommandParser parser,
|
71
|
71
|
final WindowManager windowManager,
|
|
72
|
+ final TabCompleterFactory tabCompleterFactory,
|
72
|
73
|
final MessageSinkManager messageSinkManager) {
|
73
|
74
|
super("icon", "Global", "(Global)", config, parser, messageSinkManager, windowManager,
|
74
|
75
|
Arrays.asList(
|
75
|
76
|
WindowComponent.TEXTAREA.getIdentifier(),
|
76
|
77
|
WindowComponent.INPUTFIELD.getIdentifier()));
|
77
|
78
|
|
78
|
|
- tabCompleter = new TabCompleter(config);
|
79
|
|
- tabCompleter.addEntries(TabCompletionType.COMMAND,
|
80
|
|
- CommandManager.getCommandManager().getCommandNames(CommandType.TYPE_GLOBAL));
|
81
|
|
- tabCompleter.addEntries(TabCompletionType.COMMAND,
|
82
|
|
- AliasWrapper.getAliasWrapper().getAliases());
|
|
79
|
+ tabCompleter = tabCompleterFactory.getTabCompleter(config, CommandType.TYPE_GLOBAL);
|
83
|
80
|
|
84
|
81
|
windowManager.addWindow(this);
|
85
|
82
|
}
|
|
@@ -124,6 +121,8 @@ public class GlobalWindow extends WritableFrameContainer {
|
124
|
121
|
|
125
|
122
|
/** The global configuration to read settings from. */
|
126
|
123
|
private final AggregateConfigProvider globalConfig;
|
|
124
|
+ /** The factory to use to create tab completers. */
|
|
125
|
+ private final TabCompleterFactory tabCompleterFactory;
|
127
|
126
|
/** The provider to use to retrieve a command controller. */
|
128
|
127
|
private final Provider<CommandController> commandControllerProvider;
|
129
|
128
|
/** The provider to use to retrieve a window manager. */
|
|
@@ -134,18 +133,21 @@ public class GlobalWindow extends WritableFrameContainer {
|
134
|
133
|
/**
|
135
|
134
|
* Creates a new instance of {@link GlobalWindowManager}.
|
136
|
135
|
*
|
137
|
|
- * @param identityController Controller to retrieve global configuration from.
|
|
136
|
+ * @param globalConfig Configuration provider to read settings from.
|
|
137
|
+ * @param tabCompleterFactory Factory to use to create tab completers.
|
138
|
138
|
* @param commandControllerProvider The provider to use to retrieve a command controller.
|
139
|
139
|
* @param windowManagerProvider The provider to use to retrieve a window manager.
|
140
|
140
|
* @param messageSinkManagerProvider The provider to use to retrieve a sink manager.
|
141
|
141
|
*/
|
142
|
142
|
@Inject
|
143
|
143
|
public GlobalWindowManager(
|
144
|
|
- final IdentityController identityController,
|
|
144
|
+ @GlobalConfig final AggregateConfigProvider globalConfig,
|
|
145
|
+ final TabCompleterFactory tabCompleterFactory,
|
145
|
146
|
final Provider<CommandController> commandControllerProvider,
|
146
|
147
|
final Provider<WindowManager> windowManagerProvider,
|
147
|
148
|
final Provider<MessageSinkManager> messageSinkManagerProvider) {
|
148
|
|
- this.globalConfig = identityController.getGlobalConfiguration();
|
|
149
|
+ this.globalConfig = globalConfig;
|
|
150
|
+ this.tabCompleterFactory = tabCompleterFactory;
|
149
|
151
|
this.commandControllerProvider = commandControllerProvider;
|
150
|
152
|
this.windowManagerProvider = windowManagerProvider;
|
151
|
153
|
this.messageSinkManagerProvider = messageSinkManagerProvider;
|
|
@@ -175,7 +177,8 @@ public class GlobalWindow extends WritableFrameContainer {
|
175
|
177
|
if (globalWindow == null) {
|
176
|
178
|
globalWindow = new GlobalWindow(globalConfig,
|
177
|
179
|
new GlobalCommandParser(globalConfig, commandControllerProvider.get()),
|
178
|
|
- windowManagerProvider.get(), messageSinkManagerProvider.get());
|
|
180
|
+ windowManagerProvider.get(), tabCompleterFactory,
|
|
181
|
+ messageSinkManagerProvider.get());
|
179
|
182
|
}
|
180
|
183
|
} else {
|
181
|
184
|
if (globalWindow != null) {
|