]>
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
2 * Copyright (C) 2007-2012 Mathieu Baudier
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.eclipse
.ui
.utils
;
19 import org
.eclipse
.jface
.viewers
.TableViewer
;
20 import org
.eclipse
.jface
.viewers
.TableViewerColumn
;
21 import org
.eclipse
.jface
.viewers
.TreeViewer
;
22 import org
.eclipse
.jface
.viewers
.TreeViewerColumn
;
23 import org
.eclipse
.swt
.widgets
.Table
;
24 import org
.eclipse
.swt
.widgets
.TableColumn
;
25 import org
.eclipse
.swt
.widgets
.TreeColumn
;
28 * Centralizes useful methods to manage Jface Table, Tree and TreeColumn
31 public class ViewerUtils
{
34 * Creates a basic column for the given table. For the time being, we do not
35 * support moveable columns.
37 public static TableColumn
createColumn(Table parent
, String name
,
38 int style
, int width
) {
39 TableColumn result
= new TableColumn(parent
, style
);
41 result
.setWidth(width
);
42 result
.setResizable(true);
47 * Creates a TableViewerColumn for the given viewer. For the time being, we
48 * do not support moveable columns.
50 public static TableViewerColumn
createTableViewerColumn(TableViewer parent
,
51 String name
, int style
, int width
) {
52 TableViewerColumn tvc
= new TableViewerColumn(parent
, style
);
53 final TableColumn column
= tvc
.getColumn();
55 column
.setWidth(width
);
56 column
.setResizable(true);
61 * Creates a TreeViewerColumn for the given viewer. For the time being, we
62 * do not support moveable columns.
64 public static TreeViewerColumn
createTreeViewerColumn(TreeViewer parent
,
65 String name
, int style
, int width
) {
66 TreeViewerColumn tvc
= new TreeViewerColumn(parent
, style
);
67 final TreeColumn column
= tvc
.getColumn();
69 column
.setWidth(width
);
70 column
.setResizable(true);