[jbpm-commits] JBoss JBPM SVN: r2876 - in projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client: task and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Nov 11 05:19:21 EST 2008


Author: heiko.braun at jboss.com
Date: 2008-11-11 05:19:21 -0500 (Tue, 11 Nov 2008)
New Revision: 2876

Modified:
   projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
   projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskList.java
   projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java
Log:
Task form binding, first cut

Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java	2008-11-11 09:44:06 UTC (rev 2875)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java	2008-11-11 10:19:21 UTC (rev 2876)
@@ -22,11 +22,9 @@
 package org.jboss.bpm.console.client.model;
 
 import com.google.gwt.json.client.*;
-import com.allen_sauer.gwt.log.client.Log;
 import org.jboss.bpm.console.client.model.forms.FieldDef;
 import org.jboss.bpm.console.client.model.forms.FormDef;
 import org.jboss.bpm.console.client.util.JSONWalk;
-import org.jboss.bpm.console.server.gson.GsonFactory;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -87,8 +85,6 @@
    public static TaskReference parseTaskReference(JSONObject item)
    {
 
-      Log.debug("Parsing " + item.toString());
-
       long id = JSONWalk.on(item).next("id").asLong();
       long tokenId = JSONWalk.on(item).next("tokenId").asLong();
       long instanceId = JSONWalk.on(item).next("processInstanceId").asLong();
@@ -105,6 +101,16 @@
             isSignalling, isBlocking
       );
 
