Author: tchemit Date: 2008-02-20 14:37:27 +0000 (Wed, 20 Feb 2008) New Revision: 1138 Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java Log: refactoring Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 13:51:45 UTC (rev 1137) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 14:37:27 UTC (rev 1138) @@ -19,8 +19,6 @@ package fr.cemagref.simexplorer.is.ui.swing.actions; import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper; -import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; -import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; @@ -61,26 +59,10 @@ if (!super.beforeAction(e)) { return false; } - String actionName = getActionName(); - // on retrouve l'arbre concerné à partir du nom de l'action - if ("collapseAllDetail".equals(actionName)) { - JDetailTab ui = (JDetailTab) getUI(); - tree = ui.getNavigationTree(); - } else if ("collapseAllLocal".equals(actionName)) { - JSynchronizeTab ui = (JSynchronizeTab) getUI(); - tree = ui.getTree(false); - } else if ("collapseAllRemote".equals(actionName)) { - JSynchronizeTab ui = (JSynchronizeTab) getUI(); - tree = ui.getTree(true); - } - if (tree == null) { - // arbre non trouvé (cela devrait souleve une exception !) - return false; - } - node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree); - boolean result; - result = !(node == null || node.isLeaf()); - return result; + + tree = getTreeForAction("collapseAll", getActionName()); + node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree); + return !(node == null || node.isLeaf()); } @Override @@ -90,7 +72,6 @@ @Override public void updateUI() { - super.updateUI(); tree.invalidate(); getMainUI().repaint(); } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 13:51:45 UTC (rev 1137) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 14:37:27 UTC (rev 1138) @@ -19,8 +19,6 @@ package fr.cemagref.simexplorer.is.ui.swing.actions; import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper; -import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; -import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; @@ -62,27 +60,9 @@ if (!super.beforeAction(e)) { return false; } - String actionName = getActionName(); - // on retrouve l'arbre concerné à partir du nom de l'action - if ("expandAllDetail".equals(actionName)) { - JDetailTab ui = (JDetailTab) getUI(); - tree = ui.getNavigationTree(); - } else if ("expandAllLocal".equals(actionName)) { - JSynchronizeTab ui = (JSynchronizeTab) getUI(); - tree = ui.getTree(false); - } else if ("expandAllRemote".equals(actionName)) { - JSynchronizeTab ui = (JSynchronizeTab) getUI(); - tree = ui.getTree(true); - } - if (tree == null) { - // arbre non trouvé (cela devrait souleve une exception !) - return false; - } - - node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree); - boolean result; - result = !(node == null || node.isLeaf()); - return result; + tree = getTreeForAction("expandAll", getActionName()); + node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree); + return !(node == null || node.isLeaf()); } @Override @@ -92,7 +72,6 @@ @Override public void updateUI() { - super.updateUI(); tree.invalidate(); getMainUI().repaint(); } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java 2008-02-20 13:51:45 UTC (rev 1137) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java 2008-02-20 14:37:27 UTC (rev 1138) @@ -19,8 +19,11 @@ package fr.cemagref.simexplorer.is.ui.swing.actions.util; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; +import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; +import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; import jaxx.runtime.JAXXObject; import jaxx.runtime.swing.JAXXTab; import org.apache.commons.beanutils.Converter; @@ -29,6 +32,7 @@ import javax.swing.JComponent; import javax.swing.JTabbedPane; +import javax.swing.JTree; import java.awt.Component; import java.awt.event.ActionEvent; import java.util.regex.Matcher; @@ -153,4 +157,23 @@ } return entityModel; } + + protected JTree getTreeForAction(String actionPrefix, String actionName) { + JTree tree = null; + // on retrouve l'arbre concerné à partir du nom de l'action + if ((actionPrefix + "Detail").equals(actionName)) { + JDetailTab ui = (JDetailTab) getUI(); + tree = ui.getNavigationTree(); + } else if ((actionPrefix + "Local").equals(actionName)) { + JSynchronizeTab ui = (JSynchronizeTab) getUI(); + tree = ui.getTree(false); + } else if ((actionPrefix + "Remote").equals(actionName)) { + JSynchronizeTab ui = (JSynchronizeTab) getUI(); + tree = ui.getTree(true); + } + if (tree == null) { + throw new SimExplorerRuntimeException("could not find a tree for command " + actionName); + } + return tree; + } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org