// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.editor.name.operation.SwapSynonymAndAcceptedOperation;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
/**
* <p>SwapSynonymAndAcceptedHandler class.</p>
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
editor = EditorUtil.getActiveMultiPageTaxonEditor();
Shell shell = HandlerUtil.getActiveShell(event);
Synonym synonym = (Synonym) EditorUtil.getSelection(event).getFirstElement();
-
+
// Force user to save taxon - not really necessary though, is it?
if (!EditorUtil.forceUserSave(editor, shell)) {
return null;
}
-
+
try {
- SwapSynonymAndAcceptedOperation operation = new SwapSynonymAndAcceptedOperation(event.getCommand().getName(), editor.getUndoContext(),
- editor.getTaxon(), synonym, this);
-
+ SwapSynonymAndAcceptedOperation operation = new SwapSynonymAndAcceptedOperation(event.getCommand().getName(),
+ editor.getUndoContext(),
+ editor.getTaxon(),
+ synonym,
+ this,
+ (ICdmEntitySessionEnabled)editor.getEditorInput());
+
EditorUtil.executeOperation(operation);
-
+
} catch (NotDefinedException e) {
logger.warn("Command name not set");
- }
+ }
return null;
}
public boolean postOperation(CdmBase objectAffectedByOperation) {
// Redraw existing editor
//((IPostOperationEnabled) editor).postOperation(null);
-
+
editor.doSave(EditorUtil.getMonitor());
editor.close(true);
-
+
if (objectAffectedByOperation instanceof Taxon) {
-
+
taxon = (Taxon) objectAffectedByOperation;
-
-
+
+
}
return true;
}
public boolean onComplete() {
Display display = Display.getCurrent();
display.asyncExec(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
try {
EditorUtil.openTaxonBase(taxon.getUuid());
-
+
} catch (Exception e) {
- EditorUtil.warningDialog("Could not open editor for taxon", this, e.getMessage());
+ MessagingUtils.warningDialog("Could not open editor for taxon", this, e.getMessage());
}
-
+
}
});
return true;