Author: tchemit Date: 2008-02-15 15:43:11 +0000 (Fri, 15 Feb 2008) New Revision: 997 Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportAction.java Log: implements import action Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportAction.java 2008-02-15 15:42:44 UTC (rev 996) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportAction.java 2008-02-15 15:43:11 UTC (rev 997) @@ -18,11 +18,16 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.actions; -import fr.cemagref.simexplorer.is.ui.SimExplorerRuntimeException; +import fr.cemagref.simexplorer.is.ui.StorageServiceHelper; +import fr.cemagref.simexplorer.is.ui.swing.ImportDialog; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel; import java.awt.event.ActionEvent; +import java.io.File; +import static org.codelutin.i18n.I18n.*; + /** * Action de base pour importer une application * @@ -31,24 +36,69 @@ @jaxx.runtime.builder.ActionConfig( actionCommand = "importElement", name = "simexplorer.action.import", - shortDescription = "simexplorer.action.import.tooltip", longDescription = "simexplorer.action.import.help", smallIcon = "action/import-element.png", - mnemonic = 'i', + mnemonic = 'I', hideActionText = false ) public class ImportAction extends SimExplorerAbstractTabAction { + protected ImportDialog ui; + + protected File f; + protected Boolean remote; private static final long serialVersionUID = 3377670691203328711L; - public ImportAction(String name) { super(name); + ui = new ImportDialog(getMainUI()); } + public void disposeUI() { + ui = null; + } + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e)) { + return false; + } + ListTabModel model = (ListTabModel) getModel(); + remote = model.isRemote(); + f = getUi(remote).getFile(); + + return f != null; + } + + @Override protected void doAction(ActionEvent e) throws Exception { - super.doAction(e); - throw new SimExplorerRuntimeException(this + " is not implemented yet!"); + StorageServiceHelper.importElement(getContext(), remote, f); } + + @Override + protected void afterAction(ActionEvent e) throws Exception { + super.afterAction(e); + //TODO should invalidate the 'remote' list + //TODO look if detail history is touch by this modification + //TODO look if synchronize is touched by this modification + } + + @Override + protected void clear() { + super.clear(); + f = null; + remote = null; + // this is a multi-tab action, must reset tab after each action + setTab(null); + } + + protected ImportDialog getUi(Boolean remote) { + if (ui == null) { + ui = new ImportDialog(getMainUI()); + } + ui.setTitle(remote? _("simexplorer.action.import.remote.tooltip"):_("simexplorer.action.import.local.tooltip")); + ui.getTypeImport().setSelected(ui.getSelected().getModel(),true); + ui.getTypeImport().updateSelectedValue(); + return ui; + } } \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org