Browse Source

Desingleton PluginManager (and as a side-effect, ServerManager).

Depends-On: I4a3d9b78a5f80aab0330d0906e8c76d00813c97c
Change-Id: I72fe837b5ea2352ae0c695948336efcdd92c09c8
Reviewed-on: http://gerrit.dmdirc.com/2522
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1
Shane Mc Cormack 11 years ago
parent
commit
11e80671c4
58 changed files with 322 additions and 154 deletions
  1. 8
    0
      src/com/dmdirc/addons/lagdisplay/LagDisplayPlugin.java
  2. 1
    2
      src/com/dmdirc/addons/lagdisplay/ServerInfoDialog.java
  3. 20
    9
      src/com/dmdirc/addons/mediasource_dcop/AmarokSource.java
  4. 11
    7
      src/com/dmdirc/addons/mediasource_dcop/DcopMediaSourcePlugin.java
  5. 18
    9
      src/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java
  6. 17
    8
      src/com/dmdirc/addons/mediasource_dcop/NoatunSource.java
  7. 5
    2
      src/com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin.java
  8. 1
    2
      src/com/dmdirc/addons/nickcolours/NickColourInputDialog.java
  9. 9
    0
      src/com/dmdirc/addons/nickcolours/NickColourPanel.java
  10. 10
    2
      src/com/dmdirc/addons/nickcolours/NickColourPlugin.java
  11. 4
    5
      src/com/dmdirc/addons/notifications/NotificationsPlugin.java
  12. 1
    2
      src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java
  13. 9
    0
      src/com/dmdirc/addons/osd/OsdPlugin.java
  14. 1
    2
      src/com/dmdirc/addons/osd/OsdWindow.java
  15. 8
    8
      src/com/dmdirc/addons/parser_twitter/actions/TwitterActionComponents.java
  16. 13
    5
      src/com/dmdirc/addons/relaybot/RelayBotPlugin.java
  17. 1
    2
      src/com/dmdirc/addons/relaybot/RelayChannelHandler.java
  18. 1
    1
      src/com/dmdirc/addons/serverlistdialog/ServerListDialog.java
  19. 12
    3
      src/com/dmdirc/addons/serverlistdialog/ServerListModel.java
  20. 8
    2
      src/com/dmdirc/addons/serverlists/ServerEntry.java
  21. 12
    3
      src/com/dmdirc/addons/serverlists/ServerList.java
  22. 7
    2
      src/com/dmdirc/addons/serverlists/io/ServerEntryReader.java
  23. 3
    2
      src/com/dmdirc/addons/serverlists/io/ServerGroupReader.java
  24. 8
    3
      src/com/dmdirc/addons/serverlists/service/ServerListServiceProvider.java
  25. 1
    2
      src/com/dmdirc/addons/systray/SystrayPlugin.java
  26. 4
    2
      src/com/dmdirc/addons/ui_dummy/DummyChannelWindow.java
  27. 12
    1
      src/com/dmdirc/addons/ui_dummy/DummyController.java
  28. 5
    2
      src/com/dmdirc/addons/ui_dummy/DummyInputHandler.java
  29. 7
    3
      src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java
  30. 6
    4
      src/com/dmdirc/addons/ui_swing/Apple.java
  31. 1
    2
      src/com/dmdirc/addons/ui_swing/MainFrame.java
  32. 1
    1
      src/com/dmdirc/addons/ui_swing/SwingController.java
  33. 1
    2
      src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java
  34. 1
    2
      src/com/dmdirc/addons/ui_swing/commands/ServerSettings.java
  35. 1
    1
      src/com/dmdirc/addons/ui_swing/components/TopicBar.java
  36. 2
    3
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorker.java
  37. 1
    2
      src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonToggle.java
  38. 2
    3
      src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java
  39. 1
    1
      src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java
  40. 5
    2
      src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java
  41. 1
    2
      src/com/dmdirc/addons/ui_swing/components/menubar/HelpMenu.java
  42. 1
    2
      src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java
  43. 1
    2
      src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java
  44. 4
    5
      src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java
  45. 1
    2
      src/com/dmdirc/addons/ui_swing/dialogs/about/AboutDialog.java
  46. 6
    3
      src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java
  47. 7
    3
      src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java
  48. 2
    2
      src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java
  49. 1
    1
      src/com/dmdirc/addons/ui_swing/dialogs/paste/PasteDialog.java
  50. 2
    1
      src/com/dmdirc/addons/ui_web/DynamicRequestHandler.java
  51. 12
    2
      src/com/dmdirc/addons/ui_web/StaticRequestHandler.java
  52. 15
    2
      src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java
  53. 13
    2
      src/com/dmdirc/addons/ui_web/WebInterfaceUI.java
  54. 4
    2
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java
  55. 5
    2
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java
  56. 4
    3
      src/com/dmdirc/addons/userlevel/AccessLevelComponent.java
  57. 3
    2
      src/com/dmdirc/addons/userlevel/ChannelAccessLevelComponent.java
  58. 1
    2
      src/com/dmdirc/addons/windowstatus/WindowStatusPlugin.java

+ 8
- 0
src/com/dmdirc/addons/lagdisplay/LagDisplayPlugin.java View File

@@ -89,6 +89,14 @@ public final class LagDisplayPlugin extends BasePlugin implements
89 89
         panel = new LagDisplayPanel(this, controller);
90 90
     }
91 91
 
92
+    /**
93
+     * Get our PluginInfo.
94
+     * @return Our PluginInfo.
95
+     */
96
+    public PluginInfo getPluginInfo() {
97
+        return pluginInfo;
98
+    }
99
+
92 100
     /** {@inheritDoc} */
93 101
     @Override
