commit 90cf660a0f8827f0a66011c6df51950744bc5652
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Mon Aug 28 16:59:11 2017 +0200

    ref #6595 Set visibility of context menu items in name editor

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java
index 3c124d8ce..0651699eb 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java
@@ -14,13 +14,14 @@ import java.util.Set;
 import javax.inject.Named;
 
 import org.apache.log4j.Logger;
+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;
 import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.PartInitException;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
@@ -29,12 +30,12 @@ import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
 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.ChangeSynonymToAcceptedTaxonOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
 
@@ -59,7 +60,7 @@ public class ChangeSynonymToAcceptedTaxonHandlerE4 implements IPostOperationEnab
 
 		IEditorInput input = editor.getEditorInput();
 
-		if (!(input instanceof TaxonEditorInput)) {
+		if (!(input instanceof TaxonEditorInputE4)) {
 			logger.error("Editor input is not TaxonEditorInput"); //$NON-NLS-1$
 			return;
 		}
@@ -78,9 +79,9 @@ public class ChangeSynonymToAcceptedTaxonHandlerE4 implements IPostOperationEnab
 		}
 
 		// Get taxon
-		Taxon taxon = ((TaxonEditorInput) input).getTaxon();
+		Taxon taxon = ((TaxonEditorInputE4) input).getTaxon();
 
-		TaxonNode newParentNode = TaxonNodeSelectionDialog.select(shell, editor.getConversationHolder(), Messages.ChangeSynonymToAcceptedTaxonHandler_SELECT_PARENT, null, null, ((TaxonEditorInput) input).getTaxonNode().getClassification());
+		TaxonNode newParentNode = TaxonNodeSelectionDialog.select(shell, editor.getConversationHolder(), Messages.ChangeSynonymToAcceptedTaxonHandler_SELECT_PARENT, null, null, ((TaxonEditorInputE4) input).getTaxonNode().getClassification());
 
 
 		if(newParentNode != null){
@@ -113,21 +114,15 @@ public class ChangeSynonymToAcceptedTaxonHandlerE4 implements IPostOperationEnab
 			TaxonNode newNode = (TaxonNode) objectAffectedByOperation;
 //			TaxonNode newNode = parentNode.addChild(newTaxon);
 
-			try {
-				// TODO
-				/*
-				 * This doesn't work b/c newNode hasn't been committed yet, and therefore
-				 *  CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid);
-				 *  doesn't work yet.
-				 */
-				EditorUtil.openTaxonNode(newNode.getUuid());
-
-			} catch (PartInitException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			} catch (Exception e) {
-				MessagingUtils.warningDialog(Messages.ChangeSynonymToAcceptedTaxonHandler_CREATE_FAILURE, this, e.getMessage());
-			}
+//			try {
+				// FIXME E4 this throws an exception
+//				EditorUtil.openTaxonNodeE4(newNode.getUuid());
+//
+//			} catch (PartInitException e) {
+//				e.printStackTrace();
+//			} catch (Exception e) {
+//				MessagingUtils.warningDialog(Messages.ChangeSynonymToAcceptedTaxonHandler_CREATE_FAILURE, this, e.getMessage());
+//			}
 		}
 		return true;
 	}
@@ -136,4 +131,19 @@ public class ChangeSynonymToAcceptedTaxonHandlerE4 implements IPostOperationEnab
     public boolean onComplete() {
 		return false;
 	}
