Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 174355 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/TableViewerRow.java (+6 lines)
Lines 9-14 Link Here
9
 * Contributors:
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
10
 *     IBM Corporation - initial API and implementation
11
 *     Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation
11
 *     Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation
12
 *     											- Fix for bug 174355
12
 ******************************************************************************/
13
 ******************************************************************************/
13
14
14
package org.eclipse.jface.viewers;
15
package org.eclipse.jface.viewers;
Lines 181-184 Link Here
181
		return null;
182
		return null;
182
	}
183
	}
183
184
185
	public TreePath getTreePath() {
186
		// Tables don't support paths
187
		return null;
188
	}
189
184
}
190
}
(-)src/org/eclipse/jface/viewers/WrappedViewerLabelProvider.java (+47 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.jface.viewers;
12
package org.eclipse.jface.viewers;
13
13
14
import org.eclipse.core.runtime.Assert;
14
import org.eclipse.swt.graphics.Color;
15
import org.eclipse.swt.graphics.Color;
15
import org.eclipse.swt.graphics.Font;
16
import org.eclipse.swt.graphics.Font;
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Image;
Lines 33-38 Link Here
33
34
34
	private IFontProvider fontProvider;
35
	private IFontProvider fontProvider;
35
36
37
	private IViewerLabelProvider viewerLabelProvider;
38
39
	private ITreePathLabelProvider treePathLabelProvider;
40
	
36
	/**
41
	/**
37
	 * Create a new instance of the receiver based on labelProvider.
42
	 * Create a new instance of the receiver based on labelProvider.
38
	 * 
43
	 * 
Lines 50-55 Link Here
50
	 *            {@link Object}
55
	 *            {@link Object}
51
	 */
56
	 */
52
	public void setProviders(Object provider) {
57
	public void setProviders(Object provider) {
58
		if (provider instanceof ITreePathLabelProvider)
59
			treePathLabelProvider = ((ITreePathLabelProvider) provider);
60
61
		if (provider instanceof IViewerLabelProvider)
62
			viewerLabelProvider = ((IViewerLabelProvider) provider);
63
		
53
		if (provider instanceof ILabelProvider)
64
		if (provider instanceof ILabelProvider)
54
			labelProvider = ((ILabelProvider) provider);
65
			labelProvider = ((ILabelProvider) provider);
55
66
Lines 138-141 Link Here
138
	IFontProvider getFontProvider() {
149
	IFontProvider getFontProvider() {
139
		return fontProvider;
150
		return fontProvider;
140
	}
151
	}
152
	
153
	public void update(ViewerCell cell) {
154
		if (viewerLabelProvider != null) {
155
			ViewerLabel label = new ViewerLabel(cell.getText(), cell.getImage());
156
			viewerLabelProvider.updateLabel(label, cell.getElement());
157
			applyViewerLabel(cell, label);
158
		} else if (treePathLabelProvider != null) {
159
			ViewerLabel label = new ViewerLabel(cell.getText(), cell.getImage());
160
			TreePath treePath = cell.getViewerRow().getTreePath();
161
			
162
			Assert.isNotNull(treePath);
163
			treePathLabelProvider.updateLabel(label, treePath);
164
			
165
			applyViewerLabel(cell, label);
166
		} else {
167
			super.update(cell);
168
		}
169
	}
170
171
	private void applyViewerLabel(ViewerCell cell, ViewerLabel label) {
172
		if (label.hasNewText()) {
173
			cell.setText(label.getText());
174
		}
175
		if (label.hasNewImage()) {
176
			cell.setImage(label.getImage());
177
		}
178
		if (label.hasNewBackground()) {
179
			cell.setBackground(label.getBackground());
180
		}
181
		if (label.hasNewForeground()) {
182
			cell.setForeground(label.getForeground());
183
		}
184
		if (label.hasNewFont()) {
185
			cell.setFont(label.getFont());
186
		}
187
	}
141
}
188
}
(-)src/org/eclipse/jface/viewers/TreeViewerRow.java (-3 / +22 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
10
 *     Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
11
 *     											 - Fix for bug 174355
11
 ******************************************************************************/
12
 ******************************************************************************/
12
13
13
package org.eclipse.jface.viewers;
14
package org.eclipse.jface.viewers;
14
15
16
import java.util.ArrayList;
17
import java.util.LinkedList;
18
19
import org.eclipse.core.runtime.Assert;
15
import org.eclipse.swt.graphics.Color;
20
import org.eclipse.swt.graphics.Color;
16
import org.eclipse.swt.graphics.Font;
21
import org.eclipse.swt.graphics.Font;
17
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.graphics.Image;
Lines 293-298 Link Here
293
		
298
		
294
		return rv;
299
		return rv;
295
	}
300
	}
