|
@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_swing.framemanager.tree;
|
25
|
25
|
import com.dmdirc.ClientModule.GlobalConfig;
|
26
|
26
|
import com.dmdirc.DMDircMBassador;
|
27
|
27
|
import com.dmdirc.FrameContainer;
|
|
28
|
+import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
|
28
|
29
|
import com.dmdirc.addons.ui_swing.SwingController;
|
29
|
30
|
import com.dmdirc.addons.ui_swing.SwingWindowFactory;
|
30
|
31
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
|
@@ -36,8 +37,9 @@ import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
|
36
|
37
|
import com.dmdirc.addons.ui_swing.injection.SwingEventBus;
|
37
|
38
|
import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
|
38
|
39
|
import com.dmdirc.events.FrameIconChangedEvent;
|
|
40
|
+import com.dmdirc.events.NotificationClearedEvent;
|
|
41
|
+import com.dmdirc.events.NotificationSetEvent;
|
39
|
42
|
import com.dmdirc.events.UserErrorEvent;
|
40
|
|
-import com.dmdirc.interfaces.NotificationListener;
|
41
|
43
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
42
|
44
|
import com.dmdirc.interfaces.config.ConfigChangeListener;
|
43
|
45
|
import com.dmdirc.logger.ErrorLevel;
|
|
@@ -67,12 +69,12 @@ import javax.swing.tree.TreePath;
|
67
|
69
|
import net.miginfocom.swing.MigLayout;
|
68
|
70
|
|
69
|
71
|
import net.engio.mbassy.listener.Handler;
|
|
72
|
+import net.engio.mbassy.listener.Invoke;
|
70
|
73
|
|
71
|
74
|
/**
|
72
|
75
|
* Manages open windows in the application in a tree style view.
|
73
|
76
|
*/
|
74
|
|
-public class TreeFrameManager implements FrameManager, Serializable, ConfigChangeListener,
|
75
|
|
- NotificationListener {
|
|
77
|
+public class TreeFrameManager implements FrameManager, Serializable, ConfigChangeListener {
|
76
|
78
|
|
77
|
79
|
/** Serial version UID. */
|
78
|
80
|
private static final long serialVersionUID = 5;
|
|
@@ -178,6 +180,7 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
178
|
180
|
|
179
|
181
|
setColours();
|
180
|
182
|
|
|
183
|
+ eventBus.subscribe(TreeFrameManager.this);
|
181
|
184
|
swingEventBus.subscribe(TreeFrameManager.this);
|
182
|
185
|
redoTreeView();
|
183
|
186
|
}
|
|
@@ -220,8 +223,6 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
220
|
223
|
eventBus.unsubscribe(nodes.get(window.getContainer()).getLabel());
|
221
|
224
|
nodes.remove(window.getContainer());
|
222
|
225
|
}
|
223
|
|
- window.getContainer().removeNotificationListener(
|
224
|
|
- TreeFrameManager.this);
|
225
|
226
|
}
|
226
|
227
|
});
|
227
|
228
|
}
|
|
@@ -256,10 +257,10 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
256
|
257
|
tree.scrollRectToVisible(new Rectangle(0, (int) view.getY(),
|
257
|
258
|
0, 0));
|
258
|
259
|
}
|
259
|
|
- window.addNotificationListener(TreeFrameManager.this);
|
260
|
260
|
|
261
|
261
|
// TODO: Should this colour be configurable?
|
262
|
|
- node.getLabel().notificationSet(window, window.getNotification().or(Colour.BLACK));
|
|
262
|
+ node.getLabel().notificationSet(new NotificationSetEvent(window,
|
|
263
|
+ window.getNotification().or(Colour.BLACK)));
|
263
|
264
|
node.getLabel().iconChanged(new FrameIconChangedEvent(window, window.getIcon()));
|
264
|
265
|
}
|
265
|
266
|
});
|
|
@@ -378,44 +379,32 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
378
|
379
|
}
|
379
|
380
|
}
|
380
|
381
|
|
381
|
|
- @Override
|
382
|
|
- public void notificationSet(final FrameContainer window, final Colour colour) {
|
383
|
|
- SwingUtilities.invokeLater(new Runnable() {
|
384
|
|
-
|
385
|
|
- @Override
|
386
|
|
- public void run() {
|
|
382
|
+ @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
|
|
383
|
+ public void notificationSet(final NotificationSetEvent event) {
|
387
|
384
|
synchronized (nodes) {
|
388
|
|
- final TreeViewNode node = nodes.get(window);
|
389
|
|
- if (window != null && node != null) {
|
|
385
|
+ final TreeViewNode node = nodes.get(event.getWindow());
|
|
386
|
+ if (event.getWindow() != null && node != null) {
|
390
|
387
|
final NodeLabel label = node.getLabel();
|
391
|
388
|
if (label != null) {
|
392
|
|
- label.notificationSet(window, colour);
|
|
389
|
+ label.notificationSet(event);
|
393
|
390
|
tree.repaint();
|
394
|
391
|
}
|
395
|
392
|
}
|
396
|
393
|
}
|
397
|
|
- }
|
398
|
|
- });
|
399
|
394
|
}
|
400
|
395
|
|
401
|
|
- @Override
|
402
|
|
- public void notificationCleared(final FrameContainer window) {
|
403
|
|
- SwingUtilities.invokeLater(new Runnable() {
|
404
|
|
-
|
405
|
|
- @Override
|
406
|
|
- public void run() {
|
|
396
|
+ @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
|
|
397
|
+ public void notificationCleared(final NotificationClearedEvent event) {
|
407
|
398
|
synchronized (nodes) {
|
408
|
|
- final TreeViewNode node = nodes.get(window);
|
409
|
|
- if (window != null && node != null) {
|
|
399
|
+ final TreeViewNode node = nodes.get(event.getWindow());
|
|
400
|
+ if (event.getWindow() != null && node != null) {
|
410
|
401
|
final NodeLabel label = node.getLabel();
|
411
|
402
|
if (label != null) {
|
412
|
|
- label.notificationCleared(window);
|
|
403
|
+ label.notificationCleared(event);
|
413
|
404
|
tree.repaint();
|
414
|
405
|
}
|
415
|
406
|
}
|
416
|
407
|
}
|
417
|
|
- }
|
418
|
|
- });
|
419
|
408
|
}
|
420
|
409
|
|
421
|
410
|
}
|