1 package org
.argeo
.slc
.client
.ui
.views
;
5 import org
.argeo
.slc
.client
.core
.TableContent
;
6 import org
.argeo
.slc
.process
.SlcExecution
;
7 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
8 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
9 import org
.eclipse
.jface
.viewers
.LabelProvider
;
10 import org
.eclipse
.jface
.viewers
.TableViewer
;
11 import org
.eclipse
.jface
.viewers
.Viewer
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.graphics
.Image
;
14 import org
.eclipse
.swt
.layout
.GridData
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.swt
.widgets
.Table
;
17 import org
.eclipse
.swt
.widgets
.TableColumn
;
18 import org
.eclipse
.ui
.part
.ViewPart
;
20 public class ProcessListView
extends ViewPart
{
21 // private final static Log log = LogFactory.getLog(ProcessListView.class);
23 public static final String ID
= "org.argeo.slc.client.ui.processListView";
25 private TableViewer viewer
;
28 private TableContent tableContent
;
30 public void createPartControl(Composite parent
) {
31 Table table
= createTable(parent
);
32 viewer
= new TableViewer(table
);
33 viewer
.setLabelProvider(new ViewLabelProvider());
34 viewer
.setContentProvider(new ViewContentProvider());
36 viewer
.setInput(getViewSite());
39 protected Table
createTable(Composite parent
) {
40 int style
= SWT
.SINGLE
| SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
41 | SWT
.FULL_SELECTION
| SWT
.HIDE_SELECTION
;
43 Table table
= new Table(parent
, style
);
45 GridData gridData
= new GridData(GridData
.FILL_BOTH
);
46 gridData
.grabExcessVerticalSpace
= true;
47 gridData
.grabExcessHorizontalSpace
= true;
48 gridData
.horizontalSpan
= 3;
49 table
.setLayoutData(gridData
);
51 table
.setLinesVisible(true);
52 table
.setHeaderVisible(true);
54 TableColumn column
= new TableColumn(table
, SWT
.LEFT
, 0);
55 column
.setText("Date");
58 column
= new TableColumn(table
, SWT
.LEFT
, 1);
59 column
.setText("Host");
62 column
= new TableColumn(table
, SWT
.LEFT
, 2);
66 column
= new TableColumn(table
, SWT
.LEFT
, 3);
67 column
.setText("Status");
73 protected static class ViewContentProvider
implements
74 IStructuredContentProvider
{
76 public void inputChanged(Viewer arg0
, Object arg1
, Object arg2
) {
79 public void dispose() {
82 @SuppressWarnings("unchecked")
83 public Object
[] getElements(Object obj
) {
84 if (obj
instanceof List
) {
85 return ((List
<SlcExecution
>) obj
).toArray();
92 protected class ViewLabelProvider
extends LabelProvider
implements
94 public String
getColumnText(Object obj
, int index
) {
95 return tableContent
.getLabel(obj
, index
);
98 public Image
getColumnImage(Object obj
, int index
) {
104 public void setFocus() {
105 viewer
.getControl().setFocus();
108 public void retrieveResults() {
109 viewer
.setInput(tableContent
.getContent());
113 public void setTableContent(TableContent tableContent
) {
114 this.tableContent
= tableContent
;