Browse Source

Remove static colour manager refs

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

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

@@ -24,6 +24,7 @@ package com.dmdirc.addons.osd;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.interfaces.config.IdentityController;
27
+import com.dmdirc.ui.messages.ColourManager;
27 28
 
28 29
 import java.util.ArrayList;
29 30
 import java.util.LinkedList;
@@ -45,6 +46,8 @@ public class OsdManager {
45 46
     private final IdentityController identityController;
46 47
     /** The Plugin that owns this OSD Manager. */
47 48
     private final OsdPlugin plugin;
49
+    /** The colour manager to use to parse colours. */
50
+    private final ColourManager colourManager;
48 51
     /** List of OSD Windows. */
49 52
     private final List<OsdWindow> windowList = new ArrayList<>();
50 53
     /** List of messages to be queued. */
@@ -99,10 +102,11 @@ public class OsdManager {
99 102
             /** {@inheritDoc} */
100 103
             @Override
101 104
             public OsdWindow call() {
102
-                return new OsdWindow(identityController, timeout, message, false,
105
+                return new OsdWindow(identityController, plugin, OsdManager.this, colourManager,
106
+                        timeout, message, false,
103 107
                         identityController.getGlobalConfiguration().getOptionInt(
104 108
                         plugin.getDomain(), "locationX"), policy.getYPosition(
105
-                        OsdManager.this, startY), plugin, OsdManager.this);
109
+                        OsdManager.this, startY));
106 110
             }
107 111
         }));
108 112
     }

+ 13
- 5
src/com/dmdirc/addons/osd/OsdPlugin.java View File

@@ -25,8 +25,8 @@ package com.dmdirc.addons.osd;
25 25
 import com.dmdirc.config.prefs.CategoryChangeListener;
26 26
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
27 27
 import com.dmdirc.config.prefs.PreferencesCategory;
28
-import com.dmdirc.config.prefs.PreferencesInterface;
29 28
 import com.dmdirc.config.prefs.PreferencesDialogModel;
29
+import com.dmdirc.config.prefs.PreferencesInterface;
30 30
 import com.dmdirc.config.prefs.PreferencesSetting;
31 31
 import com.dmdirc.config.prefs.PreferencesType;
32 32
 import com.dmdirc.config.prefs.SettingChangeListener;
@@ -34,6 +34,7 @@ import com.dmdirc.interfaces.CommandController;
34 34
 import com.dmdirc.interfaces.config.IdentityController;
35 35
 import com.dmdirc.plugins.PluginInfo;
36 36
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
37
+import com.dmdirc.ui.messages.ColourManager;
37 38
 import com.dmdirc.util.validators.NumericalValidator;
38 39
 import com.dmdirc.util.validators.OptionalValidator;
39 40
 
@@ -43,7 +44,7 @@ import java.util.Map;
43 44
 /**
44 45
  * Allows the user to display on-screen-display messages.
45 46
  */
