1 package org
.argeo
.slc
.client
.ui
.views
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.core
.test
.tree
.ResultAttributes
;
8 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
9 import org
.argeo
.slc
.process
.SlcExecution
;
10 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
11 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
12 import org
.eclipse
.jface
.viewers
.LabelProvider
;
13 import org
.eclipse
.jface
.viewers
.TableViewer
;
14 import org
.eclipse
.jface
.viewers
.Viewer
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.graphics
.Image
;
17 import org
.eclipse
.swt
.layout
.GridData
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Table
;
20 import org
.eclipse
.swt
.widgets
.TableColumn
;
21 import org
.eclipse
.ui
.part
.ViewPart
;
23 public class SlcExecutionListView
extends ViewPart
{
24 private final static Log log
= LogFactory
25 .getLog(SlcExecutionListView
.class);
27 public static final String ID
= "org.argeo.slc.client.ui.SlcExecutionListView";
29 private TableViewer viewer
;
31 private SlcExecutionDao slcExecutionDao
;
33 public void createPartControl(Composite parent
) {
34 Table table
= createTable(parent
);
35 viewer
= new TableViewer(table
);
36 viewer
.setLabelProvider(new ViewLabelProvider());
37 viewer
.setContentProvider(new ViewContentProvider());
39 viewer
.setInput(getViewSite());
42 protected Table
createTable(Composite parent
) {
43 int style
= SWT
.SINGLE
| SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
44 | SWT
.FULL_SELECTION
| SWT
.HIDE_SELECTION
;
46 Table table
= new Table(parent
, style
);
48 GridData gridData
= new GridData(GridData
.FILL_BOTH
);
49 gridData
.grabExcessVerticalSpace
= true;
50 gridData
.grabExcessHorizontalSpace
= true;
51 gridData
.horizontalSpan
= 3;
52 table
.setLayoutData(gridData
);
54 table
.setLinesVisible(true);
55 table
.setHeaderVisible(true);
57 TableColumn column
= new TableColumn(table
, SWT
.LEFT
, 0);
58 column
.setText("Date");
61 column
= new TableColumn(table
, SWT
.LEFT
, 1);
62 column
.setText("Host");
65 column
= new TableColumn(table
, SWT
.LEFT
, 2);
69 column
= new TableColumn(table
, SWT
.LEFT
, 3);
70 column
.setText("Status");
76 protected static class ViewContentProvider
implements
77 IStructuredContentProvider
{
79 public void inputChanged(Viewer arg0
, Object arg1
, Object arg2
) {
82 public void dispose() {
85 @SuppressWarnings("unchecked")
86 public Object
[] getElements(Object obj
) {
87 if (obj
instanceof List
) {
88 return ((List
<ResultAttributes
>) obj
).toArray();
95 protected class ViewLabelProvider
extends LabelProvider
implements
97 public String
getColumnText(Object obj
, int index
) {
98 SlcExecution ra
= (SlcExecution
) obj
;
102 return getText(ra
.getStartDate());
108 return ra
.currentStep().getType();
113 public Image
getColumnImage(Object obj
, int index
) {
119 public void setFocus() {
120 viewer
.getControl().setFocus();
123 public void retrieveResults() {
125 List
<SlcExecution
> lst
= slcExecutionDao
.listSlcExecutions();
127 if (log
.isTraceEnabled())
128 log
.trace("Result attributes count: " + lst
.size());
129 viewer
.setInput(lst
);
131 } catch (Exception e
) {
132 // TODO Auto-generated catch block
137 public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao
) {
138 this.slcExecutionDao
= slcExecutionDao
;