fix #8784: update factual data view after deleting specimen description
authorKatja Luther <k.luther@bgbm.org>
Thu, 23 Jan 2020 10:40:18 +0000 (11:40 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 23 Jan 2020 10:40:18 +0000 (11:40 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DeleteHandlerE4.java

index f137491b961af88d99896720032663425778a424..a83275a76caa53585858fc6cbdb0c02234fab412 100644 (file)
@@ -36,6 +36,7 @@ import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
@@ -85,6 +86,7 @@ public class DeleteHandlerE4 {
                 continue;
             }
             DescriptionBase description = null;
+            SpecimenOrObservationBase specimen = null;
             DeleteResult result = new DeleteResult();
             if (object instanceof DescriptionBase){
                 result = CdmStore.getService(IDescriptionService.class).isDeletable(((DescriptionBase) object).getUuid());
@@ -107,8 +109,8 @@ public class DeleteHandlerE4 {
 
                 } else if(object instanceof SpecimenDescription){
                     operation = new DeleteSpecimenDescriptionOperation(label, undoContext, (SpecimenDescription) object, factualDataPart, cdmEntitySessionEnabled);
-
-                    ((SpecimenDescription) object).getDescribedSpecimenOrObservation().removeDescription((SpecimenDescription) object);
+                    specimen = ((SpecimenDescription) object).getDescribedSpecimenOrObservation();
+                    specimen.removeDescription((SpecimenDescription) object);
 
                 } else if(object instanceof DescriptionElementBase){
                     // DescriptionElementBase
@@ -133,8 +135,10 @@ public class DeleteHandlerE4 {
                 if (factualDataPart.getSelectionProvidingPart().getObject() instanceof DerivateView){
                     ((DerivateView)factualDataPart.getSelectionProvidingPart().getObject()).addOperation(operation);
                     ((DerivateView)factualDataPart.getSelectionProvidingPart().getObject()).setDirty(true);
+
                     if (object instanceof DescriptionBase){
-                        ((DerivateView)factualDataPart.getSelectionProvidingPart().getObject()).changed(((SpecimenDescription)object).getDescribedSpecimenOrObservation());
+                        factualDataPart.getViewer().refresh();
+                        factualDataPart.collapse();
                     } else if (object instanceof DescriptionElementBase){
                         if (description != null){
                             factualDataPart.changed(description);
@@ -146,6 +150,7 @@ public class DeleteHandlerE4 {
                     ((BulkEditorE4)factualDataPart.getSelectionProvidingPart().getObject()).setDirty(true);
                     ((BulkEditorE4)factualDataPart.getSelectionProvidingPart().getObject()).changed(((SpecimenDescription)object).getDescribedSpecimenOrObservation());
                 }
+
             }
             else{
                 Exception e = result.getExceptions() != null && !result.getExceptions().isEmpty()? result.getExceptions().iterator().next() : null;