Browse Source

Remove horrible SwingController lookups.

Change-Id: I4d45e014c4a18ec6ee2e6835a0a423c7f16c2f55
Reviewed-on: http://gerrit.dmdirc.com/2858
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith 10 years ago
parent
commit
adced3940d

+ 10
- 5
src/com/dmdirc/addons/nickcolours/NickColourInputDialog.java View File

@@ -66,6 +66,7 @@ public class NickColourInputDialog extends StandardDialog
66 66
     /**
67 67
      * Creates a new instance of NickColourInputDialog.
68 68
      *
69
+     * @param swingController The controller that owns this dialog.
69 70
      * @param panel The panel that's opening this dialog
70 71
      * @param row The row of the table we're editing
71 72
      * @param nickname The nickname that's currently set
@@ -73,11 +74,12 @@ public class NickColourInputDialog extends StandardDialog
73 74
      * @param textcolour The text colour that's currently set
74 75
      * @param nickcolour The nicklist colour that's currently set
75 76
      */
76
-    public NickColourInputDialog(final NickColourPanel panel, final int row,
77
+    public NickColourInputDialog(
78
+            final SwingController swingController,
79
+            final NickColourPanel panel, final int row,
77 80
             final String nickname, final String network,
78 81
             final String textcolour, final String nickcolour) {
79
-        super(((SwingController) panel.getPlugin().getPluginInfo().getMetaData().getManager()
80
-                .getPluginInfoByName("ui_swing").getPlugin()), false);
82
+        super(swingController, false);
81 83
 
82 84
         this.panel = panel;
83 85
         this.row = row;
@@ -95,10 +97,13 @@ public class NickColourInputDialog extends StandardDialog
95 97
     /**
96 98
      * Creates a new instance of NickColourInputDialog.
97 99
      *
100
+     * @param swingController The controller that owns this dialog.
98 101
      * @param panel The panel that's opening this dialog
99 102
      */
100
-    public NickColourInputDialog(final NickColourPanel panel) {
101
-        this(panel, -1, "", "", "", "");
103
+    public NickColourInputDialog(
104
+            final SwingController swingController,
105
+            final NickColourPanel panel) {
106
+        this(swingController, panel, -1, "", "", "", "");
102 107
 
103 108
         isnew = true;
104 109
     }

+ 10
- 5
src/com/dmdirc/addons/nickcolours/NickColourPanel.java View File

@@ -57,15 +57,19 @@ public class NickColourPanel extends JPanel implements ActionListener,
57 57
      * objects being unserialized with the new class).
58 58
      */
59 59
     private static final long serialVersionUID = 1;
60
+
61
+    /** The table headings. */
62
+    private static final String[] HEADERS =
63
+            {"Network", "Nickname", "Text colour", "Nicklist colour"};
64
+
60 65
     /** The table used for displaying the options. */
61 66
     private final JTable table;
62 67
     /** The plugin we're associated with. */
63 68
     private final transient NickColourPlugin plugin;
64 69
     /** The identity to write settings to. */
65 70
     private final ConfigProvider configIdentity;
66
-    /** The table headings. */
67
-    private static final String[] HEADERS = {"Network", "Nickname",
68
-        "Text colour", "Nicklist colour"};
71
+    /** The controller that owns this dialog. */
72
+    private final SwingController swingController;
69 73
 
70 74
     /** Edit and delete buttons. */
71 75
     private final JButton editButton, deleteButton;
@@ -83,6 +87,7 @@ public class NickColourPanel extends JPanel implements ActionListener,
83 87
             final ColourManager colourManager) {
84 88
         this.plugin = plugin;
85 89
         this.configIdentity = controller.getIdentityManager().getUserSettings();
90
+        this.swingController = controller;
86 91
 
87 92
         final Object[][] data = plugin.getData();
88 93
 
@@ -159,7 +164,7 @@ public class NickColourPanel extends JPanel implements ActionListener,
159 164
     @Override
160 165
     public void actionPerformed(final ActionEvent e) {
161 166
         if (e.getActionCommand().equals("Add")) {
162
-            new NickColourInputDialog(this);
167
+            new NickColourInputDialog(swingController, this);
163 168
         } else if (e.getActionCommand().equals("Edit")) {
164 169
             final DefaultTableModel model
165 170
                     = ((DefaultTableModel) table.getModel());
@@ -179,7 +184,7 @@ public class NickColourPanel extends JPanel implements ActionListener,
179 184
                 nickcolour = "";
180 185
             }
181 186
 
182
-            new NickColourInputDialog(this, row, nickname, network, textcolour,
187
+            new NickColourInputDialog(swingController, this, row, nickname, network, textcolour,
183 188
                     nickcolour);
184 189
         } else if (e.getActionCommand().equals("Delete")) {
185 190
             final int row = table.getSelectedRow();

+ 4
- 4
src/com/dmdirc/addons/nickcolours/NickColourPlugin.java View File

@@ -76,6 +76,8 @@ public class NickColourPlugin extends BasePlugin implements ActionListener, Conf
76 76
     private final IdentityController identityController;
77 77
     /** Manager to parse colours with. */
78 78
     private final ColourManager colourManager;
79
+    /** The swing controller to use. */
80
+    private final SwingController swingController;
79 81
 
80 82
     /** {@inheritDoc} */
81 83
     @Override
@@ -264,10 +266,8 @@ public class NickColourPlugin extends BasePlugin implements ActionListener, Conf
264 266
                     /** {@inheritDoc} */
265 267
                     @Override
266 268
                     public NickColourPanel call() {
267
-                        return new NickColourPanel(
268
-                                (SwingController) pluginInfo.getMetaData().getManager()
269
-                                .getPluginInfoByName("ui_swing").getPlugin(),
270
-                                NickColourPlugin.this, colourManager);
269
+                        return new NickColourPanel(swingController, NickColourPlugin.this,
270
+                                colourManager);
271 271
                     }
272 272
                 }));
273 273
 

+ 6
- 1
src/com/dmdirc/addons/osd/OsdManager.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.osd;
24 24
 
25
+import com.dmdirc.addons.ui_swing.MainFrame;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.interfaces.config.IdentityController;
27 28
 import com.dmdirc.ui.messages.ColourManager;
@@ -42,6 +43,8 @@ import lombok.RequiredArgsConstructor;
42 43
 @RequiredArgsConstructor
43 44
 public class OsdManager {
44 45
 
46
+    /** The window the OSD will be associated with. */
47
+    private final MainFrame mainFrame;
45 48
     /** The controller to read/write settings with. */
46 49
     private final IdentityController identityController;
47 50
     /** The Plugin that owns this OSD Manager. */
@@ -102,7 +105,9 @@ public class OsdManager {
102 105
             /** {@inheritDoc} */
103 106
             @Override
104 107
             public OsdWindow call() {
105
-                return new OsdWindow(identityController, plugin, OsdManager.this, colourManager,
108
+                return new OsdWindow(
109
+                        mainFrame,
110
+                        identityController, plugin, OsdManager.this, colourManager,
106 111
                         timeout, message, false,
107 112
                         identityController.getGlobalConfiguration().getOptionInt(
108 113
                         plugin.getDomain(), "locationX"), policy.getYPosition(

+ 11
- 3
src/com/dmdirc/addons/osd/OsdPlugin.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.osd;
24 24
 
25
+import com.dmdirc.addons.ui_swing.MainFrame;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25 27
 import com.dmdirc.config.prefs.CategoryChangeListener;
26 28
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
27 29
 import com.dmdirc.config.prefs.PreferencesCategory;
@@ -64,25 +66,29 @@ public class OsdPlugin extends BaseCommandPlugin implements
64 66
     private final IdentityController identityController;
65 67
     /** The manager to use to parse colours. */
66 68
     private final ColourManager colourManager;
69
+    /** The window that the OSDs will be associated with. */
70
+    private final MainFrame mainFrame;
67 71
 
68 72
     /**
69 73
      * Creates a new instance of this plugin.
70 74
      *
75
+     * @param swingController The controller that owns this plugin.
71 76
      * @param pluginInfo This plugin's plugin info
72 77
      * @param identityController The controller to use to read and write settings.
73 78
      * @param commandController Command controller to register commands
74 79
      * @param colourManager The manager to use to parse colours.
75 80
      */
76 81
     public OsdPlugin(
82
+            final SwingController swingController,
77 83
             final PluginInfo pluginInfo,
78 84
             final IdentityController identityController,
79 85
             final CommandController commandController,
80 86
             final ColourManager colourManager) {
81
-        super(commandController);
82 87
         this.pluginInfo = pluginInfo;
83 88
         this.identityController = identityController;
84 89
         this.colourManager = colourManager;
85
-        osdManager = new OsdManager(identityController, this, colourManager);
90
+        this.mainFrame = swingController.getMainFrame();
91
+        osdManager = new OsdManager(mainFrame, identityController, this, colourManager);
86 92
         registerCommand(new OsdCommand(commandController, osdManager), OsdCommand.INFO);
87 93
     }
88 94
 
@@ -161,7 +167,9 @@ public class OsdPlugin extends BaseCommandPlugin implements
161 167
     /** {@inheritDoc} */
162 168
     @Override
163 169
     public void categorySelected(final PreferencesCategory category) {
164
-        osdWindow = new OsdWindow(identityController, this, osdManager, colourManager, -1,
170
+        osdWindow = new OsdWindow(
171
+                mainFrame,
172
+                identityController, this, osdManager, colourManager, -1,
165 173
                 "Please drag this OSD to position", true, x, y);
166 174
         osdWindow.setBackgroundColour(backgroundSetting.getValue());
167 175
         osdWindow.setForegroundColour(foregroundSetting.getValue());

+ 4
- 3
src/com/dmdirc/addons/osd/OsdWindow.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.osd;
24 24
 
25
-import com.dmdirc.addons.ui_swing.SwingController;
25
+import com.dmdirc.addons.ui_swing.MainFrame;
26 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27 27
 import com.dmdirc.interfaces.config.IdentityController;
28 28
 import com.dmdirc.ui.Colour;
@@ -87,6 +87,7 @@ public class OsdWindow extends JDialog implements MouseListener,
87 87
     /**
88 88
      * Creates a new instance of OsdWindow.
89 89
      *
90
+     * @param mainFrame The window to associate with.
90 91
      * @param identityController The controller to read/write settings with.
91 92
      * @param colourManager The manager to use to parse colours.
92 93
      * @param timeout Timeout period for the window. Set to -1 to use value from
@@ -100,12 +101,12 @@ public class OsdWindow extends JDialog implements MouseListener,
100 101
      * @param osdManager The manager that owns this OSD Window
101 102
      */
102 103
     public OsdWindow(
104
+            final MainFrame mainFrame,
103 105
             final IdentityController identityController, final OsdPlugin plugin,
104 106
             final OsdManager osdManager, final ColourManager colourManager,
105 107
             final int timeout, final String text, final boolean config, final int x,
106 108
             final int y) {
107
-        super(((SwingController) plugin.getPluginInfo().getMetaData().getManager()
108
-                .getPluginInfoByName("ui_swing").getPlugin()).getMainFrame(), false);
109
+        super(mainFrame, false);
109 110
 
110 111
         this.colourManager = colourManager;
111 112
         this.config = config;

+ 3
- 5
src/com/dmdirc/addons/serverlistdialog/ServerListDialogPlugin.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.serverlistdialog;
24 24
 
25 25
 import com.dmdirc.actions.wrappers.PerformWrapper;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27
-import com.dmdirc.plugins.PluginManager;
28 27
 import com.dmdirc.plugins.implementations.BasePlugin;
29 28
 
30 29
 import java.awt.event.ActionEvent;
@@ -46,16 +45,15 @@ public class ServerListDialogPlugin extends BasePlugin implements ActionListener
46 45
     /**
47 46
      * Creates a new server list dialog plugin.
48 47
      *
49
-     * @param pluginManager The plugin manager to use to find the Swing UI.
48
+     * @param swingController The controller that will own the dialog.
50 49
      * @param performWrapper The wrapper to use for modifying performs.
51 50
      */
52 51
     public ServerListDialogPlugin(
53
-            final PluginManager pluginManager,
52
+            final SwingController swingController,
54 53
             final PerformWrapper performWrapper) {
55 54
         this.performWrapper = performWrapper;
56 55
 
57
-        controller = (SwingController) pluginManager.getPluginInfoByName(
58
-                "ui_swing").getPlugin();
56
+        controller = swingController;
59 57
         final JMenuItem item = new JMenuItem("Server lists");
60 58
         item.setMnemonic('l');
61 59
         item.addActionListener(this);

+ 6
- 11
src/com/dmdirc/addons/systray/SystrayPlugin.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.systray;
24 24
 
25 25
 import com.dmdirc.actions.CoreActionType;
26
-import com.dmdirc.interfaces.actions.ActionType;
27 26
 import com.dmdirc.addons.ui_swing.MainFrame;
28 27
 import com.dmdirc.addons.ui_swing.SwingController;
29 28
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
@@ -32,7 +31,7 @@ import com.dmdirc.config.prefs.PreferencesDialogModel;
32 31
 import com.dmdirc.config.prefs.PreferencesSetting;
33 32
 import com.dmdirc.config.prefs.PreferencesType;
34 33
 import com.dmdirc.interfaces.ActionController;
35
-import com.dmdirc.interfaces.CommandController;
34
+import com.dmdirc.interfaces.actions.ActionType;
36 35
 import com.dmdirc.interfaces.config.IdentityController;
37 36
 import com.dmdirc.plugins.PluginInfo;
38 37
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
@@ -56,13 +55,13 @@ import java.awt.event.MouseListener;
56 55
  * The Systray plugin shows DMDirc in the user's system tray, and allows
57 56
  * notifications to be disabled.
58 57
  */
59
-public final class SystrayPlugin extends BaseCommandPlugin implements
58
+public class SystrayPlugin extends BaseCommandPlugin implements
60 59
         ActionListener, MouseListener, com.dmdirc.interfaces.ActionListener {
61 60
 
62 61
     /** The tray icon we're currently using. */
63 62
     private final TrayIcon icon;
64 63
     /** Main frame instance. */
65
-    private MainFrame mainFrame;
64
+    private final MainFrame mainFrame;
66 65
     /** This plugin's plugin info. */
67 66
     private final PluginInfo pluginInfo;
68 67
     /** The action controller to use. */
@@ -73,23 +72,22 @@ public final class SystrayPlugin extends BaseCommandPlugin implements
73 72
     /**
74 73
      * Creates a new system tray plugin.
75 74
      *
75
+     * @param swingController The controller that owns this plugin.
76 76
      * @param pluginInfo This plugin's plugin info.
77 77
      * @param actionController The action controller to use.
78 78
      * @param identityController The identity manager to read settings from.
79
-     * @param commandController Command controller to register commands.
80 79
      * @param urlBuilder URL builder to use to resolve icon paths.
81 80
      */
82 81
     public SystrayPlugin(
82
+            final SwingController swingController,
83 83
             final PluginInfo pluginInfo,
84 84
             final ActionController actionController,
85 85
             final IdentityController identityController,
86
-            final CommandController commandController,
87 86
             final URLBuilder urlBuilder) {
88
-        super(commandController);
89
-
90 87
         this.pluginInfo = pluginInfo;
91 88
         this.actionController = actionController;
92 89
         this.identityController = identityController;
90
+        this.mainFrame = swingController.getMainFrame();
93 91
 
94 92
         final MenuItem show = new MenuItem("Show/hide");
95 93
         final MenuItem quit = new MenuItem("Quit");
@@ -171,9 +169,6 @@ public final class SystrayPlugin extends BaseCommandPlugin implements
171 169
         boolean continueLoading = true;
172 170
         try {
173 171
             SystemTray.getSystemTray().add(icon);
174
-            mainFrame = ((SwingController) pluginInfo.getMetaData().getManager()
175
-                    .getPluginInfoByName("ui_swing").getPlugin())
176
-                    .getMainFrame();
177 172
             actionController.registerListener(this, CoreActionType.CLIENT_MINIMISED);
178 173
         } catch (AWTException ex) {
179 174
             continueLoading = false;

Loading…
Cancel
Save