Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/ILabelUpdate.java24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java22
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/LabelUpdate.java178
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelLabelProvider.java18
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelViewer.java25
5 files changed, 182 insertions, 85 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/ILabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/ILabelUpdate.java
index d4aee312d..c9d769484 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/ILabelUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/ILabelUpdate.java
@@ -29,44 +29,50 @@ public interface ILabelUpdate extends IPresentationUpdate {
public Object getElement();
/**
- * Returns the column the label is for, or <code>null</code> if no columns.
+ * Returns the id's of the visible columns in presentation order,
+ * or <code>null</code> if none.
*
- * @return column id or <code>null</code>
+ * @return column id's or <code>null</code>
*/
- public String getColumnId();
+ public String[] getColumnIds();
/**
- * Sets the text of the label. Cannot be <code>null</code>.
+ * Sets the text of the label of the specified column. Cannot be <code>null</code>.
*
* @param text
+ * @param columnIndex column index (0 when no columns)
*/
- public void setLabel(String text);
+ public void setLabel(String text, int columnIndex);
/**
* Sets the font of the label.
*
* @param fontData
+ * @param columnIndex column index (0 when no columns)
*/
- public void setFontData(FontData fontData);
+ public void setFontData(FontData fontData, int columnIndex);
/**
* Sets the image of the label.
*
* @param image
+ * @param columnIndex column index (0 when no columns)
*/
- public void setImageDescriptor(ImageDescriptor image);
+ public void setImageDescriptor(ImageDescriptor image, int columnIndex);
/**
* Sets the foreground color of the label.
*
* @param foreground
+ * @param columnIndex column index (0 when no columns)
*/
- public void setForeground(RGB foreground);
+ public void setForeground(RGB foreground, int columnIndex);
/**
* Sets the background color of the label.
*
* @param background
+ * @param columnIndex column index (0 when no columns)
*/
- public void setBackground(RGB background);
+ public void setBackground(RGB background, int columnIndex);
}
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 63118d413..dcf1caf43 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
@@ -164,14 +164,24 @@ public abstract class ElementLabelProvider implements IElementLabelProvider {
* @param update
*/
protected void retrieveLabel(ILabelUpdate update) throws CoreException {
- String columnId = update.getColumnId();
+ String[] columnIds = update.getColumnIds();
IPresentationContext presentationContext = update.getPresentationContext();
Object element = update.getElement();
- update.setLabel(getLabel(element, presentationContext, columnId));
- update.setImageDescriptor(getImageDescriptor(element, presentationContext, columnId));
- update.setBackground(getBackground(element, presentationContext, columnId));
- update.setForeground(getForeground(element, presentationContext, columnId));
- update.setFontData(getFontData(element, presentationContext, columnId));
+ 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(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);
+ }
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/LabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/LabelUpdate.java
index 98e0e52d4..e27691c62 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/LabelUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/LabelUpdate.java
@@ -14,6 +14,8 @@ import org.eclipse.debug.internal.ui.actions.context.AbstractRequestMonitor;
import org.eclipse.debug.internal.ui.model.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
@@ -25,41 +27,45 @@ import org.eclipse.swt.widgets.TreeItem;
class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate {
private Object fElement;
- private String fColumnId;
- private RGB fBackground;
- private RGB fForeground;
- private ImageDescriptor fImageDescriptor;
- private String fLabel;
- private FontData fFontData;
+ private String[] fColumnIds;
+ private RGB[] fBackgrounds;
+ private RGB[] fForegrounds;
+ private ImageDescriptor[] fImageDescriptors;
+ private String[] fLabels;
+ private FontData[] fFontDatas;
private TreeModelLabelProvider fProvider;
- private int fColumnIndex;
private TreeItem fItem;
+ private int fNumColumns;
/**
* Label/Image cache keys
* TODO: workaround for bug 159461
*/
static String PREV_LABEL_KEY = "PREV_LABEL_KEY"; //$NON-NLS-1$
- static String PREV_IAMGE_KEY = "PREV_IMAGE_KEY"; //$NON-NLS-1$
+ static String PREV_IMAGE_KEY = "PREV_IMAGE_KEY"; //$NON-NLS-1$
/**
* @param element element the label is for
* @param provider label provider to callback to
* @param columnId column identifier or <code>null</code>
*/
- public LabelUpdate(Object element, TreeItem item, TreeModelLabelProvider provider, String columnId, int columnIndex) {
+ public LabelUpdate(Object element, TreeItem item, TreeModelLabelProvider provider, String[] columnIds) {
fElement = element;
fProvider = provider;
- fColumnId = columnId;
- fColumnIndex = columnIndex;
+ fColumnIds = columnIds;
fItem = item;
+ fNumColumns = 1;
+ if (columnIds != null) {
+ fNumColumns = columnIds.length;
+ }
+ fLabels = new String[fNumColumns];
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#getColumnId()
+ * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#getColumnIds()
*/
- public String getColumnId() {
- return fColumnId;
+ public String[] getColumnIds() {
+ return fColumnIds;
}
/* (non-Javadoc)
@@ -70,38 +76,62 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate {
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setBackground(org.eclipse.swt.graphics.RGB)
+ * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setBackground(org.eclipse.swt.graphics.RGB, int)
*/
- public void setBackground(RGB background) {
- fBackground = background;
+ public void setBackground(RGB background, int columnIndex) {
+ if (background == null) {
+ return;
+ }
+ if (fBackgrounds == null) {
+ fBackgrounds = new RGB[fNumColumns];
+ }
+ fBackgrounds[columnIndex] = background;
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setFontData(org.eclipse.swt.graphics.FontData)
+ * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setFontData(org.eclipse.swt.graphics.FontData, int)
*/
- public void setFontData(FontData fontData) {
- fFontData = fontData;
+ public void setFontData(FontData fontData, int columnIndex) {
+ if (fontData == null) {
+ return;
+ }
+ if (fFontDatas == null) {
+ fFontDatas = new FontData[fNumColumns];
+ }
+ fFontDatas[columnIndex] = fontData;
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setForeground(org.eclipse.swt.graphics.RGB)
+ * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setForeground(org.eclipse.swt.graphics.RGB, int)
*/
- public void setForeground(RGB foreground) {
- fForeground = foreground;
+ public void setForeground(RGB foreground, int columnIndex) {
+ if (foreground == null) {
+ return;
+ }
+ if (fForegrounds == null) {
+ fForegrounds = new RGB[fNumColumns];
+ }
+ fForegrounds[columnIndex] = foreground;
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
+ * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor, int)
*/
- public void setImageDescriptor(ImageDescriptor image) {
- fImageDescriptor = image;
+ public void setImageDescriptor(ImageDescriptor image, int columnIndex) {
+ if (image == null) {
+ return;
+ }
+ if (fImageDescriptors == null) {
+ fImageDescriptors = new ImageDescriptor[fNumColumns];
+ }
+ fImageDescriptors[columnIndex] = image;
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setLabel(java.lang.String)
+ * @see org.eclipse.debug.internal.ui.model.ILabelUpdate#setLabel(java.lang.String, int)
*/
- public void setLabel(String text) {
- fLabel = text;
+ public void setLabel(String text, int columnIndex) {
+ fLabels[columnIndex] = text;
}
/* (non-Javadoc)
@@ -123,38 +153,66 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate {
*/
public void update() {
if (!fItem.isDisposed()) {
- fItem.setText(fColumnIndex, fLabel);
- setPrevious(PREV_LABEL_KEY, fLabel, fColumnIndex);
- Image image = fProvider.getImage(fImageDescriptor);
- fItem.setImage(fColumnIndex, image);
- setPrevious(PREV_IAMGE_KEY, image, fColumnIndex);
- fItem.setForeground(fColumnIndex, fProvider.getColor(fForeground));
- fItem.setBackground(fColumnIndex, fProvider.getColor(fBackground));
- fItem.setFont(fColumnIndex, fProvider.getFont(fFontData));
-
- }
- }
-
- /**
- * TODO: workaround for bug 159461
- *
- * @param key
- * @param current
- * @param index
- */
- private void setPrevious(String key, Object current, int index) {
- Object[] previous = (Object[]) fItem.getData(key);
- if (previous == null) {
- int columnCount = fItem.getParent().getColumnCount();
- if (columnCount == 0) {
- columnCount++;
+ if (fColumnIds == null) {
+ fItem.setText(fLabels[0]);
+ } else {
+ fItem.setText(fLabels);
+ }
+ fItem.setData(PREV_LABEL_KEY, fLabels);
+ if (fImageDescriptors == null) {
+ fItem.setImage((Image)null);
+ fItem.setData(PREV_IMAGE_KEY, null); // TODO: bug 159461
+ } else {
+ if (fImageDescriptors == null) {
+ fItem.setImage((Image)null);
+ fItem.setData(PREV_IMAGE_KEY, null);
+ } else {
+ Image[] images = new Image[fImageDescriptors.length];
+ for (int i = 0; i < fImageDescriptors.length; i++) {
+ images[i] = fProvider.getImage(fImageDescriptors[i]);
+ }
+ if (fColumnIds == null) {
+ fItem.setImage(images[0]);
+ } else {
+ fItem.setImage(images);
+ }
+ fItem.setData(PREV_IMAGE_KEY, images); // TODO: bug 159461
+ }
+ }
+ if (fForegrounds == null) {
+ fItem.setForeground((Color)null);
+ } else {
+ if (fColumnIds == null) {
+ fItem.setForeground(fProvider.getColor(fForegrounds[0]));
+ } else {
+ for (int i = 0; i< fForegrounds.length; i++) {
+ fItem.setForeground(i, fProvider.getColor(fForegrounds[i]));
+ }
+ }
+ }
+ if (fBackgrounds == null) {
+ fItem.setBackground((Color)null);
+ } else {
+ if (fColumnIds == null) {
+ fItem.setBackground(fProvider.getColor(fBackgrounds[0]));
+ } else {
+ for (int i = 0; i< fBackgrounds.length; i++) {
+ fItem.setBackground(i, fProvider.getColor(fBackgrounds[i]));
+ }
+ }
+ }
+ if (fFontDatas == null) {
+ fItem.setFont((Font)null);
+ } else {
+ if (fColumnIds == null) {
+ fItem.setFont(fProvider.getFont(fFontDatas[0]));
+ } else {
+ for (int i = 0; i < fFontDatas.length; i++) {
+ fItem.setFont(i, fProvider.getFont(fFontDatas[i]));
+ }
+ }
}
- previous = new Object[columnCount];
- fItem.setData(key, previous);
- }
- if (index < previous.length) {
- previous[index] = current;
}
- }
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelLabelProvider.java
index ff8971faf..9ceab1fad 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelLabelProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelLabelProvider.java
@@ -26,6 +26,7 @@ import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerRow;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -166,20 +167,19 @@ class TreeModelLabelProvider extends ColumnLabelProvider {
}
public synchronized void update(ViewerCell cell) {
+ // NOT USED - the viewer updates each row instead
+ }
+
+ public synchronized void update(Object element, ViewerRow row) {
String[] visibleColumns = fViewer.getVisibleColumns();
- Object element = cell.getElement();
- String columnId = null;
- if (visibleColumns != null) {
- columnId = visibleColumns[cell.getColumnIndex()];
- }
IElementLabelProvider presentation = getLabelAdapter(element);
if (presentation != null) {
- presentation.update(new LabelUpdate(element, (TreeItem) cell.getItem(), this, columnId, cell.getColumnIndex()));
+ presentation.update(new LabelUpdate(element, (TreeItem) row.getItem(), this, visibleColumns));
} else if (element instanceof String) {
// for example, expression error messages
- cell.setText((String)element);
- }
- }
+ row.setText(0, (String)element);
+ }
+ }
/**
* Returns the presentation context for this label provider.
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelViewer.java
index de6d9d8bd..36bbebef2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelViewer.java
@@ -317,7 +317,7 @@ public class TreeModelViewer extends TreeViewer {
item.setText(i, (String)labels[i]);
}
}
- Object[] images = (Object[]) item.getData(LabelUpdate.PREV_IAMGE_KEY);
+ Object[] images = (Object[]) item.getData(LabelUpdate.PREV_IMAGE_KEY);
if (images != null) {
for (int i = 0; i < images.length; i++) {
item.setImage(i, (Image) images[i]);
@@ -1005,4 +1005,27 @@ public class TreeModelViewer extends TreeViewer {
cp.removeModelChangedListener(listener);
}
}
+
+ /*
+ * (non-Javadoc) Method declared in AbstractTreeViewer.
+ */
+ protected void doUpdateItem(final Item item, Object element) {
+ if (!(item instanceof TreeItem)) {
+ return;
+ }
+ TreeItem treeItem = (TreeItem) item;
+ if (treeItem.isDisposed()) {
+ unmapElement(element, treeItem);
+ return;
+ }
+
+ ((TreeModelLabelProvider)getLabelProvider()).update(element, getRowPartFromItem(treeItem));
+
+ // As it is possible for user code to run the event
+ // loop check here.
+ if (item.isDisposed()) {
+ unmapElement(element, item);
+ }
+ }
+
}

Back to the top