Browse Source

Notifications work once again

git-svn-id: http://svn.dmdirc.com/trunk@2475 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Gregory Holmes 17 years ago
parent
commit
dbdc7064b2

+ 21
- 2
src/com/dmdirc/ui/swing/framemanager/buttonbar/ButtonBar.java View File

@@ -26,6 +26,7 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.FrameContainerComparator;
27 27
 import com.dmdirc.Main;
28 28
 import com.dmdirc.config.IdentityManager;
29
+import com.dmdirc.interfaces.NotificationListener;
29 30
 import com.dmdirc.ui.interfaces.FrameManager;
30 31
 import com.dmdirc.ui.interfaces.FramemanagerPosition;
31 32
 import com.dmdirc.ui.interfaces.Window;
@@ -61,14 +62,14 @@ import javax.swing.SwingConstants;
61 62
  * @author chris
62 63
  */
63 64
 public final class ButtonBar implements FrameManager, ActionListener,
64
-        ComponentListener, Serializable {
65
+        ComponentListener, Serializable, NotificationListener {
65 66
     
66 67
     /**
67 68
      * A version number for this class. It should be changed whenever the class
68 69
      * structure is changed (or anything else that would prevent serialized
69 70
      * objects being unserialized with the new class).
70 71
      */
71
-    private static final long serialVersionUID = 1;
72
+    private static final long serialVersionUID = 2;
72 73
     
73 74
     /** A map of parent containers to their respective windows. */
74 75
     private final Map<FrameContainer, List<FrameContainer>> windows;
@@ -235,6 +236,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
235 236
         addButton(window);
236 237
         
237 238
         relayout();
239
+        window.addNotificationListener(this);
238 240
     }
239 241
     
240 242
     /** {@inheritDoc} */
@@ -242,6 +244,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
242 244
         windows.remove(window);
243 245
         
244 246
         relayout();
247
+        window.removeNotificationListener(this);
245 248
     }
246 249
         
247 250
     /** {@inheritDoc} */
@@ -250,6 +253,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
250 253
         addButton(window);
251 254
         
252 255
         relayout();
256
+        window.addNotificationListener(this);
253 257
     }
254 258
     
255 259
     /** {@inheritDoc} */
@@ -257,6 +261,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
257 261
         windows.get(parent).remove(window);
258 262
         
259 263
         relayout();
264
+        window.removeNotificationListener(this);
260 265
     }
261 266
     
262 267
     /** {@inheritDoc} */
@@ -325,4 +330,18 @@ public final class ButtonBar implements FrameManager, ActionListener,
325 330
         // Do nothing
326 331
     }
327 332
     
333
+    
334
+    /** {@inheritDoc} */
335
+    @Override
336
+    public void notificationSet(final Window window, final Color colour) {
337
+        if (buttons.containsKey(window)) {
338
+            buttons.get(window.getContainer()).setForeground(colour);
339
+        }
340
+    }
341
+
342
+    /** {@inheritDoc} */
343
+    @Override
344
+    public void notificationCleared(final Window window) {
345
+        notificationSet(window, window.getContainer().getNotification());
346
+    }
328 347
 }

+ 0
- 2
src/com/dmdirc/ui/swing/framemanager/ctrltab/CtrlTabFrameManager.java View File

@@ -23,11 +23,9 @@
23 23
 package com.dmdirc.ui.swing.framemanager.ctrltab;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Main;
27 26
 import com.dmdirc.logger.ErrorLevel;
28 27
 import com.dmdirc.logger.Logger;
29 28
 import com.dmdirc.ui.interfaces.FrameManager;
30
-import com.dmdirc.ui.swing.MainFrame;
31 29
 import com.dmdirc.ui.swing.components.TreeScroller;
32 30
 import com.dmdirc.ui.swing.framemanager.tree.TreeViewModel;
33 31
 

+ 20
- 3
src/com/dmdirc/ui/swing/framemanager/tree/TreeFrameManager.java View File

@@ -25,9 +25,11 @@ package com.dmdirc.ui.swing.framemanager.tree;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.config.ConfigChangeListener;
27 27
 import com.dmdirc.config.IdentityManager;
28
+import com.dmdirc.interfaces.NotificationListener;
28 29
 import com.dmdirc.logger.ErrorLevel;
29 30
 import com.dmdirc.logger.Logger;
30 31
 import com.dmdirc.ui.interfaces.FrameManager;
32
+import com.dmdirc.ui.interfaces.Window;
31 33
 import com.dmdirc.ui.swing.components.TreeScroller;
32 34
 import static com.dmdirc.ui.swing.UIUtilities.SMALL_BORDER;
33 35
 
@@ -66,14 +68,14 @@ import javax.swing.tree.TreeSelectionModel;
66 68
  */
67 69
 public final class TreeFrameManager implements FrameManager, MouseListener,
68 70
         ActionListener, MouseMotionListener, AdjustmentListener, Serializable,
69
-        ConfigChangeListener, TreeSelectionListener {
71
+        ConfigChangeListener, TreeSelectionListener, NotificationListener {
70 72
     
71 73
     /**
72 74
      * A version number for this class. It should be changed whenever the class
73 75
      * structure is changed (or anything else that would prevent serialized
74 76
      * objects being unserialized with the new class).
75 77
      */
76
-    private static final long serialVersionUID = 3;
78
+    private static final long serialVersionUID = 4;
77 79
     
78 80
     /** display tree. */
79 81
     private final JTree tree;
@@ -247,6 +249,7 @@ public final class TreeFrameManager implements FrameManager, MouseListener,
247 249
             }
248 250
             nodes.remove(window);
249 251
             labels.remove(node);
252
+            window.removeNotificationListener(this);
250 253
         }
251 254
     }
252 255
     
@@ -265,6 +268,7 @@ public final class TreeFrameManager implements FrameManager, MouseListener,
265 268
         tree.expandPath(new TreePath(node.getPath()).getParentPath());
266 269
         final Rectangle view = tree.getRowBounds(tree.getRowForPath(new TreePath(node.getPath())));
267 270
         tree.scrollRectToVisible(new Rectangle(0, (int) view.getY(), 0, 0));
271
+        window.addNotificationListener(this);
268 272
     }
269 273
     
270 274
     /** {@inheritDoc} */
@@ -446,5 +450,18 @@ public final class TreeFrameManager implements FrameManager, MouseListener,
446 450
         ((FrameContainer )((DefaultMutableTreeNode) e.getPath().
447 451
                 getLastPathComponent()).getUserObject()).activateFrame();
448 452
     }
449
-    
453
+
454
+    /** {@inheritDoc} */
455
+    @Override
456
+    public void notificationSet(final Window window, final Color colour) {
457
+        notificationColours.put(window.getContainer(), colour);
458
+        tree.repaint();
459
+    }
460
+
461
+    /** {@inheritDoc} */
462
+    @Override
463
+    public void notificationCleared(final Window window) {
464
+        notificationColours.remove(window.getContainer());
465
+        tree.repaint();
466
+    }
450 467
 }

Loading…
Cancel
Save