Mercurial > projects > dwt-addons
comparison dwtx/jface/viewers/TreeViewerColumn.d @ 10:b6c35faf97c8
Viewers
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 31 Mar 2008 00:47:19 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:6c14e54dfc11 | 10:b6c35faf97c8 |
---|---|
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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 ******************************************************************************/ | |
13 | |
14 module dwtx.jface.viewers.TreeViewerColumn; | |
15 | |
16 import dwtx.jface.viewers.ViewerColumn; | |
17 import dwtx.jface.viewers.TreeViewer; | |
18 | |
19 import dwt.widgets.Tree; | |
20 import dwt.widgets.TreeColumn; | |
21 | |
22 import dwt.dwthelper.utils; | |
23 | |
24 /** | |
25 * ViewerColumn implementation for TreeViewer to enable column-specific label | |
26 * providers and editing support. | |
27 * | |
28 * @since 3.3 | |
29 * | |
30 */ | |
31 public final class TreeViewerColumn : ViewerColumn { | |
32 private TreeColumn column; | |
33 | |
34 /** | |
35 * Creates a new viewer column for the given {@link TreeViewer} on a new | |
36 * {@link TreeColumn} with the given style bits. The column is inserted at | |
37 * the given index into the list of columns. | |
38 * | |
39 * @param viewer | |
40 * the tree viewer to which this column belongs | |
41 * @param style | |
42 * the style bits used to create the column, for applicable style bits | |
43 * see {@link TreeColumn} | |
44 * @see TreeColumn#TreeColumn(Tree, int) | |
45 */ | |
46 public this(TreeViewer viewer, int style) { | |
47 this(viewer, style, -1); | |
48 } | |
49 | |
50 /** | |
51 * Creates a new viewer column for the given {@link TreeViewer} on a new | |
52 * {@link TreeColumn} with the given style bits. The column is added at the | |
53 * end of the list of columns. | |
54 * | |
55 * @param viewer | |
56 * the tree viewer to which this column belongs | |
57 * @param style | |
58 * the style bits used to create the column, for applicable style bits | |
59 * see {@link TreeColumn} | |
60 * @param index | |
61 * the index at which to place the newly created column | |
62 * @see TreeColumn#TreeColumn(Tree, int, int) | |
63 */ | |
64 public this(TreeViewer viewer, int style, int index) { | |
65 this(viewer, createColumn(viewer.getTree(), style, index)); | |
66 } | |
67 | |
68 /** | |
69 * Creates a new viewer column for the given {@link TreeViewer} on the given | |
70 * {@link TreeColumn}. | |
71 * | |
72 * @param viewer | |
73 * the tree viewer to which this column belongs | |
74 * @param column | |
75 * the underlying tree column | |
76 */ | |
77 public this(TreeViewer viewer, TreeColumn column) { | |
78 super(viewer, column); | |
79 this.column = column; | |
80 } | |
81 | |
82 private static TreeColumn createColumn(Tree table, int style, int index) { | |
83 if (index >= 0) { | |
84 return new TreeColumn(table, style, index); | |
85 } | |
86 | |
87 return new TreeColumn(table, style); | |
88 } | |
89 | |
90 /** | |
91 * @return the underlying DWT column | |
92 */ | |
93 public TreeColumn getColumn() { | |
94 return column; | |
95 } | |
96 } |