Author: Grid.Qian
Date: 2009-12-24 02:20:10 -0500 (Thu, 24 Dec 2009)
New Revision: 19565
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java
Log:
JBIDE-5394: BPEL Plugin is not correctly initalizing variables
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java 2009-12-23
17:30:14 UTC (rev 19564)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/VariablePartAssignCategory.java 2009-12-24
07:20:10 UTC (rev 19565)
@@ -57,8 +57,11 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.wsdl.Message;
import org.eclipse.wst.wsdl.Part;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMContentBuilderImpl;
@@ -71,6 +74,8 @@
import org.eclipse.xsd.XSDNamedComponent;
import org.eclipse.xsd.XSDTypeDefinition;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* An AssignCategory presenting a tree from which the user can select any of: -
@@ -773,5 +778,102 @@
}
createDefaultContent(document, rootCMElementDeclaration);
}
+
+ public void visitCMElementDeclaration(CMElementDeclaration ed) {
+ int forcedMin = (buildOptionalElements(buildPolicy) || alwaysVisit) ? 1 : 0;
+ int min = 1;
+
+ // Correct the min value if the element is contained in
+ // a group.
+ if (!cmGroupStack.isEmpty()) {
+ CMGroup group = (CMGroup) cmGroupStack.peek();
+ int gmin = group.getMinOccur();
+ if (gmin == 0)
+ if (buildOptionalElements(buildPolicy)) {
+ /* do nothing: min = min */
+ }
+ else {
+ min = min * gmin; // min = 0
+ }
+ else {
+ min = min * gmin;
+ }
+ }
+
+ int max = Math.min(ed.getMaxOccur(), getNumOfRepeatableElements());
+ if (max < min)
+ max = min;
+
+ alwaysVisit = false;
+
+ // Note - ed may not be abstract but has substitutionGroups
+ // involved.
+ if (buildFirstSubstitution(buildPolicy) || isAbstract(ed)) // leave
+ // this
+ // for
+ // backward
+ // compatibility
+ // for now
+ {
+ // Note - To change so that if ed is optional, we do not
+ // generate anything here.
+ ed = getSubstitution(ed);
+
+ // Note - the returned ed may be an abstract element in
+ // which case the xml will be invalid.
+ }
+
+ if (min > 0 && !visitedCMElementDeclarationList.contains(ed)) {
+ visitedCMElementDeclarationList.add(ed);
+ for (int i = 1; i <= max; i++) {
+ // create an Element for each
+ Element element = null;
+ if (rootElement != null) {
+ element = rootElement;
+ rootElement = null;
+ }
+ else {
+ element = createElement(ed, computeName(ed, currentParent), currentParent);
+ }
+
+ // visit the children of the GrammarElement
+ Node oldParent = currentParent;
+ currentParent = element;
+ handlePushParent(element, ed);
+
+ namespaceTable.addElement(element);
+
+ boolean oldAttachNodesToParent = attachNodesToParent;
+ attachNodesToParent = true;
+
+ // instead of calling super.visitCMElementDeclaration()
+ // we duplicate the code with some minor modifications
+ CMNamedNodeMap nodeMap = ed.getAttributes();
+ int size = nodeMap.getLength();
+ for (int j = 0; j < size; j++) {
+ visitCMNode(nodeMap.item(j));
+ }
+
+ CMContent content = ed.getContent();
+ if (content != null) {
+ visitCMNode(content);
+ }
+
+ if (ed.getContentType() == CMElementDeclaration.PCDATA) {
+ CMDataType dataType = ed.getDataType();
+ if (dataType != null) {
+ visitCMDataType(dataType);
+ }
+ }
+ // end duplication
+ attachNodesToParent = oldAttachNodesToParent;
+ handlePopParent(element, ed);
+ currentParent = oldParent;
+ linkNode(element);
+ }
+ int size = visitedCMElementDeclarationList.size();
+ visitedCMElementDeclarationList.remove(size - 1);
+ }
+ }
}
}
Show replies by date