Browse Source

Revert "Continue main removal"

Revert "Begin removing CommandManager singleton."

This reverts commit eefba0d347.

Change-Id: Iba86c7f2bf870684e0d41f88d82f16b43d43fe80
Depends-On: I8eb4f70f80292d66e3bdbe9f32766b5f427413c2
Reviewed-on: http://gerrit.dmdirc.com/2600
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.7
Shane Mc Cormack 11 years ago
parent
commit
ca45e4719f
23 changed files with 108 additions and 72 deletions
  1. 1
    1
      src/com/dmdirc/addons/lagdisplay/ServerInfoDialog.java
  2. 1
    1
      src/com/dmdirc/addons/serverlistdialog/ServerListDialog.java
  3. 1
    1
      src/com/dmdirc/addons/serverlists/ServerEntry.java
  4. 2
    1
      src/com/dmdirc/addons/ui_dummy/DummyChannelWindow.java
  5. 1
    12
      src/com/dmdirc/addons/ui_dummy/DummyController.java
  6. 3
    2
      src/com/dmdirc/addons/ui_dummy/DummyInputHandler.java
  7. 4
    3
      src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java
  8. 2
    2
      src/com/dmdirc/addons/ui_swing/Apple.java
  9. 1
    1
      src/com/dmdirc/addons/ui_swing/MainFrame.java
  10. 3
    11
      src/com/dmdirc/addons/ui_swing/SwingController.java
  11. 2
    2
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorker.java
  12. 2
    2
      src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java
  13. 3
    3
      src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java
  14. 1
    1
      src/com/dmdirc/addons/ui_swing/components/menubar/HelpMenu.java
  15. 1
    1
      src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java
  16. 1
    1
      src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java
  17. 4
    4
      src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java
  18. 1
    1
      src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java
  19. 2
    1
      src/com/dmdirc/addons/ui_web/DynamicRequestHandler.java
  20. 3
    8
      src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java
  21. 1
    9
      src/com/dmdirc/addons/ui_web/WebInterfaceUI.java
  22. 3
    4
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java
  23. 65
    0
      test/com/dmdirc/addons/redirect/RedirectCommandTest.java

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

