|
@@ -26,6 +26,7 @@ import com.dmdirc.CustomWindow;
|
26
|
26
|
import com.dmdirc.DMDircMBassador;
|
27
|
27
|
import com.dmdirc.Precondition;
|
28
|
28
|
import com.dmdirc.events.FrameClosingEvent;
|
|
29
|
+import com.dmdirc.events.FrameOpenedEvent;
|
29
|
30
|
import com.dmdirc.interfaces.WindowModel;
|
30
|
31
|
import com.dmdirc.interfaces.ui.FrameListener;
|
31
|
32
|
import com.dmdirc.util.collections.ListenerList;
|
|
@@ -67,12 +68,15 @@ public class WindowManager {
|
67
|
68
|
private final ListenerList listeners = new ListenerList();
|
68
|
69
|
/** Counter to use for ID assignments. */
|
69
|
70
|
private final AtomicLong nextId = new AtomicLong(0L);
|
|
71
|
+ /** Event bus to dispatch window events on. */
|
|
72
|
+ private final DMDircMBassador eventBus;
|
70
|
73
|
|
71
|
74
|
/**
|
72
|
75
|
* Creates a new instance of {@link WindowManager}.
|
73
|
76
|
*/
|
74
|
77
|
@Inject
|
75
|
78
|
public WindowManager(final DMDircMBassador eventBus) {
|
|
79
|
+ this.eventBus = eventBus;
|
76
|
80
|
eventBus.subscribe(this);
|
77
|
81
|
}
|
78
|
82
|
|
|
@@ -238,7 +242,7 @@ public class WindowManager {
|
238
|
242
|
*
|
239
|
243
|
* @return True if the target is in the hierarchy, false otherwise
|
240
|
244
|
*/
|
241
|
|
- protected boolean isInHierarchy(final WindowModel target) {
|
|
245
|
+ private boolean isInHierarchy(final WindowModel target) {
|
242
|
246
|
return rootWindows.contains(target) || parents.containsKey(target);
|
243
|
247
|
}
|
244
|
248
|
|
|
@@ -366,6 +370,7 @@ public class WindowManager {
|
366
|
370
|
* @param focus Should this window become focused
|
367
|
371
|
*/
|
368
|
372
|
private void fireAddWindow(final WindowModel window, final boolean focus) {
|
|
373
|
+ eventBus.publishAsync(new FrameOpenedEvent(window));
|
369
|
374
|
for (FrameListener listener : listeners.get(FrameListener.class)) {
|
370
|
375
|
listener.addWindow(window, focus);
|
371
|
376
|
}
|
|
@@ -381,6 +386,7 @@ public class WindowManager {
|
381
|
386
|
*/
|
382
|
387
|
private void fireAddWindow(final WindowModel parent,
|
383
|
388
|
final WindowModel child, final boolean focus) {
|
|
389
|
+ eventBus.publishAsync(new FrameOpenedEvent(child, parent));
|
384
|
390
|
for (FrameListener listener : listeners.get(FrameListener.class)) {
|
385
|
391
|
listener.addWindow(parent, child, focus);
|
386
|
392
|
}
|