Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ebd0975bf74ca1e6e3d6d9e6286773d862038efc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*******************************************************************************
 * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
 * This program and the accompanying materials are made available under the terms
 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.te.ui.trees;

import java.util.Comparator;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.TreeColumn;

/**
 * <p>
 * The data descriptor to describe tree columns of a tree viewer.
 * </p>
 * <p>
 * A ColumnDescriptor encapsulates the following information about the tree
 * column:
 * <ol>
 * <li><code>name</code>, the column's name used as the column's label.</li>
 * <li><code>description</code>, the column's description used as the tooltip
 * text of the column.</li>
 * <li><code>moveable</code>, if the column is move able.</li>
 * <li><code>resizable</code>, if the column is resizable.</li>
 * <li><code>visible</code>, if the column is visible.</li>
 * <li><code>style</code>, the column's style when it is created.</li>
 * <li><code>alignment</code>, the alignment of the column's header text.</li>
 * <li><code>width</code>, the column's initial width when it is created.</li>
 * <li><code>image</code>, the column's image displayed in the header.</li>
 * <li><code>labelProvider</code>, the label provider of the column.</li>
 * <li><code>comparator</code>, the comparator of the column.</li>
 * </ol>
 * </p>
 * <p>
 * This class is not intended to be subclassed.
 * </p>
 */
public class ColumnDescriptor {
	private String id;
	//The name of the column, used as the column's label.
	private String name;
	//The description of the column, used as the column's tooltip text.
	private String description;

	//If the column is move able.
	private boolean moveable;
	//If the column is resizable, true by default.
	private boolean resizable = true;
	//If the column is visible, true by default.
	private boolean visible = true;

	//The style of the column when it is created, SWT.LEFT by default.
	private int style = SWT.LEFT;
	//The alignment of the column's header text, SWT.LEFT by default.
	private int alignment = SWT.LEFT;
	//The column's initial width when it is created, 150 by default.
	private int width = 150;

	//The column's header image.
	private Image image;

	//The label provider of the column.
	private ILabelProvider labelProvider;

	//The comparator of the column, used to sort the viewer.
	private Comparator<Object> comparator;

	//The corresponding tree column. Not intended to be changed by other callers.
	private TreeColumn treeColumn;
	//If the column's sorting order is ascending. Defaults to true. Not intended to be changed by other callers.
	private boolean ascending = true;
	//The column's order. Not intended to be changed by other callers.
	private int order;

	/**
	 * Create a column descriptor with specified column id.
	 *
	 * @param id
	 * 				The column id;
	 */
	public ColumnDescriptor(String id) {
		this.id = id;
	}

	/**
	 * Get the column's id.
	 *
	 * @return the column's id.
	 */
	public String getId() {
		return id;
	}

	/**
	 * Set the column's id.
	 *
	 * @param id
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * Get the column's sorting orientation.
	 *
	 * @return The sorting orientation.
	 */
	public boolean isAscending() {
		return ascending;
	}

	/**
	 * Set the column's sorting orientation.
	 *
	 * @param a The new orientation.
	 */
	public void setAscending(boolean a) {
		this.ascending = a;
	}

	/**
	 * Set the column's sorting comparator.
	 *
	 * @param comparator The new comparator.
	 */
	public void setComparator(Comparator<Object> comparator) {
		this.comparator = comparator;
	}

	/**
	 * Get the column's sorting comparator.
	 *
	 * @return The new comparator.
	 */
	public Comparator<Object> getComparator() {
		return comparator;
	}

	/**
	 * Set the tree column.
	 *
	 * @param column The tree column.
	 */
	public void setTreeColumn(TreeColumn column) {
		this.treeColumn = column;
	}

	/**
	 * Get the tree column.
	 *
	 * @return The tree column.
	 */
	public TreeColumn getTreeColumn() {
		return treeColumn;
	}

	/**
	 * Set the visibility of this tree column.
	 *
	 * @param v the new visibility
	 */
	public void setVisible(boolean v) {
		visible = v;
	}

	/**
	 * Get the visibility of the tree column.
	 *
	 * @return This column's visibility.
	 */
	public boolean isVisible() {
		return visible;
	}

	/**
	 * Set the name of the column.
	 *
	 * @param name The new name.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Get the name of the column.
	 *
	 * @return The column's name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set the description of the column.
	 *
	 * @param desc The column's description.
	 */
	public void setDescription(String desc) {
		description = desc;
	}

	/**
	 * Get the description of the column.
	 *
	 * @return The column's description.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Set if the column is moveable.
	 *
	 * @param m The new value.
	 */
	public void setMoveable(boolean m) {
		moveable = m;
	}

	/**
	 * Get if the column is move able.
	 *
	 * @return If the column is move able.
	 */
	public boolean isMoveable() {
		return moveable;
	}

	/**
	 * Set the column's creation style.
	 *
	 * @param style The column's creation style.
	 */
	public void setStyle(int style) {
		this.style = style;
	}

	/**
	 * Get the column's creation style.
	 *
	 * @return The column's creation style.
	 */
	public int getStyle() {
		return style;
	}

	/**
	 * Set the column's alignment.
	 *
	 * @param alignment The column's alignment.
	 */
	public void setAlignment(int alignment) {
		this.alignment = alignment;
	}

	/**
	 * Get the column's alignment.
	 *
	 * @return The column's alignment.
	 */
	public int getAlignment() {
		return alignment;
	}

	/**
	 * Set the column's image.
	 *
	 * @param img The new image.
	 */
	public void setImage(Image img) {
		this.image = img;
	}

	/**
	 * Get the column's image.
	 *
	 * @return The column's image.
	 */
	public Image getImage() {
		return image;
	}

	/**
	 * Set if the column is resizable.
	 *
	 * @param r The new value.
	 */
	public void setResizable(boolean r) {
		resizable = r;
	}

	/**
	 * Get if the column is resizable.
	 *
	 * @return If the column is resizable.
	 */
	public boolean isResizable() {
		return resizable;
	}

	/**
	 * Set the column's initial width.
	 *
	 * @param width The new column width.
	 */
	public void setWidth(int width) {
		this.width = width;
	}

	/**
	 * Get the column's initial width.
	 *
	 * @return the column's initial width.
	 */
	public int getWidth() {
		return width;
	}

	/**
	 * Set the column's label provider.
	 *
	 * @param p The new column label provider.
	 */
	public void setLabelProvider(ILabelProvider p) {
		labelProvider = p;
	}

	/**
	 * Get the column's label provider.
	 *
	 * @return The column's label provider.
	 */
	public ILabelProvider getLabelProvider() {
		return labelProvider;
	}

	/**
	 * Get the column's order number.
	 *
	 * @return The column's order.
	 */
	public int getOrder() {
    	return order;
    }

	/**
	 * Set the column's order.
	 *
	 * @param order The new order.
	 */
	public void setOrder(int order) {
    	this.order = order;
    }
}

Back to the top