Procházet zdrojové kódy

Remove some usages of Main.

Change-Id: Ie4d579ba97c2c1ed8a727f6548bdd9ae98981bdf
Depends-On: I5f88cccf81f0fb80e2fcf915d453660d5690c8c0
Reviewed-on: http://gerrit.dmdirc.com/2709
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8
Chris Smith před 10 roky
rodič
revize
fdde3a55cd

+ 5
- 4
src/com/dmdirc/addons/ui_dummy/DummyInputHandler.java Zobrazit soubor

@@ -26,7 +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
+import com.dmdirc.plugins.ServiceManager;
30 30
 
31 31
 /**
32 32
  * Dummy input handler.
@@ -37,16 +37,17 @@ public class DummyInputHandler extends InputHandler {
37 37
      * Creates a new instance of InputHandler. Adds listeners to the target
38 38
      * that we need to operate.
39 39
      *
40
-     * @param controller The controller that owns us.
40
+     * @param serviceManager Manager to use to look up tab completion services.
41 41
      * @param target The text field this input handler is dealing with.
42 42
      * @param commandParser The command parser to use for this text field.
43 43
      * @param parentWindow The window that owns this input handler
44 44
      */
45
-    public DummyInputHandler(final UIController controller,
45
+    public DummyInputHandler(
46
+            final ServiceManager serviceManager,
46 47
             final InputField target,
47 48
             final CommandParser commandParser,
48 49
             final WritableFrameContainer parentWindow) {
49
-        super(controller, target, commandParser, parentWindow);
50
+        super(serviceManager, target, commandParser, parentWindow);
50 51
     }
51 52
 
52 53
     /** {@inheritDoc} */

+ 5
- 1
src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java Zobrazit soubor

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_dummy;
24 24
 
25
+import com.dmdirc.Main;
25 26
 import com.dmdirc.WritableFrameContainer;
26 27
 import com.dmdirc.ui.input.InputHandler;
27 28
 import com.dmdirc.interfaces.ui.InputWindow;
@@ -51,7 +52,10 @@ public class DummyInputWindow implements InputWindow {
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public InputHandler getInputHandler() {
54
-        return new DummyInputHandler(controller, new DummyInputField(), null,
55
+        return new DummyInputHandler(
56
+                Main.mainInstance.getPluginManager(),
57
+                new DummyInputField(),
58
+                null,
55 59
                 getContainer());
56 60
     }
57 61
 

+ 2
- 1
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Zobrazit soubor

@@ -128,7 +128,8 @@ public class TopicBar extends JComponent implements ActionListener,
128 128
                 channelFrame.getIconManager().getIcon("close"),
129 129
                 channelFrame.getIconManager().getIcon("close-active"));
130 130
 
131
-        final SwingInputHandler handler = new SwingInputHandler(controller, topicText,
131
+        final SwingInputHandler handler = new SwingInputHandler(
132
+                controller.getPluginManager(), topicText,
132 133
                 channelFrame.getContainer().getCommandParser(),
133 134
                 channelFrame.getContainer());
134 135
         handler.setTypes(true, false, true, false);

+ 2
- 2
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java Zobrazit soubor

@@ -131,8 +131,8 @@ 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(controller, inputField,
135
-                getContainer().getCommandParser(), getContainer());
134
+        inputHandler = new SwingInputHandler(controller.getPluginManager(),
135
+                inputField, getContainer().getCommandParser(), getContainer());
136 136
         inputHandler.addValidationListener(inputField);
137 137
         inputHandler.setTabCompleter(((WritableFrameContainer) frameParent).
138 138
                 getTabCompleter());

+ 5
- 4
src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java Zobrazit soubor

@@ -28,9 +28,9 @@ 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;
32 31
 import com.dmdirc.logger.ErrorLevel;
33 32
 import com.dmdirc.logger.Logger;
33
+import com.dmdirc.plugins.ServiceManager;
34 34
 import com.dmdirc.ui.input.InputHandler;
35 35
 
36 36
 import java.awt.event.ActionEvent;
@@ -52,16 +52,17 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
52 52
      * Creates a new instance of InputHandler. Adds listeners to the target
53 53
      * that we need to operate.
54 54
      *
55
-     * @param controller The UIController that owns this input handler.
55
+     * @param serviceManager Manager to use to look up tab completion services.
56 56
      * @param target The text field this input handler is dealing with.
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 UIController controller,
60
+    public SwingInputHandler(
61
+            final ServiceManager serviceManager,
61 62
             final InputField target,
62 63
             final CommandParser commandParser,
63 64
             final WritableFrameContainer parentWindow) {
64
-        super(controller, target, commandParser, parentWindow);
65
+        super(serviceManager, target, commandParser, parentWindow);
65 66
     }
66 67
 
67 68
     /** {@inheritDoc} */

+ 3
- 2
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java Zobrazit soubor

@@ -104,8 +104,9 @@ 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(parent.getController(),
108
-                topicText, channel.getCommandParser(), channelWindow.getContainer());
107
+        final SwingInputHandler handler = new SwingInputHandler(
108
+                parent.getController().getPluginManager(), topicText,
109
+                channel.getCommandParser(), channelWindow.getContainer());
109 110
         handler.setTypes(true, false, true, false);
110 111
         handler.setTabCompleter(channel.getTabCompleter());
111 112
 

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/paste/PasteDialog.java Zobrazit soubor

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

+ 1
- 2
src/com/dmdirc/addons/ui_web/StaticRequestHandler.java Zobrazit soubor

@@ -60,8 +60,7 @@ public class StaticRequestHandler extends AbstractHandler {
60 60
 
61 61
         if (rm == null) {
62 62
             try {
63
-                rm = controller.getMain().getPluginManager()
64
-                    .getPluginInfoByName("ui_web").getResourceManager();
63
+                rm = controller.getPluginInfo().getResourceManager();
65 64
             } catch (IOException ex) {
66 65
                 // Die horribly
67 66
             }

+ 19
- 3
src/com/dmdirc/addons/ui_web/WebInterfacePlugin.java Zobrazit soubor

@@ -24,6 +24,8 @@ package com.dmdirc.addons.ui_web;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.ServerManager;
27
+import com.dmdirc.plugins.PluginInfo;
28
+import com.dmdirc.plugins.PluginManager;
27 29
 import com.dmdirc.plugins.implementations.BasePlugin;
28 30
 
29 31
 import lombok.Getter;
@@ -41,6 +43,12 @@ public class WebInterfacePlugin extends BasePlugin {
41 43
     /** Server manager to use. */
42 44
     private final ServerManager serverManager;
43 45
 
46
+    /** Plugin manager to use. */
47
+    private final PluginManager pluginManager;
48
+
49
+    /** This plugin's information object. */
50
+    private final PluginInfo pluginInfo;
51
+
44 52
     /** The UI that we're using. */
45 53
     @Getter
46 54
     private WebInterfaceUI controller;
@@ -50,19 +58,26 @@ public class WebInterfacePlugin extends BasePlugin {
50 58
      *
51 59
      * @param main The instance of main that this client uses.
52 60
      * @param serverManager Server manager to use.
61
+     * @param pluginManager Plugin manager to use.
62
+     * @param pluginInfo This plugin's info object.
53 63
      */
54 64
     public WebInterfacePlugin(
55 65
             final Main main,
56
-            final ServerManager serverManager) {
66
+            final ServerManager serverManager,
67
+            final PluginManager pluginManager,
68
+            final PluginInfo pluginInfo) {
57 69
         this.main = main;
58 70
         this.serverManager = serverManager;
71
+        this.pluginManager = pluginManager;
72
+        this.pluginInfo = pluginInfo;
59 73
     }
60 74
 
61 75
     /** {@inheritDoc} */
62 76
     @Override
63 77
     public void onLoad() {
64 78
         if (controller == null) {
65
-            controller = new WebInterfaceUI(main, getDomain(), serverManager);
79
+            controller = new WebInterfaceUI(main, getDomain(), serverManager,
80
+                    pluginManager, pluginInfo);
66 81
         }
67 82
     }
68 83
 
@@ -73,7 +88,8 @@ public class WebInterfacePlugin extends BasePlugin {
73 88
      */
74 89
     public void addWebHandler(final Handler newHandler) {
75 90
         if (controller == null) {
76
-            controller = new WebInterfaceUI(main, getDomain(), serverManager);
91
+            controller = new WebInterfaceUI(main, getDomain(), serverManager,
92
+                    pluginManager, pluginInfo);
77 93
         }
78 94
 
79 95
         controller.addWebHandler(newHandler);

+ 19
- 1
src/com/dmdirc/addons/ui_web/WebInterfaceUI.java Zobrazit soubor

@@ -30,6 +30,8 @@ import com.dmdirc.ServerManager;
30 30
 import com.dmdirc.addons.ui_web.uicomponents.WebStatusBar;
31 31
 import com.dmdirc.interfaces.ui.UIController;
32 32
 import com.dmdirc.interfaces.ui.Window;
33
+import com.dmdirc.plugins.PluginInfo;
34
+import com.dmdirc.plugins.PluginManager;
33 35
 import com.dmdirc.ui.core.components.StatusBarManager;
34 36
 
35 37
 import java.net.URI;
@@ -61,18 +63,34 @@ public class WebInterfaceUI implements UIController {
61 63
     /** Instance of Main that owns us. */
62 64
     private final Main main;
63 65
 
66
+    /** The PluginInfo object for this plugin. */
67
+    @Getter
68
+    private final PluginInfo pluginInfo;
69
+
70
+    /** The plugin manager used to find other plugins. */
71
+    @Getter
72
+    private final PluginManager pluginManager;
73
+
64 74
     /**
65 75
      * Creates a new WebInterfaceUI belonging to the specified plugin.
66 76
      *
67 77
      * @param domain The domain to retrieve config settings from
78
+     * @param serverManager The manager to use to find and create servers
79
+     * @param pluginManager The manager to use to find other plugins
80
+     * @param pluginInfo The information object for this UI's plugin.
68 81
      */
69 82
     public WebInterfaceUI(
70 83
             final Main main,
71 84
             final String domain,
72
-            final ServerManager serverManager) {
85
+            final ServerManager serverManager,
86
+            final PluginManager pluginManager,
87
+            final PluginInfo pluginInfo) {
73 88
         super();
74 89
 
75 90
         this.main = main;
91
+        this.pluginManager = pluginManager;
92
+        this.pluginInfo = pluginInfo;
93
+
76 94
         final SecurityHandler sh = new SecurityHandler();
77 95
         final Constraint constraint = new Constraint();
78 96
         final ConstraintMapping cm = new ConstraintMapping();

+ 7
- 6
src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java Zobrazit soubor

@@ -25,7 +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
+import com.dmdirc.plugins.ServiceManager;
29 29
 import com.dmdirc.ui.input.InputHandler;
30 30
 import com.dmdirc.ui.input.TabCompleter;
31 31
 
@@ -34,11 +34,12 @@ import com.dmdirc.ui.input.TabCompleter;
34 34
  */
35 35
 public class WebInputHandler extends InputHandler {
36 36
 
37
-    public WebInputHandler(final UIController controller,
38
-                           final InputField thisTarget,
39
-                           final CommandParser thisCommandParser,
40
-                           final WritableFrameContainer thisParentWindow) {
41
-        super(controller, thisTarget, thisCommandParser, thisParentWindow);
37
+    public WebInputHandler(
38
+            final ServiceManager serviceManager,
39
+            final InputField thisTarget,
40
+            final CommandParser thisCommandParser,
41
+            final WritableFrameContainer thisParentWindow) {
42
+        super(serviceManager, thisTarget, thisCommandParser, thisParentWindow);
42 43
     }
43 44
 
44 45
     public InputField getTarget() {

+ 6
- 6
src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java Zobrazit soubor

@@ -47,8 +47,7 @@ public class WebInputWindow extends WebWindow implements InputWindow {
47 47
 
48 48
     private final WebInputHandler inputHandler;
49 49
 
50
-    private final Map<Client, WebInputHandler> inputHandlers
51
-            = new HashMap<Client, WebInputHandler>();
50
+    private final Map<Client, WebInputHandler> inputHandlers = new HashMap<>();
52 51
 
53 52
     private final WebInterfaceUI controller;
54 53
 
@@ -58,8 +57,8 @@ public class WebInputWindow extends WebWindow implements InputWindow {
58 57
         this.container = parent;
59 58
         this.commandparser = parent.getCommandParser();
60 59
         this.controller = controller;
61
-        this.inputHandler = new WebInputHandler(controller, new WebInputField(),
62
-                commandparser, getContainer());
60
+        this.inputHandler = new WebInputHandler(controller.getPluginManager(),
61
+                new WebInputField(), commandparser, getContainer());
63 62
     }
64 63
 
65 64
     /** {@inheritDoc} */
@@ -70,8 +69,9 @@ public class WebInputWindow extends WebWindow implements InputWindow {
70 69
 
71 70
     public WebInputHandler getInputHandler(final Client client) {
72 71
         if (!inputHandlers.containsKey(client)) {
73
-            final WebInputHandler ih = new WebInputHandler(controller,
74
-                    new WebInputField(client), commandparser, getContainer());
72
+            final WebInputHandler ih = new WebInputHandler(
73
+                    controller.getPluginManager(), new WebInputField(client),
74
+                    commandparser, getContainer());
75 75
             ih.setTabCompleter(inputHandler.getTabCompleter());
76 76
             inputHandlers.put(client, ih);
77 77
         }

Načítá se…
Zrušit
Uložit