Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2006-10-10 16:14:42 +0000
committerDarin Wright2006-10-10 16:14:42 +0000
commit07bbc13149b54976d86f887474129cd8a1a41ade (patch)
tree3ea1fb5bff6040dd3f9d44df1ebc5e4ce534ec78
parent9c4417480774d39f4648e327ea48e9d3efe20a48 (diff)
downloadeclipse.platform.debug-07bbc13149b54976d86f887474129cd8a1a41ade.tar.gz
eclipse.platform.debug-07bbc13149b54976d86f887474129cd8a1a41ade.tar.xz
eclipse.platform.debug-07bbc13149b54976d86f887474129cd8a1a41ade.zip
workaround for Bug 159461 - Virtual tree/table's clearAll should not visually change existing items
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/LabelUpdate.java46
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelLabelProvider.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/viewers/TreeModelViewer.java56
3 files changed, 74 insertions, 35 deletions
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 61e2a2ab7..bb0a946d7 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,9 +14,10 @@ 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.jface.viewers.ViewerRow;
import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.TreeItem;
/**
* @since 3.3
@@ -32,17 +33,25 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate {
private FontData fFontData;
private TreeModelLabelProvider fProvider;
private int fColumnIndex;
+ private TreeItem fItem;
+
+ /**
+ * Label/Image cache keys
+ */
+ static String PREV_LABEL_KEY = "PREV_LABEL_KEY"; //$NON-NLS-1$
+ static String PREV_IAMGE_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, TreeModelLabelProvider provider, String columnId, int columnIndex) {
+ public LabelUpdate(Object element, TreeItem item, TreeModelLabelProvider provider, String columnId, int columnIndex) {
fElement = element;
fProvider = provider;
fColumnId = columnId;
fColumnIndex = columnIndex;
+ fItem = item;
}
/* (non-Javadoc)
@@ -111,12 +120,33 @@ class LabelUpdate extends AbstractRequestMonitor implements ILabelUpdate {
/**
* Applies settings to viewer cell
*/
- public void update(ViewerRow row) {
- row.setText(fColumnIndex, fLabel);
- row.setImage(fColumnIndex, fProvider.getImage(fImageDescriptor));
- row.setForeground(fColumnIndex, fProvider.getColor(fForeground));
- row.setBackground(fColumnIndex, fProvider.getColor(fBackground));
- row.setFont(fColumnIndex, fProvider.getFont(fFontData));
+ 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));
+
+ }
}
+ 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++;
+ }
+ 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 68a9365e9..ff8971faf 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
@@ -32,6 +32,7 @@ import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.progress.UIJob;
/**
@@ -173,7 +174,7 @@ class TreeModelLabelProvider extends ColumnLabelProvider {
}
IElementLabelProvider presentation = getLabelAdapter(element);
if (presentation != null) {
- presentation.update(new LabelUpdate(element, this, columnId, cell.getColumnIndex()));
+ presentation.update(new LabelUpdate(element, (TreeItem) cell.getItem(), this, columnId, cell.getColumnIndex()));
} else if (element instanceof String) {
// for example, expression error messages
cell.setText((String)element);
@@ -224,7 +225,9 @@ class TreeModelLabelProvider extends ColumnLabelProvider {
fComplete = null;
}
//System.out.println("Changed Labels: " + updates.length);
- fViewer.apply(updates);
+ for (int i = 0; i < updates.length; i++) {
+ updates[i].update();
+ }
return Status.OK_STATUS;
}
};
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 5660c15cf..8089d0af6 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
@@ -33,15 +33,18 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerRow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
@@ -296,6 +299,33 @@ public class TreeModelViewer extends TreeViewer {
setLabelProvider(new TreeModelLabelProvider(this));
}
+
+
+ protected void hookControl(Control control) {
+ Tree treeControl = (Tree) control;
+ treeControl.addListener(SWT.SetData, new Listener() {
+ public void handleEvent(Event event) {
+ // to avoid flash, reset previous labels/image
+ TreeItem item = (TreeItem) event.item;
+ Object[] labels = (Object[]) item.getData(LabelUpdate.PREV_LABEL_KEY);
+ if (labels != null) {
+ for (int i = 0; i < labels.length; i++) {
+ item.setText(i, (String)labels[i]);
+ }
+ }
+ Object[] images = (Object[]) item.getData(LabelUpdate.PREV_IAMGE_KEY);
+ if (images != null) {
+ for (int i = 0; i < images.length; i++) {
+ item.setImage(i, (Image) images[i]);
+ }
+ }
+ }
+ });
+ super.hookControl(control);
+ }
+
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ContentViewer#handleDispose(org.eclipse.swt.events.DisposeEvent)
*/
@@ -875,30 +905,6 @@ public class TreeModelViewer extends TreeViewer {
}
}
}
-
- /**
- * @param updates
- */
- protected void apply(LabelUpdate[] updates) {
- Object prevElement = null;
- Widget[] widgets = null;
- for (int i = 0; i < updates.length; i++) {
- LabelUpdate update = updates[i];
- Object element = update.getElement();
- if (!element.equals(prevElement)) {
- prevElement = element;
- widgets = findItems(element);
- }
- for (int j = 0; j < widgets.length; j++) {
- Widget widget = widgets[j];
- if (widget instanceof TreeItem) {
- TreeItem item = (TreeItem) widget;
- ViewerRow row = getRowPartFromItem(item);
- update.update(row);
- }
- }
- }
- }
/**
* Returns whether the candidate selection should override the current

Back to the top