Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2006-10-24 03:08:38 +0000
committerDarin Wright2006-10-24 03:08:38 +0000
commit13e65338eac56e0ecfcea3d99fd1d8119f231e08 (patch)
treeb1370cf1901014dc62ae37a7b8abc86abf2cea55
parent8dad58d27bc54534a9daac2bb10797cbc34922c7 (diff)
downloadeclipse.platform.debug-13e65338eac56e0ecfcea3d99fd1d8119f231e08.tar.gz
eclipse.platform.debug-13e65338eac56e0ecfcea3d99fd1d8119f231e08.tar.xz
eclipse.platform.debug-13e65338eac56e0ecfcea3d99fd1d8119f231e08.zip
Bug 156883 - [Viewers] enhancements to ILazyTreeContentProvider
-rw-r--r--org.eclipse.debug.ui/.options1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugTargetContentProvider.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java107
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchContentProvider.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ThreadContentProvider.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenCountUpdate.java71
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java48
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/HasChildrenUpdate.java121
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java75
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java9
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java178
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java14
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenCountUpdate.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenUpdate.java9
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementContentProvider.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IHasChildrenUpdate.java37
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewerUpdate.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java15
24 files changed, 631 insertions, 269 deletions
diff --git a/org.eclipse.debug.ui/.options b/org.eclipse.debug.ui/.options
index 5c01ca7a5..225871223 100644
--- a/org.eclipse.debug.ui/.options
+++ b/org.eclipse.debug.ui/.options
@@ -2,4 +2,5 @@ org.eclipse.debug.ui/debug = false
org.eclipse.debug.ui/debug/viewers/model = false
org.eclipse.debug.ui/debug/viewers/viewer = false
org.eclipse.debug.ui/debug/viewers/deltas = false
+org.eclipse.debug.ui/debug/viewers/contentProvider = false
org.eclipse.debug.ui/debug/commands = false
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugTargetContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugTargetContentProvider.java
index 1ae6c63de..b077874e7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugTargetContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugTargetContentProvider.java
@@ -42,4 +42,9 @@ public class DebugTargetContentProvider extends ElementContentProvider {
return getElements(((IDebugTarget)parent).getThreads(), index, length);
}
+ protected boolean hasChildren(Object element, IPresentationContext context, IProgressMonitor monitor) throws CoreException {
+ return ((IDebugTarget)element).hasThreads();
+ }
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java
index 4497a315a..3ebaedbba 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java
@@ -18,7 +18,9 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.viewers.TreePath;
/**
* @since 3.3
@@ -31,11 +33,12 @@ public abstract class ElementContentProvider implements IElementContentProvider
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider#updateChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IElementRequestMonitor)
*/
public void update(final IChildrenUpdate update) {
- Job job = new Job("Retrieving Children") { //$NON-NLS-1$
+ Job job = new Job("children update") { //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) {
- if (!monitor.isCanceled()) {
+ if (!update.isCanceled()) {
retrieveChildren(update);
}
+ update.done();
return Status.OK_STATUS;
}
};
@@ -48,11 +51,12 @@ public abstract class ElementContentProvider implements IElementContentProvider
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate)
*/
public void update(final IChildrenCountUpdate update) {
- Job job = new Job("Computing hasChildren") { //$NON-NLS-1$
+ Job job = new Job("child count update") { //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) {
- if (!monitor.isCanceled()) {
+ if (!update.isCanceled()) {
retrieveChildCount(update);
}
+ update.done();
return Status.OK_STATUS;
}
};
@@ -73,10 +77,15 @@ public abstract class ElementContentProvider implements IElementContentProvider
IPresentationContext context = update.getPresentationContext();
if (supportsContext(context)) {
int offset = update.getOffset();
- Object[] children = getChildren(update.getParent(), offset, update.getLength(), context, update);
- if (!update.isCanceled() && children != null) {
- for (int i = 0; i < children.length; i++) {
- update.setChild(children[i], offset + i);
+ Object parent = update.getElement(update.getParent());
+ if (parent == null) {
+ update.setCanceled(true);
+ } else {
+ Object[] children = getChildren(parent, offset, update.getLength(), context, update);
+ if (!update.isCanceled() && children != null) {
+ for (int i = 0; i < children.length; i++) {
+ update.setChild(children[i], offset + i);
+ }
}
}
}
@@ -84,7 +93,6 @@ public abstract class ElementContentProvider implements IElementContentProvider
status = e.getStatus();
}
update.setStatus(status);
- update.done();
}
}
@@ -100,26 +108,31 @@ public abstract class ElementContentProvider implements IElementContentProvider
IStatus status = Status.OK_STATUS;
try {
IPresentationContext context = update.getPresentationContext();
- Object[] parents = update.getParents();
+ TreePath[] parents = update.getParents();
if (supportsContext(context)) {
for (int i = 0; i < parents.length; i++) {
- Object parent = parents[i];
+ Object parent = update.getElement(parents[i]);
+ if (parent == null) {
+ // viewer input changed to null
+ update.setCanceled(true);
+ break;
+ }
int childCount = getChildCount(parent, context, update);
- if (!update.isCanceled()) {
- update.setChildCount(parent, childCount);
+ if (update.isCanceled()) {
+ break;
+ } else {
+ update.setChildCount(parents[i], childCount);
}
}
} else {
for (int i = 0; i < parents.length; i++) {
- Object parent = parents[i];
- update.setChildCount(parent, 0);
+ update.setChildCount(parents[i], 0);
}
}
} catch (CoreException e) {
status = e.getStatus();
}
update.setStatus(status);
- update.done();
}
}
@@ -183,4 +196,66 @@ public abstract class ElementContentProvider implements IElementContentProvider
}
return null;
}
+
+ public void update(final IHasChildrenUpdate update) {
+ Job job = new Job("has children update") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ updateHasChildren(update);
+ }
+ update.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ // TODO: rule
+ job.schedule();
+ }
+
+ /**
+ * Updates whether the given elements have children.
+ *
+ * @param update specifies element and progress monitor
+ */
+ protected void updateHasChildren(IHasChildrenUpdate update) {
+ if (!update.isCanceled()) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ IPresentationContext context = update.getPresentationContext();
+ TreePath[] elements = update.getElements();
+ if (supportsContext(context)) {
+ for (int i = 0; i < elements.length; i++) {
+ Object element = update.getElement(elements[i]);
+ boolean hasChildren = hasChildren(element, context, update);
+ if (!update.isCanceled()) {
+ update.setHasChilren(elements[i], hasChildren);
+ }
+ }
+ } else {
+ for (int i = 0; i < elements.length; i++) {
+ update.setHasChilren(elements[i], false);
+ }
+ }
+ } catch (CoreException e) {
+ status = e.getStatus();
+ }
+ update.setStatus(status);
+ update.done();
+ }
+
+ }
+
+ /**
+ * Returns whether the given element has children in the specified context.
+ * Subclasses can override to be more efficient.
+ *
+ * @param element
+ * @param context
+ * @param monitor
+ * @return
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context, IProgressMonitor monitor) throws CoreException {
+ return getChildCount(element, context, monitor) > 0;
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchContentProvider.java
index 2e00a6679..b6bcbeedd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchContentProvider.java
@@ -42,4 +42,9 @@ public class LaunchContentProvider extends ElementContentProvider {
return getElements(((ILaunch)parent).getChildren(), index, length);
}
+ protected boolean hasChildren(Object element, IPresentationContext context, IProgressMonitor monitor) throws CoreException {
+ return ((ILaunch)element).hasChildren();
+ }
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java
index 5b33632ad..c66035ac9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java
@@ -53,4 +53,17 @@ public class StackFrameContentProvider extends ElementContentProvider {
return id.equals(IDebugUIConstants.ID_VARIABLE_VIEW) || id.equals(IDebugUIConstants.ID_REGISTER_VIEW);
}
+ protected boolean hasChildren(Object element, IPresentationContext context, IProgressMonitor monitor) throws CoreException {
+ String id = context.getId();
+ IStackFrame frame = (IStackFrame) element;
+ if (id.equals(IDebugUIConstants.ID_VARIABLE_VIEW)) {
+ return frame.hasVariables();
+ } else if (id.equals(IDebugUIConstants.ID_REGISTER_VIEW)) {
+ return frame.hasRegisterGroups();
+ }
+ return false;
+ }
+
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ThreadContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ThreadContentProvider.java
index 31456dc58..facff78be 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ThreadContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ThreadContentProvider.java
@@ -42,4 +42,8 @@ public class ThreadContentProvider extends ElementContentProvider {
return getElements(((IThread)parent).getStackFrames(), index, length);
}
+ protected boolean hasChildren(Object element, IPresentationContext context, IProgressMonitor monitor) throws CoreException {
+ return ((IThread)element).hasStackFrames();
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java
index 6fadbe3d1..3518a4243 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java
@@ -206,5 +206,11 @@ public class VariableContentProvider extends ElementContentProvider {
}
}
return value;
- }
+ }
+
+ protected boolean hasChildren(Object element, IPresentationContext context, IProgressMonitor monitor) throws CoreException {
+ return ((IVariable)element).getValue().hasVariables();
+ }
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenCountUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenCountUpdate.java
index ce5f7d2a3..e147153ec 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenCountUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenCountUpdate.java
@@ -27,17 +27,25 @@ import org.eclipse.jface.viewers.TreeViewer;
*/
class ChildrenCountUpdate extends ViewerUpdateMonitor implements IChildrenCountUpdate {
- private Map fCounts;
+ /**
+ * Map of <code>TreePath</code>s to <code>Integer</code>s.
+ */
+ private Map fCounts = new HashMap();
+
+ /**
+ * Set of <code>TreePath</code>s.
+ */
private Set fParents = new HashSet();
+
private boolean fStarted = false;
- private IElementContentProvider fPresentation;
+ private IElementContentProvider fContentProvider;
/**
* @param contentProvider
*/
- public ChildrenCountUpdate(ModelContentProvider contentProvider, IElementContentProvider presentation) {
+ public ChildrenCountUpdate(ModelContentProvider contentProvider, IElementContentProvider elementContentProvider) {
super(contentProvider);
- fPresentation = presentation;
+ fContentProvider = elementContentProvider;
}
/* (non-Javadoc)
@@ -48,43 +56,30 @@ class ChildrenCountUpdate extends ViewerUpdateMonitor implements IChildrenCountU
while (iterator.hasNext()) {
Entry entry = (Entry) iterator.next();
int count = ((Integer)(entry.getValue())).intValue();
- Object parent = entry.getKey();
- TreePath[] treePaths = getContentProvider().getTreePaths(parent);
+ TreePath parentPath = (TreePath) entry.getKey();
int viewCount = count;
- if (treePaths.length > 0) {
- // all children are filtered the same per parent occurrence
- if (count == 0) {
- getContentProvider().clearFilters(treePaths[0]);
- } else {
- viewCount = getContentProvider().modelToViewChildCount(treePaths[0], count);
- }
+ if (count == 0) {
+ getContentProvider().clearFilters(parentPath);
+ } else {
+ viewCount = getContentProvider().modelToViewChildCount(parentPath, count);
}
- //System.out.println("setChildCount(" + parent + ", modelCount: " + count + " viewCount: " + viewCount + ")");
- ((TreeViewer)(getContentProvider().getViewer())).setChildCount(parent, viewCount);
- if (treePaths.length > 0) {
- if (treePaths[0].getSegmentCount() > 0) {
- getContentProvider().doRestore(treePaths[0]);
- }
+ if (ModelContentProvider.DEBUG_CONTENT_PROVIDER) {
+ System.out.println("setChildCount(" + getElement(parentPath) + ", modelCount: " + count + " viewCount: " + viewCount + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
+ ((TreeViewer)(getContentProvider().getViewer())).setChildCount(parentPath, viewCount);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IChildCountRequestMonitor#setChildCount(int)
- */
- public void setChildCount(Object parent, int numChildren) {
- if (fCounts == null) {
- fCounts = new HashMap();
- }
- fCounts.put(parent, new Integer(numChildren));
+ public void setChildCount(TreePath parentPath, int numChildren) {
+ fCounts.put(parentPath, new Integer(numChildren));
}
/**
* @param element
* @return
*/
- protected boolean coalesce(Object element) {
- fParents.add(element);
+ protected boolean coalesce(TreePath treePath) {
+ fParents.add(treePath);
return true;
}
@@ -99,15 +94,23 @@ class ChildrenCountUpdate extends ViewerUpdateMonitor implements IChildrenCountU
fStarted = true;
}
TreeModelContentProvider contentProvider = (TreeModelContentProvider)getContentProvider();
- contentProvider.countRequestStarted(fPresentation);
- fPresentation.update(this);
+ contentProvider.countRequestStarted(fContentProvider);
+ if (!isCanceled()) {
+ fContentProvider.update(this);
+ } else {
+ done();
+ }
+ }
+
+ public TreePath[] getParents() {
+ return (TreePath[]) fParents.toArray(new TreePath[fParents.size()]);
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate#getParents()
+ * @see org.eclipse.debug.internal.ui.viewers.model.ViewerUpdateMonitor#isContained(org.eclipse.jface.viewers.TreePath)
*/
- public Object[] getParents() {
- return fParents.toArray();
+ boolean isContained(TreePath path) {
+ return ((TreePath)fParents.iterator().next()).startsWith(path, null);
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java
index 0365e31d7..6d19aa839 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java
@@ -19,7 +19,6 @@ import org.eclipse.jface.viewers.TreePath;
*/
class ChildrenUpdate extends ViewerUpdateMonitor implements IChildrenUpdate {
- private Object fParent;
private TreePath fParentPath;
private Object[] fElements;
private int fIndex;
@@ -33,13 +32,12 @@ class ChildrenUpdate extends ViewerUpdateMonitor implements IChildrenUpdate {
* @param node node to update
* @param model model containing the node
*/
- public ChildrenUpdate(ModelContentProvider provider, Object parent, TreePath parentPath, int index, IElementContentProvider presentation) {
+ public ChildrenUpdate(ModelContentProvider provider, TreePath parentPath, int index, IElementContentProvider presentation) {
super(provider);
fParentPath = parentPath;
fIndex = index;
fLength = 1;
fContentProvider = presentation;
- fParent = parent;
}
/*
@@ -58,29 +56,41 @@ class ChildrenUpdate extends ViewerUpdateMonitor implements IChildrenUpdate {
int viewIndex = provider.modelToViewIndex(fParentPath, modelIndex);
if (provider.shouldFilter(fParentPath, element)) {
if (provider.addFilteredIndex(fParentPath, modelIndex)) {
- //System.out.println("REMOVE(" + fParent + ", modelIndex: " + modelIndex + " viewIndex: " + viewIndex + ", " + element + ")");
- viewer.remove(fParent, viewIndex);
+ if (ModelContentProvider.DEBUG_CONTENT_PROVIDER) {
+ System.out.println("REMOVE(" + getElement(fParentPath) + ", modelIndex: " + modelIndex + " viewIndex: " + viewIndex + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+ viewer.remove(fParentPath, viewIndex);
}
} else {
if (provider.isFiltered(fParentPath, modelIndex)) {
provider.clearFilteredChild(fParentPath, modelIndex);
int insertIndex = provider.modelToViewIndex(fParentPath, modelIndex);
- //System.out.println("insert(" + fParentPath.getLastSegment() + ", modelIndex: " + modelIndex + " insertIndex: " + insertIndex + ", " + element + ")");
+ if (ModelContentProvider.DEBUG_CONTENT_PROVIDER) {
+ System.out.println("insert(" + fParentPath.getLastSegment() + ", modelIndex: " + modelIndex + " insertIndex: " + insertIndex + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
if (fParentPath.getSegmentCount() == 0) {
- viewer.insert(fParent, element, insertIndex);
+ // TODO: does empty path work in viewer?
+ viewer.insert(getElement(fParentPath), element, insertIndex);
} else {
viewer.insert(fParentPath, element, insertIndex);
}
} else {
- //System.out.println("replace(" + fParent + ", modelIndex: " + modelIndex + " viewIndex: " + viewIndex + ", " + element + ")");
- viewer.replace(fParent, viewIndex, element);
+ if (ModelContentProvider.DEBUG_CONTENT_PROVIDER) {
+ System.out.println("replace(" + getElement(fParentPath) + ", modelIndex: " + modelIndex + " viewIndex: " + viewIndex + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+ if (fParentPath.getSegmentCount() > 0) {
+ viewer.replace(fParentPath, viewIndex, element);
+ } else {
+ viewer.replace(getElement(fParentPath), viewIndex, element);
+ }
}
- provider.updateChildCount(element, 0);
+ TreePath childPath = fParentPath.createChildPath(element);
+ provider.updateHasChildren(childPath);
}
}
}
} else {
- provider.updateChildCount(fParent, 0);
+ provider.updateHasChildren(fParentPath);
}
}
@@ -119,7 +129,11 @@ class ChildrenUpdate extends ViewerUpdateMonitor implements IChildrenUpdate {
//System.out.println("\tRequest (" + fParent + "): " + fIndex + " length: " + fLength);
TreeModelContentProvider contentProvider = (TreeModelContentProvider)getContentProvider();
contentProvider.childRequestStarted(this);
- fContentProvider.update(this);
+ if (!isCanceled()) {
+ fContentProvider.update(this);
+ } else {
+ done();
+ }
}
/* (non-Javadoc)
@@ -136,11 +150,15 @@ class ChildrenUpdate extends ViewerUpdateMonitor implements IChildrenUpdate {
return fIndex;
}
+ public TreePath getParent() {
+ return fParentPath;
+ }
+
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate#getParent()
+ * @see org.eclipse.debug.internal.ui.viewers.model.ViewerUpdateMonitor#isContained(org.eclipse.jface.viewers.TreePath)
*/
- public Object getParent() {
- return fParent;
+ boolean isContained(TreePath path) {
+ return fParentPath.startsWith(path, null);
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java
index 2856e27e0..1dee5ccc6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java
@@ -21,15 +21,13 @@ class ElementCompareRequest extends MementoUpdate implements IElementCompareRequ
private boolean fEqual;
private ModelDelta fDelta;
- private ModelContentProvider fProvider;
-
/**
* @param context
* @param element
* @param memento
*/
public ElementCompareRequest(ModelContentProvider provider, Object element, IMemento memento, ModelDelta delta) {
- super(provider.getPresentationContext(), element, memento);
+ super(provider, provider.getPresentationContext(), element, memento);
fProvider = provider;
fDelta = delta;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java
index a50a9fb99..b41260f14 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java
@@ -28,8 +28,8 @@ class ElementMementoRequest extends MementoUpdate implements IElementMementoRequ
* @param element
* @param memento
*/
- public ElementMementoRequest(IMementoManager manager, IPresentationContext context, Object element, IMemento memento, ModelDelta delta) {
- super(context, element, memento);
+ public ElementMementoRequest(ModelContentProvider provider, IMementoManager manager, IPresentationContext context, Object element, IMemento memento, ModelDelta delta) {
+ super(provider, context, element, memento);
fManager = manager;
fDelta = delta;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/HasChildrenUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/HasChildrenUpdate.java
new file mode 100644
index 000000000..3f670a0ca
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/HasChildrenUpdate.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.model;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+
+/**
+ * @since 3.3
+ */
+class HasChildrenUpdate extends ViewerUpdateMonitor implements IHasChildrenUpdate {
+
+ /**
+ * Map of <code>TreePath</code>s to <code>Boolean</code>s.
+ */
+ private Map fBooleans = new HashMap();
+
+ /**
+ * Set of <code>TreePath</code>s.
+ */
+ private Set fElements = new HashSet();
+
+ private boolean fStarted = false;
+ private IElementContentProvider fContentProvider;
+
+ /**
+ * @param contentProvider
+ */
+ public HasChildrenUpdate(ModelContentProvider contentProvider, IElementContentProvider elementContentProvider) {
+ super(contentProvider);
+ fContentProvider = elementContentProvider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.ViewerUpdateMonitor#performUpdate()
+ */
+ protected void performUpdate() {
+ Iterator iterator = fBooleans.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+ boolean hasChildren = ((Boolean)(entry.getValue())).booleanValue();
+ TreePath elementPath = (TreePath) entry.getKey();
+ ModelContentProvider contentProvider = getContentProvider();
+ if (!hasChildren) {
+ contentProvider.clearFilters(elementPath);
+ }
+ if (ModelContentProvider.DEBUG_CONTENT_PROVIDER) {
+ System.out.println("setHasChildren(" + getElement(elementPath) + " >> " + hasChildren); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (elementPath.getSegmentCount() > 0) {
+ ((TreeViewer)(contentProvider.getViewer())).setHasChildren(elementPath, hasChildren);
+ contentProvider.doRestore(elementPath);
+ } else {
+ ((TreeViewer)(contentProvider.getViewer())).setHasChildren(getElement(elementPath), hasChildren);
+ }
+
+ }
+ }
+
+ /**
+ * @param element
+ * @return
+ */
+ protected boolean coalesce(TreePath treePath) {
+ fElements.add(treePath);
+ return true;
+ }
+
+ /**
+ *
+ */
+ protected void start() {
+ synchronized (this) {
+ if (fStarted) {
+ return;
+ }
+ fStarted = true;
+ }
+ TreeModelContentProvider contentProvider = (TreeModelContentProvider)getContentProvider();
+ contentProvider.hasChildrenRequestStarted(fContentProvider);
+ if (!isCanceled()) {
+ fContentProvider.update(this);
+ } else {
+ done();
+ }
+ }
+
+ public TreePath[] getElements() {
+ return (TreePath[]) fElements.toArray(new TreePath[fElements.size()]);
+ }
+
+ public void setHasChilren(TreePath element, boolean hasChildren) {
+ fBooleans.put(element, Boolean.valueOf(hasChildren));
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.ViewerUpdateMonitor#isContained(org.eclipse.jface.viewers.TreePath)
+ */
+ boolean isContained(TreePath path) {
+ return ((TreePath)fElements.iterator().next()).startsWith(path, null);
+ }
+
+}
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 55be92c00..9b5357f4a 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
@@ -322,27 +322,6 @@ public class InternalTreeModelViewer extends TreeViewer {
public IPresentationContext getPresentationContext() {
return fContext;
}
-
- /* (non-Javadoc)
- *
- * Clear filters when refreshing an element structurally.
- *
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#internalRefresh(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean, boolean)
- */
- protected void internalRefresh(Widget widget, Object element, boolean doStruct, boolean updateLabels) {
- if (doStruct) {
- IContentProvider provider = getContentProvider();
- if (provider instanceof ModelContentProvider) {
- ModelContentProvider mcp = (ModelContentProvider) provider;
- if (widget instanceof TreeItem) {
- mcp.refreshingStructure(getTreePathFromItem((TreeItem)widget));
- } else {
- mcp.refreshingStructure(ModelContentProvider.EMPTY_TREE_PATH);
- }
- }
- }
- super.internalRefresh(widget, element, doStruct, updateLabels);
- }
protected void unmapElement(Object element, Widget widget) {
if (fNotifyUnmap) {
@@ -387,23 +366,6 @@ public class InternalTreeModelViewer extends TreeViewer {
}
}
- protected TreePath[] getTreePaths(Object element) {
- Widget[] widgets = findItems(element);
- TreePath[] paths = new TreePath[widgets.length];
- for (int i = 0; i < widgets.length; i++) {
- TreePath path = (TreePath) widgets[i].getData(TREE_PATH_KEY);
- if (path == null) {
- if (widgets[i] instanceof Item) {
- path = getTreePathFromItem((Item)widgets[i]);
- } else {
- path = ModelContentProvider.EMPTY_TREE_PATH;
- }
- }
- paths[i] = path;
- }
- return paths;
- }
-
/* (non-Javadoc)
*
* Override because we allow inserting with filters present.
@@ -431,43 +393,6 @@ public class InternalTreeModelViewer extends TreeViewer {
}
return super.hasFilters();
}
-
- /**
- * Removes the element at the specified index of the parent.
- *
- * @param parent parent element
- * @param index child index
- */
- public void remove(final Object parent, final int index) {
- preservingSelection(new Runnable() {
- public void run() {
- if (parent.equals(getInput())) {
- Tree tree = (Tree) getControl();
- if (index < tree.getItemCount()) {
- TreeItem item = tree.getItem(index);
- Object element = item.getData();
- if (element != null) {
- unmapElement(element, item);
- }
- item.dispose();
- }
- } else {
- Widget[] parentItems = findItems(parent);
- for (int i = 0; i < parentItems.length; i++) {
- TreeItem parentItem = (TreeItem) parentItems[i];
- if (index < parentItem.getItemCount()) {
- TreeItem item = parentItem.getItem(index);
- Object element = item.getData();
- if (element != null) {
- unmapElement(element, item);
- }
- item.dispose();
- }
- }
- }
- }
- });
- }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.AbstractTreeViewer#inputChanged(java.lang.Object, java.lang.Object)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java
index b0540f0bc..25d1b48d9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java
@@ -14,6 +14,7 @@ import org.eclipse.debug.internal.ui.commands.actions.AbstractRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -214,5 +215,13 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate {
}
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElement(org.eclipse.jface.viewers.TreePath)
+ */
+ public Object getElement(TreePath path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java
index 52f95381f..d9b29d8a9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java
@@ -13,6 +13,7 @@ package org.eclipse.debug.internal.ui.viewers.model;
import org.eclipse.debug.internal.ui.commands.actions.AbstractRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.IMemento;
/**
@@ -23,6 +24,7 @@ abstract class MementoUpdate extends AbstractRequestMonitor implements IViewerUp
private IPresentationContext fContext;
private Object fElement;
private IMemento fMemento;
+ protected ModelContentProvider fProvider;
/**
* Constructs a viewer state request.
@@ -31,10 +33,11 @@ abstract class MementoUpdate extends AbstractRequestMonitor implements IViewerUp
* @param element element
* @param memento memento
*/
- public MementoUpdate(IPresentationContext context, Object element, IMemento memento) {
+ public MementoUpdate(ModelContentProvider provider, IPresentationContext context, Object element, IMemento memento) {
fContext = context;
fElement = element;
fMemento = memento;
+ fProvider = provider;
}
/* (non-Javadoc)
@@ -52,4 +55,12 @@ abstract class MementoUpdate extends AbstractRequestMonitor implements IViewerUp
return fMemento;
}
+ public ModelContentProvider getContentProvider() {
+ return fProvider;
+ }
+
+ public Object getElement(TreePath path) {
+ return fProvider.getElement(path);
+ }
+
}
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 6aebfaf51..dd0ed8f2f 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
@@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -26,6 +27,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
@@ -42,11 +44,9 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.IMemento;
@@ -59,8 +59,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
*
* @since 3.3
*/
-abstract class ModelContentProvider implements IContentProvider,
- IModelChangedListener {
+abstract class ModelContentProvider implements IContentProvider, IModelChangedListener {
private Viewer fViewer;
@@ -82,9 +81,9 @@ abstract class ModelContentProvider implements IContentProvider,
private ListenerList fUpdateListeners = new ListenerList();
/**
- * Nesting count of updates
+ * List of updates in progress
*/
- private int fUpdateNestingCount = 0;
+ private List fUpdatesInProgress = new ArrayList();
/**
* Map of viewer states keyed by viewer input mementos
@@ -144,6 +143,14 @@ abstract class ModelContentProvider implements IContentProvider,
* Constant for an empty tree path.
*/
protected static final TreePath EMPTY_TREE_PATH = new TreePath(new Object[]{});
+
+ // debug flag
+ public static boolean DEBUG_CONTENT_PROVIDER = false;
+
+ static {
+ DEBUG_CONTENT_PROVIDER = DebugUIPlugin.DEBUG && "true".equals( //$NON-NLS-1$
+ Platform.getDebugOption("org.eclipse.debug.ui/debug/viewers/contentProvider")); //$NON-NLS-1$
+ }
/*
* (non-Javadoc)
@@ -209,10 +216,12 @@ abstract class ModelContentProvider implements IContentProvider,
keyMemento.save(writer);
final ModelDelta stateDelta = (ModelDelta) fViewerStates.remove(writer.toString());
if (stateDelta != null) {
- //System.out.println("RESTORE: " + stateDelta.toString());
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("RESTORE: " + stateDelta.toString()); //$NON-NLS-1$
+ }
stateDelta.setElement(input);
// begin restoration
- UIJob job = new UIJob("restore state") {
+ UIJob job = new UIJob("restore state") { //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
if (input.equals(getViewer().getInput())) {
fPendingState = stateDelta;
@@ -246,18 +255,23 @@ abstract class ModelContentProvider implements IContentProvider,
}
};
- manager.addRequest(new ElementMementoRequest(manager, getPresentationContext(),
+ manager.addRequest(new ElementMementoRequest(ModelContentProvider.this, manager, getPresentationContext(),
delta.getElement(), inputMemento, delta));
manager.processReqeusts();
}
}
/**
- * Restore selection/expansion based on items already in the tree
+ * Restore selection/expansion based on items already in the viewer
*/
abstract protected void doInitialRestore();
/**
+ * @param delta
+ */
+ abstract void doRestore(final ModelDelta delta);
+
+ /**
* Perform any restoration required for the given tree path.
*
* @param path
@@ -283,7 +297,7 @@ abstract class ModelContentProvider implements IContentProvider,
} else {
if (element.equals(potentialMatch)) {
// already processed - visit children
- return true;
+ return path.getSegmentCount() > depth;
}
}
return false;
@@ -375,11 +389,11 @@ abstract class ModelContentProvider implements IContentProvider,
public boolean visit(IModelDelta delta, int depth) {
if (delta.getParentDelta() == null) {
manager.addRequest(
- new ElementMementoRequest(manager, getPresentationContext(),
+ new ElementMementoRequest(ModelContentProvider.this, manager, getPresentationContext(),
delta.getElement(), inputMemento, (ModelDelta)delta));
} else {
manager.addRequest(
- new ElementMementoRequest(manager, getPresentationContext(),
+ new ElementMementoRequest(ModelContentProvider.this, manager, getPresentationContext(),
delta.getElement(), childrenMemento.createChild("CHILD_ELEMENT"), (ModelDelta)delta)); //$NON-NLS-1$
}
return true;
@@ -722,14 +736,6 @@ abstract class ModelContentProvider implements IContentProvider,
}
/**
- * Notification that a structural refresh is occurring at the specified path
- *
- * @param path
- */
- protected void refreshingStructure(TreePath path) {
- }
-
- /**
* Notification the given element is being unmapped.
*
* @param path
@@ -738,20 +744,6 @@ abstract class ModelContentProvider implements IContentProvider,
//System.out.println("Unmap " + path.getLastSegment());
fTransform.clear(path);
}
-
- /**
- * Return tree paths to the given element in the viewer or <code>null</code>
- *
- * @param element
- * @return tree paths or <code>null</code>
- */
- protected TreePath[] getTreePaths(Object element) {
- if (fViewer instanceof InternalTreeModelViewer) {
- InternalTreeModelViewer tmv = (InternalTreeModelViewer) fViewer;
- return tmv.getTreePaths(element);
- }
- return null;
- }
/**
* Returns filtered children or <code>null</code>
@@ -770,37 +762,16 @@ abstract class ModelContentProvider implements IContentProvider,
fTransform.clear(parent);
}
- /**
- * @param delta
- */
- void doRestore(final ModelDelta delta) {
- if (delta.getFlags() != IModelDelta.NO_CHANGE) {
- UIJob job = new UIJob("restore delta") { //$NON-NLS-1$
- public IStatus runInUIThread(IProgressMonitor monitor) {
- TreePath treePath = getTreePath(delta);
- AbstractTreeViewer viewer = (AbstractTreeViewer)getViewer();
- if ((delta.getFlags() & IModelDelta.EXPAND) != 0) {
- viewer.expandToLevel(treePath, 1);
- }
- if ((delta.getFlags() & IModelDelta.SELECT) != 0) {
- viewer.setSelection(new TreeSelection(treePath));
- }
- delta.setFlags(IModelDelta.NO_CHANGE);
- checkIfRestoreComplete();
- return Status.OK_STATUS;
- }
- };
- job.setSystem(true);
- job.schedule();
- }
- }
+
protected void checkIfRestoreComplete() {
CheckState state = new CheckState();
fPendingState.accept(state);
if (state.isComplete()) {
fPendingState = null;
- //System.out.println("RESTORE COMPELTE");
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("RESTORE COMPELTE"); //$NON-NLS-1$
+ }
}
}
@@ -819,9 +790,9 @@ abstract class ModelContentProvider implements IContentProvider,
*/
void updateStarted(IAsynchronousRequestMonitor update) {
boolean begin = false;
- synchronized (this) {
- begin = fUpdateNestingCount == 0;
- fUpdateNestingCount++;
+ synchronized (fUpdatesInProgress) {
+ begin = fUpdatesInProgress.isEmpty();
+ fUpdatesInProgress.add(update);
}
if (begin) {
notifyUpdate(UPDATE_SEQUENCE_BEGINS, null);
@@ -836,9 +807,9 @@ abstract class ModelContentProvider implements IContentProvider,
*/
void updateComplete(IAsynchronousRequestMonitor update) {
boolean end = false;
- synchronized (this) {
- fUpdateNestingCount--;
- end = fUpdateNestingCount == 0;
+ synchronized (fUpdatesInProgress) {
+ fUpdatesInProgress.remove(update);
+ end = fUpdatesInProgress.isEmpty();
}
notifyUpdate(UPDATE_COMPLETE, update);
if (end) {
@@ -876,6 +847,17 @@ abstract class ModelContentProvider implements IContentProvider,
}
}
+ protected void cancelSubtreeUpdates(TreePath path) {
+ synchronized (fUpdatesInProgress) {
+ for (int i = 0; i < fUpdatesInProgress.size(); i++) {
+ ViewerUpdateMonitor update = (ViewerUpdateMonitor) fUpdatesInProgress.get(i);
+ if (update.isContained(path)) {
+ update.setCanceled(true);
+ }
+ }
+ }
+ }
+
/**
* Registers the given listener for model delta notification.
*
@@ -902,5 +884,18 @@ abstract class ModelContentProvider implements IContentProvider,
IModelProxy proxy = (IModelProxy) proxies.next();
proxy.removeModelChangedListener(listener);
}
- }
+ }
+
+ /**
+ * Returns the element corresponding to the given tree path.
+ *
+ * @param path tree path
+ * @return model element
+ */
+ protected Object getElement(TreePath path) {
+ if (path.getSegmentCount() > 0) {
+ return path.getLastSegment();
+ }
+ return getViewer().getInput();
+ }
}
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 b7200ada8..1752c9afd 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
@@ -17,32 +17,49 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
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.model.provisional.TreeModelViewer;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.ILazyTreeContentProvider;
+import org.eclipse.jface.viewers.ILazyTreePathContentProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.progress.UIJob;
/**
* Content provider for a virtual tree.
*
* @since 3.3
*/
-class TreeModelContentProvider extends ModelContentProvider implements ILazyTreeContentProvider {
+class TreeModelContentProvider extends ModelContentProvider implements ILazyTreePathContentProvider {
protected static final String[] STATE_PROPERTIES = new String[]{IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE};
+ /**
+ * Map of parent paths to requests
+ */
private Map fPendingChildRequests = new HashMap();
+
+ /**
+ * Map of content adapters to requests
+ */
private Map fPendingCountRequests = new HashMap();
+ /**
+ * Map of content adapters to requests
+ */
+ private Map fPendingHasChildrenRequests = new HashMap();
+
private Timer fTimer = new Timer();
/* (non-Javadoc)
@@ -61,44 +78,27 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
if (getViewer() != null) {
int[] filteredChildren = getFilteredChildren(path);
if (filteredChildren != null) {
- Object parent = getViewer().getInput();
- if (path.getSegmentCount() > 0) {
- parent = path.getLastSegment();
- }
for (int i = 0; i < filteredChildren.length; i++) {
- doUpdateElement(parent, path, filteredChildren[i]);
+ doUpdateElement(path, filteredChildren[i]);
}
}
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILazyTreeContentProvider#updateChildCount(java.lang.Object, int)
- */
- public synchronized void updateChildCount(Object element, int currentChildCount) {
- //System.out.println("updateChildCount(" + element + ", " + currentChildCount + ")");
- TreePath[] treePaths = getTreePaths(element);
- for (int i = 0; i < treePaths.length; i++) {
- // re-filter children when asked to update the child count for an element (i.e.
- // when refreshing, see if filtered children are still filtered)
- refilterChildren(treePaths[i]);
- }
- doUpdateChildCount(element, currentChildCount);
- }
- protected synchronized void doUpdateChildCount(Object element, int currentChildCount) {
+ protected synchronized void doUpdateChildCount(TreePath path) {
+ Object element = getElement(path);
IElementContentProvider contentAdapter = getContentAdapter(element);
if (contentAdapter != null) {
ChildrenCountUpdate request = (ChildrenCountUpdate) fPendingCountRequests.get(contentAdapter);
if (request != null) {
- if (request.coalesce(element)) {
+ if (request.coalesce(path)) {
return;
} else {
request.start();
}
}
final ChildrenCountUpdate newRequest = new ChildrenCountUpdate(this, contentAdapter);
- newRequest.coalesce(element);
+ newRequest.coalesce(path);
fPendingCountRequests.put(contentAdapter, newRequest);
fTimer.schedule(new TimerTask() {
public void run() {
@@ -107,23 +107,9 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
}, 10L);
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILazyTreeContentProvider#updateElement(java.lang.Object, int)
- */
- public synchronized void updateElement(Object parent, int viewIndex) {
- //System.out.println("updateElement(" + parent + ", " + viewIndex + ")");
- TreePath[] paths = getTreePaths(parent);
- if (paths.length > 0) {
- TreePath path = paths[0]; // all children filter the same, per parent occurrence
- int modelIndex = viewToModelIndex(path, viewIndex);
- //System.out.println("updateElement("+ parent + ", " + viewIndex + ") > modelIndex = " + modelIndex);
- doUpdateElement(parent, path, modelIndex);
- }
- }
- protected synchronized void doUpdateElement(Object parent, TreePath parentPath, int modelIndex) {
- ChildrenUpdate request = (ChildrenUpdate) fPendingChildRequests.get(parent);
+ protected synchronized void doUpdateElement(TreePath parentPath, int modelIndex) {
+ ChildrenUpdate request = (ChildrenUpdate) fPendingChildRequests.get(parentPath);
if (request != null) {
if (request.coalesce(modelIndex)) {
return;
@@ -131,10 +117,11 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
request.start();
}
}
+ Object parent = getElement(parentPath);
IElementContentProvider contentAdapter = getContentAdapter(parent);
if (contentAdapter != null) {
- final ChildrenUpdate newRequest = new ChildrenUpdate(this, parent, parentPath, modelIndex, contentAdapter);
- fPendingChildRequests.put(parent, newRequest);
+ final ChildrenUpdate newRequest = new ChildrenUpdate(this, parentPath, modelIndex, contentAdapter);
+ fPendingChildRequests.put(parentPath, newRequest);
fTimer.schedule(new TimerTask() {
public void run() {
newRequest.start();
@@ -143,6 +130,29 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
}
}
+ protected synchronized void doUpdateHasChildren(TreePath path) {
+ Object element = getElement(path);
+ IElementContentProvider contentAdapter = getContentAdapter(element);
+ if (contentAdapter != null) {
+ HasChildrenUpdate request = (HasChildrenUpdate) fPendingHasChildrenRequests.get(contentAdapter);
+ if (request != null) {
+ if (request.coalesce(path)) {
+ return;
+ } else {
+ request.start();
+ }
+ }
+ final HasChildrenUpdate newRequest = new HasChildrenUpdate(this, contentAdapter);
+ newRequest.coalesce(path);
+ fPendingHasChildrenRequests.put(contentAdapter, newRequest);
+ fTimer.schedule(new TimerTask() {
+ public void run() {
+ newRequest.start();
+ }
+ }, 10L);
+ }
+ }
+
protected synchronized void childRequestStarted(IChildrenUpdate update) {
fPendingChildRequests.remove(update.getParent());
}
@@ -150,6 +160,10 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
protected synchronized void countRequestStarted(Object key) {
fPendingCountRequests.remove(key);
}
+
+ protected synchronized void hasChildrenRequestStarted(Object key) {
+ fPendingHasChildrenRequests.remove(key);
+ }
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.ModelContentProvider#getPresentationContext()
@@ -171,13 +185,14 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.ModelContentProvider#handleAdd(org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta)
*/
protected void handleAdd(IModelDelta delta) {
- doUpdateChildCount(delta.getParentDelta().getElement(), 0);
+ doUpdateChildCount(getTreePath(delta.getParentDelta()));
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.ModelContentProvider#handleContent(org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta)
*/
protected void handleContent(IModelDelta delta) {
+ cancelSubtreeUpdates(getTreePath(delta));
getTreeViewer().refresh(delta.getElement());
}
@@ -201,8 +216,15 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
treeViewer.replace(delta.getParentDelta().getElement(), index, delta.getElement());
}
if (childCount > 0) {
- treeViewer.setChildCount(delta.getElement(), childCount);
- treeViewer.expandToLevel(getTreePath(delta), 1);
+ TreePath elementPath = getTreePath(delta);
+ int viewCount = modelToViewChildCount(elementPath, childCount);
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("[expand] setChildCount(" + delta.getElement() + ", (model) " + childCount + " (view) " + viewCount); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ treeViewer.setChildCount(delta.getElement(), viewCount);
+ if (!treeViewer.getExpandedState(elementPath)) {
+ treeViewer.expandToLevel(elementPath, 1);
+ }
}
}
@@ -316,4 +338,70 @@ class TreeModelContentProvider extends ModelContentProvider implements ILazyTree
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILazyTreePathContentProvider#getParents(java.lang.Object)
+ */
+ public TreePath[] getParents(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILazyTreePathContentProvider#updateChildCount(org.eclipse.jface.viewers.TreePath, int)
+ */
+ public synchronized void updateChildCount(TreePath treePath, int currentChildCount) {
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("updateChildCount(" + getElement(treePath) + ", " + currentChildCount + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ refilterChildren(treePath);
+ //re-filter children when asked to update the child count for an element (i.e.
+ // when refreshing, see if filtered children are still filtered)
+ doUpdateChildCount(treePath);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILazyTreePathContentProvider#updateElement(org.eclipse.jface.viewers.TreePath, int)
+ */
+ public synchronized void updateElement(TreePath parentPath, int viewIndex) {
+ int modelIndex = viewToModelIndex(parentPath, viewIndex);
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("updateElement("+ getElement(parentPath) + ", " + viewIndex + ") > modelIndex = " + modelIndex); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ doUpdateElement(parentPath, modelIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILazyTreePathContentProvider#updateHasChildren(org.eclipse.jface.viewers.TreePath)
+ */
+ public synchronized void updateHasChildren(TreePath path) {
+ if (DEBUG_CONTENT_PROVIDER) {
+ System.out.println("updateHasChildren(" + getElement(path)); //$NON-NLS-1$
+ }
+ doUpdateHasChildren(path);
+ }
+
+ /**
+ * @param delta
+ */
+ void doRestore(final ModelDelta delta) {
+ if (delta.getFlags() != IModelDelta.NO_CHANGE) {
+ UIJob job = new UIJob("restore delta") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ TreePath treePath = getTreePath(delta);
+ AbstractTreeViewer viewer = (AbstractTreeViewer)getViewer();
+ if ((delta.getFlags() & IModelDelta.EXPAND) != 0) {
+ viewer.expandToLevel(treePath, 1);
+ }
+ if ((delta.getFlags() & IModelDelta.SELECT) != 0) {
+ viewer.setSelection(new TreeSelection(treePath));
+ }
+ delta.setFlags(IModelDelta.NO_CHANGE);
+ checkIfRestoreComplete();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java
index 6b949abab..8014e05a3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java
@@ -18,6 +18,7 @@ import org.eclipse.debug.internal.ui.commands.actions.AbstractRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.AsynchronousSchedulingRuleFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.progress.WorkbenchJob;
/**
@@ -119,4 +120,17 @@ abstract class ViewerUpdateMonitor extends AbstractRequestMonitor implements IVi
public IPresentationContext getPresentationContext() {
return fContentProvider.getPresentationContext();
}
+
+ public Object getElement(TreePath path) {
+ return fContentProvider.getElement(path);
+ }
+
+ /**
+ * Whether this update is rooted at or below the given path.
+ *
+ * @param path
+ * @return whether this update is rooted at or below the given path
+ */
+ abstract boolean isContained(TreePath path);
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenCountUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenCountUpdate.java
index 11e752081..9ea4246cd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenCountUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenCountUpdate.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.model.provisional;
+import org.eclipse.jface.viewers.TreePath;
+
/**
* Request monitor used to collect the number of children for an element in a viewer.
@@ -19,17 +21,18 @@ package org.eclipse.debug.internal.ui.viewers.model.provisional;
public interface IChildrenCountUpdate extends IViewerUpdate {
/**
- * Returns the parent elements that children counts have been requested for.
+ * Returns the parent elements that children counts have been requested for
+ * as tree paths. An empty path identifies the root element.
*
- * @return parent elements
+ * @return parent elements as tree paths
*/
- public Object[] getParents();
+ public TreePath[] getParents();
/**
* Sets the number of children for the given parent.
*
- * @param parent parent element
+ * @param parent parent element or empty path for root element
* @param numChildren number of children
*/
- public void setChildCount(Object parent, int numChildren);
+ public void setChildCount(TreePath parentPath, int numChildren);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenUpdate.java
index 51de60bbd..d477a2c0c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IChildrenUpdate.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.model.provisional;
+import org.eclipse.jface.viewers.TreePath;
+
/**
* Context sensitive children update request for a parent and subrange of its
* children.
@@ -19,11 +21,12 @@ package org.eclipse.debug.internal.ui.viewers.model.provisional;
public interface IChildrenUpdate extends IViewerUpdate {
/**
- * Returns the parent element that children are being requested for.
+ * Returns the parent element that children are being requested for
+ * as a tree path. An empty path identifies the root element.
*
- * @return parent element
+ * @return parent element as a tree path
*/
- public Object getParent();
+ public TreePath getParent();
/**
* Returns the offset at which children have been requested for. This is
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementContentProvider.java
index af72558ea..19ee90d20 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementContentProvider.java
@@ -33,4 +33,11 @@ public interface IElementContentProvider {
*/
public void update(IChildrenUpdate update);
+ /**
+ * Updates whether elements have children.
+ *
+ * @param update specifies elements to update and stores result
+ */
+ public void update(IHasChildrenUpdate update);
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IHasChildrenUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IHasChildrenUpdate.java
new file mode 100644
index 000000000..9dc602174
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IHasChildrenUpdate.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.model.provisional;
+
+import org.eclipse.jface.viewers.TreePath;
+
+/**
+ * Context sensitive update request for whether elements have children.
+ *
+ * @since 3.3
+ */
+public interface IHasChildrenUpdate extends IViewerUpdate {
+
+ /**
+ * The elements this request is for specified as tree paths.
+ * An empty path identifies the root element.
+ *
+ * @return elements as tree paths
+ */
+ public TreePath[] getElements();
+
+ /**
+ * Sets whether the given element has children.
+ *
+ * @param element tree path to element, or empty for root element
+ * @param hasChildren whether it has children
+ */
+ public void setHasChilren(TreePath element, boolean hasChildren);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewerUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewerUpdate.java
index fe89b3196..911677413 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewerUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewerUpdate.java
@@ -12,6 +12,7 @@ package org.eclipse.debug.internal.ui.viewers.model.provisional;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.TreePath;
/**
* A context sensitive viewer update request.
@@ -42,4 +43,13 @@ public interface IViewerUpdate extends IProgressMonitor {
* @return request status or <code>null</code>
*/
public IStatus getStatus();
+
+ /**
+ * Returns the model element corresponding to the given tree path.
+ * Returns the root element for the empty path.
+ *
+ * @param path viewer tree path
+ * @return corresponding model element
+ */
+ public Object getElement(TreePath path);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
index 26b4d9783..1ac103f9b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
@@ -285,6 +285,9 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
val = null;
}
if (val != null && !monitor.isCanceled()) {
+ if (monitor.isCanceled()) {
+ break;
+ }
getModelPresentation().computeDetail(val, this);
synchronized (this) {
try {
@@ -508,6 +511,9 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
private Job fTriggerDetailsJob = new UIJob("trigger details") { //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
populateDetailPane();
return Status.OK_STATUS;
}
@@ -612,6 +618,7 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
*/
public Viewer createViewer(Composite parent) {
+ fTriggerDetailsJob.setSystem(true);
TreeModelViewer variablesViewer = createTreeViewer(parent);
variablesViewer.getPresentationContext().addPropertyChangeListener(
new IPropertyChangeListener() {
@@ -1681,13 +1688,17 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.IViewerUpdateListener#viewerUpdatesBegin()
*/
- public void viewerUpdatesBegin() {
+ public synchronized void viewerUpdatesBegin() {
+ fTriggerDetailsJob.cancel();
+ if (fDetailsJob != null) {
+ fDetailsJob.cancel();
+ }
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.IViewerUpdateListener#viewerUpdatesComplete()
*/
- public void viewerUpdatesComplete() {
+ public synchronized void viewerUpdatesComplete() {
if (fVisitor.isTriggerDetails()) {
fTriggerDetailsJob.schedule();
}

Back to the top