Merge branch 'develop' into bulkEditorE4
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / e4 / handler / DeleteTaxonBaseHandlerE4.java
index cccbb01c4376466d9779a835ed8e4f88ac10e82f..89143960e88f4d0cbbd21b1fe37cd8b589e750a1 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.taxeditor.editor.name.e4.handler;
 import javax.inject.Named;
 
+import org.eclipse.e4.core.di.annotations.CanExecute;
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
@@ -28,6 +29,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteTaxonBaseOperation;
@@ -112,13 +114,26 @@ public class DeleteTaxonBaseHandlerE4 implements IPostOperationEnabled {
                 DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID);
                }
                }
-
-
        }
 
+    @CanExecute
+    public boolean canExecute(
+            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                NameEditorMenuPropertyTester.isSynonym(selectedElement)
+                || NameEditorMenuPropertyTester.isMisapplication(selectedElement)
+                || NameEditorMenuPropertyTester.isRelatedConcept(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
-
+           editor.redraw();
                return true;
        }