Author: tchemit Date: 2008-01-24 00:28:51 +0000 (Thu, 24 Jan 2008) New Revision: 468 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java Log: action d'export, a finir Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java 2008-01-24 00:27:41 UTC (rev 467) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java 2008-01-24 00:28:51 UTC (rev 468) @@ -18,8 +18,20 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.action.application; -import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractAction; +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.service.StorageService; +import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; +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; +import java.text.MessageFormat; + /** * Action pour exporter une application * @@ -34,17 +46,57 @@ mnemonic = 'x', hideActionText = false ) -public class ExportApplicationAction extends SimExplorerAbstractAction { +public class ExportApplicationAction extends SimExplorerAbstractTabAction { private static final long serialVersionUID = 7535647131305304738L; + private static final MessageFormat FILENAME_PATTERN = new MessageFormat("export-{0}.xml"); + JTree tree; + LoggableElementTreeNode node; + File file; + LoggableElement element; + String uuid; + Version version; + public ExportApplicationAction(String name) { - super(name); + super(name, null); } @Override - public void actionPerformed(java.awt.event.ActionEvent e) { - super.actionPerformed(e); - //TODO + 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) { + element = (LoggableElement) node.getUserObject(); + uuid = element.getMetaData().getUuid(); + version = element.getMetaData().getVersion(); + } + return result; } + + @Override + protected void doAction(ActionEvent e) throws Exception { + super.doAction(e); + + //TODO Where to save (if local to remote and vice-versa ?) + StorageService service = getStorageService(((DetailTabModel) getModel()).isRemote()); + service.exportElement(getContext().getToken(), null, uuid, version.toString()); + } + + @Override + protected void clear() { + super.clear(); + tree = null; + node = null; + file = null; + element = null; + version=null; + uuid=null; + } } \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org