Author: guixl
Date: Mon Jul 19 14:38:21 2010
New Revision: 965504

URL: http://svn.apache.org/viewvc?rev=965504&view=rev
Log:
start scxml document debug model job

Added:
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/debug/
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/debug/CommonsSCXMLEngine.java
   (with props)
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/icons/obj16/ScxmlCreateDebug.gif
   (with props)
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/debug/
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/debug/ModelingDocumentDebugWizard.java
   (with props)
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingNewDebugFileWizard.java
   (with props)
Modified:
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.properties
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.xml

Added: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/debug/CommonsSCXMLEngine.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/debug/CommonsSCXMLEngine.java?rev=965504&view=auto
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/debug/CommonsSCXMLEngine.java
 (added)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/debug/CommonsSCXMLEngine.java
 Mon Jul 19 14:38:21 2010
@@ -0,0 +1,63 @@
+package guixl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.scxml.SCXMLExecutor;
+import org.apache.commons.scxml.TriggerEvent;
+import org.apache.commons.scxml.env.SimpleDispatcher;
+import org.apache.commons.scxml.env.SimpleErrorReporter;
+import org.apache.commons.scxml.env.jexl.JexlContext;
+import org.apache.commons.scxml.env.jexl.JexlEvaluator;
+import org.apache.commons.scxml.io.SCXMLParser;
+import org.apache.commons.scxml.model.ModelException;
+import org.apache.commons.scxml.model.SCXML;
+import org.xml.sax.SAXException;
+
+public class HelloWorld {
+
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               List customActions = new ArrayList();
+        /*
+         * Add CustomAction implement class here
+         * 
+         * CustomAction ca = new 
CustomAction("http://my.custom-actions.domain/CUSTOM","hello";, Hello.class);
+         * customActions.add(ca);
+        */
+        SCXML scxml=null;
+        try {
+                       scxml =  
SCXMLParser.parse(HelloWorld.class.getClassLoader().
+                               getResource("guixl/hello-world.xml"), null, 
customActions);
+                       SCXMLExecutor engine = new SCXMLExecutor(new 
JexlEvaluator(), new SimpleDispatcher(),
+                           new SimpleErrorReporter());
+               engine.setStateMachine(scxml);
+               engine.setSuperStep(true);
+               engine.setRootContext(new JexlContext());
+               //engine.addListener(scxml, new Listener());
+               engine.go();
+               while(true){
+                       BufferedReader reader=new BufferedReader(new 
InputStreamReader(System.in));   
+                   System.out.print("Command input:");   
+                   String str;
+                               str = reader.readLine();
+                               if(str.trim().equals("exit")) break;
+                               else{
+                                       engine.triggerEvent(new 
TriggerEvent(str,TriggerEvent.SIGNAL_EVENT));
+                               }
+               }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               } catch (SAXException e) {
+                       e.printStackTrace();
+               } catch (ModelException e) {
+                       e.printStackTrace();
+               } 
+       }
+
+}

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

Added: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/icons/obj16/ScxmlCreateDebug.gif
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/icons/obj16/ScxmlCreateDebug.gif?rev=965504&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/icons/obj16/ScxmlCreateDebug.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Modified: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.properties
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.properties?rev=965504&r1=965503&r2=965504&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.properties
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.properties
 Mon Jul 19 14:38:21 2010
@@ -18,6 +18,9 @@ importWizardName=Import SCXML Document
 importWizardDesc=Creates Modeling diagram by importing SCXML document.
 SCXML=SCXML
 
+createDebugWizardName=Create Apache Commons SCXML Debug Runtime
+createDebugWizardDesc=Creates Apache Commons SCXML engine runtime.
+
 exportScxmlDocumentLabel=Export Scxml Document
 initDiagramActionLabel=Initialize modeling_diagram diagram file
 loadResourceActionLabel=Load Resource...

Modified: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.xml
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.xml?rev=965504&r1=965503&r2=965504&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.xml
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/plugin.xml
 Mon Jul 19 14:38:21 2010
@@ -45,8 +45,8 @@
    <extension point="org.eclipse.ui.newWizards">
       <?gmfgen generated="true"?>
       <category
-                  id = "org.apache.commons.scxml.modeling.import"
-                  name="%SCXML">
+            id="org.apache.commons.scxml.modeling.import"
+            name="%SCXML">
          </category>
          <wizard
             name="%newWizardName"
@@ -60,8 +60,8 @@
 <extension point="org.eclipse.ui.newWizards">
       <?gmfgen generated="true"?>
       <category
-                  id = "org.apache.commons.scxml.modeling.import"
-                  name="%SCXML">
+            id="org.apache.commons.scxml.modeling.import"
+            name="%SCXML">
          </category>
          <wizard
             name="%importWizardName"
