Author: koen.aers(a)jboss.com
Date: 2009-08-03 05:46:40 -0400 (Mon, 03 Aug 2009)
New Revision: 16940
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewayDeserializer.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewaySerializer.java
Log:
GPD-356: Designer creates duplicate handler nodes under decision nodes
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF 2009-07-31 23:24:37
UTC (rev 16939)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF 2009-08-03 09:46:40
UTC (rev 16940)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.jboss.tools.flow.jpdl4;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.1.0.qualifier
Bundle-Vendor: %Bundle-Vendor.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.jboss.tools.flow.common;bundle-version="1.0.0",
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewayDeserializer.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewayDeserializer.java 2009-07-31
23:24:37 UTC (rev 16939)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewayDeserializer.java 2009-08-03
09:46:40 UTC (rev 16940)
@@ -3,12 +3,17 @@
*/
package org.jboss.tools.flow.jpdl4.io;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.tools.flow.common.wrapper.Wrapper;
import org.jboss.tools.flow.jpdl4.model.ExclusiveGateway;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
class ExclusiveGatewayDeserializer extends NodeDeserializer {
+
public void deserializeAttributes(Wrapper wrapper, Element element) {
super.deserializeAttributes(wrapper, element);
if (!(wrapper.getElement() instanceof ExclusiveGateway)) return;
@@ -16,15 +21,28 @@
exclusiveGateWay.setExpr(element.getAttribute("expr"));
exclusiveGateWay.setLang(element.getAttribute("lang"));
}
- public Wrapper deserializeChildNode(Wrapper parent, Node node) {
- Wrapper result = null;
- ExclusiveGateway exclusiveGateway = (ExclusiveGateway)parent.getElement();
- if (node instanceof Element && "handler".equals(node.getNodeName()))
{
- String className = ((Element)node).getAttribute("class");
- exclusiveGateway.setHandler("".equals(className) ? null : className);
- } else {
- result = super.deserializeChildNode(parent, node);
+
+ public void deserializeChildNodes(Wrapper wrapper,
+ Element element) {
+ if (wrapper == null) return;
+ NodeList nodeList = element.getChildNodes();
+ ArrayList<Node> unknownNodeList = new ArrayList<Node>();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if ("handler".equals(node.getNodeName())) {
+ deserializeHandler(wrapper, node, unknownNodeList);
+ } else {
+ deserializeChildNode(wrapper, node, unknownNodeList);
+ }
}
- return result;
+ wrapper.getElement().setMetaData("trailingNodes", unknownNodeList);
}
+
+ private void deserializeHandler(Wrapper parent, Node node, List<Node>
unknownNodeList) {
+ parent.setMetaData("beforeHandlerNodes", new
ArrayList<Node>(unknownNodeList));
+ unknownNodeList.clear();
+ String className = ((Element)node).getAttribute("class");
+ parent.setPropertyValue(ExclusiveGateway.HANDLER, "".equals(className) ? null
: className);
+ }
+
}
\ No newline at end of file
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewaySerializer.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewaySerializer.java 2009-07-31
23:24:37 UTC (rev 16939)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/io/ExclusiveGatewaySerializer.java 2009-08-03
09:46:40 UTC (rev 16940)
@@ -9,20 +9,26 @@
import org.jboss.tools.flow.jpdl4.model.ExclusiveGateway;
class ExclusiveGatewaySerializer extends ProcessNodeSerializer {
+
protected List<String> getAttributesToSave() {
List<String> result = super.getAttributesToSave();
result.add("expr");
result.add("lang");
return result;
}
+
public void appendBody(StringBuffer buffer, Wrapper wrapper, int level) {
ExclusiveGateway exclusiveGateway = (ExclusiveGateway)wrapper.getElement();
String handler = exclusiveGateway.getHandler();
if (handler != null && !"".equals(handler)) {
- buffer.append("\n");
- appendPadding(buffer, level + 1);
- buffer.append("<handler class=\"" + handler + "\"
/>");
+ appendHandler(buffer, wrapper, handler, level);
}
super.appendBody(buffer, wrapper, level);
}
+
+ private void appendHandler(StringBuffer buffer, Wrapper wrapper, String handler, int
level) {
+ appendUnknownNodes("beforeHandlerNodes", buffer, wrapper, level);
+ buffer.append("<handler
class=\"").append(handler).append("\" />");
+ }
+
}
\ No newline at end of file