Author: tchemit Date: 2008-01-23 21:57:05 +0000 (Wed, 23 Jan 2008) New Revision: 458 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/CollapseAllAction.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExpandAllAction.java Log: implantation collapse - expand (fonctionne sur le node s?\195?\169lectionn?\195?\169 :)) Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/CollapseAllAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/CollapseAllAction.java 2008-01-23 21:56:29 UTC (rev 457) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/CollapseAllAction.java 2008-01-23 21:57:05 UTC (rev 458) @@ -18,8 +18,14 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.action.application; -import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import java.awt.event.ActionEvent; + /** * Pour réduire tous les noeuds de l'arbe d'une application * @@ -34,12 +40,52 @@ mnemonic = 'c', hideActionText = true ) -public class CollapseAllAction extends SimExplorerAbstractAction { +public class CollapseAllAction extends SimExplorerAbstractTabAction { private static final long serialVersionUID = -3254708595851406041L; + JTree tree; + LoggableElementTreeNode node; public CollapseAllAction(String name) { - super(name); + super(name, null); } + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e) || !isEnabled()) { + return false; + } + JApplicationDetailTab ui = (JApplicationDetailTab) getUI(); + + tree = ui.getTree(); + TreePath path = tree.getSelectionPath(); + if (path != null) { + Object o = path.getLastPathComponent(); + if (o != null && !(o instanceof LoggableElementTreeNode)) { + return false; + } + node = (LoggableElementTreeNode) o; + } + if (node == null) { + // take the root node + node = (LoggableElementTreeNode) tree.getModel().getRoot(); + } + boolean result; + result = node != null && !node.isLeaf(); + return result; + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + + node.collaspeAll(tree); + } + + @Override + protected void clear() { + super.clear(); + tree = null; + node = null; + } + } \ No newline at end of file Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExpandAllAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExpandAllAction.java 2008-01-23 21:56:29 UTC (rev 457) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExpandAllAction.java 2008-01-23 21:57:05 UTC (rev 458) @@ -18,8 +18,14 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.action.application; -import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import java.awt.event.ActionEvent; + /** * Pour dérouler tous les noeuds de l'arbre d'une application * @@ -34,12 +40,50 @@ mnemonic = 'e', hideActionText = true ) -public class ExpandAllAction extends SimExplorerAbstractAction { +public class ExpandAllAction extends SimExplorerAbstractTabAction { private static final long serialVersionUID = 9033359716418852179L; + JTree tree; + LoggableElementTreeNode node; public ExpandAllAction(String name) { - super(name); + super(name, null); } - + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e) || !isEnabled()) { + return false; + } + JApplicationDetailTab ui = (JApplicationDetailTab) getUI(); + + tree = ui.getTree(); + TreePath path = tree.getSelectionPath(); + if (path != null) { + Object o = path.getLastPathComponent(); + if (o != null && !(o instanceof LoggableElementTreeNode)) { + return false; + } + node = (LoggableElementTreeNode) o; + } + if (node == null) { + // take the root node + node = (LoggableElementTreeNode) tree.getModel().getRoot(); + } + boolean result; + result = node != null && !node.isLeaf(); + return result; + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + node.expandAll(tree); + } + + @Override + protected void clear() { + super.clear(); + tree = null; + node = null; + } } \ No newline at end of file