01: /**
02: * Miroslav Popov, Aug 2, 2005
03: */package org.enhydra.jawe.components.simplenavigator.actions;
04:
05: import java.awt.event.ActionEvent;
06:
07: import javax.swing.JMenuItem;
08: import javax.swing.tree.TreePath;
09:
10: import org.enhydra.jawe.ActionBase;
11: import org.enhydra.jawe.JaWEComponent;
12: import org.enhydra.jawe.JaWEManager;
13: import org.enhydra.jawe.components.XPDLTreeUtil;
14: import org.enhydra.jawe.components.simplenavigator.SimpleNavigator;
15: import org.enhydra.jawe.components.simplenavigator.SimpleNavigatorPanel;
16:
17: /**
18: * @author Miroslav Popov
19: */
20: public class ExpandAll extends ActionBase {
21:
22: public ExpandAll(JaWEComponent jawecomponent) {
23: super (jawecomponent);
24: }
25:
26: public void enableDisableAction() {
27: if (JaWEManager.getInstance().getJaWEController()
28: .getMainPackage() != null) {
29: setEnabled(true);
30: } else {
31: setEnabled(false);
32: }
33: }
34:
35: public void actionPerformed(ActionEvent e) {
36: SimpleNavigator tcon = (SimpleNavigator) jawecomponent;
37:
38: SimpleNavigatorPanel panel = (SimpleNavigatorPanel) (tcon
39: .getView());
40:
41: TreePath tp = null;
42: if (e.getSource() instanceof JMenuItem) {
43: tp = panel.getTree().getPathForLocation(
44: panel.getMouseClickLocation().x,
45: panel.getMouseClickLocation().y);
46: }
47: if (tp == null) {
48: tp = panel.getTree().getSelectionPath();
49: if (tp == null) {
50: tp = new TreePath(panel.getTree().getModel().getRoot());
51: }
52: }
53: panel.getTree().removeTreeSelectionListener(tcon);
54: XPDLTreeUtil.expandOrCollapsToLevel(panel.getTree(), tp, -1,
55: true);
56: if (!(e.getSource() instanceof JMenuItem)) {
57: panel.setCurrentSelection();
58: }
59: panel.getTree().addTreeSelectionListener(tcon);
60: }
61: }
|