@@ -73,7 +73,7 @@ public class ServerInfoDialog extends StatusbarPopupWindow {
73 73
     /** {@inheritDoc} */
74 74
     @Override
75 75
     protected void initContent(final JPanel panel) {
76
-        final List<Server> servers = getController().getServerManager().getServers();
76
+        final List<Server> servers = getController().getMain().getServerManager().getServers();
77 77
 
78 78
         if (servers.isEmpty()) {
79 79
             panel.add(new JLabel("No open servers."));

+ 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(controller.getPluginManager(), controller.getServerManager());
86
+        model = new ServerListModel(controller.getPluginManager(), controller.getMain().getServerManager());
87 87
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
88 88
 
89 89
         connectButton = new JButton("Connect");

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

@@ -97,7 +97,7 @@ public class ServerEntry extends ServerGroupItemBase {
97 97
     /** {@inheritDoc} */
98 98
     @Override
99 99
     public void connect() {
100
-        final Server server = serverManager.createServer(address, getProfileIdentity());
100
+        final Server server = new Server(serverManager, address, getProfileIdentity());
101 101
         server.connect();
102 102
     }
103 103
 

+ 2
- 1
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.
@@ -35,7 +36,7 @@ public final class DummyChannelWindow extends DummyInputWindow {
35 36
      * @param controller Parent Controller
36 37
      * @param parent Parent channel
37 38
      */
38
-    public DummyChannelWindow(final DummyController controller, final Channel parent) {
39
+    public DummyChannelWindow(final UIController controller, final Channel parent) {
39 40
         super(controller, parent);
40 41
     }
41 42
 }

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

@@ -30,34 +30,23 @@ import com.dmdirc.plugins.BasePlugin;
30 30
 import com.dmdirc.ui.core.components.StatusBarManager;
31 31
 import com.dmdirc.interfaces.ui.UIController;
32 32
 import com.dmdirc.interfaces.ui.Window;
33
-import com.dmdirc.plugins.PluginManager;
34 33
 
35 34
 import java.net.URI;
36 35
 
37
-import lombok.Getter;
38
-
39 36
 /**
40 37
  * Implements a dummy UI controller.
41 38
  */
42
-@SuppressWarnings("PMD.UnusedPrivateField")
43 39
 public final class DummyController extends BasePlugin implements UIController {
44 40
 
45 41
     /** The main that owns us. */
46 42
     private final Main main;
47
-    /** Plugin manager. */
48
-    @Getter
49
-    private final PluginManager pluginManager;
50 43
 
51 44
     /**
52 45
      * Creates a new instance of DummyController.
53
-     *
54
-     * @param main Main
55
-     * @param pluginManager Plugin manager
56 46
      */
57
-    public DummyController(final Main main, final PluginManager pluginManager) {
47
+    public DummyController(final Main main) {
58 48
         super();
59 49
         this.main = main;
60
-        this.pluginManager = pluginManager;
61 50
         StatusBarManager.getStatusBarManager().registerStatusBar(new DummyStatusBar());
62 51
     }
63 52
 

+ 3
- 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.
@@ -41,11 +42,11 @@ public class DummyInputHandler extends InputHandler {
41 42
      * @param commandParser The command parser to use for this text field.
42 43
      * @param parentWindow The window that owns this input handler
43 44
      */
44
-    public DummyInputHandler(final DummyController controller,
45
+    public DummyInputHandler(final UIController controller,
45 46
             final InputField target,
46 47
             final CommandParser commandParser,
47 48
             final WritableFrameContainer parentWindow) {
48
-        super(target, commandParser, parentWindow, controller.getPluginManager());
49
+        super(controller, target, commandParser, parentWindow);
49 50
     }
50 51
 
51 52
     /** {@inheritDoc} */

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

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_dummy;
25 25
 import com.dmdirc.WritableFrameContainer;
26 26
 import com.dmdirc.ui.input.InputHandler;
27 27
 import com.dmdirc.interfaces.ui.InputWindow;
28
+import com.dmdirc.interfaces.ui.UIController;
28 29
 
29 30
 /**
30 31
  * Dummy input window, used for testing.
@@ -35,14 +36,14 @@ public class DummyInputWindow implements InputWindow {
35 36
     private final WritableFrameContainer container;
36 37
 
37 38
     /** Our Controller. */
38
-    private final DummyController controller;
39
+    private final UIController controller;
39 40
 
40 41
     /**
41 42
      * Instantiates a new DummyInputWindow.
42 43
      *
43 44
      * @param owner Parent window
44 45
      */
45
-    public DummyInputWindow(final DummyController controller, final WritableFrameContainer owner) {
46
+    public DummyInputWindow(final UIController controller, final WritableFrameContainer owner) {
46 47
         this.controller = controller;
47 48
         this.container = owner;
48 49
     }
@@ -62,7 +63,7 @@ public class DummyInputWindow implements InputWindow {
62 63
 
63 64
     /** {@inheritDoc} */
64 65
     @Override
65
-    public DummyController getController() {
66
+    public UIController getController() {
66 67
         return controller;
67 68
     }
68 69
 

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

@@ -444,7 +444,7 @@ public final class Apple implements InvocationHandler, ActionListener {
444 444
             synchronized (addresses) {
445 445
                 clientOpened = true;
446 446
                 for (final URI addr : addresses) {
447
-                    controller.getServerManager().connectToAddress(addr);
447
+                    controller.getMain().getServerManager().connectToAddress(addr);
448 448
                 }
449 449
                 addresses.clear();
450 450
             }
@@ -518,7 +518,7 @@ public final class Apple implements InvocationHandler, ActionListener {
518 518
                 if (Thread.currentThread().getContextClassLoader() == null) {
519 519
                     Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
520 520
                 }
521
-                controller.getServerManager().connectToAddress(uri);
521
+                controller.getMain().getServerManager().connectToAddress(uri);
522 522
             } else {
523 523
                 addresses.add(uri);
524 524
             }

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

@@ -521,7 +521,7 @@ public final class MainFrame extends JFrame implements WindowListener,
521 521
             protected Void doInBackground() {
522 522
                 ActionManager.getActionManager().triggerEvent(
523 523
                         CoreActionType.CLIENT_CLOSING, null);
524
-                controller.getServerManager().closeAll(controller
524
+                controller.getMain().getServerManager().closeAll(controller
525 525
                         .getGlobalConfig().getOption("general", "closemessage"));
526 526
                 controller.getGlobalIdentity().setOption("ui",
527 527
                         "frameManagerSize",

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

@@ -26,7 +26,6 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Main;
28 28
 import com.dmdirc.Server;
29
-import com.dmdirc.ServerManager;
30 29
 import com.dmdirc.actions.ActionManager;
31 30
 import com.dmdirc.addons.ui_swing.commands.ChannelSettings;
32 31
 import com.dmdirc.addons.ui_swing.commands.Input;
@@ -106,7 +105,7 @@ public class SwingController extends BasePlugin implements UIController {
106 105
     private final AtomicBoolean mainFrameCreated = new AtomicBoolean(false);
107 106
     /** URL Handler to use. */
108 107
     @Getter
109
-    private final URLHandler URLHandler;
108
+    private final URLHandler URLHandler = new URLHandler(this);
110 109
     /** Singleton instance of MainFrame. */
111 110
     @Getter
112 111
     private MainFrame mainFrame;
@@ -156,31 +155,24 @@ public class SwingController extends BasePlugin implements UIController {
156 155
     /** Apple handler, deals with Mac specific code. */
157 156
     @Getter
158 157
     private final Apple apple;
159
-    /** Server manager. */
160
-    @Getter
161
-    private final ServerManager serverManager;
162 158
 
163 159
     /**
164 160
      * Instantiates a new SwingController.
165 161
      *
166 162
      * @param pluginInfo Plugin info
167 163
      * @param identityManager Identity Manager
168
-     * @param main Main
169 164
      */
170 165
     public SwingController(final PluginInfo pluginInfo,
171 166
             final IdentityManager identityManager,
172 167
             final PluginManager pluginManager,
173
-            final ActionManager actionManager,
174
-            final ServerManager serverManager,
175
-            final Main main) {
168
+            final Main main,
169
+            final ActionManager actionManager) {
176 170
         super();
177 171
         this.main = main;
178 172
         this.pluginInfo = pluginInfo;
179 173
         this.identityManager = identityManager;
180 174
         this.actionManager = actionManager;
181 175
         this.pluginManager = pluginManager;
182
-        this.serverManager = serverManager;
183
-        URLHandler = new URLHandler(this, serverManager);
184 176
         globalConfig = identityManager.getGlobalConfiguration();
185 177
         globalIdentity = identityManager.getGlobalConfigIdentity();
186 178
         addonIdentity = identityManager.getGlobalAddonIdentity();

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

@@ -67,11 +67,11 @@ public class InstallWorker extends LoggingSwingWorker<String, Void> {
67 67
                     ActionManager.installActionPack(file.getAbsolutePath());
68 68
                     break;
69 69
                 case TYPE_PLUGIN:
70
-                    final File newFile = new File(controller
70
+                    final File newFile = new File(controller.getMain()
71 71
                             .getPluginManager().getDirectory(),
72 72
                             info.getTitle() + ".jar");
73 73
                     if (file.renameTo(newFile)) {
74
-                        controller.getPluginManager().addPlugin(
74
+                        controller.getMain().getPluginManager().addPlugin(
75 75
                                 newFile.getName());
76 76
                     } else {
77 77
                         return "Unable to install addon, failed to move file: "

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

@@ -63,7 +63,7 @@ public class PluginPanel extends AddonPanel implements ActionListener {
63 63
 
64 64
         ActionManager.getActionManager().registerListener(this,
65 65
                 CoreActionType.PLUGIN_REFRESH);
66
-        controller.getPluginManager().refreshPlugins();
66
+        controller.getMain().getPluginManager().refreshPlugins();
67 67
     }
68 68
 
69 69
     /** {@inheritDoc} */
@@ -71,7 +71,7 @@ public class PluginPanel extends AddonPanel implements ActionListener {
71 71
     protected JTable populateList(final JTable table) {
72 72
         final List<PluginInfo> list = new ArrayList<PluginInfo>();
73 73
         final List<PluginInfo> sortedList = new ArrayList<PluginInfo>();
74
-        list.addAll(controller.getPluginManager().getPluginInfos());
74
+        list.addAll(controller.getMain().getPluginManager().getPluginInfos());
75 75
         Collections.sort(list);
76 76
         for (final PluginInfo plugin : list) {
77 77
             if (plugin.getMetaData().getParents().length == 0) {

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

@@ -24,11 +24,11 @@ package com.dmdirc.addons.ui_swing.components.inputfields;
24 24
 
25 25
 import com.dmdirc.WritableFrameContainer;
26 26
 import com.dmdirc.addons.ui_swing.Apple;
27
-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;
30 29
 import com.dmdirc.commandparser.parsers.CommandParser;
31 30
 import com.dmdirc.interfaces.ui.InputField;
31
+import com.dmdirc.interfaces.ui.UIController;
32 32
 import com.dmdirc.logger.ErrorLevel;
33 33
 import com.dmdirc.logger.Logger;
34 34
 import com.dmdirc.ui.input.InputHandler;
@@ -57,11 +57,11 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
57 57
      * @param commandParser The command parser to use for this text field.
58 58
      * @param parentWindow The window that owns this input handler
59 59
      */
60
-    public SwingInputHandler(final SwingController controller,
60
+    public SwingInputHandler(final UIController controller,
61 61
             final InputField target,
62 62
             final CommandParser commandParser,
63 63
             final WritableFrameContainer parentWindow) {
64
-        super(target, commandParser, parentWindow, controller.getPluginManager());
64
+        super(controller, target, commandParser, parentWindow);
65 65
     }
66 66
 
67 67
     /** {@inheritDoc} */

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

@@ -95,7 +95,7 @@ public class HelpMenu extends JMenu implements ActionListener {
95 95
         if (e.getActionCommand().equals("About")) {
96 96
             controller.showDialog(AboutDialog.class);
97 97
         } else if (e.getActionCommand().equals("JoinDevChat")) {
98
-            controller.getServerManager().joinDevChat();
98
+            controller.getMain().getServerManager().joinDevChat();
99 99
         } else if (e.getActionCommand().equals("feedback")) {
100 100
             controller.showDialog(FeedbackDialog.class);
101 101
         }

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

@@ -99,7 +99,7 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
99 99
         accept.setActionCommand("acceptAll");
100 100
         accept.addActionListener(this);
101 101
 
102
-        for (final Server server : controller.getServerManager().getServers()) {
102
+        for (final Server server : controller.getMain().getServerManager().getServers()) {
103 103
             server.addInviteListener(this);
104 104
         }
105 105
 

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

@@ -180,7 +180,7 @@ public final class FeedbackDialog extends StandardDialog implements
180 180
         final StringBuilder serverInfo = new StringBuilder();
181 181
         final StringBuilder dmdircInfo = new StringBuilder();
182 182
         if (serverCheckbox.isSelected()) {
183
-            for (Server server : getController().getServerManager()
183
+            for (Server server : getController().getMain().getServerManager()
184 184
                     .getServers()) {
185 185
                 if (server.getState().isDisconnected()) {
186 186
                     continue;

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

@@ -125,7 +125,7 @@ public final class NewServerDialog extends StandardDialog implements
125 125
 
126 126
         serverField.requestFocusInWindow();
127 127
 
128
-        if (getController().getServerManager().numServers() == 0 ||
128
+        if (getController().getMain().getServerManager().numServers() == 0 ||
129 129
                 getController().getMainFrame().getActiveFrame() == null) {
130 130
             newServerWindowCheck.setSelected(true);
131 131
             newServerWindowCheck.setEnabled(false);
@@ -247,13 +247,13 @@ public final class NewServerDialog extends StandardDialog implements
247 247
 
248 248
             // Open in a new window?
249 249
             if (newServerWindowCheck.isSelected()
250
-                    || getController().getServerManager().numServers() == 0
250
+                    || getController().getMain().getServerManager().numServers() == 0
251 251
                     || getController().getMainFrame().getActiveFrame() == null) {
252 252
 
253 253
                 new LoggingSwingWorker<Void, Void>() {
254 254
                     @Override
255 255
                     protected Void doInBackground() {
256
-                        final Server server = getController().getServerManager().createServer(address, profile);
256
+                        final Server server = new Server(getController().getMain().getServerManager(), address, profile);
257 257
                         server.connect();
258 258
                         return null;
259 259
                     }
@@ -268,7 +268,7 @@ public final class NewServerDialog extends StandardDialog implements
268 268
                     @Override
269 269
                     protected Void doInBackground() {
270 270
                         if (server == null) {
271
-                            final Server newServer = getController().getServerManager().createServer(address, profile);
271
+                            final Server newServer = new Server(getController().getMain().getServerManager(), address, profile);
272 272
                             newServer.connect();
273 273
                         } else {
274 274
                             server.connect(address, profile);

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

@@ -81,7 +81,7 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
81 81
                     + "no resource manager");
82 82
         } else {
83 83
             addCoreLicences(rm);
84
-            for (PluginInfo pi : controller.getPluginManager()
84
+            for (PluginInfo pi : controller.getMain().getPluginManager()
85 85
                     .getPluginInfos()) {
86 86
                 addPluginLicences(pi);
87 87
             }

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

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_web;
24 24
 
25 25
 import com.dmdirc.Channel;
26
+import com.dmdirc.Server;
26 27
 import com.dmdirc.addons.ui_web.uicomponents.WebInputHandler;
27 28
 import com.dmdirc.addons.ui_web.uicomponents.WebInputWindow;
28 29
 import com.dmdirc.addons.ui_web.uicomponents.WebWindow;
@@ -277,7 +278,7 @@ public class DynamicRequestHandler extends AbstractHandler {
277 278
     private void doNewServer(final HttpServletRequest request)
278 279
             throws IOException {
279 280
         try {
280
-            controller.getMain().getServerManager().createServer(
281
+            new Server(controller.getMain().getServerManager(),
281 282
                     new URI("irc://" + request.getParameter("password") + "@"
282 283
                     + request.getParameter("server") + ":"
283 284
                     + request.getParameter("port")),

+ 3
- 8
src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.ui_web;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.plugins.BasePlugin;
27
-import com.dmdirc.plugins.PluginManager;
28 27
 
29 28
 import lombok.Getter;
30 29
 
@@ -42,24 +41,20 @@ public class WebInterfacePlugin extends BasePlugin {
42 41
     @Getter
43 42
     private WebInterfaceUI controller;
44 43
 
45
-    /** Plugin manager. */
46
-    private final PluginManager pluginManager;
47
-
48 44
     /**
49 45
      * Create a new WebInterfacePlugin
50 46
      *
51 47
      * @param main The instance of main that this client uses.
52 48
      */
53
-    public WebInterfacePlugin(final PluginManager pluginManager, final Main main) {
49
+    public WebInterfacePlugin(final Main main) {
54 50
         this.main = main;
55
-        this.pluginManager = pluginManager;
56 51
     }
57 52
 
58 53
     /** {@inheritDoc} */
59 54
     @Override
60 55
     public void onLoad() {
61 56
         if (controller == null) {
62
-            controller = new WebInterfaceUI(pluginManager, main, getDomain());
57
+            controller = new WebInterfaceUI(main, getDomain());
63 58
         }
64 59
     }
65 60
 
@@ -70,7 +65,7 @@ public class WebInterfacePlugin extends BasePlugin {
70 65
      */
71 66
     public void addWebHandler(final Handler newHandler) {
72 67
         if (controller == null) {
73
-            controller = new WebInterfaceUI(pluginManager, main, getDomain());
68
+            controller = new WebInterfaceUI(main, getDomain());
74 69
         }
75 70
 
76 71
         controller.addWebHandler(newHandler);

+ 1
- 9
src/com/dmdirc/addons/ui_web/WebInterfaceUI.java View File

@@ -29,7 +29,6 @@ import com.dmdirc.Server;
29 29
 import com.dmdirc.addons.ui_web.uicomponents.WebStatusBar;
30 30
 import com.dmdirc.interfaces.ui.UIController;
31 31
 import com.dmdirc.interfaces.ui.Window;
32
-import com.dmdirc.plugins.PluginManager;
33 32
 import com.dmdirc.ui.core.components.StatusBarManager;
34 33
 
35 34
 import java.net.URI;
@@ -61,22 +60,15 @@ public class WebInterfaceUI implements UIController {
61 60
     /** Instance of Main that owns us. */
62 61
     private final Main main;
63 62
 
64
-    /** Plugin manager. */
65
-    @Getter
66
-    private final PluginManager pluginManager;
67
-
68 63
     /**
69 64
      * Creates a new WebInterfaceUI belonging to the specified plugin.
70 65
      *
71
-     * @param pluginManager Plugin manager
72 66
      * @param domain The domain to retrieve config settings from
73 67
      */
74
-    public WebInterfaceUI(final PluginManager pluginManager,
75
-            final Main main, final String domain) {
68
+    public WebInterfaceUI(final Main main, final String domain) {
76 69
         super();
77 70
 
78 71
         this.main = main;
79
-        this.pluginManager = pluginManager;
80 72
         final SecurityHandler sh = new SecurityHandler();
81 73
         final Constraint constraint = new Constraint();
82 74
         final ConstraintMapping cm = new ConstraintMapping();

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

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

+ 65
- 0
test/com/dmdirc/addons/redirect/RedirectCommandTest.java View File

@@ -0,0 +1,65 @@
1
+/*
2
+ * Copyright (c) 2006-2012 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.redirect;
24
+
25
+import com.dmdirc.TestMain;
26
+import com.dmdirc.MessageTarget;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandManager;
29
+import com.dmdirc.commandparser.commands.context.ChatCommandContext;
30
+import com.dmdirc.commandparser.commands.global.Echo;
31
+import com.dmdirc.config.IdentityManager;
32
+import com.dmdirc.config.InvalidIdentityFileException;
33
+import com.dmdirc.interfaces.ui.InputWindow;
34
+
35
+import org.junit.BeforeClass;
36
+import org.junit.Ignore;
37
+import org.junit.Test;
38
+
39
+import static org.mockito.Mockito.*;
40
+
41
+public class RedirectCommandTest {
42
+
43
+    @BeforeClass
44
+    public static void setupClass() throws InvalidIdentityFileException {
45
+        TestMain.getTestMain();
46
+        CommandManager.getCommandManager().registerCommand(new Echo(), Echo.INFO);
47
+    }
48
+
49
+    @Ignore
50
+    @Test
51
+    public void testExecute() {
52
+        final RedirectCommand command = new RedirectCommand();
53
+        final MessageTarget target = mock(MessageTarget.class);
54
+        final InputWindow window = mock(InputWindow.class);
55
+        //when(window.getCommandParser()).thenReturn(parser);
56
+        when(window.getContainer().getConfigManager()).thenReturn(
57
+                IdentityManager.getIdentityManager().getGlobalConfiguration());
58
+
59
+        command.execute(target, new CommandArguments("/redirect /echo test"),
60
+                new ChatCommandContext(window.getContainer(), RedirectCommand.INFO, target));
61
+
62
+        verify(target).sendLine("test");
63
+    }
64
+
65
+}

Loading…
Cancel
Save