]> git.argeo.org Git - lgpl/argeo-commons.git/blob - base/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/utils/ViewerUtils.java
Update license headers
[lgpl/argeo-commons.git] / base / runtime / org.argeo.eclipse.ui / src / main / java / org / argeo / eclipse / ui / utils / ViewerUtils.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.eclipse.ui.utils;
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 * Centralizes useful methods to manage Jface Table, Tree and TreeColumn
28 * viewers.
29 */
30 public class ViewerUtils {
31
32 /**
33 * Creates a basic column for the given table. For the time being, we do not
34 * support moveable columns.
35 */
36 public static TableColumn createColumn(Table parent, String name,
37 int style, int width) {
38 TableColumn result = new TableColumn(parent, style);
39 result.setText(name);
40 result.setWidth(width);
41 result.setResizable(true);
42 return result;
43 }
44
45 /**
46 * Creates a TableViewerColumn for the given viewer. For the time being, we
47 * do not support moveable columns.
48 */
49 public static TableViewerColumn createTableViewerColumn(TableViewer parent,
50 String name, int style, int width) {
51 TableViewerColumn tvc = new TableViewerColumn(parent, style);
52 final TableColumn column = tvc.getColumn();
53 column.setText(name);
54 column.setWidth(width);
55 column.setResizable(true);
56 return tvc;
57 }
58
59 /**
60 * Creates a TreeViewerColumn for the given viewer. For the time being, we
61 * do not support moveable columns.
62 */
63 public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
64 String name, int style, int width) {
65 TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
66 final TreeColumn column = tvc.getColumn();
67 column.setText(name);
68 column.setWidth(width);
69 column.setResizable(true);
70 return tvc;
71 }
72 }