]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java
Full refactoring of the UI distribution view:
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / utils / ViewerUtils.java
1 package org.argeo.slc.client.ui.dist.utils;
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 * Centralizes useful methods to manage table to display nodes list.
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 moveable columns.
19 */
20 public static TableColumn createColumn(Table parent, String name,
21 int style, int width) {
22 TableColumn result = new TableColumn(parent, style);
23 result.setText(name);
24 result.setWidth(width);
25 result.setResizable(true);
26 return result;
27 }
28
29 /**
30 * Creates a TableViewerColumn for the given viewer. For the time being, we
31 * do not support moveable columns.
32 */
33 public static TableViewerColumn createTableViewerColumn(TableViewer parent,
34 String name, int style, int width) {
35 TableViewerColumn tvc = new TableViewerColumn(parent, style);
36 final TableColumn column = tvc.getColumn();
37 column.setText(name);
38 column.setWidth(width);
39 column.setResizable(true);
40 return tvc;
41 }
42
43 /**
44 * Creates a TreeViewerColumn for the given viewer. For the time being, we
45 * do not support moveable columns.
46 */
47 public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
48 String name, int style, int width) {
49 TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
50 final TreeColumn column = tvc.getColumn();
51 column.setText(name);
52 column.setWidth(width);
53 column.setResizable(true);
54 return tvc;
55 }
56 }