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;
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.
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);
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)