rendered paste body### Eclipse Workspace Patch 1.0
#P org.eclipse.jface
Index: src/org/eclipse/jface/viewers/StyledCellLabelProvider.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java,v
retrieving revision 1.3
diff -u -r1.3 StyledCellLabelProvider.java
--- src/org/eclipse/jface/viewers/StyledCellLabelProvider.java 23 Apr 2008 16:18:14 -0000 1.3
+++ src/org/eclipse/jface/viewers/StyledCellLabelProvider.java 24 Apr 2008 16:14:42 -0000
@@ -21,6 +21,7 @@
import org.eclipse.swt.graphics.TextLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Widget;
/**
* A {@link StyledCellLabelProvider} supports styled labels by using owner
@@ -67,6 +68,8 @@
private ColumnViewer viewer;
private ViewerColumn column;
+
+ private Widget itemOfLastMeasure;
/**
* Creates a new StyledCellLabelProvider. By default, owner draw is enabled, focus is drawn and no
@@ -269,6 +272,23 @@
boolean applyColors = useColors(event); // always returns false
TextLayout layout = getSharedTextLayout(event.display);
+
+ int textWidthDelta = updateTextLayout(layout, cell, applyColors);
+ /* remove-begin if bug 228695 fixed */
+ itemOfLastMeasure = event.item;
+ /* remove-end if bug 228695 fixed */
+
+ event.width += textWidthDelta;
+ }
+
+ /**
+ * @param layout
+ * @param cell
+ * @param applyColors
+ * @return the text width delta (0 if the text layout contains no other font)
+ */
+ private int updateTextLayout(TextLayout layout, ViewerCell cell,
+ boolean applyColors) {
layout.setText(""); //$NON-NLS-1$ //make sure all previous ranges are cleared (see bug 226090)
layout.setText(cell.getText());
@@ -288,10 +308,11 @@
}
}
}
+ int textWidthDelta = 0;
if (containsOtherFont) {
- int textWidthDelta= layout.getBounds().width - originalTextWidth;
- event.width += textWidthDelta;
+ textWidthDelta = layout.getBounds().width - originalTextWidth;
}
+ return textWidthDelta;
}
/*
@@ -307,6 +328,7 @@
ViewerCell cell= getViewerCell(event, element);
boolean applyColors = useColors(event);
+
GC gc = event.gc;
// remember colors to restore the GC later
Color oldForeground = gc.getForeground();
@@ -323,7 +345,6 @@
gc.setBackground(background);
}
}
-
Image image = cell.getImage();
if (image != null) {
Rectangle imageBounds = cell.getImageBounds();
@@ -341,8 +362,15 @@
Rectangle textBounds = cell.getTextBounds();
if (textBounds != null) {
- // fLayout has already been configured in 'measure()'
TextLayout textLayout= getSharedTextLayout(event.display);
+
+ /* remove-begin if bug 228695 fixed */
+ if (event.item != itemOfLastMeasure) {
+ // fLayout has not been configured in 'measure()'
+ updateTextLayout(textLayout, cell, applyColors);
+ itemOfLastMeasure = event.item;
+ }
+ /* remove-end if bug 228695 fixed */
/* remove-begin if bug 228376 fixed */
if (!applyColors) {