ref #8753: set selection to null after deleting descriptiveDataSet
authorKatja Luther <k.luther@bgbm.org>
Thu, 7 May 2020 14:10:15 +0000 (16:10 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 7 May 2020 14:10:15 +0000 (16:10 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetNavigator.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/handler/DeleteDescriptiveDataSetHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataPartE4.java

index f2971e66cfdbb30b52abec190b2955cbdf6e31bf..e80fdc8b982cb12582d2e31de89a452cbcbba1ab 100644 (file)
@@ -69,6 +69,7 @@ import eu.etaxonomy.cdm.model.term.TermType;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.IDescriptiveDataSetEditor;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.event.EventUtility;
 import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
@@ -89,7 +90,7 @@ import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
  *
  */
 public class DescriptiveDataSetEditor implements IE4SavablePart, IConversationEnabled, ICdmEntitySessionEnabled,
-IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
+IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable, IDescriptiveDataSetEditor {
 
     private DescriptiveDataSetComposite composite;
 
@@ -342,6 +343,7 @@ IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
             cdmEntitySession = null;
         }
         dirty.setDirty(false);
+        selectionService.setSelection(null);
     }
 
     @Focus
index 473547b800a15334a6dcf76f07e67d805e5eb516..62d13cf4383221374dc47b585fd884a009c17051 100644 (file)
@@ -201,6 +201,10 @@ public class DescriptiveDataSetNavigator implements IConversationEnabled, ICdmEn
         return conversation;
     }
 
+    public ESelectionService getSelService() {
+        return selService;
+    }
+
     /** {@inheritDoc} */
     @PreDestroy
     public void dispose() {
index 56d538549f26dcef60400ddb30569684ee7c69d7..7763961cd73b6a545e4ec63844d2008aca0c4963 100644 (file)
@@ -15,12 +15,14 @@ import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
@@ -28,11 +30,13 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 public class DeleteDescriptiveDataSetHandler {
+    protected EPartService partService;
 
-       @Execute
+    @Execute
        public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
-               @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+               @Named(IServiceConstants.ACTIVE_PART)MPart activePart, EPartService partService) {
            boolean confirm = MessagingUtils.confirmDialog(Messages.DeleteDescriptiveDataSetHandler_DELETE_TITLE, Messages.DeleteDescriptiveDataSetHandler_DELETE_MESSAGE);
+           this.partService = partService;
            Object object = activePart.getObject();
            if(!selection.isEmpty() && confirm && object instanceof DescriptiveDataSetNavigator){
                Iterator iterator = selection.iterator();
@@ -45,6 +49,8 @@ public class DeleteDescriptiveDataSetHandler {
                            DescriptiveDataSetNavigator navigator = (DescriptiveDataSetNavigator) object;
                            navigator.removeDescriptiveDataSet((DescriptiveDataSet) next);
                            navigator.getConversationHolder().commit();
+                           navigator.getSelService().setSelection(null);
+
                        }
                        else{
                            MessagingUtils.errorDialog(Messages.DeleteDescriptiveDataSetHandler_DELETE_FAILED_TITLE, DeleteDescriptiveDataSetHandler.class, Messages.DeleteDescriptiveDataSetHandler_DELETE_FAILED_MESSAGE, TaxeditorEditorPlugin.PLUGIN_ID, null, false);
@@ -55,6 +61,7 @@ public class DeleteDescriptiveDataSetHandler {
        }
 
        private void deleteDescriptiveDataSet(UUID descriptiveDataSetUuid){
+           EditorUtil.closeObsoleteDescriptiveDatasetEditor(descriptiveDataSetUuid, partService);
         UUID monitorUuid =  CdmApplicationState.getLongRunningTasksService().deleteDescriptiveDataset(descriptiveDataSetUuid);
 
         String jobLabel = "Delete descriptive dataset";
@@ -83,6 +90,7 @@ public class DeleteDescriptiveDataSetHandler {
                                         .collect(Collectors.joining("\n"))));
                     }
 
+
                 }
             } catch (InterruptedException e) {
                 return;
@@ -94,4 +102,6 @@ public class DeleteDescriptiveDataSetHandler {
     }
 
 
+
+
 }
\ No newline at end of file
index f5a077f5b152482b537bb4180216b7b7351889d0..f4420d7de21230f8471444425bf0fc46e1efe92b 100644 (file)
@@ -104,6 +104,7 @@ public class SupplementalDataPartE4 extends AbstractCdmEditorPartE4 {
                    showEmptyPage();
                    return;
                }
+
                else if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
                    return;
                }