Browse Source

Fix debug plugin after parser changes.

pull/392/head
Greg Holmes 9 years ago
parent
commit
1a0a0f027f

+ 4
- 4
parserdebug/src/com/dmdirc/addons/parserdebug/DebugWindow.java View File

@@ -26,7 +26,6 @@ import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.interfaces.Connection;
28 28
 import com.dmdirc.parser.interfaces.Parser;
29
-import com.dmdirc.parser.interfaces.callbacks.DebugInfoListener;
30 29
 import com.dmdirc.ui.core.components.WindowComponent;
31 30
 import com.dmdirc.ui.messages.BackBufferFactory;
32 31
 
@@ -40,7 +39,7 @@ import java.util.Optional;
40 39
 public class DebugWindow extends FrameContainer {
41 40
 
42 41
     /** The debug listener for this window. */
43
-    protected final DebugInfoListener listener;
42
+    protected final Object listener;
44 43
     /** The parser this window is debugging. */
45 44
     protected Parser parser;
46 45
     /** The connection we're operating on. */
@@ -50,7 +49,8 @@ public class DebugWindow extends FrameContainer {
50 49
      * Creates a new instance of DebugWindow.
51 50
      */
52 51
     public DebugWindow(
53
-            final DebugInfoListener listener,
52
+            // TODO: Icky.
53
+            final Object listener,
54 54
             final String title,
55 55
             final Parser parser,
56 56
             final Connection connection,
@@ -88,7 +88,7 @@ public class DebugWindow extends FrameContainer {
88 88
 
89 89
         // Remove any callbacks or listeners
90 90
         if (parser != null) {
91
-            parser.getCallbackManager().delCallback(DebugInfoListener.class, listener);
91
+            parser.getCallbackManager().unsubscribe(listener);
92 92
         }
93 93
     }
94 94
 

+ 8
- 8
parserdebug/src/com/dmdirc/addons/parserdebug/ParserDebugManager.java View File

@@ -26,8 +26,8 @@ import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.events.ServerDisconnectedEvent;
27 27
 import com.dmdirc.interfaces.Connection;
28 28
 import com.dmdirc.parser.common.CallbackNotFoundException;
29
+import com.dmdirc.parser.events.DebugInfoEvent;
29 30
 import com.dmdirc.parser.interfaces.Parser;
30
-import com.dmdirc.parser.interfaces.callbacks.DebugInfoListener;
31 31
 import com.dmdirc.ui.WindowManager;
32 32
 import com.dmdirc.ui.messages.BackBufferFactory;
33 33
 import com.dmdirc.util.URLBuilder;
@@ -40,7 +40,7 @@ import javax.inject.Inject;
40 40
 
41 41
 import net.engio.mbassy.listener.Handler;
42 42
 
43
-public class ParserDebugManager implements DebugInfoListener {
43
+public class ParserDebugManager {
44 44
 
45 45
     /** Event bus to subscribe to events on. */
46 46
     private final DMDircMBassador eventBus;
@@ -97,7 +97,7 @@ public class ParserDebugManager implements DebugInfoListener {
97 97
      */
98 98
     public boolean addParser(final Parser parser, final Connection connection) {
99 99
         try {
100
-            parser.getCallbackManager().addCallback(DebugInfoListener.class, this);
100
+            parser.getCallbackManager().subscribe(this);
101 101
             final DebugWindow window = new DebugWindow(this, "Parser Debug", parser,
102 102
                     connection, eventBus, backBufferFactory);
103 103
             windowManager.addWindow(connection.getWindowModel(), window);
@@ -121,7 +121,7 @@ public class ParserDebugManager implements DebugInfoListener {
121 121
      */
122 122
     public boolean removeParser(final Parser parser, final boolean close) {
123 123
         try {
124
-            parser.getCallbackManager().delCallback(DebugInfoListener.class, this);
124
+            parser.getCallbackManager().unsubscribe(this);
125 125
             final DebugWindow window = registeredParsers.get(parser);
126 126
             window.addLine("======================", new Date());
127 127
             window.addLine("No Longer Monitoring: " + parser + " (User Requested)", new Date());
@@ -155,11 +155,11 @@ public class ParserDebugManager implements DebugInfoListener {
155 155
             }
156 156
     }
157 157
 
158
-    @Override
159
-    public void onDebugInfo(final Parser parser, final Date date, final int level, final String data) {
160
-        final DebugWindow window = registeredParsers.get(parser);
158
+    @Handler
159
+    public void onDebugInfo(final DebugInfoEvent event) {
160
+        final DebugWindow window = registeredParsers.get(event.getParser());
161 161
         if (window != null) {
162
-            window.addLine(String.format("[%d] %s%n", level, data), new Date());
162
+            window.addLine(String.format("[%d] %s%n", event.getLevel(), event.getData()), new Date());
163 163
         }
164 164
     }
165 165
 

Loading…
Cancel
Save