Bladeren bron

Rest of the plugin uses of getOptionColour.

Change-Id: Ia5208e2dc03c352982fb6a1c49f81825c5ed773f
Reviewed-on: http://gerrit.dmdirc.com/3077
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith 10 jaren geleden
bovenliggende
commit
30f24d6fdd

+ 18
- 17
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java Bestand weergeven

@@ -36,6 +36,7 @@ import com.dmdirc.logger.ErrorLevel;
36 36
 import com.dmdirc.logger.Logger;
37 37
 import com.dmdirc.ui.Colour;
38 38
 import com.dmdirc.ui.WindowManager;
39
+import com.dmdirc.ui.messages.ColourManager;
39 40
 
40 41
 import java.awt.Rectangle;
41 42
 import java.awt.event.MouseEvent;
@@ -77,6 +78,8 @@ public class TreeFrameManager implements FrameManager,
77 78
     private TreeScroller scroller;
78 79
     /** Configuration manager. */
79 80
     private AggregateConfigProvider config;
81
+    /** Colour manager. */
82
+    private ColourManager colourManager;
80 83
     /** Window manage. */
81 84
     private final WindowManager windowManager;
82 85
 
@@ -134,6 +137,7 @@ public class TreeFrameManager implements FrameManager,
134 137
     public void setController(final SwingController controller) {
135 138
         this.controller = controller;
136 139
         this.config = controller.getGlobalConfig();
140
+        this.colourManager = controller.getColourManager();
137 141
 
138 142
         UIUtilities.invokeLater(new Runnable() {
139 143
 
@@ -142,20 +146,15 @@ public class TreeFrameManager implements FrameManager,
142 146
                 model = new TreeViewModel(config, new TreeViewNode(null, null));
143 147
                 tree = new Tree(TreeFrameManager.this, model,
144 148
                         TreeFrameManager.this.controller);
145
-                tree.setCellRenderer(new TreeViewTreeCellRenderer(config,
149
+                tree.setCellRenderer(new TreeViewTreeCellRenderer(config, colourManager,
146 150
                         TreeFrameManager.this));
147 151
                 tree.setVisible(true);
148 152
 
149
-                controller.getGlobalConfig().addChangeListener("treeview",
150
-                        TreeFrameManager.this);
151
-                controller.getGlobalConfig().addChangeListener("ui",
152
-                        "sortrootwindows", TreeFrameManager.this);
153
-                controller.getGlobalConfig().addChangeListener("ui",
154
-                        "sortchildwindows", TreeFrameManager.this);
155
-                controller.getGlobalConfig().addChangeListener("ui",
156
-                        "backgroundcolour", TreeFrameManager.this);
157
-                controller.getGlobalConfig().addChangeListener("ui",
158
-                        "foregroundcolour", TreeFrameManager.this);
153
+                config.addChangeListener("treeview", TreeFrameManager.this);
154
+                config.addChangeListener("ui", "sortrootwindows", TreeFrameManager.this);
155
+                config.addChangeListener("ui", "sortchildwindows", TreeFrameManager.this);
156
+                config.addChangeListener("ui", "backgroundcolour", TreeFrameManager.this);
157
+                config.addChangeListener("ui", "foregroundcolour", TreeFrameManager.this);
159 158
             }
160 159
         });
161 160
     }
@@ -278,13 +277,15 @@ public class TreeFrameManager implements FrameManager,
278 277
     /** Sets treeview colours. */
279 278
     private void setColours() {
280 279
         tree.setBackground(UIUtilities.convertColour(
281
-                controller.getGlobalConfig().getOptionColour(
282
-                "treeview", "backgroundcolour",
283
-                "ui", "backgroundcolour")));
280
+                colourManager.getColourFromString(
281
+                        config.getOptionString(
282
+                                "treeview", "backgroundcolour",
283
+                                "ui", "backgroundcolour"), null)));
284 284
         tree.setForeground(UIUtilities.convertColour(
285
-                controller.getGlobalConfig().getOptionColour(
286
-                "treeview", "foregroundcolour",
287
-                "ui", "foregroundcolour")));
285
+                colourManager.getColourFromString(
286
+                        config.getOptionString(
287
+                                "treeview", "foregroundcolour",
288
+                                "ui", "foregroundcolour"), null)));
288 289
 
