]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrProcessListView.java
Improve RCP
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / views / JcrProcessListView.java
index ddc34a581943f63ed47d898436261e6c449fd70c..cfc57497954490348ebcdac1a4eb88cfa98a1907 100644 (file)
@@ -19,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;
@@ -41,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";
 
@@ -68,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();
                        }
                };
@@ -157,8 +157,29 @@ public class JcrProcessListView extends ViewPart {
        class LabelProvider extends ColumnLabelProvider implements
                        ITableLabelProvider {
 
-               public Image getColumnImage(Object element, int columnIndex) {
-                       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) {