View Javadoc
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  /** Useful methods to manage table to display nodes list. */
12  public class ViewerUtils {
13  
14  	/**
15  	 * Creates a basic column for the given table. For the time being, we do not
16  	 * support moveable columns.
17  	 */
18  	public static TableColumn createColumn(Table parent, String name,
19  			int style, int width) {
20  		TableColumn result = new TableColumn(parent, style);
21  		result.setText(name);
22  		result.setWidth(width);
23  		result.setResizable(true);
24  		return result;
25  	}
26  
27  	/**
28  	 * Creates a TableViewerColumn for the given viewer. For the time being, we
29  	 * do not support moveable columns.
30  	 */
31  	public static TableViewerColumn createTableViewerColumn(TableViewer parent,
32  			String name, int style, int width) {
33  		TableViewerColumn tvc = new TableViewerColumn(parent, style);
34  		final TableColumn column = tvc.getColumn();
35  		column.setText(name);
36  		column.setWidth(width);
37  		column.setResizable(true);
38  		return tvc;
39  	}
40  
41  	/**
42  	 * Creates a TreeViewerColumn for the given viewer. For the time being, we
43  	 * do not support moveable columns.
44  	 */
45  	public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
46  			String name, int style, int width) {
47  		TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
48  		final TreeColumn column = tvc.getColumn();
49  		column.setText(name);
50  		column.setWidth(width);
51  		column.setResizable(true);
52  		return tvc;
53  	}
54  }