Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2007-01-30 19:18:51 +0000
committerDarin Wright2007-01-30 19:18:51 +0000
commit66b76590afcb66137c9f78a3ca50acf001991184 (patch)
tree75f22568fba78d78d6969cc7bd51ee88ea00cd22 /org.eclipse.debug.ui
parent3d8f85cfea88d6b9587090c09fe1268d76e9e3d7 (diff)
downloadeclipse.platform.debug-66b76590afcb66137c9f78a3ca50acf001991184.tar.gz
eclipse.platform.debug-66b76590afcb66137c9f78a3ca50acf001991184.tar.xz
eclipse.platform.debug-66b76590afcb66137c9f78a3ca50acf001991184.zip
Bug 159944 Asynchronous viewer should allow model to set selection after selected object is removed
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelSelectionPolicy.java19
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java6
3 files changed, 50 insertions, 1 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java
index 380ed3487..15c903fbb 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java
@@ -32,6 +32,7 @@ import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILazyTreePathContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
@@ -320,7 +321,30 @@ public class InternalTreeModelViewer extends TreeViewer {
super.hookControl(control);
}
-
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#handleInvalidSelection
+ *
+ * Override the default handler for invalid selection to allow model
+ * selection policy to select the new selection.
+ */
+ protected void handleInvalidSelection(ISelection selection, ISelection newSelection) {
+ IModelSelectionPolicy selectionPolicy = getSelectionPolicy(selection);
+ if (selectionPolicy != null) {
+ ISelection temp = newSelection;
+ newSelection = selectionPolicy.replaceInvalidSelection(selection, newSelection);
+ if (temp != newSelection) {
+ if (newSelection == null) {
+ newSelection = new StructuredSelection();
+ }
+ // call super.setSelection(...) to avoid asking the selection policy
+ // if the selection should be overridden
+ super.setSelection(newSelection, false);
+ return;
+ }
+ }
+ super.handleInvalidSelection(selection, newSelection);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ContentViewer#handleDispose(org.eclipse.swt.events.DisposeEvent)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelSelectionPolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelSelectionPolicy.java
index 951342465..53dd10ec2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelSelectionPolicy.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelSelectionPolicy.java
@@ -65,4 +65,23 @@ public interface IModelSelectionPolicy {
*/
public boolean isSticky(ISelection selection, IPresentationContext context);
+ /**
+ * Replaces an invalid selection.
+ * <p>
+ * This method is called if a model change picked up by a viewer
+ * results in an invalid selection. For instance if an element contained in
+ * the selection has been removed from the viewer, the selection policy associated
+ * with the invalid selection is free to specify a new selection. The default
+ * selection policy returns the <code>newSelection</code> as is (with missing
+ * elements removed). Model selection policies may implement a different strategy
+ * for picking a new selection when the old selection becomes invalid.
+ * </p>
+ *
+ * @param invalidSelection
+ * the selection before the viewer was updated
+ * @param newSelection
+ * the selection after the update, or <code>null</code> if none
+ * @return new selection or <code>null</code> if none
+ */
+ public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java
index b0fe1d1ad..8dc078a12 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java
@@ -103,4 +103,10 @@ public class DefaultSelectionPolicy implements IModelSelectionPolicy {
return false;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy#handleInvalidSelection(org.eclipse.jface.viewers.ISelection, org.eclipse.jface.viewers.ISelection)
+ */
+ public ISelection replaceInvalidSelection(ISelection selection, ISelection newSelection) {
+ return newSelection;
+ }
}

Back to the top