diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model')
28 files changed, 0 insertions, 2591 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java deleted file mode 100644 index 8dd7a59d3..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.internal.ui.DelegatingModelPresentation; -import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext; -import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper; -import org.eclipse.debug.ui.IDebugModelPresentation; -import org.eclipse.debug.ui.IDebugModelPresentationExtension; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.RGB; - -/** - * @since 3.3 - */ -public class DebugElementLabelProvider extends ElementLabelProvider { - - protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; - return debugContext.getModelPresentation().getText(element); - } - return DebugElementHelper.getLabel(element); - } - - protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; - return DebugElementHelper.getBackground(element, debugContext.getModelPresentation()); - } - return DebugElementHelper.getBackground(element); - } - - protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; - return DebugElementHelper.getFont(element, debugContext.getModelPresentation()); - - } - return DebugElementHelper.getFont(element); - } - - protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; - return DebugElementHelper.getForeground(element, debugContext.getModelPresentation()); - } - return DebugElementHelper.getForeground(element); - } - - protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; - return DebugElementHelper.getImageDescriptor(element, debugContext.getModelPresentation()); - } - return DebugElementHelper.getImageDescriptor(element); - } - - /** - * Returns the model presentation for the specified model, or <code>null</code> if none. - * - * @param context presentation context - * @param modelId debug model identifier - * @return debug model presentation or <code>null</code> - */ - protected IDebugModelPresentation getModelPresentation(IPresentationContext context, String modelId) { - if (context instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) context; - IDebugModelPresentation presentation = debugContext.getModelPresentation(); - if (presentation instanceof DelegatingModelPresentation) { - return ((DelegatingModelPresentation)presentation).getPresentation(modelId); - } - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#requiresUIJob(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate[]) - */ - protected boolean requiresUIJob(ILabelUpdate[] updates) { - if (updates.length > 0) { - ILabelUpdate update = updates[0]; - IPresentationContext context = update.getPresentationContext(); - if (context instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) context; - IDebugModelPresentation presentation = debugContext.getModelPresentation(); - if (presentation instanceof IDebugModelPresentationExtension) { - IDebugModelPresentationExtension extension = (IDebugModelPresentationExtension) presentation; - for (int i = 0; i < updates.length; i++) { - if (extension.requiresUIThread(updates[i].getElement())) { - return true; - } - } - } - } - } - return false; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementMementoProvider.java deleted file mode 100644 index 3340c752b..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementMementoProvider.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.ui.IMemento; - -/** - * Abstract memento provider debug elements. - * - * @since 3.4 - */ -public abstract class DebugElementMementoProvider extends ElementMementoProvider { - - protected static final String ELEMENT_NAME = "ELEMENT_NAME"; //$NON-NLS-1$ - - protected boolean encodeElement(Object element, IMemento memento, IPresentationContext context) throws CoreException { - if (supportsContext(context)) { - String name = getElementName(element, context); - memento.putString(ELEMENT_NAME, name); - return true; - } - return false; - } - - protected boolean isEqual(Object element, IMemento memento, IPresentationContext context) throws CoreException { - String mementoName = memento.getString(ELEMENT_NAME); - if (mementoName != null) { - String name = getElementName(element, context); - if (name != null) { - return name.equals(mementoName); - } - } - return false; - } - - /** - * Returns whether this adapter supports the given context. - * - * @param context - * @return whether this adapter supports the given context - */ - protected boolean supportsContext(IPresentationContext context) { - return supportsContextId(context.getId()); - } - - /** - * Returns whether this adapter provides content in the specified context id. - * - * @param id part id - * @return whether this adapter provides content in the specified context id - */ - protected boolean supportsContextId(String id) { - return true; - } - - /** - * Returns the name of the given element to use in a memento in the given context, - * or <code>null</code> if unsupported. - * - * @param element model element - * @param context presentation context - * @return element name or <code>null</code> if none - * @throws CoreException - */ - protected abstract String getElementName(Object element, IPresentationContext context) throws CoreException; -} 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 deleted file mode 100644 index f0a0bf838..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugTargetContentProvider.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.model.IDebugTarget; -import org.eclipse.debug.core.model.IMemoryBlockRetrieval; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * @since 3.3 - */ -public class DebugTargetContentProvider extends ElementContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - String id = context.getId(); - if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) - { - return ((IDebugTarget)element).getThreads().length; - } - else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - { - return getAllChildren(element, context, monitor).length; - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return IDebugUIConstants.ID_DEBUG_VIEW.equals(id) || IDebugUIConstants.ID_MEMORY_VIEW.equals(id); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(getAllChildren(parent, context, monitor), index, length); - } - - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - String id = context.getId(); - if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) - { - return ((IDebugTarget)element).hasThreads(); - } - else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - { - return getAllChildren(element, context, monitor).length > 0; - } - return false; - } - - protected Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - String id = context.getId(); - if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) - { - return ((IDebugTarget)parent).getThreads(); - } - else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - { - if (parent instanceof IMemoryBlockRetrieval) - { - if (((IMemoryBlockRetrieval)parent).supportsStorageRetrieval()) - return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent); - } - } - return EMPTY; - } - - -} 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 deleted file mode 100644 index d9c2166ef..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -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.debug.internal.ui.viewers.model.provisional.IViewerUpdate; - -/** - * @since 3.3 - */ -public abstract class ElementContentProvider implements IElementContentProvider { - - protected static final Object[] EMPTY = new Object[0]; - - /* (non-Javadoc) - * @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[] updates) { - Job job = new Job("children update") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - for (int i = 0; i < updates.length; i++) { - IChildrenUpdate update = updates[i]; - if (!update.isCanceled()) { - retrieveChildren(update); - } - update.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(getRule(updates)); - job.schedule(); - } - - /* (non-Javadoc) - * @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[] updates) { - Job job = new Job("child count update") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - for (int i = 0; i < updates.length; i++) { - IChildrenCountUpdate update = updates[i]; - if (!update.isCanceled()) { - retrieveChildCount(update); - } - update.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(getRule(updates)); - job.schedule(); - } - - /** - * Computes the children for the given parent in the specified context. - * - * @param update update request - */ - protected void retrieveChildren(IChildrenUpdate update) { - if (!update.isCanceled()) { - IStatus status = Status.OK_STATUS; - try { - IPresentationContext context = update.getPresentationContext(); - if (supportsContext(context)) { - int offset = update.getOffset(); - Object[] children = getChildren(update.getElement(), offset, update.getLength(), context, update); - if (!update.isCanceled() && children != null) { - for (int i = 0; i < children.length; i++) { - update.setChild(children[i], offset + i); - } - } - } - } catch (CoreException e) { - status = e.getStatus(); - } - update.setStatus(status); - } - } - - /** - * Computes whether the given element is a container. - * - * @param parent potential parent - * @param context presentation context - * @param monitor result to report to - */ - protected void retrieveChildCount(IChildrenCountUpdate update) { - if (!update.isCanceled()) { - IStatus status = Status.OK_STATUS; - try { - IPresentationContext context = update.getPresentationContext(); - if (supportsContext(context)) { - int childCount = getChildCount( update.getElement(), context, update); - if (!update.isCanceled()) { - update.setChildCount(childCount); - } - } else { - update.setChildCount(0); - } - } catch (CoreException e) { - status = e.getStatus(); - } - update.setStatus(status); - } - } - - /** - * Returns the children for the given parent at the specified index in the specified context - * or <code>null</code> if none. - * - * @param parent element to retrieve children for - * @param index child index - * @param length number of children to retrieve - * @param context context children will be presented in - * @return child or <code>null</code> - * @throws CoreException if an exception occurs retrieving child - */ - protected abstract Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException; - - /** - * Returns the number of children for the given element. - * - * @param elementPath element that may have children - * @param context context element will be presented in - * @return number of children - * @throws CoreException if an exception occurs determining child count - */ - protected abstract int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException; - - /** - * Returns whether this adapter supports the given context. - * - * @param context - * @return whether this adapter supports the given context - */ - protected boolean supportsContext(IPresentationContext context) { - return supportsContextId(context.getId()); - } - - /** - * Returns whether this adapter provides content in the specified context id. - * - * @param id part id - * @return whether this adapter provides content in the specified context id - */ - protected abstract boolean supportsContextId(String id); - - /** - * Returns the range of elements from <code>index</code> to <code>index + length</code> - * or <code>null</code> if the index and range is outside the bounds of the original element array. - * - * @param elements the original element array - * @param index the initial index to start copying from - * @param length the number of elements we want to copy into the returned array - * @return element or <code>null</code> - */ - protected Object[] getElements(Object[] elements, int index, int length) { - int max = elements.length; - if (index < max && ((index + length) > max)) { - length = max - index; - } - if ((index + length) <= elements.length) { - Object[] sub = new Object[length]; - System.arraycopy(elements, index, sub, 0, length); - return sub; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate[]) - */ - public void update(final IHasChildrenUpdate[] updates) { - Job job = new Job("has children update") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - for (int i = 0; i < updates.length; i++) { - IHasChildrenUpdate update = updates[i]; - if (!update.isCanceled()) { - updateHasChildren(update); - } - update.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(getRule(updates)); - 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(); - if (supportsContext(context)) { - boolean hasChildren = hasChildren(update.getElement(), context, update); - if (!update.isCanceled()) { - update.setHasChilren(hasChildren); - } - } else { - update.setHasChilren(false); - } - } catch (CoreException e) { - status = e.getStatus(); - } - update.setStatus(status); - } - - } - - /** - * 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, IViewerUpdate monitor) throws CoreException { - return getChildCount(element, context, monitor) > 0; - } - - /** - * Returns a scheduling rule to use when performing the given updates or - * <code>null</code> if none. - * - * @param updates - * @return scheduling rule or <code>null</code> if none - */ - protected ISchedulingRule getRule(IChildrenCountUpdate[] updates) { - return null; - } - - /** - * Returns a scheduling rule to use when performing the given updates or - * <code>null</code> if none. - * - * @param updates - * @return scheduling rule or <code>null</code> if none - */ - protected ISchedulingRule getRule(IChildrenUpdate[] updates) { - return null; - } - - /** - * Returns a scheduling rule to use when performing the given updates or - * <code>null</code> if none. - * - * @param updates - * @return scheduling rule or <code>null</code> if none - */ - protected ISchedulingRule getRule(IHasChildrenUpdate[] updates) { - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java deleted file mode 100644 index 0c867bd64..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java +++ /dev/null @@ -1,361 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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 - * Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310) - *******************************************************************************/ -package org.eclipse.debug.internal.ui.model.elements; - -import java.util.LinkedList; -import java.util.NoSuchElementException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider; -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.FontData; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.progress.UIJob; - -/** - * Implementation of a context sensitive label provider, which provides - * base functionality for subclasses such as label jobs and a basic label updater. - * - * @since 3.3.0.qualifier - */ -public abstract class ElementLabelProvider implements IElementLabelProvider { - - private Job fLabelJob = null; - - /** - * Describes a label job - */ - interface ILabelJob { - /** - * Returns whether the updates were queued. - * - * @param updates updates - * @return whether the updates were queued - */ - public boolean queue(ILabelUpdate[] updates); - } - - /** - * A <code>Job</code> to update labels. This <code>Job</code> can run - * in a non-UI thread. - */ - class LabelJob extends Job implements ILabelJob { - - private LabelUpdater fUpdater = new LabelUpdater(); - - public LabelJob() { - super("Label Job"); //$NON-NLS-1$ - setSystem(true); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus run(IProgressMonitor monitor) { - fUpdater.run(); - return Status.OK_STATUS; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider.ILabelJob#queue(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate) - */ - public boolean queue(ILabelUpdate[] updates) { - return fUpdater.queue(updates); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#shouldRun() - */ - public boolean shouldRun() { - return fUpdater.shouldRun(); - } - - } - - /** - * A <code>Job</code> to update labels. This <code>Job</code> runs - * only in the UI thread. - */ - class UILabelJob extends UIJob implements ILabelJob { - - private LabelUpdater fUpdater = new LabelUpdater(); - - public UILabelJob() { - super("Label Job"); //$NON-NLS-1$ - setSystem(true); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus runInUIThread(IProgressMonitor monitor) { - fUpdater.run(); - return Status.OK_STATUS; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider.ILabelJob#queue(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate) - */ - public boolean queue(ILabelUpdate[] updates) { - return fUpdater.queue(updates); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#shouldRun() - */ - public boolean shouldRun() { - return fUpdater.shouldRun(); - } - } - - /** - * Queue of label updates - */ - class LabelUpdater implements Runnable { - - LinkedList fQueue = new LinkedList(); - - public synchronized boolean queue(ILabelUpdate[] updates) { - if (fQueue == null) { - return false; - } else { - for (int i = 0; i < updates.length; i++) { - fQueue.addLast(updates[i]); - } - return true; - } - } - - /* (non-Javadoc) - * @see java.lang.Runnable#run() - */ - public void run() { - ILabelUpdate update = getNextUpdate(); - while (update != null) { - ISchedulingRule rule = getRule(update); - if (!update.isCanceled()) { - try { - if (rule != null) { - Job.getJobManager().beginRule(rule, null); - } - retrieveLabel(update); - } catch (CoreException e) { - update.setStatus(e.getStatus()); - } finally { - if (rule != null) { - Job.getJobManager().endRule(rule); - } - } - } - update.done(); - update = getNextUpdate(); - } - } - - /** - * Returns the next update to process, if there is one in the - * queue. If there are no queued items <code>null</code> is returned - * @return the next queued item or <code>null</code> if the queue is empty. - */ - public synchronized ILabelUpdate getNextUpdate() { - if (fQueue == null) { - return null; - } - ILabelUpdate update = null; - try { - update = (ILabelUpdate) fQueue.removeFirst(); - } catch (NoSuchElementException e) { - fQueue = null; - } - return update; - } - - public boolean shouldRun() { - return fQueue != null; - } - } - - /** - * Retrieves label attributes for the specified update. - * - * @param update - */ - protected void retrieveLabel(ILabelUpdate update) throws CoreException { - String[] columnIds = update.getColumnIds(); - IPresentationContext presentationContext = update.getPresentationContext(); - TreePath elementPath = update.getElementPath(); - int numColumns = 1; - if (columnIds != null) { - numColumns = columnIds.length; - } - for (int i = 0; i < numColumns; i++) { - String columnId = null; - if (columnIds != null) { - columnId = columnIds[i]; - } - update.setLabel(getLabel(elementPath, presentationContext, columnId), i); - update.setImageDescriptor(getImageDescriptor(elementPath, presentationContext, columnId), i); - update.setBackground(getBackground(elementPath, presentationContext, columnId), i); - update.setForeground(getForeground(elementPath, presentationContext, columnId), i); - update.setFontData(getFontData(elementPath, presentationContext, columnId), i); - if (update instanceof ICheckUpdate && - Boolean.TRUE.equals(presentationContext.getProperty(ICheckUpdate.PROP_CHECK))) - { - ((ICheckUpdate) update).setChecked( - getChecked(elementPath, presentationContext), getGrayed(elementPath, presentationContext)); - } - } - } - - /** - * Returns the <code>FontData</code> for the path in the given column with the current presentation - * @param element - * @param presentationContext - * @param columnId - * @return font information or <code>null</code> - */ - protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - return null; - } - - /** - * Returns the <code>RGB</code> foreground colour for the path in the given column with the current presentation - * @param element - * @param presentationContext - * @param columnId - * @return color or <code>null</code> - */ - protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - return null; - } - - /** - * Returns the <code>RGB</code> background colour for the path in the given column with the current presentation - * @param element - * @param presentationContext - * @param columnId - * @return color or <code>null</code> - */ - protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - return null; - } - - /** - * Returns the <code>ImageDescriptor</code> for the path in the given column with the current presentation - * @param element - * @param presentationContext - * @param columnId - * @return image descriptor or <code>null</code> - */ - protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - return null; - } - - /** - * Returns the label for the path in the given column with the current presentation - * @param element - * @param presentationContext - * @param columnId - * @return label - */ - protected abstract String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException; - - /** - * Returns the checked state for the given path. - * - * @param path Path of the element to retrieve the grayed state for. - * @param presentationContext Presentation context where the element is - * displayed. - * @return <code>true<code> if the element check box should be checked - * @throws CoreException - * - * @since 3.6 - */ - protected boolean getChecked(TreePath path, IPresentationContext presentationContext) throws CoreException { - return false; - } - - /** - * Returns the grayed state for the given path. - * - * @param path Path of the element to retrieve the grayed state for. - * @param presentationContext Presentation context where the element is - * displayed. - * @return <code>true<code> if the element check box should be grayed - * @throws CoreException - * - * @since 3.6 - */ - protected boolean getGrayed(TreePath path, IPresentationContext presentationContext) throws CoreException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate[]) - */ - public synchronized void update(ILabelUpdate[] updates) { - if (fLabelJob == null) { - fLabelJob = newLabelJob(updates); - } - if (!((ILabelJob)fLabelJob).queue(updates)) { - fLabelJob = newLabelJob(updates); - ((ILabelJob)fLabelJob).queue(updates); - } - // TODO: rule - fLabelJob.schedule(); - } - - /** - * Returns a new <code>Job</code> to update the specified labels. This method - * is used to determine if a UI job is needed or not, in the event the request for an update - * job has come from a non-UI thread. - * @param updates an array of pending label updates - * @return a new <code>Job</code> to update labels with. - */ - private Job newLabelJob(ILabelUpdate[] updates) { - if (requiresUIJob(updates)) { - return new UILabelJob(); - } else { - return new LabelJob(); - } - } - - /** - * Returns whether a UI job should be used for updates versus a non-UI job. - * @param updates - * @return true if the array of updates requires a UI job to update the labels, false otherwise - */ - protected boolean requiresUIJob(ILabelUpdate[] updates) { - return false; - } - - /** - * Returns the scheduling rule for the given update or <code>null</code> - * it none. - * - * @param update label update - * @return associated scheduling rule, or <code>null</code> - */ - protected ISchedulingRule getRule(ILabelUpdate update) { - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementMementoProvider.java deleted file mode 100644 index 536fb5b18..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementMementoProvider.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -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.debug.internal.ui.viewers.model.provisional.IElementCompareRequest; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.ui.IMemento; - -/** - * @since 3.3 - */ -public abstract class ElementMementoProvider implements IElementMementoProvider { - - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[]) - */ - public void compareElements(final IElementCompareRequest[] requests) { - Job job = new Job("compare element") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - for (int i = 0; i < requests.length; i++) { - IElementCompareRequest request = requests[i]; - try { - request.setEqual(isEqual(request.getElement(), request.getMemento(), request.getPresentationContext())); - } catch (CoreException e) { - request.setStatus(e.getStatus()); - } - request.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - // TODO: rule - job.schedule(); - } - - /** - * Returns whether the memento represents the given element. - * - * @param element the element to compare to the memento - * @param memento memento - * @param context the context the compare is in - * @return whether the memento represents the given element - */ - protected abstract boolean isEqual(Object element, IMemento memento, IPresentationContext context) throws CoreException; - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) - */ - public void encodeElements(final IElementMementoRequest[] requests) { - Job job = new Job("encode element") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - for (int i = 0; i < requests.length; i++) { - IElementMementoRequest request = requests[i]; - try { - if (!encodeElement(request.getElement(), request.getMemento(), request.getPresentationContext())) { - request.cancel(); - } - } catch (CoreException e) { - request.setStatus(e.getStatus()); - } - request.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - // TODO: rule - job.schedule(); - } - - /** - * Encodes the specified element into the given memento. - * Returns whether the element could be encoded - * - * @param element the element to encode - * @param memento the memento to write to - * @param context presentation context - * @return false if cancelled/not supported - * @throws CoreException - */ - protected abstract boolean encodeElement(Object element, IMemento memento, IPresentationContext context) throws CoreException; - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java deleted file mode 100644 index 6a6c2d249..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.model.elements; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -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.internal.ui.viewers.model.ViewerAdapterService; -import org.eclipse.debug.internal.ui.viewers.model.ViewerUpdateMonitor; -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.debug.internal.ui.viewers.model.provisional.IViewerUpdate; - -/** - * @since 3.3 - */ -public class ExpressionContentProvider extends VariableContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate[]) - */ - public void update(IChildrenCountUpdate[] updates) { - // See if we can delegate to a model specific content provider - Map delegateMap = new HashMap(); - List notDelegated = new ArrayList(); - findDelegates(delegateMap, notDelegated, updates); - - // Batch the updates and send them to the delegates - for (Iterator iterator = delegateMap.keySet().iterator(); iterator.hasNext();) { - IElementContentProvider delegate = (IElementContentProvider) iterator.next(); - List updateList = (List)delegateMap.get(delegate); - delegate.update((IChildrenCountUpdate[])updateList.toArray(new IChildrenCountUpdate[updateList.size()])); - } - if (notDelegated.size() > 0){ - super.update((IChildrenCountUpdate[])notDelegated.toArray(new IChildrenCountUpdate[notDelegated.size()])); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate[]) - */ - public void update(IHasChildrenUpdate[] updates) { - // See if we can delegate to a model specific content provider - Map delegateMap = new HashMap(); - List notDelegated = new ArrayList(); - findDelegates(delegateMap, notDelegated, updates); - - // Batch the updates and send them to the delegates - for (Iterator iterator = delegateMap.keySet().iterator(); iterator.hasNext();) { - IElementContentProvider delegate = (IElementContentProvider) iterator.next(); - List updateList = (List)delegateMap.get(delegate); - delegate.update((IHasChildrenUpdate[])updateList.toArray(new IHasChildrenUpdate[updateList.size()])); - } - if (notDelegated.size() > 0){ - super.update((IHasChildrenUpdate[])notDelegated.toArray(new IHasChildrenUpdate[notDelegated.size()])); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate[]) - */ - public void update(IChildrenUpdate[] updates) { - // See if we can delegate to a model specific content provider - Map delegateMap = new HashMap(); - List notDelegated = new ArrayList(); - findDelegates(delegateMap, notDelegated, updates); - - // Batch the updates and send them to the delegates - for (Iterator iterator = delegateMap.keySet().iterator(); iterator.hasNext();) { - IElementContentProvider delegate = (IElementContentProvider) iterator.next(); - List updateList = (List)delegateMap.get(delegate); - delegate.update((IChildrenUpdate[])updateList.toArray(new IChildrenUpdate[updateList.size()])); - } - if (notDelegated.size() > 0){ - super.update((IChildrenUpdate[])notDelegated.toArray(new IChildrenUpdate[notDelegated.size()])); - } - } - - /** - * Finds all possibly delegate content providers for the given set of updates. Found delegates are added - * to the given map as the key while the list of updates to be sent to that delegate are set as the value. - * Any updates that are not to be delegated are put in the notDelegated list. - * - * @param delegateMap map to add delegates to - * @param notDelegated list of updates that should not be delegated - * @param updates array of updates that can be handled by delegates - * @since 3.4 - */ - private void findDelegates(Map delegateMap, List notDelegated, IViewerUpdate[] updates){ - for (int i = 0; i < updates.length; i++) { - if (updates[i] instanceof ViewerUpdateMonitor && !((ViewerUpdateMonitor)updates[i]).isDelegated() && updates[i].getElement() instanceof IExpression){ - IElementContentProvider delegate = ViewerAdapterService.getContentProvider(((IExpression)updates[i].getElement()).getValue()); - if (delegate != null){ - List updateList = (List)delegateMap.get(delegate); - if (updateList == null){ - updateList = new ArrayList(); - delegateMap.put(delegate, updateList); - } - ((ViewerUpdateMonitor)updates[i]).setDelegated(true); - updateList.add(updates[i]); - continue; - } - } - notDelegated.add(updates[i]); - } - } - - - protected Object[] getAllChildren(Object parent, IPresentationContext context) throws CoreException { - if (parent instanceof IErrorReportingExpression) { - IErrorReportingExpression expression = (IErrorReportingExpression) parent; - if (expression.hasErrors()) { - String[] messages = expression.getErrorMessages(); - LinkedHashSet set = new LinkedHashSet(messages.length); - for (int i = 0; i < messages.length; i++) { - set.add(messages[i]); - } - return set.toArray(); - } - } - if (parent instanceof IExpression) { - IExpression expression = (IExpression) parent; - IValue value = expression.getValue(); - if (value != null) { - return getValueChildren(expression, value, context); - } - } - return EMPTY; - } - - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - if (element instanceof IErrorReportingExpression) { - IErrorReportingExpression expression = (IErrorReportingExpression) element; - if (expression.hasErrors()) { - return true; - } - } - IValue value = ((IExpression)element).getValue(); - if (value == null) { - return false; - } - return value.hasVariables(); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java deleted file mode 100644 index 8788f0cd6..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IErrorReportingExpression; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.swt.graphics.RGB; - -/** - * @since 3.3 - */ -public class ExpressionLabelProvider extends VariableLabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.VariableLabelProvider#getForeground(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (element instanceof IErrorReportingExpression) { - IErrorReportingExpression expression = (IErrorReportingExpression) element; - if (expression.hasErrors()) { - return new RGB(255, 0, 0); - } - } - return super.getForeground(elementPath, presentationContext, columnId); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java deleted file mode 100644 index 94503f48f..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.IExpressionManager; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * Default content provider for the expression manager. - */ -public class ExpressionManagerContentProvider extends ElementContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((IExpressionManager) element).getExpressions().length; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(((IExpressionManager) parent).getExpressions(), index, length); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return id.equals(IDebugUIConstants.ID_EXPRESSION_VIEW); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate) - */ - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((IExpressionManager)element).hasExpressions(); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerMementoProvider.java deleted file mode 100644 index 8c4194adc..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerMementoProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.IExpressionManager; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; - -/** - * Memento provider for expression manager. - * - * @since 3.4 - */ -public class ExpressionManagerMementoProvider extends DebugElementMementoProvider { - - private static final String EXP_MGR = "EXP_MGR"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext) - */ - protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IExpressionManager) { - return EXP_MGR; - } - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionMementoProvider.java deleted file mode 100644 index 6bb4fe271..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionMementoProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; - -/** - * Memento provider for expressions. - * - * @since 3.4 - */ -public class ExpressionMementoProvider extends DebugElementMementoProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext) - */ - protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IExpression) { - return ((IExpression) element).getExpressionText(); - } - return null; - } - -} 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 deleted file mode 100644 index c350078b5..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchContentProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * @since 3.3 - */ -public class LaunchContentProvider extends ElementContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((ILaunch)element).getChildren().length; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return IDebugUIConstants.ID_DEBUG_VIEW.equals(id); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(((ILaunch)parent).getChildren(), index, length); - } - - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((ILaunch)element).hasChildren(); - } - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchManagerContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchManagerContentProvider.java deleted file mode 100644 index 81883a39b..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/LaunchManagerContentProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * @since 3.3 - */ -public class LaunchManagerContentProvider extends ElementContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((ILaunchManager)element).getLaunches().length; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return IDebugUIConstants.ID_DEBUG_VIEW.equals(id); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(((ILaunchManager)parent).getLaunches(),index, length); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java deleted file mode 100644 index bb4008fd5..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * This content provider is required in order to have selection maintained properly - * when swtiching between session. The problem is, when swtich debug session, the memory view reset the input - * to the viewer. - * - * After the input is set, viewer's doInitialRestore is called. At this time, the elemtns - * are not mapped in the viewer yet, as a result, the selection cannot be maintained. - * - * The viewer tries to restore selection again after elements are added to the view. This is done - * in the HasChildrenJob. However, this job will not get scheduled unless the element provides a content - * provider adapter. As a result, the job is never scheduled and the selection cannot be maintained. - * - */ -public class MemoryBlockContentProvider extends ElementContentProvider { - - protected int getChildCount(Object element, IPresentationContext context, - IViewerUpdate monitor) throws CoreException { - return 0; - } - - protected Object[] getChildren(Object parent, int index, int length, - IPresentationContext context, IViewerUpdate monitor) - throws CoreException { - return EMPTY; - } - - protected boolean supportsContextId(String id) { - if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - return true; - return false; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java deleted file mode 100644 index 91233a4d4..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.TreePath; - -public class MemoryBlockLabelProvider extends DebugElementLabelProvider { - - protected String getLabel(TreePath elementPath, - IPresentationContext presentationContext, String columnId) - throws CoreException { - Object element = elementPath.getLastSegment(); - - if (element instanceof IMemoryBlock) - return getLabel((IMemoryBlock)element); - - return super.getLabel(elementPath, presentationContext, columnId); - } - - protected ImageDescriptor getImageDescriptor(TreePath elementPath, - IPresentationContext presentationContext, String columnId) - throws CoreException { - - Object element = elementPath.getLastSegment(); - - if (element instanceof IMemoryBlock) - return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_VARIABLE); - - return super.getImageDescriptor(elementPath, presentationContext, columnId); - } - - /** - * @param memoryBlockLabel - * @return - */ - private String getLabel(IMemoryBlock memoryBlock) { - - String memoryBlockLabel = " "; //$NON-NLS-1$ - if (memoryBlock instanceof IMemoryBlockExtension) - { - // simply return the expression without the address - // do not want to keep track of changes in the address - if (((IMemoryBlockExtension)memoryBlock).getExpression() != null) - { - memoryBlockLabel += ((IMemoryBlockExtension)memoryBlock).getExpression(); - } - } - else - { - long address = memoryBlock.getStartAddress(); - memoryBlockLabel = Long.toHexString(address); - } - return memoryBlockLabel; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java deleted file mode 100644 index 11d0ee3cd..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.model.IMemoryBlockRetrieval; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -public class MemoryRetrievalContentProvider extends ElementContentProvider { - - protected int getChildCount(Object element, IPresentationContext context, - IViewerUpdate monitor) throws CoreException { - return getAllChildren(element, context, monitor).length; - } - - protected Object[] getChildren(Object parent, int index, int length, - IPresentationContext context, IViewerUpdate monitor) - throws CoreException { - - return getElements(getAllChildren(parent, context, monitor), index, length); - - } - - protected Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor) { - String id = context.getId(); - if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - { - if (parent instanceof IMemoryBlockRetrieval) - { - if (((IMemoryBlockRetrieval)parent).supportsStorageRetrieval()) - return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent); - } - } - return EMPTY; - } - - protected boolean supportsContextId(String id) { - return id.equals(IDebugUIConstants.ID_MEMORY_VIEW); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java deleted file mode 100644 index ca4727c53..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockRetrieval; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.ui.IMemento; - -public class MemoryViewElementMementoProvider extends ElementMementoProvider { - - private static final String OBJECT_ID = "OBJECT_ID"; //$NON-NLS-1$ - - protected boolean encodeElement(Object element, IMemento memento, - IPresentationContext context) throws CoreException { - String id = context.getId(); - if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - { - if (element instanceof IMemoryBlock || element instanceof IMemoryBlockRetrieval) - { - memento.putInteger(OBJECT_ID, element.hashCode()); - return true; - } - } - return false; - } - - protected boolean isEqual(Object element, IMemento memento, - IPresentationContext context) throws CoreException { - String id = context.getId(); - if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) - { - if (element instanceof IMemoryBlock || element instanceof IMemoryBlockRetrieval) - { - Integer objectId = memento.getInteger(OBJECT_ID); - if (objectId != null && objectId.intValue() == element.hashCode()) - return true; - } - } - return false; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupContentProvider.java deleted file mode 100644 index 8d3016462..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupContentProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IRegisterGroup; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * Register group content provider. - * - * @since 3.3 - */ -public class RegisterGroupContentProvider extends ElementContentProvider { - - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((IRegisterGroup)element).getRegisters().length; - } - - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(((IRegisterGroup)parent).getRegisters(), index, length); - } - - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((IRegisterGroup)element).hasRegisters(); - } - - protected boolean supportsContextId(String id) { - return IDebugUIConstants.ID_REGISTER_VIEW.equals(id); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupLabelProvider.java deleted file mode 100644 index cc04c51c8..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupLabelProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.TreePath; - -/** - * @since 3.3 - */ -public class RegisterGroupLabelProvider extends DebugElementLabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getImageDescriptor(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - if (columnId == null || VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals(columnId)) { - return super.getImageDescriptor(elementPath, presentationContext, columnId); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected String getLabel(TreePath elementPath, IPresentationContext context, String columnId) throws CoreException { - if (columnId == null || VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals(columnId)) { - return super.getLabel(elementPath, context, columnId); - } else { - return IInternalDebugCoreConstants.EMPTY_STRING; - } - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupMementoProvider.java deleted file mode 100644 index 9d2f9401e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/RegisterGroupMementoProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IRegisterGroup; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; - -/** - * Memento provider for register groups. - * - * @since 3.4 - */ -public class RegisterGroupMementoProvider extends DebugElementMementoProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext) - */ - protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IRegisterGroup) { - return ((IRegisterGroup) element).getName(); - } - return null; - } - -} 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 deleted file mode 100644 index 61ce7cef0..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IStackFrame; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * @since 3.3 - */ -public class StackFrameContentProvider extends ElementContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getAllChildren(element, context, monitor).length; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(getAllChildren(parent, context, monitor), index, length); - } - - /** - * This method retrieves all of the children for the specified parent given the current context - * @param parent the parent ot get the children for - * @param context the context for which to get the children for - * @param monitor the monitor for progress - * @return the collection of children, or an empty collection, never <code>null</code> - * @throws CoreException - */ - protected Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - if (parent instanceof IStackFrame) { - String id = context.getId(); - IStackFrame frame = (IStackFrame) parent; - if (id.equals(IDebugUIConstants.ID_VARIABLE_VIEW)) { - return frame.getVariables(); - } else if (id.equals(IDebugUIConstants.ID_REGISTER_VIEW)) { - return frame.getRegisterGroups(); - } - } else { - monitor.cancel(); - } - return EMPTY; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return id.equals(IDebugUIConstants.ID_VARIABLE_VIEW) || id.equals(IDebugUIConstants.ID_REGISTER_VIEW); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.core.runtime.IProgressMonitor) - */ - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate 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/StackFrameMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameMementoProvider.java deleted file mode 100644 index 450ce046c..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameMementoProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IStackFrame; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * Memento provider for stack frames. - * - * @since 3.4 - */ -public class StackFrameMementoProvider extends DebugElementMementoProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext) - */ - protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IStackFrame) { - IStackFrame frame = (IStackFrame) element; - if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId())) { - // for registers view attempt to maintain expansion for target rather than each frame - return frame.getModelIdentifier(); - } else { - return frame.getName(); - } - } - return null; - } - -} 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 deleted file mode 100644 index dd99e6650..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ThreadContentProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IThread; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * @since 3.3 - */ -public class ThreadContentProvider extends ElementContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((IThread)element).getStackFrames().length; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return IDebugUIConstants.ID_DEBUG_VIEW.equals(id); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(((IThread)parent).getStackFrames(), index, length); - } - - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate 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 deleted file mode 100644 index 8c050f792..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.model.elements; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugEvent; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IDebugEventSetListener; -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.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; -import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition; -import org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache; -import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * @since 3.3 - */ -public class VariableContentProvider extends ElementContentProvider { - - /** - * Cache of logical structures to avoid computing structures for different - * subranges. - */ - private static LogicalStructureCache fgLogicalCache; - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getAllChildren(element, context).length; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) - */ - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return getElements(getAllChildren(parent, context), index, length); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate) - */ - protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return ((IVariable)element).getValue().hasVariables(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) - */ - protected boolean supportsContextId(String id) { - return id.equals(IDebugUIConstants.ID_EXPRESSION_VIEW) || id.equals(IDebugUIConstants.ID_VARIABLE_VIEW) || id.equals(IDebugUIConstants.ID_REGISTER_VIEW); - } - - /** - * Gets all the children variables for the parent - * @param parent the parent IVariable - * @param context the context the children will be presented in - * @return an array of all children or an empty array if none - * @throws CoreException - */ - protected Object[] getAllChildren(Object parent, IPresentationContext context) throws CoreException { - IVariable variable = (IVariable) parent; - IValue value = variable.getValue(); - if (value != null) { - return getValueChildren(variable, value, context); - } - return EMPTY; - } - - /** - * Return whether to show compute a logical structure or a raw structure - * in the specified context - * - * @return whether to show compute a logical structure or a raw structure - * in the specified context - */ - protected boolean isShowLogicalStructure(IPresentationContext context) { - Boolean show = (Boolean) context.getProperty(VariablesView.PRESENTATION_SHOW_LOGICAL_STRUCTURES); - return show != null && show.booleanValue(); - } - - /** - * 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 preference - return 100; - } - - /** - * Returns any logical value for the raw value in the specified context - * - * @param value - * @param context - * @return logical value for the raw value - */ - protected IValue getLogicalValue(IValue value, IPresentationContext context) throws CoreException { - return getLogicalValue(value, new ArrayList(), context); - } - - /** - * Returns children for the given value, creating array partitions if - * required - * - * @param parent expression or variable containing the given value - * @param value the value to retrieve children for - * @param context the context in which children have been requested - * @return children for the given value, creating array partitions if - * required - * @throws CoreException - */ - protected Object[] getValueChildren(IDebugElement parent, IValue value, IPresentationContext context) throws CoreException { - if (value == null) { - return EMPTY; - } - IValue logicalValue = getLogicalValue(value, context); - 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 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 partitions 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 any logical value for the raw value. This method will recurse - * over the returned value until the same structure is encountered again (to - * avoid infinite recursion). - * - * @param value raw value to possibly be replaced by a logical value - * @param previousStructureIds - * the list of logical structures that have already been applied - * to the returned value during the recursion of this method. - * Callers should always pass in a new, empty list. - * @return logical value if one is calculated, otherwise the raw value is returned - */ - protected IValue getLogicalValue(IValue value, List previousStructureIds, IPresentationContext context) throws CoreException { - if (isShowLogicalStructure(context)) { - ILogicalStructureType[] types = DebugPlugin.getLogicalStructureTypes(value); - if (types.length > 0) { - ILogicalStructureType type = DebugPlugin.getDefaultStructureType(types); - if (type != null && !previousStructureIds.contains(type.getId())) { - IValue logicalValue = getLogicalStructureCache().getLogicalStructure(type, value); - previousStructureIds.add(type.getId()); - return getLogicalValue(logicalValue, previousStructureIds, context); - } - } - } - return value; - } - - /** - * Returns the logical structure cache to use to store calculated structures. If the cache does not - * exist yet, one is created and a debug event listener is added to clear the cache on RESUME and - * TERMINATE events. - * - * @return the logical structure cache to use - */ - protected synchronized LogicalStructureCache getLogicalStructureCache(){ - if (fgLogicalCache == null){ - fgLogicalCache = new LogicalStructureCache(); - // Add a listener to clear the cache when resuming, terminating, or suspending - DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener(){ - public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - if (events[i].getKind() == DebugEvent.TERMINATE){ - fgLogicalCache.clear(); - break; - } else if (events[i].getKind() == DebugEvent.RESUME && events[i].getDetail() != DebugEvent.EVALUATION_IMPLICIT){ - fgLogicalCache.clear(); - break; - } else if (events[i].getKind() == DebugEvent.SUSPEND && events[i].getDetail() != DebugEvent.EVALUATION_IMPLICIT){ - fgLogicalCache.clear(); - break; - } else if (events[i].getKind() == DebugEvent.CHANGE && events[i].getDetail() == DebugEvent.CONTENT){ - fgLogicalCache.clear(); - break; - } - } - } - }); - } - return fgLogicalCache; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java deleted file mode 100644 index b886d20ed..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * 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.model.elements; - -import org.eclipse.debug.internal.ui.elements.adapters.DefaultVariableCellModifier; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.widgets.Composite; - -/** - * @since 3.3 - */ -public class VariableEditor implements IElementEditor { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellEditor(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String, java.lang.Object, org.eclipse.swt.widgets.Composite) - */ - public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) { - return new TextCellEditor(parent); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellModifier(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object) - */ - public ICellModifier getCellModifier(IPresentationContext context, Object element) { - return new DefaultVariableCellModifier(); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java deleted file mode 100644 index d01ab5121..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -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.internal.ui.DefaultLabelProvider; -import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.RGB; - -/** - * Provides context sensitive labels for debug variables. - * - * @since 3.3 - */ -public class VariableLabelProvider extends DebugElementLabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getBackground(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (columnId != null) { - if (element instanceof IVariable) { - IVariable variable = (IVariable) element; - if (variable.hasValueChanged()) { - return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND).getRGB(); - } - } - } - return super.getBackground(elementPath, presentationContext, columnId); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getForeground(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - Object element = elementPath.getLastSegment(); - if (columnId == null) { - if (element instanceof IVariable) { - IVariable variable = (IVariable) element; - if (variable.hasValueChanged()) { - return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_DEBUG_ELEMENT_COLOR).getRGB(); - } - } - } - return super.getForeground(elementPath, presentationContext, columnId); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getImageDescriptor(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - if (columnId == null || VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals(columnId)) { - return super.getImageDescriptor(elementPath, presentationContext, columnId); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getFontData(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { - return JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) - */ - protected String getLabel(TreePath elementPath, IPresentationContext context, String columnId) throws CoreException { - if (columnId == null) { - return super.getLabel(elementPath, context, columnId); - } else { - IVariable variable = (IVariable) elementPath.getLastSegment(); - IValue value = variable.getValue(); - return getColumnText(variable, value, context, columnId); - } - } - - /** - * Returns text for a specific columns for the variable/value. - * - * @param variable variable to retrieve text for - * @param value the value associated with the variable - * @param context presentation context specifying how to display the text - * @param columnId the column to get the text for - * @return the label text - * @throws CoreException - */ - protected String getColumnText(IVariable variable, IValue value, IPresentationContext context, String columnId) throws CoreException { - if (VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals(columnId)) { - return getVariableName(variable, context); - } else if (VariableColumnPresentation.COLUMN_VARIABLE_TYPE.equals(columnId)) { - return getVariableTypeName(variable, context); - } else if (VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals(columnId)) { - return getValueText(variable, value, context); - } else if (VariableColumnPresentation.COLUMN_VALUE_TYPE.equals(columnId)) { - return getValueTypeName(variable, value, context); - } - return null; - } - - /** - * Returns the name of the given variable to display in <code>COLUMN_VARIABLE_NAME</code>. - * - * @param variable - * @return variable name - * @throws CoreException - */ - protected String getVariableName(IVariable variable, IPresentationContext context) throws CoreException { - return variable.getName(); - } - - /** - * Returns the type name of the given variable to display in <code>COLUMN_VARIABLE_TYPE</code>. - * - * @param variable - * @return variable type name - * @throws CoreException - */ - protected String getVariableTypeName(IVariable variable, IPresentationContext context) throws CoreException { - return variable.getReferenceTypeName(); - } - - /** - * Returns the label for the given value's type to display in <code>COLUMN_VARIABLE_VALUE</code> - * - * @param variable - * @param value - * @return value label - * @throws CoreException - */ - protected String getValueTypeName(IVariable variable, IValue value, IPresentationContext context) throws CoreException { - return value.getReferenceTypeName(); - } - - /** - * Returns the label for the given value to display in <code>COLUMN_VALUE_TYPE</code> - * - * @param variable - * @param value - * @return value label - * @throws CoreException - */ - protected String getValueText(IVariable variable, IValue value, IPresentationContext context) throws CoreException { - return escapeSpecialChars(value.getValueString()); - } - - /** - * Escapes special characters using the default label provider - * - * @param label the text to escape - * @return the string with special characters escaped - */ - protected String escapeSpecialChars(String label) { - return DefaultLabelProvider.escapeSpecialChars(label); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableMementoProvider.java deleted file mode 100644 index f64ff8b7a..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableMementoProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IVariable; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; - -/** - * Memento provider for variables and registers. - * - * @since 3.4 - */ -public class VariableMementoProvider extends DebugElementMementoProvider { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext) - */ - protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IVariable) { - return ((IVariable) element).getName(); - } - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ViewerInputProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ViewerInputProvider.java deleted file mode 100644 index cc0bf6208..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ViewerInputProvider.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.model.elements; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; - -/** - * Common code for viewer input providers. Creates a job to process request asynchronously. - - * @since 3.4 - */ -public abstract class ViewerInputProvider implements IViewerInputProvider { - - protected static final Object[] EMPTY = new Object[0]; - - /* (non-Javadoc) - * @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 IViewerInputUpdate update) { - Job job = new Job("viewer input resolution") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - if (!update.isCanceled()) { - retrieveInput(update); - } - update.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(getRule(update)); - job.schedule(); - } - - /** - * Computes the viewer input for the specified context. - * - * @param update update request - */ - protected void retrieveInput(IViewerInputUpdate update) { - if (!update.isCanceled()) { - IStatus status = Status.OK_STATUS; - try { - IPresentationContext context = update.getPresentationContext(); - if (supportsContext(context)) { - update.setInputElement(getViewerInput(update.getElement(), context, update)); - } else { - update.setInputElement(update.getElement()); - } - } catch (CoreException e) { - status = e.getStatus(); - } - update.setStatus(status); - } - } - - - /** - * Returns the viewer input derived from the given source object in the specified - * context, possibly <code>null</code>. - * - * @param source element to derive a viewer input from - * @param context context for which an input is requested - * @param update viewer update request - * @throws CoreException if an exception occurs retrieving child - */ - protected abstract Object getViewerInput(Object source, IPresentationContext context, IViewerUpdate update) throws CoreException; - - - /** - * Returns whether this adapter supports the given context. - * - * @param context - * @return whether this adapter supports the given context - */ - protected boolean supportsContext(IPresentationContext context) { - return supportsContextId(context.getId()); - } - - /** - * Returns whether this adapter provides content in the specified context id. - * - * @param id part id - * @return whether this adapter provides content in the specified context id - */ - protected abstract boolean supportsContextId(String id); - - /** - * Returns a scheduling rule to use when performing the given updates or - * <code>null</code> if none. - * - * @param updates - * @return scheduling rule or <code>null</code> if none - */ - protected ISchedulingRule getRule(IViewerInputUpdate update) { - return null; - } - -} |