ref #5616 Fix NPE for opening synonyms from SearchResult view
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 13 Sep 2016 11:35:33 +0000 (13:35 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 13 Sep 2016 11:35:33 +0000 (13:35 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/BulkEditorInputType.java
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenTaxonEditorForTaxonBaseHandler.java [moved from eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenTaxonEditorForTaxonHandler.java with 77% similarity]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
eu.etaxonomy.taxeditor.navigation/plugin.xml

index a509aecbddfa4e436d9563d672c08961f26275f0..bbbc9a27da7c2648a2d91daef5aef0fb22cbb7ea 100644 (file)
@@ -27,7 +27,7 @@ import eu.etaxonomy.cdm.model.name.NameRelationship;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
 
 public enum BulkEditorInputType {
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
 
 public enum BulkEditorInputType {
@@ -100,7 +100,7 @@ public enum BulkEditorInputType {
                        return GROUP;
                } else if (User.class.isAssignableFrom(clazz)) {
                        return USER;
                        return GROUP;
                } else if (User.class.isAssignableFrom(clazz)) {
                        return USER;
-               } else if (Taxon.class.isAssignableFrom(clazz)){
+               } else if (TaxonBase.class.isAssignableFrom(clazz)){
                        return TAXON;
                } else if (Media.class.isAssignableFrom(clazz)){
             return MEDIA;
                        return TAXON;
                } else if (Media.class.isAssignableFrom(clazz)){
             return MEDIA;
index 3ce1fcb21c03be11a8a3c888313cde0f822233fa..dbee6199252b64cd132ec36b4c128b2dd17dfb41 100644 (file)
@@ -8,6 +8,7 @@ Bundle-Vendor: %Bundle-Vendor.0
 Bundle-Localization: OSGI-INF/l10n/plugin
 Export-Package: eu.etaxonomy.taxeditor.editor,
  eu.etaxonomy.taxeditor.editor.handler,
 Bundle-Localization: OSGI-INF/l10n/plugin
 Export-Package: eu.etaxonomy.taxeditor.editor,
  eu.etaxonomy.taxeditor.editor.handler,
+ eu.etaxonomy.taxeditor.editor.handler.defaultHandler,
  eu.etaxonomy.taxeditor.editor.internal,
  eu.etaxonomy.taxeditor.editor.key.polytomous,
  eu.etaxonomy.taxeditor.editor.name,
  eu.etaxonomy.taxeditor.editor.internal,
  eu.etaxonomy.taxeditor.editor.key.polytomous,
  eu.etaxonomy.taxeditor.editor.name,
@@ -12,7 +12,7 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 
-public class DefaultOpenTaxonEditorForTaxonHandler extends DefaultOpenHandlerBase<TaxonBase> {
+public class DefaultOpenTaxonEditorForTaxonBaseHandler extends DefaultOpenHandlerBase<TaxonBase> {
 
     @Override
     protected TaxonBase getEntity(UUID uuid) {
 
     @Override
     protected TaxonBase getEntity(UUID uuid) {
@@ -24,7 +24,7 @@ public class DefaultOpenTaxonEditorForTaxonHandler extends DefaultOpenHandlerBas
         try {
             EditorUtil.openTaxonBase(entity.getUuid());
         } catch (PartInitException e) {
         try {
             EditorUtil.openTaxonBase(entity.getUuid());
         } catch (PartInitException e) {
-            MessagingUtils.error(DefaultOpenTaxonEditorForTaxonHandler.class, "Could not open taxon editor for taxon/synonym "+entity, e);
+            MessagingUtils.error(DefaultOpenTaxonEditorForTaxonBaseHandler.class, "Could not open taxon editor for taxon/synonym "+entity, e);
         }
     }
 
         }
     }
 
index 5eb1e17849f34c50a5222c53bef2bd1ee0d20b26..77071c9b521104310bfe5767801016a8a0dd1d90 100644 (file)
@@ -10,6 +10,8 @@
 
 package eu.etaxonomy.taxeditor.editor.name.handler;
 
 
 package eu.etaxonomy.taxeditor.editor.name.handler;
 
+import java.util.Set;
+
 import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
@@ -170,6 +172,17 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
        }
 
        private boolean isOrphaned(Object selectedElement) {
        }
 
        private boolean isOrphaned(Object selectedElement) {
-           return selectedElement instanceof Taxon  && ((Taxon) selectedElement).isOrphaned();
+           if(selectedElement instanceof Taxon){
+               return ((Taxon) selectedElement).isOrphaned();
+           }
+           else if(selectedElement instanceof Synonym){
+               Set<Taxon> acceptedTaxa = ((Synonym) selectedElement).getAcceptedTaxa();
+               for (Taxon taxon : acceptedTaxa) {
+                if(!taxon.isOrphaned()){
+                    return false;
+                }
+            }
+           }
+           return false;
        }
 }
        }
 }
index 65c7e18ea73cb5033a2326e6c7b014f3cef8a1e0..be4c61af80e4f663d7ba7a28cf6902b6c7466f29 100644 (file)
          </activeWhen>
       </handler>
       <handler
          </activeWhen>
       </handler>
       <handler
-            class="eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenTaxonEditorForTaxonHandler"
+            class="eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenTaxonEditorForTaxonBaseHandler"
             commandId="eu.etaxonomy.taxeditor.editor.openTaxonEditorForTaxon">
          <activeWhen>
             <and>
             commandId="eu.etaxonomy.taxeditor.editor.openTaxonEditorForTaxon">
          <activeWhen>
             <and>