01: /*******************************************************************************
02: * Copyright (c) 2006 Tom Schindl 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: * Tom Schindl - initial API and implementation
10: * Boris Bokowski (IBM Corporation) - Javadoc improvements
11: ******************************************************************************/package org.eclipse.jface.viewers;
12:
13: import org.eclipse.swt.widgets.Table;
14: import org.eclipse.swt.widgets.TableColumn;
15:
16: /**
17: * ViewerColumn implementation for TableViewer to enable column-specific label
18: * providers and editing support.
19: *
20: * @since 3.3
21: */
22: public final class TableViewerColumn extends ViewerColumn {
23: private TableColumn column;
24:
25: /**
26: * Creates a new viewer column for the given {@link TableViewer} on a new
27: * {@link TableColumn} with the given style bits. The column is added at the
28: * end of the list of columns.
29: *
30: * @param viewer
31: * the table viewer to which this column belongs
32: * @param style
33: * the style used to create the column, for applicable style bits
34: * see {@link TableColumn}
35: * @see TableColumn#TableColumn(Table, int)
36: */
37: public TableViewerColumn(TableViewer viewer, int style) {
38: this (viewer, style, -1);
39: }
40:
41: /**
42: * Creates a new viewer column for the given {@link TableViewer} on a new
43: * {@link TableColumn} with the given style bits. The column is inserted at
44: * the given index into the list of columns.
45: *
46: * @param viewer
47: * the table viewer to which this column belongs
48: * @param style
49: * the style used to create the column, for applicable style bits
50: * see {@link TableColumn}
51: * @param index
52: * the index at which to place the newly created column
53: * @see TableColumn#TableColumn(Table, int, int)
54: */
55: public TableViewerColumn(TableViewer viewer, int style, int index) {
56: this (viewer, createColumn(viewer.getTable(), style, index));
57: }
58:
59: /**
60: * Creates a new viewer column for the given {@link TableViewer} on the given
61: * {@link TableColumn}.
62: *
63: * @param viewer
64: * the table viewer to which this column belongs
65: * @param column
66: * the underlying table column
67: */
68: public TableViewerColumn(TableViewer viewer, TableColumn column) {
69: super (viewer, column);
70: this .column = column;
71: }
72:
73: private static TableColumn createColumn(Table table, int style,
74: int index) {
75: if (index >= 0) {
76: return new TableColumn(table, style, index);
77: }
78:
79: return new TableColumn(table, style);
80: }
81:
82: /**
83: * @return the underlying SWT table column
84: */
85: public TableColumn getColumn() {
86: return column;
87: }
88: }
|