|
@@ -78,14 +78,8 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
78
|
78
|
|
79
|
79
|
/** Serial version UID. */
|
80
|
80
|
private static final long serialVersionUID = 5;
|
81
|
|
- /** display tree. */
|
82
|
|
- private Tree tree;
|
83
|
|
- /** data model. */
|
84
|
|
- private TreeViewModel model;
|
85
|
81
|
/** node storage, used for adding and deleting nodes correctly. */
|
86
|
82
|
private final Map<FrameContainer, TreeViewNode> nodes;
|
87
|
|
- /** Tree scroller. */
|
88
|
|
- private TreeScroller scroller;
|
89
|
83
|
/** Configuration manager. */
|
90
|
84
|
private final AggregateConfigProvider config;
|
91
|
85
|
/** Colour manager. */
|
|
@@ -100,6 +94,12 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
100
|
94
|
private final DMDircMBassador eventBus;
|
101
|
95
|
/** Swing event bus. */
|
102
|
96
|
private final DMDircMBassador swingEventBus;
|
|
97
|
+ /** display tree. */
|
|
98
|
+ private Tree tree;
|
|
99
|
+ /** data model. */
|
|
100
|
+ private TreeViewModel model;
|
|
101
|
+ /** Tree scroller. */
|
|
102
|
+ private TreeScroller scroller;
|
103
|
103
|
|
104
|
104
|
/**
|
105
|
105
|
* Creates a new instance of the TreeFrameManager.
|
|
@@ -114,15 +114,12 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
114
|
114
|
* @param swingEventBus The swing event bus
|
115
|
115
|
*/
|
116
|
116
|
@Inject
|
117
|
|
- public TreeFrameManager(
|
118
|
|
- final WindowManager windowManager,
|
|
117
|
+ public TreeFrameManager(final WindowManager windowManager,
|
119
|
118
|
@GlobalConfig final AggregateConfigProvider globalConfig,
|
120
|
|
- final ColourManager colourManager,
|
121
|
|
- final ActiveFrameManager activeFrameManager,
|
|
119
|
+ final ColourManager colourManager, final ActiveFrameManager activeFrameManager,
|
122
|
120
|
final SwingWindowFactory windowFactory,
|
123
|
121
|
@PluginDomain(SwingController.class) final String domain,
|
124
|
|
- final DMDircMBassador eventBus,
|
125
|
|
- @SwingEventBus final DMDircMBassador swingEventBus) {
|
|
122
|
+ final DMDircMBassador eventBus, @SwingEventBus final DMDircMBassador swingEventBus) {
|
126
|
123
|
this.windowFactory = windowFactory;
|
127
|
124
|
this.windowManager = windowManager;
|
128
|
125
|
this.nodes = new HashMap<>();
|
|
@@ -138,8 +135,8 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
138
|
135
|
model = new TreeViewModel(config, new TreeViewNode(null, null));
|
139
|
136
|
tree = new Tree(TreeFrameManager.this, model, activeFrameManager, globalConfig,
|
140
|
137
|
windowFactory, domain);
|
141
|
|
- tree.setCellRenderer(new TreeViewTreeCellRenderer(config, colourManager,
|
142
|
|
- TreeFrameManager.this));
|
|
138
|
+ tree.setCellRenderer(
|
|
139
|
+ new TreeViewTreeCellRenderer(config, colourManager, TreeFrameManager.this));
|
143
|
140
|
tree.setVisible(true);
|
144
|
141
|
|
145
|
142
|
config.addChangeListener("treeview", TreeFrameManager.this);
|
|
@@ -169,8 +166,7 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
169
|
166
|
public void run() {
|
170
|
167
|
final JScrollPane scrollPane = new JScrollPane(tree);
|
171
|
168
|
scrollPane.setAutoscrolls(true);
|
172
|
|
- scrollPane.setHorizontalScrollBarPolicy(
|
173
|
|
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
|
169
|
+ scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
174
|
170
|
|
175
|
171
|
parent.setVisible(false);
|
176
|
172
|
parent.setLayout(new MigLayout("ins 0, fill"));
|
|
@@ -213,9 +209,9 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
213
|
209
|
}
|
214
|
210
|
final DefaultMutableTreeNode node = nodes.get(window.getContainer());
|
215
|
211
|
if (node.getLevel() == 0) {
|
216
|
|
- eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM,
|
217
|
|
- new IllegalArgumentException(),
|
218
|
|
- "delServer triggered for root node" + node.toString(), ""));
|
|
212
|
+ eventBus.publishAsync(
|
|
213
|
+ new UserErrorEvent(ErrorLevel.MEDIUM, new IllegalArgumentException(),
|
|
214
|
+ "delServer triggered for root node" + node.toString(), ""));
|
219
|
215
|
} else {
|
220
|
216
|
model.removeNodeFromParent(nodes.get(window.getContainer()));
|
221
|
217
|
}
|
|
@@ -233,8 +229,7 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
233
|
229
|
* @param parent Parent node
|
234
|
230
|
* @param window Window to add
|
235
|
231
|
*/
|
236
|
|
- public void addWindow(final TreeViewNode parent,
|
237
|
|
- final FrameContainer window) {
|
|
232
|
+ public void addWindow(final TreeViewNode parent, final FrameContainer window) {
|
238
|
233
|
UIUtilities.invokeAndWait(new Runnable() {
|
239
|
234
|
|
240
|
235
|
@Override
|
|
@@ -254,8 +249,7 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
254
|
249
|
final Rectangle view = tree.getRowBounds(tree.getRowForPath(new TreePath(node.
|
255
|
250
|
getPath())));
|
256
|
251
|
if (view != null) {
|
257
|
|
- tree.scrollRectToVisible(new Rectangle(0, (int) view.getY(),
|
258
|
|
- 0, 0));
|
|
252
|
+ tree.scrollRectToVisible(new Rectangle(0, (int) view.getY(), 0, 0));
|
259
|
253
|
}
|
260
|
254
|
|
261
|
255
|
// TODO: Should this colour be configurable?
|
|
@@ -298,16 +292,12 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
298
|
292
|
|
299
|
293
|
/** Sets treeview colours. */
|
300
|
294
|
private void setColours() {
|
301
|
|
- tree.setBackground(UIUtilities.convertColour(
|
302
|
|
- colourManager.getColourFromString(
|
303
|
|
- config.getOptionString(
|
304
|
|
- "treeview", "backgroundcolour",
|
305
|
|
- "ui", "backgroundcolour"), null)));
|
306
|
|
- tree.setForeground(UIUtilities.convertColour(
|
307
|
|
- colourManager.getColourFromString(
|
308
|
|
- config.getOptionString(
|
309
|
|
- "treeview", "foregroundcolour",
|
310
|
|
- "ui", "foregroundcolour"), null)));
|
|
295
|
+ tree.setBackground(UIUtilities.convertColour(colourManager.getColourFromString(
|
|
296
|
+ config.getOptionString("treeview", "backgroundcolour", "ui",
|
|
297
|
+ "backgroundcolour"), null)));
|
|
298
|
+ tree.setForeground(UIUtilities.convertColour(colourManager.getColourFromString(
|
|
299
|
+ config.getOptionString("treeview", "foregroundcolour", "ui",
|
|
300
|
+ "foregroundcolour"), null)));
|
311
|
301
|
|
312
|
302
|
tree.repaint();
|
313
|
303
|
}
|
|
@@ -330,8 +320,7 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
330
|
320
|
@Override
|
331
|
321
|
public void run() {
|
332
|
322
|
((DefaultTreeModel) tree.getModel()).setRoot(null);
|
333
|
|
- ((DefaultTreeModel) tree.getModel()).setRoot(new TreeViewNode(
|
334
|
|
- null, null));
|
|
323
|
+ ((DefaultTreeModel) tree.getModel()).setRoot(new TreeViewNode(null, null));
|
335
|
324
|
if (scroller != null) {
|
336
|
325
|
scroller.unregister();
|
337
|
326
|
}
|
|
@@ -367,8 +356,8 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
367
|
356
|
|
368
|
357
|
@Override
|
369
|
358
|
public void run() {
|
370
|
|
- final TreeNode[] treePath = ((DefaultTreeModel) tree.getModel()).getPathToRoot(
|
371
|
|
- nodes.get(window.getContainer()));
|
|
359
|
+ final TreeNode[] treePath = ((DefaultTreeModel) tree.getModel())
|
|
360
|
+ .getPathToRoot(nodes.get(window.getContainer()));
|
372
|
361
|
if (treePath != null && treePath.length > 0) {
|
373
|
362
|
final TreePath path = new TreePath(treePath);
|
374
|
363
|
tree.setTreePath(path);
|
|
@@ -381,30 +370,30 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
|
381
|
370
|
|
382
|
371
|
@Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
|
383
|
372
|
public void notificationSet(final NotificationSetEvent event) {
|
384
|
|
- synchronized (nodes) {
|
385
|
|
- final TreeViewNode node = nodes.get(event.getWindow());
|
386
|
|
- if (event.getWindow() != null && node != null) {
|
387
|
|
- final NodeLabel label = node.getLabel();
|
388
|
|
- if (label != null) {
|
389
|
|
- label.notificationSet(event);
|
390
|
|
- tree.repaint();
|
391
|
|
- }
|
392
|
|
- }
|
|
373
|
+ synchronized (nodes) {
|
|
374
|
+ final TreeViewNode node = nodes.get(event.getWindow());
|
|
375
|
+ if (event.getWindow() != null && node != null) {
|
|
376
|
+ final NodeLabel label = node.getLabel();
|
|
377
|
+ if (label != null) {
|
|
378
|
+ label.notificationSet(event);
|
|
379
|
+ tree.repaint();
|
393
|
380
|
}
|
|
381
|
+ }
|
|
382
|
+ }
|
394
|
383
|
}
|
395
|
384
|
|
396
|
385
|
@Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
|
397
|
386
|
public void notificationCleared(final NotificationClearedEvent event) {
|
398
|
|
- synchronized (nodes) {
|
399
|
|
- final TreeViewNode node = nodes.get(event.getWindow());
|
400
|
|
- if (event.getWindow() != null && node != null) {
|
401
|
|
- final NodeLabel label = node.getLabel();
|
402
|
|
- if (label != null) {
|
403
|
|
- label.notificationCleared(event);
|
404
|
|
- tree.repaint();
|
405
|
|
- }
|
406
|
|
- }
|
|
387
|
+ synchronized (nodes) {
|
|
388
|
+ final TreeViewNode node = nodes.get(event.getWindow());
|
|
389
|
+ if (event.getWindow() != null && node != null) {
|
|
390
|
+ final NodeLabel label = node.getLabel();
|
|
391
|
+ if (label != null) {
|
|
392
|
+ label.notificationCleared(event);
|
|
393
|
+ tree.repaint();
|
407
|
394
|
}
|
|
395
|
+ }
|
|
396
|
+ }
|
408
|
397
|
}
|
409
|
398
|
|
410
|
399
|
}
|