289 290
         tree.repaint();
290 291
     }

+ 27
- 13
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeViewTreeCellRenderer.java Bestand weergeven

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_swing.framemanager.tree;
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.interfaces.config.ConfigChangeListener;
28
+import com.dmdirc.ui.messages.ColourManager;
28 29
 import com.dmdirc.ui.messages.Styliser;
29 30
 
30 31
 import java.awt.Color;
@@ -47,6 +48,8 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
47 48
     private final TreeFrameManager manager;
48 49
     /** Config manager. */
49 50
     private final AggregateConfigProvider config;
51
+    /** The colour manager to use to resolve colours. */
52
+    private final ColourManager colourManager;
50 53
     /** Styliser to use. */
51 54
     private final Styliser styliser;
52 55
     /** Rollover colours. */
@@ -62,13 +65,18 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
62 65
      * Creates a new instance of TreeViewTreeCellRenderer.
63 66
      *
64 67
      * @param config Config manager to retrieve settings from
68
+     * @param colourManager The colour manager to use to resolve colours.
65 69
      * @param manager Parent TreeFrameManager
66 70
      */
67
-    public TreeViewTreeCellRenderer(final AggregateConfigProvider config,
71
+    public TreeViewTreeCellRenderer(
72
+            final AggregateConfigProvider config,
73
+            final ColourManager colourManager,
68 74
             final TreeFrameManager manager) {
69 75
         this.manager = manager;
70 76
 
71 77
         this.config = config;
78
+        this.colourManager = colourManager;
79
+
72 80
         styliser = new Styliser(null, config);
73 81
 
74 82
         setColours();
@@ -145,18 +153,24 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
145 153
 
146 154
     /** Sets the colours for the renderer. */
147 155
     private void setColours() {
148
-        rolloverColour = UIUtilities.convertColour(config.getOptionColour(
149
-                "ui", "treeviewRolloverColour",
150
-                "treeview", "backgroundcolour",
151
-                "ui", "backgroundcolour"));
152
-        activeBackground = UIUtilities.convertColour(config.getOptionColour(
153
-                "ui", "treeviewActiveBackground",
154
-                "treeview", "backgroundcolour",
155
-                "ui", "backgroundcolour"));
156
-        activeForeground = UIUtilities.convertColour(config.getOptionColour(
157
-                "ui", "treeviewActiveForeground",
158
-                "treeview", "foregroundcolour",
159
-                "ui", "foregroundcolour"));
156
+        rolloverColour = UIUtilities.convertColour(
157
+                colourManager.getColourFromString(
158
+                        config.getOptionString(
159
+                                "ui", "treeviewRolloverColour",
160
+                                "treeview", "backgroundcolour",
161
+                                "ui", "backgroundcolour"), null));
162
+        activeBackground = UIUtilities.convertColour(
163
+                colourManager.getColourFromString(
164
+                        config.getOptionString(
165
+                                "ui", "treeviewActiveBackground",
166
+                                "treeview", "backgroundcolour",
167
+                                "ui", "backgroundcolour"), null));
168
+        activeForeground = UIUtilities.convertColour(
169
+                colourManager.getColourFromString(
170
+                        config.getOptionString(
171
+                                "ui", "treeviewActiveForeground",
172
+                                "treeview", "foregroundcolour",
173
+                                "ui", "foregroundcolour"), null));
160 174
         activeBold = config.getOptionBool("ui", "treeviewActiveBold");
161 175
 
162 176
         manager.getTree().repaint();

Laden…
Annuleren
Opslaan