X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.client.ui.dist%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Futils%2FViewerUtils.java;fp=org.argeo.slc.client.ui.dist%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Futils%2FViewerUtils.java;h=18f77f382d47bef61572488b7de06e23bb3faa25;hb=2db415932b071525adb52c6374e021174512a924;hp=0000000000000000000000000000000000000000;hpb=7e2f6c6ae08e97925955184aaa29035ac05de149;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java new file mode 100644 index 000000000..18f77f382 --- /dev/null +++ b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java @@ -0,0 +1,56 @@ +package org.argeo.slc.client.ui.dist.utils; + +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.TreeViewerColumn; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TreeColumn; + +/** + * Centralizes useful methods to manage table to display nodes list. + */ +public class ViewerUtils { + + /** + * Creates a basic column for the given table. For the time being, we do not + * support moveable columns. + */ + public static TableColumn createColumn(Table parent, String name, + int style, int width) { + TableColumn result = new TableColumn(parent, style); + result.setText(name); + result.setWidth(width); + result.setResizable(true); + return result; + } + + /** + * Creates a TableViewerColumn for the given viewer. For the time being, we + * do not support moveable columns. + */ + public static TableViewerColumn createTableViewerColumn(TableViewer parent, + String name, int style, int width) { + TableViewerColumn tvc = new TableViewerColumn(parent, style); + final TableColumn column = tvc.getColumn(); + column.setText(name); + column.setWidth(width); + column.setResizable(true); + return tvc; + } + + /** + * Creates a TreeViewerColumn for the given viewer. For the time being, we + * do not support moveable columns. + */ + public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent, + String name, int style, int width) { + TreeViewerColumn tvc = new TreeViewerColumn(parent, style); + final TreeColumn column = tvc.getColumn(); + column.setText(name); + column.setWidth(width); + column.setResizable(true); + return tvc; + } +}