Author: guixl
Date: Fri Jun 25 08:48:25 2010
New Revision: 957846

URL: http://svn.apache.org/viewvc?rev=957846&view=rev
Log:
Finish state,parallel,onEntry,onExit and transition node transfer job for SCXML 
document import function

Added:
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/import.xsl
   (with props)
Modified:
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingImportWizard.java
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java

Modified: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingImportWizard.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingImportWizard.java?rev=957846&r1=957845&r2=957846&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingImportWizard.java
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingImportWizard.java
 Fri Jun 25 08:48:25 2010
@@ -212,20 +212,33 @@ public class ModelingImportWizard extend
                 */
                public void run(IProgressMonitor monitor)
                                throws InvocationTargetException, 
InterruptedException {
-                       monitor.beginTask("SCXML document export progress", 9);
+                       monitor.beginTask("SCXML document export progress", 13);
 
                        try {
-                               String content = documentImportSelectPage
-                                               .getImportSCXMLContent();
+                               ScxmlExportStreamHandlerAction shc = new 
ScxmlExportStreamHandlerAction();
+                               String documentContent = 
documentImportSelectPage.getImportSCXMLContent();
                                monitor.worked(1);
+                               
documentContent=documentContent.replace("xmlns=\"http://www.w3.org/2005/07/scxml\"";,
 "");
                                monitor.worked(1);
                                monitor.worked(1);
                                monitor.worked(1);
                                monitor.worked(1);
+                               System.out.println(documentContent);
+                               String content = 
shc.ExecuteXSL(documentContent, this
+                                               
.getClass().getClassLoader().getResourceAsStream(
+                                                               
"xslt/import.xsl"));
                                monitor.worked(1);
+                               
content=content.replace("CONSTANT_org.apache.commons.scxml_CONSTANT", 
"org.apache.commons.scxml:");
                                monitor.worked(1);
-                               xmlFile.setContents(new 
ScxmlExportStreamHandlerAction()
-                                               .string2InputStream(content), 
1, null);
+                               
content=content.replace("CONSTANT_xmi_version_CONSTANT", "xml:version");
+                               monitor.worked(1);
+                               
content=content.replace("CONSTANT_xmlns_xmi_CONSTANT", "xmlns:xmi");
+                               monitor.worked(1);
+                               
content=content.replace("CONSTANT_xmlns_xsi_CONSTANT", "xmlns:xsi");
+                               monitor.worked(1);
+                               
content=content.replace("CONSTANT_xmlns_org.apache.commons.scxml_CONSTANT", 
"xmlns:org.apache.commons.scxml");
+                               monitor.worked(1);
+                               
xmlFile.setContents(shc.string2InputStream(content), 1, null);
                                monitor.worked(1);
                                if (monitor.isCanceled())
                                        throw new InterruptedException(

Modified: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java?rev=957846&r1=957845&r2=957846&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
 Fri Jun 25 08:48:25 2010
@@ -179,7 +179,7 @@ public class ScxmlExportStreamHandlerAct
                        StreamResult result = new StreamResult(byteRep);
                        StreamSource style = new StreamSource(xslfile);
                        Transformer transformer = 
transformerFactory.newTransformer(style);
-                       
transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, 
"utf-8"); // \u8BBE\u7F6E\u7F16\u7801
+                       
transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, 
"UTF-8"); // \u8BBE\u7F6E\u7F16\u7801
                        transformer.transform(source, result);
                        return byteRep.toString();
                } catch (Exception e) {

Added: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/import.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/import.xsl?rev=957846&view=auto
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/import.xsl
 (added)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/import.xsl
 Fri Jun 25 08:48:25 2010
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+<xsl:output method="xml" encoding="utf-8"/>
+
+<xsl:template match="/">
+               <xsl:element 
name="CONSTANT_org.apache.commons.scxml_CONSTANTServiceTemplate">
+                       <xsl:attribute 
name="CONSTANT_xmi_version_CONSTANT">2.0</xsl:attribute>
+                       <xsl:attribute 
name="CONSTANT_xmlns_xmi_CONSTANT">http://www.omg.org/XMI</xsl:attribute>
+                       <xsl:attribute 
name="CONSTANT_xmlns_xsi_CONSTANT">http://www.w3.org/2001/XMLSchema-instance</xsl:attribute>
+                       <xsl:attribute 
name="CONSTANT_xmlns_org.apache.commons.scxml_CONSTANT">org.apache.commons.scxml</xsl:attribute>
+                       <xsl:attribute name="initial"><xsl:value-of 
select="scxml/@initial"/></xsl:attribute>
+                       <xsl:attribute name="name"><xsl:value-of 
select="scxml/@name"/></xsl:attribute>
+                       <xsl:attribute name="version">1.0</xsl:attribute>
+                       <xsl:attribute name="profile">profile</xsl:attribute>
+                       <xsl:apply-templates/>
+               </xsl:element>
+</xsl:template>
+
+<xsl:template match="state">
+       <xsl:element name="stateList">
+               <xsl:choose>
+               <xsl:when test="@id">
+                       <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               </xsl:when>
+               <xsl:otherwise>
+                       <xsl:attribute name="id"><xsl:value-of  
select="generate-id()"/></xsl:attribute>
+               </xsl:otherwise>
+               </xsl:choose>
+               <xsl:for-each select="*">
+                       <xsl:choose>
+                       <xsl:when test="name()='state'">
+                               <xsl:call-template name="subState" />
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:apply-templates/>
+                       </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:for-each>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="parallel">
+       <xsl:element name="parallel">
+               <xsl:if test="@id">
+                       <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               </xsl:if>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template name="subState">
+       <xsl:element name="subState">
+               <xsl:choose>
+               <xsl:when test="@id">
+                       <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               </xsl:when>
+               <xsl:otherwise>
+                       <xsl:attribute name="id"><xsl:value-of  
select="generate-id()"/></xsl:attribute>
+               </xsl:otherwise>
+               </xsl:choose>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="onEntry">
+       <xsl:element name="onEntry">
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="onExit">
+       <xsl:element name="onExit">
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="transition">
+       <xsl:element name="targetConnection">
+               <xsl:if test="@event">
+                       <xsl:attribute name="event"><xsl:value-of  
select="@event"/></xsl:attribute>
+               </xsl:if>
+               <xsl:if test="@cond">
+                       <xsl:attribute name="cond"><xsl:value-of  
select="@cond"/></xsl:attribute>
+               </xsl:if>
+               <xsl:attribute name="target"><xsl:value-of  
select="@target"/></xsl:attribute>
+       </xsl:element>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file

Propchange: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/import.xsl
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to