|
@@ -31,17 +31,19 @@ import com.dmdirc.addons.ui_swing.components.TreeScroller;
|
31
|
31
|
import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
|
32
|
32
|
import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
|
33
|
33
|
import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
|
|
34
|
+import com.dmdirc.events.UserErrorEvent;
|
34
|
35
|
import com.dmdirc.interfaces.FrameInfoListener;
|
35
|
36
|
import com.dmdirc.interfaces.NotificationListener;
|
36
|
37
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
37
|
38
|
import com.dmdirc.interfaces.config.ConfigChangeListener;
|
38
|
39
|
import com.dmdirc.logger.ErrorLevel;
|
39
|
|
-import com.dmdirc.logger.Logger;
|
40
|
40
|
import com.dmdirc.plugins.PluginDomain;
|
41
|
41
|
import com.dmdirc.ui.Colour;
|
42
|
42
|
import com.dmdirc.ui.WindowManager;
|
43
|
43
|
import com.dmdirc.ui.messages.ColourManager;
|
44
|
44
|
|
|
45
|
+import com.google.common.eventbus.EventBus;
|
|
46
|
+
|
45
|
47
|
import java.awt.Rectangle;
|
46
|
48
|
import java.awt.event.MouseEvent;
|
47
|
49
|
import java.io.Serializable;
|
|
@@ -65,9 +67,8 @@ import net.miginfocom.swing.MigLayout;
|
65
|
67
|
/**
|
66
|
68
|
* Manages open windows in the application in a tree style view.
|
67
|
69
|
*/
|
68
|
|
-public class TreeFrameManager implements FrameManager,
|
69
|
|
- Serializable, ConfigChangeListener, NotificationListener,
|
70
|
|
- FrameInfoListener {
|
|
70
|
+public class TreeFrameManager implements FrameManager, Serializable, ConfigChangeListener,
|
|
71
|
+ NotificationListener, FrameInfoListener {
|
71
|
72
|
|
72
|
73
|
/** Serial version UID. */
|
73
|
74
|
private static final long serialVersionUID = 5;
|
|
@@ -89,6 +90,8 @@ public class TreeFrameManager implements FrameManager,
|
89
|
90
|
private final WindowManager windowManager;
|
90
|
91
|
/** Active frame manager. */
|
91
|
92
|
private final ActiveFrameManager activeFrameManager;
|
|
93
|
+ /** The event bus to post errors to. */
|
|
94
|
+ private final EventBus eventBus;
|
92
|
95
|
|
93
|
96
|
/**
|
94
|
97
|
* Creates a new instance of the TreeFrameManager.
|
|
@@ -99,6 +102,7 @@ public class TreeFrameManager implements FrameManager,
|
99
|
102
|
* @param activeFrameManager The active window manager
|
100
|
103
|
* @param windowFactory The factory to use to retrieve swing windows.
|
101
|
104
|
* @param domain The domain to read settings from.
|
|
105
|
+ * @param eventBus The event bus to post errors to
|
102
|
106
|
*/
|
103
|
107
|
@Inject
|
104
|
108
|
public TreeFrameManager(
|
|
@@ -107,13 +111,15 @@ public class TreeFrameManager implements FrameManager,
|
107
|
111
|
final ColourManager colourManager,
|
108
|
112
|
final ActiveFrameManager activeFrameManager,
|
109
|
113
|
final SwingWindowFactory windowFactory,
|
110
|
|
- @PluginDomain(SwingController.class) final String domain) {
|
|
114
|
+ @PluginDomain(SwingController.class) final String domain,
|
|
115
|
+ final EventBus eventBus) {
|
111
|
116
|
this.windowFactory = windowFactory;
|
112
|
117
|
this.windowManager = windowManager;
|
113
|
118
|
this.nodes = new HashMap<>();
|
114
|
119
|
this.config = globalConfig;
|
115
|
120
|
this.colourManager = colourManager;
|
116
|
121
|
this.activeFrameManager = activeFrameManager;
|
|
122
|
+ this.eventBus = eventBus;
|
117
|
123
|
|
118
|
124
|
UIUtilities.invokeLater(new Runnable() {
|
119
|
125
|
@Override
|
|
@@ -186,15 +192,14 @@ public class TreeFrameManager implements FrameManager,
|
186
|
192
|
|
187
|
193
|
@Override
|
188
|
194
|
public void run() {
|
189
|
|
- if (nodes == null || nodes.get(window.getContainer()) == null) {
|
|
195
|
+ if (nodes.get(window.getContainer()) == null) {
|
190
|
196
|
return;
|
191
|
197
|
}
|
192
|
198
|
final DefaultMutableTreeNode node = nodes.get(window.getContainer());
|
193
|
199
|
if (node.getLevel() == 0) {
|
194
|
|
- Logger.appError(ErrorLevel.MEDIUM,
|
195
|
|
- "delServer triggered for root node"
|
196
|
|
- + node.toString(),
|
197
|
|
- new IllegalArgumentException());
|
|
200
|
+ eventBus.post(new UserErrorEvent(ErrorLevel.MEDIUM,
|
|
201
|
+ new IllegalArgumentException(),
|
|
202
|
+ "delServer triggered for root node" + node.toString(), ""));
|
198
|
203
|
} else {
|
199
|
204
|
model.removeNodeFromParent(nodes.get(window.getContainer()));
|
200
|
205
|
}
|
|
@@ -321,8 +326,7 @@ public class TreeFrameManager implements FrameManager,
|
321
|
326
|
|
322
|
327
|
for (FrameContainer window : windowManager.getRootWindows()) {
|
323
|
328
|
addWindow(null, window);
|
324
|
|
- final Collection<FrameContainer> childWindows = window
|
325
|
|
- .getChildren();
|
|
329
|
+ final Collection<FrameContainer> childWindows = window.getChildren();
|
326
|
330
|
for (FrameContainer childWindow : childWindows) {
|
327
|
331
|
addWindow(nodes.get(window), childWindow);
|
328
|
332
|
}
|