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 IStructuredContentProvider
{
67 // private List<ResultAttributes> lst;
69 public void inputChanged(Viewer arg0
, Object arg1
, Object arg2
) {
70 // if (arg2 instanceof List) {
71 // lst = (List<ResultAttributes>) arg2;
72 // log.trace("result count: " + lst.size());
76 public void dispose() {
79 @SuppressWarnings("unchecked")
80 public Object
[] getElements(Object obj
) {
82 // return new Object[0];
84 // return lst.toArray();
85 if (obj
instanceof List
) {
86 return ((List
<ResultAttributes
>) obj
).toArray();
91 // testResultCollectionDao.listResultAttributes(null).toArray();
95 protected class ViewLabelProvider
extends LabelProvider
implements
97 public String
getColumnText(Object obj
, int index
) {
98 ResultAttributes ra
= (ResultAttributes
) obj
;
101 return getText(ra
.getCloseDate());
108 public Image
getColumnImage(Object obj
, int index
) {
114 public void setFocus() {
115 viewer
.getControl().setFocus();
118 public void retrieveResults() {
120 List
<ResultAttributes
> lst
= testResultCollectionDao
121 .listResultAttributes(null);
122 if (log
.isTraceEnabled())
123 log
.trace("Result attributes count: " + lst
.size());
124 viewer
.setInput(lst
);
126 } catch (Exception e
) {
127 // TODO Auto-generated catch block
132 public void setTestResultCollectionDao(
133 TreeTestResultCollectionDao testResultCollectionDao
) {
134 this.testResultCollectionDao
= testResultCollectionDao
;