10
|
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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13
|
|
14 module dwtx.jface.viewers.ColumnLabelProvider;
|
|
15
|
|
16 import dwtx.jface.viewers.CellLabelProvider;
|
|
17 import dwtx.jface.viewers.IFontProvider;
|
|
18 import dwtx.jface.viewers.IColorProvider;
|
|
19 import dwtx.jface.viewers.ILabelProvider;
|
|
20 import dwtx.jface.viewers.ViewerCell;
|
|
21
|
|
22 import dwt.graphics.Color;
|
|
23 import dwt.graphics.Font;
|
|
24 import dwt.graphics.Image;
|
|
25
|
|
26 import dwt.dwthelper.utils;
|
|
27
|
|
28 /**
|
|
29 * The ColumnLabelProvider is the label provider for viewers
|
|
30 * that have column support such as {@link TreeViewer} and
|
|
31 * {@link TableViewer}
|
|
32 *
|
|
33 * <p><b>This classes is intended to be subclassed</b></p>
|
|
34 *
|
|
35 * @since 3.3
|
|
36 *
|
|
37 */
|
|
38 public class ColumnLabelProvider : CellLabelProvider,
|
|
39 IFontProvider, IColorProvider, ILabelProvider {
|
|
40
|
|
41 /* (non-Javadoc)
|
|
42 * @see dwtx.jface.viewers.CellLabelProvider#update(dwtx.jface.viewers.ViewerCell)
|
|
43 */
|
|
44 public void update(ViewerCell cell) {
|
|
45 Object element = cell.getElement();
|
|
46 cell.setText(getText(element));
|
|
47 Image image = getImage(element);
|
|
48 cell.setImage(image);
|
|
49 cell.setBackground(getBackground(element));
|
|
50 cell.setForeground(getForeground(element));
|
|
51 cell.setFont(getFont(element));
|
|
52
|
|
53 }
|
|
54
|
|
55 /* (non-Javadoc)
|
|
56 * @see dwtx.jface.viewers.IFontProvider#getFont(java.lang.Object)
|
|
57 */
|
|
58 public Font getFont(Object element) {
|
|
59 return null;
|
|
60 }
|
|
61
|
|
62 /* (non-Javadoc)
|
|
63 * @see dwtx.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
|
64 */
|
|
65 public Color getBackground(Object element) {
|
|
66 return null;
|
|
67 }
|
|
68
|
|
69 /* (non-Javadoc)
|
|
70 * @see dwtx.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
|
71 */
|
|
72 public Color getForeground(Object element) {
|
|
73 return null;
|
|
74 }
|
|
75
|
|
76
|
|
77 /* (non-Javadoc)
|
|
78 * @see dwtx.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
|
79 */
|
|
80 public Image getImage(Object element) {
|
|
81 return null;
|
|
82 }
|
|
83
|
|
84 /* (non-Javadoc)
|
|
85 * @see dwtx.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
|
86 */
|
|
87 public String getText(Object element) {
|
|
88 return element is null ? "" : element.toString();//$NON-NLS-1$
|
|
89 }
|
|
90
|
|
91 }
|