@@ -71,8 +71,7 @@
             
id="org.apache.commons.scxml.modeling.diagram.part.ModelingImportWizardID">
                 <description>%importWizardDesc</description>  
       </wizard>
-   </extension>   
-   
+   </extension>
 
    <extension point="org.eclipse.ui.popupMenus">
       <?gmfgen generated="true"?>
@@ -122,6 +121,23 @@
          </action>
       </objectContribution>
       </extension>
+      
+      <extension point="org.eclipse.ui.popupMenus">
+   <objectContribution
+            objectClass="org.eclipse.core.resources.IFile"
+            nameFilter="*.modeling"
+            id="org.apache.commons.scxml.modeling.createDebug">
+         <action
+                  enablesFor="1"
+               label="%createDebugWizardName"
+               tooltip="%createDebugWizardDesc"
+               
class="org.apache.commons.scxml.modeling.debug.ModelingDocumentDebugWizard"
+               icon="icons/obj16/ScxmlCreateDebug.gif"
+               menubarPath="additions"
+               id="org.apache.commons.scxml.modeling.createDebugAction">
+         </action>
+      </objectContribution>
+      </extension>
        
    <extension 
point="org.eclipse.gmf.runtime.common.ui.services.action.globalActionHandlerProviders">
       <?gmfgen generated="true"?>
@@ -1210,4 +1226,4 @@
          schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
          sequence="F5"/>
    </extension>
-</plugin>
\ No newline at end of file
+</plugin>

Added: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/debug/ModelingDocumentDebugWizard.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/debug/ModelingDocumentDebugWizard.java?rev=965504&view=auto
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/debug/ModelingDocumentDebugWizard.java
 (added)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/debug/ModelingDocumentDebugWizard.java
 Mon Jul 19 14:38:21 2010
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.scxml.modeling.debug;
+
+import 
org.apache.commons.scxml.modeling.diagram.edit.parts.ServiceTemplateEditPart;
+import org.apache.commons.scxml.modeling.diagram.part.Messages;
+import 
org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorPlugin;
+import 
org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorUtil;
+import 
org.apache.commons.scxml.modeling.diagram.part.ModelingNewDebugFileWizard;
+import org.apache.commons.scxml.modeling.export.ModelingDocumentExportWizard;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Create Apache Commons SCXML debug runtime
+ */
+public class ModelingDocumentDebugWizard implements IObjectActionDelegate{
+       /**
+        * @generated
+        */
+       private IWorkbenchPart targetPart;
+
+       /**
+        * @generated
+        */
+       private URI domainModelURI;
+       
+       private IFile file;
+
+       /**
+        * @generated
+        */
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               this.targetPart = targetPart;
+       }
+
+       /**
+        * @generated
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               domainModelURI = null;
+               action.setEnabled(false);
+               if (selection instanceof IStructuredSelection == false
+                               || selection.isEmpty()) {
+                       return;
+               }
+               file = (IFile) ((IStructuredSelection) selection)
+                               .getFirstElement();             
+               
+               domainModelURI = 
URI.createPlatformResourceURI(file.getFullPath()
+                               .toString(), true);
+               action.setEnabled(true);
+       }
+
+       /**
+        * @generated
+        */
+       private Shell getShell() {
+               return targetPart.getSite().getShell();
+       }
+
+       /**
+        * @generated
+        */
+       public void run(IAction action) {
+               TransactionalEditingDomain editingDomain = 
GMFEditingDomainFactory.INSTANCE
+                               .createEditingDomain();
+               ResourceSet resourceSet = editingDomain.getResourceSet();
+               EObject diagramRoot = null;
+               try {
+                       Resource resource = 
resourceSet.getResource(domainModelURI, true);
+                       diagramRoot = (EObject) resource.getContents().get(0);
+               } catch (WrappedException ex) {
+                       ModelingDiagramEditorPlugin.getInstance().logError(
+                                       "Unable to load resource: " + 
domainModelURI, ex); //$NON-NLS-1$
+               }
+               if (diagramRoot == null) {
+                       MessageDialog
+                                       .openError(
+                                                       getShell(),
+                                                       
Messages.ModelingInitDiagramFileAction_InitDiagramFileResourceErrorDialogTitle,
+                                                       
Messages.ModelingInitDiagramFileAction_InitDiagramFileResourceErrorDialogMessage);
+                       return;
+               }
+               Wizard wizard = new 
ModelingNewDebugFileWizard(file,domainModelURI,
+                               diagramRoot, editingDomain);
+               wizard
+                               .setWindowTitle(NLS
+                                               .bind(
+                                                               
Messages.ModelingInitDiagramFileAction_ExportScxmlDocumentWizardTitle,
+                                                               
ServiceTemplateEditPart.MODEL_ID));
+               ModelingDiagramEditorUtil.runWizard(getShell(), wizard,
+                               "ExportScxmlDocument"); //$NON-NLS-1$
+       }
+}
+

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

