Browse Source

Merge pull request #412 from csmith/master

Remove CallbackNotFoundException usages.
pull/417/head
Greg Holmes 9 years ago
parent
commit
5bfd27482a

+ 5
- 11
parserdebug/src/com/dmdirc/addons/parserdebug/ParserDebugCommand.java View File

51
             + "onDebugInfo for the parser that owns this window",
51
             + "onDebugInfo for the parser that owns this window",
52
             CommandType.TYPE_SERVER);
52
             CommandType.TYPE_SERVER);
53
     /** Parser debug manager. */
53
     /** Parser debug manager. */
54
-    final ParserDebugManager parserDebugManager;
54
+    private final ParserDebugManager parserDebugManager;
55
 
55
 
56
     /**
56
     /**
57
      * Creates a new instance of ParserDebugCommand.
57
      * Creates a new instance of ParserDebugCommand.
86
             return;
86
             return;
87
         }
87
         }
88
         if (parserDebugManager.containsParser(parser.get())) {
88
         if (parserDebugManager.containsParser(parser.get())) {
89
-            if (parserDebugManager.removeParser(parser.get(), false)) {
90
-                sendLine(origin, isSilent, FORMAT_OUTPUT, "Removing callback ok");
91
-            } else {
92
-                sendLine(origin, isSilent, FORMAT_ERROR, "Removing callback failed");
93
-            }
89
+            parserDebugManager.removeParser(parser.get(), false);
90
+            sendLine(origin, isSilent, FORMAT_OUTPUT, "Removed callback");
94
         } else {
91
         } else {
95
-            if (parserDebugManager.addParser(parser.get(), connection)) {
96
-                sendLine(origin, isSilent, FORMAT_OUTPUT, "Adding callback ok");
97
-            } else {
98
-                sendLine(origin, isSilent, FORMAT_ERROR, "Adding callback failed");
99
-            }
92
+            parserDebugManager.addParser(parser.get(), connection);
93
+            sendLine(origin, isSilent, FORMAT_OUTPUT, "Added callback");
100
         }
94
         }
101
     }
95
     }
102
 
96
 

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

25
 import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.events.ServerDisconnectedEvent;
26
 import com.dmdirc.events.ServerDisconnectedEvent;
27
 import com.dmdirc.interfaces.Connection;
27
 import com.dmdirc.interfaces.Connection;
28
-import com.dmdirc.parser.common.CallbackNotFoundException;
29
 import com.dmdirc.parser.events.DebugInfoEvent;
28
 import com.dmdirc.parser.events.DebugInfoEvent;
30
 import com.dmdirc.parser.interfaces.Parser;
29
 import com.dmdirc.parser.interfaces.Parser;
31
 import com.dmdirc.ui.WindowManager;
30
 import com.dmdirc.ui.WindowManager;
32
 import com.dmdirc.ui.messages.BackBufferFactory;
31
 import com.dmdirc.ui.messages.BackBufferFactory;
33
-import com.dmdirc.util.URLBuilder;
34
 
32
 
35
 import java.util.Date;
33
 import java.util.Date;
36
 import java.util.HashMap;
34
 import java.util.HashMap;
52
 
50
 
53
     @Inject
51
     @Inject
54
     public ParserDebugManager(
52
     public ParserDebugManager(
55
-            final URLBuilder urlBuilder,
56
             final WindowManager windowManager,
53
             final WindowManager windowManager,
57
             final DMDircMBassador eventBus,
54
             final DMDircMBassador eventBus,
58
             final BackBufferFactory backBufferFactory) {
55
             final BackBufferFactory backBufferFactory) {
92
      *
89
      *
93
      * @param parser Parser to add
90
      * @param parser Parser to add
94
      * @param connection The connection associated with the parser
91
      * @param connection The connection associated with the parser
95
-     *
96
-     * @return Whether we added the parser without error
97
      */
92
      */
98
-    public boolean addParser(final Parser parser, final Connection connection) {
99
-        try {
100
-            parser.getCallbackManager().subscribe(this);
101
-            final DebugWindow window = new DebugWindow(this, "Parser Debug", parser,
102
-                    connection, eventBus, backBufferFactory);
103
-            windowManager.addWindow(connection.getWindowModel(), window);
104
-            registeredParsers.put(parser, window);
105
-            window.addLine("======================", new Date());
106
-            window.addLine("Started Monitoring: " + parser, new Date());
107
-            window.addLine("======================", new Date());
108
-            return true;
109
-        } catch (CallbackNotFoundException ex) {
110
-            return false;
111
-        }
93
+    public void addParser(final Parser parser, final Connection connection) {
94
+        parser.getCallbackManager().subscribe(this);
95
+        final DebugWindow window = new DebugWindow(this, "Parser Debug", parser,
96
+                connection, eventBus, backBufferFactory);
97
+        windowManager.addWindow(connection.getWindowModel(), window);
98
+        registeredParsers.put(parser, window);
99
+        window.addLine("======================", new Date());
100
+        window.addLine("Started Monitoring: " + parser, new Date());
101
+        window.addLine("======================", new Date());
112
     }
102
     }
113
 
103
 
114
     /**
104
     /**
116
      *
106
      *
117
      * @param parser Parser to add
107
      * @param parser Parser to add
118
      * @param close  Close debug window?
108
      * @param close  Close debug window?
119
-     *
120
-     * @return Whether removed the parser without error
121
      */
109
      */
122
-    public boolean removeParser(final Parser parser, final boolean close) {
123
-        try {
124
-            parser.getCallbackManager().unsubscribe(this);
125
-            final DebugWindow window = registeredParsers.get(parser);
126
-            window.addLine("======================", new Date());
127
-            window.addLine("No Longer Monitoring: " + parser + " (User Requested)", new Date());
128
-            window.addLine("======================", new Date());
129
-            if (close) {
130
-                window.close();
131
-            }
132
-            registeredParsers.remove(parser);
133
-            return true;
134
-        } catch (CallbackNotFoundException ex) {
135
-            return false;
110
+    public void removeParser(final Parser parser, final boolean close) {
111
+        parser.getCallbackManager().unsubscribe(this);
112
+        final DebugWindow window = registeredParsers.get(parser);
113
+        window.addLine("======================", new Date());
114
+        window.addLine("No Longer Monitoring: " + parser + " (User Requested)", new Date());
115
+        window.addLine("======================", new Date());
116
+        if (close) {
117
+            window.close();
136
         }
118
         }
119
+        registeredParsers.remove(parser);
137
     }
120
     }
138
 
121
 
139
     /**
122
     /**

Loading…
Cancel
Save