Merge branch 'develop' into remoting-4.0
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / handler / SwapSynonymAndAcceptedHandler.java
index 55c685bdfbc2213e4ddf4c10c1d312453b9e3036..014f92da1cfa6c34d8f7f914ea7011bb92327c66 100644 (file)
@@ -1,9 +1,9 @@
 // $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.
 */
@@ -26,7 +26,9 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 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>
@@ -46,26 +48,31 @@ public class SwapSynonymAndAcceptedHandler extends AbstractHandler implements
         * @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;
        }
@@ -77,15 +84,15 @@ public class SwapSynonymAndAcceptedHandler extends AbstractHandler implements
        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;
        }
@@ -97,14 +104,15 @@ public class SwapSynonymAndAcceptedHandler extends AbstractHandler implements
        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;