diff options
author | Darin Wright | 2007-08-20 19:05:10 +0000 |
---|---|---|
committer | Darin Wright | 2007-08-20 19:05:10 +0000 |
commit | 915e49c30214e6279a4a9fb91a7c70f963c6a256 (patch) | |
tree | 0b6e7d5436cb5e72cd0d8147a28bad158d02d329 /org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java | |
parent | 38f0eda6752aff71557ebcd7677d8e2bb3e0a66f (diff) | |
download | eclipse.platform.debug-915e49c30214e6279a4a9fb91a7c70f963c6a256.tar.gz eclipse.platform.debug-915e49c30214e6279a4a9fb91a7c70f963c6a256.tar.xz eclipse.platform.debug-915e49c30214e6279a4a9fb91a7c70f963c6a256.zip |
Bug 176627 - [Registers view] Switching stack frames: Unnecessary scrolling to top and group closing
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java')
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java new file mode 100644 index 000000000..9c69c018c --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java @@ -0,0 +1,128 @@ +package org.eclipse.debug.internal.ui.viewers.model; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.internal.core.commands.Request; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate; +import org.eclipse.jface.viewers.TreePath; +import org.eclipse.ui.progress.WorkbenchJob; + +/** + * Internal implementation of the {@link IViewerInputUpdate} interface. Allows + * implementors to translate the active debug context into an appropriate viewer + * input. + * + * @since 3.4 + * @see IViewerInputUpdate + */ +public class ViewerInputUpdate extends Request implements IViewerInputUpdate { + + /** + * Presentation context + */ + private IPresentationContext fContext; + + /** + * New viewer input + */ + private Object fSource; + + /** + * Whether this update is done + */ + private boolean fDone; + + /** + * Viewer input to use + */ + private Object fInput; + + /** + * Client making request + */ + private IViewerInputRequestor fRequestor; + + /** + * When <code>done()</code> is called, the viewer must be informed that the update is complete in the UI thread. + */ + protected WorkbenchJob fViewerInputUpdateJob = new WorkbenchJob("Asynchronous viewer input update") { //$NON-NLS-1$ + public IStatus runInUIThread(IProgressMonitor monitor) { + fRequestor.viewerInputComplete(ViewerInputUpdate.this); + return Status.OK_STATUS; + } + }; + + /** + * Constructs a viewer input update request. + * + * @param context presentation context + * @param requestor client making the request + * @param source source from which to derive a viewer input + */ + public ViewerInputUpdate(IPresentationContext context, IViewerInputRequestor requestor, Object source){ + fContext = context; + fSource = source; + fRequestor = requestor; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#getPresentationContext() + */ + public IPresentationContext getPresentationContext() { + return fContext; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#done() + */ + public final void done() { + synchronized (this) { + if (isDone()) { + return; + } + fDone = true; + } + fViewerInputUpdateJob.schedule(); + } + + /** + * Returns whether this request is done yet. + * + * @return whether this request is done yet + */ + protected synchronized boolean isDone() { + return fDone; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#getElement() + */ + public Object getElement() { + return fSource; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElementPath() + */ + public TreePath getElementPath() { + return TreePath.EMPTY; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#setViewerInput(java.lang.Object) + */ + public void setViewerInput(Object element) { + fInput = element; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#getViewerInput() + */ + public Object getViewerInput() { + return fInput; + } + +} |