KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006 Tom Schindl 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  * Tom Schindl - initial API and implementation
10  * Boris Bokowski (IBM Corporation) - Javadoc improvements
11  ******************************************************************************/

12
13 package org.eclipse.jface.viewers;
14
15 import org.eclipse.swt.widgets.Table;
16 import org.eclipse.swt.widgets.TableColumn;
17
18 /**
19  * ViewerColumn implementation for TableViewer to enable column-specific label
20  * providers and editing support.
21  *
22  * @since 3.3
23  */

24 public final class TableViewerColumn extends ViewerColumn {
25     private TableColumn column;
26
27     /**
28      * Creates a new viewer column for the given {@link TableViewer} on a new
29      * {@link TableColumn} with the given style bits. The column is added at the
30      * end of the list of columns.
31      *
32      * @param viewer
33      * the table viewer to which this column belongs
34      * @param style
35      * the style used to create the column, for applicable style bits
36      * see {@link TableColumn}
37      * @see TableColumn#TableColumn(Table, int)
38      */

39     public TableViewerColumn(TableViewer viewer, int style) {
40         this(viewer, style, -1);
41     }
42
43     /**
44      * Creates a new viewer column for the given {@link TableViewer} on a new
45      * {@link TableColumn} with the given style bits. The column is inserted at
46      * the given index into the list of columns.
47      *
48      * @param viewer
49      * the table viewer to which this column belongs
50      * @param style
51      * the style used to create the column, for applicable style bits
52      * see {@link TableColumn}
53      * @param index
54      * the index at which to place the newly created column
55      * @see TableColumn#TableColumn(Table, int, int)
56      */

57     public TableViewerColumn(TableViewer viewer, int style, int index) {
58         this(viewer, createColumn(viewer.getTable(), style, index));
59     }
60
61     /**
62      * Creates a new viewer column for the given {@link TableViewer} on the given
63      * {@link TableColumn}.
64      *
65      * @param viewer
66      * the table viewer to which this column belongs
67      * @param column
68      * the underlying table column
69      */

70     public TableViewerColumn(TableViewer viewer, TableColumn column) {
71         super(viewer, column);
72         this.column = column;
73     }
74     
75     private static TableColumn createColumn(Table table, int style, int index) {
76         if (index >= 0) {
77             return new TableColumn(table, style, index);
78         }
79
80         return new TableColumn(table, style);
81     }
82
83     /**
84      * @return the underlying SWT table column
85      */

86     public TableColumn getColumn() {
87         return column;
88     }
89 }
90
Popular Tags