X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FDefaultExplorerSelectionListener.java;h=713b28297e67856ba0841f263aeb12a9f0028aa3;hb=HEAD;hp=407fbff3ba8fa750ae823c4148aa71c131d9b129;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/DefaultExplorerSelectionListener.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/DefaultExplorerSelectionListener.java index 407fbff3b..713b28297 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/DefaultExplorerSelectionListener.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/DefaultExplorerSelectionListener.java @@ -15,9 +15,10 @@ import org.eclipse.jface.viewers.IPostSelectionProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.services.IDisposable; import org.simantics.browsing.ui.GraphExplorer; -public class DefaultExplorerSelectionListener implements ISelectionListener { +public class DefaultExplorerSelectionListener implements ISelectionListener, IDisposable { private static final boolean DEBUG = false; @@ -35,6 +36,13 @@ public class DefaultExplorerSelectionListener implements ISelectionListener { this.filter = filter; } + @Override + public void dispose() { + owner = null; + explorer = null; + filter = null; + } + @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { // Always disregard own selections. @@ -44,6 +52,7 @@ public class DefaultExplorerSelectionListener implements ISelectionListener { if (DEBUG) System.out.println("[" + owner + "] workbench selection changed: part=" + part + ", selection=" + selection); ISelection s = selection; + WorkbenchSelectionFilter filter = this.filter; if (filter != null) s = filter.filterSelection(part, selection); @@ -52,9 +61,12 @@ public class DefaultExplorerSelectionListener implements ISelectionListener { System.out.println("** [" + owner + "] workbench selection changed: part=" + part + ", selection=" + selection); System.out.println(" SETTING NEW SELECTION"); } - if(!explorer.isDisposed()) { + GraphExplorer explorer = this.explorer; + if(explorer != null && !explorer.isDisposed()) { IPostSelectionProvider selectionProvider = (IPostSelectionProvider)explorer.getAdapter(IPostSelectionProvider.class); - selectionProvider.setSelection(selection); + if (selectionProvider != null) { + selectionProvider.setSelection(selection); + } } } else { if (DEBUG)