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/ColumnLabelProvider.java (-7 / +17 lines)
Lines 7-12 Link Here
7
 *
7
 *
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> - Fix for bug 174355
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.jface.viewers;
13
package org.eclipse.jface.viewers;
Lines 32-45 Link Here
32
	 * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
33
	 * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
33
	 */
34
	 */
34
	public void update(ViewerCell cell) {
35
	public void update(ViewerCell cell) {
35
		cell.setText(getText(cell.getElement()));
36
		update(cell, buildLabel(cell));
36
		cell.setImage(getImage(cell.getElement()));
37
		cell.setBackground(getBackground(cell.getElement()));
38
		cell.setForeground(getForeground(cell.getElement()));
39
		cell.setFont(getFont(cell.getElement()));
40
41
	}
37
	}
42
38
	
39
	ViewerLabel buildLabel(ViewerCell cell) {
40
		Object element = cell.getElement();
41
		ViewerLabel label = new ViewerLabel(cell.getText(),cell.getImage());
42
43
		// Set up the initial settings from the label provider
44
		label.setBackground(getBackground(element));
45
		label.setForeground(getForeground(element));
46
		label.setFont(getFont(element));
47
		label.setText(getText(element));
48
		label.setImage(getImage(element));
49
		
50
		return label;
51
	}
52
	
43
	/* (non-Javadoc)
53
	/* (non-Javadoc)
44
	 * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
54
	 * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
45
	 */
55
	 */
(-)src/org/eclipse/jface/viewers/DecoratingLabelProvider.java (-10 / +2 lines)
Lines 7-12 Link Here
7
 *
7
 *
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> - Fix for bug 174355
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jface.viewers;
12
package org.eclipse.jface.viewers;
12
13
Lines 471-485 Link Here
471
		label.setFont(getFont(cell.getElement()));
472
		label.setFont(getFont(cell.getElement()));
472
473
473
		updateLabel(label, cell.getElement());
474
		updateLabel(label, cell.getElement());
474
475
		update(cell, label);
475
		cell.setBackground(label.getBackground());
476
		cell.setForeground(label.getForeground());
477
		cell.setFont(label.getFont());
478
479
		if (label.hasNewText())
480
			cell.setText(label.getText());
481
482
		if (label.hasNewImage())
483
			cell.setImage(label.getImage());
484
	}
476
	}
485
}
477
}
(-)src/org/eclipse/jface/viewers/WrappedViewerLabelProvider.java (+13 lines)
Lines 7-12 Link Here
7
 *
7
 *
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> - Fix for bug 174355
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.jface.viewers;
13
package org.eclipse.jface.viewers;
Lines 33-38 Link Here
33
34
34
	private IFontProvider fontProvider;
35
	private IFontProvider fontProvider;
35
36
37
	private IViewerLabelProvider viewerLabelProvider;
38
	
36
	/**
39
	/**
37
	 * Create a new instance of the receiver based on labelProvider.
40
	 * Create a new instance of the receiver based on labelProvider.
38
	 * 
41
	 * 
Lines 59-64 Link Here
59
		if (provider instanceof IFontProvider)
62
		if (provider instanceof IFontProvider)
60
			fontProvider = (IFontProvider) provider;
63
			fontProvider = (IFontProvider) provider;
61
64
65
		if(provider instanceof IViewerLabelProvider)
66
			viewerLabelProvider = (IViewerLabelProvider) provider;
67
		
62
	}
68
	}
63
69
64
	/*
70
	/*
Lines 115-120 Link Here
115
		return colorProvider.getForeground(element);
121
		return colorProvider.getForeground(element);
116
	}
122
	}
117
123
124
	public void update(ViewerCell cell, ViewerLabel label) {
125
		if( viewerLabelProvider != null ) {
126
			viewerLabelProvider.updateLabel(label, cell.getElement());
127
		}
128
		super.update(cell,label);
129
	}
130
		
118
	/**
131
	/**
119
	 * Get the lable provider
132
	 * Get the lable provider
120
	 * @return {@link ILabelProvider}
133
	 * @return {@link ILabelProvider}
(-)src/org/eclipse/jface/viewers/TableColumnViewerLabelProvider.java (-22 / +12 lines)
Lines 63-100 Link Here
63
	 * @see org.eclipse.jface.viewers.WrappedViewerLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
63
	 * @see org.eclipse.jface.viewers.WrappedViewerLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
64
	 */
64
	 */
