ref #6566 Migrate "Delete" context menu items
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 18 May 2017 15:00:26 +0000 (17:00 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 18 May 2017 15:00:26 +0000 (17:00 +0200)
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/DeleteDerivateHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/AppModelId.java

index 099187e9a7d1ad08b8a63571d085bf7f0dca637a..0ba92d6dc32da8327b3e7888693b796c09848973 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="ASCII"?>
 <fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
   <imports xsi:type="commands:Command" xmi:id="_WPjpoDSnEeek0dKsFNy--Q" elementId="eu.etaxonomy.taxeditor.command.openPart"/>
-  <imports xsi:type="commands:Command" xmi:id="_YykZkDulEeeOtqC_3qh40A" elementId="org.eclipse.ui.edit.delete"/>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_gSpRsDQDEeeTNOFVGI4q2w" featurename="descriptors" parentElementId="xpath:/">
     <elements xsi:type="basic:PartDescriptor" xmi:id="_gSpRsTQDEeeTNOFVGI4q2w" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView" label="%command.label.DERIVATIVE_EDITOR" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/derivate_view-16x16-32.png" tooltip="" allowMultiple="true" category="Sample Category" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
       <tags>View</tags>
@@ -19,6 +18,7 @@
       <handlers xmi:id="_QNvcUDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.SingleReadHandler.copySingleRead" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.SingleReadCopyToClipboardHandler" command="_N0wLsDumEeeOtqC_3qh40A"/>
       <handlers xmi:id="_bAGysDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.SingleReadHandler.reuseSingleRead" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.SingleReadReuseHandler" command="_HmerkDumEeeOtqC_3qh40A"/>
       <handlers xmi:id="_ed9ZoDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.SingleReadHandler.removeSingleRead" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.SingleReadRemoveHandler" command="_K4DxEDumEeeOtqC_3qh40A"/>
+      <handlers xmi:id="_CQjyIDvaEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler" command="_YPp1wDvREeeOtqC_3qh40A"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_CYXZ0DQEEeeTNOFVGI4q2w" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor">
         <children xsi:type="menu:Menu" xmi:id="_cdjzEDmAEeeOos_QXKSXcA" elementId="eu.etaxonomy.taxeditor.editor.menu.add" label="%menu.label.5">
           <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_ASKmMDpCEeecM-jyCkToYw" coreExpressionId="isAddDerivateAllowed"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_oQXH0DumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabelreuse_single_read_for_other_sequence" label="%command.label.REUSE_SINGLE_READ_FOR_OTHER_SEQUENCE" command="_N0wLsDumEeeOtqC_3qh40A"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_1apX0DumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabelremove_single_read_from_this_sequence" label="%command.label.REMOVE_SINGLE_READ_FROM_THIS_SEQUENCE" command="_K4DxEDumEeeOtqC_3qh40A"/>
         <children xsi:type="menu:MenuSeparator" xmi:id="_c0f98DulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.3"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_XWW6QDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel52" label="%command.label.52" command="_YykZkDulEeeOtqC_3qh40A"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_wg0-oDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel54" toBeRendered="false" visible="false" label="%command.label.54" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/deep-delete-16x16-32.png" command="_fKT-wDulEeeOtqC_3qh40A"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_XWW6QDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel52" label="%command.label.52" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/delete.gif" command="_YPp1wDvREeeOtqC_3qh40A"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_wg0-oDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel54" label="%command.label.54" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/deep-delete-16x16-32.png" command="_fKT-wDulEeeOtqC_3qh40A"/>
       </menus>
     </elements>
   </fragments>
-  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__3UcUDSmEeek0dKsFNy--Q" featurename="children" parentElementId="bulkeditor.menus.openmenu">
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__3UcUDSmEeek0dKsFNy--Q" featurename="children" parentElementId="bulkeditor.menus.openmenu" positionInList="last">
     <elements xsi:type="menu:HandledMenuItem" xmi:id="_Uwm_YDSnEeek0dKsFNy--Q" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabelderivative_editor" label="%command.label.DERIVATIVE_EDITOR" command="_WPjpoDSnEeek0dKsFNy--Q">
       <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_7imM4DSoEeek0dKsFNy--Q" coreExpressionId="isCdmStoreConnected"/>
       <parameters xmi:id="_ZMAMoDSnEeek0dKsFNy--Q" elementId="eu.etaxonomy.taxeditor.editor.openPart.parameter.specimenEditor" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"/>
@@ -69,5 +69,6 @@
     <elements xsi:type="commands:Command" xmi:id="_HmerkDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.reuseSingleRead" commandName="%command.name.REUSE_SINGLE_READ"/>
     <elements xsi:type="commands:Command" xmi:id="_K4DxEDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.removeSingleReadFromSequence" commandName="%command.name.REMOVE_SINGLE_READ"/>
     <elements xsi:type="commands:Command" xmi:id="_N0wLsDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.copySingleReadToClipBoard" commandName="%command.name.COPY_SINGLE_READ_TO_CLIPBOARD"/>
+    <elements xsi:type="commands:Command" xmi:id="_YPp1wDvREeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivate.delete" commandName="Delete"/>
   </fragments>
 </fragment:ModelFragments>
index 01905f64bfe8d05751d68f30615d59113a718f4b..dec73021e004a2ff2876b7536bc9ab26a13d11c8 100644 (file)
                name="eu.etaxonomy.taxeditor.editor.separator7"
                visible="true">
          </separator>
-         <command
-               commandId="org.eclipse.ui.edit.delete"
-               label="%command.label.52"
-               style="push">
-         </command>
-         <command
-               commandId="eu.etaxonomy.taxeditor.editor.derivate.deepDelete"
-               icon="icons/deep-delete-16x16-32.png"
-               label="%command.label.54"
-               style="push">
-         </command>
       </menuContribution>
       <menuContribution
             locationURI="popup:eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor">
             </with>
          </activeWhen>
       </handler>
-      <handler
-            class="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler"
-            commandId="org.eclipse.ui.edit.delete">
-         <activeWhen>
-            <with
-                  variable="activePartId">
-               <equals
-                     value="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
-               </equals>
-            </with>
-         </activeWhen>
-      </handler>
       <handler
             class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.ToggleShowOnlyIndividualAssociationsHandler"
             commandId="eu.etaxonomy.taxeditor.editor.handler.showOnlyIndividualAssociations">
                typeId="eu.etaxonomy.taxeditor.uuidParameterType">
          </commandParameter>
       </command>
-      <command
-            defaultHandler="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler"
-            id="eu.etaxonomy.taxeditor.editor.derivate.deepDelete"
-            name="%command.name.44">
-      </command>
       <command
             categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
             defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionToOtherTaxonHandler"
index 34c7cec1bfb167ea5c5b279896a250c17d7ceedb..c93bc1e16378858044892397698da6d9a0f77fa6 100644 (file)
@@ -9,20 +9,18 @@
 
 package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
 
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.commands.operations.IUndoContext;
+import javax.inject.Named;
+
+import org.eclipse.core.commands.ParameterizedCommand;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.viewers.TreeNode;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
 
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
@@ -31,19 +29,14 @@ import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.molecular.Sequence;
 import eu.etaxonomy.cdm.model.molecular.SingleRead;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.AppModelId;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
-import eu.etaxonomy.taxeditor.editor.view.derivate.operation.DeleteDerivateOperation;
 import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
-import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
 
 /**
  *
@@ -51,188 +44,89 @@ import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
  * @date Oct 21, 2014
  *
  */
-public class DeleteDerivateHandler extends RemotingCdmHandler {
+public class DeleteDerivateHandler {
 
-    SpecimenDeleteConfigurator deleteConfigurator;
-    IEditorPart editor;
-    TreeNode node;
 
-    /**
-     * @param label
-     */
-    public DeleteDerivateHandler(String label) {
-        super(label);
+    private SpecimenDeleteConfigurator deleteConfigurator;
 
-    }
+    @Execute
+    public Object execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode treeNode, ParameterizedCommand command) {
+        deleteConfigurator = new SpecimenDeleteConfigurator();
+        if(command.getId().equals(AppModelId.COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATE_DEEPDELETE)){
+            deleteConfigurator.setDeleteChildren(true);
+        }
 
-    /**
-     * @param label
-     */
-    public DeleteDerivateHandler() {
-        super(Messages.DeleteDerivateHandler_LABEL);
+        DerivateView derivateView = (DerivateView) part.getObject();
+        Object value = treeNode.getValue();
+        IStatus allowStatus = allowOperations(derivateView, treeNode);
+        if(allowStatus.isOK()) {
+            DeleteResult deleteResult;
+            if(value instanceof SingleRead
+                    && treeNode.getParent()!=null
+                    && treeNode.getParent().getValue() instanceof Sequence){
+                deleteResult = CdmStore.getService(ISequenceService.class).deleteSingleRead(((SingleRead)value).getUuid(),
+                        ((Sequence) treeNode.getParent().getValue()).getUuid());
+            } else if(value instanceof Sequence){
+                deleteResult = CdmStore.getService(ISequenceService.class).delete(((Sequence) value).getUuid());
+            } else {
+                deleteResult = CdmStore.getService(IOccurrenceService.class).delete(((CdmBase) value).getUuid(), deleteConfigurator);
+            }
 
-    }
+            if (!deleteResult.isOk()) {
+                MessagingUtils.warningDialog(Messages.DeleteDerivateOperation_DELETE_FAILED, this, deleteResult.toString());
 
-//    /** {@inheritDoc} */
-//    @Override
-//    public Object execute(ExecutionEvent event) throws ExecutionException {
-//        IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveSite(event).getSelectionProvider().getSelection();
-//
-//        IWorkbenchPart part = HandlerUtil.getActivePart(event);
-//        IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
-//
-//        try {
-//            String label = event.getCommand().getName();
-//
-//            IUndoContext undoContext = EditorUtil.getUndoContext();
-//
-//            if(selection.size()>0){
-//                Object object = selection.iterator().next();
-//
-//                if(object instanceof TreeNode){
-//                    Object value = ((TreeNode) object).getValue();
-//                    if(value instanceof SpecimenOrObservationBase<?> || value instanceof Sequence || value instanceof SingleRead){
-//                        if(postOperationEnabled instanceof IConversationEnabled){
-//                            ConversationHolder conversationHolder = ((IConversationEnabled) postOperationEnabled).getConversationHolder();
-//                            label += " "+DerivateLabelProvider.getDerivateText(value, conversationHolder); //$NON-NLS-1$
-//                        }
-//                        SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
-//                        boolean deepDelete = event.getCommand().getId().equals("eu.etaxonomy.taxeditor.editor.derivate.deepDelete"); //$NON-NLS-1$
-//                        config.setDeleteChildren(deepDelete);
-//                        config.setDeleteMolecularData(deepDelete);
-//                        DeleteDerivateOperation deleteDerivateOperation = new DeleteDerivateOperation(label, undoContext, (CdmBase) value, (TreeNode) object, postOperationEnabled, config);
-//                        IStatus status = AbstractUtility.executeOperation(deleteDerivateOperation);
-//                        DerivateView derivateView = (DerivateView)postOperationEnabled;
-//                        if(derivateView.postOperation(null)){
-//                            derivateView.remove(object);
-//
-//                           // derivateView.updateRootEntities();
-//                            //update DerivateView
-//
-//
-//                        }
-//                    }
-//                }
-//                else{
-//                    MessagingUtils.error(getClass(), Messages.DeleteDerivateHandler_INVALID_SELECTION, null);
-//                }
-//            }
-//
-//        } catch (NotDefinedException e) {
-//            MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
-//        }
-//        return null;
-//    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IStatus allowOperations(ExecutionEvent event) {
-        //check whether object can be deleted
-        editor = HandlerUtil.getActiveEditor(event);
-        IStructuredSelection selection = (IStructuredSelection) HandlerUtil
-                .getCurrentSelection(event);
-        AbstractPostOperation operation;
-        deleteConfigurator = new SpecimenDeleteConfigurator();
+                return Status.CANCEL_STATUS;
+            }
+            if(derivateView.postOperation(null)){
+                derivateView.remove(treeNode);
 
+            }
+            return Status.OK_STATUS;
+        }
+        return null;
+    }
+
+    public IStatus allowOperations(DerivateView derivateView, TreeNode treeNode) {
         String confirmationQuestion = Messages.DeleteDerivateOperation_REALLY_DELETE;
         if(deleteConfigurator.isDeleteChildren()){
             confirmationQuestion += Messages.DeleteDerivateOperation_AND_CHILDREN;
         }
 
-        if(editor.isDirty()){
+        if(derivateView.isDirty()){
             MessagingUtils.warningDialog(DerivateView.VIEW_HAS_UNSAVED_CHANGES, this, DerivateView.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION);
             return Status.CANCEL_STATUS;
         }
-
         confirmationQuestion += "?"; //$NON-NLS-1$
         if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfigurator, null, Messages.DeleteDerivateOperation_CONFIRM, confirmationQuestion)){
             return Status.CANCEL_STATUS;
         }
-        Object object = selection.iterator().next();
         DeleteResult deleteResult;
-        if(object instanceof TreeNode){
-            Object value = ((TreeNode) object).getValue();
-            if(value instanceof SpecimenOrObservationBase<?> || value instanceof Sequence || value instanceof SingleRead){
-                if (value instanceof Sequence || value instanceof SingleRead){
-                    deleteResult = CdmStore.getService(ISequenceService.class).isDeletable(((CdmBase)value).getUuid(), deleteConfigurator);
-                } else{
-                    deleteResult = CdmStore.getService(IOccurrenceService.class).isDeletable(((CdmBase)value).getUuid(), deleteConfigurator);
-                }
-                if (deleteResult.isOk() || deleteResult.getExceptions().isEmpty()){ return Status.OK_STATUS;}
-                else{
-                    if (!deleteResult.isOk()){
-                        DeleteResultMessagingUtils.messageDialogWithDetails(deleteResult, Messages.DeleteDerivateOperation_DELETE_FAILED, TaxeditorEditorPlugin.PLUGIN_ID);
-                    } else {
-                        if (!deleteResult.getExceptions().isEmpty()){
-                            DeleteResultMessagingUtils.messageDialogWithDetails(deleteResult, Messages.DeleteDerivateHandler_SUCCESSFULL_BUT_EXCEPTIONS, TaxeditorEditorPlugin.PLUGIN_ID);
-                        }
+        Object value = treeNode.getValue();
+        if(value instanceof SpecimenOrObservationBase<?> || value instanceof Sequence || value instanceof SingleRead){
+            if (value instanceof Sequence || value instanceof SingleRead){
+                deleteResult = CdmStore.getService(ISequenceService.class).isDeletable(((CdmBase)value).getUuid(), deleteConfigurator);
+            } else{
+                deleteResult = CdmStore.getService(IOccurrenceService.class).isDeletable(((CdmBase)value).getUuid(), deleteConfigurator);
+            }
+            if (deleteResult.isOk() || deleteResult.getExceptions().isEmpty()){ return Status.OK_STATUS;}
+            else{
+                if (!deleteResult.isOk()){
+                    DeleteResultMessagingUtils.messageDialogWithDetails(deleteResult, Messages.DeleteDerivateOperation_DELETE_FAILED, TaxeditorEditorPlugin.PLUGIN_ID);
+                } else {
+                    if (!deleteResult.getExceptions().isEmpty()){
+                        DeleteResultMessagingUtils.messageDialogWithDetails(deleteResult, Messages.DeleteDerivateHandler_SUCCESSFULL_BUT_EXCEPTIONS, TaxeditorEditorPlugin.PLUGIN_ID);
                     }
+                }
 
-                    return Status.CANCEL_STATUS;
-                    }
+                return Status.CANCEL_STATUS;
             }
-
         }
-
         return Status.CANCEL_STATUS;
-
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public AbstractOperation prepareOperation(ExecutionEvent event) {
-        IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveSite(event).getSelectionProvider().getSelection();
-
-        IWorkbenchPart part = HandlerUtil.getActivePart(event);
-        IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
-
-        try {
-            String label = event.getCommand().getName();
-
-            IUndoContext undoContext = EditorUtil.getUndoContext();
-
-            if(selection.size()>0){
-                Object object = selection.iterator().next();
-
-                if(object instanceof TreeNode){
-                    node = (TreeNode)object;
-                    Object value = ((TreeNode) object).getValue();
-                    if(value instanceof SpecimenOrObservationBase<?> || value instanceof Sequence || value instanceof SingleRead){
-                        if(postOperationEnabled instanceof IConversationEnabled){
-                            ConversationHolder conversationHolder = ((IConversationEnabled) postOperationEnabled).getConversationHolder();
-                            label += " "+DerivateLabelProvider.getDerivateText(value, conversationHolder); //$NON-NLS-1$
-                        }
-
-
-                        DeleteDerivateOperation deleteDerivateOperation = new DeleteDerivateOperation(label, undoContext, (CdmBase) value, (TreeNode) object, postOperationEnabled, this.deleteConfigurator);
-                        return deleteDerivateOperation;
-                    }
-                }
-            }
-        } catch (NotDefinedException e) {
-            MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
-        }
-        return null;
-
+    @CanExecute
+    public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode node){
+        return node !=null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void onComplete() {
-
-        IPostOperationEnabled postOperationEnabled = (editor instanceof IPostOperationEnabled) ? (IPostOperationEnabled) editor : null;
-        if (postOperationEnabled != null){
-            DerivateView derivateView = (DerivateView)postOperationEnabled;
-          if(derivateView.postOperation(null)){
-              derivateView.remove(node);
-
-          }
-        }
-    }
 }
index 8638a309e67840a7c1089c49f78b6749ef6a392f..ff08c367a981d667f86dfcde7c7591ed0492030d 100644 (file)
@@ -11,6 +11,7 @@ public class AppModelId {
        public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_COMMAND_ADD_DERIVATE_ADD_TISSUE_SAMPLE = "eu.etaxonomy.taxeditor.editor.command.add_derivate.add_tissue_sample";
        public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_COMMAND_SPECIMENEDITOR_CREATE_FIELD_UNIT = "eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit";
        public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATE_DEEPDELETE = "eu.etaxonomy.taxeditor.editor.derivate.deepDelete";
+       public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATE_DELETE = "eu.etaxonomy.taxeditor.editor.derivate.delete";
        public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATIVE_COPYSINGLEREADTOCLIPBOARD = "eu.etaxonomy.taxeditor.editor.derivative.copySingleReadToClipBoard";
        public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATIVE_REMOVESINGLEREADFROMSEQUENCE = "eu.etaxonomy.taxeditor.editor.derivative.removeSingleReadFromSequence";
        public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATIVE_REUSESINGLEREAD = "eu.etaxonomy.taxeditor.editor.derivative.reuseSingleRead";