1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.eclipse.ui.util;
17
18 import org.eclipse.jface.viewers.TableViewer;
19 import org.eclipse.jface.viewers.TableViewerColumn;
20 import org.eclipse.jface.viewers.TreeViewer;
21 import org.eclipse.jface.viewers.TreeViewerColumn;
22 import org.eclipse.swt.widgets.Table;
23 import org.eclipse.swt.widgets.TableColumn;
24 import org.eclipse.swt.widgets.TreeColumn;
25
26
27
28
29 public class ViewerUtils {
30
31
32
33
34
35 public static TableColumn createColumn(Table parent, String name, int style, int width) {
36 TableColumn result = new TableColumn(parent, style);
37 result.setText(name);
38 result.setWidth(width);
39 result.setResizable(true);
40 return result;
41 }
42
43
44
45
46
47 public static TableViewerColumn createTableViewerColumn(TableViewer parent, String name, int style, int width) {
48 TableViewerColumn tvc = new TableViewerColumn(parent, style);
49 TableColumn column = tvc.getColumn();
50 column.setText(name);
51 column.setWidth(width);
52 column.setResizable(true);
53 return tvc;
54 }
55
56
57
58
59
60
61
62
63
64
65 public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent, String name, int style, int width) {
66 TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
67 TreeColumn column = tvc.getColumn();
68 column.setText(name);
69 column.setWidth(width);
70 column.setResizable(true);
71 return tvc;
72 }
73 }