KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > ColumnLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jface.viewers;
13
14 import org.eclipse.swt.graphics.Color;
15 import org.eclipse.swt.graphics.Font;
16 import org.eclipse.swt.graphics.Image;
17
18 /**
19  * The ColumnLabelProvider is the label provider for viewers
20  * that have column support such as {@link TreeViewer} and
21  * {@link TableViewer}
22  *
23  * <p><b>This classes is intended to be subclassed</b></p>
24  *
25  * @since 3.3
26  *
27  */

28 public class ColumnLabelProvider extends CellLabelProvider implements
29         IFontProvider, IColorProvider, ILabelProvider {
30
31     /* (non-Javadoc)
32      * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
33      */

34     public void update(ViewerCell cell) {
35         Object JavaDoc element = cell.getElement();
36         cell.setText(getText(element));
37         Image image = getImage(element);
38         cell.setImage(image);
39         cell.setBackground(getBackground(element));
40         cell.setForeground(getForeground(element));
41         cell.setFont(getFont(element));
42
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
47      */

48     public Font getFont(Object JavaDoc element) {
49         return null;
50     }
51
52     /* (non-Javadoc)
53      * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
54      */

55     public Color getBackground(Object JavaDoc element) {
56         return null;
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
61      */

62     public Color getForeground(Object JavaDoc element) {
63         return null;
64     }
65
66
67     /* (non-Javadoc)
68      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
69      */

70     public Image getImage(Object JavaDoc element) {
71         return null;
72     }
73
74     /* (non-Javadoc)
75      * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
76      */

77     public String JavaDoc getText(Object JavaDoc element) {
78         return element == null ? "" : element.toString();//$NON-NLS-1$
79
}
80
81 }
82
Popular Tags