01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.viewers;
11:
12: import org.eclipse.swt.graphics.Color;
13: import org.eclipse.swt.graphics.Font;
14: import org.eclipse.swt.graphics.Image;
15:
16: /**
17: * The ColumnLabelProvider is the label provider for viewers
18: * that have column support such as {@link TreeViewer} and
19: * {@link TableViewer}
20: *
21: * <p><b>This classes is intended to be subclassed</b></p>
22: *
23: * @since 3.3
24: *
25: */
26: public class ColumnLabelProvider extends CellLabelProvider implements
27: IFontProvider, IColorProvider, ILabelProvider {
28:
29: /* (non-Javadoc)
30: * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
31: */
32: public void update(ViewerCell cell) {
33: Object element = cell.getElement();
34: cell.setText(getText(element));
35: Image image = getImage(element);
36: cell.setImage(image);
37: cell.setBackground(getBackground(element));
38: cell.setForeground(getForeground(element));
39: cell.setFont(getFont(element));
40:
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
45: */
46: public Font getFont(Object element) {
47: return null;
48: }
49:
50: /* (non-Javadoc)
51: * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
52: */
53: public Color getBackground(Object element) {
54: return null;
55: }
56:
57: /* (non-Javadoc)
58: * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
59: */
60: public Color getForeground(Object element) {
61: return null;
62: }
63:
64: /* (non-Javadoc)
65: * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
66: */
67: public Image getImage(Object element) {
68: return null;
69: }
70:
71: /* (non-Javadoc)
72: * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
73: */
74: public String getText(Object element) {
75: return element == null ? "" : element.toString();//$NON-NLS-1$
76: }
77:
78: }
|