Added: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingNewDebugFileWizard.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/ModelingNewDebugFileWizard.java?rev=965504&view=auto
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingNewDebugFileWizard.java
 (added)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingNewDebugFileWizard.java
 Mon Jul 19 14:38:21 2010
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml.modeling.diagram.part;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
+import java.util.List;
+
+import 
org.apache.commons.scxml.modeling.diagram.edit.parts.ServiceTemplateEditPart;
+import org.apache.commons.scxml.modeling.diagram.part.Messages;
+import 
org.apache.commons.scxml.modeling.diagram.part.ModelElementSelectionPage;
+import 
org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorPlugin;
+import 
org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorUtil;
+import org.apache.commons.scxml.modeling.diagram.part.ModelingVisualIDRegistry;
+import org.apache.commons.scxml.modeling.export.ScxmlExportStreamHandlerAction;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import 
org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * Apache Commons SCXML debug runtime wizard
+ *
+ */
+public class ModelingNewDebugFileWizard extends Wizard {
+
+       /**
+        * @generated
+        */
+       private WizardNewFileCreationPage myFileCreationPage;
+
+       /**
+        * @generated
+        */
+       private ModelElementSelectionPage diagramRootElementSelectionPage;
+
+       /**
+        * @generated
+        */
+       private TransactionalEditingDomain myEditingDomain;
+
+       /**
+        * model file
+        */
+       private IFile modelFile;
+
+       /**
+        * @generated
+        */
+       public ModelingNewDebugFileWizard(IFile file, URI domainModelURI,
+                       EObject diagramRoot, TransactionalEditingDomain 
editingDomain) {
+               modelFile = file;
+               assert domainModelURI != null : "Domain model uri must be 
specified"; //$NON-NLS-1$
+               assert diagramRoot != null : "Doagram root element must be 
specified"; //$NON-NLS-1$
+               assert editingDomain != null : "Editing domain must be 
specified"; //$NON-NLS-1$
+
+               myFileCreationPage = new WizardNewFileCreationPage(
+                               
Messages.ModelingNewScxmlFileWizard_CreationPageName,
+                               StructuredSelection.EMPTY);
+               myFileCreationPage
+                               
.setTitle(Messages.ModelingNewScxmlFileWizard_CreationPageTitle);
+               myFileCreationPage.setDescription(NLS.bind(
+                               
Messages.ModelingNewScxmlFileWizard_CreationPageDescription,
+                               ServiceTemplateEditPart.MODEL_ID));
+               IPath filePath;
+               String fileName = 
domainModelURI.trimFileExtension().lastSegment();
+               if (domainModelURI.isPlatformResource()) {
+                       filePath = new Path(domainModelURI.trimSegments(1)
+                                       .toPlatformString(true));
+               } else if (domainModelURI.isFile()) {
+                       filePath = new 
Path(domainModelURI.trimSegments(1).toFileString());
+               } else {
+                       throw new IllegalArgumentException(
+                                       "Unsupported URI: " + domainModelURI); 
//$NON-NLS-1$
+               }
+               myFileCreationPage.setContainerFullPath(filePath);
+               myFileCreationPage.setFileName(ModelingDiagramEditorUtil
+                               .getUniqueFileName(filePath, fileName, 
"java")); //$NON-NLS-1$
+
+               diagramRootElementSelectionPage = new 
DiagramRootElementSelectionPage(
+                               
Messages.ModelingNewScxmlFileWizard_RootSelectionPageName);
+               diagramRootElementSelectionPage
+                               
.setTitle(Messages.ModelingNewScxmlFileWizard_RootSelectionPageTitle);
+               diagramRootElementSelectionPage
+                               
.setDescription(Messages.ModelingNewScxmlFileWizard_RootSelectionPageDescription);
+               diagramRootElementSelectionPage.setModelElement(diagramRoot);
+
+               myEditingDomain = editingDomain;
+
+       }
+
+       /**
+        * 
+        * @param is
+        * @return change InputStream to String object
+        * @throws IOException
+        */
+       public static String inputStream2String(InputStream is) throws 
IOException {
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               int i = -1;
+               while ((i = is.read()) != -1) {
+                       baos.write(i);
+               }
+               return baos.toString();
+       }
+
+       /**
+        * @generated
+        */
+       public void addPages() {
+               addPage(myFileCreationPage);
+               addPage(diagramRootElementSelectionPage);
+       }
+
+       /**
+        * @generated
+        */
+       public boolean performFinish() {
+               try {
+                       List affectedFiles = new LinkedList();
+                       final IFile xmlFile = 
myFileCreationPage.createNewFile();
+                       affectedFiles.add(xmlFile);
+                       new ProgressMonitorDialog(null).run(true, false,
+                                       new 
ScxmlExportOperation(false,xmlFile));
+               } catch (InvocationTargetException e1) {
+                       e1.printStackTrace();
+               } catch (InterruptedException e1) {
+                       e1.printStackTrace();
+               }
+
+               return true;
+       }
+
+       class ScxmlExportOperation implements IRunnableWithProgress {
+
+               private boolean indeterminate;
+               private IFile debugClassFile;
+
+               /**
+                * LongRunningOperation constructor
+                * 
+                * @param indeterminate
+                *            whether the animation is unknown
+                */
+               public ScxmlExportOperation(boolean indeterminate,IFile file) {
+                       this.indeterminate = indeterminate;
+                       debugClassFile=file;
+               }
+               
+               public IFile getXmlFile() {
+                       return debugClassFile;
+               }
+
+               public void setXmlFile(IFile xmlFile) {
+                       this.debugClassFile = xmlFile;
+               }
+
+               /**
+                * Runs the long running operation
+                * 
+                * @param monitor
+                *            the progress monitor
+                */
+               public void run(IProgressMonitor monitor)
+                               throws InvocationTargetException, 
InterruptedException {
+
+                       int diagramVID = ModelingVisualIDRegistry
+                                       
.getDiagramVisualID(diagramRootElementSelectionPage
+                                                       .getModelElement());
+                       monitor.beginTask("SCXML document export progress",9);
+                       
+                       try {
+                               InputStream 
fileTemplate=this.getClass().getClassLoader().getResourceAsStream("debug/CommonsSCXMLEngine.java");
+                               monitor.worked(1);
+                               debugClassFile.setContents(fileTemplate, 1, 
null);
+                               monitor.worked(8);
+                               
+                               // get target list by regular expression
+                               /*ScxmlExportStreamHandlerAction shc = new 
ScxmlExportStreamHandlerAction(
+                                               modelFile.getContents());
+                               shc.contentPreHandler();
+                               monitor.worked(1);
+                               shc.getTargetList();
+                               monitor.worked(1);
+                               shc.transferToXpath();
+                               monitor.worked(1);
+                               shc.getIdMap(modelFile.getContents());
+                               monitor.worked(1);
+                               shc.updateTargetId();
+                               monitor.worked(1);
+                               System.out.println(shc.getStreamContnet());
+                               String content = 
shc.ExecuteXSL(shc.getStreamContnet(), this
+                                               
.getClass().getClassLoader().getResourceAsStream(
+                                                               
"xslt/export.xsl"));
+                               monitor.worked(1);
+                               
content=content.replace("xmlns_attribute_url_in_xslt_file", "xmlns");
+                               monitor.worked(1);
+                               
xmlFile.setContents(shc.string2InputStream(content), 1, null);
+                               monitor.worked(1);*/
+                               
+                               
+                               if (monitor.isCanceled()) throw new 
InterruptedException(
+                               "The SCXML document debug class creation 
operation was cancelled");
+                               
+                               monitor.done();
+                       } catch (CoreException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       /**
+        * @generated
+        */
+       private static class DiagramRootElementSelectionPage extends
+                       ModelElementSelectionPage {
+
+               /**
+                * @generated
+                */
+               protected DiagramRootElementSelectionPage(String pageName) {
+                       super(pageName);
+               }
+
+               /**
+                * @generated
+                */
+               protected String getSelectionTitle() {
+                       return 
Messages.ModelingNewScxmlFileWizard_RootSelectionPageSelectionTitle;
+               }
+
+               /**
+                * @generated
+                */
+               protected boolean validatePage() {
+                       if (selectedModelElement == null) {
+                               
setErrorMessage(Messages.ModelingNewScxmlFileWizard_RootSelectionPageNoSelectionMessage);
+                               return false;
+                       }
+                       boolean result = ViewService
+                                       .getInstance()
+                                       .provides(
+                                                       new 
CreateDiagramViewOperation(
+                                                                       new 
EObjectAdapter(selectedModelElement),
+                                                                       
ServiceTemplateEditPart.MODEL_ID,
+                                                                       
ModelingDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT));
+                       setErrorMessage(result ? null
+                                       : 
Messages.ModelingNewScxmlFileWizard_RootSelectionPageInvalidSelectionMessage);
+                       return result;
+               }
+       }
+}

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


Reply via email to