+
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                NameEditorMenuPropertyTester.isNotHomotypicSynonymOfAcceptedTaxon(selectedElement)
+                && !NameEditorMenuPropertyTester.isAccepted(selectedElement)
+                && !NameEditorMenuPropertyTester.isMisapplication(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToMisapplicationHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToMisapplicationHandlerE4.java
index bcbdfd610..fdd4971d7 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToMisapplicationHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToMisapplicationHandlerE4.java
@@ -11,6 +11,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;
@@ -23,6 +24,7 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptRelationshipTypeOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
@@ -64,4 +66,17 @@ public class ChangeToMisapplicationHandlerE4 {
 
         AbstractUtility.executeOperation(operation);
 	}
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                !NameEditorMenuPropertyTester.isAccepted(selectedElement)
+                && !NameEditorMenuPropertyTester.isMisapplication(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToSynonymHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToSynonymHandlerE4.java
index 3c88050a3..91a1bbf5c 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToSynonymHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToSynonymHandlerE4.java
@@ -11,6 +11,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;
@@ -19,6 +20,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptToSynonymOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
@@ -48,4 +50,17 @@ public class ChangeToSynonymHandlerE4 {
         AbstractUtility.executeOperation(operation);
 
 	}
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                !NameEditorMenuPropertyTester.isAccepted(selectedElement)
+                && !NameEditorMenuPropertyTester.isSynonym(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHeterotypicSynonymHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHeterotypicSynonymHandlerE4.java
index bdde05fac..d27cfd344 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHeterotypicSynonymHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHeterotypicSynonymHandlerE4.java
@@ -11,13 +11,16 @@ 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;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
@@ -45,4 +48,13 @@ public class CreateHeterotypicSynonymHandlerE4 {
         		editor.getUndoContext(), editor.getTaxon(), newSynonymName, editor);
         AbstractUtility.executeOperation(operation);
 	}
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        Object selectedElement = selection.getFirstElement();
+        boolean canExecute = NameEditorMenuPropertyTester.isAccepted(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHomotypicSynonymHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHomotypicSynonymHandlerE4.java
index 312b4ede3..931b26384 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHomotypicSynonymHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateHomotypicSynonymHandlerE4.java
@@ -11,15 +11,18 @@ 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;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
@@ -48,4 +51,13 @@ public class CreateHomotypicSynonymHandlerE4 {
         		editor.getUndoContext(), taxon, group, newSynonymName, editor);
         AbstractUtility.executeOperation(operation);
 	}
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        Object selectedElement = selection.getFirstElement();
+        boolean canExecute = NameEditorMenuPropertyTester.isAccepted(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateMisapplicationHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateMisapplicationHandlerE4.java
index e862dbbe9..851830787 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateMisapplicationHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateMisapplicationHandlerE4.java
@@ -11,15 +11,18 @@ 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;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
@@ -49,4 +52,16 @@ public class CreateMisapplicationHandlerE4 {
         		editor.getUndoContext(), editor.getTaxon(), concept, type, editor);
         AbstractUtility.executeOperation(operation);
 	}
+
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute = NameEditorMenuPropertyTester.isAccepted(selectedElement)
+                && NameEditorMenuPropertyTester.isMisapplication(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateSynonymInHomotypicalGroupHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateSynonymInHomotypicalGroupHandlerE4.java
index 257144649..dfc8677dc 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateSynonymInHomotypicalGroupHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateSynonymInHomotypicalGroupHandlerE4.java
@@ -11,6 +11,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;
@@ -21,6 +22,7 @@ import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
@@ -60,4 +62,15 @@ public class CreateSynonymInHomotypicalGroupHandlerE4 {
         AbstractUtility.executeOperation(operation);
 
 	}
+
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute = NameEditorMenuPropertyTester.isSynonym(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteAllEmptyNamesHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteAllEmptyNamesHandlerE4.java
index 3557593c8..8b96934f1 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteAllEmptyNamesHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteAllEmptyNamesHandlerE4.java
@@ -11,6 +11,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;
@@ -45,4 +46,20 @@ public class DeleteAllEmptyNamesHandlerE4 extends DeleteTaxonBaseHandlerE4 {
 
 	}
 
+    @Override
+    @CanExecute
+    public boolean canExecute(
+            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+
+        editor = (TaxonNameEditorE4) activePart.getObject();
+
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute = editor.checkForEmptyNames();
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteTaxonBaseHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteTaxonBaseHandlerE4.java
index cccbb01c4..ff25e883b 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteTaxonBaseHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteTaxonBaseHandlerE4.java
@@ -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,10 +114,23 @@ 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) {
 
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/MoveSynonymToAnotherAcceptedTaxonHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/MoveSynonymToAnotherAcceptedTaxonHandlerE4.java
index ab054e854..b8545651f 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/MoveSynonymToAnotherAcceptedTaxonHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/MoveSynonymToAnotherAcceptedTaxonHandlerE4.java
@@ -7,8 +7,10 @@ import java.util.UUID;
 import javax.inject.Named;
 
 import org.apache.log4j.Logger;
+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;
 import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.widgets.Shell;
@@ -22,6 +24,7 @@ import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
 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.MoveSynonymToAnotherAcceptedTaxonOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
@@ -69,22 +72,30 @@ public class MoveSynonymToAnotherAcceptedTaxonHandlerE4 implements IPostOperatio
 		            oldParent.getUuid(), synonym.getUuid(), newParentNode.getTaxon(), editor);
 
 		    AbstractUtility.executeOperation(operation);
-
 		}
 	}
 
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                NameEditorMenuPropertyTester.isSynonym(selectedElement)
+                        && NameEditorMenuPropertyTester.isNotHomotypicSynonymOfAcceptedTaxon(selectedElement);
+
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 	@Override
 	public boolean postOperation(CdmBase objectAffectedByOperation) {
-		// TODO Auto-generated method stub
 		return false;
 	}
 
 	@Override
 	public boolean onComplete() {
-		// TODO Auto-generated method stub
 		return false;
 	}
 
-
-
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SetBasionymHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SetBasionymHandlerE4.java
index 0e066266d..ae24df964 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SetBasionymHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SetBasionymHandlerE4.java
@@ -11,6 +11,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;
@@ -19,6 +20,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
+import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
 import eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicalGroupBasionymOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
@@ -46,4 +48,15 @@ public class SetBasionymHandlerE4 {
         					editor.getTaxon(), selectedTaxonBase, editor);
         AbstractUtility.executeOperation(operation);
 	}
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                NameEditorMenuPropertyTester.isSynonymInHomotypicalGroupWithMoreSynonyms(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SwapSynonymAndAcceptedHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SwapSynonymAndAcceptedHandlerE4.java
index 95b818040..945a35c03 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SwapSynonymAndAcceptedHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SwapSynonymAndAcceptedHandlerE4.java
@@ -11,6 +11,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;
@@ -26,6 +27,7 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 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.SwapSynonymAndAcceptedOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
@@ -68,6 +70,17 @@ public class SwapSynonymAndAcceptedHandlerE4 implements IPostOperationEnabled {
 
     }
 
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        Object selectedElement = selection.getFirstElement();
+        canExecute =
+                NameEditorMenuPropertyTester.isSynonym(selectedElement);
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
     @Override
     public boolean postOperation(CdmBase objectAffectedByOperation) {
         // Redraw existing editor
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
index 3030a0db4..758e3ea42 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
@@ -19,7 +19,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.Page;
-import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
+import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -101,7 +101,7 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
 
 	}
 
-	private boolean isAcceptedAndHasNoHomotypicSynonyms(Object selectedElement) {
+	public static boolean isAcceptedAndHasNoHomotypicSynonyms(Object selectedElement) {
 		if (isAccepted(selectedElement)){
 			Taxon taxon = (Taxon) selectedElement;
 			return taxon.getSynonymsInGroup(taxon.getHomotypicGroup()).isEmpty();
@@ -109,7 +109,7 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
 		return false;
 	}
 
-	private boolean isSynonymInHomotypicalGroupWithMoreSynonyms(Object selectedElement) {
+	public static boolean isSynonymInHomotypicalGroupWithMoreSynonyms(Object selectedElement) {
 		if (isSynonym(selectedElement)){
 			Synonym synonym = (Synonym) selectedElement;
 			return synonym.getHomotypicGroup().getTypifiedNames().size()>1;
@@ -118,11 +118,11 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
 	}
 
 
-	private boolean isNotHomotypicSynonymOfAcceptedTaxon(Object selectedElement) {
+	public static boolean isNotHomotypicSynonymOfAcceptedTaxon(Object selectedElement) {
 		if (isSynonym(selectedElement)){
 			Synonym synonym = (Synonym) selectedElement;
 			Taxon taxon = synonym.getAcceptedTaxon();
-			if (taxon != null && 
+			if (taxon != null &&
 					taxon.getHomotypicGroup().equals(synonym.getHomotypicGroup())){
 				return false;
 			}
@@ -135,38 +135,38 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
 	 * @param receiver
 	 * @return
 	 */
-	private boolean hasEmptyNames(Object receiver) {
-		TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
+	public static boolean hasEmptyNames(Object receiver) {
+		TaxonNameEditorE4 editor = (TaxonNameEditorE4) EditorUtil.getActiveEditorPage(Page.NAME);
 		return editor == null ? false : editor.checkForEmptyNames();
 	}
 
-	private boolean isRelatedConcept(Object selectedElement) {
+	public static boolean isRelatedConcept(Object selectedElement) {
 		if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isRelatedConcept()){
 			return true;
 		}
 		return false;
 	}
 
-	private boolean isTaxonBase(Object selectedElement) {
+	public static boolean isTaxonBase(Object selectedElement) {
 		return (selectedElement instanceof TaxonBase) ? true : false;
 	}
 
-	private boolean isMisapplication(Object selectedElement) {
+	public static boolean isMisapplication(Object selectedElement) {
 		if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isMisapplication()){
 			return true;
 		}
 		return false;
 	}
 
-	private boolean isSynonym(Object selectedElement) {
+	public static boolean isSynonym(Object selectedElement) {
 		return (selectedElement instanceof Synonym) ? true : false;
 	}
 
-	private boolean isAccepted(Object selectedElement) {
+	public static boolean isAccepted(Object selectedElement) {
 		return (selectedElement instanceof Taxon  && ! ((Taxon) selectedElement).isMisapplication()) ? true : false;
 	}
 
-	private boolean isOrphaned(Object selectedElement) {
+	public static boolean isOrphaned(Object selectedElement) {
 	    if(selectedElement instanceof Taxon){
 	        return ((Taxon) selectedElement).isOrphaned();
 	    }
