|
@@ -23,6 +23,7 @@
|
23
|
23
|
package com.dmdirc.addons.ui_swing.framemanager.tree;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.addons.ui_swing.SwingController;
|
|
26
|
+import com.dmdirc.addons.ui_swing.SwingWindowFactory;
|
26
|
27
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
27
|
28
|
import com.dmdirc.addons.ui_swing.actions.CloseFrameContainerAction;
|
28
|
29
|
import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
|
|
@@ -72,21 +73,32 @@ public class Tree extends JTree implements MouseMotionListener,
|
72
|
73
|
private boolean dragButton;
|
73
|
74
|
/** Show handles. */
|
74
|
75
|
private boolean showHandles;
|
|
76
|
+ /** Factory to use to retrieve swing windows. */
|
|
77
|
+ private final SwingWindowFactory windowFactory;
|
75
|
78
|
|
76
|
79
|
/**
|
77
|
80
|
* Specialised JTree for frame manager.
|
78
|
81
|
*
|
79
|
|
- * @param manager Frame manager
|
80
|
|
- * @param model tree model.
|
81
|
|
- * @param controller Swing controller
|
|
82
|
+ * @param manager Frame manager
|
|
83
|
+ * @param model tree model.
|
|
84
|
+ * @param controller Swing controller
|
|
85
|
+ * @param globalConfig The config to read settings from.
|
|
86
|
+ * @param domain The domain to read settings from.
|
|
87
|
+ * @param windowFactory The factory to use to get swing windows.
|
82
|
88
|
*/
|
83
|
|
- public Tree(final TreeFrameManager manager, final TreeModel model,
|
84
|
|
- final SwingController controller) {
|
|
89
|
+ public Tree(
|
|
90
|
+ final TreeFrameManager manager,
|
|
91
|
+ final TreeModel model,
|
|
92
|
+ final SwingController controller,
|
|
93
|
+ final AggregateConfigProvider globalConfig,
|
|
94
|
+ final SwingWindowFactory windowFactory,
|
|
95
|
+ final String domain) {
|
85
|
96
|
super(model);
|
86
|
97
|
|
87
|
98
|
this.manager = manager;
|
88
|
99
|
this.controller = controller;
|
89
|
|
- this.config = controller.getGlobalConfig();
|
|
100
|
+ this.config = globalConfig;
|
|
101
|
+ this.windowFactory = windowFactory;
|
90
|
102
|
|
91
|
103
|
putClientProperty("JTree.lineStyle", "Angled");
|
92
|
104
|
getInputMap().setParent(null);
|
|
@@ -105,8 +117,8 @@ public class Tree extends JTree implements MouseMotionListener,
|
105
|
117
|
setFocusable(false);
|
106
|
118
|
|
107
|
119
|
dragSelect = config.getOptionBool("treeview", "dragSelection");
|
108
|
|
- showHandles = config.getOptionBool(controller.getDomain(), "showtreeexpands");
|
109
|
|
- config.addChangeListener(controller.getDomain(), "showtreeexpands", this);
|
|
120
|
+ showHandles = config.getOptionBool(domain, "showtreeexpands");
|
|
121
|
+ config.addChangeListener(domain, "showtreeexpands", this);
|
110
|
122
|
config.addChangeListener("treeview", this);
|
111
|
123
|
|
112
|
124
|
setShowsRootHandles(showHandles);
|
|
@@ -162,7 +174,7 @@ public class Tree extends JTree implements MouseMotionListener,
|
162
|
174
|
dragSelect = config.getOptionBool("treeview", "dragSelection");
|
163
|
175
|
break;
|
164
|
176
|
case "showtreeexpands":
|
165
|
|
- config.getOptionBool(controller.getDomain(), "showtreeexpands");
|
|
177
|
+ showHandles = config.getOptionBool(domain, "showtreeexpands");
|
166
|
178
|
setShowsRootHandles(showHandles);
|
167
|
179
|
putClientProperty("showHandles", showHandles);
|
168
|
180
|
break;
|
|
@@ -179,9 +191,9 @@ public class Tree extends JTree implements MouseMotionListener,
|
179
|
191
|
if (dragSelect && dragButton) {
|
180
|
192
|
final TreeViewNode node = getNodeForLocation(e.getX(), e.getY());
|
181
|
193
|
if (node != null) {
|
182
|
|
- controller.requestWindowFocus(controller.getWindowFactory()
|
183
|
|
- .getSwingWindow(((TreeViewNode) new TreePath(node.getPath()).
|
184
|
|
- getLastPathComponent()).getWindow()));
|
|
194
|
+ controller.requestWindowFocus(windowFactory.getSwingWindow(
|
|
195
|
+ ((TreeViewNode) new TreePath(node.getPath()).getLastPathComponent())
|
|
196
|
+ .getWindow()));
|
185
|
197
|
}
|
186
|
198
|
}
|
187
|
199
|
manager.checkRollover(e);
|
|
@@ -219,9 +231,8 @@ public class Tree extends JTree implements MouseMotionListener,
|
219
|
231
|
final TreePath selectedPath = getPathForLocation(e.getX(),
|
220
|
232
|
e.getY());
|
221
|
233
|
if (selectedPath != null) {
|
222
|
|
- controller.requestWindowFocus(controller.getWindowFactory()
|
223
|
|
- .getSwingWindow(((TreeViewNode) selectedPath
|
224
|
|
- .getLastPathComponent()).getWindow()));
|
|
234
|
+ controller.requestWindowFocus(windowFactory.getSwingWindow(
|
|
235
|
+ ((TreeViewNode) selectedPath.getLastPathComponent()).getWindow()));
|
225
|
236
|
}
|
226
|
237
|
}
|
227
|
238
|
processMouseEvents(e);
|
|
@@ -266,7 +277,7 @@ public class Tree extends JTree implements MouseMotionListener,
|
266
|
277
|
public void processMouseEvents(final MouseEvent e) {
|
267
|
278
|
final TreePath localPath = getPathForLocation(e.getX(), e.getY());
|
268
|
279
|
if (localPath != null && e.isPopupTrigger()) {
|
269
|
|
- final TextFrame frame = controller.getWindowFactory().getSwingWindow(
|
|
280
|
+ final TextFrame frame = windowFactory.getSwingWindow(
|
270
|
281
|
((TreeViewNode) localPath.getLastPathComponent()).getWindow());
|
271
|
282
|
|
272
|
283
|
if (frame == null) {
|
|
@@ -333,10 +344,10 @@ public class Tree extends JTree implements MouseMotionListener,
|
333
|
344
|
}
|
334
|
345
|
break;
|
335
|
346
|
case "popout":
|
336
|
|
- controller.getWindowFactory().getSwingWindow(node.getWindow()).setPopout(true);
|
|
347
|
+ windowFactory.getSwingWindow(node.getWindow()).setPopout(true);
|
337
|
348
|
break;
|
338
|
349
|
case "popin":
|
339
|
|
- controller.getWindowFactory().getSwingWindow(node.getWindow()).setPopout(false);
|
|
350
|
+ windowFactory.getSwingWindow(node.getWindow()).setPopout(false);
|
340
|
351
|
break;
|
341
|
352
|
}
|
342
|
353
|
final TreeViewNode parentNode = (TreeViewNode) node.getParent();
|