46
-public final class OsdPlugin extends BaseCommandPlugin implements
47
+public class OsdPlugin extends BaseCommandPlugin implements
47 48
         CategoryChangeListener, PreferencesInterface, SettingChangeListener {
48 49
 
49 50
     /** Config OSD Window. */
@@ -61,21 +62,27 @@ public final class OsdPlugin extends BaseCommandPlugin implements
61 62
     private final PluginInfo pluginInfo;
62 63
     /** The controller to read/write settings with. */
63 64
     private final IdentityController identityController;
65
+    /** The manager to use to parse colours. */
66
+    private final ColourManager colourManager;
64 67
 
65 68
     /**
66 69
      * Creates a new instance of this plugin.
67 70
      *
68 71
      * @param pluginInfo This plugin's plugin info
72
+     * @param identityController The controller to use to read and write settings.
69 73
      * @param commandController Command controller to register commands
74
+     * @param colourManager The manager to use to parse colours.
70 75
      */
71 76
     public OsdPlugin(
72 77
             final PluginInfo pluginInfo,
73 78
             final IdentityController identityController,
74
-            final CommandController commandController) {
79
+            final CommandController commandController,
80
+            final ColourManager colourManager) {
75 81
         super(commandController);
76 82
         this.pluginInfo = pluginInfo;
77 83
         this.identityController = identityController;
78
-        osdManager = new OsdManager(identityController, this);
84
+        this.colourManager = colourManager;
85
+        osdManager = new OsdManager(identityController, this, colourManager);
79 86
         registerCommand(new OsdCommand(commandController, osdManager), OsdCommand.INFO);
80 87
     }
81 88
 
@@ -154,7 +161,8 @@ public final class OsdPlugin extends BaseCommandPlugin implements
154 161
     /** {@inheritDoc} */
155 162
     @Override
156 163
     public void categorySelected(final PreferencesCategory category) {
157
-        osdWindow = new OsdWindow(identityController, -1, "Please drag this OSD to position", true, x, y, this, osdManager);
164
+        osdWindow = new OsdWindow(identityController, this, osdManager, colourManager, -1,
165
+                "Please drag this OSD to position", true, x, y);
158 166
         osdWindow.setBackgroundColour(backgroundSetting.getValue());
159 167
         osdWindow.setForegroundColour(foregroundSetting.getValue());
160 168
         osdWindow.setFontSize(Integer.parseInt(fontSizeSetting.getValue()));

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

@@ -25,6 +25,7 @@ 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.interfaces.config.IdentityController;
28
+import com.dmdirc.ui.Colour;
28 29
 import com.dmdirc.ui.messages.ColourManager;
29 30
 
30 31
 import java.awt.Color;
@@ -62,6 +63,9 @@ public class OsdWindow extends JDialog implements MouseListener,
62 63
     /** The OSD Manager that owns this window. */
63 64
     private final OsdManager osdManager;
64 65
 
66
+    /** The manager to use to parse colours. */
67
+    private final ColourManager colourManager;
68
+
65 69
     /** OSD Label. */
66 70
     private final JLabel label;
67 71
 
@@ -84,6 +88,7 @@ public class OsdWindow extends JDialog implements MouseListener,
84 88
      * Creates a new instance of OsdWindow.
85 89
      *
86 90
      * @param identityController The controller to read/write settings with.
91
+     * @param colourManager The manager to use to parse colours.
87 92
      * @param timeout Timeout period for the window. Set to -1 to use value from
88 93
      *        config
89 94
      * @param text The text to be displayed in the OSD window
@@ -95,12 +100,14 @@ public class OsdWindow extends JDialog implements MouseListener,
95 100
      * @param osdManager The manager that owns this OSD Window
96 101
      */
97 102
     public OsdWindow(
98
-            final IdentityController identityController,
103
+            final IdentityController identityController, final OsdPlugin plugin,
104
+            final OsdManager osdManager, final ColourManager colourManager,
99 105
             final int timeout, final String text, final boolean config, final int x,
100
-            final int y, final OsdPlugin plugin, final OsdManager osdManager) {
106
+            final int y) {
101 107
         super(((SwingController) plugin.getPluginInfo().getMetaData().getManager()
102 108
                 .getPluginInfoByName("ui_swing").getPlugin()).getMainFrame(), false);
103 109
 
110
+        this.colourManager = colourManager;
104 111
         this.config = config;
105 112
         this.osdManager = osdManager;
106 113
 
@@ -258,7 +265,7 @@ public class OsdWindow extends JDialog implements MouseListener,
258 265
      * @param colour The background colour to use
259 266
      */
260 267
     public void setBackgroundColour(final String colour) {
261
-        panel.setBackground(UIUtilities.convertColour(ColourManager.parseColour(colour)));
268
+        panel.setBackground(UIUtilities.convertColour(colourManager.getColourFromString(colour, Colour.WHITE)));
262 269
     }
263 270
 
264 271
     /**
@@ -267,7 +274,7 @@ public class OsdWindow extends JDialog implements MouseListener,
267 274
      * @param colour The foreground colour to use
268 275
      */
269 276
     public void setForegroundColour(final String colour) {
270
-        label.setForeground(UIUtilities.convertColour(ColourManager.parseColour(colour)));
277
+        label.setForeground(UIUtilities.convertColour(colourManager.getColourFromString(colour, Colour.WHITE)));
271 278
     }
272 279
 
273 280
     /** {@inheritDoc} */

Loading…
Cancel
Save