65
	public void update(ViewerCell cell) {
65
	public void update(ViewerCell cell) {
66
66
		ViewerLabel label = buildLabel(cell);
67
		
67
		Object element = cell.getElement();
68
		Object element = cell.getElement();
68
		int index = cell.getColumnIndex();
69
		int index = cell.getColumnIndex();
69
70
70
		if (tableLabelProvider == null) {
71
		if (tableLabelProvider != null) {
71
			cell.setText(getLabelProvider().getText(element));
72
			label.setText(tableLabelProvider.getColumnText(element, index));
72
			cell.setImage(getLabelProvider().getImage(element));
73
			label.setImage(tableLabelProvider.getColumnImage(element, index));
73
		} else {
74
			cell.setText(tableLabelProvider.getColumnText(element, index));
75
			cell.setImage(tableLabelProvider.getColumnImage(element, index));
76
		}
74
		}
77
75
78
		if (tableColorProvider == null) {
76
		if (tableColorProvider != null) {
79
			if (getColorProvider() != null) {
77
			label.setBackground(tableColorProvider
80
				cell.setBackground(getColorProvider().getBackground(element));
81
				cell.setForeground(getColorProvider().getForeground(element));
82
			}
83
84
		} else {
85
			cell.setBackground(tableColorProvider
86
					.getBackground(element, index));
78
					.getBackground(element, index));
87
			cell.setForeground(tableColorProvider
79
			label.setForeground(tableColorProvider
88
					.getForeground(element, index));
80
					.getForeground(element, index));
89
90
		}
81
		}
91
82
92
		if (tableFontProvider == null) {
83
		if (tableFontProvider != null) {
93
			if (getFontProvider() != null)
84
			label.setFont(tableFontProvider.getFont(element, index));
94
				cell.setFont(getFontProvider().getFont(element));
85
		}
95
		} else
96
			cell.setFont(tableFontProvider.getFont(element, index));
97
86
87
		update(cell, label);
98
	}
88
	}
99
89
100
90
(-)src/org/eclipse/jface/viewers/CellLabelProvider.java (-1 / +18 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
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 174355
11
 ******************************************************************************/
12
 ******************************************************************************/
12
13
13
package org.eclipse.jface.viewers;
14
package org.eclipse.jface.viewers;
Lines 193-196 Link Here
193
	 */
194
	 */
194
	public abstract void update(ViewerCell cell);
195
	public abstract void update(ViewerCell cell);
195
196
196
}
197
	/**
198
	 * update the cell using the informations provided by {@link ViewerLabel} 
199
	 * @param cell the cell
200
	 * @param label the label holding informations
201
	 */
202
	void update(ViewerCell cell, ViewerLabel label) {
203
		cell.setBackground(label.getBackground());
204
		cell.setForeground(label.getForeground());
205
		cell.setFont(label.getFont());
206
207
		if (label.hasNewText())
208
			cell.setText(label.getText());
209
210
		if (label.hasNewImage())
211
			cell.setImage(label.getImage());
212
	}
213
}
(-)Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerTest.java (-3 / +18 lines)
Lines 16-25 Link Here
16
import org.eclipse.jface.viewers.ColumnViewer;
16
import org.eclipse.jface.viewers.ColumnViewer;
17
import org.eclipse.jface.viewers.ColumnWeightData;
17
import org.eclipse.jface.viewers.ColumnWeightData;
18
import org.eclipse.jface.viewers.ITableLabelProvider;
18
import org.eclipse.jface.viewers.ITableLabelProvider;
19
import org.eclipse.jface.viewers.IViewerLabelProvider;
19
import org.eclipse.jface.viewers.StructuredViewer;
20
import org.eclipse.jface.viewers.StructuredViewer;
20
import org.eclipse.jface.viewers.TableLayout;
21
import org.eclipse.jface.viewers.TableLayout;
21
import org.eclipse.jface.viewers.TableViewer;
22
import org.eclipse.jface.viewers.TableViewer;
22
import org.eclipse.jface.viewers.ViewerColumn;
23
import org.eclipse.jface.viewers.ViewerColumn;
24
import org.eclipse.jface.viewers.ViewerLabel;
23
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Image;
26
import org.eclipse.swt.graphics.Image;
25
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Composite;
Lines 34-40 Link Here
34
36
35
		public String getText(Object element) {
37
		public String getText(Object element) {
36
			if (fExtended)
38
			if (fExtended)
37
				return providedString((String) element);
39
				return providedString((TestElement) element);
38
			return element.toString();
40
			return element.toString();
39
		}
41
		}
40
42
Lines 49-54 Link Here
49
		}
51
		}
50
	}
52
	}
51
53
54
	public static class TableTestViewerLabelProvider extends TableTestLabelProvider implements IViewerLabelProvider {
55
56
		public void updateLabel(ViewerLabel label, Object element) {
57
			label.setText("ViewerLabelProvider-"+label.getText());
58
		}
59
		
60
	}
61
	
52
	public TableViewerTest(String name) {
62
	public TableViewerTest(String name) {
53
		super(name);
63
		super(name);
54
	}
64
	}
Lines 183-188 Link Here
183
193
184
	}
194
	}
185
195
186
	
196
	public void testViewerLabelProvider() {
197
		TableViewer tableviewer = (TableViewer) fViewer;
198
		tableviewer.setLabelProvider(new TableTestViewerLabelProvider());
199
		assertTrue(getItemText(0).startsWith("ViewerLabelProvider-"));
200
		tableviewer.setLabelProvider(new TableTestLabelProvider());
201
	}
187
202
188
}
203
}
(-)Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerColumnTest.java (-1 / +1 lines)
Lines 32-38 Link Here
32
32
33
        public String getText(Object element) {
33
        public String getText(Object element) {
34
            if (fExtended)
34
            if (fExtended)
35
                return providedString((String) element);
35
                return providedString((TestElement) element);
36
36
37
            return element.toString();
37
            return element.toString();
38
        }
38
        }

Return to bug 174355