Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2009-11-03 22:55:19 +0000
committerPawel Piech2009-11-03 22:55:19 +0000
commitdb03260337a0c8fe44d7c115ab8c6e2496078fe1 (patch)
treebe084ccff8244dab33c72a7dd5ebed0ba2b5aa8e
parenta4ada607ce454d849b04403d6b6f3235da1d740e (diff)
downloadeclipse.platform.debug-db03260337a0c8fe44d7c115ab8c6e2496078fe1.tar.gz
eclipse.platform.debug-db03260337a0c8fe44d7c115ab8c6e2496078fe1.tar.xz
eclipse.platform.debug-db03260337a0c8fe44d7c115ab8c6e2496078fe1.zip
Bug 293844 - Problematic order of handling of INSERTED/ADDED/REMOVED and other non model changing flags
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java100
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java44
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java34
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelContentProvider.java57
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java69
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java12
8 files changed, 256 insertions, 73 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
index 79fb7a56a..ec382c721 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
@@ -133,7 +133,7 @@ abstract public class DeltaTests extends TestCase {
model.validateData(fViewer, TreePath.EMPTY);
}
- public void testInsertElement() {
+ public void testInsert() {
//TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
TestModel model = TestModel.simpleSingleLevel();
@@ -144,6 +144,7 @@ abstract public class DeltaTests extends TestCase {
// Set the input into the view and update the view.
fViewer.setInput(model.getRootElement());
+
while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
@@ -166,7 +167,104 @@ abstract public class DeltaTests extends TestCase {
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
}
+
+ /**
+ * This test checks that insert and select delta flags are processed in correct order:
+ * insert then select.
+ */
+ public void testInsertAndSelect() {
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
+
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
+
+ while (!fListener.isFinished())
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep();
+
+ model.validateData(fViewer, TreePath.EMPTY);
+
+ // Update the model
+ // Insert two new elements at once
+ TestElement element0 = new TestElement(model, "00", new TestElement[] {});
+ TestElement element1 = new TestElement(model, "01", new TestElement[] {});
+ TreePath elementPath0 = new TreePath(new Object[] { element0 });
+ TreePath elementPath1 = new TreePath(new Object[] { element1 });
+ ModelDelta rootDelta = model.insertElementChild(TreePath.EMPTY, 0, element0);
+ rootDelta = model.insertElementChild(rootDelta, TreePath.EMPTY, 1, element1);
+
+ // Set the select flag on the first added node.
+ ModelDelta delta0 = rootDelta.getChildDelta(element0);
+ delta0.setFlags(delta0.getFlags() | IModelDelta.SELECT);
+ fListener.reset();
+ fListener.addHasChildrenUpdate(elementPath0);
+ fListener.addHasChildrenUpdate(elementPath1);
+ fListener.addLabelUpdate(elementPath0);
+ fListener.addLabelUpdate(elementPath1);
+
+ // TODO: list full set of expected updates.
+ fListener.setFailOnRedundantUpdates(false);
+
+ model.postDelta(rootDelta);
+ while (!fListener.isFinished())
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+
+ /**
+ * This test checks that insert and remove deltas are processed in correct order:
+ * remove deltas are processed first then insert deltas.
+ */
+ public void testInsertAndRemove() {
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ fViewer.setInput(model.getRootElement());
+
+ while (!fListener.isFinished())
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep();
+
+ model.validateData(fViewer, TreePath.EMPTY);
+
+ // Update the model
+ // Remove one element then insert a new one
+ IModelDelta removeDelta = model.removeElementChild(TreePath.EMPTY, 3).getChildDeltas()[0];
+
+ // Insert new elements at once
+ TestElement element = new TestElement(model, "00", new TestElement[] {});
+ TreePath elementPath = new TreePath(new Object[] { element });
+ IModelDelta insertDelta = model.insertElementChild(TreePath.EMPTY, 1, element).getChildDeltas()[0];
+
+ // Create a combined delta where the insert child delta is first and the remove child delta is second.
+ ModelDelta combinedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE, 0, model.getRootElement().getChildren().length);
+ combinedDelta.addNode(insertDelta.getElement(), insertDelta.getIndex(), insertDelta.getFlags(), insertDelta.getChildCount());
+ combinedDelta.addNode(removeDelta.getElement(), removeDelta.getIndex(), removeDelta.getFlags(), removeDelta.getChildCount());
+
+ // Set the select flag on the first added node.
+ fListener.reset();
+ fListener.addHasChildrenUpdate(elementPath);
+ fListener.addLabelUpdate(elementPath);
+
+ // TODO: list full set of expected updates.
+ fListener.setFailOnRedundantUpdates(false);
+
+ model.postDelta(combinedDelta);
+ while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+
+
public void testAddElement() {
//TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
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 201650697..11f7f983a 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
@@ -161,7 +161,11 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
ModelDelta getBaseDelta(ModelDelta rootDelta) {
ModelDelta delta = rootDelta;
for (int i = 0; i < fRootPath.getSegmentCount(); i++) {
- delta = delta.addNode(fRootPath.getSegment(i), IModelDelta.NO_CHANGE);
+ ModelDelta subDelta = delta.getChildDelta(fRootPath.getSegment(i));
+ if (subDelta == null) {
+ subDelta = delta.addNode(fRootPath.getSegment(i), IModelDelta.NO_CHANGE);
+ }
+ delta = subDelta;
}
return delta;
}
@@ -294,7 +298,10 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
fModelProxy.fireModelChanged(delta);
}
- private ModelDelta getElementDelta(ModelDelta baseDelta, TreePath path) {
+ /** Create or retrieve delta for given path
+ * @param combine if then new deltas for the given path are created. If false existing ones are reused.
+ */
+ private ModelDelta getElementDelta(ModelDelta baseDelta, TreePath path, boolean combine) {
TestElement element = getRootElement();
ModelDelta delta = baseDelta;
@@ -306,7 +313,14 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
for (j = 0; j < children.length; j++) {
if (segment.equals(children[j])) {
element = children[j];
- delta = delta.addNode(element, j, IModelDelta.NO_CHANGE);
+ ModelDelta nextDelta = null;
+ if (combine) {
+ nextDelta = delta.getChildDelta(element);
+ }
+ if (nextDelta == null) {
+ nextDelta = delta.addNode(element, j, IModelDelta.NO_CHANGE);
+ }
+ delta = nextDelta;
break;
}
}
@@ -332,7 +346,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path);
TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath);
+ ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
element.setLabelAppendix(labelAppendix);
delta.setFlags(delta.getFlags() | IModelDelta.STATE);
@@ -345,7 +359,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path);
TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath);
+ ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
element.setChecked(checked, grayed);
delta.setFlags(delta.getFlags() | IModelDelta.STATE);
@@ -360,7 +374,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
// Find the parent element and generate the delta node for it.
TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath);
+ ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
// Set the new children array
element.fChildren = children;
@@ -378,7 +392,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
TreePath relativePath = getRelativePath(parentPath);
TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath);
+ ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
TestElement oldChild = element.fChildren[index];
element.fChildren[index] = child;
delta.addNode(oldChild, child, IModelDelta.REPLACED);
@@ -394,7 +408,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
// Find the parent element and generate the delta node for it.
TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath);
+ ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
// Add the new element
element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
@@ -407,13 +421,19 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
}
public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement newChild) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ return insertElementChild(null, parentPath, index, newChild);
+ }
+
+ public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, int index, TestElement newChild) {
+ if (rootDelta == null) {
+ rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ }
ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(parentPath);
// Find the parent element and generate the delta node for it.
TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath);
+ ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
// Add the new element
element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
@@ -424,7 +444,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
return rootDelta;
}
-
+
private TestElement[] doInsertElementInArray(TestElement[] children, int index, TestElement newChild) {
// Create the new children array add the element to it and set it to
// the parent.
@@ -441,7 +461,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
// Find the parent element and generate the delta node for it.
TestElement element = getElement(parentPath);
- ModelDelta delta= getElementDelta(baseDelta, parentPath);
+ ModelDelta delta= getElementDelta(baseDelta, parentPath, false);
// Create a new child array with the element removed
TestElement[] children = element.getChildren();
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
index e6e2ecf8d..928c7fa32 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
@@ -40,14 +40,17 @@ public class TestModelUpdatesListener implements IViewerUpdateListener, ILabelUp
public static final int CHILDREN_COUNT_UPDATES = 0X0010;
public static final int CHILDREN_UPDATES = 0X0020;
public static final int MODEL_CHANGED_COMPLETE = 0X0040;
- public static final int MODEL_PROXIES_INSTALLED = 0X0080;
+ public static final int MODEL_PROXIES_INSTALLED = 0X0080;
+
+ public static final int VIEWER_UPDATES_RUNNING = 0X0100;
+ public static final int LABEL_UPDATES_RUNNING = 0X0200;
public static final int LABEL_COMPLETE = LABEL_UPDATES_COMPLETE | LABEL_UPDATES;
public static final int CONTENT_COMPLETE =
CONTENT_UPDATES_COMPLETE | HAS_CHILDREN_UPDATES | CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES;
- public static final int ALL_UPDATES_COMPLETE = LABEL_COMPLETE | CONTENT_COMPLETE | MODEL_PROXIES_INSTALLED;
+ public static final int ALL_UPDATES_COMPLETE = LABEL_COMPLETE | CONTENT_COMPLETE | MODEL_PROXIES_INSTALLED | LABEL_UPDATES_RUNNING | VIEWER_UPDATES_RUNNING;
private boolean fFailOnRedundantUpdates;
private boolean fFailOnMultipleUpdateSequences;
@@ -60,6 +63,8 @@ public class TestModelUpdatesListener implements IViewerUpdateListener, ILabelUp
private boolean fViewerUpdatesComplete;
private boolean fLabelUpdatesComplete;
private boolean fModelChangedComplete;
+ private int fViewerUpdatesRunning;
+ private int fLabelUpdatesRunning;
public TestModelUpdatesListener(boolean failOnRedundantUpdates, boolean failOnMultipleUpdateSequences) {
setFailOnRedundantUpdates(failOnRedundantUpdates);
@@ -202,15 +207,32 @@ public class TestModelUpdatesListener implements IViewerUpdateListener, ILabelUp
if ( (flags & MODEL_PROXIES_INSTALLED) != 0) {
if (fProxyModels.size() != 0) return false;
}
+ if ( (flags & VIEWER_UPDATES_RUNNING) != 0) {
+ if (fViewerUpdatesRunning != 0) {
+ return false;
+ }
+ }
+ if ( (flags & LABEL_UPDATES_RUNNING) != 0) {
+ if (fLabelUpdatesRunning != 0) {
+ return false;
+ }
+ }
return true;
}
public void updateStarted(IViewerUpdate update) {
+ synchronized (this) {
+ fViewerUpdatesRunning++;
+ }
System.out.println("started: " + update);
-
}
public void updateComplete(IViewerUpdate update) {
+ System.out.println("completed: " + update);
+ synchronized (this) {
+ fViewerUpdatesRunning--;
+ }
+
if (!update.isCanceled()) {
if (update instanceof IHasChildrenUpdate) {
if (!fHasChildrenUpdates.remove(update.getElementPath()) && fFailOnRedundantUpdates) {
@@ -251,12 +273,18 @@ public class TestModelUpdatesListener implements IViewerUpdateListener, ILabelUp
}
public void labelUpdateComplete(ILabelUpdate update) {
+ synchronized (this) {
+ fLabelUpdatesRunning--;
+ }
if (!fLabelUpdates.remove(update.getElementPath()) && fFailOnRedundantUpdates) {
Assert.fail("Redundant update: " + update);
}
}
public void labelUpdateStarted(ILabelUpdate update) {
+ synchronized (this) {
+ fLabelUpdatesRunning++;
+ }
System.out.println("started: " + update);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelContentProvider.java
index 6d0992ad7..4801352a5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelContentProvider.java
@@ -24,6 +24,34 @@ import org.eclipse.jface.viewers.TreePath;
public interface ITreeModelContentProvider extends ILazyTreePathContentProvider {
/**
+ * Bit-mask which allows all possible model delta flags.
+ *
+ * @since 3.6
+ * @see #setModelDeltaMask(int)
+ */
+ public static final int ALL_MODEL_DELTA_FLAGS = ~0;
+
+ /**
+ * Bit-mask which allows only flags which control selection and expansion.
+ *
+ * @since 3.6
+ * @see #setModelDeltaMask(int)
+ */
+ public static final int CONTROL_MODEL_DELTA_FLAGS =
+ IModelDelta.EXPAND | IModelDelta.COLLAPSE | IModelDelta.SELECT | IModelDelta.REVEAL | IModelDelta.FORCE;
+
+ /**
+ * Bit-mask which allows only flags which update viewer's information
+ * about the model.
+ *
+ * @since 3.6
+ * @see #setModelDeltaMask(int)
+ */
+ public static final int UPDATE_MODEL_DELTA_FLAGS =
+ IModelDelta.ADDED | IModelDelta.CONTENT | IModelDelta.INSERTED | IModelDelta.INSTALL | IModelDelta.REMOVED |
+ IModelDelta.REPLACED | IModelDelta.STATE | IModelDelta.UNINSTALL;
+
+ /**
* Translates and returns the given child index from the viewer coordinate
* space to the model coordinate space.
*
@@ -72,20 +100,25 @@ public interface ITreeModelContentProvider extends ILazyTreePathContentProvider
public void unmapPath(TreePath path);
/**
- * Turns on the mode which causes the model viewer to ignore SELECT,
- * EXPAND, and COLLAPSE flags of {@link IModelDelta}.
+ * Sets the bit mask which will be used to filter the {@link IModelDelta}
+ * coming from the model. Any delta flags which are hidden by the mask
+ * will be ignored.
*
- * @param suppress If <code>true</code> it turns on the suppress mode.
+ * @param the bit mask for <code>IModelDelta</code> flags
+ *
+ * @since 3.6
*/
- public void setSuppressModelControlDeltas(boolean suppress);
+ public void setModelDeltaMask(int mask);
/**
- * Returns true if the viewer is currently in the mode to ignore SELECT,
- * REVEAL, EXPAND, and COLLAPSE flags of {@link IModelDelta}.
- *
- * @return Returns <code>true</code> if in suppress mode.
+ * Returns the current model delta mask.
+ *
+ * @return bit mask used to filter model delta events.
+ *
+ * @see #setModelDeltaMask(int)
+ * @since 3.6
*/
- public boolean isSuppressModelControlDeltas();
+ public int getModelDeltaMask();
/**
* Translates and returns the given child count from the model coordinate
@@ -125,6 +158,10 @@ public interface ITreeModelContentProvider extends ILazyTreePathContentProvider
* , etc.)
*
* @param delta The model delta to process.
+ * @param mask Mask that can be used to suppress processing of some of the
+ * delta flags
+ *
+ * @since 3.6
*/
- public void updateModel(IModelDelta delta);
+ public void updateModel(IModelDelta delta, int mask);
}
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 c34867139..dd1e8e894 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
@@ -1019,7 +1019,8 @@ public class InternalTreeModelViewer extends TreeViewer
fIsPopup = (style & SWT.POP_UP) != 0;
if (fIsPopup) {
- ((ITreeModelContentProvider)getContentProvider()).setSuppressModelControlDeltas(true);
+ ((ITreeModelContentProvider)getContentProvider()).setModelDeltaMask(
+ ~ITreeModelContentProvider.ALL_MODEL_DELTA_FLAGS & ~ITreeModelContentProvider.CONTROL_MODEL_DELTA_FLAGS);
}
if ((style & SWT.CHECK) != 0) {
context.setProperty(ICheckUpdate.PROP_CHECK, Boolean.TRUE);
@@ -2255,7 +2256,7 @@ public class InternalTreeModelViewer extends TreeViewer
}
public void updateViewer(IModelDelta delta) {
- ((ITreeModelContentProvider)getContentProvider()).updateModel(delta);
+ ((ITreeModelContentProvider)getContentProvider()).updateModel(delta, ITreeModelContentProvider.ALL_MODEL_DELTA_FLAGS);
}
/*
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java
index 222aba56a..2b42fb480 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java
@@ -180,7 +180,8 @@ public class InternalVirtualTreeModelViewer extends Viewer
fLabelProvider = new TreeModelLabelProvider(this);
if ((style & SWT.POP_UP) != 0) {
- ((ITreeModelContentProvider)getContentProvider()).setSuppressModelControlDeltas(true);
+ ((ITreeModelContentProvider)getContentProvider()).setModelDeltaMask(
+ ~ITreeModelContentProvider.ALL_MODEL_DELTA_FLAGS | ITreeModelContentProvider.CONTROL_MODEL_DELTA_FLAGS);
}
}
@@ -261,7 +262,8 @@ public class InternalVirtualTreeModelViewer extends Viewer
if (parentItem != null) {
VirtualItem item = parentItem.addItem(position);
item.setData(element);
-
+ mapElement(element, item);
+ doUpdate(item);
}
} else {
// TODO: Implement insert() for element
@@ -1294,7 +1296,7 @@ public class InternalVirtualTreeModelViewer extends Viewer
}
public void updateViewer(IModelDelta delta) {
- ((ModelContentProvider)getContentProvider()).updateNodes(new IModelDelta[] { delta }, true);
+ ((ITreeModelContentProvider)getContentProvider()).updateModel(delta, ITreeModelContentProvider.ALL_MODEL_DELTA_FLAGS);
}
public ViewerLabel getElementLabel(TreePath path, String columnId) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
index ff8e90bbd..647523d10 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
@@ -68,11 +68,10 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
private ITreeModelContentProviderTarget fViewer;
- /**
- * Flag indicating whether the viewer should ignore SELECT, REVEAL,
- * EXPAND, and COLLAPSE flags of {@link IModelDelta} coming from the model.
- */
- private boolean fSuppressModelControlRequests = false;
+ /**
+ * Mask used to filter delta updates coming from the model.
+ */
+ private int fModelDeltaMask = ~0;
/**
* Map tree paths to model proxy responsible for element
@@ -910,7 +909,7 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
DebugUIPlugin.debug("RECEIVED DELTA: " + delta.toString()); //$NON-NLS-1$
}
- updateNodes(new IModelDelta[] { delta }, false);
+ updateModel(delta, getModelDeltaMask());
// Call model listeners after updating the viewer model.
Object[] listeners = fModelListeners.getListeners();
@@ -927,27 +926,27 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
}
/**
- * Turns on the mode which causes the model viewer to ignore SELECT,
- * EXPAND, and COLLAPSE flags of {@link IModelDelta}.
- *
- * @param suppress If <code>true</code> it turns on the suppress mode.
+ * @see ITreeModelContentProvider#setModelDeltaMask(int)
*/
- public void setSuppressModelControlDeltas(boolean suppress) {
- fSuppressModelControlRequests = suppress;
+ public void setModelDeltaMask(int mask) {
+ fModelDeltaMask = mask;
}
/**
- * Returns true if the viewer is currently in the mode to ignore SELECT,
- * REVEAL, EXPAND, and COLLAPSE flags of {@link IModelDelta}.
- *
- * @return Returns <code>true</code> if in suppress mode.
+ * @see ITreeModelContentProvider#getModelDeltaMask()
*/
- public boolean isSuppressModelControlDeltas() {
- return fSuppressModelControlRequests;
+ public int getModelDeltaMask() {
+ return fModelDeltaMask;
}
- public void updateModel(IModelDelta delta) {
- updateNodes(new IModelDelta[] { delta }, true);
+ public void updateModel(IModelDelta delta, int mask) {
+ IModelDelta[] deltaArray = new IModelDelta[] { delta };
+ updateNodes(deltaArray,
+ mask & (IModelDelta.REMOVED | IModelDelta.UNINSTALL));
+ updateNodes(deltaArray,
+ mask & ITreeModelContentProvider.UPDATE_MODEL_DELTA_FLAGS & ~(IModelDelta.REMOVED | IModelDelta.UNINSTALL));
+ updateNodes(deltaArray,
+ mask & ITreeModelContentProvider.CONTROL_MODEL_DELTA_FLAGS);
}
/**
@@ -958,10 +957,10 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
* processing of SELECT, REVEAL, EXPAND, COLLAPSE flags of
* {@link IModelDelta}.
*/
- protected void updateNodes(IModelDelta[] nodes, boolean override) {
+ protected void updateNodes(IModelDelta[] nodes, int mask) {
for (int i = 0; i < nodes.length; i++) {
IModelDelta node = nodes[i];
- int flags = node.getFlags();
+ int flags = node.getFlags() & mask;
if ((flags & IModelDelta.ADDED) != 0) {
handleAdd(node);
@@ -987,21 +986,19 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
if ((flags & IModelDelta.UNINSTALL) != 0) {
handleUninstall(node);
}
- if (!fSuppressModelControlRequests || override) {
- if ((flags & IModelDelta.EXPAND) != 0) {
- handleExpand(node);
- }
- if ((flags & IModelDelta.COLLAPSE) != 0) {
- handleCollapse(node);
- }
- if ((flags & IModelDelta.SELECT) != 0) {
- handleSelect(node);
- }
- if ((flags & IModelDelta.REVEAL) != 0) {
- handleReveal(node);
- }
+ if ((flags & IModelDelta.EXPAND) != 0) {
+ handleExpand(node);
+ }
+ if ((flags & IModelDelta.COLLAPSE) != 0) {
+ handleCollapse(node);
+ }
+ if ((flags & IModelDelta.SELECT) != 0) {
+ handleSelect(node);
+ }
+ if ((flags & IModelDelta.REVEAL) != 0) {
+ handleReveal(node);
}
- updateNodes(node.getChildDeltas(), override);
+ updateNodes(node.getChildDeltas(), mask);
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java
index 0bd532dcb..7156008c4 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java
@@ -363,8 +363,8 @@ public class SubTreeModelViewer extends TreeModelViewer {
fBaseProvider.addViewerUpdateListener(listener);
}
- public boolean isSuppressModelControlDeltas() {
- return fBaseProvider.isSuppressModelControlDeltas();
+ public int getModelDeltaMask() {
+ return fBaseProvider.getModelDeltaMask();
}
public int modelToViewChildCount(TreePath parentPath, int count) {
@@ -383,8 +383,8 @@ public class SubTreeModelViewer extends TreeModelViewer {
fBaseProvider.removeViewerUpdateListener(listener);
}
- public void setSuppressModelControlDeltas(boolean suppress) {
- fBaseProvider.setSuppressModelControlDeltas(suppress);
+ public void setModelDeltaMask(int mask) {
+ fBaseProvider.setModelDeltaMask(mask);
}
public boolean shouldFilter(Object parentElementOrTreePath, Object element) {
@@ -401,8 +401,8 @@ public class SubTreeModelViewer extends TreeModelViewer {
fBaseProvider.unmapPath(createFullPath(path));
}
- public void updateModel(IModelDelta delta) {
- fBaseProvider.updateModel(delta);
+ public void updateModel(IModelDelta delta, int mask) {
+ fBaseProvider.updateModel(delta, mask);
}
public TreePath[] getParents(Object element) {

Back to the top