Browse Source

Event bus logging.

Change-Id: Icdc378dceb8e67692fbe2353e47ebfcc1554f679
Reviewed-on: http://gerrit.dmdirc.com/3718
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/18/3718/2
Greg Holmes 9 years ago
parent
commit
3a23dabdc9

+ 4
- 3
src/com/dmdirc/addons/ui_swing/Apple.java View File

@@ -26,9 +26,9 @@ import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.ServerManager;
27 27
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
28 28
 import com.dmdirc.events.ClientOpenedEvent;
29
+import com.dmdirc.events.UserErrorEvent;
29 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30 31
 import com.dmdirc.logger.ErrorLevel;
31
-import com.dmdirc.logger.Logger;
32 32
 import com.dmdirc.util.InvalidURIException;
33 33
 import com.dmdirc.util.URIParser;
34 34
 
@@ -104,7 +104,8 @@ public class Apple implements InvocationHandler {
104 104
                 registerOpenURLCallback();
105 105
                 eventBus.register(this);
106 106
             } catch (UnsatisfiedLinkError ule) {
107
-                Logger.appError(ErrorLevel.MEDIUM, "Unable to load JNI library.", ule);
107
+                eventBus.post(new UserErrorEvent(ErrorLevel.MEDIUM,
108
+                        ule, "Unable to load JNI library", ""));
108 109
             }
109 110
         }
110 111
     }
@@ -135,7 +136,7 @@ public class Apple implements InvocationHandler {
135 136
                     : classes);
136 137
             return method.invoke(obj, objects == null ? new Object[0] : objects);
137 138
         } catch (ReflectiveOperationException ex) {
138
-            Logger.userError(ErrorLevel.LOW, "Unable to find OS X classes");
139
+            eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to find OS X classes.", ""));
139 140
         }
140 141
 
141 142
         return null;

+ 8
- 3
src/com/dmdirc/addons/ui_swing/SwingUIInitialiser.java View File

@@ -25,10 +25,12 @@ package com.dmdirc.addons.ui_swing;
25 25
 import com.dmdirc.ClientModule.AddonConfig;
26 26
 import com.dmdirc.ClientModule.GlobalConfig;
27 27
 import com.dmdirc.addons.ui_swing.dialogs.DialogKeyListener;
28
+import com.dmdirc.events.UserErrorEvent;
28 29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 30
 import com.dmdirc.interfaces.config.ConfigProvider;
30 31
 import com.dmdirc.logger.ErrorLevel;
31
-import com.dmdirc.logger.Logger;
32
+
33
+import com.google.common.eventbus.EventBus;
32 34
 
33 35
 import java.awt.Font;
34 36
 import java.awt.KeyboardFocusManager;
@@ -50,13 +52,15 @@ public class SwingUIInitialiser {
50 52
     private final ConfigProvider addonConfig;
51 53
     private final DialogKeyListener dialogKeyListener;
52 54
     private final DMDircEventQueue eventQueue;
55
+    private final EventBus eventBus;
53 56
 
54 57
     @Inject
55
-    public SwingUIInitialiser(final Apple apple,
58
+    public SwingUIInitialiser(final EventBus eventBus, final Apple apple,
56 59
             @GlobalConfig final AggregateConfigProvider globalConfig,
57 60
             @AddonConfig final ConfigProvider addonConfig,
58 61
             final DialogKeyListener dialogKeyListener,
59 62
             final DMDircEventQueue eventQueue) {
63
+        this.eventBus = eventBus;
60 64
         this.apple = apple;
61 65
         this.globalConfig = globalConfig;
62 66
         this.addonConfig = addonConfig;
@@ -122,7 +126,8 @@ public class SwingUIInitialiser {
122 126
                             Font.PLAIN, 12));
123 127
                 } catch (UnsupportedOperationException | UnsupportedLookAndFeelException |
124 128
                         IllegalAccessException | InstantiationException | ClassNotFoundException ex) {
125
-                    Logger.userError(ErrorLevel.LOW, "Unable to set UI Settings");
129
+                    eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex,
130
+                            "Unable to set UI Settings", ""));
126 131
                 }
127 132
 
128 133
                 if ("Metal".equals(UIManager.getLookAndFeel().getName())

+ 11
- 3
src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java View File

@@ -29,11 +29,13 @@ import com.dmdirc.addons.ui_swing.components.frames.CustomInputFrameFactory;
29 29
 import com.dmdirc.addons.ui_swing.components.frames.ServerFrameFactory;
30 30
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
31 31
 import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
32
+import com.dmdirc.events.UserErrorEvent;
32 33
 import com.dmdirc.interfaces.ui.FrameListener;
33 34
 import com.dmdirc.logger.ErrorLevel;
34
-import com.dmdirc.logger.Logger;
35 35
 import com.dmdirc.util.collections.ListenerList;
36 36
 
37
+import com.google.common.eventbus.EventBus;
38
+
37 39
 import java.util.Collection;
38 40
 import java.util.HashMap;
39 41
 import java.util.Map;
@@ -60,6 +62,8 @@ public class SwingWindowFactory implements FrameListener {
60 62
     private final Provider<ActiveFrameManager> activeFrameManager;
61 63
     /** Our list of listeners. */
62 64
     private final ListenerList listeners = new ListenerList();
65
+    /** The event bus to post errors to. */
66
+    private final EventBus eventBus;
63 67
 
64 68
     /**
65 69
      * Creates a new window factory for the specified controller.
@@ -69,6 +73,7 @@ public class SwingWindowFactory implements FrameListener {
69 73
      * @param customInputFrameFactory The factory to use to produce custom input frames.
70 74
      * @param serverFrameFactory      The factory to use to produce server frames.
71 75
      * @param channelFrameFactory     The factory to use to produce channel frames.
76
+     * @param eventBus                The event bus to post errors to
72 77
      */
73 78
     @Inject
74 79
     public SwingWindowFactory(
@@ -76,8 +81,10 @@ public class SwingWindowFactory implements FrameListener {
76 81
             final CustomFrameFactory customFrameFactory,
77 82
             final CustomInputFrameFactory customInputFrameFactory,
78 83
             final ServerFrameFactory serverFrameFactory,
79
-            final ChannelFrameFactory channelFrameFactory) {
84
+            final ChannelFrameFactory channelFrameFactory,
85
+            final EventBus eventBus) {
80 86
         this.activeFrameManager = activeFrameManager;
87
+        this.eventBus = eventBus;
81 88
 
82 89
         registerImplementation(customFrameFactory);
83 90
         registerImplementation(customInputFrameFactory);
@@ -131,7 +138,8 @@ public class SwingWindowFactory implements FrameListener {
131 138
      */
132 139
     protected TextFrame doAddWindow(final FrameContainer window) {
133 140
         if (!implementations.containsKey(window.getComponents())) {
134
-            Logger.userError(ErrorLevel.HIGH, "Unable to create window: Unknown type");
141
+            eventBus.post(new UserErrorEvent(ErrorLevel.HIGH, null,
142
+                    "Unable to create window: Unknown type.", ""));
135 143
             return null;
136 144
         }
137 145
 

Loading…
Cancel
Save