Author: tchemit Date: 2008-01-24 23:47:31 +0000 (Thu, 24 Jan 2008) New Revision: 537 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java Log: ajout action delete Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java 2008-01-24 23:47:31 UTC (rev 537) @@ -0,0 +1,99 @@ +/* +* ##% 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.action.application; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeHelper; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab; + +import javax.swing.JTree; +import java.awt.event.ActionEvent; +import java.io.File; + +/** + * Action pour downloader un résultat ou une librairie + * + * @author chemit + */ + at jaxx.runtime.builder.ActionConfig( + actionCommand = "delete", + name = "simexplorer.action.application.delete", + shortDescription = "simexplorer.action.application.delete.tooltip", + longDescription = "simexplorer.action.application.delete.help", + smallIcon = "action/delete.png", + mnemonic = 'x', + hideActionText = false +) +public class DeleteAction extends SimExplorerAbstractTabAction { + + private static final long serialVersionUID = 7535647131305304738L; + + + JTree tree; + LoggableElementTreeNode node; + File file; + LoggableElement element; + String uuid; + Version version; + + public DeleteAction(String name) { + super(name); + } + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e)) { + return false; + } + JApplicationDetailTab ui = (JApplicationDetailTab) getUI(); + tree = ui.getTree(); + node = LoggableElementTreeHelper.getSelectedNodeOrRootNode(tree); + boolean result; + result = node != null && node.isLoggableElement(); + if (result) { + // ask user confirmation of node to delete + element = (LoggableElement) node.getUserObject(); + uuid = element.getMetaData().getUuid(); + version = element.getMetaData().getVersion(); + } + result = false; + return result; + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + super.doAction(e); + //StorageService service = getContext().getStorageService(((DetailTabModel) getModel()).isRemote()); + //TODO + } + + @Override + protected void clear() { + super.clear(); + tree = null; + node = null; + file = null; + element = null; + version = null; + uuid = null; + } +} \ No newline at end of file