|
@@ -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
|
|