Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2010-06-24 12:39:52 -0400
committerDarin Wright2010-06-24 12:39:52 -0400
commita85476b026ebf5afda8bf26cafc3fac2548086a6 (patch)
treed72a89fd5575ef042c9fc9b6a5113c7e00d4045b
parent48d5818bd27a4b22f767d5870242d1011b5ef68a (diff)
downloadeclipse.platform.debug-a85476b026ebf5afda8bf26cafc3fac2548086a6.tar.gz
eclipse.platform.debug-a85476b026ebf5afda8bf26cafc3fac2548086a6.tar.xz
eclipse.platform.debug-a85476b026ebf5afda8bf26cafc3fac2548086a6.zip
[r3.6.1] Bug 317100 - Debug breadcrumb does not allow to switch threads
-rw-r--r--org.eclipse.debug.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java69
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java6
4 files changed, 86 insertions, 7 deletions
diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
index 052406d6e..f707a7142 100644
--- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.tests;singleton:=true
-Bundle-Version: 3.6.0.qualifier
+Bundle-Version: 3.6.1.qualifier
Bundle-Activator: org.eclipse.debug.tests.TestsPlugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java
index 9b072f7db..230c09c6f 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems and others.
+ * Copyright (c) 2009, 2010 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,8 @@ import junit.framework.TestCase;
import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -31,7 +33,7 @@ import org.eclipse.ui.PlatformUI;
/**
* Tests to verify that the viewer properly handles selection changes.
*/
-abstract public class SelectionTests extends TestCase {
+abstract public class SelectionTests extends TestCase implements ITestModelUpdatesListenerConstants {
Display fDisplay;
Shell fShell;
ITreeModelViewer fViewer;
@@ -114,6 +116,69 @@ abstract public class SelectionTests extends TestCase {
}
/**
+ * In this test verify that selection policy can prevent selection
+ * from being set and verify that a FORCE flag can override the selection
+ * policy.
+ */
+ public void testSelectionPolicy() {
+ // Create the model and populate the view.
+ final TestModel model = makeMultiLevelModel();
+
+ // Set the selection and verify it.
+ TreeSelection selection_3_3_3 = new TreeSelection(model.findElement("3.3.3"));
+ fViewer.setSelection(selection_3_3_3, true, false);
+ assertEquals(selection_3_3_3, fViewer.getSelection());
+
+ model.setSelectionPolicy(new IModelSelectionPolicy() {
+
+ public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
+ return null;
+ }
+
+ public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) {
+ return false;
+ }
+
+ public boolean isSticky(ISelection selection, IPresentationContext context) {
+ return true;
+ }
+
+ public boolean contains(ISelection selection, IPresentationContext context) {
+ return true;
+ }
+ });
+
+ // Attempt to change selection and verify that old selection is still valid.
+ TreeSelection selection_3_3_1 = new TreeSelection(model.findElement("3.3.1"));
+ fViewer.setSelection(selection_3_3_1, true, false);
+ assertEquals(selection_3_3_3, fViewer.getSelection());
+
+ // Now attempt to *force* selection and verify that new selection was set.
+ fViewer.setSelection(selection_3_3_1, true, true);
+ assertEquals(selection_3_3_1, fViewer.getSelection());
+
+ // Create the an update delta to attempt to change selection back to
+ // 3.3.3 and verify that selection did not get overriden.
+ TreePath path_3_3_3 = model.findElement("3.3.3");
+ ModelDelta baseDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ ModelDelta delta_3_3_3 = model.getElementDelta(baseDelta, path_3_3_3, false);
+ delta_3_3_3.setFlags(IModelDelta.SELECT);
+ fViewer.updateViewer(baseDelta);
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE))
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ assertEquals(selection_3_3_1, fViewer.getSelection());
+
+ // Add the *force* flag to the selection delta and update viewer again.
+ // Verify that selection did change.
+ delta_3_3_3.setFlags(IModelDelta.SELECT | IModelDelta.FORCE);
+ fViewer.updateViewer(baseDelta);
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE))
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ assertEquals(selection_3_3_3, fViewer.getSelection());
+ }
+
+
+ /**
* In this test:
* - set a seleciton to an element
* - then remove that element
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
index e172326eb..8a6aad223 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems and others.
+ * Copyright (c) 2009, 2010 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,6 +31,8 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory2;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
@@ -44,7 +46,7 @@ import org.eclipse.jface.viewers.Viewer;
*
* @since 3.6
*/
-public class TestModel implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory2 , IElementMementoProvider {
+public class TestModel implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory2 , IElementMementoProvider, IModelSelectionPolicyFactory {
public static class TestElement extends PlatformObject {
private final TestModel fModel;
@@ -155,6 +157,8 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
private Object fInput = null;
private TreePath fRootPath = TreePath.EMPTY;
private ModelProxy fModelProxy;
+ private IModelSelectionPolicy fModelSelectionPolicy;
+
/**
* Constructor private. Use static factory methods instead.
@@ -165,6 +169,14 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
return fRoot;
}
+ public void setSelectionPolicy(IModelSelectionPolicy modelSelectionPolicy) {
+ fModelSelectionPolicy = modelSelectionPolicy;
+ }
+
+ public IModelSelectionPolicy createModelSelectionPolicyAdapter(Object element, IPresentationContext context) {
+ return fModelSelectionPolicy;
+ }
+
public ModelDelta getBaseDelta(ModelDelta rootDelta) {
ModelDelta delta = rootDelta;
for (int i = 0; i < fRootPath.getSegmentCount(); i++) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
index fcde05bba..86eaba6fb 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
@@ -345,7 +345,9 @@ public class TreeModelContentProvider extends ModelContentProvider implements IT
ITreeModelContentProviderTarget treeViewer = getViewer();
// check if selection is allowed
IStructuredSelection candidate = new TreeSelection(getViewerTreePath(delta));
- if (!treeViewer.overrideSelection(treeViewer.getSelection(), candidate)) {
+ if ((delta.getFlags() & IModelDelta.FORCE) == 0 &&
+ !treeViewer.overrideSelection(treeViewer.getSelection(), candidate))
+ {
return;
}
// empty the selection before replacing elements to avoid materializing elements (@see bug 305739)
@@ -371,7 +373,7 @@ public class TreeModelContentProvider extends ModelContentProvider implements IT
}
}
TreePath selectionPath = getViewerTreePath(delta);
- if (treeViewer.trySelection(new TreeSelection(selectionPath), false, true)) {
+ if (treeViewer.trySelection(new TreeSelection(selectionPath), false, (delta.getFlags() | IModelDelta.FORCE) == 0)) {
cancelRestore(selectionPath, IModelDelta.SELECT);
}
}

Back to the top