94 102
     public void onLoad() {

+ 1
- 2
src/com/dmdirc/addons/lagdisplay/ServerInfoDialog.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.lagdisplay;
24 24
 
25 25
 import com.dmdirc.Server;
26
-import com.dmdirc.ServerManager;
27 26
 import com.dmdirc.ServerState;
28 27
 import com.dmdirc.addons.ui_swing.MainFrame;
29 28
 import com.dmdirc.addons.ui_swing.SwingController;
@@ -74,7 +73,7 @@ public class ServerInfoDialog extends StatusbarPopupWindow {
74 73
     /** {@inheritDoc} */
75 74
     @Override
76 75
     protected void initContent(final JPanel panel) {
77
-        final List<Server> servers = ServerManager.getServerManager().getServers();
76
+        final List<Server> servers = getController().getMain().getServerManager().getServers();
78 77
 
79 78
         if (servers.isEmpty()) {
80 79
             panel.add(new JLabel("No open servers."));

+ 20
- 9
src/com/dmdirc/addons/mediasource_dcop/AmarokSource.java View File

@@ -32,10 +32,22 @@ import java.util.List;
32 32
  */
33 33
 public class AmarokSource implements MediaSource {
34 34
 
35
+    /** Our parent plugin. */
36
+    private final DcopMediaSourcePlugin myPlugin;
37
+
38
+    /**
39
+     * Create a new instance of this source.
40
+     *
41
+     * @param myPlugin The plugin that owns this source.
42
+     */
43
+    public AmarokSource(final DcopMediaSourcePlugin myPlugin) {
44
+        this.myPlugin = myPlugin;
45
+    }
46
+
35 47
     /** {@inheritDoc} */
36 48
     @Override
37 49
     public MediaSourceState getState() {
38
-        final List<String> res = DcopMediaSourcePlugin.getDcopResult("dcop amarok player status");
50
+        final List<String> res = myPlugin.getDcopResult("dcop amarok player status");
39 51
         if (res.isEmpty()) {
40 52
             return MediaSourceState.CLOSED;
41 53
         } else {
@@ -67,44 +79,43 @@ public class AmarokSource implements MediaSource {
67 79
     /** {@inheritDoc} */
68 80
     @Override
69 81
     public String getArtist() {
70
-        return DcopMediaSourcePlugin.getDcopResult("dcop amarok player artist").get(0);
82
+        return myPlugin.getDcopResult("dcop amarok player artist").get(0);
71 83
     }
72 84
 
73 85
     /** {@inheritDoc} */
74 86
     @Override
75 87
     public String getTitle() {
76
-        return DcopMediaSourcePlugin.getDcopResult("dcop amarok player title").get(0);
88
+        return myPlugin.getDcopResult("dcop amarok player title").get(0);
77 89
     }
78 90
 
79 91
     /** {@inheritDoc} */
80 92
     @Override
81 93
     public String getAlbum() {
82
-        return DcopMediaSourcePlugin.getDcopResult("dcop amarok player album").get(0);
94
+        return myPlugin.getDcopResult("dcop amarok player album").get(0);
83 95
     }
84 96
 
85 97
     /** {@inheritDoc} */
86 98
     @Override
87 99
     public String getLength() {
88
-        return DcopMediaSourcePlugin.getDcopResult("dcop amarok player totalTime").get(0);
100
+        return myPlugin.getDcopResult("dcop amarok player totalTime").get(0);
89 101
     }
90 102
 
91 103
     /** {@inheritDoc} */
92 104
     @Override
93 105
     public String getTime() {
94
-        return DcopMediaSourcePlugin.getDcopResult(
95
-                "dcop amarok player currentTime").get(0);
106
+        return myPlugin.getDcopResult("dcop amarok player currentTime").get(0);
96 107
     }
97 108
 
98 109
     /** {@inheritDoc} */
99 110
     @Override
100 111
     public String getFormat() {
101
-        return DcopMediaSourcePlugin.getDcopResult("dcop amarok player type").get(0);
112
+        return myPlugin.getDcopResult("dcop amarok player type").get(0);
102 113
     }
103 114
 
104 115
     /** {@inheritDoc} */
105 116
     @Override
106 117
     public String getBitrate() {
107
-        return DcopMediaSourcePlugin.getDcopResult("dcop amarok player bitrate").get(0);
118
+        return myPlugin.getDcopResult("dcop amarok player bitrate").get(0);
108 119
     }
109 120
 
110 121
 }

+ 11
- 7
src/com/dmdirc/addons/mediasource_dcop/DcopMediaSourcePlugin.java View File

@@ -40,15 +40,19 @@ public class DcopMediaSourcePlugin extends BasePlugin
40 40
     /** Media sources. */
41 41
     private final List<MediaSource> sources;
42 42
 
43
+    /** This plugins plugin manager. */
44
+    private final PluginManager pluginManager;
45
+
43 46
     /**
44 47
      * Creates a new instance of DcopMediaSourcePlugin.
45 48
      */
46
-    public DcopMediaSourcePlugin() {
49
+    public DcopMediaSourcePlugin(final PluginManager pluginManager) {
47 50
         super();
51
+        this.pluginManager = pluginManager;
48 52
         sources = new ArrayList<MediaSource>();
49
-        sources.add(new AmarokSource());
50
-        sources.add(new KaffeineSource());
51
-        sources.add(new NoatunSource());
53
+        sources.add(new AmarokSource(this));
54
+        sources.add(new KaffeineSource(this));
55
+        sources.add(new NoatunSource(this));
52 56
     }
53 57
 
54 58
     /**
@@ -58,10 +62,10 @@ public class DcopMediaSourcePlugin extends BasePlugin
58 62
      * @return The result of the dcop query, line-by-line
59 63
      */
60 64
     @SuppressWarnings("unchecked")
61
-    protected static List<String> getDcopResult(final String query) {
65
+    protected List<String> getDcopResult(final String query) {
62 66
         try {
63
-            return (List<String>) PluginManager.getPluginManager()
64
-                    .getExportedService("dcop").execute(query);
67
+            return (List<String>) pluginManager.getExportedService("dcop")
68
+                    .execute(query);
65 69
         } catch (NoSuchProviderException nspe) {
66 70
             return new ArrayList<String>();
67 71
         }

+ 18
- 9
src/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java View File

@@ -32,10 +32,22 @@ import java.util.List;
32 32
  */
33 33
 public class KaffeineSource implements MediaSource {
34 34
 
35
+    /** Our parent plugin. */
36
+    private final DcopMediaSourcePlugin myPlugin;
37
+
38
+    /**
39
+     * Create a new instance of this source.
40
+     *
41
+     * @param myPlugin The plugin that owns this source.
42
+     */
43
+    public KaffeineSource(final DcopMediaSourcePlugin myPlugin) {
44
+        this.myPlugin = myPlugin;
45
+    }
46
+
35 47
     /** {@inheritDoc} */
36 48
     @Override
37 49
     public MediaSourceState getState() {
38
-        final List<String> res = DcopMediaSourcePlugin.getDcopResult("dcop kaffeine KaffeineIface isPlaying");
50
+        final List<String> res = myPlugin.getDcopResult("dcop kaffeine KaffeineIface isPlaying");
39 51
         if (res.isEmpty()) {
40 52
             return MediaSourceState.CLOSED;
41 53
         } else {
@@ -57,35 +69,32 @@ public class KaffeineSource implements MediaSource {
57 69
     /** {@inheritDoc} */
58 70
     @Override
59 71
     public String getArtist() {
60
-        return DcopMediaSourcePlugin.getDcopResult(
61
-                "dcop kaffeine KaffeineIface artist").get(0);
72
+        return myPlugin.getDcopResult("dcop kaffeine KaffeineIface artist").get(0);
62 73
     }
63 74
 
64 75
     /** {@inheritDoc} */
65 76
     @Override
66 77
     public String getTitle() {
67
-        return DcopMediaSourcePlugin.getDcopResult(
68
-                "dcop kaffeine KaffeineIface title").get(0);
78
+        return myPlugin.getDcopResult("dcop kaffeine KaffeineIface title").get(0);
69 79
     }
70 80
 
71 81
     /** {@inheritDoc} */
72 82
     @Override
73 83
     public String getAlbum() {
74
-        return DcopMediaSourcePlugin.getDcopResult(
75
-                "dcop kaffeine KaffeineIface album").get(0);
84
+        return myPlugin.getDcopResult("dcop kaffeine KaffeineIface album").get(0);
76 85
     }
77 86
 
78 87
     /** {@inheritDoc} */
79 88
     @Override
80 89
     public String getLength() {
81
-        return duration(Integer.parseInt(DcopMediaSourcePlugin.getDcopResult(
90
+        return duration(Integer.parseInt(myPlugin.getDcopResult(
82 91
                 "dcop kaffeine KaffeineIface getLength").get(0)));
83 92
     }
84 93
 
85 94
     /** {@inheritDoc} */
86 95
     @Override
87 96
     public String getTime() {
88
-        return duration(Integer.parseInt(DcopMediaSourcePlugin.getDcopResult(
97
+        return duration(Integer.parseInt(myPlugin.getDcopResult(
89 98
                 "dcop kaffeine KaffeineIface getTimePos").get(0)));
90 99
     }
91 100
 

+ 17
- 8
src/com/dmdirc/addons/mediasource_dcop/NoatunSource.java View File

@@ -32,10 +32,22 @@ import java.util.List;
32 32
  */
33 33
 public class NoatunSource implements MediaSource {
34 34
 
35
+    /** Our parent plugin. */
36
+    private final DcopMediaSourcePlugin myPlugin;
37
+
38
+    /**
39
+     * Create a new instance of this source.
40
+     *
41
+     * @param myPlugin The plugin that owns this source.
42
+     */
43
+    public NoatunSource(final DcopMediaSourcePlugin myPlugin) {
44
+        this.myPlugin = myPlugin;
45
+    }
46
+
35 47
     /** {@inheritDoc} */
36 48
     @Override
37 49
     public MediaSourceState getState() {
38
-        final List<String> res = DcopMediaSourcePlugin.getDcopResult("dcop noatun Noatun state");
50
+        final List<String> res = myPlugin.getDcopResult("dcop noatun Noatun state");
39 51
         if (res.isEmpty()) {
40 52
             return MediaSourceState.CLOSED;
41 53
         } else {
@@ -67,8 +79,7 @@ public class NoatunSource implements MediaSource {
67 79
     /** {@inheritDoc} */
68 80
     @Override
69 81
     public String getArtist() {
70
-        final String result = DcopMediaSourcePlugin.getDcopResult(
71
-                "dcop noatun Noatun title").get(0);
82
+        final String result = myPlugin.getDcopResult("dcop noatun Noatun title").get(0);
72 83
         if (result.indexOf(" - ") == -1) {
73 84
             return "";
74 85
         }
@@ -78,8 +89,7 @@ public class NoatunSource implements MediaSource {
78 89
     /** {@inheritDoc} */
79 90
     @Override
80 91
     public String getTitle() {
81
-        final String result = DcopMediaSourcePlugin.getDcopResult(
82
-                "dcop noatun Noatun title").get(0);
92
+        final String result = myPlugin.getDcopResult("dcop noatun Noatun title").get(0);
83 93
         if (result.indexOf(" - ") == -1) {
84 94
             return "";
85 95
         }
@@ -95,14 +105,13 @@ public class NoatunSource implements MediaSource {
95 105
     /** {@inheritDoc} */
96 106
     @Override
97 107
     public String getLength() {
98
-        return DcopMediaSourcePlugin.getDcopResult(
99
-                "dcop noatun Noatun lengthString").get(0);
108
+        return myPlugin.getDcopResult("dcop noatun Noatun lengthString").get(0);
100 109
     }
101 110
 
102 111
     /** {@inheritDoc} */
103 112
     @Override
104 113
     public String getTime() {
105
-        return duration(Integer.parseInt(DcopMediaSourcePlugin.getDcopResult(
114
+        return duration(Integer.parseInt(myPlugin.getDcopResult(
106 115
                 "dcop noatun Noatun position").get(0)) /1000);
107 116
     }
108 117
 

+ 5
- 2
src/com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin.java View File

@@ -28,7 +28,6 @@ import com.dmdirc.logger.ErrorLevel;
28 28
 import com.dmdirc.logger.Logger;
29 29
 import com.dmdirc.plugins.BaseFileDependantPlugin;
30 30
 import com.dmdirc.plugins.PluginInfo;
31
-import com.dmdirc.plugins.PluginManager;
32 31
 import com.dmdirc.util.io.StreamReader;
33 32
 import com.dmdirc.util.resourcemanager.ResourceManager;
34 33
 
@@ -45,6 +44,9 @@ public class WindowsMediaSourcePlugin extends BaseFileDependantPlugin
45 44
     /** Media sources. */
46 45
     private final List<MediaSource> sources;
47 46
 
47
+    /** My plugin info. */
48
+    private final PluginInfo pluginInfo;
49
+
48 50
     /**
49 51
      * Creates a new instance of DcopMediaSourcePlugin.
50 52
      *
@@ -52,6 +54,7 @@ public class WindowsMediaSourcePlugin extends BaseFileDependantPlugin
52 54
      */
53 55
     public WindowsMediaSourcePlugin(final PluginInfo pluginInfo) {
54 56
         super(pluginInfo.getMetaData());
57
+        this.pluginInfo = pluginInfo;
55 58
         sources = new ArrayList<MediaSource>();
56 59
         sources.add(new DllSource(this, "Winamp", true));
57 60
         sources.add(new DllSource(this, "iTunes", false));
@@ -93,7 +96,7 @@ public class WindowsMediaSourcePlugin extends BaseFileDependantPlugin
93 96
     @Override
94 97
     public void onLoad() {
95 98
         // Extract GetMediaInfo.exe and required DLLs
96
-        final PluginInfo pi = PluginManager.getPluginManager().getPluginInfoByName("windowsmediasource");
99
+        final PluginInfo pi = pluginInfo.getMetaData().getManager().getPluginInfoByName("windowsmediasource");
97 100
 
98 101
         // This shouldn't actually happen, but check to make sure.
99 102
         if (pi == null) {

+ 1
- 2
src/com/dmdirc/addons/nickcolours/NickColourInputDialog.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.addons.nickcolours;
25 25
 import com.dmdirc.addons.ui_swing.SwingController;
26 26
 import com.dmdirc.addons.ui_swing.components.colours.ColourChooser;
27 27
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
28
-import com.dmdirc.plugins.PluginManager;
29 28
 
30 29
 import java.awt.event.ActionEvent;
31 30
 import java.awt.event.ActionListener;
@@ -77,7 +76,7 @@ public class NickColourInputDialog extends StandardDialog
77 76
     public NickColourInputDialog(final NickColourPanel panel, final int row,
78 77
             final String nickname, final String network,
79 78
             final String textcolour, final String nickcolour) {
80
-        super(((SwingController) PluginManager.getPluginManager()
79
+        super(((SwingController) panel.getPlugin().getPluginInfo().getMetaData().getManager()
81 80
                 .getPluginInfoByName("ui_swing").getPlugin()), false);
82 81
 
83 82
         this.panel = panel;

+ 9
- 0
src/com/dmdirc/addons/nickcolours/NickColourPanel.java View File

@@ -139,6 +139,15 @@ public class NickColourPanel extends JPanel implements ActionListener,
139 139
         deleteButton.setEnabled(false);
140 140
     }
141 141
 
142
+    /**
143
+     * Get an instance of the plugin that owns us.
144
+     *
145
+     * @return Our plugin.
146
+     */
147
+    public NickColourPlugin getPlugin() {
148
+        return plugin;
149
+    }
150
+
142 151
     /**
143 152
      * {@inheritDoc}
144 153
      *

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

@@ -43,7 +43,6 @@ import com.dmdirc.parser.interfaces.ChannelInfo;
43 43
 import com.dmdirc.parser.interfaces.ClientInfo;
44 44
 import com.dmdirc.plugins.BasePlugin;
45 45
 import com.dmdirc.plugins.PluginInfo;
46
-import com.dmdirc.plugins.PluginManager;
47 46
 import com.dmdirc.ui.Colour;
48 47
 import com.dmdirc.ui.messages.ColourManager;
49 48
 
@@ -80,6 +79,15 @@ public final class NickColourPlugin extends BasePlugin implements ActionListener
80 79
         this.pluginInfo = pluginInfo;
81 80
     }
82 81
 
82
+    /**
83
+     * Get our PluginInfo
84
+     *
85
+     * @return our PluginInfo
86
+     */
87
+    public PluginInfo getPluginInfo() {
88
+        return pluginInfo;
89
+    }
90
+
83 91
     /** {@inheritDoc} */
84 92
     @Override
85 93
     public void processEvent(final ActionType type, final StringBuffer format,
@@ -270,7 +278,7 @@ public final class NickColourPlugin extends BasePlugin implements ActionListener
270 278
                     @Override
271 279
                     public NickColourPanel call() {
272 280
                         return new NickColourPanel(
273
-                                (SwingController) PluginManager.getPluginManager()
281
+                                (SwingController) pluginInfo.getMetaData().getManager()
274 282
                                 .getPluginInfoByName("ui_swing").getPlugin(),
275 283
                                 NickColourPlugin.this);
276 284
                     }

+ 4
- 5
src/com/dmdirc/addons/notifications/NotificationsPlugin.java View File

@@ -32,7 +32,6 @@ import com.dmdirc.interfaces.ActionListener;
32 32
 import com.dmdirc.interfaces.actions.ActionType;
33 33
 import com.dmdirc.plugins.BasePlugin;
34 34
 import com.dmdirc.plugins.PluginInfo;
35
-import com.dmdirc.plugins.PluginManager;
36 35
 
37 36
 import java.util.ArrayList;
38 37
 import java.util.List;
@@ -70,7 +69,7 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
70 69
         loadSettings();
71 70
         ActionManager.getActionManager().registerListener(this,
72 71
                 CoreActionType.PLUGIN_LOADED, CoreActionType.PLUGIN_UNLOADED);
73
-        for (PluginInfo target : PluginManager.getPluginManager()
72
+        for (PluginInfo target : pluginInfo.getMetaData().getManager()
74 73
                 .getPluginInfos()) {
75 74
             if (target.isLoaded()) {
76 75
                 addPlugin(target);
@@ -171,7 +170,7 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
171 170
      * @return The method with the specified name or null if none were found.
172 171
      */
173 172
     public PluginInfo getMethod(final String name) {
174
-        return PluginManager.getPluginManager().getPluginInfoByName(name);
173
+        return pluginInfo.getMetaData().getManager().getPluginInfoByName(name);
175 174
     }
176 175
 
177 176
     /**
@@ -182,7 +181,7 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
182 181
     public List<PluginInfo> getMethods() {
183 182
         final List<PluginInfo> plugins = new ArrayList<PluginInfo>();
184 183
         for (String method : methods) {
185
-            plugins.add(PluginManager.getPluginManager()
184
+            plugins.add(pluginInfo.getMetaData().getManager()
186 185
                     .getPluginInfoByName(method));
187 186
         }
188 187
         return plugins;
@@ -208,7 +207,7 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
208 207
         }
209 208
         for (String method : order) {
210 209
             if (methods.contains(method)) {
211
-                return PluginManager.getPluginManager().getPluginInfoByName(
210
+                return pluginInfo.getMetaData().getManager().getPluginInfoByName(
212 211
                     method);
213 212
             }
214 213
         }

+ 1
- 2
src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java View File

@@ -34,7 +34,6 @@ import com.dmdirc.interfaces.actions.ActionType;
34 34
 import com.dmdirc.plugins.BasePlugin;
35 35
 import com.dmdirc.plugins.Plugin;
36 36
 import com.dmdirc.plugins.PluginInfo;
37
-import com.dmdirc.plugins.PluginManager;
38 37
 
39 38
 import java.util.ArrayList;
40 39
 import java.util.Collections;
@@ -85,7 +84,7 @@ public class NowPlayingPlugin extends BasePlugin implements ActionListener  {
85 84
         actionController.registerListener(this, CoreActionType.PLUGIN_LOADED,
86 85
                 CoreActionType.PLUGIN_UNLOADED);
87 86
 
88
-        for (PluginInfo target : PluginManager.getPluginManager().getPluginInfos()) {
87
+        for (PluginInfo target : pluginInfo.getMetaData().getManager().getPluginInfos()) {
89 88
             if (target.isLoaded()) {
90 89
                 addPlugin(target);
91 90
             }

+ 9
- 0
src/com/dmdirc/addons/osd/OsdPlugin.java View File

@@ -71,6 +71,15 @@ public final class OsdPlugin extends BasePlugin implements
71 71
         registerCommand(new OsdCommand(osdManager), OsdCommand.INFO);
72 72
     }
73 73
 
74
+    /**
75
+     * Get our PluginInfo.
76
+     *
77
+     * @return our PluginInfo.
78
+     */
79
+    public PluginInfo getPluginInfo() {
80
+        return pluginInfo;
81
+    }
82
+
74 83
     /** {@inheritDoc} */
75 84
     @Override
76 85
     public void showConfig(final PreferencesDialogModel manager) {

+ 1
- 2
src/com/dmdirc/addons/osd/OsdWindow.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.addons.osd;
25 25
 import com.dmdirc.addons.ui_swing.SwingController;
26 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27 27
 import com.dmdirc.config.IdentityManager;
28
-import com.dmdirc.plugins.PluginManager;
29 28
 import com.dmdirc.ui.messages.ColourManager;
30 29
 
31 30
 import java.awt.Color;
@@ -96,7 +95,7 @@ public class OsdWindow extends JDialog implements MouseListener,
96 95
      */
97 96
     public OsdWindow(final int timeout, final String text, final boolean config, final int x,
98 97
             final int y, final OsdPlugin plugin, final OsdManager osdManager) {
99
-        super(((SwingController) PluginManager.getPluginManager()
98
+        super(((SwingController) plugin.getPluginInfo().getMetaData().getManager()
100 99
                 .getPluginInfoByName("ui_swing").getPlugin()).getMainFrame(), false);
101 100
 
102 101
         this.config = config;

+ 8
- 8
src/com/dmdirc/addons/parser_twitter/actions/TwitterActionComponents.java View File

@@ -23,11 +23,11 @@
23 23
 package com.dmdirc.addons.parser_twitter.actions;
24 24
 
25 25
 import com.dmdirc.Server;
26
-import com.dmdirc.ServerManager;
27 26
 import com.dmdirc.interfaces.actions.ActionComponent;
28 27
 import com.dmdirc.addons.parser_twitter.Twitter;
29 28
 import com.dmdirc.addons.parser_twitter.api.TwitterStatus;
30 29
 import com.dmdirc.addons.parser_twitter.api.TwitterUser;
30
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
31 31
 import com.dmdirc.parser.interfaces.Parser;
32 32
 
33 33
 /**
@@ -43,10 +43,10 @@ public enum TwitterActionComponents implements ActionComponent {
43 43
 
44 44
         /** {@inheritDoc} */
45 45
         @Override
46
-        public Object get(final Object argument) {
47
-            final long id = Long.parseLong(((String) argument).substring(1));
46
+        public Object get(final ActionComponentArgument arg) {
47
+            final long id = Long.parseLong(((String) arg.getObject()).substring(1));
48 48
 
49
-            for (Server server : ServerManager.getServerManager().getServers()) {
49
+            for (Server server : arg.getMain().getServerManager().getServers()) {
50 50
                 final Parser parser = server.getParser();
51 51
 
52 52
                 if (parser instanceof Twitter) {
@@ -86,8 +86,8 @@ public enum TwitterActionComponents implements ActionComponent {
86 86
 
87 87
         /** {@inheritDoc} */
88 88
         @Override
89
-        public Object get(final Object argument) {
90
-            return ((TwitterStatus) argument).getUser();
89
+        public Object get(final ActionComponentArgument arg) {
90
+            return ((TwitterStatus) arg.getObject()).getUser();
91 91
         }
92 92
 
93 93
         /** {@inheritDoc} */
@@ -115,8 +115,8 @@ public enum TwitterActionComponents implements ActionComponent {
115 115
 
116 116
         /** {@inheritDoc} */
117 117
         @Override
118
-        public Object get(final Object argument) {
119
-            return ((TwitterUser) argument).getScreenName();
118
+        public Object get(final ActionComponentArgument arg) {
119
+            return ((TwitterUser) arg.getObject()).getScreenName();
120 120
         }
121 121
 
122 122
         /** {@inheritDoc} */

+ 13
- 5
src/com/dmdirc/addons/relaybot/RelayBotPlugin.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.relaybot;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
-import com.dmdirc.ServerManager;
28 27
 import com.dmdirc.actions.ActionManager;
29 28
 import com.dmdirc.actions.CoreActionType;
30 29
 import com.dmdirc.addons.ui_swing.UIUtilities;
@@ -88,7 +87,7 @@ public class RelayBotPlugin extends BasePlugin implements ActionListener, Config
88 87
 
89 88
         // Add ourself to all currently known channels that we should be
90 89
         // connected with.
91
-        for (Server server : ServerManager.getServerManager().getServers()) {
90
+        for (Server server : getPluginManager().getMain().getServerManager().getServers()) {
92 91
             final Parser parser = server.getParser();
93 92
             if (parser instanceof IRCParser && !(parser.getCallbackManager() instanceof RelayCallbackManager)) {
94 93
                 new RelayCallbackManager(this, (IRCParser) parser);
@@ -99,13 +98,22 @@ public class RelayBotPlugin extends BasePlugin implements ActionListener, Config
99 98
         }
100 99
     }
101 100
 
101
+    /**
102
+     * Get our plugin manager.
103
+     *
104
+     * @return Our plugin manager.
105
+     */
106
+    protected PluginManager getPluginManager() {
107
+        return pluginInfo.getMetaData().getManager();
108
+    }
109
+
102 110
     /** {@inheritDoc} */
103 111
     @Override
104 112
     public void onUnload() {
105 113
         ActionManager.getActionManager().unregisterListener(this);
106 114
 
107 115
         // Remove RelayCallbackManagers
108
-        for (Server server : ServerManager.getServerManager().getServers()) {
116
+        for (Server server : getPluginManager().getMain().getServerManager().getServers()) {
109 117
             final Parser parser = server.getParser();
110 118
             if (parser instanceof IRCParser && parser.getCallbackManager() instanceof RelayCallbackManager) {
111 119
                 ((RelayCallbackManager) parser.getCallbackManager()).onSocketClosed(parser, new Date());
@@ -174,7 +182,7 @@ public class RelayBotPlugin extends BasePlugin implements ActionListener, Config
174 182
     public void configChanged(final String domain, final String key) {
175 183
         final boolean wasUnset = !IdentityManager.getIdentityManager().getGlobalConfiguration().hasOptionString(domain, key);
176 184
 
177
-        for (Server server : ServerManager.getServerManager().getServers()) {
185
+        for (Server server : getPluginManager().getMain().getServerManager().getServers()) {
178 186
             if (server.hasChannel(key)) {
179 187
                 final Channel chan = server.getChannel(key);
180 188
                 if (wasUnset) {
@@ -290,7 +298,7 @@ public class RelayBotPlugin extends BasePlugin implements ActionListener, Config
290 298
             /** {@inheritDoc} */
291 299
             @Override
292 300
             public RelayChannelPanel call() {
293
-                return new RelayChannelPanel(PluginManager.getPluginManager()
301
+                return new RelayChannelPanel(getPluginManager()
294 302
                         .getPluginInfoByName("ui_swing").getPlugin(),
295 303
                         RelayBotPlugin.this);
296 304
             }

+ 1
- 2
src/com/dmdirc/addons/relaybot/RelayChannelHandler.java View File

@@ -33,7 +33,6 @@ import com.dmdirc.parser.interfaces.callbacks.ChannelMessageListener;
33 33
 import com.dmdirc.parser.irc.IRCChannelClientInfo;
34 34
 import com.dmdirc.parser.irc.IRCParser;
35 35
 import com.dmdirc.plugins.PluginInfo;
36
-import com.dmdirc.plugins.PluginManager;
37 36
 import com.dmdirc.ui.messages.Styliser;
38 37
 
39 38
 import java.lang.reflect.Field;
@@ -213,7 +212,7 @@ public class RelayChannelHandler implements ChannelMessageListener {
213 212
     */
214 213
     private void colourClient(final ChannelClientInfo channelClient) {
215 214
         // Use nick colour plugin to colour the client if available.
216
-        final PluginInfo nickColour = PluginManager.getPluginManager()
215
+        final PluginInfo nickColour = myPlugin.getPluginManager()
217 216
                 .getPluginInfoByName("nickcolour");
218 217
 
219 218
         final boolean fullColour = IdentityManager.getIdentityManager()

+ 1
- 1
src/com/dmdirc/addons/serverlistdialog/ServerListDialog.java View File

@@ -83,7 +83,7 @@ public final class ServerListDialog extends StandardDialog implements
83 83
         super(controller, controller.getMainFrame(), ModalityType.MODELESS);
84 84
 
85 85
         setTitle("Server List");
86
-        model = new ServerListModel();
86
+        model = new ServerListModel(controller.getPluginManager(), controller.getMain().getServerManager());
87 87
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
88 88
 
89 89
         connectButton = new JButton("Connect");

+ 12
- 3
src/com/dmdirc/addons/serverlistdialog/ServerListModel.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.serverlistdialog;
24 24
 
25
+import com.dmdirc.ServerManager;
25 26
 import com.dmdirc.actions.wrappers.PerformWrapper.PerformDescription;
26 27
 import com.dmdirc.actions.wrappers.PerformType;
27 28
 import com.dmdirc.logger.ErrorLevel;
@@ -30,6 +31,7 @@ import com.dmdirc.addons.serverlists.ServerEntry;
30 31
 import com.dmdirc.addons.serverlists.ServerGroup;
31 32
 import com.dmdirc.addons.serverlists.ServerGroupItem;
32 33
 import com.dmdirc.addons.serverlists.ServerList;
34
+import com.dmdirc.plugins.PluginManager;
33 35
 import com.dmdirc.util.collections.ListenerList;
34 36
 
35 37
 import java.io.IOException;
@@ -45,16 +47,23 @@ import javax.swing.tree.DefaultTreeModel;
45 47
 public class ServerListModel {
46 48
 
47 49
     /** Server list. */
48
-    private final ServerList list = new ServerList();
50
+    private final ServerList list;
49 51
     /** Listener list. */
50 52
     private final ListenerList listeners;
51 53
     /** Active server item. */
52 54
     private ServerGroupItem activeItem;
55
+    /** ServerManager that ServerEntrys use to create servers */
56
+    private final ServerManager serverManager;
53 57
 
54 58
     /**
55 59
      * Creates a new server list model.
60
+     *
61
+     * @param pluginManager PluginManager currently in use.
62
+     * @param serverManager ServerManager currently in use.
56 63
      */
57
-    public ServerListModel() {
64
+    public ServerListModel(final PluginManager pluginManager, final ServerManager serverManager) {
65
+        this.serverManager = serverManager;
66
+        list = new ServerList(pluginManager, serverManager);
58 67
         listeners = new ListenerList();
59 68
     }
60 69
 
@@ -217,7 +226,7 @@ public class ServerListModel {
217 226
      */
218 227
     public void addEntry(final ServerGroup parentGroup, final String entryName,
219 228
             final URI url) {
220
-        final ServerGroupItem sg = new ServerEntry(parentGroup, entryName, url,
229
+        final ServerGroupItem sg = new ServerEntry(serverManager, parentGroup, entryName, url,
221 230
                 null);
222 231
         parentGroup.addItem(sg);
223 232
         for (ServerListListener listener : listeners.get(

+ 8
- 2
src/com/dmdirc/addons/serverlists/ServerEntry.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.serverlists;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 
27
+import com.dmdirc.ServerManager;
27 28
 import java.net.URI;
28 29
 
29 30
 /**
@@ -40,6 +41,9 @@ public class ServerEntry extends ServerGroupItemBase {
40 41
     /** The group that owns this entry. */
41 42
     private final ServerGroup group;
42 43
 
44
+    /** The manager to use to create new servers. */
45
+    private final ServerManager serverManager;
46
+
43 47
     /**
44 48
      * Creates a new server entry.
45 49
      *
@@ -48,8 +52,10 @@ public class ServerEntry extends ServerGroupItemBase {
48 52
      * @param address The address of this server
49 53
      * @param profile The name of the profile to be used by this server
50 54
      */
51
-    public ServerEntry(final ServerGroup group, final String name,
55
+    public ServerEntry(final ServerManager serverManager,
56
+            final ServerGroup group, final String name,
52 57
             final URI address, final String profile) {
58
+        this.serverManager = serverManager;
53 59
         setName(name);
54 60
         setProfile(profile);
55 61
         this.address = address;
@@ -91,7 +97,7 @@ public class ServerEntry extends ServerGroupItemBase {
91 97
     /** {@inheritDoc} */
92 98
     @Override
93 99
     public void connect() {
94
-        final Server server = new Server(address, getProfileIdentity());
100
+        final Server server = new Server(serverManager, address, getProfileIdentity());
95 101
         server.connect();
96 102
     }
97 103
 

+ 12
- 3
src/com/dmdirc/addons/serverlists/ServerList.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.serverlists;
24 24
 
25 25
 import com.dmdirc.Precondition;
26
+import com.dmdirc.ServerManager;
26 27
 import com.dmdirc.addons.serverlists.io.ServerGroupReader;
27 28
 import com.dmdirc.addons.serverlists.io.ServerGroupWriter;
28 29
 import com.dmdirc.addons.serverlists.service.ServerListServiceProvider;
@@ -30,6 +31,7 @@ import com.dmdirc.config.Identity;
30 31
 import com.dmdirc.config.IdentityListener;
31 32
 import com.dmdirc.config.IdentityManager;
32 33
 
34
+import com.dmdirc.plugins.PluginManager;
33 35
 import java.io.IOException;
34 36
 import java.util.Collection;
35 37
 import java.util.Collections;
@@ -48,17 +50,24 @@ public class ServerList implements IdentityListener {
48 50
     private final Map<ServerGroup, ServerGroupWriter> groups
49 51
             = new HashMap<ServerGroup, ServerGroupWriter>();
50 52
 
53
+    /** ServerManager that ServerEntrys use to create servers */
54
+    private final ServerManager serverManager;
55
+
51 56
     /**
52 57
      * Creates a new ServerList and loads groups and servers.
58
+     *
59
+     * @param pluginManager Plugin Manager to use.
60
+     * @param serverManager Server Manager to use.
53 61
      */
54
-    public ServerList() {
62
+    public ServerList(final PluginManager pluginManager, final ServerManager serverManager) {
63
+        this.serverManager = serverManager;
55 64
         IdentityManager.getIdentityManager().registerIdentityListener("servergroup", this);
56 65
 
57 66
         for (Identity identity : IdentityManager.getIdentityManager().getIdentitiesByType("servergroup")) {
58 67
             identityAdded(identity);
59 68
         }
60 69
 
61
-        new ServerListServiceProvider(this).register();
70
+        new ServerListServiceProvider(pluginManager, this).register();
62 71
     }
63 72
 
64 73
     /**
@@ -136,7 +145,7 @@ public class ServerList implements IdentityListener {
136 145
     @Override
137 146
     public void identityAdded(final Identity identity) {
138 147
         try {
139
-            final ServerGroupReader reader = new ServerGroupReader(identity);
148
+            final ServerGroupReader reader = new ServerGroupReader(serverManager, identity);
140 149
             addServerGroup(reader.read(), reader.getWriter());
141 150
         } catch (IllegalArgumentException ex) {
142 151
             // Silently ignore

+ 7
- 2
src/com/dmdirc/addons/serverlists/io/ServerEntryReader.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.serverlists.io;
24 24
 
25
+import com.dmdirc.ServerManager;
25 26
 import com.dmdirc.addons.serverlists.ServerEntry;
26 27
 import com.dmdirc.addons.serverlists.ServerGroup;
27 28
 import com.dmdirc.config.Identity;
@@ -39,14 +40,18 @@ public class ServerEntryReader {
39 40
     /** The identity to read entries from. */
40 41
     private final Identity identity;
41 42
 
43
+    /** ServerManager that ServerEntrys use to create servers */
44
+    private final ServerManager serverManager;
45
+
42 46
     /**
43 47
      * Creates a new Server Entry Reader which will read from the specified
44 48
      * identity.
45 49
      *
46 50
      * @param identity The identity which defines our server entries
47 51
      */
48
-    public ServerEntryReader(final Identity identity) {
52
+    public ServerEntryReader(final ServerManager serverManager, final Identity identity) {
49 53
         this.identity = identity;
54
+        this.serverManager = serverManager;
50 55
     }
51 56
 
52 57
     /**
@@ -70,7 +75,7 @@ public class ServerEntryReader {
70 75
         final String serverName = identity.getOption(name, "name");
71 76
         final URI serverURI = new URI(identity.getOption(name, "address"));
72 77
 
73
-        return new ServerEntry(group, serverName, serverURI, null);
78
+        return new ServerEntry(serverManager, group, serverName, serverURI, null);
74 79
     }
75 80
 
76 81
 }

+ 3
- 2
src/com/dmdirc/addons/serverlists/io/ServerGroupReader.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.serverlists.io;
24 24
 
25
+import com.dmdirc.ServerManager;
25 26
 import com.dmdirc.addons.serverlists.ServerGroup;
26 27
 import com.dmdirc.config.Identity;
27 28
 
@@ -48,9 +49,9 @@ public class ServerGroupReader {
48 49
      *
49 50
      * @param identity The identity describing the server group
50 51
      */
51
-    public ServerGroupReader(final Identity identity) {
52
+    public ServerGroupReader(final ServerManager serverManager, final Identity identity) {
52 53
         this.identity = identity;
53
-        this.entryReader = new ServerEntryReader(identity);
54
+        this.entryReader = new ServerEntryReader(serverManager, identity);
54 55
     }
55 56
 
56 57
     /**

+ 8
- 3
src/com/dmdirc/addons/serverlists/service/ServerListServiceProvider.java View File

@@ -51,15 +51,20 @@ public class ServerListServiceProvider implements ServiceProvider {
51 51
     /** The services that this provider providers. */
52 52
     private final List<Service> services;
53 53
 
54
+    /** Plugin Manager */
55
+    private final PluginManager pluginManager;
56
+
54 57
     /**
55 58
      * Creates a new server list service provider.
56 59
      *
60
+     * @param pluginManager The PluginManager to use.
57 61
      * @param serverList The {@link ServerList} to retrieve items from
58 62
      */
59
-    public ServerListServiceProvider(final ServerList serverList) {
63
+    public ServerListServiceProvider(final PluginManager pluginManager, final ServerList serverList) {
60 64
         this.serverList = serverList;
65
+        this.pluginManager = pluginManager;
61 66
         this.services = Arrays.asList(new Service[] {
62
-           PluginManager.getPluginManager().getService("parser", "serverlist", true)
67
+           pluginManager.getService("parser", "serverlist", true)
63 68
         });
64 69
     }
65 70
 
@@ -145,7 +150,7 @@ public class ServerListServiceProvider implements ServiceProvider {
145 150
      * @return A corresponding parser instance
146 151
      */
147 152
     protected Parser getParserForItem(final MyInfo myInfo, final ServerGroupItem item) {
148
-        return new ParserFactory().getParser(myInfo, item.getAddress());
153
+        return new ParserFactory(pluginManager).getParser(myInfo, item.getAddress());
149 154
     }
150 155
 
151 156
 }

+ 1
- 2
src/com/dmdirc/addons/systray/SystrayPlugin.java View File

@@ -35,7 +35,6 @@ import com.dmdirc.config.prefs.PreferencesType;
35 35
 import com.dmdirc.interfaces.ActionController;
36 36
 import com.dmdirc.plugins.BasePlugin;
37 37
 import com.dmdirc.plugins.PluginInfo;
38
-import com.dmdirc.plugins.PluginManager;
39 38
 import com.dmdirc.ui.IconManager;
40 39
 import com.dmdirc.ui.messages.Styliser;
41 40
 import com.dmdirc.util.validators.ValidationResponse;
@@ -159,7 +158,7 @@ public final class SystrayPlugin extends BasePlugin implements ActionListener,
159 158
         boolean continueLoading = true;
160 159
         try {
161 160
             SystemTray.getSystemTray().add(icon);
162
-            mainFrame = ((SwingController) PluginManager.getPluginManager()
161
+            mainFrame = ((SwingController) pluginInfo.getMetaData().getManager()
163 162
                     .getPluginInfoByName("ui_swing").getPlugin())
164 163
                     .getMainFrame();
165 164
             actionController.registerListener(this, CoreActionType.CLIENT_MINIMISED);

+ 4
- 2
src/com/dmdirc/addons/ui_dummy/DummyChannelWindow.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_dummy;
24 24
 
25 25
 import com.dmdirc.Channel;
26
+import com.dmdirc.interfaces.ui.UIController;
26 27
 
27 28
 /**
28 29
  * Dummy channel window, used for testing.
@@ -32,9 +33,10 @@ public final class DummyChannelWindow extends DummyInputWindow {
32 33
     /**
33 34
      * Instantiates a new DummyChannelWindow.
34 35
      *
36
+     * @param controller Parent Controller
35 37
      * @param parent Parent channel
36 38
      */
37
-    public DummyChannelWindow(final Channel parent) {
38
-        super(parent);
39
+    public DummyChannelWindow(final UIController controller, final Channel parent) {
40
+        super(controller, parent);
39 41
     }
40 42
 }

+ 12
- 1
src/com/dmdirc/addons/ui_dummy/DummyController.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_dummy;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
+import com.dmdirc.Main;
27 28
 import com.dmdirc.Server;
28 29
 import com.dmdirc.plugins.BasePlugin;
29 30
 import com.dmdirc.ui.core.components.StatusBarManager;
@@ -37,14 +38,24 @@ import java.net.URI;
37 38
  */
38 39
 public final class DummyController extends BasePlugin implements UIController {
39 40
 
41
+    /** The main that owns us. */
42
+    private final Main main;
43
+
40 44
     /**
41 45
      * Creates a new instance of DummyController.
42 46
      */
43
-    public DummyController() {
47
+    public DummyController(final Main main) {
44 48
         super();
49
+        this.main = main;
45 50
         StatusBarManager.getStatusBarManager().registerStatusBar(new DummyStatusBar());
46 51
     }
47 52
 
53
+    /** {@inheritDoc} */
54
+    @Override
55
+    public Main getMain() {
56
+        return main;
57
+    }
58
+
48 59
     /** {@inheritDoc} */
49 60
     @Override
50 61
     public void showFirstRunWizard() {

+ 5
- 2
src/com/dmdirc/addons/ui_dummy/DummyInputHandler.java View File

@@ -26,6 +26,7 @@ import com.dmdirc.WritableFrameContainer;
26 26
 import com.dmdirc.commandparser.parsers.CommandParser;
27 27
 import com.dmdirc.ui.input.InputHandler;
28 28
 import com.dmdirc.interfaces.ui.InputField;
29
+import com.dmdirc.interfaces.ui.UIController;
29 30
 
30 31
 /**
31 32
  * Dummy input handler.
@@ -36,14 +37,16 @@ public class DummyInputHandler extends InputHandler {
36 37
      * Creates a new instance of InputHandler. Adds listeners to the target
37 38
      * that we need to operate.
38 39
      *
40
+     * @param controller The controller that owns us.
39 41
      * @param target The text field this input handler is dealing with.
40 42
      * @param commandParser The command parser to use for this text field.
41 43
      * @param parentWindow The window that owns this input handler
42 44
      */
43
-    public DummyInputHandler(final InputField target,
45
+    public DummyInputHandler(final UIController controller,
46
+            final InputField target,
44 47
             final CommandParser commandParser,
45 48
             final WritableFrameContainer parentWindow) {
46
-        super(target, commandParser, parentWindow);
49
+        super(controller, target, commandParser, parentWindow);
47 50
     }
48 51
 
49 52
     /** {@inheritDoc} */

+ 7
- 3
src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java View File

@@ -35,19 +35,23 @@ public class DummyInputWindow implements InputWindow {
35 35
     /** Our container. */
36 36
     private final WritableFrameContainer container;
37 37
 
38
+    /** Our Controller. */
39
+    private final UIController controller;
40
+
38 41
     /**
39 42
      * Instantiates a new DummyInputWindow.
40 43
      *
41 44
      * @param owner Parent window
42 45
      */
43
-    public DummyInputWindow(final WritableFrameContainer owner) {
46
+    public DummyInputWindow(final UIController controller, final WritableFrameContainer owner) {
47
+        this.controller = controller;
44 48
         this.container = owner;
45 49
     }
46 50
 
47 51
     /** {@inheritDoc} */
48 52
     @Override
49 53
     public InputHandler getInputHandler() {
50
-        return new DummyInputHandler(new DummyInputField(), null,
54
+        return new DummyInputHandler(controller, new DummyInputField(), null,
51 55
                 getContainer());
52 56
     }
53 57
 
@@ -60,7 +64,7 @@ public class DummyInputWindow implements InputWindow {
60 64
     /** {@inheritDoc} */
61 65
     @Override
62 66
     public UIController getController() {
63
-        return new DummyController();
67
+        return controller;
64 68
     }
65 69
 
66 70
 }

+ 6
- 4
src/com/dmdirc/addons/ui_swing/Apple.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25
-import com.dmdirc.ServerManager;
26 25
 import com.dmdirc.actions.ActionManager;
27 26
 import com.dmdirc.actions.CoreActionType;
28 27
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
@@ -112,6 +111,8 @@ public final class Apple implements InvocationHandler, ActionListener {
112 111
     private MenuBar menuBar = null;
113 112
     /** Has the CLIENT_OPENED action been called? */
114 113
     private boolean clientOpened = false;
114
+    /** Our swing controller. */
115
+    private final SwingController controller;
115 116
 
116 117
     /**
117 118
      * Create the Apple class.
@@ -127,8 +128,9 @@ public final class Apple implements InvocationHandler, ActionListener {
127 128
      *
128 129
      * @param configManager Config manager
129 130
      */
130
-    public Apple(final ConfigManager configManager) {
131
+    public Apple(final ConfigManager configManager, final SwingController controller) {
131 132
         this.configManager = configManager;
133
+        this.controller = controller;
132 134
         if (isApple()) {
133 135
             try {
134 136
                 System.loadLibrary("DMDirc-Apple"); // NOPMD
@@ -477,7 +479,7 @@ public final class Apple implements InvocationHandler, ActionListener {
477 479
             synchronized (addresses) {
478 480
                 clientOpened = true;
479 481
                 for (final URI addr : addresses) {
480
-                    ServerManager.getServerManager().connectToAddress(addr);
482
+                    controller.getMain().getServerManager().connectToAddress(addr);
481 483
                 }
482 484
                 addresses.clear();
483 485
             }
@@ -508,7 +510,7 @@ public final class Apple implements InvocationHandler, ActionListener {
508 510
                         Thread.currentThread().setContextClassLoader(
509 511
                                 ClassLoader.getSystemClassLoader());
510 512
                     }
511
-                    ServerManager.getServerManager().connectToAddress(addr);
513
+                    controller.getMain().getServerManager().connectToAddress(addr);
512 514
                 } else {
513 515
                     addresses.add(addr);
514 516
                 }

+ 1
- 2
src/com/dmdirc/addons/ui_swing/MainFrame.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.ServerManager;
27 26
 import com.dmdirc.actions.ActionManager;
28 27
 import com.dmdirc.actions.CoreActionType;
29 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
@@ -522,7 +521,7 @@ public final class MainFrame extends JFrame implements WindowListener,
522 521
             protected Void doInBackground() {
523 522
                 ActionManager.getActionManager().triggerEvent(
524 523
                         CoreActionType.CLIENT_CLOSING, null);
525
-                ServerManager.getServerManager().closeAll(controller
524
+                controller.getMain().getServerManager().closeAll(controller
526 525
                         .getGlobalConfig().getOption("general", "closemessage"));
527 526
                 controller.getGlobalIdentity().setOption("ui",
528 527
                         "frameManagerSize",

+ 1
- 1
src/com/dmdirc/addons/ui_swing/SwingController.java View File

@@ -176,7 +176,7 @@ public class SwingController extends BasePlugin implements UIController {
176 176
         globalConfig = identityManager.getGlobalConfiguration();
177 177
         globalIdentity = identityManager.getGlobalConfigIdentity();
178 178
         addonIdentity = identityManager.getGlobalAddonIdentity();
179
-        apple = new Apple(getGlobalConfig());
179
+        apple = new Apple(getGlobalConfig(), this);
180 180
         iconManager = new IconManager(globalConfig);
181 181
         prefsComponentFactory = new PrefsComponentFactory(this);
182 182
         dialogManager = new DialogManager(this);

+ 1
- 2
src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java View File

@@ -33,7 +33,6 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
35 35
 import com.dmdirc.commandparser.commands.context.CommandContext;
36
-import com.dmdirc.plugins.PluginManager;
37 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 37
 
39 38
 /**
@@ -52,7 +51,7 @@ public class ChannelSettings extends Command implements
52 51
     @Override
53 52
     public void execute(final FrameContainer origin,
54 53
             final CommandArguments args, final CommandContext context) {
55
-        ((SwingController) PluginManager.getPluginManager()
54
+        ((SwingController) getController().getMain().getPluginManager()
56 55
                 .getPluginInfoByName("ui_swing").getPlugin())
57 56
                 .showChannelSettingsDialog(((ChannelCommandContext) context)
58 57
                 .getChannel());

+ 1
- 2
src/com/dmdirc/addons/ui_swing/commands/ServerSettings.java View File

@@ -32,7 +32,6 @@ import com.dmdirc.commandparser.commands.Command;
32 32
 import com.dmdirc.commandparser.commands.CommandOptions;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
-import com.dmdirc.plugins.PluginManager;
36 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 36
 
38 37
 /**
@@ -52,7 +51,7 @@ public class ServerSettings extends Command implements IntelligentCommand {
52 51
     @Override
53 52
     public void execute(final FrameContainer origin,
54 53
             final CommandArguments args, final CommandContext context) {
55
-        ((SwingController) PluginManager.getPluginManager()
54
+        ((SwingController) getController().getMain().getPluginManager()
56 55
                 .getPluginInfoByName("ui_swing").getPlugin())
57 56
                 .showServerSettingsDialog(context.getSource().getServer());
58 57
     }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/TopicBar.java View File

@@ -122,7 +122,7 @@ public class TopicBar extends JComponent implements ActionListener,
122 122
                 channelFrame.getIconManager().getIcon("close"),
123 123
                 channelFrame.getIconManager().getIcon("close-active"));
124 124
 
125
-        final SwingInputHandler handler = new SwingInputHandler(topicText,
125
+        final SwingInputHandler handler = new SwingInputHandler(controller, topicText,
126 126
                 channelFrame.getContainer().getCommandParser(),
127 127
                 channelFrame.getContainer());
128 128
         handler.setTypes(true, false, true, false);

+ 2
- 3
src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorker.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.addons.ui_swing.components.addonbrowser;
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27 27
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28
-import com.dmdirc.plugins.PluginManager;
29 28
 import com.dmdirc.ui.themes.ThemeManager;
30 29
 import com.dmdirc.util.io.Downloader;
31 30
 
@@ -68,11 +67,11 @@ public class InstallWorker extends LoggingSwingWorker<String, Void> {
68 67
                     ActionManager.installActionPack(file.getAbsolutePath());
69 68
                     break;
70 69
                 case TYPE_PLUGIN:
71
-                    final File newFile = new File(PluginManager
70
+                    final File newFile = new File(controller.getMain()
72 71
                             .getPluginManager().getDirectory(),
73 72
                             info.getTitle() + ".jar");
74 73
                     if (file.renameTo(newFile)) {
75
-                        PluginManager.getPluginManager().addPlugin(
74
+                        controller.getMain().getPluginManager().addPlugin(
76 75
                                 newFile.getName());
77 76
                     } else {
78 77
                         return "Unable to install addon, failed to move file: "

+ 1
- 2
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonToggle.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.ui_swing.components.addonpanel;
24 24
 
25 25
 import com.dmdirc.config.Identity;
26 26
 import com.dmdirc.plugins.PluginInfo;
27
-import com.dmdirc.plugins.PluginManager;
28 27
 import com.dmdirc.ui.themes.Theme;
29 28
 import com.dmdirc.ui.themes.ThemeManager;
30 29
 import com.dmdirc.updater.UpdateChecker;
@@ -159,7 +158,7 @@ public final class AddonToggle {
159 158
                     } else {
160 159
                         pi.unloadPlugin();
161 160
                     }
162
-                    PluginManager.getPluginManager().updateAutoLoad(pi);
161
+                    pi.getMetaData().getManager().updateAutoLoad(pi);
163 162
                     if (getID() != -1) {
164 163
                         if (getUpdateState()) {
165 164
                             identity.unsetOption("updater", "enable-addon-"

+ 2
- 3
src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java View File

@@ -29,7 +29,6 @@ import com.dmdirc.addons.ui_swing.UIUtilities;
29 29
 import com.dmdirc.interfaces.ActionListener;
30 30
 import com.dmdirc.interfaces.actions.ActionType;
31 31
 import com.dmdirc.plugins.PluginInfo;
32
-import com.dmdirc.plugins.PluginManager;
33 32
 
34 33
 import java.awt.Window;
35 34
 import java.util.ArrayList;
@@ -64,7 +63,7 @@ public class PluginPanel extends AddonPanel implements ActionListener {
64 63
 
65 64
         ActionManager.getActionManager().registerListener(this,
66 65
                 CoreActionType.PLUGIN_REFRESH);
67
-        PluginManager.getPluginManager().refreshPlugins();
66
+        controller.getMain().getPluginManager().refreshPlugins();
68 67
     }
69 68
 
70 69
     /** {@inheritDoc} */
@@ -72,7 +71,7 @@ public class PluginPanel extends AddonPanel implements ActionListener {
72 71
     protected JTable populateList(final JTable table) {
73 72
         final List<PluginInfo> list = new ArrayList<PluginInfo>();
74 73
         final List<PluginInfo> sortedList = new ArrayList<PluginInfo>();
75
-        list.addAll(PluginManager.getPluginManager().getPluginInfos());
74
+        list.addAll(controller.getMain().getPluginManager().getPluginInfos());
76 75
         Collections.sort(list);
77 76
         for (final PluginInfo plugin : list) {
78 77
             if (plugin.getMetaData().getParents().length == 0) {

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java View File

@@ -131,7 +131,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
131 131
      */
132 132
     private void initComponents() {
133 133
         inputField = new SwingInputField(this, getController().getMainFrame());
134
-        inputHandler = new SwingInputHandler(inputField,
134
+        inputHandler = new SwingInputHandler(controller, inputField,
135 135
                 getContainer().getCommandParser(), getContainer());
136 136
         inputHandler.addValidationListener(inputField);
137 137
         inputHandler.setTabCompleter(((WritableFrameContainer) frameParent).

+ 5
- 2
src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java View File

@@ -28,6 +28,7 @@ import com.dmdirc.addons.ui_swing.UIUtilities;
28 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29 29
 import com.dmdirc.commandparser.parsers.CommandParser;
30 30
 import com.dmdirc.interfaces.ui.InputField;
31
+import com.dmdirc.interfaces.ui.UIController;
31 32
 import com.dmdirc.logger.ErrorLevel;
32 33
 import com.dmdirc.logger.Logger;
33 34
 import com.dmdirc.ui.input.InputHandler;
@@ -51,14 +52,16 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
51 52
      * Creates a new instance of InputHandler. Adds listeners to the target
52 53
      * that we need to operate.
53 54
      *
55
+     * @param controller The UIController that owns this input handler.
54 56
      * @param target The text field this input handler is dealing with.
55 57
      * @param commandParser The command parser to use for this text field.
56 58
      * @param parentWindow The window that owns this input handler
57 59
      */
58
-    public SwingInputHandler(final InputField target,
60
+    public SwingInputHandler(final UIController controller,
61
+            final InputField target,
59 62
             final CommandParser commandParser,
60 63
             final WritableFrameContainer parentWindow) {
61
-        super(target, commandParser, parentWindow);
64
+        super(controller, target, commandParser, parentWindow);
62 65
     }
63 66
 
64 67
     /** {@inheritDoc} */

+ 1
- 2
src/com/dmdirc/addons/ui_swing/components/menubar/HelpMenu.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.menubar;
24 24
 
25
-import com.dmdirc.ServerManager;
26 25
 import com.dmdirc.addons.ui_swing.Apple;
27 26
 import com.dmdirc.addons.ui_swing.SwingController;
28 27
 import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
@@ -96,7 +95,7 @@ public class HelpMenu extends JMenu implements ActionListener {
96 95
         if (e.getActionCommand().equals("About")) {
97 96
             controller.showDialog(AboutDialog.class);
98 97
         } else if (e.getActionCommand().equals("JoinDevChat")) {
99
-            ServerManager.getServerManager().joinDevChat();
98
+            controller.getMain().getServerManager().joinDevChat();
100 99
         } else if (e.getActionCommand().equals("feedback")) {
101 100
             controller.showDialog(FeedbackDialog.class);
102 101
         }

+ 1
- 2
src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25 25
 import com.dmdirc.Invite;
26 26
 import com.dmdirc.Server;
27
-import com.dmdirc.ServerManager;
28 27
 import com.dmdirc.actions.ActionManager;
29 28
 import com.dmdirc.actions.CoreActionType;
30 29
 import com.dmdirc.addons.ui_swing.MainFrame;
@@ -100,7 +99,7 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
100 99
         accept.setActionCommand("acceptAll");
101 100
         accept.addActionListener(this);
102 101
 
103
-        for (final Server server : ServerManager.getServerManager().getServers()) {
102
+        for (final Server server : controller.getMain().getServerManager().getServers()) {
104 103
             server.addInviteListener(this);
105 104
         }
106 105
 

+ 1
- 2
src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs;
24 24
 
25 25
 import com.dmdirc.Server;
26
-import com.dmdirc.ServerManager;
27 26
 import com.dmdirc.addons.ui_swing.SwingController;
28 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
29 28
 import com.dmdirc.addons.ui_swing.components.SendWorker;
@@ -181,7 +180,7 @@ public final class FeedbackDialog extends StandardDialog implements
181 180
         final StringBuilder serverInfo = new StringBuilder();
182 181
         final StringBuilder dmdircInfo = new StringBuilder();
183 182
         if (serverCheckbox.isSelected()) {
184
-            for (Server server : ServerManager.getServerManager()
183
+            for (Server server : getController().getMain().getServerManager()
185 184
                     .getServers()) {
186 185
                 if (server.getState().isDisconnected()) {
187 186
                     continue;

+ 4
- 5
src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs;
24 24
 
25 25
 import com.dmdirc.Server;
26
-import com.dmdirc.ServerManager;
27 26
 import com.dmdirc.addons.ui_swing.SwingController;
28 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
29 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
@@ -126,7 +125,7 @@ public final class NewServerDialog extends StandardDialog implements
126 125
 
127 126
         serverField.requestFocusInWindow();
128 127
 
129
-        if (ServerManager.getServerManager().numServers() == 0 ||
128
+        if (getController().getMain().getServerManager().numServers() == 0 ||
130 129
                 getController().getMainFrame().getActiveFrame() == null) {
131 130
             newServerWindowCheck.setSelected(true);
132 131
             newServerWindowCheck.setEnabled(false);
@@ -248,13 +247,13 @@ public final class NewServerDialog extends StandardDialog implements
248 247
 
249 248
             // Open in a new window?
250 249
             if (newServerWindowCheck.isSelected()
251
-                    || ServerManager.getServerManager().numServers() == 0
250
+                    || getController().getMain().getServerManager().numServers() == 0
252 251
                     || getController().getMainFrame().getActiveFrame() == null) {
253 252
 
254 253
                 new LoggingSwingWorker<Void, Void>() {
255 254
                     @Override
256 255
                     protected Void doInBackground() {
257
-                        final Server server = new Server(address, profile);
256
+                        final Server server = new Server(getController().getMain().getServerManager(), address, profile);
258 257
                         server.connect();
259 258
                         return null;
260 259
                     }
@@ -269,7 +268,7 @@ public final class NewServerDialog extends StandardDialog implements
269 268
                     @Override
270 269
                     protected Void doInBackground() {
271 270
                         if (server == null) {
272
-                            final Server newServer = new Server(address, profile);
271
+                            final Server newServer = new Server(getController().getMain().getServerManager(), address, profile);
273 272
                             newServer.connect();
274 273
                         } else {
275 274
                             server.connect(address, profile);

+ 1
- 2
src/com/dmdirc/addons/ui_swing/dialogs/about/AboutDialog.java View File

@@ -78,8 +78,7 @@ public final class AboutDialog extends StandardDialog implements
78 78
 
79 79
         tabbedPane.add("About", new AboutPanel(getController().getURLHandler()));
80 80
         tabbedPane.add("Credits", cp);
81
-        tabbedPane.add("Licences", new LicencesPanel(getController()
82
-                .getGlobalConfig()));
81
+        tabbedPane.add("Licences", new LicencesPanel(getController()));
83 82
         tabbedPane.add("Information", new InfoPanel(getController()));
84 83
         tabbedPane.addChangeListener(this);
85 84
 

+ 6
- 3
src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java View File

@@ -22,12 +22,12 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
27 28
 import com.dmdirc.logger.ErrorLevel;
28 29
 import com.dmdirc.logger.Logger;
29 30
 import com.dmdirc.plugins.PluginInfo;
30
-import com.dmdirc.plugins.PluginManager;
31 31
 import com.dmdirc.util.resourcemanager.ResourceManager;
32 32
 
33 33
 import java.io.BufferedReader;
@@ -51,6 +51,8 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
51 51
     private final JTree tree;
52 52
     /** Model to load licences into. */
53 53
     private final DefaultTreeModel model;
54
+    /** Swing Controller */
55
+    final SwingController controller;
54 56
 
55 57
     /**
56 58
      * Instantiates a new licence loader.
@@ -58,9 +60,10 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
58 60
      * @param tree Tree
59 61
      * @param model Model to load licences into
60 62
      */
61
-    public LicenceLoader(final JTree tree, final DefaultTreeModel model) {
63
+    public LicenceLoader(final SwingController controller, final JTree tree, final DefaultTreeModel model) {
62 64
         super();
63 65
 
66
+        this.controller = controller;
64 67
         this.tree = tree;
65 68
         this.model = model;
66 69
     }
@@ -78,7 +81,7 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
78 81
                     + "no resource manager");
79 82
         } else {
80 83
             addCoreLicences(rm);
81
-            for (PluginInfo pi : PluginManager.getPluginManager()
84
+            for (PluginInfo pi : controller.getMain().getPluginManager()
82 85
                     .getPluginInfos()) {
83 86
                 addPluginLicences(pi);
84 87
             }

+ 7
- 3
src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
27 28
 import com.dmdirc.config.ConfigManager;
@@ -65,16 +66,19 @@ public final class LicencesPanel extends JPanel implements
65 66
     private JEditorPane licence;
66 67
     /** Licence list. */
67 68
     private JTree list;
69
+    /** Swing Controller. */
70
+    private final SwingController controller;
68 71
 
69 72
     /**
70 73
      * Creates a new instance of LicencesPanel.
71 74
      *
72 75
      * @param config Config manager
73 76
      */
74
-    public LicencesPanel(final ConfigManager config) {
77
+    public LicencesPanel(final SwingController controller) {
75 78
         super();
76 79
 
77
-        this.config = config;
80
+        this.controller = controller;
81
+        this.config = controller.getGlobalConfig();
78 82
         initComponents();
79 83
         addListeners();
80 84
         layoutComponents();
@@ -130,7 +134,7 @@ public final class LicencesPanel extends JPanel implements
130 134
         list.getSelectionModel().setSelectionMode(TreeSelectionModel.
131 135
                 SINGLE_TREE_SELECTION);
132 136
         new TreeScroller(list);
133
-        new LicenceLoader(list, listModel).executeInExecutor();
137
+        new LicenceLoader(controller, list, listModel).executeInExecutor();
134 138
         licence = new JEditorPane();
135 139
         licence.setEditorKit(new HTMLEditorKit());
136 140
         final Font font = UIManager.getFont("Label.font");

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java View File

@@ -104,8 +104,8 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
104 104
         topicText.setWrapStyleWord(true);
105 105
         topicText.setRows(5);
106 106
         topicText.setColumns(30);
107
-        final SwingInputHandler handler = new SwingInputHandler(topicText,
108
-                channel.getCommandParser(), channelWindow.getContainer());
107
+        final SwingInputHandler handler = new SwingInputHandler(parent.getController(),
108
+                topicText, channel.getCommandParser(), channelWindow.getContainer());
109 109
         handler.setTypes(true, false, true, false);
110 110
         handler.setTabCompleter(channel.getTabCompleter());
111 111
 

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/paste/PasteDialog.java View File

@@ -121,7 +121,7 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
121 121
         textField.setColumns(50);
122 122
         textField.setRows(10);
123 123
 
124
-        new SwingInputHandler(textField, parent.getContainer()
124
+        new SwingInputHandler(getController(), textField, parent.getContainer()
125 125
                 .getCommandParser(), parent.getContainer())
126 126
                 .setTypes(false, false, true,false);
127 127
 

+ 2
- 1
src/com/dmdirc/addons/ui_web/DynamicRequestHandler.java View File

@@ -278,7 +278,8 @@ public class DynamicRequestHandler extends AbstractHandler {
278 278
     private void doNewServer(final HttpServletRequest request)
279 279
             throws IOException {
280 280
         try {
281
-            new Server(new URI("irc://" + request.getParameter("password") + "@"
281
+            new Server(controller.getMain().getServerManager(),
282
+                    new URI("irc://" + request.getParameter("password") + "@"
282 283
                     + request.getParameter("server") + ":"
283 284
                     + request.getParameter("port")),
284 285
                     findProfile(request.getParameter("profile"))).connect();

+ 12
- 2
src/com/dmdirc/addons/ui_web/StaticRequestHandler.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_web;
24 24
 
25
-import com.dmdirc.plugins.PluginManager;
26 25
 import com.dmdirc.util.resourcemanager.ResourceManager;
27 26
 
28 27
 import java.io.IOException;
@@ -42,6 +41,17 @@ public class StaticRequestHandler extends AbstractHandler {
42 41
 
43 42
     private ResourceManager rm;
44 43
 
44
+    private final WebInterfaceUI controller;
45
+
46
+    /**
47
+     * Create a new StaticRequestHandler.
48
+     *
49
+     * @param controller UI Controller that owns this handler.
50
+     */
51
+    public StaticRequestHandler(final WebInterfaceUI controller) {
52
+        this.controller = controller;
53
+    }
54
+
45 55
     /** {@inheritDoc} */
46 56
     @Override
47 57
     public void handle(final String target, final HttpServletRequest request,
@@ -50,7 +60,7 @@ public class StaticRequestHandler extends AbstractHandler {
50 60
 
51 61
         if (rm == null) {
52 62
             try {
53
-                rm = PluginManager.getPluginManager()
63
+                rm = controller.getMain().getPluginManager()
54 64
                     .getPluginInfoByName("ui_web").getResourceManager();
55 65
             } catch (IOException ex) {
56 66
                 // Die horribly

+ 15
- 2
src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_web;
24 24
 
25
+import com.dmdirc.Main;
25 26
 import com.dmdirc.plugins.BasePlugin;
26 27
 
27 28
 import lombok.Getter;
@@ -33,15 +34,27 @@ import org.mortbay.jetty.Handler;
33 34
  */
34 35
 public class WebInterfacePlugin extends BasePlugin {
35 36
 
37
+    /** Our instance of main. */
38
+    private final Main main;
39
+
36 40
     /** The UI that we're using. */
37 41
     @Getter
38 42
     private WebInterfaceUI controller;
39 43
 
44
+    /**
45
+     * Create a new WebInterfacePlugin
46
+     *
47
+     * @param main The instance of main that this client uses.
48
+     */
49
+    public WebInterfacePlugin(final Main main) {
50
+        this.main = main;
51
+    }
52
+
40 53
     /** {@inheritDoc} */
41 54
     @Override
42 55
     public void onLoad() {
43 56
         if (controller == null) {
44
-            controller = new WebInterfaceUI(getDomain());
57
+            controller = new WebInterfaceUI(main, getDomain());
45 58
         }
46 59
     }
47 60
 
@@ -52,7 +65,7 @@ public class WebInterfacePlugin extends BasePlugin {
52 65
      */
53 66
     public void addWebHandler(final Handler newHandler) {
54 67
         if (controller == null) {
55
-            controller = new WebInterfaceUI(getDomain());
68
+            controller = new WebInterfaceUI(main, getDomain());
56 69
         }
57 70
 
58 71
         controller.addWebHandler(newHandler);

+ 13
- 2
src/com/dmdirc/addons/ui_web/WebInterfaceUI.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_web;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
+import com.dmdirc.Main;
27 28
 import com.dmdirc.Server;
28 29
 import com.dmdirc.addons.ui_web.uicomponents.WebStatusBar;
29 30
 import com.dmdirc.interfaces.ui.UIController;
@@ -56,14 +57,18 @@ public class WebInterfaceUI implements UIController {
56 57
     @Getter
57 58
     private final DynamicRequestHandler handler;
58 59
 
60
+    /** Instance of Main that owns us. */
61
+    private final Main main;
62
+
59 63
     /**
60 64
      * Creates a new WebInterfaceUI belonging to the specified plugin.
61 65
      *
62 66
      * @param domain The domain to retrieve config settings from
63 67
      */
64
-    public WebInterfaceUI(final String domain) {
68
+    public WebInterfaceUI(final Main main, final String domain) {
65 69
         super();
66 70
 
71
+        this.main = main;
67 72
         final SecurityHandler sh = new SecurityHandler();
68 73
         final Constraint constraint = new Constraint();
69 74
         final ConstraintMapping cm = new ConstraintMapping();
@@ -84,7 +89,7 @@ public class WebInterfaceUI implements UIController {
84 89
         webServer.setHandlers(new Handler[]{
85 90
             sh,
86 91
             new RootRequestHandler(),
87
-            new StaticRequestHandler(),
92
+            new StaticRequestHandler(this),
88 93
             new DMDircRequestHandler(),
89 94
             handler,
90 95
         });
@@ -100,6 +105,12 @@ public class WebInterfaceUI implements UIController {
100 105
         StatusBarManager.getStatusBarManager().registerStatusBar(new WebStatusBar(handler));
101 106
     }
102 107
 
108
+    /** {@inheritDoc} */
109
+    @Override
110
+    public Main getMain() {
111
+        return main;
112
+    }
113
+
103 114
     /**
104 115
      * Adds the specified handler to the webserver.
105 116
      *

+ 4
- 2
src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_web.uicomponents;
25 25
 import com.dmdirc.WritableFrameContainer;
26 26
 import com.dmdirc.commandparser.parsers.CommandParser;
27 27
 import com.dmdirc.interfaces.ui.InputField;
28
+import com.dmdirc.interfaces.ui.UIController;
28 29
 import com.dmdirc.ui.input.InputHandler;
29 30
 import com.dmdirc.ui.input.TabCompleter;
30 31
 
@@ -33,10 +34,11 @@ import com.dmdirc.ui.input.TabCompleter;
33 34
  */
34 35
 public class WebInputHandler extends InputHandler {
35 36
 
36
-    public WebInputHandler(final InputField thisTarget,
37
+    public WebInputHandler(final UIController controller,
38
+                           final InputField thisTarget,
37 39
                            final CommandParser thisCommandParser,
38 40
                            final WritableFrameContainer thisParentWindow) {
39
-        super(thisTarget, thisCommandParser, thisParentWindow);
41
+        super(controller, thisTarget, thisCommandParser, thisParentWindow);
40 42
     }
41 43
 
42 44
     public InputField getTarget() {

+ 5
- 2
src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java View File

@@ -50,12 +50,15 @@ public class WebInputWindow extends WebWindow implements InputWindow {
50 50
     private final Map<Client, WebInputHandler> inputHandlers
51 51
             = new HashMap<Client, WebInputHandler>();
52 52
 
53
+    private final WebInterfaceUI controller;
54
+
53 55
     public WebInputWindow(final WebInterfaceUI controller,
54 56
             final WritableFrameContainer parent, final String id) {
55 57
         super(controller, parent, id);
56 58
         this.container = parent;
57 59
         this.commandparser = parent.getCommandParser();
58
-        this.inputHandler = new WebInputHandler(new WebInputField(),
60
+        this.controller = controller;
61
+        this.inputHandler = new WebInputHandler(controller, new WebInputField(),
59 62
                 commandparser, getContainer());
60 63
     }
61 64
 
@@ -67,7 +70,7 @@ public class WebInputWindow extends WebWindow implements InputWindow {
67 70
 
68 71
     public WebInputHandler getInputHandler(final Client client) {
69 72
         if (!inputHandlers.containsKey(client)) {
70
-            final WebInputHandler ih = new WebInputHandler(
73
+            final WebInputHandler ih = new WebInputHandler(controller,
71 74
                     new WebInputField(client), commandparser, getContainer());
72 75
             ih.setTabCompleter(inputHandler.getTabCompleter());
73 76
             inputHandlers.put(client, ih);

+ 4
- 3
src/com/dmdirc/addons/userlevel/AccessLevelComponent.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.userlevel;
24 24
 
25 25
 import com.dmdirc.interfaces.actions.ActionComponent;
26
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
26 27
 import com.dmdirc.parser.interfaces.ClientInfo;
27 28
 
28 29
 /**
@@ -34,9 +35,9 @@ public class AccessLevelComponent implements ActionComponent {
34 35
 
35 36
     /** {@inheritDoc} */
36 37
     @Override
37
-    public Object get(final Object argument) {
38
-        UserLevelPlugin.doGlobalLevel((ClientInfo) argument);
39
-        return ((ClientInfo) argument).getMap().get("level");
38
+    public Object get(final ActionComponentArgument arg) {
39
+        UserLevelPlugin.doGlobalLevel((ClientInfo) arg.getObject());
40
+        return ((ClientInfo) arg.getObject()).getMap().get("level");
40 41
     }
41 42
 
42 43
     /** {@inheritDoc} */

+ 3
- 2
src/com/dmdirc/addons/userlevel/ChannelAccessLevelComponent.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.userlevel;
24 24
 
25 25
 import com.dmdirc.interfaces.actions.ActionComponent;
26
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
26 27
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
27 28
 
28 29
 /**
@@ -34,8 +35,8 @@ public class ChannelAccessLevelComponent implements ActionComponent {
34 35
 
35 36
     /** {@inheritDoc} */
36 37
     @Override
37
-    public Object get(final Object argument) {
38
-        final ChannelClientInfo ci = (ChannelClientInfo) argument;
38
+    public Object get(final ActionComponentArgument arg) {
39
+        final ChannelClientInfo ci = (ChannelClientInfo) arg.getObject();
39 40
 
40 41
         UserLevelPlugin.doChannelLevel(ci);
41 42
 

+ 1
- 2
src/com/dmdirc/addons/windowstatus/WindowStatusPlugin.java View File

@@ -42,7 +42,6 @@ import com.dmdirc.parser.interfaces.ChannelInfo;
42 42
 import com.dmdirc.parser.interfaces.ClientInfo;
43 43
 import com.dmdirc.plugins.BasePlugin;
44 44
 import com.dmdirc.plugins.PluginInfo;
45
-import com.dmdirc.plugins.PluginManager;
46 45
 
47 46
 import java.util.HashMap;
48 47
 import java.util.Map;
@@ -91,7 +90,7 @@ public final class WindowStatusPlugin extends BasePlugin
91 90
     /** {@inheritDoc} */
92 91
     @Override
93 92
     public void onLoad() {
94
-        controller = (SwingController) PluginManager.getPluginManager()
93
+        controller = (SwingController) pluginInfo.getMetaData().getManager()
95 94
                 .getPluginInfoByName("ui_swing").getPlugin();
96 95
         controller.getSwingStatusBar().addComponent(panel);
97 96
         controller.getMainFrame().addSelectionListener(this);

Loading…
Cancel
Save