- added TaxonDeletionConfigurator to delete operations
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / handler / DeleteTaxonBaseHandler.java
index 86240cb151f15d8270c6b60ca0ebc6caa45bfa5f..ed85b64c00acdb64cf79575bc147cb35fb9d14b0 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * 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.
 */
@@ -16,19 +16,19 @@ import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.HandlerUtil;
 
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 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.editor.name.operation.DeleteMisapplicationOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteTaxonOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -47,16 +47,17 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
         * @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 = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
-                               
+
                Object selectedElement = EditorUtil.getSelection(event).getFirstElement();
-               
+
                doExecute(event, editor, selectedElement);
-               
+
                return null;
        }
-       
+
        /**
         * @param editor
         * @param selectedElement
@@ -65,14 +66,14 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
         */
        protected void doExecute(ExecutionEvent event, TaxonNameEditor editor, Object selectedElement) {
                AbstractPostOperation operation = null;
-               String commandName = null;              
+               String commandName = null;
 
                try {
                        commandName = event.getCommand().getName();
                } catch (NotDefinedException e) {
                        MessagingUtils.error(getClass(), e);
                }
-               
+
                // synonym
                if(selectedElement instanceof Synonym){
                        operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
@@ -87,35 +88,29 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
                        if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Are you sure you want to delete the selected taxon?")){
                                return ;
                        }
+
                        IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-                       
-                       operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, null, activePage, this, editor);
+
+                       operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, new TaxonDeletionConfigurator(), null, activePage, this, editor);
                        //editor.dispose();
-                       
+
                }
                else {
                        throw new IllegalArgumentException("Element has to be Synonym, Misapplication or Concept");
                }
-                               
-               EditorUtil.executeOperation(operation);
-               
-               
-               
-               
+
+               AbstractUtility.executeOperation(operation);
        }
 
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
                Display.getDefault().asyncExec(new Runnable(){
 
-                       public void run() {
-                               EditorUtil.close(editor.getMultiPageTaxonEditor());
-                                       
+                       @Override
+            public void run() {
+                               AbstractUtility.close(editor.getMultiPageTaxonEditor());
                        }
-                       
                });
-               
-               
                return true;
        }
 
@@ -124,6 +119,5 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
                // TODO Auto-generated method stub
                return false;
        }
-       
-       
+
 }