[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Hi Simon,
Please find the 9th patch attached.
Now changes made in Sequence sub-nodes in the source tab
are reflected in the design tab. This is not yet working with other container
activities yet.
How I tested the code:
- Create asynchronous
bpel process from the template.
- Open it in two
editors: one in design tab, another one in source tab.
- Try changing the
name attribute of any activity in the source tab. The change should be
reflected in the design tab of the other editor.
- Try to corrupt an
activity node tag, e.g. put a space inside “<bpws:receive”.
The corresponding receive activity element should disappear in the design
tab.
- Restore the
corrupted tag. The activity should re-appear again.
The code may contain bugs J So,
please speak up if you find any.
Thanks,
Vitaly.
|
### Eclipse Workspace Patch 1.0
#P org.eclipse.bpel.model
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/technology/org.eclipse.bpel/plugins/org.eclipse.bpel.model/META-INF/MANIFEST.MF,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 MANIFEST.MF
--- META-INF/MANIFEST.MF 22 Jul 2007 16:34:44 -0000 1.7.2.2
+++ META-INF/MANIFEST.MF 3 Aug 2007 12:30:30 -0000
@@ -19,6 +19,7 @@
Export-Package: org.eclipse.bpel.model,
org.eclipse.bpel.model.adapters,
org.eclipse.bpel.model.extensions,
+ org.eclipse.bpel.model.impl,
org.eclipse.bpel.model.messageproperties,
org.eclipse.bpel.model.messageproperties.util,
org.eclipse.bpel.model.partnerlinktype,
Index: src/org/eclipse/bpel/model/impl/ActivityImpl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/impl/ActivityImpl.java,v
retrieving revision 1.2
diff -u -r1.2 ActivityImpl.java
--- src/org/eclipse/bpel/model/impl/ActivityImpl.java 19 Jan 2006 21:08:48 -0000 1.2
+++ src/org/eclipse/bpel/model/impl/ActivityImpl.java 3 Aug 2007 12:30:30 -0000
@@ -14,13 +14,18 @@
*/
package org.eclipse.bpel.model.impl;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
import org.eclipse.bpel.model.Activity;
import org.eclipse.bpel.model.BPELPackage;
import org.eclipse.bpel.model.Documentation;
import org.eclipse.bpel.model.Sources;
import org.eclipse.bpel.model.Targets;
+import org.eclipse.bpel.model.util.BPELConstants;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
@@ -28,7 +33,11 @@
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.wst.wsdl.WSDLElement;
+import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl;
+import org.eclipse.wst.wsdl.util.WSDLConstants;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* <!-- begin-user-doc -->
@@ -451,5 +460,114 @@
result.append(')');
return result.toString();
}
+
+ public void elementChanged(Element changedElement) {
+ if (!isUpdatingDOM()) {
+ if (!isReconciling) {
+ isReconciling = true;
+ reconcile(changedElement);
+
+ WSDLElement theContainer = getContainer();
+ if (theContainer != null && theContainer.getElement() == changedElement) {
+ ((WSDLElementImpl)theContainer).elementChanged(changedElement);
+ }
+ isReconciling = false;
+ traverseToRootForPatching();
+ }
+ }
+ }
+
+ protected void reconcile(Element changedElement) {
+ reconcileAttributes(changedElement);
+ reconcileContents(changedElement);
+ }
+
+ protected void reconcileAttributes(Element changedElement) {
+ if (changedElement.hasAttribute(BPELConstants.AT_NAME)) {
+ String name = changedElement.getAttribute(BPELConstants.AT_NAME);
+ if (name != null) {
+ setName(name);
+ }
+ }
+ }
+
+ protected void reconcileContents(Element changedElement) {
+ List remainingModelObjects = new ArrayList(getWSDLContents());
+
+ Collection contentNodes = getContentNodes(changedElement);
+
+ Element theDocumentationElement = null;
+
+ // for each applicable child node of changedElement
+ LOOP: for (Iterator i = contentNodes.iterator(); i.hasNext();) {
+ Element child = (Element)i.next();
+ // Set Documentation element if exists
+ /*if (WSDLConstants.DOCUMENTATION_ELEMENT_TAG.equals(child.getLocalName())
+ && WSDLConstants.isMatchingNamespace(child.getNamespaceURI(), WSDLConstants.WSDL_NAMESPACE_URI)) {
+ // assume the first 'documentation' element is 'the' documentation element
+ // 'there can be only one!'
+ if (theDocumentationElement == null) {
+ theDocumentationElement = child;
+ }
+ }*/
+ // go thru the model objects to collect matching object for reuse
+ for (Iterator contents = remainingModelObjects.iterator(); contents.hasNext();) {
+ Object modelObject = (Object)contents.next();
+ if (((WSDLElement)modelObject).getElement() == child) {
+ contents.remove(); // removes the 'child' Node from the remainingModelObjects list
+ continue LOOP;
+ }
+ }
+
+ // if the documentation element has changed... update it
+ if (theDocumentationElement != getDocumentationElement()) {
+ setDocumentationElement(theDocumentationElement);
+ }
+
+ // we haven't found a matching model object for the Node, se we may need to
+ // create a new model object
+ handleUnreconciledElement(child, remainingModelObjects);
+ }
+
+ // now we can remove the remaining model objects
+ handleReconciliation(remainingModelObjects);
+ }
+
+ public int getActivityNodeIndex(Node activityNode) {
+ Node parent = activityNode.getParentNode();
+ if (parent == null) {
+ return -1; //error
+ }
+
+ int index = 0;
+ for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child == activityNode) {
+ return index;
+ }
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ index++;
+ }
+ }
+
+ return -1; // error
+ }
+
+ private Collection getContentNodes(Element changedElement) {
+ Collection result = new ArrayList();
+ for (Node child = changedElement.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ result.add(child);
+ }
+ }
+ return result;
+ }
+
+ /*protected void handleReconciliation(Collection remainingModelObjects) {
+ for (Iterator i = remainingModelObjects.iterator(); i.hasNext();){
+ remove(this, i.next());
+ }
+ }*/
+
+
} //ActivityImpl
Index: src/org/eclipse/bpel/model/impl/SequenceImpl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/impl/SequenceImpl.java,v
retrieving revision 1.2
diff -u -r1.2 SequenceImpl.java
--- src/org/eclipse/bpel/model/impl/SequenceImpl.java 19 Jan 2006 21:08:48 -0000 1.2
+++ src/org/eclipse/bpel/model/impl/SequenceImpl.java 3 Aug 2007 12:30:30 -0000
@@ -15,13 +15,35 @@
package org.eclipse.bpel.model.impl;
import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.bpel.model.Activity;
+import org.eclipse.bpel.model.Assign;
+import org.eclipse.bpel.model.BPELFactory;
import org.eclipse.bpel.model.BPELPackage;
+import org.eclipse.bpel.model.Compensate;
+import org.eclipse.bpel.model.CompensateScope;
import org.eclipse.bpel.model.Documentation;
+import org.eclipse.bpel.model.Empty;
+import org.eclipse.bpel.model.Exit;
+import org.eclipse.bpel.model.Flow;
+import org.eclipse.bpel.model.ForEach;
+import org.eclipse.bpel.model.If;
+import org.eclipse.bpel.model.Invoke;
+import org.eclipse.bpel.model.Pick;
+import org.eclipse.bpel.model.Receive;
+import org.eclipse.bpel.model.Reply;
+import org.eclipse.bpel.model.RepeatUntil;
+import org.eclipse.bpel.model.Rethrow;
+import org.eclipse.bpel.model.Scope;
import org.eclipse.bpel.model.Sequence;
import org.eclipse.bpel.model.Sources;
import org.eclipse.bpel.model.Targets;
+import org.eclipse.bpel.model.Throw;
+import org.eclipse.bpel.model.Validate;
+import org.eclipse.bpel.model.Wait;
+import org.eclipse.bpel.model.While;
+import org.eclipse.bpel.model.util.BPELConstants;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
@@ -245,5 +267,106 @@
}
return eDynamicIsSet(eFeature);
}
+
+ protected void handleReconciliation(Collection remainingModelObjects) {
+ for (Iterator i = remainingModelObjects.iterator(); i.hasNext();){
+ remove(this, i.next());
+ }
+ }
+
+ public void handleUnreconciledElement(Element child, Collection remainingModelObjects) {
+ String bpelType = child.getLocalName();
+
+ int childIndex = getActivityNodeIndex(child);
+
+ if (bpelType.equals(BPELConstants.ND_EMPTY)) {
+ Empty empty = BPELFactory.eINSTANCE.createEmpty();
+ empty.setElement(child);
+ getActivities().add(childIndex, empty);
+ } else if (bpelType.equals(BPELConstants.ND_INVOKE)) {
+ Invoke invoke = BPELFactory.eINSTANCE.createInvoke();
+ invoke.setElement(child);
+ getActivities().add(childIndex, invoke);
+ } else if (bpelType.equals(BPELConstants.ND_RECEIVE)) {
+ Receive receive = BPELFactory.eINSTANCE.createReceive();
+ receive.setElement(child);
+ getActivities().add(childIndex, receive);
+ } else if (bpelType.equals(BPELConstants.ND_REPLY)) {
+ Reply reply = BPELFactory.eINSTANCE.createReply();
+ reply.setElement(child);
+ getActivities().add(childIndex, reply);
+ } else if (bpelType.equals(BPELConstants.ND_VALIDATE)) {
+ Validate validate = BPELFactory.eINSTANCE.createValidate();
+ validate.setElement(child);
+ getActivities().add(childIndex, validate);
+ } else if (bpelType.equals(BPELConstants.ND_IF)) {
+ If _if = BPELFactory.eINSTANCE.createIf();
+ _if.setElement(child);
+ getActivities().add(childIndex, _if);
+ } else if (bpelType.equals(BPELConstants.ND_PICK)) {
+ Pick pick = BPELFactory.eINSTANCE.createPick();
+ pick.setElement(child);
+ getActivities().add(childIndex, pick);
+ } else if (bpelType.equals(BPELConstants.ND_WHILE)) {
+ While _while = BPELFactory.eINSTANCE.createWhile();
+ _while.setElement(child);
+ getActivities().add(childIndex, _while);
+ } else if (bpelType.equals(BPELConstants.ND_FOR_EACH)) {
+ ForEach foreach = BPELFactory.eINSTANCE.createForEach();
+ foreach.setElement(child);
+ getActivities().add(childIndex, foreach);
+ } else if (bpelType.equals(BPELConstants.ND_REPEAT_UNTIL)) {
+ RepeatUntil repeatUntil = BPELFactory.eINSTANCE.createRepeatUntil();
+ repeatUntil.setElement(child);
+ getActivities().add(childIndex, repeatUntil);
+ } else if (bpelType.equals(BPELConstants.ND_WAIT)) {
+ Wait wait = BPELFactory.eINSTANCE.createWait();
+ wait.setElement(child);
+ getActivities().add(childIndex, wait);
+ } else if (bpelType.equals(BPELConstants.ND_SEQUENCE)) {
+ Sequence sequence = BPELFactory.eINSTANCE.createSequence();
+ sequence.setElement(child);
+ getActivities().add(childIndex, sequence);
+ } else if (bpelType.equals(BPELConstants.ND_SCOPE)) {
+ Scope scope = BPELFactory.eINSTANCE.createScope();
+ scope.setElement(child);
+ getActivities().add(childIndex, scope);
+ } else if (bpelType.equals(BPELConstants.ND_FLOW)) {
+ Flow flow = BPELFactory.eINSTANCE.createFlow();
+ flow.setElement(child);
+ getActivities().add(childIndex, flow);
+ } else if (bpelType.equals(BPELConstants.ND_EXIT)) {
+ Exit exit = BPELFactory.eINSTANCE.createExit();
+ exit.setElement(child);
+ getActivities().add(childIndex, exit);
+ } else if (bpelType.equals(BPELConstants.ND_THROW)) {
+ Throw _throw = BPELFactory.eINSTANCE.createThrow();
+ _throw.setElement(child);
+ getActivities().add(childIndex, _throw);
+ } else if (bpelType.equals(BPELConstants.ND_RETHROW)) {
+ Rethrow rethrow = BPELFactory.eINSTANCE.createRethrow();
+ rethrow.setElement(child);
+ getActivities().add(childIndex, rethrow);
+ } else if (bpelType.equals(BPELConstants.ND_COMPENSATE)) {
+ Compensate compensate = BPELFactory.eINSTANCE.createCompensate();
+ compensate.setElement(child);
+ getActivities().add(childIndex, compensate);
+ } else if (bpelType.equals(BPELConstants.ND_COMPENSATE_SCOPE)) {
+ CompensateScope compensateScope = BPELFactory.eINSTANCE.createCompensateScope();
+ compensateScope.setElement(child);
+ getActivities().add(childIndex, compensateScope);
+ } else if (bpelType.equals(BPELConstants.ND_ASSIGN)) {
+ Assign assign = BPELFactory.eINSTANCE.createAssign();
+ assign.setElement(child);
+ getActivities().add(childIndex, assign);
+ } else {
+ super.handleUnreconciledElement(child, remainingModelObjects);
+ }
+ }
+
+ protected void remove(Object component, Object modelObject) {
+ ((Sequence)component).getActivities().remove(modelObject);
+ }
+
} //SequenceImpl
#P org.eclipse.bpel.ui
Index: src/org/eclipse/bpel/ui/BPELModelReconcileAdapter.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Attic/BPELModelReconcileAdapter.java,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 BPELModelReconcileAdapter.java
--- src/org/eclipse/bpel/ui/BPELModelReconcileAdapter.java 22 Jul 2007 16:34:38 -0000 1.1.2.1
+++ src/org/eclipse/bpel/ui/BPELModelReconcileAdapter.java 3 Aug 2007 12:30:33 -0000
@@ -1,6 +1,12 @@
package org.eclipse.bpel.ui;
+import java.util.ArrayList;
+import java.util.Collection;
+
import org.eclipse.bpel.model.Process;
+import org.eclipse.bpel.model.impl.ActivityImpl;
+import org.eclipse.bpel.model.util.BPELConstants;
+import org.eclipse.bpel.ui.util.BPELEditorUtil;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.wsdl.Definition;
@@ -16,109 +22,90 @@
import org.w3c.dom.Node;
-class BPELModelReconcileAdapter extends ModelReconcileAdapter
-{
- protected Process process;
-
- public BPELModelReconcileAdapter(Document document, Process process)
- {
- super(document);
- this.process = process;
- }
-
- // This method is clever enough to deal with 'bad' documents that happen
- // to have more than one root element. It picks of the first 'matching' element.
- //
- // TODO (cs) why aren't we calling this from the WSDLModelAdapter when the model is initialized?
- //
- private Element getProcessElement(Document document)
- {
- Element processElement = null;
- for (Node node = document.getFirstChild(); node != null; node = node.getNextSibling())
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element element = (Element)node;
- /*if (WSDLEditorUtil.getInstance().getWSDLType(element) == WSDLConstants.DEFINITION)
- {
- definitionElement = element;
- break;
- }*/
- }
- }
- return processElement;
- }
+class BPELModelReconcileAdapter extends ModelReconcileAdapter {
+ protected Process process;
+
+ public BPELModelReconcileAdapter(Document document, Process process) {
+ super(document);
+ this.process = process;
+ }
+
+ // This method is clever enough to deal with 'bad' documents that happen
+ // to have more than one root element. It picks of the first 'matching' element.
+ //
+ // TODO (cs) why aren't we calling this from the WSDLModelAdapter when the model is initialized?
+ //
+ private Element getProcessElement(Document document) {
+ Element processElement = null;
+ for (Node node = document.getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element)node;
+ if (BPELEditorUtil.getInstance().getBPELType(element).equals(BPELConstants.ND_PROCESS)) {
+ processElement = element;
+ break;
+ }
+ }
+ }
+ return processElement;
+ }
- protected void handleNodeChanged(Node node)
- {
- if (node instanceof Element) {
- reconcileModelObjectForElement((Element)node);
- } else if (node instanceof Document) {
- // The document changed so we may need to fix up the
- // definition's root element
- Document document = (Document)node;
- Element processElement = getProcessElement(document);
- /*if (definitionElement != null && definitionElement != process.getElement())
- {
- // here we handle the case where a new 'definition' element was added
- //(e.g. the file was totally blank and then we type in the root element)
- // See Bug 5366
- //
- if (definitionElement.getLocalName().equals(WSDLConstants.DEFINITION_ELEMENT_TAG))
- {
- //System.out.println("****** Setting new definition");
- process.setElement(definitionElement);
- }
- }
- else if (definitionElement != null)
- {
- // handle the case where the definition element's content has changed
- //
- ((ProcessImpl)process).elementChanged(definitionElement);
- }
- else if (definitionElement == null)
- {
- // if there's no definition element clear out the WSDL
- //
- ((ProcessImpl)process).removeAll();
+ protected void handleNodeChanged(Node node) {
+ if (node instanceof Element) {
+ reconcileModelObjectForElement((Element)node);
+ } else if (node instanceof Document) {
+ // The document changed so we may need to fix up the
+ // definition's root element
+ Document document = (Document)node;
+ Element processElement = getProcessElement(document);
+ /*if (definitionElement != null && definitionElement != process.getElement()) {
+ // here we handle the case where a new 'definition' element was added
+ //(e.g. the file was totally blank and then we type in the root element)
+ // See Bug 5366
+ //
+ if (definitionElement.getLocalName().equals(WSDLConstants.DEFINITION_ELEMENT_TAG)) {
+ //System.out.println("****** Setting new definition");
+ process.setElement(definitionElement);
+ }
+ } else if (definitionElement != null) {
+ // handle the case where the definition element's content has changed
+ //
+ ((ProcessImpl)process).elementChanged(definitionElement);
+ } else if (definitionElement == null) {
+ // if there's no definition element clear out the WSDL
+ //
+ ((ProcessImpl)process).removeAll();
+ // The removeAll() call does not remove namespaces as well and the model
+ // does not reconcile well in this case. Also reset the definition name and target
+ // namespace.
+ process.getNamespaces().clear();
+ process.setQName(null);
+ process.setTargetNamespace(null);
- // The removeAll() call does not remove namespaces as well and the model
- // does not reconcile well in this case. Also reset the definition name and target
- // namespace.
-
- process.getNamespaces().clear();
- process.setQName(null);
- process.setTargetNamespace(null);
-
- // Reset the document because removeAll() sets the document to null as well.
- process.setDocument(document);
- }*/
- }
- }
+ // Reset the document because removeAll() sets the document to null as well.
+ process.setDocument(document);
+ }*/
+ }
+ }
- private void reconcileModelObjectForElement(Element element)
- {
- Object modelObject = null;//WSDLEditorUtil.getInstance().findModelObjectForElement(process, element);
- if (modelObject != null)
- {
- if (modelObject instanceof XSDSchemaExtensibilityElementImpl)
- {
- XSDSchemaExtensibilityElementImpl ee = (XSDSchemaExtensibilityElementImpl)modelObject;
- ((XSDSchemaImpl)ee.getSchema()).elementChanged(element);
- ee.elementChanged(element);
- }
- else if (modelObject instanceof WSDLElementImpl)
- {
- ((WSDLElementImpl)modelObject).elementChanged(element);
- }
- else if (modelObject instanceof XSDConcreteComponent)
- {
- ((XSDConcreteComponent)modelObject).elementChanged(element);
- }
- }
- }
+ private void reconcileModelObjectForElement(Element element) {
+ Object modelObject = BPELEditorUtil.getInstance().findModelObjectForElement(process, element);
+ if (modelObject != null) {
+ if (modelObject instanceof ActivityImpl) {
+ ((ActivityImpl)modelObject).elementChanged(element);
+ } else if (modelObject instanceof XSDSchemaExtensibilityElementImpl) {
+ XSDSchemaExtensibilityElementImpl ee = (XSDSchemaExtensibilityElementImpl)modelObject;
+ ((XSDSchemaImpl)ee.getSchema()).elementChanged(element);
+ ee.elementChanged(element);
+ } else if (modelObject instanceof WSDLElementImpl) {
+ ((WSDLElementImpl)modelObject).elementChanged(element);
+ } else if (modelObject instanceof XSDConcreteComponent) {
+ ((XSDConcreteComponent)modelObject).elementChanged(element);
+ }
+ }
+ }
+
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty)
+ public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty)
{
if (!isDirty)
{