Browse Source

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 10 years ago
parent
commit
fdde3a55cd

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

26
 import com.dmdirc.commandparser.parsers.CommandParser;
26
 import com.dmdirc.commandparser.parsers.CommandParser;
27
 import com.dmdirc.ui.input.InputHandler;
27
 import com.dmdirc.ui.input.InputHandler;
28
 import com.dmdirc.interfaces.ui.InputField;
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
  * Dummy input handler.
32
  * Dummy input handler.
37
      * Creates a new instance of InputHandler. Adds listeners to the target
37
      * Creates a new instance of InputHandler. Adds listeners to the target
38
      * that we need to operate.
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
      * @param target The text field this input handler is dealing with.
41
      * @param target The text field this input handler is dealing with.
42
      * @param commandParser The command parser to use for this text field.
42
      * @param commandParser The command parser to use for this text field.
43
      * @param parentWindow The window that owns this input handler
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
             final InputField target,
47
             final InputField target,
47
             final CommandParser commandParser,
48
             final CommandParser commandParser,
48
             final WritableFrameContainer parentWindow) {
49
             final WritableFrameContainer parentWindow) {
49
-        super(controller, target, commandParser, parentWindow);
50
+        super(serviceManager, target, commandParser, parentWindow);
50
     }
51
     }
51
 
52
 
52
     /** {@inheritDoc} */
53
     /** {@inheritDoc} */

+ 5
- 1
src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java View File

22
 
22
 
23
 package com.dmdirc.addons.ui_dummy;
23
 package com.dmdirc.addons.ui_dummy;
24
 
24
 
25
+import com.dmdirc.Main;
25
 import com.dmdirc.WritableFrameContainer;
26
 import com.dmdirc.WritableFrameContainer;
26
 import com.dmdirc.ui.input.InputHandler;
27
 import com.dmdirc.ui.input.InputHandler;
27
 import com.dmdirc.interfaces.ui.InputWindow;
28
 import com.dmdirc.interfaces.ui.InputWindow;
51
     /** {@inheritDoc} */
52
     /** {@inheritDoc} */
52
     @Override
53
     @Override
53
     public InputHandler getInputHandler() {
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
                 getContainer());
59
                 getContainer());
56
     }
60
     }
57
 
61
 

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

128
                 channelFrame.getIconManager().getIcon("close"),
128
                 channelFrame.getIconManager().getIcon("close"),
129
                 channelFrame.getIconManager().getIcon("close-active"));
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
                 channelFrame.getContainer().getCommandParser(),
133
                 channelFrame.getContainer().getCommandParser(),
133
                 channelFrame.getContainer());
134
                 channelFrame.getContainer());
134
         handler.setTypes(true, false, true, false);
135
         handler.setTypes(true, false, true, false);

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

131
      */
131
      */
132
     private void initComponents() {
132
     private void initComponents() {
133
         inputField = new SwingInputField(this, getController().getMainFrame());
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
         inputHandler.addValidationListener(inputField);
136
         inputHandler.addValidationListener(inputField);
137
         inputHandler.setTabCompleter(((WritableFrameContainer) frameParent).
137
         inputHandler.setTabCompleter(((WritableFrameContainer) frameParent).
138
                 getTabCompleter());
138
                 getTabCompleter());

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

28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29
 import com.dmdirc.commandparser.parsers.CommandParser;
29
 import com.dmdirc.commandparser.parsers.CommandParser;
30
 import com.dmdirc.interfaces.ui.InputField;
30
 import com.dmdirc.interfaces.ui.InputField;
31
-import com.dmdirc.interfaces.ui.UIController;
32
 import com.dmdirc.logger.ErrorLevel;
31
 import com.dmdirc.logger.ErrorLevel;
33
 import com.dmdirc.logger.Logger;
32
 import com.dmdirc.logger.Logger;
33
+import com.dmdirc.plugins.ServiceManager;
34
 import com.dmdirc.ui.input.InputHandler;
34
 import com.dmdirc.ui.input.InputHandler;
35
 
35
 
36
 import java.awt.event.ActionEvent;
36
 import java.awt.event.ActionEvent;
52
      * Creates a new instance of InputHandler. Adds listeners to the target
52
      * Creates a new instance of InputHandler. Adds listeners to the target
53
      * that we need to operate.
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
      * @param target The text field this input handler is dealing with.
56
      * @param target The text field this input handler is dealing with.
57
      * @param commandParser The command parser to use for this text field.
57
      * @param commandParser The command parser to use for this text field.
58
      * @param parentWindow The window that owns this input handler
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
             final InputField target,
62
             final InputField target,
62
             final CommandParser commandParser,
63
             final CommandParser commandParser,
63
             final WritableFrameContainer parentWindow) {
64
             final WritableFrameContainer parentWindow) {
64
-        super(controller, target, commandParser, parentWindow);
65
+        super(serviceManager, target, commandParser, parentWindow);
65
     }
66
     }
