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
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.Table
;
22 import org
.eclipse
.swt
.widgets
.TableColumn
;
23 import org
.eclipse
.ui
.IWorkbench
;
24 import org
.eclipse
.ui
.IWorkbenchWindow
;
25 import org
.eclipse
.ui
.commands
.ICommandService
;
26 import org
.eclipse
.ui
.handlers
.IHandlerService
;
27 import org
.eclipse
.ui
.part
.ViewPart
;
30 * This class display the list of all processes that have run in the
31 * corresponding agent. Currently, the local agent.
36 public class ProcessListView
extends ViewPart
{
37 // private final static Log log = LogFactory.getLog(ProcessListView.class);
39 public static final String ID
= "org.argeo.slc.client.ui.processListView";
41 private TableViewer viewer
;
44 private SlcExecutionDao slcExecutionDao
;
45 private ITableLabelProvider tableLabelProvider
;
46 private IStructuredContentProvider structuredContentProvider
;
48 public void createPartControl(Composite parent
) {
49 Table table
= createTable(parent
);
50 viewer
= new TableViewer(table
);
51 viewer
.setLabelProvider(tableLabelProvider
);
52 viewer
.setContentProvider(structuredContentProvider
);
53 viewer
.setInput(getViewSite());
54 viewer
.addDoubleClickListener(new ViewDoubleClickListener());
58 protected Table
createTable(Composite parent
) {
59 int style
= SWT
.SINGLE
| SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
61 // does not function with RAP, commented for the moment being
62 // | SWT.HIDE_SELECTION;
64 Table table
= new Table(parent
, style
);
66 // GridData gridData = new GridData(GridData.FILL_BOTH);
67 // gridData.grabExcessVerticalSpace = true;
68 // gridData.grabExcessHorizontalSpace = true;
69 // gridData.horizontalSpan = 3;
70 // table.setLayoutData(gridData);
72 table
.setLinesVisible(true);
73 table
.setHeaderVisible(true);
75 TableColumn column
= new TableColumn(table
, SWT
.LEFT
, 0);
76 column
.setText("Date");
79 column
= new TableColumn(table
, SWT
.LEFT
, 1);
80 column
.setText("Host");
83 column
= new TableColumn(table
, SWT
.LEFT
, 2);
87 column
= new TableColumn(table
, SWT
.LEFT
, 3);
88 column
.setText("Status");
94 public void setFocus() {
95 viewer
.getControl().setFocus();
98 public void retrieveResults() {
99 viewer
.setInput(slcExecutionDao
.listSlcExecutions());
103 class ViewDoubleClickListener
implements IDoubleClickListener
{
104 public void doubleClick(DoubleClickEvent evt
) {
105 Object obj
= ((IStructuredSelection
) evt
.getSelection())
108 if (obj
instanceof SlcExecution
) {
109 SlcExecution se
= (SlcExecution
) obj
;
111 IWorkbench iw
= ClientUiPlugin
.getDefault().getWorkbench();
112 IHandlerService handlerService
= (IHandlerService
) iw
113 .getService(IHandlerService
.class);
115 // get the command from plugin.xml
116 IWorkbenchWindow window
= iw
.getActiveWorkbenchWindow();
117 ICommandService cmdService
= (ICommandService
) window
118 .getService(ICommandService
.class);
119 Command cmd
= cmdService
120 .getCommand("org.argeo.slc.client.ui.displayProcessDetails");
122 ArrayList
<Parameterization
> parameters
= new ArrayList
<Parameterization
>();
125 IParameter iparam
= cmd
126 .getParameter("org.argeo.slc.client.commands.processUuid");
127 Parameterization params
= new Parameterization(iparam
,
128 se
.getUuid()); // "testUUID");//
129 parameters
.add(params
);
131 // build the parameterized command
132 ParameterizedCommand pc
= new ParameterizedCommand(cmd
,
133 parameters
.toArray(new Parameterization
[parameters
136 // execute the command
137 handlerService
= (IHandlerService
) window
138 .getService(IHandlerService
.class);
139 handlerService
.executeCommand(pc
, null);
141 } catch (Exception e
) {
143 throw new SlcException("Problem while rendering result. "
151 public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao
) {
152 this.slcExecutionDao
= slcExecutionDao
;
155 public void setTableLabelProvider(ITableLabelProvider tableLabelProvider
) {
156 this.tableLabelProvider
= tableLabelProvider
;
159 public void setStructuredContentProvider(
160 IStructuredContentProvider structuredContentProvider
) {
161 this.structuredContentProvider
= structuredContentProvider
;