Revision 639 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/DefaultJScriptingBrowser.java
DefaultJScriptingBrowser.java | ||
---|---|---|
20 | 20 |
import javax.swing.ImageIcon; |
21 | 21 |
import javax.swing.JComponent; |
22 | 22 |
import javax.swing.JLabel; |
23 |
import javax.swing.JPanel; |
|
23 | 24 |
import javax.swing.JScrollPane; |
24 | 25 |
import javax.swing.JTree; |
25 | 26 |
import javax.swing.KeyStroke; |
... | ... | |
42 | 43 |
import org.slf4j.LoggerFactory; |
43 | 44 |
import org.slf4j.Logger; |
44 | 45 |
|
45 |
public class DefaultJScriptingBrowser extends JScriptingBrowser { |
|
46 |
public class DefaultJScriptingBrowser extends JPanel implements JScriptingBrowser {
|
|
46 | 47 |
|
47 | 48 |
private static final Logger logger = LoggerFactory.getLogger(DefaultJScriptingBrowser.class); |
49 |
private static final long serialVersionUID = 3140698910497806258L; |
|
48 | 50 |
|
49 | 51 |
protected ScriptingUIManager uimanager; |
50 | 52 |
protected ScriptingManager manager; |
... | ... | |
53 | 55 |
protected ScriptingFolder root; |
54 | 56 |
protected ActionListener defaultActionlistener = null; |
55 | 57 |
protected ActionListener selectionActionlistener = null; |
56 |
protected ActionListener dropDownActionlistener = null; |
|
57 | 58 |
private final boolean foldersOnly; |
58 | 59 |
|
59 |
public static class BrowserActionEvent extends ActionEvent {
|
|
60 |
public static class DefaultBrowserActionEvent extends ActionEvent implements BrowserActionEvent {
|
|
60 | 61 |
|
61 | 62 |
/** |
62 | 63 |
* |
... | ... | |
64 | 65 |
private static final long serialVersionUID = -1474410768278633364L; |
65 | 66 |
private ScriptingBaseScript script = null; |
66 | 67 |
|
67 |
public BrowserActionEvent(Object source, int id, String command, |
|
68 |
public DefaultBrowserActionEvent(Object source, int id, String command,
|
|
68 | 69 |
ScriptingBaseScript script) { |
69 | 70 |
super(source, id, command); |
70 | 71 |
this.script = script; |
71 | 72 |
} |
72 | 73 |
|
74 |
@Override |
|
73 | 75 |
public ScriptingBaseScript getScript() { |
74 | 76 |
return this.script; |
75 | 77 |
} |
... | ... | |
203 | 205 |
this.makeUI(); |
204 | 206 |
} |
205 | 207 |
|
208 |
@Override |
|
209 |
public JComponent asJComponent() { |
|
210 |
return this; |
|
211 |
} |
|
212 |
|
|
206 | 213 |
public void refresh() { |
207 | 214 |
((ScriptingFolderTreeModel) this.treeModel).reload(); |
208 | 215 |
} |
... | ... | |
217 | 224 |
return this.root; |
218 | 225 |
} |
219 | 226 |
|
227 |
@Override |
|
220 | 228 |
public void addDefaultActionListener(ActionListener actionlistener) { |
221 | 229 |
this.defaultActionlistener = actionlistener; |
222 | 230 |
} |
223 | 231 |
|
232 |
@Override |
|
224 | 233 |
public void addSelectionActionListener(ActionListener actionlistener) { |
225 | 234 |
this.selectionActionlistener = actionlistener; |
226 | 235 |
} |
227 | 236 |
|
228 |
public void addDropDownActionListener(ActionListener actionlistener) { |
|
229 |
this.dropDownActionlistener = actionlistener; |
|
230 |
} |
|
231 |
|
|
232 | 237 |
private void makeUI() { |
233 | 238 |
if (this.foldersOnly) { |
234 | 239 |
treeModel = new ScriptingFolderTreeModelFoldersOnly(root); |
... | ... | |
248 | 253 |
public void valueChanged(TreeSelectionEvent e) { |
249 | 254 |
if (selectionActionlistener != null) { |
250 | 255 |
JComponent tree = (JComponent) e.getSource(); |
251 |
ActionEvent event = new BrowserActionEvent( |
|
256 |
ActionEvent event = new DefaultBrowserActionEvent(
|
|
252 | 257 |
tree.getParent(), |
253 | 258 |
SELECTION_ACTION, |
254 | 259 |
"select", |
... | ... | |
317 | 322 |
ScriptingUnit unit = (ScriptingUnit) path.getLastPathComponent(); |
318 | 323 |
if (unit instanceof ScriptingBaseScript) { |
319 | 324 |
if (this.defaultActionlistener != null) { |
320 |
ActionEvent event = new BrowserActionEvent( |
|
325 |
ActionEvent event = new DefaultBrowserActionEvent(
|
|
321 | 326 |
this, |
322 | 327 |
DEFAULT_ACTION, |
323 | 328 |
"default", |
... | ... | |
329 | 334 |
} |
330 | 335 |
|
331 | 336 |
private class EnterAction extends AbstractAction { |
337 |
private static final long serialVersionUID = -3673546098243190397L; |
|
332 | 338 |
|
333 | 339 |
@Override |
334 | 340 |
public void actionPerformed(ActionEvent ae) { |
... | ... | |
339 | 345 |
} |
340 | 346 |
|
341 | 347 |
private class ExpandSelectedNodeAction extends AbstractAction { |
348 |
private static final long serialVersionUID = -4121272513454221967L; |
|
342 | 349 |
|
343 | 350 |
@Override |
344 | 351 |
public void actionPerformed(ActionEvent ae) { |
... | ... | |
382 | 389 |
setOpaque(false); |
383 | 390 |
} |
384 | 391 |
|
385 |
private Map<String, ImageIcon> icons = new HashMap<String, ImageIcon>();
|
|
392 |
private final Map<String, ImageIcon> icons = new HashMap<>();
|
|
386 | 393 |
|
387 | 394 |
private ImageIcon getIcon(String iconName) { |
388 | 395 |
ImageIcon img = this.icons.get(iconName); |
... | ... | |
401 | 408 |
return getIcon(unit.getIconNames()[0]); |
402 | 409 |
} |
403 | 410 |
|
411 |
@Override |
|
404 | 412 |
public Component getTreeCellRendererComponent(JTree tree, Object value, |
405 | 413 |
boolean sel, boolean expanded, boolean leaf, int row, |
406 | 414 |
boolean hasFocus) { |
Also available in: Unified diff