Author: tchemit Date: 2008-02-13 02:45:46 +0000 (Wed, 13 Feb 2008) New Revision: 890 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryNextAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryPreviousAction.java Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java Log: mise en place des actions d'historique Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-13 02:45:10 UTC (rev 889) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-13 02:45:46 UTC (rev 890) @@ -26,7 +26,9 @@ import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeHelper; +import javax.swing.tree.TreeNode; import java.awt.event.ActionEvent; /** @@ -73,7 +75,11 @@ @Override protected void doAction(ActionEvent e) throws Exception { model.setRootNode(element); - SimExplorerUIRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), model); + // create navigation tree + TreeNode root = LoggableElementTreeHelper.buildLoggableElementNode(model.getRootNode()); + model.getHistory().add(root); + // push it in tree + SimExplorerUIRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), model.getHistory()); } @Override Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryNextAction.java (from rev 880, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryNextAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryNextAction.java 2008-02-13 02:45:46 UTC (rev 890) @@ -0,0 +1,72 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.ui.swing.actions; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper; +import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import java.awt.event.ActionEvent; + +/** @author chemit */ + at jaxx.runtime.builder.ActionConfig( + actionCommand = "historyNext", + name = "simexplorer.action.historyNext", + shortDescription = "simexplorer.action.historyNext.tooltip", + longDescription = "simexplorer.action.historyNext.help", + smallIcon = "action/history-next.png", + mnemonic = 'N', + hideActionText = true +) +public class HistoryNextAction extends SimExplorerAbstractTabAction { + + DetailTabModel model; + + private static final long serialVersionUID = 2165684159831076054L; + + public HistoryNextAction(String name) { + super(name); + } + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e)) { + return false; + } + model = (DetailTabModel) getModel(); + return model.getHistory().hasNext(); + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + TreeNode node = model.getHistory().gotoNext(); + model.setRootNode((LoggableElement) ((DefaultMutableTreeNode) node).getUserObject()); + SimExplorerUIRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), model.getHistory()); + } + + @Override + protected void clear() { + super.clear(); + model = null; + } +} \ No newline at end of file Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryPreviousAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryPreviousAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryPreviousAction.java 2008-02-13 02:45:46 UTC (rev 890) @@ -0,0 +1,75 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.ui.swing.actions; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper; +import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import java.awt.event.ActionEvent; + +/** + * + * @author chemit + */ + at jaxx.runtime.builder.ActionConfig( + actionCommand = "historyPrevious", + name = "simexplorer.action.historyPrevious", + shortDescription = "simexplorer.action.historyPrevious.tooltip", + longDescription = "simexplorer.action.historyPrevious.help", + smallIcon = "action/history-previous.png", + mnemonic = 'N', + hideActionText = true +) +public class HistoryPreviousAction extends SimExplorerAbstractTabAction { + + DetailTabModel model; + + private static final long serialVersionUID = 2165684159831076054L; + + public HistoryPreviousAction(String name) { + super(name); + } + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e)) { + return false; + } + model = (DetailTabModel) getModel(); + return model.getHistory().hastPrevious(); + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + TreeNode node = model.getHistory().gotoPrevious(); + model.setRootNode((LoggableElement) ((DefaultMutableTreeNode) node).getUserObject()); + SimExplorerUIRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), model.getHistory()); + } + + @Override + protected void clear() { + super.clear(); + model = null; + } +} \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org