diff options
author | Kevin Barnes | 2005-01-19 16:12:24 +0000 |
---|---|---|
committer | Kevin Barnes | 2005-01-19 16:12:24 +0000 |
commit | 3a693b815315096c9638f3bf0cee5fb4faafc844 (patch) | |
tree | b1b43d4ebdc0b16d2d46f13bccc06ccd3aeef5cf /org.eclipse.debug.ui | |
parent | dd332c34e075acb2fbe2ff5ec4a70c33dc9c907d (diff) | |
download | eclipse.platform.debug-3a693b815315096c9638f3bf0cee5fb4faafc844.tar.gz eclipse.platform.debug-3a693b815315096c9638f3bf0cee5fb4faafc844.tar.xz eclipse.platform.debug-3a693b815315096c9638f3bf0cee5fb4faafc844.zip |
Bug 44724 - background content in debug views
Diffstat (limited to 'org.eclipse.debug.ui')
27 files changed, 1016 insertions, 147 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java index 16933fa85..d90f1ee30 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java @@ -46,8 +46,11 @@ import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IExpression; import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; +import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; import org.eclipse.debug.internal.ui.launchConfigurations.PerspectiveManager; import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager; @@ -371,6 +374,9 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener { DeferredContentAdapterFactory factory = new DeferredContentAdapterFactory(); manager.registerAdapters(factory, IDebugTarget.class); manager.registerAdapters(factory, IThread.class); + manager.registerAdapters(factory, IStackFrame.class); + manager.registerAdapters(factory, IVariable.class); + manager.registerAdapters(factory, IExpression.class); DebugUIAdapterFactory uiFactory = new DebugUIAdapterFactory(); manager.registerAdapters(uiFactory, ILaunchConfiguration.class); manager.registerAdapters(uiFactory, ILaunchConfigurationType.class); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java index c27efbb21..c0c52e986 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java @@ -12,6 +12,7 @@ package org.eclipse.debug.internal.ui.launchConfigurations; import java.text.MessageFormat; + import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java index 5ca2b8a0d..21512dfb2 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java @@ -25,7 +25,9 @@ import org.eclipse.swt.widgets.TreeItem; public abstract class AbstractViewerState { // paths to expanded elements - private List fExpandedElements = null; + private List fSavedExpansion = null; + // paths currently expanded + private List fCurrentExpansion = new ArrayList(); // paths to selected elements private IPath[] fSelection = null; @@ -43,18 +45,19 @@ public abstract class AbstractViewerState { * @param viewer viewer of which to save the state */ public void saveState(TreeViewer viewer) { + fCurrentExpansion.clear(); List expanded = new ArrayList(); - fExpandedElements = null; + fSavedExpansion = null; TreeItem[] items = viewer.getTree().getItems(); try { for (int i = 0; i < items.length; i++) { - collectExandedItems(items[i], expanded); + collectExpandedItems(items[i], expanded); } if (expanded.size() > 0) { - fExpandedElements = expanded; + fSavedExpansion = expanded; } } catch (DebugException e) { - fExpandedElements = null; + fSavedExpansion = null; } TreeItem[] selection = viewer.getTree().getSelection(); fSelection = new IPath[selection.length]; @@ -67,13 +70,13 @@ public abstract class AbstractViewerState { } } - protected void collectExandedItems(TreeItem item, List expanded) + protected void collectExpandedItems(TreeItem item, List expanded) throws DebugException { if (item.getExpanded()) { expanded.add(encodeElement(item)); TreeItem[] items = item.getItems(); for (int i = 0; i < items.length; i++) { - collectExandedItems(items[i], expanded); + collectExpandedItems(items[i], expanded); } } } @@ -96,38 +99,50 @@ public abstract class AbstractViewerState { * @param viewer viewer to which state is restored */ public void restoreState(TreeViewer viewer) { - if (fExpandedElements != null) { - List expansion = new ArrayList(fExpandedElements.size()); - for (int i = 0; i < fExpandedElements.size(); i++) { - IPath path = (IPath) fExpandedElements.get(i); - if (path != null) { - Object obj; - try { - obj = decodePath(path, viewer); - if (obj != null) { - expansion.add(obj); - } - } catch (DebugException e) { - } - } - } - viewer.setExpandedElements(expansion.toArray()); - } - if (fSelection != null) { - List selection = new ArrayList(fSelection.length); - for (int i = 0; i < fSelection.length; i++) { - IPath path = fSelection[i]; - Object obj; - try { - obj = decodePath(path, viewer); - if (obj != null) { - selection.add(obj); - } - } catch (DebugException e) { - } - } - viewer.setSelection(new StructuredSelection(selection)); - } + boolean expansionComplete = true; + if (fSavedExpansion != null && fSavedExpansion.size() > 0) { + for (int i = 0; i < fSavedExpansion.size(); i++) { + IPath path = (IPath) fSavedExpansion.get(i); + if (path != null) { + Object obj; + try { + obj = decodePath(path, viewer); + if (obj != null) { + fCurrentExpansion.add(obj); + } else { + expansionComplete = false; + } + } catch (DebugException e) { + } + } + } + viewer.setExpandedElements(fCurrentExpansion.toArray()); + if (expansionComplete) { + fSavedExpansion = null; + } + } + + boolean selectionComplete = true; + if (fSelection != null) { + List selection = new ArrayList(fSelection.length); + for (int i = 0; i < fSelection.length; i++) { + IPath path = fSelection[i]; + Object obj; + try { + obj = decodePath(path, viewer); + if (obj != null) { + selection.add(obj); + } else { + selectionComplete = false; + } + } catch (DebugException e) { + } + } + viewer.setSelection(new StructuredSelection(selection)); + if (selectionComplete) { + fSelection = null; + } + } } /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties index e5796e9df..82abde7e8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties @@ -70,3 +70,4 @@ IncrementalDeferredTreeContentManager.0=Replace children IncrementalDeferredTreeContentManager.1=Prune children OtherBreakpointOrganizer.0=Others WorkingSetCategory.0=\ (default) +RemoteTreeViewer.0=Restore Viewer State diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/IRemoteTreeViewerUpdateListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/IRemoteTreeViewerUpdateListener.java new file mode 100644 index 000000000..8e1dcc6f9 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/IRemoteTreeViewerUpdateListener.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views; + +public interface IRemoteTreeViewerUpdateListener { + public void treeUpdated(); +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java index 51a6a462d..2b28b7927 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java @@ -1,4 +1,5 @@ -/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others. +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -9,12 +10,29 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.views; -import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.internal.progress.PendingUpdateAdapter;
import org.eclipse.ui.progress.DeferredTreeContentManager;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
import org.eclipse.ui.progress.IElementCollector;
import org.eclipse.ui.progress.WorkbenchJob;
/** - * A remote content manager that merges content into a tree rather then replacing
* its children with a "pending" node, and then the real children when they are available.
* This avoids collapsing the viewer when a refresh is performed. This implementation is
* currently tied to the <code>RemoteTreeViewer</code>.
*
* @since 3.1 +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.internal.progress.PendingUpdateAdapter; +import org.eclipse.ui.progress.DeferredTreeContentManager; +import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; +import org.eclipse.ui.progress.IElementCollector; +import org.eclipse.ui.progress.WorkbenchJob; +/** + * A remote content manager that merges content into a tree rather then replacing + * its children with a "pending" node, and then the real children when they are available. + * This avoids collapsing the viewer when a refresh is performed. This implementation is + * currently tied to the <code>RemoteTreeViewer</code>. + * + * @since 3.1 */ public class RemoteTreeContentManager extends DeferredTreeContentManager { - private RemoteTreeViewer fViewer;
+ private RemoteTreeViewer fViewer; + /** * Contructs a new content manager. * @@ -122,15 +140,18 @@ public class RemoteTreeContentManager extends DeferredTreeContentManager { return Status.OK_STATUS; } }; - updateJob.setSystem(true);
updateJob.setPriority(Job.INTERACTIVE); + updateJob.setSystem(true); + updateJob.setPriority(Job.INTERACTIVE); updateJob.schedule(); } /** - * Create a UIJob to prune the children of the parent in the tree viewer, starting
* at the given offset. + * Create a UIJob to prune the children of the parent in the tree viewer, starting + * at the given offset. * * @param parent the parent for which children should be pruned - * @param offset the offset at which children should be pruned. All children at and after
* this index will be removed from the tree. + * @param offset the offset at which children should be pruned. All children at and after + * this index will be removed from the tree. * @param monitor */ protected void prune(final Object parent, final int offset) { @@ -151,6 +172,18 @@ public class RemoteTreeContentManager extends DeferredTreeContentManager { return Status.OK_STATUS; } }; - updateJob.setSystem(true);
updateJob.setPriority(Job.INTERACTIVE); + updateJob.setSystem(true); + updateJob.setPriority(Job.INTERACTIVE); updateJob.schedule(); - }
/* (non-Javadoc)
* @see org.eclipse.ui.progress.DeferredTreeContentManager#runClearPlaceholderJob(org.eclipse.ui.internal.progress.PendingUpdateAdapter)
*/
protected void runClearPlaceholderJob(PendingUpdateAdapter placeholder) {
// the placeholder is not used when there were already children in the tree (null)
if (placeholder != null) {
super.runClearPlaceholderJob(placeholder);
}
}
} + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.DeferredTreeContentManager#runClearPlaceholderJob(org.eclipse.ui.internal.progress.PendingUpdateAdapter) + */ + protected void runClearPlaceholderJob(PendingUpdateAdapter placeholder) { + // the placeholder is not used when there were already children in the tree (null) + if (placeholder != null) { + super.runClearPlaceholderJob(placeholder); + } + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java index b902b2671..cf0838ddb 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java @@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.ILaunch; -import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Item; @@ -40,6 +40,7 @@ public class RemoteTreeViewer extends TreeViewer { private ExpansionJob fExpansionJob = null; private SelectionJob fSelectionJob = null; + private StateRestorationJob fStateRestorationJob = new StateRestorationJob(DebugUIViewsMessages.getString("RemoteTreeViewer.0")); //$NON-NLS-1$ class ExpansionJob extends UIJob { @@ -54,6 +55,7 @@ public class RemoteTreeViewer extends TreeViewer { */ public ExpansionJob(Object target, Object lock) { super(DebugUIViewsMessages.getString("LaunchViewer.1")); //$NON-NLS-1$ + setPriority(Job.INTERACTIVE); element = target; parents = new ArrayList(); this.lock = lock; @@ -105,7 +107,8 @@ public class RemoteTreeViewer extends TreeViewer { class SelectionJob extends UIJob { - private Object element; + private IStructuredSelection selection; + private Object first; private List parents; // top down private Object lock; @@ -114,12 +117,14 @@ public class RemoteTreeViewer extends TreeViewer { * * @param target the element to select */ - public SelectionJob(Object target, Object lock) { + public SelectionJob(IStructuredSelection sel, Object lock) { super(DebugUIViewsMessages.getString("LaunchViewer.0")); //$NON-NLS-1$ - element = target; + setPriority(Job.INTERACTIVE); + selection = sel; + first = selection.getFirstElement(); parents = new ArrayList(); this.lock = lock; - addAllParents(parents, element); + addAllParents(parents, first); } /* (non-Javadoc) @@ -143,8 +148,8 @@ public class RemoteTreeViewer extends TreeViewer { } } if (allParentsExpanded) { - if (findItem(element) != null) { - setSelection(new StructuredSelection(element), true); + if (findItem(first) != null) { + setSelection(selection, true); fSelectionJob = null; return Status.OK_STATUS; } @@ -154,13 +159,27 @@ public class RemoteTreeViewer extends TreeViewer { } public void validate(Object object) { - if (element.equals(object) || parents.contains(object)) { + if (first.equals(object) || parents.contains(object)) { cancel(); fSelectionJob = null; } } } + private class StateRestorationJob extends UIJob { + public StateRestorationJob(String name) { + super(name); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + public IStatus runInUIThread(IProgressMonitor monitor) { + restoreExpansionState(); + return Status.OK_STATUS; + } + + } /** * Constructs a remote tree viewer parented by the given composite. * @@ -169,16 +188,35 @@ public class RemoteTreeViewer extends TreeViewer { public RemoteTreeViewer(Composite parent) { super(parent); } - - + /** + * Constructs a remote tree viewer parented by the given composite + * with the given style. + * + * @param parent parent composite + * @param style style bits + */ + public RemoteTreeViewer(Composite parent, int style) { + super(parent, style); + } + + /** + * Constructs a remote tree viewer with the given tree. + * + * @param tree tree widget + */ + public RemoteTreeViewer(Tree tree) { + super(tree); + } + protected void runDeferredUpdates() { if (fExpansionJob != null) { fExpansionJob.schedule(); } - if (fSelectionJob != null) { - fSelectionJob.schedule(); - } + if (fSelectionJob != null) { + fSelectionJob.schedule(); + } + fStateRestorationJob.schedule(); } /** @@ -197,26 +235,6 @@ public class RemoteTreeViewer extends TreeViewer { } } } - - /** - * Constructs a remote tree viewer parented by the given composite - * with the given style. - * - * @param parent parent composite - * @param style style bits - */ - public RemoteTreeViewer(Composite parent, int style) { - super(parent, style); - } - - /** - * Constructs a remote tree viewer with the given tree. - * - * @param tree tree widget - */ - public RemoteTreeViewer(Tree tree) { - super(tree); - } /* (non-Javadoc) * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object) @@ -274,18 +292,19 @@ public class RemoteTreeViewer extends TreeViewer { } } } - - public synchronized void setDeferredSelection(Object element) { - if (findItem(element) == null) { + + public synchronized void deferSelection(IStructuredSelection selection) { + Object element = selection.getFirstElement(); + if (!selection.isEmpty() && findItem(element) == null) { if (fSelectionJob != null) { fSelectionJob.cancel(); } - fSelectionJob = new SelectionJob(element, this); + fSelectionJob = new SelectionJob(selection, this); fSelectionJob.schedule(); } else { - setSelection(new StructuredSelection(element), true); + setSelection(selection, true); } - } + } private void cancel(Job job) { if (job != null) { @@ -308,47 +327,42 @@ public class RemoteTreeViewer extends TreeViewer { } } - - public Object[] filter(Object[] elements) { return super.filter(elements); } - - - + public Object[] getCurrentChildren(Object parent) { Widget widget = findItem(parent); if (widget != null) { Item[] items = getChildren(widget); Object[] children = new Object[items.length]; for (int i = 0; i < children.length; i++) { - Object data = items[i].getData(); - if (data == null) { - data = new Object(); - } - children[i] = data; + Object data = items[i].getData(); + if (data == null) { + return null; + } + children[i] = data; } return children; } return null; } - - public synchronized void prune(final Object parent, final int offset) { - preservingSelection(new Runnable() { - public void run() { - Widget widget = findItem(parent); - if (widget != null) { - Item[] currentChildren = getChildren(widget); - for (int i = offset; i < currentChildren.length; i++) { - disassociate(currentChildren[i]); - currentChildren[i].dispose(); - } - } + Widget widget = findItem(parent); + if (widget != null) { + final Item[] currentChildren = getChildren(widget); + if (offset < currentChildren.length) { + preservingSelection(new Runnable() { + public void run() { + for (int i = offset; i < currentChildren.length; i++) { + disassociate(currentChildren[i]); + currentChildren[i].dispose(); + } + } + }); } - }); - + } } public synchronized void replace(final Object parent, final Object[] children, final int offset) { @@ -399,6 +413,9 @@ public class RemoteTreeViewer extends TreeViewer { }); } + protected synchronized void restoreExpansionState() { + } + } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java index 5098032f5..03f19f2c6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java @@ -23,7 +23,6 @@ import org.eclipse.debug.internal.ui.VariablesViewModelPresentation; import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages; import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition; import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider; import org.eclipse.debug.internal.ui.views.variables.VariablesViewer; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; @@ -49,6 +48,7 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; /** @@ -100,7 +100,7 @@ public class ExpressionInformationControl extends PopupInformationControl { viewer.addFilter(filters[i]); } } - ((VariablesViewContentProvider)viewer.getContentProvider()).setShowLogicalStructure(view.isShowLogicalStructure()); + ((RemoteExpressionsContentProvider)viewer.getContentProvider()).setShowLogicalStructure(view.isShowLogicalStructure()); Map map = view.getPresentationAttributes(exp.getModelIdentifier()); Iterator iterator = map.keySet().iterator(); while (iterator.hasNext()) { @@ -180,9 +180,18 @@ public class ExpressionInformationControl extends PopupInformationControl { sashForm = new SashForm(composite, parent.getStyle()); sashForm.setOrientation(SWT.VERTICAL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); - + + page = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage(); + VariablesView view = getViewToEmulate(); + IWorkbenchPartSite site = null; + if (view != null) { + site = view.getSite(); + } else { + site = page.getActivePart().getSite(); + } + viewer = new VariablesViewer(sashForm, SWT.NO_TRIM); - viewer.setContentProvider(new ExpressionPopupContentProvider()); + viewer.setContentProvider(new ExpressionPopupContentProvider(viewer, site, view)); modelPresentation = new VariablesViewModelPresentation(); viewer.setLabelProvider(modelPresentation); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java index 4114ca294..c0cc13fff 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java @@ -10,15 +10,18 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.views.expression; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; +import org.eclipse.debug.internal.ui.views.variables.VariablesView; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.ui.IWorkbenchPartSite; -public class ExpressionPopupContentProvider extends ExpressionViewContentProvider { +public class ExpressionPopupContentProvider extends RemoteExpressionsContentProvider { private Object input = null; - public ExpressionPopupContentProvider() { - super(null); + public ExpressionPopupContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { + super(viewer, site, view); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java index 332073f47..3f1cf3ef7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java @@ -22,8 +22,8 @@ import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler; import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider; import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider; import org.eclipse.debug.internal.ui.views.variables.VariablesViewMessages; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.IMenuManager; @@ -34,11 +34,14 @@ import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IMemento; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPart; @@ -61,7 +64,7 @@ public class ExpressionView extends VariablesView { if (element instanceof IErrorReportingExpression) { expression= (IErrorReportingExpression) element; } else if (element instanceof String) { - Object parent= ((VariablesViewContentProvider) getVariablesViewer().getContentProvider()).getParent(element); + Object parent= ((ITreeContentProvider)getVariablesViewer().getContentProvider()).getParent(element); if (parent instanceof IErrorReportingExpression) { expression= (IErrorReportingExpression) parent; } @@ -91,8 +94,8 @@ public class ExpressionView extends VariablesView { * * @return a content provider */ - protected IContentProvider createContentProvider() { - return new ExpressionViewContentProvider(this); + protected IContentProvider createContentProvider(Viewer viewer) { + return new RemoteExpressionsContentProvider((RemoteTreeViewer)viewer, getSite(), this); } /** @@ -230,4 +233,14 @@ public class ExpressionView extends VariablesView { setInitialContent(); } + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#restoreState() + */ + protected void restoreState() { + } + /* (non-Javadoc) + * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento) + */ + public void saveState(IMemento memento) { + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java new file mode 100644 index 000000000..206ccf19e --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.expression; + +import org.eclipse.debug.core.IExpressionManager; +import org.eclipse.debug.core.model.IExpression; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; +import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider; +import org.eclipse.debug.internal.ui.views.variables.VariablesView; +import org.eclipse.ui.IWorkbenchPartSite; + +public class RemoteExpressionsContentProvider extends RemoteVariablesContentProvider { + + /** + * @param viewer + * @param site + * @param view + */ + public RemoteExpressionsContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { + super(viewer, site, view); + } + + public Object[] getChildren(Object parent) { + if (parent instanceof IExpressionManager) { + return ((IExpressionManager)parent).getExpressions(); + } + if (parent instanceof IExpression) { + return super.getChildren(parent); + } + return super.getChildren(parent); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + public boolean hasChildren(Object element) { + if (element instanceof IExpressionManager) { + IExpressionManager manager = (IExpressionManager) element; + return manager.hasExpressions(); + } + if (element instanceof IExpression) { + return true; + } + return super.hasChildren(element); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java index c71665151..00ebf9c54 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java @@ -54,6 +54,9 @@ public class DebugViewContentProvider extends BaseWorkbenchContentProvider imple * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ public Object[] getChildren(Object parentElement) { + if (parentElement instanceof IStackFrame) { + return null; + } Object[] children = null; if (fUseDeferredContent) { children = fManager.getChildren(parentElement); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DeferredContentAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DeferredContentAdapterFactory.java index 3be146294..bca250c1d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DeferredContentAdapterFactory.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DeferredContentAdapterFactory.java @@ -12,7 +12,13 @@ package org.eclipse.debug.internal.ui.views.launch; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IExpression; +import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.internal.ui.views.variables.DeferredExpression; +import org.eclipse.debug.internal.ui.views.variables.DeferredStackFrame; +import org.eclipse.debug.internal.ui.views.variables.DeferredVariable; import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; /** @@ -32,6 +38,15 @@ public class DeferredContentAdapterFactory implements IAdapterFactory { if (adaptableObject instanceof IThread) { return new DeferredThread(); } + if (adaptableObject instanceof IStackFrame) { + return new DeferredStackFrame(); + } + if (adaptableObject instanceof IVariable) { + return new DeferredVariable(); + } + if (adaptableObject instanceof IExpression) { + return new DeferredExpression(); + } } return null; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java index 69ab44aa5..e3ced452c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java @@ -781,7 +781,7 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect LaunchViewer launchViewer = (LaunchViewer)getViewer(); launchViewer.deferExpansion(element); if (selectNeeded) { - launchViewer.setDeferredSelection(element); + launchViewer.deferSelection(new StructuredSelection(element)); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java index 3a3eca60f..4a1cca964 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java @@ -29,6 +29,7 @@ import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler; +import org.eclipse.jface.viewers.StructuredSelection; /** * Handles debug events, updating the launch view and viewer. @@ -233,7 +234,7 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements getLaunchViewer().update(new Object[] {thread, frame}, null); if (!evaluationEvent) { getLaunchViewer().deferExpansion(thread); - getLaunchViewer().setDeferredSelection(frame); + getLaunchViewer().deferSelection(new StructuredSelection(frame)); } else if (wasTimedOut) { getLaunchView().showEditorForCurrentSelection(); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java index 8186de4fe..1e87118b8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java @@ -98,6 +98,7 @@ public class LaunchViewer extends RemoteTreeViewer { treeItem.setForeground(cp.getForeground(element)); treeItem.setBackground(cp.getBackground(element)); } + } /* (non-Javadoc) @@ -109,5 +110,5 @@ public class LaunchViewer extends RemoteTreeViewer { super.refresh(element); getControl().setRedraw(true); } - + }
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewTabCursorManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewTabCursorManager.java index 504c80c10..84c88e837 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewTabCursorManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewTabCursorManager.java @@ -12,6 +12,7 @@ package org.eclipse.debug.internal.ui.views.memory; import java.math.BigInteger; + import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.internal.ui.DebugUIMessages; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java index f0677067a..2fe9815f2 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java @@ -18,6 +18,7 @@ import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.Viewer; /** * Displays registers and their values with a detail area. @@ -27,7 +28,7 @@ public class RegistersView extends VariablesView { /** * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createContentProvider() */ - protected IContentProvider createContentProvider() { + protected IContentProvider createContentProvider(Viewer viewer) { RegistersViewContentProvider cp = new RegistersViewContentProvider(this); cp.setExceptionHandler(this); return cp; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredExpression.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredExpression.java new file mode 100644 index 000000000..f1db331d8 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredExpression.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.variables; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.IExpressionManager; +import org.eclipse.debug.core.model.IErrorReportingExpression; +import org.eclipse.debug.core.model.IExpression; +import org.eclipse.debug.core.model.IValue; +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.ui.progress.IElementCollector; + +public class DeferredExpression extends DeferredVariable { + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor) + */ + public void fetchDeferredChildren(Object parent, IElementCollector collector, IProgressMonitor monitor) { + Object[] children= null; + try { + if (parent instanceof IExpressionManager) { + children = ((IExpressionManager)parent).getExpressions(); + } else if (parent instanceof IExpression) { + if (parent instanceof IErrorReportingExpression) { + IErrorReportingExpression expression= (IErrorReportingExpression) parent; + if (expression.hasErrors()) { + children= expression.getErrorMessages(); + } + } + if (children == null) { + IExpression expression = (IExpression)parent; + IValue value = expression.getValue(); + children = getValueChildren(expression, value); + } + } else if (parent instanceof IVariable) { + super.fetchDeferredChildren(parent, collector, monitor); + return; + } + } catch (DebugException de) { + DebugUIPlugin.log(de); + } + + if (children == null) { + children = new Object[0]; + } + collector.add(children, monitor); + collector.done(); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredLogicalStructure.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredLogicalStructure.java new file mode 100644 index 000000000..a01eafde9 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredLogicalStructure.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.variables; + + + +/** + * Default deferred content provider for a variable + */ +public class DeferredLogicalStructure extends DeferredVariable { + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.variables.DeferredVariable#isShowLogicalStructure() + */ + protected boolean isShowLogicalStructure() { + return true; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredStackFrame.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredStackFrame.java new file mode 100644 index 000000000..fb3aea26d --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredStackFrame.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.variables; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.ui.DebugElementWorkbenchAdapter; +import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; +import org.eclipse.ui.progress.IElementCollector; + + +/** + * Default deferred content provider for a stack frame + */ +public class DeferredStackFrame extends DebugElementWorkbenchAdapter implements IDeferredWorkbenchAdapter { + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor) + */ + public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { + IStackFrame frame = (IStackFrame) object; + try { + IVariable[] variables = frame.getVariables(); + collector.add(variables, monitor); + } catch (DebugException e) { + } + collector.done(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer() + */ + public boolean isContainer() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#getRule(java.lang.Object) + */ + public ISchedulingRule getRule(Object object) { + return null; + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredVariable.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredVariable.java new file mode 100644 index 000000000..013b3e689 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/DeferredVariable.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.variables; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILogicalStructureType; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.core.model.IIndexedValue; +import org.eclipse.debug.core.model.IValue; +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.ui.DebugElementWorkbenchAdapter; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; +import org.eclipse.ui.progress.IElementCollector; + + +/** + * Default deferred content provider for a variable + */ +public class DeferredVariable extends DebugElementWorkbenchAdapter implements IDeferredWorkbenchAdapter { + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor) + */ + public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { + IVariable variable = (IVariable) object; + try { + IValue value = variable.getValue(); + if (value != null) { + IVariable[] variables = getValueChildren(variable, value); + collector.add(variables, monitor); + } + } catch (DebugException e) { + // TODO: exception handler from variables view? + } + collector.done(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer() + */ + public boolean isContainer() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#getRule(java.lang.Object) + */ + public ISchedulingRule getRule(Object object) { + return null; + } + + /** + * Returns children for the given value, creating array paritions if required + * + * @param parent expression or variable containing the given value + * @param value the value to retrieve children for + * @return children for the given value, creating array paritions if required + * @throws DebugException + */ + protected IVariable[] getValueChildren(IDebugElement parent, IValue value) throws DebugException { + if (value == null) { + return null; + } + IValue logicalValue = getLogicalValue(value); + if (logicalValue instanceof IIndexedValue) { + IIndexedValue indexedValue = (IIndexedValue)logicalValue; + int partitionSize = computeParitionSize(indexedValue); + if (partitionSize > 1) { + int offset = indexedValue.getInitialOffset(); + int length = indexedValue.getSize(); + int numPartitions = length / partitionSize; + int remainder = length % partitionSize; + if (remainder > 0) { + numPartitions++; + } + IVariable[] partitions = new IVariable[numPartitions]; + for (int i = 0; i < (numPartitions - 1); i++) { + partitions[i] = new IndexedVariablePartition(parent, indexedValue, offset, partitionSize); + offset = offset + partitionSize; + } + if (remainder == 0) { + remainder = partitionSize; + } + partitions[numPartitions - 1] = new IndexedVariablePartition(parent, indexedValue, offset, remainder); + return partitions; + } + } + if (logicalValue == null) { + // safeguard against an structure type returning null + logicalValue = value; + } + return logicalValue.getVariables(); + } + + /** + * Returns any logical value for the raw value. + * + * @param value + * @return + */ + protected IValue getLogicalValue(IValue value) { + if (isShowLogicalStructure()) { + ILogicalStructureType[] types = DebugPlugin.getLogicalStructureTypes(value); + if (types.length > 0) { + IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); + ILogicalStructureType type = null; + boolean exist = false; + for (int i = 0; i < types.length; i++) { + String key = VariablesView.LOGICAL_STRUCTURE_TYPE_PREFIX + types[i].getId(); + int setting = store.getInt(key); + // 0 = never used, 1 = on, -1 = off + if (setting != 0) { + exist = true; + if (setting == 1) { + type = types[i]; + break; + } + } else { + store.setValue(key, -1); + } + } + if (type == null && !exist) { + type = types[0]; + // choose first by default + store.setValue(VariablesView.LOGICAL_STRUCTURE_TYPE_PREFIX + type.getId(), 1); + } + if (type != null) { + try { + return type.getLogicalStructure(value); + } catch (CoreException e) { + // unable to display logical structure + } + } + } + } + return value; + } + + /** + * Return wether to show compute a logical structure or a raw structure. + * + * @return wether to show compute a logical structure or a raw structure + */ + protected boolean isShowLogicalStructure() { + return false; + } + + /** + * Returns the partition size to use for the given indexed value. + * The partition size is computed by determining the number of levels + * that an indexed collection must be nested in order to partition + * the collection sub-collections of the preferred partition size. + * + * @param value indexed value + * @return size of paritions the value should be subdivided into + */ + protected int computeParitionSize(IIndexedValue value) { + int partitionSize = 1; + try { + int length = value.getSize(); + int partitionDepth = 0; + int preferredSize = getArrayPartitionSize(); + int remainder = length % preferredSize; + length = length / preferredSize; + while (length > 0) { + if (remainder == 0 && length == 1) { + break; + } + partitionDepth++; + remainder = length % preferredSize; + length = length / preferredSize; + } + for (int i = 0; i < partitionDepth; i++) { + partitionSize = partitionSize * preferredSize; + } + } catch (DebugException e) { + } + return partitionSize; + } + + /** + * Returns the number of entries that should be displayed in each + * partition of an indexed collection. + * + * @return the number of entries that should be displayed in each + * partition of an indexed collection + */ + protected int getArrayPartitionSize() { + // TODO: should fix this with a user pref + return 100; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java new file mode 100644 index 000000000..abc844834 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.variables; + +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; + +/** + * Remote content manager for variables. Creates an appropriate adapter for + * logical structures. + */ +public class RemoteVariableContentManager extends RemoteTreeContentManager { + + private VariablesView fView; + + /** + * Constructs a remote content manager for a variables view. + */ + public RemoteVariableContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { + super(provider, viewer, site); + fView = view; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.DeferredTreeContentManager#getAdapter(java.lang.Object) + */ + protected IDeferredWorkbenchAdapter getAdapter(Object element) { + // TODO: expressions & registers? + if (element instanceof IVariable && fView !=null && fView.isShowLogicalStructure()) { + return new DeferredLogicalStructure(); + } + return super.getAdapter(element); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java new file mode 100644 index 000000000..2f4a65888 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java @@ -0,0 +1,241 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.variables; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.core.model.IValue; +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.model.BaseWorkbenchContentProvider; +import org.eclipse.ui.progress.DeferredTreeContentManager; + +/** + * Provide the contents for a variables viewer. + */ +public class RemoteVariablesContentProvider extends BaseWorkbenchContentProvider { + + /** + * A table that maps children to their parent element + * such that this content provider can walk back up the + * parent chain (since values do not know their + * parent). + * Map of <code>IVariable</code> (child) -> <code>IVariable</code> (parent). + */ + private HashMap fParentCache; + + /** + * Handler for exceptions as content is retrieved + */ + private IDebugExceptionHandler fExceptionHandler = null; + + /** + * Flag indicating whether contributed content providers should be used or not. + */ + private boolean fUseObjectBrowsers; + + /** + * Remote content manager to retrieve content in the background. + */ + private DeferredTreeContentManager fManager; + + /** + * Constructs a new provider + */ + public RemoteVariablesContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { + fManager = new RemoteVariableContentManager(this, viewer, site, view); + fParentCache = new HashMap(10); + } + + /** + * @see ITreeContentProvider#getChildren(Object) + */ + public Object[] getChildren(Object parent) { + Object[] children = fManager.getChildren(parent); + if (children == null) { + children = super.getChildren(parent); + } + if (children != null) { + cache(parent, children); + return children; + } + return new Object[0]; + } + + /** + * Caches the given elememts as children of the given + * parent. + * + * @param parent parent element + * @param children children elements + */ + protected void cache(Object parent, Object[] children) { + for (int i = 0; i < children.length; i++) { + Object child = children[i]; + // avoid cycles in the cache, which can happen for + // recursive data structures + if (!fParentCache.containsKey(child)) { + fParentCache.put(child, parent); + } + } + } + + /** + * @see ITreeContentProvider#getParent(Object) + */ + public Object getParent(Object item) { + return fParentCache.get(item); + } + + /** + * Unregisters this content provider from the debug plugin so that + * this object can be garbage-collected. + */ + public void dispose() { + fParentCache= null; + setExceptionHandler(null); + } + + protected void clearCache() { + if (fParentCache != null) { + fParentCache.clear(); + } + } + + /** + * Remove the cached parent for the given children + * + * @param children for which to remove cached parents + */ + public void removeCache(Object[] children) { + if (fParentCache == null) { + return; + } + for (int i = 0; i < children.length; i++) { + fParentCache.remove(children[i]); + } + } + + /** + * @see ITreeContentProvider#hasChildren(Object) + */ + public boolean hasChildren(Object element) { + try { + if (element instanceof IVariable) { + if (element instanceof IndexedVariablePartition) { + return true; + } + element = ((IVariable)element).getValue(); + } + if (element instanceof IValue) { + return ((IValue)element).hasVariables(); + } + if (element instanceof IStackFrame) { + return ((IStackFrame)element).hasVariables(); + } + } catch (DebugException de) { + return false; + } + return false; + } + + /** + * @see IContentProvider#inputChanged(Viewer, Object, Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + clearCache(); + } + + /** + * Return all cached decendants of the given parent. + * + * @param parent the element whose decendants are to be calculated + * @return list of decendants that have been cached for + * the given parent + */ + public List getCachedDecendants(Object parent) { + Iterator children = fParentCache.keySet().iterator(); + List cachedChildren = new ArrayList(10); + while (children.hasNext()) { + Object child = children.next(); + if (isCachedDecendant(child, parent)) { + cachedChildren.add(child); + } + } + return cachedChildren; + } + + /** + * Returns whether the given child is a cached descendant + * of the given parent. + * + * @return whether the given child is a cached descendant + * of the given parent + */ + protected boolean isCachedDecendant(Object child, Object parent) { + Object p = getParent(child); + while (p != null) { + if (p.equals(parent)) { + return true; + } + p = getParent(p); + } + return false; + } + + /** + * Extract the debug model id from the specified <code>IDebugElement</code> + * and return it. + */ + protected String getDebugModelId(IDebugElement debugElement) { + return debugElement.getModelIdentifier(); + } + + /** + * Sets an exception handler for this content provider. + * + * @param handler debug exception handler or <code>null</code> + */ + protected void setExceptionHandler(IDebugExceptionHandler handler) { + fExceptionHandler = handler; + } + + /** + * Returns the exception handler for this content provider. + * + * @return debug exception handler or <code>null</code> + */ + protected IDebugExceptionHandler getExceptionHandler() { + return fExceptionHandler; + } + + /** + * Show logical structure of values + */ + public void setShowLogicalStructure(boolean flag) { + fUseObjectBrowsers = flag; + } + + public boolean isShowLogicalStructure() { + return fUseObjectBrowsers; + } + +} + 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 db59b2c06..c2bdcb1b9 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 @@ -47,6 +47,8 @@ import org.eclipse.debug.internal.ui.views.DebugViewDecoratingLabelProvider; import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider; import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator; import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler; +import org.eclipse.debug.internal.ui.views.IRemoteTreeViewerUpdateListener; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IValueDetailListener; @@ -337,6 +339,10 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel private final PositionLabelValue fColumnLabel= new PositionLabelValue(); /** The arguments for the position label pattern. */ private final Object[] fPositionLabelPatternArguments= new Object[] { fLineLabel, fColumnLabel }; + /** Whether logical structuers are showing */ + private boolean fShowLogical; + + private IRemoteTreeViewerUpdateListener fUpdateListener; /** * Remove myself as a selection listener @@ -352,6 +358,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel Viewer viewer = getViewer(); if (viewer != null) { getDetailDocument().removeDocumentListener(getDetailDocumentListener()); + ((VariablesViewer)viewer).removeUpdateListener(fUpdateListener); } super.dispose(); } @@ -388,19 +395,22 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel } showViewer(); getViewer().setInput(frame); - - // restore state - if (frame != null) { - AbstractViewerState state = (AbstractViewerState)fSelectionStates.get(frame); - if (state == null) { - // attempt to restore selection/expansion based on last frame - state = fLastState; - } - if (state != null) { - state.restoreState(getVariablesViewer()); - } - } } + + protected void restoreState() { + VariablesViewer viewer = getVariablesViewer(); + IStackFrame frame = (IStackFrame) viewer.getInput(); + if (frame != null) { + AbstractViewerState state = (AbstractViewerState)fSelectionStates.get(frame); + if (state == null) { + // attempt to restore selection/expansion based on last frame + state = fLastState; + } + if (state != null) { + state.restoreState(viewer); + } + } + } /** * Returns the variables viewer for this view @@ -530,6 +540,12 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel } setDetailPaneOrientation(orientation); + fUpdateListener = new IRemoteTreeViewerUpdateListener() { + public void treeUpdated() { + restoreState(); + } + }; + ((VariablesViewer)variablesViewer).addUpdateListener(fUpdateListener); return variablesViewer; } @@ -589,7 +605,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel // add tree viewer final TreeViewer variablesViewer = new VariablesViewer(getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); - variablesViewer.setContentProvider(createContentProvider()); + variablesViewer.setContentProvider(createContentProvider(variablesViewer)); variablesViewer.setLabelProvider(createLabelProvider(variablesViewer)); variablesViewer.setUseHashlookup(true); variablesViewer.getControl().addFocusListener(new FocusAdapter() { @@ -665,10 +681,10 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel * * @return a content provider */ - protected IContentProvider createContentProvider() { - VariablesViewContentProvider cp = new VariablesViewContentProvider(this); - cp.setExceptionHandler(this); - return cp; + protected IContentProvider createContentProvider(Viewer viewer) { + return new RemoteVariablesContentProvider((RemoteTreeViewer) viewer, getSite(), this); + // TODO: exception handler + //cp.setExceptionHandler(this); } /** @@ -1345,14 +1361,14 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel * Sets whether logical structures are being displayed */ public void setShowLogicalStructure(boolean flag) { - ((VariablesViewContentProvider)getStructuredViewer().getContentProvider()).setShowLogicalStructure(flag); + fShowLogical = flag; } /** * Returns whether logical structures are being displayed */ public boolean isShowLogicalStructure() { - return ((VariablesViewContentProvider)getStructuredViewer().getContentProvider()).isShowLogicalStructure(); + return fShowLogical; } /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java index 3924ec30e..2a868172e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java @@ -11,11 +11,15 @@ package org.eclipse.debug.internal.ui.views.variables; +import java.util.ArrayList; +import java.util.Iterator; + import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider; +import org.eclipse.debug.internal.ui.views.IRemoteTreeViewerUpdateListener; +import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; import org.eclipse.jface.viewers.IColorProvider; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Item; @@ -27,9 +31,11 @@ import org.eclipse.swt.widgets.Widget; * Variables viewer. As the user steps through code, this * we ensure that newly added varibles are visible. */ -public class VariablesViewer extends TreeViewer { +public class VariablesViewer extends RemoteTreeViewer { private Item fNewItem; + + private ArrayList fUpdateListeners = new ArrayList(); /** * Constructor for VariablesViewer. @@ -148,4 +154,23 @@ public class VariablesViewer extends TreeViewer { } } + + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.RemoteTreeViewer#restoreExpansionState() + */ + protected synchronized void restoreExpansionState() { + cancelJobs(); + for (Iterator i = fUpdateListeners.iterator(); i.hasNext();) { + IRemoteTreeViewerUpdateListener listener = (IRemoteTreeViewerUpdateListener) i.next(); + listener.treeUpdated(); + } + } + + public void addUpdateListener(IRemoteTreeViewerUpdateListener listener) { + fUpdateListeners.add(listener); + } + public void removeUpdateListener(IRemoteTreeViewerUpdateListener listener) { + fUpdateListeners.remove(listener); + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java index 08d12ae5e..0888a7436 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java @@ -62,6 +62,9 @@ public class ViewerState extends AbstractViewerState { Object[] children = contentProvider.getChildren(parent); String name = names[i]; for (int j = 0; j < children.length; j++) { + if (!(children[j] instanceof IVariable)) { + continue; + } IVariable var = (IVariable)children[j]; if (var.getName().equals(name)) { variable = var; |