+
+      // pooled actors
+      JSONArray pooledActors = JSONWalk.on(item).next("pooledActors").asArray();
+      for (int k = 0; k < pooledActors.size(); ++k)
+      {
+         JSONValue jsonValue = pooledActors.get(k);
+         JSONString t = jsonValue.isString();
+         ref.addPooledActor(t.stringValue());
+      }
+
       if(isSignalling)
       {
          JSONArray arr = JSONWalk.on(item).next("transitionNames").asArray();

Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskList.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskList.java	2008-11-11 09:44:06 UTC (rev 2875)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskList.java	2008-11-11 10:19:21 UTC (rev 2876)
@@ -32,10 +32,7 @@
 import com.gwtext.client.widgets.Component;
 import com.gwtext.client.widgets.event.PanelListenerAdapter;
 import com.gwtext.client.widgets.form.FormPanel;
-import com.gwtext.client.widgets.grid.ColumnConfig;
-import com.gwtext.client.widgets.grid.ColumnModel;
-import com.gwtext.client.widgets.grid.GridPanel;
-import com.gwtext.client.widgets.grid.GroupingView;
+import com.gwtext.client.widgets.grid.*;
 import org.jboss.bpm.console.client.MainView;
 import org.jboss.bpm.console.client.UIConstants;
 import org.jboss.bpm.console.client.model.DTOParser;
@@ -56,6 +53,7 @@
    private GridPanel grid;
    private GroupingStore store;
    private String title;
+   private RowSelectionModel rowSelectionModel;
 
    public TaskList(String titleName, final MainView view)
    {
@@ -66,6 +64,7 @@
       this.setHeader(false);
       this.setBorder(false);
       this.setFrame(false);
+      this.setIconCls("bpm-task-icon");
 
       String resourceUrl = view.getUrlBuilder().getTaskListByActorURL(view.getUsername());
       DataProxy dataProxy = new ScriptTagProxy(resourceUrl, 1000*10);
@@ -198,9 +197,7 @@
          int i=0;
          for(Record r : records)
          {
-            JavaScriptObject js = r.getDataAsJsObject();
-            JSONObject jso = new JSONObject(js);
-            TaskReference ref = DTOParser.parseTaskReference(jso);
+            TaskReference ref = transform(r);
             row2taskref.put(i, ref);
             i++;
          }
@@ -213,6 +210,14 @@
       Log.debug("Loaded " + row2taskref.size() + " tasks");
    }
 
+   public static TaskReference transform(Record r)
+   {
+      JavaScriptObject js = r.getDataAsJsObject();
+      JSONObject jso = new JSONObject(js);
+      TaskReference ref = DTOParser.parseTaskReference(jso);
+      return ref;
+   }
+
    private ColumnModel createColumnModel()
    {
       final ColumnModel columnModel = new ColumnModel(
@@ -294,6 +299,9 @@
       gridView.setForceFit(true);
       gridView.setGroupTextTpl("{text} ({[values.rs.length]} {[values.rs.length > 1 ?  \"Items\" : \"Item\"]})");
 
+      if(rowSelectionModel!=null)
+         grid.setSelectionModel(rowSelectionModel);
+      
       grid.setView(gridView);
       grid.setFrame(true);
       grid.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
@@ -312,4 +320,9 @@
    {
       return grid;
    }
+
+   public void setRowSelectionModel(RowSelectionModel model)
+   {
+      this.rowSelectionModel = model;
+   }
 }

Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java	2008-11-11 09:44:06 UTC (rev 2875)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java	2008-11-11 10:19:21 UTC (rev 2876)
@@ -24,12 +24,25 @@
 import org.jboss.bpm.console.client.Editor;
 import org.jboss.bpm.console.client.MainView;
 import org.jboss.bpm.console.client.UIConstants;
+import org.jboss.bpm.console.client.model.TaskReference;
 import org.jboss.bpm.console.client.widgets.TeaserPanel;
 import com.gwtext.client.widgets.layout.ColumnLayout;
 import com.gwtext.client.widgets.layout.ColumnLayoutData;
 import com.gwtext.client.widgets.Panel;
 import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.PaddedPanel;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.grid.RowSelectionModel;
+import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.form.FieldSet;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.form.DateField;
 import com.gwtext.client.widgets.event.PanelListenerAdapter;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.core.Position;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.data.Record;
 
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
@@ -45,6 +58,8 @@
 
    private Panel formContainer;
 
+   private TaskReference selectedInstance;
+
    public TaskListEditor(MainView mainView )
    {
       super();
@@ -100,10 +115,17 @@
          taskList = new TaskList("Your tasks", mainView);
          leftHand.add(taskList);
 
+         // ----------------------------------
+
+         Panel detailsFormPanel = assembleFormPanel();
+         leftHand.add(detailsFormPanel);
+
+         /*
          formContainer = new Panel();
          formContainer.setPaddings(10);
          formContainer.setBorder(false);
          leftHand.add(formContainer);
+         */
          
          // ----------------------------------
 
@@ -126,4 +148,103 @@
    {
       return formContainer;
    }
+
+   private Panel assembleFormPanel()
+   {
+        // ---------------
+
+      Panel outerFormPanel = new Panel();
+      outerFormPanel.setBorder(false);
+      outerFormPanel.setFrame(false);
+      outerFormPanel.setPaddings(10);
+
+      // ---------------
+
+      final FormPanel formPanel = new FormPanel();
+      formPanel.setLabelAlign(Position.LEFT);
+      formPanel.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
+      formPanel.setHeader(false);
+      formPanel.setFrame(false);
+      formPanel.setPaddings(5, 5, 5, 0);
+      formPanel.setLabelWidth(120);
+
+      // ---------------
+
+      FieldSet fieldSet = new FieldSet();
+      fieldSet.setLabelWidth(90);
+      fieldSet.setTitle("Task Instance Details");
+      fieldSet.setAutoHeight(true);
+      fieldSet.setBorder(false);
+
+      // ---------------
+      //the field names must match the data field values from the Store
+      fieldSet.add(new TextField("Id", "id", 230));
+      fieldSet.add(new TextField("Name", "name", 230));
+      fieldSet.add(new TextField("Actor", "actor", 230));
+      fieldSet.add(new DateField("State", "currentState", 230));
+      
+      Panel inner = new PaddedPanel(fieldSet, 0, 10, 0, 0);
+
+      formPanel.add(inner);
+
+      final Button startBtn = new Button("Start Progress",
+        new ButtonListenerAdapter()
+        {
+
+           public void onClick(Button button, EventObject eventObject)
+           {
+              //selectedInstance.setState(ProcessInstance.STATE.SUSPENDED);
+              //persistStateChange();
+           }
+        }
+      );
+      //startBtn.setIcon("images/icons/pause.png");
+
+      final Button stopBtn = new Button("Stop",
+        new ButtonListenerAdapter()
+        {
+
+           public void onClick(Button button, EventObject eventObject)
+           {
+              //selectedInstance.setState(ProcessInstance.STATE.RUNNING);
+              //persistStateChange();
+           }
+        }
+      );
+
+      formPanel.addButton(startBtn);
+      formPanel.addButton(stopBtn);
+
+      // ----------------
+
+      final RowSelectionModel sm = new RowSelectionModel(true);
+      sm.addListener(
+        new RowSelectionListenerAdapter()
+        {
+           public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record)
+           {
+              selectedInstance = TaskList.transform(record);
+
+              if(TaskReference.STATE.IN_PROGRESS == selectedInstance.getCurrentState())
+              {
+                 startBtn.disable();
+                 stopBtn.enable();
+              }
+              else
+              {
+                 startBtn.enable();
+                 stopBtn.disable();
+              }
+
+              formPanel.getForm().loadRecord(record);
+              formPanel.doLayout();
+           }
+        }
+      );
+      taskList.setRowSelectionModel(sm);
+
+      outerFormPanel.add(formPanel);
+
+      return outerFormPanel;
+   }
 }




More information about the jbpm-commits mailing list