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
.test
.tree
.TreeTestResultCollectionDao
;
9 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
10 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
11 import org
.eclipse
.jface
.viewers
.LabelProvider
;
12 import org
.eclipse
.jface
.viewers
.TableViewer
;
13 import org
.eclipse
.jface
.viewers
.Viewer
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.graphics
.Image
;
16 import org
.eclipse
.swt
.layout
.GridData
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.swt
.widgets
.Table
;
19 import org
.eclipse
.swt
.widgets
.TableColumn
;
20 import org
.eclipse
.ui
.part
.ViewPart
;
22 public class ResultListView
extends ViewPart
{
23 private final static Log log
= LogFactory
.getLog(ResultListView
.class);
25 public static final String ID
= "org.argeo.slc.client.ui.resultListView";
27 private TableViewer viewer
;
29 private TreeTestResultCollectionDao testResultCollectionDao
;
31 public void createPartControl(Composite parent
) {
32 Table table
= createTable(parent
);
33 viewer
= new TableViewer(table
);
34 viewer
.setLabelProvider(new ViewLabelProvider());
35 viewer
.setContentProvider(new ViewContentProvider());
37 viewer
.setInput(getViewSite());
40 protected Table
createTable(Composite parent
) {
41 int style
= SWT
.SINGLE
| SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
42 | SWT
.FULL_SELECTION
| SWT
.HIDE_SELECTION
;
44 Table table
= new Table(parent
, style
);
46 GridData gridData
= new GridData(GridData
.FILL_BOTH
);
47 gridData
.grabExcessVerticalSpace
= true;
48 gridData
.grabExcessHorizontalSpace
= true;
49 gridData
.horizontalSpan
= 3;
50 table
.setLayoutData(gridData
);
52 table
.setLinesVisible(true);
53 table
.setHeaderVisible(true);
55 TableColumn column
= new TableColumn(table
, SWT
.LEFT
, 0);
56 column
.setText("Date");
59 column
= new TableColumn(table
, SWT
.LEFT
, 1);
60 column
.setText("UUID");
66 protected static class ViewContentProvider
implements
67 IStructuredContentProvider
{
68 // private List<ResultAttributes> lst;
70 public void inputChanged(Viewer arg0
, Object arg1
, Object arg2
) {
71 // if (arg2 instanceof List) {
72 // lst = (List<ResultAttributes>) arg2;
73 // log.trace("result count: " + lst.size());
77 public void dispose() {
80 @SuppressWarnings("unchecked")
81 public Object
[] getElements(Object obj
) {
83 // return new Object[0];
85 // return lst.toArray();
86 if (obj
instanceof List
) {
87 return ((List
<ResultAttributes
>) obj
).toArray();
92 // testResultCollectionDao.listResultAttributes(null).toArray();
96 protected class ViewLabelProvider
extends LabelProvider
implements
98 public String
getColumnText(Object obj
, int index
) {
99 ResultAttributes ra
= (ResultAttributes
) obj
;
102 return getText(ra
.getCloseDate());
109 public Image
getColumnImage(Object obj
, int index
) {
115 public void setFocus() {
116 viewer
.getControl().setFocus();
119 public void retrieveResults() {
121 List
<ResultAttributes
> lst
= testResultCollectionDao
122 .listResultAttributes(null);
123 if (log
.isTraceEnabled())
124 log
.trace("Result attributes count: " + lst
.size());
125 viewer
.setInput(lst
);
127 } catch (Exception e
) {
128 // TODO Auto-generated catch block
134 public void setTestResultCollectionDao(
135 TreeTestResultCollectionDao testResultCollectionDao
) {
136 this.testResultCollectionDao
= testResultCollectionDao
;