avoid NPE and fix closing of obsolete editors when deleting classification
authorKatja Luther <k.luther@bgbm.org>
Mon, 29 Jun 2020 12:25:01 +0000 (14:25 +0200)
committerKatja Luther <k.luther@bgbm.org>
Mon, 29 Jun 2020 12:25:01 +0000 (14:25 +0200)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingDeleteTaxonNodeHandlerE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/util/TaxonTreeNodeContentProvider.java

index 07338d1..dbd639e 100644 (file)
@@ -75,6 +75,7 @@ public class RemotingDeleteTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
             if (object instanceof TaxonNodeDto && ((TaxonNodeDto)object).getTaxonUuid() == null){
                 TaxonNodeDto dto = (TaxonNodeDto)object;
                 classifications.add(dto);
+                treeNodes.add(dto);
                 containsClassification = true;
             }else if(object instanceof TaxonNodeDto) {
                 treeNodes.add((TaxonNodeDto) object);
@@ -88,23 +89,25 @@ public class RemotingDeleteTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
         Iterator it = treeNodes.iterator();
 
         treeNodes = new HashSet();
-        while (it.hasNext()){
-            TaxonNodeDto treeNode = (TaxonNodeDto) it.next();
+        if (!containsClassification){
+            while (it.hasNext()){
+                TaxonNodeDto treeNode = (TaxonNodeDto) it.next();
 
-            treeNodes.add(treeNode);
-            if (treeNode == null){
-               MessagingUtils.informationDialog(Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED, Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE);
-               return Status.CANCEL_STATUS;
+                treeNodes.add(treeNode);
+                if (treeNode == null){
+                       MessagingUtils.informationDialog(Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED, Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE);
+                       return Status.CANCEL_STATUS;
 
-            }
-           if (treeNode instanceof TaxonNodeDto){
-               containsTaxonNodes = true;
-               if (treeNode.getTaxonomicChildrenCount()>0){
-                       containsNodeWithChildren = true;
-               }
-            }
+                }
+               if (treeNode instanceof TaxonNodeDto){
+                       containsTaxonNodes = true;
+                       if (treeNode.getTaxonomicChildrenCount()>0){
+                               containsNodeWithChildren = true;
+                       }
+                }
 
 
+            }
         }
 
         for (TaxonNodeDto rootNode: classifications){
index d276647..0dece26 100644 (file)
@@ -71,7 +71,9 @@ public class TaxonTreeNodeContentProvider implements ITreeContentProvider {
         if(element instanceof TaxonNodeDto){
             if (((TaxonNodeDto) element).getParentUUID() != null){
                 TaxonNode parent = taxonNodeService.load(((TaxonNodeDto) element).getParentUUID());
-                return new TaxonNodeDto(parent);
+                if (parent != null){
+                    return new TaxonNodeDto(parent);
+                }
             }
         }
         return null;