commit 30afcea01068a7e0dcd2bde6b9a5f28e4bbcdd6f
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Tue Sep 13 13:07:42 2016 +0200

    fix #5616 Add check for orphaned taxa to CdmViewer context menu
    
     - removed default handler for this

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml b/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
index c8bd4f726..6570a9cb4 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
@@ -540,11 +540,6 @@
             selection="eu.etaxonomy.cdm.model.taxon.TaxonNode"
             viewerName="%viewCommandMapping.viewerName.BULK_EDITOR">
       </viewCommandMapping>
-      <viewCommandMapping
-            commandId="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity"
-            selection="eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache"
-            viewerName="%viewCommandMapping.viewerName.BULK_EDITOR">
-      </viewCommandMapping>
       <viewCommandMapping
             commandId="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity"
             selection="eu.etaxonomy.cdm.model.common.IdentifiableEntity"
diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml
index 3ef7f1725..e32835fb7 100644
--- a/eu.etaxonomy.taxeditor.editor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.editor/plugin.xml
@@ -1632,7 +1632,6 @@
             name="%command.name.41">
       </command>
       <command
-            defaultHandler="eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenTaxonEditorForTaxonHandler"
             id="eu.etaxonomy.taxeditor.editor.openTaxonEditorForTaxon"
             name="%command.name.42">
          <commandParameter
@@ -1952,6 +1951,16 @@
             </test>
          </with>
       </definition>
+      <definition
+            id="isOrphanedTaxon">
+         <with
+               variable="selection">
+            <test
+                  forcePluginActivation="true"
+                  property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isOrphaned">
+            </test>
+         </with>
+      </definition>
    </extension>
    <extension
          point="org.eclipse.core.expressions.propertyTesters">
@@ -1959,7 +1968,7 @@
             class="eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester"
             id="eu.etaxonomy.taxeditor.editor.name.propertyTester"
             namespace="eu.etaxonomy.taxeditor.editor.name.propertyTester"
-            properties="isAcceptedTaxon,isSynonym,isMisapplication,isTaxonBase,hasEmptyNames,isAcceptedAndHasNoHomotypicSynonyms,isNotHomotypicSynonymOfAcceptedTaxon,isSynonymInHomotypicalGroupWithMoreSynonyms"
+            properties="isAcceptedTaxon,isSynonym,isMisapplication,isTaxonBase,hasEmptyNames,isAcceptedAndHasNoHomotypicSynonyms,isNotHomotypicSynonymOfAcceptedTaxon,isSynonymInHomotypicalGroupWithMoreSynonyms,isOrphaned"
             type="org.eclipse.jface.viewers.IStructuredSelection">
       </propertyTester>
       <propertyTester
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 f8a49eb01..5eb1e1784 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
@@ -12,12 +12,15 @@ package eu.etaxonomy.taxeditor.editor.name.handler;
 
 import org.eclipse.jface.viewers.IStructuredSelection;
 
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 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.store.CdmStore;
 
 /**
  * <p>NameEditorMenuPropertyTester class.</p>
@@ -37,6 +40,7 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
 	private static final String ACCEPTED_AND_NO_HOMOTYPIC_SYNONYMS = "isAcceptedAndHasNoHomotypicSynonyms";
 	private static final String NOT_HOMOTYPIC_SYNONYM_OF_ACCEPTED = "isNotHomotypicSynonymOfAcceptedTaxon";
 	private static final String SYNONYM_WITH_HOMOTYPIC_SYNONYMS = "isSynonymInHomotypicalGroupWithMoreSynonyms";
+	private static final String IS_ORPHANED = "isOrphaned";
 
 	/**
 	 * <p>Constructor for NameEditorMenuPropertyTester.</p>
@@ -57,6 +61,11 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
 			IStructuredSelection selection = (IStructuredSelection) receiver;
 
 			Object selectedElement = selection.getFirstElement();
+			if(selectedElement instanceof UuidAndTitleCache){
+			    UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache<?>)selectedElement;
+			    CdmBase cdmBase = CdmStore.getCommonService().find(uuidAndTitleCache.getType(), uuidAndTitleCache.getUuid());
+			    selectedElement = cdmBase;
+			}
 
 			if(ACCEPTED.equals(property)){
 				return isAccepted(selectedElement);
@@ -85,6 +94,9 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
 			else if (SYNONYM_WITH_HOMOTYPIC_SYNONYMS.equals(property)){
 				return isSynonymInHomotypicalGroupWithMoreSynonyms(selectedElement);
 			}
+			else if (IS_ORPHANED.equals(property)){
+			    return isOrphaned(selectedElement);
+			}
 
 		}
 
@@ -99,7 +111,7 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
 		}
 		return false;
 	}
-	
+
 	private boolean isSynonymInHomotypicalGroupWithMoreSynonyms(Object selectedElement) {
 		if (isSynonym(selectedElement)){
 			Synonym synonym = (Synonym) selectedElement;
@@ -156,4 +168,8 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
 	private boolean isAccepted(Object selectedElement) {
 		return (selectedElement instanceof Taxon  && ! ((Taxon) selectedElement).isMisapplication()) ? true : false;
 	}
+
+	private boolean isOrphaned(Object selectedElement) {
+	    return selectedElement instanceof Taxon  && ((Taxon) selectedElement).isOrphaned();
+	}
 }
diff --git a/eu.etaxonomy.taxeditor.navigation/plugin.xml b/eu.etaxonomy.taxeditor.navigation/plugin.xml
index 4960a059f..65c7e18ea 100644
--- a/eu.etaxonomy.taxeditor.navigation/plugin.xml
+++ b/eu.etaxonomy.taxeditor.navigation/plugin.xml
@@ -553,6 +553,19 @@
             </with>
          </activeWhen>
       </handler>
+      <handler
+            class="eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenTaxonEditorForTaxonHandler"
+            commandId="eu.etaxonomy.taxeditor.editor.openTaxonEditorForTaxon">
+         <activeWhen>
+            <and>
+               <not>
+                  <reference
+                        definitionId="isOrphanedTaxon">
+                  </reference>
+               </not>
+            </and>
+         </activeWhen>
+      </handler>
    </extension>
 
       
