|
@@ -32,7 +32,7 @@ import com.dmdirc.commandparser.CommandArguments;
|
32
|
32
|
import com.dmdirc.commandparser.commands.context.CommandContext;
|
33
|
33
|
import com.dmdirc.events.ClientLineAddedEvent;
|
34
|
34
|
import com.dmdirc.events.DMDircEvent;
|
35
|
|
-import com.dmdirc.interfaces.FrameCloseListener;
|
|
35
|
+import com.dmdirc.events.FrameClosingEvent;
|
36
|
36
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
37
|
37
|
import com.dmdirc.ui.WindowManager;
|
38
|
38
|
import com.dmdirc.ui.messages.Styliser;
|
|
@@ -44,6 +44,8 @@ import javax.inject.Inject;
|
44
|
44
|
import javax.inject.Provider;
|
45
|
45
|
|
46
|
46
|
import net.engio.mbassy.listener.Handler;
|
|
47
|
+import net.engio.mbassy.listener.Listener;
|
|
48
|
+import net.engio.mbassy.listener.References;
|
47
|
49
|
|
48
|
50
|
/**
|
49
|
51
|
* Displays events passed on an event bus.
|
|
@@ -108,13 +110,13 @@ public class EventBusViewer extends DebugCommand {
|
108
|
110
|
final DMDircMBassador eventBus = isGlobal ? globalEventBus : origin.getEventBus();
|
109
|
111
|
final WindowUpdater updater = new WindowUpdater(eventBus, window);
|
110
|
112
|
eventBus.subscribe(updater);
|
111
|
|
- window.addCloseListener(updater);
|
112
|
113
|
}
|
113
|
114
|
|
114
|
115
|
/**
|
115
|
116
|
* Updates a custom window with details of each event received on an event bus.
|
116
|
117
|
*/
|
117
|
|
- private static class WindowUpdater implements FrameCloseListener {
|
|
118
|
+ @Listener(references = References.Strong)
|
|
119
|
+ private static class WindowUpdater {
|
118
|
120
|
|
119
|
121
|
private final DMDircMBassador eventBus;
|
120
|
122
|
private final FrameContainer target;
|
|
@@ -124,6 +126,11 @@ public class EventBusViewer extends DebugCommand {
|
124
|
126
|
this.target = target;
|
125
|
127
|
}
|
126
|
128
|
|
|
129
|
+ @Handler
|
|
130
|
+ public void handleFrameClosing(final FrameClosingEvent event) {
|
|
131
|
+ eventBus.unsubscribe(this);
|
|
132
|
+ }
|
|
133
|
+
|
127
|
134
|
@Handler
|
128
|
135
|
public void handleEvent(final DMDircEvent event) {
|
129
|
136
|
if (event instanceof ClientLineAddedEvent
|
|
@@ -156,10 +163,5 @@ public class EventBusViewer extends DebugCommand {
|
156
|
163
|
target.addLine(FORMAT_OUTPUT, output.toString());
|
157
|
164
|
}
|
158
|
165
|
|
159
|
|
- @Override
|
160
|
|
- public void windowClosing(final FrameContainer window) {
|
161
|
|
- eventBus.unsubscribe(this);
|
162
|
|
- }
|
163
|
|
-
|
164
|
166
|
}
|
165
|
167
|
}
|