diff options
author | Darin Wright | 2006-11-21 19:42:54 +0000 |
---|---|---|
committer | Darin Wright | 2006-11-21 19:42:54 +0000 |
commit | a8c960c780b78c3339c4fedc936b598a2c9f037e (patch) | |
tree | 355b29cb337d10e9c2999f40a280ed32a887d5ed | |
parent | 73a02ec48e658184eca1602d6387f6796bef710c (diff) | |
download | eclipse.platform.debug-a8c960c780b78c3339c4fedc936b598a2c9f037e.tar.gz eclipse.platform.debug-a8c960c780b78c3339c4fedc936b598a2c9f037e.tar.xz eclipse.platform.debug-a8c960c780b78c3339c4fedc936b598a2c9f037e.zip |
Bug 153500 Asynchronous model viewer [tree paths for label updates]
9 files changed, 68 insertions, 58 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 index 7b23c987e..c7fad533f 100644 --- 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 @@ -15,6 +15,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext; import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.TreePath; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; @@ -23,10 +24,8 @@ import org.eclipse.swt.graphics.RGB; */ public class DebugElementLabelProvider extends ElementLabelProvider { - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getLabel(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String) - */ - protected String getLabel(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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); @@ -34,10 +33,8 @@ public class DebugElementLabelProvider extends ElementLabelProvider { return DebugElementHelper.getLabel(element); } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getBackground(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String) - */ - protected RGB getBackground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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()); @@ -45,10 +42,8 @@ public class DebugElementLabelProvider extends ElementLabelProvider { return DebugElementHelper.getBackground(element); } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getFontDatas(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String) - */ - protected FontData getFontData(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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()); @@ -57,10 +52,8 @@ public class DebugElementLabelProvider extends ElementLabelProvider { return DebugElementHelper.getFont(element); } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getForeground(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String) - */ - protected RGB getForeground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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()); @@ -68,10 +61,8 @@ public class DebugElementLabelProvider extends ElementLabelProvider { return DebugElementHelper.getForeground(element); } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getImageDescriptor(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String) - */ - protected ImageDescriptor getImageDescriptor(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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()); 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 index 9bd2ab90f..b56714a4e 100644 --- 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 @@ -22,6 +22,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProv 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; @@ -166,7 +167,7 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { protected void retrieveLabel(ILabelUpdate update) throws CoreException { String[] columnIds = update.getColumnIds(); IPresentationContext presentationContext = update.getPresentationContext(); - Object element = update.getElement(); + TreePath elementPath = update.getElement(); int numColumns = 1; if (columnIds != null) { numColumns = columnIds.length; @@ -176,11 +177,11 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { if (columnIds != null) { columnId = columnIds[i]; } - update.setLabel(getLabel(element, presentationContext, columnId), i); - update.setImageDescriptor(getImageDescriptor(element, presentationContext, columnId), i); - update.setBackground(getBackground(element, presentationContext, columnId), i); - update.setForeground(getForeground(element, presentationContext, columnId), i); - update.setFontData(getFontData(element, presentationContext, columnId), 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); } } @@ -190,7 +191,7 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { * @param columnId * @return font information or <code>null</code> */ - protected FontData getFontData(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { return null; } @@ -200,7 +201,7 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { * @param columnId * @return color or <code>null</code> */ - protected RGB getForeground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { return null; } @@ -210,7 +211,7 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { * @param columnId * @return color or <code>null</code> */ - protected RGB getBackground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { return null; } @@ -220,7 +221,7 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { * @param columnId * @return image descriptor or <code>null</code> */ - protected ImageDescriptor getImageDescriptor(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { return null; } @@ -230,7 +231,7 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { * @param columnId * @return label */ - protected abstract String getLabel(Object element, IPresentationContext presentationContext, String columnId) throws CoreException; + protected abstract String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException; /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider#updateLabel(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate) 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 index 6d4e87eb5..8788f0cd6 100644 --- 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 @@ -13,6 +13,7 @@ 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; /** @@ -20,14 +21,18 @@ import org.eclipse.swt.graphics.RGB; */ public class ExpressionLabelProvider extends VariableLabelProvider { - protected RGB getForeground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + /* (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(element, presentationContext, columnId); + return super.getForeground(elementPath, presentationContext, columnId); } } 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 index ee4502c56..a2690632e 100644 --- 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 @@ -14,22 +14,29 @@ import org.eclipse.core.runtime.CoreException; 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 { - protected ImageDescriptor getImageDescriptor(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + /* (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(element, presentationContext, columnId); + return super.getImageDescriptor(elementPath, presentationContext, columnId); } return null; } - protected String getLabel(Object element, IPresentationContext context, String columnId) throws CoreException { + /* (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(element, context, columnId); + return super.getLabel(elementPath, context, columnId); } else { return ""; //$NON-NLS-1$ } 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 index 8c149fa92..30d016acb 100644 --- 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 @@ -20,6 +20,7 @@ import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentatio 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; import org.eclipse.swt.graphics.RGB; /** @@ -27,7 +28,8 @@ import org.eclipse.swt.graphics.RGB; */ public class VariableLabelProvider extends DebugElementLabelProvider { - protected RGB getBackground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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; @@ -36,10 +38,11 @@ public class VariableLabelProvider extends DebugElementLabelProvider { } } } - return super.getBackground(element, presentationContext, columnId); + return super.getBackground(elementPath, presentationContext, columnId); } - protected RGB getForeground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + 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; @@ -48,21 +51,21 @@ public class VariableLabelProvider extends DebugElementLabelProvider { } } } - return super.getForeground(element, presentationContext, columnId); + return super.getForeground(elementPath, presentationContext, columnId); } - protected ImageDescriptor getImageDescriptor(Object element, IPresentationContext presentationContext, String columnId) throws CoreException { + protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { if (columnId == null || VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals(columnId)) { - return super.getImageDescriptor(element, presentationContext, columnId); + return super.getImageDescriptor(elementPath, presentationContext, columnId); } return null; } - protected String getLabel(Object element, IPresentationContext context, String columnId) throws CoreException { + protected String getLabel(TreePath elementPath, IPresentationContext context, String columnId) throws CoreException { if (columnId == null) { - return escapeSpecialChars(super.getLabel(element, context, columnId)); + return escapeSpecialChars(super.getLabel(elementPath, context, columnId)); } else { - IVariable variable = (IVariable) element; + IVariable variable = (IVariable) elementPath.getLastSegment(); IValue value = variable.getValue(); return getColumnText(variable, value, context, columnId); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java index 4ae8fbbc7..bc441abec 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java @@ -942,8 +942,8 @@ public class InternalTreeModelViewer extends TreeViewer { unmapElement(element, treeItem); return; } - - ((TreeModelLabelProvider)getLabelProvider()).update(element, getViewerRowFromItem(treeItem)); + + ((TreeModelLabelProvider)getLabelProvider()).update(getTreePathFromItem(item), getViewerRowFromItem(treeItem)); // As it is possible for user code to run the event // loop check here. diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java index 51aeeac3e..4a23cd916 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java @@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.TreeItem; */ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate { - private Object fElement; + private TreePath fElementPath; private String[] fColumnIds; private RGB[] fBackgrounds; private RGB[] fForegrounds; @@ -50,8 +50,8 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate { * @param provider label provider to callback to * @param columnId column identifier or <code>null</code> */ - public LabelUpdate(Object element, TreeItem item, TreeModelLabelProvider provider, String[] columnIds) { - fElement = element; + public LabelUpdate(TreePath elementPath, TreeItem item, TreeModelLabelProvider provider, String[] columnIds) { + fElementPath = elementPath; fProvider = provider; fColumnIds = columnIds; fItem = item; @@ -73,8 +73,8 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate { /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate#getElement() */ - public Object getElement() { - return fElement; + public TreePath getElement() { + return fElementPath; } /* (non-Javadoc) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java index 1b649ddcf..53a8fb12f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java @@ -29,6 +29,7 @@ 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.ColumnLabelProvider; +import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.jface.viewers.ViewerRow; import org.eclipse.swt.graphics.Color; @@ -184,11 +185,12 @@ class TreeModelLabelProvider extends ColumnLabelProvider { // NOT USED - the viewer updates each row instead } - public synchronized void update(Object element, ViewerRow row) { + public synchronized void update(TreePath elementPath, ViewerRow row) { String[] visibleColumns = fViewer.getVisibleColumns(); + Object element = elementPath.getLastSegment(); IElementLabelProvider presentation = getLabelAdapter(element); if (presentation != null) { - presentation.update(new LabelUpdate(element, (TreeItem) row.getItem(), this, visibleColumns)); + presentation.update(new LabelUpdate(elementPath, (TreeItem) row.getItem(), this, visibleColumns)); } else if (element instanceof String) { // for example, expression error messages row.setText(0, (String)element); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ILabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ILabelUpdate.java index fb2e414a9..d628f47fd 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ILabelUpdate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ILabelUpdate.java @@ -11,6 +11,7 @@ package org.eclipse.debug.internal.ui.viewers.model.provisional; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.TreePath; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; @@ -22,11 +23,11 @@ import org.eclipse.swt.graphics.RGB; public interface ILabelUpdate extends IViewerUpdate { /** - * Returns the element the label update is for. + * Returns a tree path for the element the label update is for. * - * @return associated element + * @return associated element tree path */ - public Object getElement(); + public TreePath getElement(); /** * Returns the id's of the visible columns in presentation order, |