]> git.argeo.org Git - lgpl/argeo-commons.git/blob - util/ViewerUtils.java
Prepare next development cycle
[lgpl/argeo-commons.git] / util / ViewerUtils.java
1 package org.argeo.eclipse.ui.util;
2
3 import org.eclipse.jface.viewers.TableViewer;
4 import org.eclipse.jface.viewers.TableViewerColumn;
5 import org.eclipse.jface.viewers.TreeViewer;
6 import org.eclipse.jface.viewers.TreeViewerColumn;
7 import org.eclipse.swt.widgets.Table;
8 import org.eclipse.swt.widgets.TableColumn;
9 import org.eclipse.swt.widgets.TreeColumn;
10
11 /**
12 * Centralise useful methods to manage JFace Table, Tree and TreeColumn viewers.
13 */
14 public class ViewerUtils {
15
16 /**
17 * Creates a basic column for the given table. For the time being, we do not
18 * support movable columns.
19 */
20 public static TableColumn createColumn(Table parent, String name, int style, int width) {
21 TableColumn result = new TableColumn(parent, style);
22 result.setText(name);
23 result.setWidth(width);
24 result.setResizable(true);
25 return result;
26 }
27
28 /**
29 * Creates a TableViewerColumn for the given viewer. For the time being, we do
30 * not support movable columns.
31 */
32 public static TableViewerColumn createTableViewerColumn(TableViewer parent, String name, int style, int width) {
33 TableViewerColumn tvc = new TableViewerColumn(parent, style);
34 TableColumn column = tvc.getColumn();
35 column.setText(name);
36 column.setWidth(width);
37 column.setResizable(true);
38 return tvc;
39 }
40
41 // public static TableViewerColumn createTableViewerColumn(TableViewer parent,
42 // Localized name, int style, int width) {
43 // return createTableViewerColumn(parent, name.lead(), style, width);
44 // }
45
46 /**
47 * Creates a TreeViewerColumn for the given viewer. For the time being, we do
48 * not support movable columns.
49 */
50 public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent, String name, int style, int width) {
51 TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
52 TreeColumn column = tvc.getColumn();
53 column.setText(name);
54 column.setWidth(width);
55 column.setResizable(true);
56 return tvc;
57 }
58 }