1 package org
.argeo
.slc
.client
.ui
.views
;
3 import java
.util
.ArrayList
;
5 import org
.argeo
.slc
.SlcException
;
6 import org
.argeo
.slc
.client
.ui
.ClientUiPlugin
;
7 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
8 import org
.argeo
.slc
.process
.SlcExecution
;
9 import org
.eclipse
.core
.commands
.Command
;
10 import org
.eclipse
.core
.commands
.IParameter
;
11 import org
.eclipse
.core
.commands
.Parameterization
;
12 import org
.eclipse
.core
.commands
.ParameterizedCommand
;
13 import org
.eclipse
.jface
.viewers
.DoubleClickEvent
;
14 import org
.eclipse
.jface
.viewers
.IDoubleClickListener
;
15 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
18 import org
.eclipse
.jface
.viewers
.TableViewer
;
19 import org
.eclipse
.swt
.SWT
;
20 import org
.eclipse
.swt
.layout
.GridData
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
22 import org
.eclipse
.swt
.widgets
.Table
;
23 import org
.eclipse
.swt
.widgets
.TableColumn
;
24 import org
.eclipse
.ui
.IWorkbench
;
25 import org
.eclipse
.ui
.IWorkbenchWindow
;
26 import org
.eclipse
.ui
.commands
.ICommandService
;
27 import org
.eclipse
.ui
.handlers
.IHandlerService
;
28 import org
.eclipse
.ui
.part
.ViewPart
;
31 * This class display the list of all processes that have run in the
32 * corresponding agent. Currently, the local agent.
37 public class ProcessListView
extends ViewPart
{
38 // private final static Log log = LogFactory.getLog(ProcessListView.class);
40 public static final String ID
= "org.argeo.slc.client.ui.processListView";
42 private TableViewer viewer
;
45 private SlcExecutionDao slcExecutionDao
;
46 private ITableLabelProvider tableLabelProvider
;
47 private IStructuredContentProvider structuredContentProvider
;
49 public void createPartControl(Composite parent
) {
50 Table table
= createTable(parent
);
51 viewer
= new TableViewer(table
);
52 viewer
.setLabelProvider(tableLabelProvider
);
53 viewer
.setContentProvider(structuredContentProvider
);
54 viewer
.setInput(getViewSite());
55 viewer
.addDoubleClickListener(new ViewDoubleClickListener());
59 protected Table
createTable(Composite parent
) {
60 int style
= SWT
.SINGLE
| SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
61 | SWT
.FULL_SELECTION
| SWT
.HIDE_SELECTION
;
63 Table table
= new Table(parent
, style
);
65 GridData gridData
= new GridData(GridData
.FILL_BOTH
);
66 gridData
.grabExcessVerticalSpace
= true;
67 gridData
.grabExcessHorizontalSpace
= true;
68 gridData
.horizontalSpan
= 3;
69 table
.setLayoutData(gridData
);
71 table
.setLinesVisible(true);
72 table
.setHeaderVisible(true);
74 TableColumn column
= new TableColumn(table
, SWT
.LEFT
, 0);
75 column
.setText("Date");
78 column
= new TableColumn(table
, SWT
.LEFT
, 1);
79 column
.setText("Host");
82 column
= new TableColumn(table
, SWT
.LEFT
, 2);
86 column
= new TableColumn(table
, SWT
.LEFT
, 3);
87 column
.setText("Status");
93 public void setFocus() {
94 viewer
.getControl().setFocus();
97 public void retrieveResults() {
98 viewer
.setInput(slcExecutionDao
.listSlcExecutions());
102 class ViewDoubleClickListener
implements IDoubleClickListener
{
103 public void doubleClick(DoubleClickEvent evt
) {
104 Object obj
= ((IStructuredSelection
) evt
.getSelection())
107 if (obj
instanceof SlcExecution
) {
108 SlcExecution se
= (SlcExecution
) obj
;
110 IWorkbench iw
= ClientUiPlugin
.getDefault().getWorkbench();
111 IHandlerService handlerService
= (IHandlerService
) iw
112 .getService(IHandlerService
.class);
114 // get the command from plugin.xml
115 IWorkbenchWindow window
= iw
.getActiveWorkbenchWindow();
116 ICommandService cmdService
= (ICommandService
) window
117 .getService(ICommandService
.class);
118 Command cmd
= cmdService
119 .getCommand("org.argeo.slc.client.ui.displayProcessDetails");
121 ArrayList
<Parameterization
> parameters
= new ArrayList
<Parameterization
>();
124 IParameter iparam
= cmd
125 .getParameter("org.argeo.slc.client.commands.processUuid");
126 Parameterization params
= new Parameterization(iparam
, se
127 .getUuid()); // "testUUID");//
128 parameters
.add(params
);
130 // build the parameterized command
131 ParameterizedCommand pc
= new ParameterizedCommand(cmd
,
132 parameters
.toArray(new Parameterization
[parameters
135 // execute the command
136 handlerService
= (IHandlerService
) window
137 .getService(IHandlerService
.class);
138 handlerService
.executeCommand(pc
, null);
140 } catch (Exception e
) {
142 throw new SlcException("Problem while rendering result. "
150 public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao
) {
151 this.slcExecutionDao
= slcExecutionDao
;
154 public void setTableLabelProvider(ITableLabelProvider tableLabelProvider
) {
155 this.tableLabelProvider
= tableLabelProvider
;
158 public void setStructuredContentProvider(
159 IStructuredContentProvider structuredContentProvider
) {
160 this.structuredContentProvider
= structuredContentProvider
;