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 61869
Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/TableViewer.java (-5 / +14 lines)
Lines 180-186 Link Here
180
		IBaseLabelProvider prov = getLabelProvider();
180
		IBaseLabelProvider prov = getLabelProvider();
181
		ITableLabelProvider tprov = null;
181
		ITableLabelProvider tprov = null;
182
		ILabelProvider lprov = null;
182
		ILabelProvider lprov = null;
183
		ITableColorProvider cprov = null;
183
		
184
		
185
		if (prov instanceof ITableColorProvider) {
186
		    cprov = (ITableColorProvider)prov;
187
		}
184
			
188
			
185
		if (prov instanceof ITableLabelProvider) {
189
		if (prov instanceof ITableLabelProvider) {
186
			tprov = (ITableLabelProvider) prov;
190
			tprov = (ITableLabelProvider) prov;
Lines 195-200 Link Here
195
			// Similar code in TableTreeViewer.doUpdateItem()
199
			// Similar code in TableTreeViewer.doUpdateItem()
196
			String text = "";//$NON-NLS-1$
200
			String text = "";//$NON-NLS-1$
197
			Image image = null;
201
			Image image = null;
202
			if(cprov != null) {
203
			    ti.setBackground(column, cprov.getBackground(element, column));
204
			    ti.setForeground(column, cprov.getForeground(element, column));
205
			}
198
			if (tprov != null) {
206
			if (tprov != null) {
199
				text = tprov.getColumnText(element, column);
207
				text = tprov.getColumnText(element, column);
200
				image = tprov.getColumnImage(element, column);
208
				image = tprov.getColumnImage(element, column);
Lines 216-231 Link Here
216
					}
224
					}
217
		    	}
225
		    	}
218
	    	}
226
	    	}
227
			
219
			ti.setText(column, text);
228
			ti.setText(column, text);
220
			if (ti.getImage(column) != image) {
229
			if (ti.getImage(column) != image) {
221
				ti.setImage(column, image);
230
				ti.setImage(column, image);
222
			}
231
			}
223
		}
232
		}
224
		if (prov instanceof IColorProvider) {
233
//		if (prov instanceof IColorProvider) {
225
			IColorProvider cprov = (IColorProvider) prov;
234
//			IColorProvider cprov = (IColorProvider) prov;
226
			ti.setForeground(cprov.getForeground(element));
235
//			ti.setForeground(cprov.getForeground(element));
227
			ti.setBackground(cprov.getBackground(element));
236
//			ti.setBackground(cprov.getBackground(element));
228
		}
237
//		}
229
		if (prov instanceof IFontProvider) {
238
		if (prov instanceof IFontProvider) {
230
		    IFontProvider fprov = (IFontProvider) prov;
239
		    IFontProvider fprov = (IFontProvider) prov;
231
		    ti.setFont(fprov.getFont(element));
240
		    ti.setFont(fprov.getFont(element));
(-)src/org/eclipse/jface/viewers/ITableColorProvider.java (+42 lines)
Added Link Here
1
/*
2
 * Contributed by Gunnar Ahlberg (www.gunnarahlberg.com)
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     Gunnar Ahlberg - www.gunnarahlberg.com
10
 *******************************************************************************/
11
12
package org.eclipse.jface.viewers;
13
14
import org.eclipse.swt.graphics.Color;
15
16
/**
17
 * Interface to provide color representation for a given element.
18
 */
19
public interface ITableColorProvider {
20
21
    /**
22
     * Provides a foreground color for the given element.
23
     * 
24
     * @param element the element
25
     * @param columnIndex the zero-based index of the column in which
26
     * 	the color appears
27
     * @return the foreground color for the element, or <code>null</code> to
28
     *         use the default foreground color
29
     */
30
    Color getForeground(Object element, int columnIndex);
31
32
    /**
33
     * Provides a background color for the given element at the specified index
34
     * 
35
     * @param element the element
36
     * @param columnIndex the zero-based index of the column in which the color appears
37
     * @return the background color for the element, or <code>null</code> to
38
     *         use the default background color
39
     *  
40
     */
41
    Color getBackground(Object element, int columnIndex);
42
}

Return to bug 61869