Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2008-07-30 12:21:17 -0400
committerDarin Wright2008-07-30 12:21:17 -0400
commit38986f03034efc24431d9c567ba7ae8868becfea (patch)
tree98f97d5ea833fcf0c7db41fc5e779563e5ac3a46 /org.eclipse.debug.ui
parent1855d4a026ac352af2b703df28b9476ba10eb089 (diff)
downloadeclipse.platform.debug-38986f03034efc24431d9c567ba7ae8868becfea.tar.gz
eclipse.platform.debug-38986f03034efc24431d9c567ba7ae8868becfea.tar.xz
eclipse.platform.debug-38986f03034efc24431d9c567ba7ae8868becfea.zip
[r341] Bug 233297 - TreeModelContentProvider appears to throw an AIOOB
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java70
2 files changed, 61 insertions, 11 deletions
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
index 136787bfe..cbd930f6a 100644
--- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.ui; singleton:=true
-Bundle-Version: 3.4.0.qualifier
+Bundle-Version: 3.4.1.qualifier
Bundle-Activator: org.eclipse.debug.internal.ui.DebugUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
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 706d67298..e54077f5f 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
@@ -151,16 +151,23 @@ public class TreeModelContentProvider extends ModelContentProvider implements IL
TreeViewer treeViewer = getTreeViewer();
TreePath elementPath = getViewerTreePath(delta);
if (modelIndex >= 0) {
- int viewIndex = modelToViewIndex(getViewerTreePath(delta.getParentDelta()), modelIndex);
+ TreePath parentPath = elementPath.getParentPath();
+ if (parentPath == null) {
+ parentPath = TreePath.EMPTY;
+ }
+ int viewIndex = modelToViewIndex(parentPath, modelIndex);
if (viewIndex >= 0) {
if (DEBUG_CONTENT_PROVIDER) {
System.out.println("[expand] replace(" + delta.getParentDelta().getElement() + ", (model) " + modelIndex + " (view) " + viewIndex + ", " + delta.getElement()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- TreePath parentPath = elementPath.getParentPath();
- if (parentPath == null) {
- parentPath = TreePath.EMPTY;
- }
treeViewer.replace(parentPath, viewIndex, delta.getElement());
+ } else {
+ // Element is filtered - if no longer filtered, insert the element
+ viewIndex = unfilterElement(parentPath, delta.getElement(), modelIndex);
+ if (viewIndex < 0) {
+ // insert did not complete
+ return;
+ }
}
}
if (childCount > 0) {
@@ -174,6 +181,40 @@ public class TreeModelContentProvider extends ModelContentProvider implements IL
}
}
}
+
+ /**
+ * Inserts the given child element of the specified parent into the tree if the element
+ * should *no* longer be filtered. Returns the view index of the newly inserted element
+ * or -1 if not inserted.
+ *
+ * @param parentPath viewer tree path to parent element
+ * @param element element to insert
+ * @param modelIndex index of the element in the model
+ * @return
+ */
+ protected int unfilterElement(TreePath parentPath, Object element, int modelIndex) {
+ // Element is filtered - if no longer filtered, insert the element
+ if (shouldFilter(parentPath, element)) {
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("[unfilter] abort unfilter element: " + element + ", (model) " + modelIndex); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // still filtered, stop
+ return -1;
+ }
+ // clear the filter an insert the element
+ clearFilteredChild(parentPath, modelIndex);
+ int viewIndex = modelToViewIndex(parentPath, modelIndex);
+ if (viewIndex >= 0) {
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("[unfilter] insert(" + parentPath.getLastSegment() + ", (model) " + modelIndex + " (view) " + viewIndex + ", " + element); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ getTreeViewer().insert(parentPath, element, viewIndex);
+ return viewIndex;
+ } else {
+ // still filtered - should not happen
+ return -1;
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.ModelContentProvider#handleInsert(org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta)
@@ -325,15 +366,24 @@ public class TreeModelContentProvider extends ModelContentProvider implements IL
InternalTreeModelViewer treeViewer = (InternalTreeModelViewer) getTreeViewer();
TreePath elementPath = getViewerTreePath(delta);
if (modelIndex >= 0) {
- int viewIndex = modelToViewIndex(getViewerTreePath(delta.getParentDelta()), modelIndex);
- if (DEBUG_CONTENT_PROVIDER) {
- System.out.println("[reveal] replace(" + delta.getParentDelta().getElement() + ", (model) " + modelIndex + " (view) " + viewIndex + ", " + delta.getElement()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
TreePath parentPath = elementPath.getParentPath();
if (parentPath == null) {
parentPath = TreePath.EMPTY;
}
- treeViewer.replace(parentPath, viewIndex, delta.getElement());
+ int viewIndex = modelToViewIndex(parentPath, modelIndex);
+ if (viewIndex >= 0) {
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("[reveal] replace(" + delta.getParentDelta().getElement() + ", (model) " + modelIndex + " (view) " + viewIndex + ", " + delta.getElement()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ treeViewer.replace(parentPath, viewIndex, delta.getElement());
+ } else {
+ // Element is filtered - insert if filter state changed
+ viewIndex = unfilterElement(parentPath, delta.getElement(), modelIndex);
+ if (viewIndex < 0) {
+ // insert did not complete
+ return;
+ }
+ }
// only move tree based on selection policy
if (treeViewer.overrideSelection(treeViewer.getSelection(), new TreeSelection(elementPath))) {
Widget item = treeViewer.findItem(elementPath);

Back to the top