瀏覽代碼

Tidy up Channel/ServerSettings dependencies.

Pass in a SwingController instead of jumping through 3 million
hoops to try and find one. It's simpler that way.

Change-Id: Ie0f8fa459df2c280c17a7de4d0c49eaa29c1a219
Reviewed-on: http://gerrit.dmdirc.com/2660
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith 10 年之前
父節點
當前提交
311830260f

+ 2
- 2
src/com/dmdirc/addons/ui_swing/SwingController.java 查看文件

@@ -189,8 +189,8 @@ public class SwingController extends BaseCommandPlugin implements UIController {
189 189
         dialogManager = new DialogManager(this);
190 190
         setAntiAlias();
191 191
         windows = new ArrayList<java.awt.Window>();
192
-        registerCommand(new ServerSettings(), ServerSettings.INFO);
193
-        registerCommand(new ChannelSettings(), ChannelSettings.INFO);
192
+        registerCommand(new ServerSettings(this), ServerSettings.INFO);
193
+        registerCommand(new ChannelSettings(this), ChannelSettings.INFO);
194 194
         registerCommand(new Input(windowFactory), Input.INFO);
195 195
         registerCommand(new PopOutCommand(this), PopOutCommand.INFO);
196 196
         registerCommand(new PopInCommand(this), PopInCommand.INFO);

+ 15
- 6
src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java 查看文件

@@ -39,22 +39,31 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
39 39
  * Opens the channel settings window for the channel.
40 40
  */
41 41
 @CommandOptions(allowOffline = false)
42
-public class ChannelSettings extends Command implements
43
-        IntelligentCommand {
42
+public class ChannelSettings extends Command implements IntelligentCommand {
44 43
 
45 44
     /** A command info object for this command. */
46 45
     public static final CommandInfo INFO = new BaseCommandInfo("channelsettings",
47 46
             "channelsettings - opens the channel settings window",
48 47
             CommandType.TYPE_CHANNEL);
49 48
 
49
+    /** The controller to use to show the settings window. */
50
+    private final SwingController controller;
51
+
52
+    /**
53
+     * Creates a new instance of the {@link ChannelSettings} command.
54
+     *
55
+     * @param controller The controller to use to show the settings window.
56
+     */
57
+    public ChannelSettings(final SwingController controller) {
58
+        this.controller = controller;
59
+    }
60
+
50 61
     /** {@inheritDoc} */
51 62
     @Override
52 63
     public void execute(final FrameContainer origin,
53 64
             final CommandArguments args, final CommandContext context) {
54
-        ((SwingController) getController().getMain().getPluginManager()
55
-                .getPluginInfoByName("ui_swing").getPlugin())
56
-                .showChannelSettingsDialog(((ChannelCommandContext) context)
57
-                .getChannel());
65
+        controller.showChannelSettingsDialog(
66
+                ((ChannelCommandContext) context).getChannel());
58 67
     }
59 68
 
60 69
     /** {@inheritDoc} */

+ 13
- 3
src/com/dmdirc/addons/ui_swing/commands/ServerSettings.java 查看文件

@@ -47,13 +47,23 @@ public class ServerSettings extends Command implements IntelligentCommand {
47 47
             "serversettings - opens the server settings window",
48 48
             CommandType.TYPE_SERVER);
49 49
 
50
+    /** The controller to use to show the settings window. */
51
+    private final SwingController controller;
52
+
53
+    /**
54
+     * Creates a new instance of the {@link ServerSettings} command.
55
+     *
56
+     * @param controller The controller to use to show the settings window.
57
+     */
58
+    public ServerSettings(final SwingController controller) {
59
+        this.controller = controller;
60
+    }
61
+
50 62
     /** {@inheritDoc} */
51 63
     @Override
52 64
     public void execute(final FrameContainer origin,
53 65
             final CommandArguments args, final CommandContext context) {
54
-        ((SwingController) getController().getMain().getPluginManager()
55
-                .getPluginInfoByName("ui_swing").getPlugin())
56
-                .showServerSettingsDialog(context.getSource().getServer());
66
+        controller.showServerSettingsDialog(context.getSource().getServer());
57 67
     }
58 68
 
59 69
     /** {@inheritDoc} */

Loading…
取消
儲存