X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fplugins%2Forg.argeo.slc.client.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fviews%2FJcrProcessListView.java;h=cfc57497954490348ebcdac1a4eb88cfa98a1907;hb=6a5737bbf4cd63e00e61a3fd81e6673b5ad9341f;hp=8c2bb40079ff5c9c38b84365e2cfb49cbadfd8fc;hpb=15fdf876a4dbb73b379f8c6c16d7d929955ade4d;p=gpl%2Fargeo-slc.git diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrProcessListView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrProcessListView.java index 8c2bb4007..cfc574979 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrProcessListView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrProcessListView.java @@ -1,5 +1,7 @@ package org.argeo.slc.client.ui.views; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; @@ -17,8 +19,10 @@ import javax.jcr.query.Query; import org.argeo.eclipse.ui.jcr.AsyncUiEventListener; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; +import org.argeo.slc.client.ui.SlcImages; import org.argeo.slc.client.ui.editors.ProcessEditor; import org.argeo.slc.client.ui.editors.ProcessEditorInput; +import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.jcr.SlcJcrConstants; import org.argeo.slc.jcr.SlcNames; import org.argeo.slc.jcr.SlcTypes; @@ -39,10 +43,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; -/** - * This class display the list of all processes that have run in the - * corresponding agent. Currently, the local agent. - */ +/** Displays processes. */ public class JcrProcessListView extends ViewPart { public static final String ID = "org.argeo.slc.client.ui.jcrProcessListView"; @@ -52,6 +53,10 @@ public class JcrProcessListView extends ViewPart { private EventListener processesObserver; + private DateFormat dateFormat = new SimpleDateFormat( + "EEE, dd MMM yyyy HH:mm:ss"); + private Integer queryLimit = 100; + public void createPartControl(Composite parent) { Table table = createTable(parent); viewer = new TableViewer(table); @@ -62,6 +67,7 @@ public class JcrProcessListView extends ViewPart { processesObserver = new AsyncUiEventListener() { protected void onEventInUiThread(EventIterator events) { + // TODO optimize by updating only the changed process viewer.refresh(); } }; @@ -127,6 +133,8 @@ public class JcrProcessListView extends ViewPart { String sql = "SELECT * from [slc:process] ORDER BY [jcr:lastModified] DESC"; Query query = session.getWorkspace().getQueryManager() .createQuery(sql, Query.JCR_SQL2); + // TODO paging + query.setLimit(queryLimit); List nodes = new ArrayList(); for (NodeIterator nit = query.execute().getNodes(); nit .hasNext();) { @@ -149,9 +157,29 @@ public class JcrProcessListView extends ViewPart { class LabelProvider extends ColumnLabelProvider implements ITableLabelProvider { - public Image getColumnImage(Object element, int columnIndex) { - // TODO Auto-generated method stub - return null; + public Image getColumnImage(Object obj, int columnIndex) { + if (columnIndex != 0) + return null; + try { + Node node = (Node) obj; + String status = node.getProperty(SlcNames.SLC_STATUS) + .getString(); + if (status.equals(ExecutionProcess.NEW) + || status.equals(ExecutionProcess.INITIALIZED) + || status.equals(ExecutionProcess.SCHEDULED)) + return SlcImages.PROCESS_SCHEDULED; + else if (status.equals(ExecutionProcess.ERROR) + || status.equals(ExecutionProcess.UNKOWN)) + return SlcImages.PROCESS_ERROR; + else if (status.equals(ExecutionProcess.COMPLETED)) + return SlcImages.PROCESS_COMPLETED; + else if (status.equals(ExecutionProcess.RUNNING)) + return SlcImages.PROCESS_RUNNING; + else + throw new SlcException("Unkown status " + status); + } catch (RepositoryException e) { + throw new SlcException("Cannot get column text", e); + } } public String getColumnText(Object obj, int index) { @@ -160,7 +188,9 @@ public class JcrProcessListView extends ViewPart { switch (index) { case 0: - return node.getProperty(Property.JCR_CREATED).getString(); + return dateFormat.format(node + .getProperty(Property.JCR_LAST_MODIFIED).getDate() + .getTime()); case 1: return "local"; case 2: