r1128 - in trunk/simexplorer-is/simexplorer-is-swing/src: java/fr/cemagref/simexplorer/is/ui/swing/actions java/fr/cemagref/simexplorer/is/ui/swing/actions/history java/fr/cemagref/simexplorer/is/ui/swing/actions/util resources/jaxx
Author: tchemit Date: 2008-02-19 18:37:50 +0000 (Tue, 19 Feb 2008) New Revision: 1128 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java Removed: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryDeleteAction.java 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 trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryUnconnectAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/HistoryAbstractAction.java Modified: trunk/simexplorer-is/simexplorer-is-swing/src/resources/jaxx/simexplorer-is-swing-actions.properties Log: creation paquetagepour les actions d'historique Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryDeleteAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryDeleteAction.java 2008-02-19 18:35:31 UTC (rev 1127) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryDeleteAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -1,109 +0,0 @@ -/* -* ##% 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.actions.util.HistoryAbstractAction; -import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; -import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; -import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; - -import java.util.Iterator; -import java.util.List; - -/** @author chemit */ - at jaxx.runtime.builder.ActionConfig( - actionCommand = "historyDelete", - name = "simexplorer.action.historyDelete", - shortDescription = "simexplorer.action.historyDelete.tooltip", - longDescription = "simexplorer.action.historyDelete.help", - //smallIcon = "action/history-next.png", - //mnemonic = 'N', - hideActionText = true -) -public class HistoryDeleteAction extends HistoryAbstractAction { - - private static final long serialVersionUID = 2165684159831076054L; - - protected DataEntityModel selected; - - public HistoryDeleteAction(String name) { - super(name); - } - - protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { - if (model.isEmpty()) { - return false; - } - if (selected == null) { - // le modele est statique pour le moment - //setTab(findTab(e)); - // on doit retrouver l'élément à traiter à partir de la source - selected = findSelectedItem(e); - } - return selected != null && selected.getUuid() != null; - } - - protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { - int pos = 0; - int currentPos = model.getCurrentIndex(); - List<EntityTreeNode> datas = model.getData(); - boolean remote = selected.isRemote(); - String uuid = selected.getUuid(); - boolean wasRemove = false; - if (log.isDebugEnabled()) { - log.debug("----- search entry to remove :" + selected + ", " + selected.isRemote()); - } - for (Iterator<EntityTreeNode> it = datas.iterator(); it.hasNext();) { - EntityTreeNode node = it.next(); - boolean remote2 = node.isRemote(); - LoggableElement le = node.getLoggableElement(); - if (le != null && remote == remote2 && uuid.equals(le.getMetaData().getUuid())) { - it.remove(); - if (log.isDebugEnabled()) { - log.debug("----- found entry to remove :" + node + ", " + node.isRemote()); - } - wasRemove = true; - break; - } - pos++; - } - if (datas.isEmpty()) { - // supprime la selection - model.setCurrentIndex(null); - return null; - } - - if (wasRemove) { - if (pos > 0 && currentPos >= pos) { - // decrementsonly if currentPos was higher but not in 0 case. - model.setCurrentIndex(currentPos - 1); - } - } - EntityTreeNode node; - node = model.getCurrent(); - return node; - } - - @Override - protected void clear() { - super.clear(); - selected = null; - } -} \ No newline at end of file Deleted: 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/HistoryNextAction.java 2008-02-19 18:35:31 UTC (rev 1127) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryNextAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -1,52 +0,0 @@ -/* -* ##% 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.ui.swing.actions.util.HistoryAbstractAction; -import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; -import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; - -/** @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 HistoryAbstractAction { - - private static final long serialVersionUID = 2165684159831076054L; - - public HistoryNextAction(String name) { - super(name); - } - - protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { - return model.hasNext(); - } - - protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { - EntityTreeNode node; - node = model.gotoNext(); - return node; - } -} \ No newline at end of file Deleted: 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 2008-02-19 18:35:31 UTC (rev 1127) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryPreviousAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -1,53 +0,0 @@ -/* -* ##% 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.ui.swing.actions.util.HistoryAbstractAction; -import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; -import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; - -/** @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 HistoryAbstractAction { - - private static final long serialVersionUID = 2165684159831076054L; - - public HistoryPreviousAction(String name) { - super(name); - } - - protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { - return model.hasPrevious(); - } - - protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { - EntityTreeNode node; - node = model.gotoPrevious(); - return node; - } - -} \ No newline at end of file Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryUnconnectAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryUnconnectAction.java 2008-02-19 18:35:31 UTC (rev 1127) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryUnconnectAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -1,78 +0,0 @@ -/* -* ##% 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.ui.swing.actions.util.HistoryAbstractAction; -import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; -import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; - -import java.util.Iterator; -import java.util.List; - -/** @author chemit */ - at jaxx.runtime.builder.ActionConfig( - actionCommand = "historyUnconnect", - name = "simexplorer.action.historyUnconnect", - shortDescription = "simexplorer.action.historyUnconnect.tooltip", - longDescription = "simexplorer.action.historyUnconnect.help", - //smallIcon = "action/history-next.png", - //mnemonic = 'N', - hideActionText = true -) -public class HistoryUnconnectAction extends HistoryAbstractAction { - - private static final long serialVersionUID = 2165684159831076054L; - - public HistoryUnconnectAction(String name) { - super(name); - } - - protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { - return !model.isEmpty(); - } - - protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { - EntityTreeNode current = model.getCurrent(); - List<EntityTreeNode> datas = model.getData(); - for (Iterator<EntityTreeNode> it = datas.iterator(); it.hasNext();) { - if (it.next().isRemote()) { - it.remove(); - } - } - if (datas.isEmpty()) { - // pas de position - model.setCurrentIndex(null); - return null; - } - Integer pos; - if (!current.isRemote()) { - // on doit repositionner sur l'élément local courant - pos = datas.indexOf(current); - } else { - // on se met sur le dernier element - pos = datas.size() - 1; - } - // on repositionne sur le dernier element de l'historique - model.setCurrentIndex(pos); - EntityTreeNode node; - node = model.getCurrent(); - return node; - } - -} \ No newline at end of file Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java (from rev 1123, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/HistoryAbstractAction.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -0,0 +1,106 @@ +/* +* ##% Copyright (C) 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.history; + +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper; +import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; +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.EntityTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; + +import java.awt.event.ActionEvent; + +/** + * Action de base pour les actions d'historique + * + * @author chemit + */ +public abstract class HistoryAbstractAction extends SimExplorerAbstractTabAction { + + protected HistoryModel<EntityTreeNode> history; + + private static final long serialVersionUID = -2880632145083173463L; + + /** + * @param model le model d'historique non null + * @return <code>true</code> if il existe une entree adequate a l'action + * dans l'historique + */ + protected abstract boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model); + + /** + * @param model le model d'historique, non null + * @return le noeud à partir de l'historique + */ + protected abstract EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model); + + protected HistoryAbstractAction(String name) { + super(name); + } + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e)) { + return false; + } + // le modele est statique pour le moment + setTab(SimExplorerTab.detail); + DetailTabModel model = (DetailTabModel) getModel(); + if (model == null) { + return false; + } + history = model.getHistory(); + return history != null && hasHistoryEntry(history); + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + EntityTreeNode node = getHistoryEntry(history); + if (log.isDebugEnabled()) { + log.debug("current history entry " + node); + } + DetailTabModel model = (DetailTabModel) getModel(); + if (node == null) { + model.synch(model.isRemote(), (MetaData) null); + } else { + model.synch(node); + } + } + + @Override + public void updateUI() { + if (!history.isEmpty()) { + // select current history element + DetailTabRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), history); + } else if (getTab().isTabVisible(getTabContainer())) { + // close tab, no more history + getTab().closeTab(getTabContainer()); + } + } + + @Override + protected void clear() { + super.clear(); + history = null; + // should be a multi-tab + setTab(null); + } +} Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java (from rev 1120, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryDeleteAction.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -0,0 +1,109 @@ +/* +* ##% 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.history; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; +import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; + +import java.util.Iterator; +import java.util.List; + +/** @author chemit */ + at jaxx.runtime.builder.ActionConfig( + actionCommand = "historyDelete", + name = "simexplorer.action.historyDelete", + shortDescription = "simexplorer.action.historyDelete.tooltip", + longDescription = "simexplorer.action.historyDelete.help", + //smallIcon = "action/history-next.png", + //mnemonic = 'N', + hideActionText = true +) +public class HistoryDeleteAction extends HistoryAbstractAction { + + private static final long serialVersionUID = 2165684159831076054L; + + protected DataEntityModel selected; + + public HistoryDeleteAction(String name) { + super(name); + } + + protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { + if (model.isEmpty()) { + return false; + } + if (selected == null) { + // le modele est statique pour le moment + //setTab(findTab(e)); + // on doit retrouver l'élément à traiter à partir de la source + selected = findSelectedItem(e); + } + return selected != null && selected.getUuid() != null; + } + + protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { + int pos = 0; + int currentPos = model.getCurrentIndex(); + List<EntityTreeNode> datas = model.getData(); + boolean remote = selected.isRemote(); + String uuid = selected.getUuid(); + boolean wasRemove = false; + if (log.isDebugEnabled()) { + log.debug("----- search entry to remove :" + selected + ", " + selected.isRemote()); + } + for (Iterator<EntityTreeNode> it = datas.iterator(); it.hasNext();) { + EntityTreeNode node = it.next(); + boolean remote2 = node.isRemote(); + LoggableElement le = node.getLoggableElement(); + if (le != null && remote == remote2 && uuid.equals(le.getMetaData().getUuid())) { + it.remove(); + if (log.isDebugEnabled()) { + log.debug("----- found entry to remove :" + node + ", " + node.isRemote()); + } + wasRemove = true; + break; + } + pos++; + } + if (datas.isEmpty()) { + // supprime la selection + model.setCurrentIndex(null); + return null; + } + + if (wasRemove) { + if (pos > 0 && currentPos >= pos) { + // decrementsonly if currentPos was higher but not in 0 case. + model.setCurrentIndex(currentPos - 1); + } + } + EntityTreeNode node; + node = model.getCurrent(); + return node; + } + + @Override + protected void clear() { + super.clear(); + selected = null; + } +} \ No newline at end of file Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java (from rev 1119, 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/history/HistoryNextAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -0,0 +1,52 @@ +/* +* ##% 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.history; + +import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; + +/** @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 HistoryAbstractAction { + + private static final long serialVersionUID = 2165684159831076054L; + + public HistoryNextAction(String name) { + super(name); + } + + protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { + return model.hasNext(); + } + + protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { + EntityTreeNode node; + node = model.gotoNext(); + return node; + } +} \ No newline at end of file Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java (from rev 1119, 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/history/HistoryPreviousAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -0,0 +1,53 @@ +/* +* ##% 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.history; + +import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; + +/** @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 HistoryAbstractAction { + + private static final long serialVersionUID = 2165684159831076054L; + + public HistoryPreviousAction(String name) { + super(name); + } + + protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { + return model.hasPrevious(); + } + + protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { + EntityTreeNode node; + node = model.gotoPrevious(); + return node; + } + +} \ No newline at end of file Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java (from rev 1119, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HistoryUnconnectAction.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -0,0 +1,78 @@ +/* +* ##% 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.history; + +import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; + +import java.util.Iterator; +import java.util.List; + +/** @author chemit */ + at jaxx.runtime.builder.ActionConfig( + actionCommand = "historyUnconnect", + name = "simexplorer.action.historyUnconnect", + shortDescription = "simexplorer.action.historyUnconnect.tooltip", + longDescription = "simexplorer.action.historyUnconnect.help", + //smallIcon = "action/history-next.png", + //mnemonic = 'N', + hideActionText = true +) +public class HistoryUnconnectAction extends HistoryAbstractAction { + + private static final long serialVersionUID = 2165684159831076054L; + + public HistoryUnconnectAction(String name) { + super(name); + } + + protected boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model) { + return !model.isEmpty(); + } + + protected EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model) { + EntityTreeNode current = model.getCurrent(); + List<EntityTreeNode> datas = model.getData(); + for (Iterator<EntityTreeNode> it = datas.iterator(); it.hasNext();) { + if (it.next().isRemote()) { + it.remove(); + } + } + if (datas.isEmpty()) { + // pas de position + model.setCurrentIndex(null); + return null; + } + Integer pos; + if (!current.isRemote()) { + // on doit repositionner sur l'élément local courant + pos = datas.indexOf(current); + } else { + // on se met sur le dernier element + pos = datas.size() - 1; + } + // on repositionne sur le dernier element de l'historique + model.setCurrentIndex(pos); + EntityTreeNode node; + node = model.getCurrent(); + return node; + } + +} \ No newline at end of file Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/HistoryAbstractAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/HistoryAbstractAction.java 2008-02-19 18:35:31 UTC (rev 1127) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/HistoryAbstractAction.java 2008-02-19 18:37:50 UTC (rev 1128) @@ -1,105 +0,0 @@ -/* -* ##% Copyright (C) 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.util; - -import fr.cemagref.simexplorer.is.entities.metadata.MetaData; -import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper; -import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; -import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; -import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; - -import java.awt.event.ActionEvent; - -/** - * Action de base pour les actions d'historique - * - * @author chemit - */ -public abstract class HistoryAbstractAction extends SimExplorerAbstractTabAction { - - protected HistoryModel<EntityTreeNode> history; - - private static final long serialVersionUID = -2880632145083173463L; - - /** - * @param model le model d'historique non null - * @return <code>true</code> if il existe une entree adequate a l'action - * dans l'historique - */ - protected abstract boolean hasHistoryEntry(HistoryModel<EntityTreeNode> model); - - /** - * @param model le model d'historique, non null - * @return le noeud à partir de l'historique - */ - protected abstract EntityTreeNode getHistoryEntry(HistoryModel<EntityTreeNode> model); - - protected HistoryAbstractAction(String name) { - super(name); - } - - @Override - protected boolean beforeAction(ActionEvent e) throws Exception { - if (!super.beforeAction(e)) { - return false; - } - // le modele est statique pour le moment - setTab(SimExplorerTab.detail); - DetailTabModel model = (DetailTabModel) getModel(); - if (model == null) { - return false; - } - history = model.getHistory(); - return history != null && hasHistoryEntry(history); - } - - @Override - protected void doAction(ActionEvent e) throws Exception { - EntityTreeNode node = getHistoryEntry(history); - if (log.isDebugEnabled()) { - log.debug("current history entry " + node); - } - DetailTabModel model = (DetailTabModel) getModel(); - if (node == null) { - model.synch(model.isRemote(), (MetaData) null); - } else { - model.synch(node); - } - } - - @Override - public void updateUI() { - if (!history.isEmpty()) { - // select current history element - DetailTabRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), history); - } else if (getTab().isTabVisible(getTabContainer())) { - // close tab, no more history - getTab().closeTab(getTabContainer()); - } - } - - @Override - protected void clear() { - super.clear(); - history = null; - // should be a multi-tab - setTab(null); - } -} Modified: trunk/simexplorer-is/simexplorer-is-swing/src/resources/jaxx/simexplorer-is-swing-actions.properties =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/resources/jaxx/simexplorer-is-swing-actions.properties 2008-02-19 18:35:31 UTC (rev 1127) +++ trunk/simexplorer-is/simexplorer-is-swing/src/resources/jaxx/simexplorer-is-swing-actions.properties 2008-02-19 18:37:50 UTC (rev 1128) @@ -64,10 +64,10 @@ action.detailToTree=fr.cemagref.simexplorer.is.ui.swing.actions.DetailToTreeAction # navigation history actions -action.historyDelete=fr.cemagref.simexplorer.is.ui.swing.actions.HistoryDeleteAction -action.historyUnconnect=fr.cemagref.simexplorer.is.ui.swing.actions.HistoryUnconnectAction -action.historyNext=fr.cemagref.simexplorer.is.ui.swing.actions.HistoryNextAction -action.historyPrevious=fr.cemagref.simexplorer.is.ui.swing.actions.HistoryPreviousAction +action.historyDelete=fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryDeleteAction +action.historyUnconnect=fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryUnconnectAction +action.historyNext=fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryNextAction +action.historyPrevious=fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryPreviousAction # import- export actions action.exportElement=fr.cemagref.simexplorer.is.ui.swing.actions.ExportAction
participants (1)
-
tchemit@users.labs.libre-entreprise.org