296
	
301
297
	
302
	public TreePath getTreePath() {
298
}
303
		ArrayList path = new ArrayList();
304
		path.add(item.getData());
305
		
306
		TreeItem tItem = item;
307
		LinkedList segments = new LinkedList();
308
		while (tItem != null) {
309
			Object segment = tItem.getData();
310
			Assert.isNotNull(segment);
311
			segments.addFirst(segment);
312
			tItem = tItem.getParentItem();
313
		}
314
		
315
		return new TreePath(segments.toArray());
316
	}
317
}
(-)src/org/eclipse/jface/viewers/ViewerRow.java (-4 / +11 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation
10
 *     Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation
11
 *                                                fix for bug 166346, bug 167325s
11
 *                                                fix for bug 166346, bug 167325s
12
 *                                              - Fix for bug 174355
12
 ******************************************************************************/
13
 ******************************************************************************/
13
14
14
package org.eclipse.jface.viewers;
15
package org.eclipse.jface.viewers;
Lines 40-51 Link Here
40
41
41
	/**
42
	/**
42
	 * Constant denoting the row above the current one (value is 1).
43
	 * Constant denoting the row above the current one (value is 1).
44
	 * 
43
	 * @see #getNeighbor(int, boolean)
45
	 * @see #getNeighbor(int, boolean)
44
	 */
46
	 */
45
	public static final int ABOVE = 1;
47
	public static final int ABOVE = 1;
46
48
47
	/**
49
	/**
48
	 * Constant denoting the row below the current one (value is 2).
50
	 * Constant denoting the row below the current one (value is 2).
51
	 * 
49
	 * @see #getNeighbor(int, boolean)
52
	 * @see #getNeighbor(int, boolean)
50
	 */
53
	 */
51
	public static final int BELOW = 2;
54
	public static final int BELOW = 2;
Lines 224-233 Link Here
224
	public abstract Control getControl();
227
	public abstract Control getControl();
225
228
226
	/**
229
	/**
227
	 * Returns a neighboring row, or <code>null</code> if no
230
	 * Returns a neighboring row, or <code>null</code> if no neighbor exists
228
	 * neighbor exists in the given direction. If <code>sameLevel</code> is
231
	 * in the given direction. If <code>sameLevel</code> is <code>true</code>,
229
	 * <code>true</code>, only sibling rows (under the same parent) will be
232
	 * only sibling rows (under the same parent) will be considered.
230
	 * considered.
231
	 * 
233
	 * 
232
	 * @param direction
234
	 * @param direction
233
	 *            the direction {@link #BELOW} or {@link #ABOVE}
235
	 *            the direction {@link #BELOW} or {@link #ABOVE}
Lines 238-241 Link Here
238
	 */
240
	 */
239
	public abstract ViewerRow getNeighbor(int direction, boolean sameLevel);
241
	public abstract ViewerRow getNeighbor(int direction, boolean sameLevel);
240
242
243
	/**
244
	 * The tree path used to identify an element by the unique path
245
	 * @return the path or <code>null</code> if no path exists
246
	 */
247
	public abstract TreePath getTreePath();
241
}
248
}

Return to bug 174355