Author: objectiser
Date: 2010-03-15 19:03:53 -0400 (Mon, 15 Mar 2010)
New Revision: 197
Added:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/util/
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/util/InteractionUtilTest.java
Removed:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElement.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/XMLUtilsTest.java
tools/eclipse/trunk/plugins/org.scribble.pi4soa.cdm/META-INF/MANIFEST.MF
Log:
Initial work on handling BPEL error focus (SAVARA-11). This currently focuses on the text
- just need to work out how to focus on graphical nodes, which may required the EMF URI.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF 2010-03-15
23:03:53 UTC (rev 197)
@@ -18,7 +18,9 @@
org.scribble.expression.xpath,
org.scribble.pi4soa.cdm;resolution:=optional,
org.scribble.contract.model,
- org.jboss.savara.tools.wsdl
+ org.jboss.savara.tools.wsdl,
+ org.eclipse.ui.ide,
+ org.eclipse.stp.bpmn.diagram;resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor:
www.jboss.org
@@ -32,4 +34,5 @@
org.jboss.savara.tools.bpel.model.change.IfModelChangeRule,
org.jboss.savara.tools.bpel.model.change.RunModelChangeRule,
org.jboss.savara.tools.bpel.model.change.SpawnModelChangeRule,
- org.jboss.savara.tools.bpel.model.change.ConversationInteractionModelChangeRule
+ org.jboss.savara.tools.bpel.model.change.ConversationInteractionModelChangeRule,
+ org.jboss.savara.tools.bpel.editor.BPELEditorManager
Added:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java
(rev 0)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.tools.bpel.editor;
+
+//import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.tools.bpel.model.BPELNotation;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the BPEL editor implementation of the EditorManager
+ * interface.
+ */
+(a)RegistryInfo(extension=EditorManager.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELEditorManager extends AbstractEditorManager {
+
+ /**
+ * This method focuses the editor on the specified source,
+ * identified by the model reference and source reference.
+ *
+ * @param mref The model reference
+ * @param sref The component source reference
+ * @param prop Additional properties
+ */
+ public void focus(ModelReference mref, SourceRef sref,
+ java.util.Map<String,Object> props) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditorID");
+
+ if (part instanceof org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditor) {
+ org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditor editor=
+ (org.eclipse.stp.bpmn.diagram.part.BpmnDiagramEditor)part;
+
+ System.out.println("FOCUS ON: "+sref.getComponentURI());
+ //editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ // Set the EMF URI attribute
+ //issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ // issue.getModelObject().getSource().getComponentURI());
+ }
+}
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -47,8 +47,8 @@
public DefaultBPELLanguageModel(ModelReference source, org.w3c.dom.Element elem,
String contents) {
m_source = source;
+ m_contents = contents;
m_bpelProcess = new Process(this, elem);
- m_contents = contents;
Namespace ns=new Namespace();
ns.setName(source.getNamespace());
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -146,6 +146,7 @@
protected TypeReference createTypeReference(String type, ConversionContext context) {
TypeReference ret=new TypeReference();
+ ret.derivedFrom(this);
if (type != null) {
int index=-1;
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElement.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElement.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElement.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -21,6 +21,7 @@
import org.scribble.model.admin.ModelListener;
import org.apache.commons.logging.*;
import org.jboss.savara.tools.bpel.model.*;
+import org.jboss.savara.tools.bpel.util.XMLUtils;
/**
* This is the generic BPEL element class.
@@ -43,8 +44,9 @@
m_element = elem;
- // TODO: Set the start/end position information
+ // Set the start/end position information
// in the source details
+ XMLUtils.setStartAndEndPosition(this, model.getOriginalContents(), elem);
getSource().setObject(this);
}
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -145,6 +145,7 @@
scope.getFaultHandlers().getCatchAll() != null)) {
org.scribble.conversation.model.If te=
new org.scribble.conversation.model.If();
+ te.derivedFrom(this);
activities.add(te);
@@ -206,6 +207,7 @@
ConversionContext context) {
// Create interaction for request
ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
Variable var=context.getVariable(getInputVariable());
@@ -235,6 +237,7 @@
// Create interaction for request
ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
Variable var=context.getVariable(getOutputVariable());
@@ -264,6 +267,7 @@
// Create interaction for request
ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
TypeReference tref=null;
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -131,12 +131,15 @@
protected void convertActivity(java.util.List<Activity> activities,
ConversionContext context) {
ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
Variable var=context.getVariable(getVariable());
TypeReference tref=createTypeReference(var.getMessageType(), context);
MessageSignature ms=new MessageSignature();
+ ms.derivedFrom(this);
+
ms.setOperation(getOperation());
ms.getTypes().add(tref);
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -119,12 +119,15 @@
protected void convertActivity(java.util.List<Activity> activities,
ConversionContext context) {
ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
Variable var=context.getVariable(getVariable());
TypeReference tref=createTypeReference(var.getMessageType(), context);
MessageSignature ms=new MessageSignature();
+ ms.derivedFrom(this);
+
ms.setOperation(getOperation());
ms.getTypes().add(tref);
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -19,11 +19,14 @@
import java.io.ByteArrayOutputStream;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.scribble.model.ModelObject;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -170,6 +173,24 @@
return(ret);
}
+ public static Node getNode(String text) throws Exception {
+ Node ret=null;
+
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(text.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ ret = doc.getDocumentElement();
+
+ return(ret);
+ }
+
/**
* This method returns the localname part of the supplied
* qualified name.
@@ -207,4 +228,73 @@
return(prefix);
}
+
+ /**
+ * This method calculates the start and end position of a supplied DOM element, within
+ * the supplied text contents, and sets the values on the supplied ModelObject.
+ *
+ * @param obj The ModelObject to be initialized
+ * @param contents The text contents
+ * @param elem The DOM element to be located in the text
+ */
+ public static void setStartAndEndPosition(ModelObject obj, String contents,
org.w3c.dom.Element elem) {
+
+ if (contents != null) {
+ org.w3c.dom.NodeList
nl=elem.getOwnerDocument().getElementsByTagName(elem.getNodeName());
+ int elempos=-1;
+
+ for (int i=0; elempos == -1 && i < nl.getLength(); i++) {
+ if (nl.item(i) == elem) {
+ elempos = i;
+ }
+ }
+
+ if (elempos != -1) {
+ int startpos=-1;
+
+ for (int i=0; i <= elempos; i++) {
+ int val1=contents.indexOf("<"+elem.getNodeName()+">",
startpos+1);
+ int val2=contents.indexOf("<"+elem.getNodeName()+" ",
startpos+1);
+
+ if (val1 == -1 && val2 != -1) {
+ startpos = val2;
+ } else if (val1 != -1 && val2 == -1) {
+ startpos = val1;
+ } else if (val1 == -1 && val2 == -1) {
+ // TODO: Error condition
+ break;
+ } else if (val1 > val2) {
+ startpos = val2;
+ } else {
+ startpos = val1;
+ }
+ }
+
+ if (startpos != -1) {
+ obj.getSource().setStartPosition(startpos);
+
+ // Check if single node
+ int p1=contents.indexOf('>', startpos);
+
+ if (p1 != -1 && contents.charAt(p1-1) == '/') {
+ obj.getSource().setEndPosition(p1);
+ } else {
+
+ org.w3c.dom.NodeList enl=elem.getElementsByTagName(elem.getNodeName());
+
+ int endpos=startpos;
+ String nodetxt="</"+elem.getNodeName()+">";
+
+ for (int i=0; endpos != -1 && i <= enl.getLength(); i++) {
+ endpos = contents.indexOf(nodetxt, endpos+1);
+ }
+
+ if (endpos != -1) {
+ obj.getSource().setEndPosition(endpos+nodetxt.length()-1);
+ }
+ }
+ }
+ }
+ }
+ }
}
Copied:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/util/InteractionUtilTest.java
(from rev 193,
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java)
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/util/InteractionUtilTest.java
(rev 0)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/util/InteractionUtilTest.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.tools.bpel.model.util;
+
+import junit.framework.TestCase;
+
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+public class InteractionUtilTest extends TestCase {
+
+ public void testIsFirstInteractionSingleInteraction() {
+ ConversationModel cm=new ConversationModel();
+ Conversation c=new Conversation();
+ cm.setConversation(c);
+
+ Interaction i1=new Interaction();
+
+ c.getBlock().getContents().add(i1);
+
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i1) == false) {
+ fail("Interaction should be first in conversation");
+ }
+ }
+
+ public void testIsFirstInteractionSecondInteraction() {
+ ConversationModel cm=new ConversationModel();
+ Conversation c=new Conversation();
+ cm.setConversation(c);
+
+ Interaction i1=new Interaction();
+ Interaction i2=new Interaction();
+
+ c.getBlock().getContents().add(i1);
+ c.getBlock().getContents().add(i2);
+
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i2)) {
+ fail("Interaction should NOT be first in conversation");
+ }
+ }
+
+ public void testIsFirstInteractionIfElse() {
+ ConversationModel cm=new ConversationModel();
+ Conversation c=new Conversation();
+ cm.setConversation(c);
+
+ If choice=new If();
+ c.getBlock().getContents().add(choice);
+
+ Block b=choice.createNewPath();
+
+ Interaction i1=new Interaction();
+
+ b.getContents().add(i1);
+
+ Block b2=choice.createNewPath();
+
+ Interaction i2=new Interaction();
+ Interaction i3=new Interaction();
+
+ b2.getContents().add(i2);
+ b2.getContents().add(i3);
+
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i1) == false) {
+ fail("Interaction should be first in conversation");
+ }
+
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i2) == false) {
+ fail("Interaction should be first in conversation");
+ }
+
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i3)) {
+ fail("Interaction should NOT be first in conversation");
+ }
+ }
+}
Deleted:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.savara.tools.bpel.util;
-
-import junit.framework.TestCase;
-
-import org.scribble.conversation.model.*;
-import org.scribble.model.*;
-
-public class InteractionUtilTest extends TestCase {
-
- public void testIsFirstInteractionSingleInteraction() {
- ConversationModel cm=new ConversationModel();
- Conversation c=new Conversation();
- cm.setConversation(c);
-
- Interaction i1=new Interaction();
-
- c.getBlock().getContents().add(i1);
-
- if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i1) == false) {
- fail("Interaction should be first in conversation");
- }
- }
-
- public void testIsFirstInteractionSecondInteraction() {
- ConversationModel cm=new ConversationModel();
- Conversation c=new Conversation();
- cm.setConversation(c);
-
- Interaction i1=new Interaction();
- Interaction i2=new Interaction();
-
- c.getBlock().getContents().add(i1);
- c.getBlock().getContents().add(i2);
-
- if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i2)) {
- fail("Interaction should NOT be first in conversation");
- }
- }
-
- public void testIsFirstInteractionIfElse() {
- ConversationModel cm=new ConversationModel();
- Conversation c=new Conversation();
- cm.setConversation(c);
-
- If choice=new If();
- c.getBlock().getContents().add(choice);
-
- Block b=choice.createNewPath();
-
- Interaction i1=new Interaction();
-
- b.getContents().add(i1);
-
- Block b2=choice.createNewPath();
-
- Interaction i2=new Interaction();
- Interaction i3=new Interaction();
-
- b2.getContents().add(i2);
- b2.getContents().add(i3);
-
- if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i1) == false) {
- fail("Interaction should be first in conversation");
- }
-
- if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i2) == false) {
- fail("Interaction should be first in conversation");
- }
-
- if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i3)) {
- fail("Interaction should NOT be first in conversation");
- }
- }
-}
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/XMLUtilsTest.java
===================================================================
---
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/XMLUtilsTest.java 2010-03-15
18:06:05 UTC (rev 196)
+++
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/XMLUtilsTest.java 2010-03-15
23:03:53 UTC (rev 197)
@@ -18,6 +18,7 @@
package org.jboss.savara.tools.bpel.util;
import org.jboss.savara.tools.bpel.util.XMLUtils;
+import org.scribble.model.ModelObject;
import junit.framework.TestCase;
@@ -51,4 +52,121 @@
fail("Failed: "+e);
}
}
+
+ public void testSetStartAndEndPosition() {
+ String
xml="<root><myelem></myelem><myelem></myelem></root>";
+
+ try {
+ org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+
+ org.w3c.dom.NodeList nl=node.getElementsByTagName("myelem");
+
+ if (nl.getLength() != 2) {
+ fail("Should be two elements: "+nl.getLength());
+ }
+
+ ModelObject obj=new ModelObject(){};
+
+ XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+
+ if (obj.getSource().getStartPosition() != 23) {
+ fail("Start position should be 23: "+obj.getSource().getStartPosition());
+ }
+
+ if (obj.getSource().getEndPosition() != 39) {
+ fail("End position should be 39: "+obj.getSource().getEndPosition());
+ }
+
+ } catch(Exception e) {
+ fail("Failed: "+e);
+ }
+ }
+
+ public void testSetStartAndEndPositionWithNS() {
+ String xml="<bpel:root xmlns:bpel=\"myns\"
><bpel:myelem></bpel:myelem><bpel:myelem></bpel:myelem></bpel:root>";
+
+ try {
+ org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+
+ org.w3c.dom.NodeList nl=node.getElementsByTagNameNS("myns",
"myelem");
+
+ if (nl.getLength() != 2) {
+ fail("Should be two elements: "+nl.getLength());
+ }
+
+ ModelObject obj=new ModelObject(){};
+
+ XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+
+ if (obj.getSource().getStartPosition() != 57) {
+ fail("Start position should be 57: "+obj.getSource().getStartPosition());
+ }
+
+ if (obj.getSource().getEndPosition() != 83) {
+ fail("End position should be 83: "+obj.getSource().getEndPosition());
+ }
+
+ } catch(Exception e) {
+ fail("Failed: "+e);
+ }
+ }
+
+ public void testSetStartAndEndPositionSingleNodeWithNS() {
+ String xml="<bpel:root xmlns:bpel=\"myns\" ><bpel:myelem
attr=\"1\" /><bpel:myelem attr=\"2\"
/></bpel:root>";
+
+ try {
+ org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+
+ org.w3c.dom.NodeList nl=node.getElementsByTagNameNS("myns",
"myelem");
+
+ if (nl.getLength() != 2) {
+ fail("Should be two elements: "+nl.getLength());
+ }
+
+ ModelObject obj=new ModelObject(){};
+
+ XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+
+ if (obj.getSource().getStartPosition() != 54) {
+ fail("Start position should be 54: "+obj.getSource().getStartPosition());
+ }
+
+ if (obj.getSource().getEndPosition() != 77) {
+ fail("End position should be 77: "+obj.getSource().getEndPosition());
+ }
+
+ } catch(Exception e) {
+ fail("Failed: "+e);
+ }
+ }
+
+ public void testSetStartAndEndPositionWithChildAndNS() {
+ String xml="<bpel:root xmlns:bpel=\"myns\"
><bpel:myelem></bpel:myelem>" +
+ "<bpel:myelem><bpel:myelem></bpel:myelem></bpel:myelem></bpel:root>";
+
+ try {
+ org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+
+ org.w3c.dom.NodeList nl=node.getElementsByTagNameNS("myns",
"myelem");
+
+ if (nl.getLength() != 3) {
+ fail("Should be three elements: "+nl.getLength());
+ }
+
+ ModelObject obj=new ModelObject(){};
+
+ XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+
+ if (obj.getSource().getStartPosition() != 57) {
+ fail("Start position should be 57: "+obj.getSource().getStartPosition());
+ }
+
+ if (obj.getSource().getEndPosition() != 110) {
+ fail("End position should be 110: "+obj.getSource().getEndPosition());
+ }
+
+ } catch(Exception e) {
+ fail("Failed: "+e);
+ }
+ }
}
Modified: tools/eclipse/trunk/plugins/org.scribble.pi4soa.cdm/META-INF/MANIFEST.MF
===================================================================
--- tools/eclipse/trunk/plugins/org.scribble.pi4soa.cdm/META-INF/MANIFEST.MF 2010-03-15
18:06:05 UTC (rev 196)
+++ tools/eclipse/trunk/plugins/org.scribble.pi4soa.cdm/META-INF/MANIFEST.MF 2010-03-15
23:03:53 UTC (rev 197)
@@ -19,7 +19,7 @@
org.eclipse.ui.views.properties.tabbed;resolution:=optional,
org.scribble.expression.xpath,
org.scribble.eclipse;resolution:=optional,
- org.scribble.contract.model;bundle-version="0.1.0"
+ org.scribble.contract.model
Scribble-Extensions: org.scribble.pi4soa.cdm.parser.CDMTokenizer,
org.scribble.pi4soa.cdm.parser.CDMModelParserRule,
org.scribble.pi4soa.cdm.model.CDMNotation,