fixes #727
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / handler / SwapSynonymAndAcceptedHandler.java
index 37dca191c0426116abb562311039abf312cc9c5d..5f1ecbb6f43c24c6bc10790d8beb6c1c500f2166 100644 (file)
@@ -16,22 +16,17 @@ import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.Page;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.operations.SwapSynonymAndAcceptedOperation;
 import eu.etaxonomy.taxeditor.propertysheet.name.SynonymPropertySource;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * @author n.hoffmann
@@ -49,15 +44,6 @@ public class SwapSynonymAndAcceptedHandler extends AbstractHandler implements
        public Object execute(ExecutionEvent event) throws ExecutionException {
                MultiPageTaxonEditor multiEditor = EditorUtil.getActiveEditor();
                
-               if (multiEditor.isDirty()) {
-                       if (!MessageDialog.openConfirm((Shell) multiEditor.getAdapter(Shell.class), "Save before proceeding", 
-                                       "All changes must be saved before proceeding.\n\n" +
-                                       "Save current changes?")) {
-                               return null;
-                       }
-                       multiEditor.doSave(null);
-               }
-               
                TaxonNameEditor editor = (TaxonNameEditor) multiEditor.getPage(Page.NAME);
                
                ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);
@@ -71,25 +57,9 @@ public class SwapSynonymAndAcceptedHandler extends AbstractHandler implements
                                                                editor.getTaxon(), synonym, editor);
                        EditorUtil.executeOperation(operation);
                        
-                       // TODO this is all very spooky
-                       // After performing the logic we do have to mangle around with the windows                      
-                       Taxon newTaxon = operation.getNewTaxon();
-                       
-                       // save and delete the taxon data
-                       CdmStore.getTaxonService().save(newTaxon);
-                       CdmStore.getTaxonService().delete(editor.getTaxon());
-                       
-                       multiEditor.doSave(null);
-                       EditorUtil.close(multiEditor);
-                       
-                       // open an editor with the new 
-                       EditorUtil.open(newTaxon.getUuid());
-                       
                } catch (NotDefinedException e) {
                        logger.warn("Command name not set");
-               } catch (PartInitException e) {
-                       logger.error("Could not open editor with new taxon", e);
-               }
+               } 
 
                return null;
        }