Author: heiko.braun(a)jboss.com
Date: 2008-10-31 16:03:31 -0400 (Fri, 31 Oct 2008)
New Revision: 2731
Added:
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FieldDef.java
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FormDef.java
Removed:
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/util/MapReplacement.java
Modified:
projects/gwt-console/trunk/gwt-console.iml
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskReference.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
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/process/ProcessImageView.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
projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java
Log:
Task form generation prototype added
Modified: projects/gwt-console/trunk/gwt-console.iml
===================================================================
--- projects/gwt-console/trunk/gwt-console.iml 2008-10-31 18:31:43 UTC (rev 2730)
+++ projects/gwt-console/trunk/gwt-console.iml 2008-10-31 20:03:31 UTC (rev 2731)
@@ -16,8 +16,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="jbpm3-core" />
<orderEntry type="module" module-name="jbpm3-enterprise"
/>
- <orderEntry type="module" module-name="jbpm3-core" />
<orderEntry type="module-library">
<library name="M2 Dep:
javax.xml.stream:stax-api:jar:1.0-2:provided">
<CLASSES>
Modified:
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskReference.java
===================================================================
---
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskReference.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskReference.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -34,6 +34,7 @@
private long id;
private long tokenId;
private long processInstanceId;
+ private long processId;
private String name;
private String actor;
@@ -47,11 +48,17 @@
{
}
- public TaskReference(long taskId, long tokenId, long processInstanceId, String
taskName, String actorName, boolean blocking, boolean signalling)
+ public TaskReference(
+ long taskId, long tokenId, long processInstanceId,
+ long processId,
+ String taskName, String actorName,
+ boolean blocking, boolean signalling
+ )
{
this.id = taskId;
this.tokenId = tokenId;
this.processInstanceId = processInstanceId;
+ this.processId = processId;
this.name = taskName;
this.actor = actorName;
isBlocking = blocking;
@@ -132,4 +139,9 @@
{
return transitionNames;
}
+
+ public long getProcessId()
+ {
+ return processId;
+ }
}
Added:
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FieldDef.java
===================================================================
---
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FieldDef.java
(rev 0)
+++
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FieldDef.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.model.forms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class FieldDef
+{
+ public enum DataType {STRING, LONG, DOUBLE, DATE, BOOL};
+ public enum InputType {TEXT, TEXTAREA, CHOICE, SELECT, BOOL};
+
+ private String label;
+ private String varname;
+ private boolean required;
+
+ private InputType inputType;
+ private String dataTypeClass;
+
+ private String description;
+
+ private List defaults = new ArrayList();
+
+ public FieldDef(String label, String varname, InputType inputType, String dataType,
boolean required)
+ {
+ this.label = label;
+ this.varname = varname;
+ this.inputType = inputType;
+ this.dataTypeClass = dataType;
+ this.required = required;
+ }
+
+ public String getVarname()
+ {
+ return varname;
+ }
+
+ public boolean isRequired()
+ {
+ return required;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public InputType getInputType()
+ {
+ return inputType;
+ }
+
+ public String getDataType()
+ {
+ return dataTypeClass;
+ }
+
+ public List getDefaults()
+ {
+ return defaults;
+ }
+
+
+ public String getLabel()
+ {
+ return label;
+ }
+}
Added:
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FormDef.java
===================================================================
---
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FormDef.java
(rev 0)
+++
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/forms/FormDef.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.model.forms;
+
+import org.jboss.bpm.console.client.model.util.MapEntry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class FormDef
+{
+ private String formName;
+ private List<FieldDef> fields = new ArrayList<FieldDef>();
+
+ public FormDef(String formName)
+ {
+ this.formName = formName;
+ }
+
+ public String getFormName()
+ {
+ return formName;
+ }
+
+ public void setFormName(String formName)
+ {
+ this.formName = formName;
+ }
+
+ public List<FieldDef> getFields()
+ {
+ return fields;
+ }
+}
Deleted:
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/util/MapReplacement.java
===================================================================
---
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/util/MapReplacement.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/util/MapReplacement.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.bpm.console.client.model.util;
-
-import java.util.List;
-
-/**
- * Json Map serialization is a problem, hence the map replacement.
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class MapReplacement
-{
- String name;
-
- List<MapEntry> entries;
-
- public MapReplacement(String name, List<MapEntry> entries)
- {
- this.name = name;
- this.entries = entries;
- }
-
- public String getName()
- {
- return name;
- }
-
- public List<MapEntry> getEntries()
- {
- return entries;
- }
-}
Modified:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java
===================================================================
---
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -23,16 +23,19 @@
import com.google.gson.Gson;
import org.jboss.bpm.console.client.model.TaskReferenceWrapper;
+import org.jboss.bpm.console.client.model.forms.FieldDef;
+import org.jboss.bpm.console.client.model.forms.FormDef;
import org.jboss.bpm.console.client.model.util.MapEntry;
-import org.jboss.bpm.console.client.model.util.MapReplacement;
import org.jboss.bpm.console.server.dao.DAOFactory;
import org.jboss.bpm.console.server.dao.TaskDAO;
+import org.jboss.bpm.console.server.dao.internal.JBPM3FormParser;
import org.jboss.bpm.console.server.gson.GsonFactory;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -104,13 +107,13 @@
entries.add( new MapEntry(s, formMapping.get(s)) );
}
- return createJsonResponse( new MapReplacement("formMapping", entries));
+ return createJsonResponse( entries );
}
@GET
@Path("forms/{processId}/{taskId}")
- @Produces("text/html")
- public Response getTasksFormByTaskName(
+ @Produces("application/json")
+ public Response getTasksFormByTaskId(
@Context
HttpServletRequest request,
@PathParam("processId")
@@ -121,7 +124,34 @@
)
{
byte[] form = getTaskDAO(request).getTaskFormByTaskName(processId, taskId);
- return Response.ok(form).build();
+ JBPM3FormParser parser = new JBPM3FormParser();
+ final FormDef formDef = new FormDef("taskform-"+taskId);
+ try
+ {
+ parser.parse( new ByteArrayInputStream(form));
+
+ parser.visitResults(
+ new JBPM3FormParser.ParseResultVisitor()
+ {
+
+ public void onInputField(FieldDef field)
+ {
+ formDef.getFields().add(field);
+ }
+
+ public void onInputButton(JBPM3FormParser.InputButton btn)
+ {
+ // TODO: parse buttons
+ }
+ }
+ );
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to parse form data", e);
+ }
+
+ return createJsonResponse(formDef);
}
private Response createJsonResponse(Object wrapper)
Modified:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java
===================================================================
---
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -21,14 +21,15 @@
*/
package org.jboss.bpm.console.server.dao.internal;
+import org.jboss.bpm.console.client.model.forms.FieldDef;
import org.jboss.bpm.console.server.util.DOMUtils;
import org.w3c.dom.Element;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -41,24 +42,9 @@
private final static String[] JSF_BOOLEAN_NAMES =
{"selectBooleanCheckbox"};
private final static String[] JSF_BUTTON_NAMES = {"saveButton",
"transitionButton"};
- private List<InputField> inputFields = new ArrayList<InputField>();
+ private List<FieldDef> inputFields = new ArrayList<FieldDef>();
private List<InputButton> inputButtons = new ArrayList<InputButton>();
- static ParseResultVisitor DUMPING_VISITOR = new ParseResultVisitor()
- {
-
- public void onInputField(InputField field)
- {
- System.out.println(field);
-
- }
-
- public void onInputButton(InputButton btn)
- {
- System.out.println(btn);
- }
- };
-
static String test = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
"\n" +
"<html
xmlns=\"http://www.w3.org/1999/xhtml\"\n" +
@@ -130,7 +116,21 @@
{
JBPM3FormParser p = new JBPM3FormParser();
p.parse( new ByteArrayInputStream(test.getBytes()));
+ p.visitResults(
+ new ParseResultVisitor()
+ {
+ public void onInputField(FieldDef field)
+ {
+ System.out.println(field);
+ }
+
+ public void onInputButton(InputButton btn)
+ {
+ System.out.println(btn);
+ }
+ }
+ );
}
public void parse(InputStream in) throws Exception
@@ -145,9 +145,9 @@
parseDatacell(it.next());
}
- visitResults(DUMPING_VISITOR);
}
+ private String lastFieldName = null; // TODO: cleanup
private void parseDatacell(Element datacell)
{
@@ -158,9 +158,10 @@
// skip facet
String nodeName = next.getLocalName();
+
if(JSF_FACET_NAME.equals(nodeName))
{
- parseFieldName(next);
+ lastFieldName = parseFieldName(next);
continue;
}
@@ -207,7 +208,7 @@
public void visitResults(ParseResultVisitor visitor)
{
- for(InputField field : inputFields)
+ for(FieldDef field : inputFields)
visitor.onInputField(field);
for(InputButton btn : inputButtons)
@@ -220,29 +221,36 @@
this.inputFields.clear();
}
+
private void parseTextAreaField(Element next)
{
- String varName = DOMUtils.getAttributeValue(next, "value");
- inputFields.add( new InputField(varName, FIELD_TYPE.TEXTAREA));
+ String varName = getTrimmedVarname(next);
+ inputFields.add( new FieldDef(lastFieldName,varName, FieldDef.InputType.TEXTAREA,
String.class.getName(), true));
}
+ private String getTrimmedVarname(Element next)
+ {
+ String s = DOMUtils.getAttributeValue(next, "value");
+ return trimVarName(s);
+ }
+
private void parseBooleanInputField(Element next)
{
- String varName = DOMUtils.getAttributeValue(next, "value");
- inputFields.add( new InputField(varName, FIELD_TYPE.BOOL));
+ String varName = getTrimmedVarname(next);
+ inputFields.add( new FieldDef(lastFieldName,varName, FieldDef.InputType.BOOL,
Boolean.class.getName(), false));
}
private void parseButtonInputField(Element next)
{
- String name = DOMUtils.getAttributeValue(next, "value");
+ String name = getTrimmedVarname(next);
String transition = DOMUtils.getAttributeValue(next, "transition");
inputButtons.add( new InputButton(name, transition));
}
private void parseTextInputField(Element next)
{
- String varName = DOMUtils.getAttributeValue(next, "value");
- inputFields.add( new InputField(varName, FIELD_TYPE.TEXT));
+ String varName = getTrimmedVarname(next);
+ inputFields.add( new FieldDef(lastFieldName, varName, FieldDef.InputType.TEXT,
String.class.getName(), true));
}
private String parseFieldName(Element facet)
@@ -260,40 +268,10 @@
return fieldName;
}
- enum FIELD_TYPE {BOOL, TEXT, TEXTAREA};
- final class InputField
+ public final class InputButton
{
String name;
- FIELD_TYPE type;
-
- public InputField(String name, FIELD_TYPE type)
- {
- this.name = trimVarName(name);
- this.type = type;
- }
-
- private String trimVarName(String varname)
- {
- String result = varname;
- if(varname.startsWith("#{var['"))
- {
- result = varname.substring( 7, varname.length()-3);
- }
-
- return result;
- }
-
-
- public String toString()
- {
- return "Field{"+type + ": " + name+"}";
- }
- }
-
- final class InputButton
- {
- String name;
String transition;
public InputButton(String name, String transition)
@@ -315,7 +293,18 @@
public interface ParseResultVisitor
{
- void onInputField(InputField field);
+ void onInputField(FieldDef field);
void onInputButton(InputButton btn);
}
+
+ private static String trimVarName(String name)
+ {
+ String result = name;
+ if(name.startsWith("#{var['"))
+ {
+ result = name.substring(7, name.length()-3);
+ }
+
+ return result;
+ }
}
Modified:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
===================================================================
---
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -76,6 +76,7 @@
t0.getId(),
t0.getToken().getId(),
t0.getProcessInstance().getId(),
+ t0.getProcessInstance().getProcessDefinition().getId(),
t0.getName(), t0.getActorId(),
t0.isBlocking(), t0.isSignalling()
);
Modified:
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
---
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -125,4 +125,9 @@
}
return getBaseUrl() + "/rs/tasks/actor?actors="+sb.toString();
}
+
+ public String getTaskFormDefURL(long processId, long taskId)
+ {
+ return getBaseUrl() + "/rs/tasks/forms/"+processId+"/"+taskId;
+ }
}
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-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -22,15 +22,16 @@
package org.jboss.bpm.console.client.model;
import com.google.gwt.json.client.*;
+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 java.util.ArrayList;
import java.util.List;
-import java.util.ArrayList;
import java.util.Map;
-import java.util.HashMap;
-import org.jboss.bpm.console.client.util.JSONWalk;
-
/**
+ * TODO: run integrated (gwt-console-server) test
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public class DTOParser
@@ -86,6 +87,7 @@
long id = JSONWalk.on(item).next("id").asLong();
long tokenId = JSONWalk.on(item).next("tokenId").asLong();
long instanceId = JSONWalk.on(item).next("processInstanceId").asLong();
+ long processId = JSONWalk.on(item).next("processId").asLong();
String name = JSONWalk.on(item).next("name").asString();
String actor = JSONWalk.on(item).next("actor").asString();
boolean isBlocking = JSONWalk.on(item).next("isBlocking").asBool();
@@ -93,6 +95,7 @@
TaskReference ref = new TaskReference(
id, tokenId, instanceId,
+ processId,
name, actor,
isSignalling, isBlocking
);
@@ -112,10 +115,53 @@
public static Map<String,String> parseFormMapping(String json)
{
- //{"Wait for money":"form.money.xhtml","Fix web order
data":"form.fix.xhtml"}
- Map<String,String> result = new HashMap<String,String>();
-
+ //[{"name":"update
erp","value":"form.raise.erp-update.xhtml"}]
+
+ throw new RuntimeException("Not implemented");
- return result;
}
+
+ public static FormDef parseFormDef(String json)
+ {
+ return parseFormDef(JSONParser.parse(json));
+ }
+
+ public static FormDef parseFormDef(JSONValue root)
+ {
+
+
+ // {"formName":"taskform-15",
+ // "fields":[
+ //
{"varname":"amount","required":true,"inputType":"TEXT",
+ //
"dataTypeClass":"java.lang.String","defaults":[]}
+ // ]}
+
+ String formName = JSONWalk.on(root).next("formName").asString();
+ FormDef formDef = new FormDef(formName);
+
+ JSONArray array = JSONWalk.on(root).next("fields").asArray();
+ for(int i=0; i<array.size(); i++)
+ {
+ JSONObject item = array.get(i).isObject();
+
+ // fieldDefs
+ String label = JSONWalk.on(item).next("label").asString();
+ String varName = JSONWalk.on(item).next("varname").asString();
+ boolean required = JSONWalk.on(item).next("required").asBool();
+ FieldDef.InputType inputType = FieldDef.InputType.valueOf(
+ JSONWalk.on(item).next("inputType").asString()
+ );
+
+ String dataType = JSONWalk.on(item).next("dataTypeClass").asString();
+
+ // TODO: Parse defaults
+
+ formDef.getFields().add(
+ new FieldDef(label, varName, inputType, dataType,required)
+ );
+ }
+
+ return formDef;
+ }
+
}
Modified:
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java
===================================================================
---
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -99,6 +99,8 @@
public void onRequestComplete(JavaScriptObject json)
{
+
+ //TODO: move to DTO Parser
JSONObject root = new JSONObject(json);
int diagramWidth =
JSONWalk.on(root).next("diagramWidth").asInt();
int diagramHeight =
JSONWalk.on(root).next("diagramHeight").asInt();
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-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskList.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -24,17 +24,24 @@
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONObject;
import com.gwtext.client.data.*;
+import com.gwtext.client.widgets.*;
+import com.gwtext.client.widgets.form.*;
import com.gwtext.client.widgets.grid.ColumnConfig;
import com.gwtext.client.widgets.grid.ColumnModel;
import org.jboss.bpm.console.client.MainView;
import org.jboss.bpm.console.client.model.DTOParser;
import org.jboss.bpm.console.client.model.TaskReference;
+import org.jboss.bpm.console.client.model.forms.FormDef;
+import org.jboss.bpm.console.client.util.JSONRequest;
+import org.jboss.bpm.console.client.util.JSONRequestHandler;
import org.jboss.bpm.console.client.widgets.RemoteListView;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
/**
+ * TODO: Buffer either generated form panels or at least the FormDef
+ *
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public class TaskList extends RemoteListView
@@ -60,12 +67,87 @@
{
throw new RuntimeException("Tasks cannot be deleted manually!");
}
-
+
protected void onExamine(final int row)
{
+ final TaskReference taskRef = row2taskref.get(row);
+ String url = view.getUrlBuilder().getTaskFormDefURL(taskRef.getProcessId(),
taskRef.getId());
+ MessageBox.show(new MessageBoxConfig() {
+ {
+ setMsg("Generate form, please wait.");
+ setProgressText("Loading...");
+ setWidth(300);
+ setWait(true);
+ setWaitConfig(new WaitConfig() {
+ {
+ setInterval(200);
+ }
+ });
+ }
+ });
+
+ JSONRequest.get(url,
+ new JSONRequestHandler() {
+
+ public void onRequestComplete(JavaScriptObject json)
+ {
+ JSONObject root = new JSONObject(json);
+ FormDef formDef = DTOParser.parseFormDef(root);
+
+ MessageBox.hide();
+
+ // generate form
+ FormPanel formPanel = new FormPanel();
+
+ // -----------
+
+ FieldSet fieldSet = new FieldSet();
+ fieldSet.setLabelWidth(90);
+ fieldSet.setTitle(taskRef.getName());
+ fieldSet.setAutoHeight(true);
+ fieldSet.setBorder(false);
+
+ // -----------
+ for(org.jboss.bpm.console.client.model.forms.FieldDef fieldDef :
formDef.getFields())
+ {
+ switch(fieldDef.getInputType())
+ {
+ case TEXT:
+ fieldSet.add( new TextField(fieldDef.getLabel(),
fieldDef.getVarname()) );
+ break;
+ case TEXTAREA:
+ fieldSet.add( new TextArea(fieldDef.getLabel(),
fieldDef.getVarname()));
+ break;
+ case BOOL:
+ fieldSet.add( new Radio(fieldDef.getLabel(),
fieldDef.getVarname()));
+ break;
+ default:
+ System.out.println("Unknown input type:" +
fieldDef.getInputType());
+ }
+ }
+
+ // -----------
+
+ Panel inner = new PaddedPanel(fieldSet, 0, 10, 0, 0);
+ formPanel.add(inner);
+
+ // -----------
+ displayForm(formPanel);
+ }
+ }
+ );
}
+ private void displayForm(FormPanel formPanel)
+ {
+ TaskListEditor parent = (TaskListEditor)
ComponentMgr.getComponent(TaskListEditor.ID);
+ Panel container = parent.getFormContainer();
+ container.clear();
+ container.add(formPanel);
+ container.doLayout();
+ }
+
protected void onRecordsLoaded(Record[] records)
{
int i=0;
@@ -84,12 +166,12 @@
protected ColumnModel createColumnModel()
{
final ColumnModel columnModel = new ColumnModel(
- new ColumnConfig[]
- {
- new ColumnConfig("ID", "id", 75, true),
- new ColumnConfig("Task Name", "name", 300, true, null,
"expand"),
- new ColumnConfig("Assigned to", "actor", 75, true)
- }
+ new ColumnConfig[]
+ {
+ new ColumnConfig("ID", "id", 75, true),
+ new ColumnConfig("Task Name", "name", 300,
true, null, "expand"),
+ new ColumnConfig("Assigned to", "actor", 75,
true)
+ }
);
return columnModel;
}
@@ -97,11 +179,11 @@
protected JsonReader createReader()
{
final RecordDef recordDef = new RecordDef(
- new FieldDef[]{
- new IntegerFieldDef("id"),
- new StringFieldDef("name"),
- new StringFieldDef("actor")
- }
+ new FieldDef[]{
+ new IntegerFieldDef("id"),
+ new StringFieldDef("name"),
+ new StringFieldDef("actor")
+ }
);
final JsonReader reader = new JsonReader(recordDef);
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-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -43,6 +43,8 @@
private Panel teaserPanel;
private boolean initialized;
+ private Panel formContainer;
+
public TaskListEditor(MainView mainView )
{
super();
@@ -98,6 +100,11 @@
taskList = new TaskList("Your tasks", mainView);
leftHand.add(taskList);
+ formContainer = new Panel();
+ formContainer.setPaddings(10);
+ formContainer.setBorder(false);
+ leftHand.add(formContainer);
+
// ----------------------------------
teaserPanel = new TeaserPanel();
@@ -114,4 +121,9 @@
return true;
}
+
+ public Panel getFormContainer()
+ {
+ return formContainer;
+ }
}
Modified:
projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java
===================================================================
---
projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java 2008-10-31
18:31:43 UTC (rev 2730)
+++
projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java 2008-10-31
20:03:31 UTC (rev 2731)
@@ -24,6 +24,7 @@
import com.google.gwt.junit.client.GWTTestCase;
import org.jboss.bpm.console.client.model.DTOParser;
import org.jboss.bpm.console.client.model.TaskReference;
+import org.jboss.bpm.console.client.model.forms.FormDef;
import java.util.List;
@@ -45,12 +46,22 @@
public void testTaskRefParsing()
{
- //{"tasks":[{"id":14,"name":"manager
evaluation","isSignalling":true,"isBlocking":false,"tokenId":6,"processInstanceId":4,"actor":"manager","transitionNames":["reject","approve"]}]}
+
//{"tasks":[{"id":14,"tokenId":6,"processInstanceId":4,"processId":2,"name":"manager
evaluation","actor":"manager","isBlocking":false,"isSignalling":true,"transitionNames":["reject","approve"]},{"id":15,"tokenId":12,"processInstanceId":10,"processId":3,"name":"submit
raise
request","actor":"manager","isBlocking":false,"isSignalling":true,"transitionNames":["submit
request"]}]}
- String json =
"{\"tasks\":[{\"id\":14,\"name\":\"manager
evaluation\",\"isSignalling\":true,\"isBlocking\":false,\"tokenId\":6,\"processInstanceId\":4,\"actor\":\"manager\",\"transitionNames\":[\"reject\",\"approve\"]}]}";
+ String json =
"{\"tasks\":[{\"id\":14,\"tokenId\":6,\"processInstanceId\":4,\"processId\":2,\"name\":\"manager
evaluation\",\"actor\":\"manager\",\"isBlocking\":false,\"isSignalling\":true,\"transitionNames\":[\"reject\",\"approve\"]},{\"id\":15,\"tokenId\":12,\"processInstanceId\":10,\"processId\":3,\"name\":\"submit
raise
request\",\"actor\":\"manager\",\"isBlocking\":false,\"isSignalling\":true,\"transitionNames\":[\"submit
request\"]}]}";
List<TaskReference> result = DTOParser.parseTaskReferenceList(json);
- assertTrue("Failed to parse TaskReferenceList", result.size()==1);
+ assertTrue("Failed to parse TaskReferenceList", result.size()==2);
assertTrue("Failed to parse transitionNames",
result.get(0).getTransitionNames().size()==2);
}
+
+ public void testForDefParsing()
+ {
+ //
{"formName":"taskform-15","fields":[{"varname":"amount","required":true,"inputType":"TEXT","dataTypeClass":"java.lang.String","defaults":[]},{"varname":"reason","required":true,"inputType":"TEXTAREA","dataTypeClass":"java.lang.String","defaults":[]}]}
+
+ String json =
"{\"formName\":\"taskform-15\",\"fields\":[{\"varname\":\"amount\",\"required\":true,\"inputType\":\"TEXT\",\"dataTypeClass\":\"java.lang.String\",\"defaults\":[]},{\"varname\":\"reason\",\"required\":true,\"inputType\":\"TEXTAREA\",\"dataTypeClass\":\"java.lang.String\",\"defaults\":[]}]}";
+ FormDef formDef = DTOParser.parseFormDef(json);
+ System.out.println("!!!" + formDef.getFormName());
+ System.out.println(formDef.getFields());
+ }
}