ref #6973 Clear editor parts when reconnecting
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 16 May 2018 10:09:53 +0000 (12:09 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 16 May 2018 10:10:01 +0000 (12:10 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/e4/ReconnectHandlerE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/e4/ShowRemotingLoginWindowHandlerE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java

index e11e80d54254ba2ca868305a4cf9603ea3b07c52..ab4e2a8484e3ece6cddaae126e56134971714b28 100644 (file)
@@ -13,6 +13,8 @@ import javax.inject.Named;
 
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Shell;
 
@@ -31,12 +33,13 @@ import eu.etaxonomy.taxeditor.ui.dialog.RemotingLoginDialog;
 public class ReconnectHandlerE4 {
 
     @Execute
-    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, ESelectionService selService) {
 
                RemotingLoginDialog loginDialog = new RemotingLoginDialog(shell,
                        SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
 
                loginDialog.open((CdmRemoteSource) CdmStore.getActiveCdmSource(), true, true);
                EventUtility.postEvent(WorkbenchEventConstants.RECONNECT, null);
+               selService.setSelection(new StructuredSelection());
        }
 }
index b033108970b199edb6618d301969bb4c04a7c5b6..e4fd2a41d60b23b339e01563775650274e2694ce 100644 (file)
@@ -13,6 +13,8 @@ import javax.inject.Named;
 
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Shell;
 
@@ -29,11 +31,12 @@ import eu.etaxonomy.taxeditor.ui.dialog.RemotingLoginDialog;
 public class ShowRemotingLoginWindowHandlerE4 {
 
     @Execute
-    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, ESelectionService selService) {
 
            RemotingLoginDialog loginDialog = new RemotingLoginDialog(shell,
                    SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
            loginDialog.open();
         EventUtility.postEvent(WorkbenchEventConstants.RECONNECT, null);
+        selService.setSelection(new StructuredSelection());
        }
 }
index 79a209c211b8deff9d01f8766b7616c02076d12f..70d97b6c9586f9b61a495e7c11e83251d59943e0 100644 (file)
@@ -15,9 +15,9 @@ import javax.inject.Inject;
 import javax.inject.Named;
 
 import org.apache.log4j.Logger;
+import org.eclipse.e4.core.contexts.IEclipseContext;
 import org.eclipse.e4.core.di.annotations.Optional;
 import org.eclipse.e4.ui.di.PersistState;
-import org.eclipse.e4.ui.di.UIEventTopic;
 import org.eclipse.e4.ui.di.UISynchronize;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.services.IServiceConstants;
@@ -40,7 +40,6 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
 import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
-import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -130,6 +129,9 @@ public abstract class AbstractCdmEditorPartE4
     @Inject
     protected ESelectionService selService;
 
+    @Inject
+    protected IEclipseContext context;
+
     protected abstract void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart);
 
     @Inject
@@ -178,12 +180,6 @@ public abstract class AbstractCdmEditorPartE4
         }
     }
 
-    @Inject
-    @Optional
-    private void clearOnReconnect(@UIEventTopic(WorkbenchEventConstants.RECONNECT)Object o){
-        showEmptyPage();
-    }
-
     public Viewer getViewer() {
         return viewer;
     }
@@ -257,7 +253,7 @@ public abstract class AbstractCdmEditorPartE4
             }
 
         }
-        selectionProvidingPart = null;
+        reset();
         if(thisPart!=null){
             thisPart.setLabel(getViewName());
         }
@@ -318,6 +314,13 @@ public abstract class AbstractCdmEditorPartE4
     private void dispose() {
     }
 
+    private void reset(){
+        previousSelection = null;
+        selectionProvidingPart = null;
+        delaySelection = null;
+        context.deactivate();
+    }
+
     @PersistState
     private void persistState(){