66
 
67
 
67
     /** {@inheritDoc} */
68
     /** {@inheritDoc} */

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

104
         topicText.setWrapStyleWord(true);
104
         topicText.setWrapStyleWord(true);
105
         topicText.setRows(5);
105
         topicText.setRows(5);
106
         topicText.setColumns(30);
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
         handler.setTypes(true, false, true, false);
110
         handler.setTypes(true, false, true, false);
110
         handler.setTabCompleter(channel.getTabCompleter());
111
         handler.setTabCompleter(channel.getTabCompleter());
111
 
112
 

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

121
         textField.setColumns(50);
121
         textField.setColumns(50);
122
         textField.setRows(10);
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
                 .setTypes(false, false, true,false);
126
                 .setTypes(false, false, true,false);
127
 
127
 
128
         scrollPane.setViewportView(textField);
128
         scrollPane.setViewportView(textField);

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

60
 
60
 
61
         if (rm == null) {
61
         if (rm == null) {
62
             try {
62
             try {
63
-                rm = controller.getMain().getPluginManager()
64
-                    .getPluginInfoByName("ui_web").getResourceManager();
63
+                rm = controller.getPluginInfo().getResourceManager();
65
             } catch (IOException ex) {
64
             } catch (IOException ex) {
66
                 // Die horribly
65
                 // Die horribly
67
             }
66
             }

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

24
 
24
 
25
 import com.dmdirc.Main;
25
 import com.dmdirc.Main;
26
 import com.dmdirc.ServerManager;
26
 import com.dmdirc.ServerManager;
27
+import com.dmdirc.plugins.PluginInfo;
28
+import com.dmdirc.plugins.PluginManager;
27
 import com.dmdirc.plugins.implementations.BasePlugin;
29
 import com.dmdirc.plugins.implementations.BasePlugin;
28
 
30
 
29
 import lombok.Getter;
31
 import lombok.Getter;
41
     /** Server manager to use. */
43
     /** Server manager to use. */
42
     private final ServerManager serverManager;
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
     /** The UI that we're using. */
52
     /** The UI that we're using. */
45
     @Getter
53
     @Getter
46
     private WebInterfaceUI controller;
54
     private WebInterfaceUI controller;
50
      *
58
      *
51
      * @param main The instance of main that this client uses.
59
      * @param main The instance of main that this client uses.
52
      * @param serverManager Server manager to use.
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
     public WebInterfacePlugin(
64
     public WebInterfacePlugin(
55
             final Main main,
65
             final Main main,
56
-            final ServerManager serverManager) {
66
+            final ServerManager serverManager,
67
+            final PluginManager pluginManager,
68
+            final PluginInfo pluginInfo) {
57
         this.main = main;
69
         this.main = main;
58
         this.serverManager = serverManager;
70
         this.serverManager = serverManager;
71
+        this.pluginManager = pluginManager;
72
+        this.pluginInfo = pluginInfo;
59
     }
73
     }
60
 
74
 
61
     /** {@inheritDoc} */
75
     /** {@inheritDoc} */
62
     @Override
76
     @Override
63
     public void onLoad() {
77
     public void onLoad() {
64
         if (controller == null) {
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
      */
88
      */
74
     public void addWebHandler(final Handler newHandler) {
89
     public void addWebHandler(final Handler newHandler) {
75
         if (controller == null) {
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
         controller.addWebHandler(newHandler);
95
         controller.addWebHandler(newHandler);

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

30
 import com.dmdirc.addons.ui_web.uicomponents.WebStatusBar;
30
 import com.dmdirc.addons.ui_web.uicomponents.WebStatusBar;
31
 import com.dmdirc.interfaces.ui.UIController;
31
 import com.dmdirc.interfaces.ui.UIController;
32
 import com.dmdirc.interfaces.ui.Window;
32
 import com.dmdirc.interfaces.ui.Window;
33
+import com.dmdirc.plugins.PluginInfo;
34
+import com.dmdirc.plugins.PluginManager;
33
 import com.dmdirc.ui.core.components.StatusBarManager;
35
 import com.dmdirc.ui.core.components.StatusBarManager;
34
 
36
 
35
 import java.net.URI;
37
 import java.net.URI;
61
     /** Instance of Main that owns us. */
63
     /** Instance of Main that owns us. */
62
     private final Main main;
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
      * Creates a new WebInterfaceUI belonging to the specified plugin.
75
      * Creates a new WebInterfaceUI belonging to the specified plugin.
66
      *
76
      *
67
      * @param domain The domain to retrieve config settings from
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
     public WebInterfaceUI(
82
     public WebInterfaceUI(
70
             final Main main,
83
             final Main main,
71
             final String domain,
84
             final String domain,
72
-            final ServerManager serverManager) {
85
+            final ServerManager serverManager,
86
+            final PluginManager pluginManager,
87
+            final PluginInfo pluginInfo) {
73
         super();
88
         super();
74
 
89
 
75
         this.main = main;
90
         this.main = main;
91
+        this.pluginManager = pluginManager;
92
+        this.pluginInfo = pluginInfo;
93
+
76
         final SecurityHandler sh = new SecurityHandler();
94
         final SecurityHandler sh = new SecurityHandler();
77
         final Constraint constraint = new Constraint();
95
         final Constraint constraint = new Constraint();
78
         final ConstraintMapping cm = new ConstraintMapping();
96
         final ConstraintMapping cm = new ConstraintMapping();

+ 7
- 6
src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java View File

25
 import com.dmdirc.WritableFrameContainer;
25
 import com.dmdirc.WritableFrameContainer;
26
 import com.dmdirc.commandparser.parsers.CommandParser;
26
 import com.dmdirc.commandparser.parsers.CommandParser;
27
 import com.dmdirc.interfaces.ui.InputField;
27
 import com.dmdirc.interfaces.ui.InputField;
28
-import com.dmdirc.interfaces.ui.UIController;
28
+import com.dmdirc.plugins.ServiceManager;
29
 import com.dmdirc.ui.input.InputHandler;
29
 import com.dmdirc.ui.input.InputHandler;
30
 import com.dmdirc.ui.input.TabCompleter;
30
 import com.dmdirc.ui.input.TabCompleter;
31
 
31
 
34
  */
34
  */
35
 public class WebInputHandler extends InputHandler {
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
     public InputField getTarget() {
45
     public InputField getTarget() {

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

47
 
47
 
48
     private final WebInputHandler inputHandler;
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
     private final WebInterfaceUI controller;
52
     private final WebInterfaceUI controller;
54
 
53
 
58
         this.container = parent;
57
         this.container = parent;
59
         this.commandparser = parent.getCommandParser();
58
         this.commandparser = parent.getCommandParser();
60
         this.controller = controller;
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
     /** {@inheritDoc} */
64
     /** {@inheritDoc} */
70
 
69
 
71
     public WebInputHandler getInputHandler(final Client client) {
70
     public WebInputHandler getInputHandler(final Client client) {
72
         if (!inputHandlers.containsKey(client)) {
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
             ih.setTabCompleter(inputHandler.getTabCompleter());
75
             ih.setTabCompleter(inputHandler.getTabCompleter());
76
             inputHandlers.put(client, ih);
76
             inputHandlers.put(client, ih);
77
         }
77
         }

Loading…
Cancel
Save