Author: Grid.Qian
Date: 2008-10-13 22:40:34 -0400 (Mon, 13 Oct 2008)
New Revision: 10817
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.classpath
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.project
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/org.eclipse.jdt.core.prefs
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/wizard/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/translate/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage$1.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$1.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$2.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$3.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage$1.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage$2.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ProFilter.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ProjectFilter.class
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/icons/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/icons/sample.gif
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/lib/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/lib/dom4j-1.6.1.jar
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.xml
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/translate/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.java
Log:
add bpmn -> jpdl plugin to trunk
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.classpath
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.classpath
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.classpath 2008-10-14 02:40:34 UTC
(rev 10817)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib" path="bin/"
sourcepath="src/org/jboss/tools/jbpm/convert/b2j/messages"/>
+ <classpathentry exported="true" kind="lib"
path="lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.project
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.project (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.project 2008-10-14 02:40:34 UTC (rev
10817)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.jbpm.convert</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/org.eclipse.jdt.core.prefs 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,7 @@
+#Wed Jul 23 02:43:33 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %PLUGIN_NAME
+Bundle-SymbolicName: org.jboss.tools.jbpm.convert.bpmnto;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Activator: org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.common;bundle-version="2.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ClassPath: .,
+ lib/dom4j-1.6.1.jar,
+ bin/
+Bundle-Vendor: %PLUGIN_PROVIDER
+Import-Package: org.eclipse.core.resources,
+ org.eclipse.ui.model
+Export-Package: org.jboss.tools.jbpm.convert.bpmnto,
+ org.jboss.tools.jbpm.convert.bpmnto.translate,
+ org.jboss.tools.jbpm.convert.bpmnto.util,
+ org.jboss.tools.jbpm.convert.bpmnto.wizard
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,78 @@
+Loop_Decision=Loop_Decition
+To=to
+Space=
+Underline=_
+Folder_Name_Separator=.
+Dom_Element_Name=name
+Dom_Element_ID=id
+Width_Attribute_Name=width
+Height_Attribute_Name=height
+X_Attribute_Name=x
+Y_Attribute_Name=y
+Label_Select_All=Select All
+Label_Deselect_All=Deselect All
+Label_Button_Browse=Browse...
+Bpmn_Diagram_Name_Suffix=_diagram
+Bpmn_Pool_Element_Name=pools
+Bpmn_Vertice_Element_Name=vertices
+Bpmn_SequenceFlow_Element_Name=sequenceEdges
+Bpmn_Href_Attribute_Name=href
+Bpmn_XmiType_Attribute_Name=type
+Bpmn_ActivityType_Attribute_Name=activityType
+Bpmn_InFlow_Attribute_Name=incomingEdges
+Bpmn_Looping_Attribute_Name=looping
+Bpmn_FlowSource_Attribute_Name=source
+Bpmn_FlowTarget_Attribute_Name=target
+Bpmn_FlowDefault_Attribute_Name=isDefault
+Bpmn_Element_ID=iD
+Bpmn_Wizard_Title=BPMN to jPDL Conversion
+Bpmn_File_Choose_WizardPage_Name=FileChoosePage
+Bpmn_File_Choose_WizardPage_Title=BPMN Resources
+Bpmn_File_Choose_WizardPage_ViewerTitle=BPMN resources
+Bpmn_File_Choose_WizardPage_Message=Select BPMN resources to convert
+Bpmn_Pool_Choose_WizardPage_Name=PoolPage
+Bpmn_Pool_Choose_WizardPage_Message=Available BPMN Pools
+Bpmn_Pool_Choose_WizardPage_Title=Select BPMN pools to translate
+Bpmn_GeneratedFile_Location_WizardPage_Name=LocationPage
+Bpmn_GeneratedFile_Location_WizardPage_Message=Select the target location
+Bpmn_GeneratedFile_Location_WizardPage_Title=Target Location
+Bpmn_GeneratedFile_Location_WizardPage_ViewerTitle=Target location
+Bpmn_GeneratedFile_Location_WizardPage_CheckBox=Overwrite existing resources
+Bpmn_Translate_Message_WizardPage_Name=MessagePage
+Bpmn_Translate_Message_WizardPage_Title=Conversion Warnings and Errors
+Bpmn_Translate_Message_WizardPage_Message=Warnings and Errors that occured during
conversion
+Bpmn_Translate_Message_WizardpageViewer_Title=Warnings and Errors
+Bpmn_EAnnotations_Element_Name=eAnnotations
+Bpmn_Details_Element_Name=details
+Bpmn_Value_Attribute_Name=value
+Jpdl_Suffix=jpdl
+Jpdl_Element_Decision_Suffix=Decision
+Jpdl_Element_Complete_Suffix=Complete
+Jpdl_Element_Cancel_Suffix=Cancel
+Jpdl_Element_Successful_Name=Successful?
+Jpdl_Process_Definition_Name=processdefinition.xml
+Jpdl_32_Namespace_Url=urn:jbpm.org:jpdl-3.2
+Jpdl_Process_Definition_Element_Name=process-definition
+Jpdl_Transition_Element=transition
+Jpdl_ProcessState_Element_Name=process-state
+Jpdl_SubProcess_Element_Name=sub-process
+Jpdl_Decision_Element_Name=decision
+Jpdl_Fork_Element_Name=fork
+Jpdl_Join_Element_Name=join
+Jpdl_Start_Element_Name=start-state
+Jpdl_State_Element_Name=state
+Jpdl_End_Element_Name=end-state
+Jpdl_Node_Element_Name=node
+Gpd_Definition_Name=gpd.xml
+Gpd_Layout_Element_Name=layoutConstraint
+Gpd_Element_Name=element
+Gpd_Process_Diagram_Name=process-diagram
+Gpd_Label_Element_Name=label
+Translate_Error_GpdFile_CanNotGenerate=Errror: Couldn't write gpd.xml:
+Translate_Error_GpdFile_CanNotWrite=Errror: Couldn't write gpd definition to a
gpd.xml:
+Translate_Error_JpdlProcess_Definition_Null=Errror: The JPDL process definition is null.
+Translate_Error_JpdlFile_CanNotGenerate=Errror: Couldn't write process definition
xml:
+Translate_Error_JpdlFile_CanNotWrite=Errror: Couldn't write process definition to a
jpdl file:
+Translate_Error_File_CanNotRead=Error: Couldn't read or parse {0} file to a DOM
document:
+Translate_Warning_Bpmn_Element_Name=Warning: The bpmn element's name is null or same
to another element's name:
+Translate_Warning_Bpmn_Element_Type=Warning: The type of this bpmn element is not
translated to corresponding jpdl element:
\ No newline at end of file
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage$1.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$1.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$2.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$2.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$3.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage$3.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage$1.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage$2.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage$2.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ProFilter.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ProFilter.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ProjectFilter.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/bin/org/jboss/tools/jbpm/convert/bpmnto/wizard/ProjectFilter.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties 2008-10-14 02:40:34
UTC (rev 10817)
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ lib/dom4j-1.6.1.jar,\
+ bin/
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/icons/sample.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/icons/sample.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/lib/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/lib/dom4j-1.6.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.properties
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.properties 2008-10-14 02:40:34
UTC (rev 10817)
@@ -0,0 +1,5 @@
+wizard.name=BPMN -> JPDL
+wizard.description = Export a BPMN file to JPDL
+category.name=BPMN Export
+PLUGIN_NAME=BPMNExport
+PLUGIN_PROVIDER=Red Hat, Inc.
\ No newline at end of file
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.xml
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/plugin.xml 2008-10-14 02:40:34 UTC
(rev 10817)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.ui.exportWizards">
+ <category name="%category.name"
+ id="org.jboss.tools.jbpm.convert.export.category"/>
+ <wizard name="%wizard.name"
+ icon="icons/sample.gif"
+ category="org.jboss.tools.jbpm.convert.export.category"
+
class="org.jboss.tools.jbpm.convert.b2j.wizard.B2JExportWizard"
+ id="org.jboss.tools.jbpm.convert.export.b2jexportwizard">
+ <description>%wizard.description</description>
+ <selection name="*.bpmn"
class="org.eclipse.core.resources.IFile"/>
+ </wizard>
+ </extension>
+
+</plugin>
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,78 @@
+Loop_Decision=Loop_Decition
+To=to
+Space=
+Underline=_
+Folder_Name_Separator=.
+Dom_Element_Name=name
+Dom_Element_ID=id
+Width_Attribute_Name=width
+Height_Attribute_Name=height
+X_Attribute_Name=x
+Y_Attribute_Name=y
+Label_Select_All=Select All
+Label_Deselect_All=Deselect All
+Label_Button_Browse=Browse...
+Bpmn_Diagram_Name_Suffix=_diagram
+Bpmn_Pool_Element_Name=pools
+Bpmn_Vertice_Element_Name=vertices
+Bpmn_SequenceFlow_Element_Name=sequenceEdges
+Bpmn_Href_Attribute_Name=href
+Bpmn_XmiType_Attribute_Name=type
+Bpmn_ActivityType_Attribute_Name=activityType
+Bpmn_InFlow_Attribute_Name=incomingEdges
+Bpmn_Looping_Attribute_Name=looping
+Bpmn_FlowSource_Attribute_Name=source
+Bpmn_FlowTarget_Attribute_Name=target
+Bpmn_FlowDefault_Attribute_Name=isDefault
+Bpmn_Element_ID=iD
+Bpmn_Wizard_Title=BPMN to jPDL Conversion
+Bpmn_File_Choose_WizardPage_Name=FileChoosePage
+Bpmn_File_Choose_WizardPage_Title=BPMN Resources
+Bpmn_File_Choose_WizardPage_ViewerTitle=BPMN resources
+Bpmn_File_Choose_WizardPage_Message=Select BPMN resources to convert
+Bpmn_Pool_Choose_WizardPage_Name=PoolPage
+Bpmn_Pool_Choose_WizardPage_Message=Available BPMN Pools
+Bpmn_Pool_Choose_WizardPage_Title=Select BPMN pools to translate
+Bpmn_GeneratedFile_Location_WizardPage_Name=LocationPage
+Bpmn_GeneratedFile_Location_WizardPage_Message=Select the target location
+Bpmn_GeneratedFile_Location_WizardPage_Title=Target Location
+Bpmn_GeneratedFile_Location_WizardPage_ViewerTitle=Target location
+Bpmn_GeneratedFile_Location_WizardPage_CheckBox=Overwrite existing resources
+Bpmn_Translate_Message_WizardPage_Name=MessagePage
+Bpmn_Translate_Message_WizardPage_Title=Conversion Warnings and Errors
+Bpmn_Translate_Message_WizardPage_Message=Warnings and Errors that occured during
conversion
+Bpmn_Translate_Message_WizardpageViewer_Title=Warnings and Errors
+Bpmn_EAnnotations_Element_Name=eAnnotations
+Bpmn_Details_Element_Name=details
+Bpmn_Value_Attribute_Name=value
+Jpdl_Suffix=jpdl
+Jpdl_Element_Decision_Suffix=Decision
+Jpdl_Element_Complete_Suffix=Complete
+Jpdl_Element_Cancel_Suffix=Cancel
+Jpdl_Element_Successful_Name=Successful?
+Jpdl_Process_Definition_Name=processdefinition.xml
+Jpdl_32_Namespace_Url=urn:jbpm.org:jpdl-3.2
+Jpdl_Process_Definition_Element_Name=process-definition
+Jpdl_Transition_Element=transition
+Jpdl_ProcessState_Element_Name=process-state
+Jpdl_SubProcess_Element_Name=sub-process
+Jpdl_Decision_Element_Name=decision
+Jpdl_Fork_Element_Name=fork
+Jpdl_Join_Element_Name=join
+Jpdl_Start_Element_Name=start-state
+Jpdl_State_Element_Name=state
+Jpdl_End_Element_Name=end-state
+Jpdl_Node_Element_Name=node
+Gpd_Definition_Name=gpd.xml
+Gpd_Layout_Element_Name=layoutConstraint
+Gpd_Element_Name=element
+Gpd_Process_Diagram_Name=process-diagram
+Gpd_Label_Element_Name=label
+Translate_Error_GpdFile_CanNotGenerate=Errror: Couldn't write gpd.xml:
+Translate_Error_GpdFile_CanNotWrite=Errror: Couldn't write gpd definition to a
gpd.xml:
+Translate_Error_JpdlProcess_Definition_Null=Errror: The JPDL process definition is null.
+Translate_Error_JpdlFile_CanNotGenerate=Errror: Couldn't write process definition
xml:
+Translate_Error_JpdlFile_CanNotWrite=Errror: Couldn't write process definition to a
jpdl file:
+Translate_Error_File_CanNotRead=Error: Couldn't read or parse {0} file to a DOM
document:
+Translate_Warning_Bpmn_Element_Name=Warning: The bpmn element's name is null or same
to another element's name:
+Translate_Warning_Bpmn_Element_Type=Warning: The type of this bpmn element is not
translated to corresponding jpdl element:
\ No newline at end of file
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.b2j.messages;
+
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class B2JMessages {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.jbpm.convert.b2j.messages.B2J"; //$NON-NLS-1$
+
+ private B2JMessages() {
+ // Do not instantiate
+ }
+
+ public static String Loop_Decision;
+ public static String To;
+ public static String Folder_Name_Separator;
+ public static String Space;
+ public static String Underline;
+ public static String Width_Attribute_Name;
+ public static String Height_Attribute_Name;
+ public static String X_Attribute_Name;
+ public static String Y_Attribute_Name;
+ public static String Label_Select_All;
+ public static String Label_Deselect_All;
+ public static String Label_Button_Browse;
+ public static String Bpmn_Diagram_Name_Suffix;
+ public static String Bpmn_Pool_Element_Name;
+ public static String Bpmn_Element_ID;
+ public static String Bpmn_Vertice_Element_Name;
+ public static String Bpmn_SequenceFlow_Element_Name;
+ public static String Bpmn_Looping_Attribute_Name;
+ public static String Bpmn_InFlow_Attribute_Name;
+ public static String Bpmn_XmiType_Attribute_Name;
+ public static String Bpmn_Href_Attribute_Name;
+ public static String Bpmn_ActivityType_Attribute_Name;
+ public static String Bpmn_FlowSource_Attribute_Name;
+ public static String Bpmn_FlowTarget_Attribute_Name;
+ public static String Bpmn_FlowDefault_Attribute_Name;
+ public static String Bpmn_Wizard_Title;
+ public static String Bpmn_File_Choose_WizardPage_Name;
+ public static String Bpmn_File_Choose_WizardPage_Title;
+ public static String Bpmn_File_Choose_WizardPage_Message;
+ public static String Bpmn_File_Choose_WizardPage_ViewerTitle;
+ public static String Bpmn_Pool_Choose_WizardPage_Name;
+ public static String Bpmn_Pool_Choose_WizardPage_Message;
+ public static String Bpmn_Pool_Choose_WizardPage_Title;
+ public static String Bpmn_GeneratedFile_Location_WizardPage_Name;
+ public static String Bpmn_GeneratedFile_Location_WizardPage_Message;
+ public static String Bpmn_GeneratedFile_Location_WizardPage_Title;
+ public static String Bpmn_GeneratedFile_Location_WizardPage_ViewerTitle;
+ public static String Bpmn_GeneratedFile_Location_WizardPage_CheckBox;
+ public static String Bpmn_Translate_Message_WizardPage_Name;
+ public static String Bpmn_Translate_Message_WizardPage_Title;
+ public static String Bpmn_Translate_Message_WizardPage_Message;
+ public static String Bpmn_Translate_Message_WizardpageViewer_Title;
+ public static String Bpmn_EAnnotations_Element_Name;
+ public static String Bpmn_Details_Element_Name;
+ public static String Bpmn_Value_Attribute_Name;
+ public static String Jpdl_Element_Decision_Suffix;
+ public static String Jpdl_Element_Complete_Suffix;
+ public static String Jpdl_Element_Cancel_Suffix;
+ public static String Jpdl_Element_Successful_Name;
+ public static String Jpdl_Suffix;
+ public static String Jpdl_Process_Definition_Name;
+ public static String Jpdl_ProcessState_Element_Name;
+ public static String Jpdl_SubProcess_Element_Name;
+ public static String Jpdl_32_Namespace_Url;
+ public static String Jpdl_Process_Definition_Element_Name;
+ public static String Jpdl_Transition_Element;
+ public static String Jpdl_Decision_Element_Name;
+ public static String Jpdl_Fork_Element_Name;
+ public static String Jpdl_Join_Element_Name;
+ public static String Jpdl_Start_Element_Name;
+ public static String Jpdl_State_Element_Name;
+ public static String Jpdl_End_Element_Name;
+ public static String Jpdl_Node_Element_Name;
+ public static String Gpd_Definition_Name;
+ public static String Gpd_Layout_Element_Name;
+ public static String Gpd_Element_Name;
+ public static String Gpd_Process_Diagram_Name;
+ public static String Gpd_Label_Element_Name;
+ public static String Dom_Element_Name;
+ public static String Dom_Element_ID;
+ public static String Translate_Error_JpdlProcess_Definition_Null;
+ public static String Translate_Error_JpdlFile_CanNotWrite;
+ public static String Translate_Error_JpdlFile_CanNotGenerate;
+ public static String Translate_Error_GpdFile_CanNotGenerate;
+ public static String Translate_Error_GpdFile_CanNotWrite;
+ public static String Translate_Error_File_CanNotRead;
+ public static String Translate_Warning_Bpmn_Element_Name;
+ public static String Translate_Warning_Bpmn_Element_Type;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, B2JMessages.class);
+ }
+}
\ No newline at end of file
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,466 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.b2j.translate;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
+import org.jboss.tools.jbpm.convert.bpmnto.translate.BPMNTranslator;
+import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
+
+/**
+ * @author Grid Qian
+ *
+ * this is a translator for bpmn ->jpdl
+ */
+public class BPMN2JPDL extends BPMNTranslator {
+
+ Document bpmnDocument;
+ List<Document> processDefs = new ArrayList<Document>();
+
+ Map<String, Element> map = new HashMap<String, Element>();
+
+ public Map<String, Element> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, Element> map) {
+ this.map = map;
+ }
+
+ public BPMN2JPDL() {
+ }
+
+ public BPMN2JPDL(String bpmnFileName, String bpmnFilePath,
+ Document bpmnDocument) {
+ this(bpmnFileName, bpmnFilePath, null, bpmnDocument);
+ }
+
+ public BPMN2JPDL(String bpmnFileName, String bpmnFilePath,
+ List<String> poolIDList, Document bpmnDocument) {
+ super(bpmnFileName, bpmnFilePath, poolIDList);
+ this.bpmnDocument = bpmnDocument;
+ }
+
+ /*
+ * Translate a bpmn diagram to string[]. Every string is jpdl process
+ * definition
+ */
+ public String[] translateToStrings() {
+ this.translateDiagram();
+ String[] strForProcessDefs = new String[processDefs.size()];
+ int i = 0;
+ for (Document def : processDefs) {
+ try {
+ strForProcessDefs[i] = DomXmlWriter.toString(def);
+ } catch (IOException e) {
+ this.errors
+ .add(B2JMessages.Translate_Error_JpdlFile_CanNotGenerate
+ + e.getMessage());
+ }
+ i++;
+ }
+
+ return strForProcessDefs;
+ }
+
+ /*
+ * Translate a bpmn diagram to file[]. Every file is a jpdl file
+ */
+ public void translateToFiles(String fileLocation) {
+ String[] strForProcessDefs = translateToStrings();
+ String[] jpdlFileNames = new String[processDefs.size()];
+
+ int i = 0;
+ for (Document def : processDefs) {
+ jpdlFileNames[i] = def.getName();
+ i++;
+ }
+
+ try {
+ TranslateHelper.createFiles(fileLocation, bpmnFileName,
+ strForProcessDefs, jpdlFileNames,
+ B2JMessages.Jpdl_Process_Definition_Name, false);
+ } catch (Exception e) {
+ errors.add(B2JMessages.Translate_Error_JpdlFile_CanNotWrite
+ + e.getMessage());
+ }
+
+ if (errors.size() != 0) {
+ for (String str : errors) {
+ BpmnToPlugin.getDefault().logError(str);
+ }
+ }
+
+ if (warnings.size() != 0) {
+ for (String str : warnings) {
+ BpmnToPlugin.getDefault().logWarning(str);
+ }
+ }
+ }
+
+ /*
+ * Translate a bpmn diagram Domument tree to some jpdl process Dom trees
+ */
+ public void translateDiagram() {
+
+ // set the namemap = null
+ TranslateHelper.setNameMap(new HashMap<String, Integer>());
+
+ Element diagram = bpmnDocument.getRootElement();
+ if (this.poolIDList == null || this.poolIDList.size() == 0) {
+ for (Object pool : diagram
+ .elements(B2JMessages.Bpmn_Pool_Element_Name)) {
+ translateGraph((Element) pool);
+ }
+ } else {
+ for (Object pool : diagram
+ .elements(B2JMessages.Bpmn_Pool_Element_Name)) {
+ if (this.poolIDList.contains(((Element) pool)
+ .attributeValue(B2JMessages.Bpmn_Element_ID))) {
+ translateGraph((Element) pool);
+ }
+ }
+ }
+ }
+
+ /*
+ * Translate a bpmn pool or subprocess to a jpdl process Dom tree
+ */
+ private Element translateGraph(Element graph) {
+ Document processDef = TranslateHelper.createJpdlDomTree(true);
+ Element processRoot = processDef.getRootElement();
+
+ DomXmlWriter.addAttribute(processRoot, B2JMessages.Dom_Element_Name,
+ TranslateHelper.generateProcessName(graph));
+ processDef.setName(processRoot
+ .attributeValue(B2JMessages.Dom_Element_Name));
+
+ map.put(graph.attributeValue(B2JMessages.Dom_Element_ID)
+ + B2JMessages.Bpmn_Pool_Element_Name, processRoot);
+
+ for (Object activity : graph.elements()) {
+ if (B2JMessages.Bpmn_Vertice_Element_Name
+ .equals(((Element) activity).getName())) {
+ translateActivity(((Element) activity), processRoot);
+ }
+ }
+ translateSequenceFlows(graph, processRoot);
+ processDefs.add(processDef);
+
+ return processRoot;
+ }
+
+ /*
+ * Translate a bpmn activity to a jpdl node according to activity type
+ */
+ private void translateActivity(Element activity, Element processRoot) {
+ String type = activity
+ .attributeValue(B2JMessages.Bpmn_XmiType_Attribute_Name);
+ Element element = null;
+
+ // According to bpmn activity type, map to different jpdl node
+ // Some type can not be supported by this translation, we give
+ // a warining message for it.
+ if ("bpmn:Activity".equals(type)) {
+ String activityType = activity
+ .attributeValue(B2JMessages.Bpmn_ActivityType_Attribute_Name);
+ if (activityType == null || "Task".equals(activityType)) {
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Node_Element_Name);
+ } else if ("EventStartEmpty".equals(activityType)
+ || "EventStartMessage".equals(activityType)
+ || "EventStartRule".equals(activityType)
+ || "EventStartTimer".equals(activityType)
+ || "EventStartLink".equals(activityType)
+ || "EventStartMultiple".equals(activityType)
+ || "EventStartSignal".equals(activityType)) {
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Start_Element_Name);
+ if (!"EventStartEmpty".equals(activityType)) {
+ warnings
+ .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + activityType);
+ }
+ } else if ("EventIntermediateEmpty".equals(activityType)
+ || "EventIntermediateMessage".equals(activityType)
+ || "EventIntermediateTimer".equals(activityType)
+ || "EventIntermediateError".equals(activityType)
+ || "EventIntermediateCompensation".equals(activityType)
+ || "EventIntermediateRule".equals(activityType)
+ || "EventIntermediateMultiple".equals(activityType)
+ || "EventIntermediateCancel".equals(activityType)
+ || "EventIntermediateLink".equals(activityType)
+ || "EventIntermediateSignal".equals(activityType)) {
+
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_State_Element_Name);
+ if (!"EventIntermediateEmpty".equals(activityType)) {
+ warnings
+ .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + activityType);
+ }
+ } else if ("EventEndEmpty".equals(activityType)
+ || "EventEndMessage".equals(activityType)
+ || "EventEndError".equals(activityType)
+ || "EventEndCompensation".equals(activityType)
+ || "EventEndTerminate".equals(activityType)
+ || "EventEndLink".equals(activityType)
+ || "EventEndMultiple".equals(activityType)
+ || "EventEndCancel".equals(activityType)
+ || "EventEndSignal".equals(activityType)) {
+
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_End_Element_Name);
+ if (!"EventEndEmpty".equals(activityType)) {
+ warnings
+ .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + activityType);
+ }
+ } else if ("GatewayDataBasedExclusive".equals(activityType)
+ || "GatewayEventBasedExclusive".equals(activityType)
+ || "GatewayComplex".equals(activityType)) {
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Decision_Element_Name);
+ if (!"GatewayDataBasedExclusive".equals(activityType)) {
+ warnings
+ .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + activityType);
+ }
+ } else if ("GatewayParallel".equals(activityType)
+ || "GatewayDataBasedInclusive".equals(activityType)) {
+ if (activity
+ .attributeValue(B2JMessages.Bpmn_InFlow_Attribute_Name) == null
+ || activity.attributeValue(
+ B2JMessages.Bpmn_InFlow_Attribute_Name).split(
+ B2JMessages.Space).length == 1) {
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Fork_Element_Name);
+ } else {
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Join_Element_Name);
+ }
+ if (!"GatewayDataBasedInclusive".equals(activityType)) {
+ warnings
+ .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + activityType);
+ }
+ }
+ } else if ("bpmn:SubProcess".equals(type)) {
+ element = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_ProcessState_Element_Name);
+ translateSubprocess(activity, element);
+ }
+
+ if (!TranslateHelper.check_mapElementName(activity, element)) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Name
+ + activity.attributeValue(B2JMessages.Bpmn_Element_ID));
+ }
+ map.put(activity.attributeValue(B2JMessages.Dom_Element_ID), element);
+
+ // If bpmn activity is loop type, then create a structure to mock it.
+ if ("true".equals(activity
+ .attributeValue(B2JMessages.Bpmn_Looping_Attribute_Name))) {
+ createMockLoop(activity, element);
+ }
+ }
+
+ /*
+ * Translate a bpmn subprocess to a jpdl processstate and a new jpdl process
+ * difinition
+ */
+ private void translateSubprocess(Element subProcess, Element element) {
+ Element processRoot = translateGraph(subProcess);
+ Element ele = DomXmlWriter.addElement(element,
+ B2JMessages.Jpdl_SubProcess_Element_Name);
+ DomXmlWriter.mapAttribute(ele, B2JMessages.Dom_Element_Name,
+ processRoot);
+
+ // translate the transaction of subprocess
+ Element eAnnot = subProcess
+ .element(B2JMessages.Bpmn_EAnnotations_Element_Name);
+ if (eAnnot != null) {
+ Element details = eAnnot
+ .element(B2JMessages.Bpmn_Details_Element_Name);
+ if (details != null
+ && "true"
+ .equals(details
+ .attributeValue(B2JMessages.Bpmn_Value_Attribute_Name))) {
+ translateTransaction(processRoot);
+ }
+ }
+ }
+
+ /*
+ * translate a transaction of sub process
+ */
+ private void translateTransaction(Element processRoot) {
+ List<Element> lastEleList = TranslateHelper.locateLastElements(processRoot);
+
+ if (lastEleList.size() == 0) {
+ return;
+ }
+ // create a decision
+ Element decision = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Decision_Element_Name);
+
+ DomXmlWriter.addAttribute(decision, B2JMessages.Dom_Element_Name,
+ B2JMessages.Jpdl_Element_Successful_Name);
+ // get bpmn id from map
+ String bpmnId = null;
+ for (String key : map.keySet()) {
+ if (map.get(key) == lastEleList.get(0)) {
+ bpmnId = key;
+ break;
+ }
+ }
+ map.put(bpmnId + B2JMessages.Jpdl_Element_Decision_Suffix, decision);
+
+ // create a transition from element to decision
+ for (Element ele : lastEleList) {
+ Element transition = DomXmlWriter.addElement(ele,
+ B2JMessages.Jpdl_Transition_Element);
+ transition.addAttribute(B2JMessages.Dom_Element_Name, ele
+ .attributeValue(B2JMessages.Dom_Element_Name)
+ + B2JMessages.To + B2JMessages.Jpdl_Decision_Element_Name);
+ transition.addAttribute(B2JMessages.To, decision
+ .attributeValue(B2JMessages.Dom_Element_Name));
+ }
+
+ // create a complete element
+ Element complete = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Node_Element_Name);
+ DomXmlWriter.addAttribute(complete, B2JMessages.Dom_Element_Name,
+ B2JMessages.Jpdl_Element_Complete_Suffix);
+ map.put(bpmnId + B2JMessages.Jpdl_Element_Complete_Suffix, complete);
+
+ // create a cancel element
+ Element cancel = DomXmlWriter.addElement(processRoot,
+ B2JMessages.Jpdl_Node_Element_Name);
+ DomXmlWriter.addAttribute(cancel, B2JMessages.Dom_Element_Name,
+ B2JMessages.Jpdl_Element_Cancel_Suffix);
+ map.put(bpmnId + B2JMessages.Jpdl_Element_Cancel_Suffix, cancel);
+
+ // create transition from decision to complete element
+ Element toComplete = DomXmlWriter.addElement(decision,
+ B2JMessages.Jpdl_Transition_Element);
+ toComplete.addAttribute(B2JMessages.Dom_Element_Name, "true");
+ toComplete.addAttribute(B2JMessages.To, complete
+ .attributeValue(B2JMessages.Dom_Element_Name));
+
+ // create transition from decision to cancel element
+ Element toCancel = DomXmlWriter.addElement(decision,
+ B2JMessages.Jpdl_Transition_Element);
+ toCancel.addAttribute(B2JMessages.Dom_Element_Name, "false");
+ toCancel.addAttribute(B2JMessages.To, cancel
+ .attributeValue(B2JMessages.Dom_Element_Name));
+ }
+
+
+ /*
+ * Translate bpmn sequenceflows to jpdl transitions
+ */
+ private void translateSequenceFlows(Element graph, Element processRoot) {
+ for (Object edge : graph
+ .elements(B2JMessages.Bpmn_SequenceFlow_Element_Name)) {
+ translateSequenceFlow((Element) edge, processRoot);
+ }
+ }
+
+ /*
+ * Translate a bpmn sequenceflow to a jpdl transition
+ */
+ private void translateSequenceFlow(Element edge, Element processRoot) {
+
+ Element source = map.get(edge
+ .attributeValue(B2JMessages.Bpmn_FlowSource_Attribute_Name));
+
+ Element transition = null;
+ if ("true".equals(edge
+ .attributeValue(B2JMessages.Bpmn_FlowDefault_Attribute_Name))
+ && source.element(B2JMessages.Jpdl_Transition_Element) != null) {
+ // move default transition to the first of transition list
+ transition = DomXmlWriter.addElement(source,
+ B2JMessages.Jpdl_Transition_Element, 0);
+ } else {
+ transition = DomXmlWriter.addElement(source,
+ B2JMessages.Jpdl_Transition_Element);
+ }
+
+ if (!TranslateHelper.check_mapElementName(edge, transition)) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Name
+ + edge.attributeValue(B2JMessages.Bpmn_Element_ID));
+ }
+ transition
+ .addAttribute(
+ B2JMessages.To,
+ map
+ .get(
+ edge
+ .attributeValue(B2JMessages.Bpmn_FlowTarget_Attribute_Name))
+ .attributeValue(B2JMessages.Dom_Element_Name));
+ }
+
+ /*
+ * create a jpdl decision structure to map bpmn loop activity
+ */
+ private void createMockLoop(Element activity, Element element) {
+
+ // create a decision
+ Element decision = DomXmlWriter.addElement(element.getParent(),
+ B2JMessages.Jpdl_Decision_Element_Name);
+ String name = activity.attributeValue(B2JMessages.Dom_Element_Name)
+ + B2JMessages.Underline + B2JMessages.Loop_Decision;
+ DomXmlWriter.addAttribute(decision, B2JMessages.Dom_Element_Name, name);
+
+ // use the decision to replace the activity in the map
+ map.put(activity.attributeValue(B2JMessages.Dom_Element_ID), decision);
+ // add the activity to map
+ map.put(activity.attributeValue(B2JMessages.Dom_Element_ID)
+ + B2JMessages.Bpmn_Vertice_Element_Name, element);
+
+ // create a transition from element to decision
+ Element first = DomXmlWriter.addElement(element,
+ B2JMessages.Jpdl_Transition_Element);
+ first.addAttribute(B2JMessages.Dom_Element_Name, B2JMessages.To
+ + B2JMessages.Underline + name);
+ first.addAttribute(B2JMessages.To, decision
+ .attributeValue(B2JMessages.Dom_Element_Name));
+
+ // create a transition from decision to element
+ Element second = DomXmlWriter.addElement(decision,
+ B2JMessages.Jpdl_Transition_Element);
+ second.addAttribute(B2JMessages.Dom_Element_Name, B2JMessages.To
+ + B2JMessages.Underline
+ + element.attributeValue(B2JMessages.Dom_Element_Name));
+ second.addAttribute(B2JMessages.To, element
+ .attributeValue(B2JMessages.Dom_Element_Name));
+
+ }
+
+ public List<Document> getProcessDefs() {
+ return processDefs;
+ }
+
+ public void setProcessDefs(List<Document> processDefs) {
+ this.processDefs = processDefs;
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.b2j.translate;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
+import org.jboss.tools.jbpm.convert.bpmnto.translate.BPMNTranslator;
+import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
+
+/**
+ * @author Grid Qian
+ *
+ * this is a translator for bpmn_diagram to gpd of jpdl
+ */
+public class GraphicalFileGenerator extends BPMNTranslator {
+
+ Document document;
+
+ // gpd.xml documents list
+ List<Document> gpdDefs = new ArrayList<Document>();
+
+ // the pool of gpd.xml name
+ List<String> gpdPoolNames = new ArrayList<String>();
+ Map<String, Element> map = new HashMap<String, Element>();
+
+ public GraphicalFileGenerator(Document bpmnDiagramDocument,
+ Map<String, Element> map, String rootLocation, String bpmnFileName) {
+ this.rootLocation = rootLocation;
+ this.bpmnFileName = bpmnFileName;
+ this.document = bpmnDiagramDocument;
+ this.map = map;
+ }
+
+ /*
+ * translate a bpmn_diagram document to a gpd document string
+ */
+ public String[] translateToStrings() {
+ this.translateDiagram();
+ String[] strForProcessDefs = new String[gpdDefs.size()];
+ int i = 0;
+ for (Document def : gpdDefs) {
+ try {
+ strForProcessDefs[i] = DomXmlWriter.toString(def);
+ } catch (IOException e) {
+ this.errors
+ .add(B2JMessages.Translate_Error_GpdFile_CanNotGenerate
+ + e.getMessage());
+ }
+ i++;
+ }
+ return strForProcessDefs;
+ }
+
+ /*
+ * translate every gpd document string to a gpd file
+ */
+ public void translateToFiles(String fileLocation) {
+ String[] strForGpdDefs = translateToStrings();
+ String[] gpdFileNames = new String[gpdDefs.size()];
+ int i = 0;
+ for (Document def : gpdDefs) {
+ gpdFileNames[i] = def.getRootElement().attributeValue(
+ B2JMessages.Dom_Element_Name);
+ i++;
+ }
+
+ try {
+ TranslateHelper.createFiles(fileLocation, bpmnFileName,
+ strForGpdDefs, gpdFileNames,
+ B2JMessages.Gpd_Definition_Name, false);
+ } catch (Exception e) {
+ errors.add(B2JMessages.Translate_Error_GpdFile_CanNotWrite
+ + e.getMessage());
+ }
+
+ if (errors.size() != 0) {
+ for (String str : errors) {
+ BpmnToPlugin.getDefault().logError(str);
+ }
+ }
+
+ if (warnings.size() != 0) {
+ for (String str : warnings) {
+ BpmnToPlugin.getDefault().logWarning(str);
+ }
+ }
+ }
+
+ /*
+ * translate the graphical bpmn_diagram document
+ */
+ public void translateDiagram() {
+ Element rootElement = document.getRootElement();
+ List<Element> eleList = DomXmlWriter.getElementsByName(rootElement,
+ B2JMessages.Gpd_Element_Name);
+
+ for (String bpmnID : map.keySet()) {
+ if (bpmnID != null) {
+ // when translate bpmn loop activity, we create a mock
+ // structure and when translate bpmn transaction, we create a
+ // mock structure too. For these reason, we need to give a (x,y)
+ // increment to avoid two element overlap
+ int xIncre = 0;
+ int yIncre = 0;
+ Element bpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
+ bpmnID, eleList);
+ if (bpmnGpdEle == null) {
+ if (bpmnID.endsWith(B2JMessages.Bpmn_Vertice_Element_Name)) {
+ bpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
+ TranslateHelper.getPureBpmnID(bpmnID,
+ B2JMessages.Bpmn_Vertice_Element_Name),
+ eleList);
+ xIncre = 150;
+ yIncre = 50;
+ } else if (bpmnID
+ .endsWith(B2JMessages.Jpdl_Element_Decision_Suffix)) {
+ bpmnGpdEle = TranslateHelper
+ .getDiagramLayoutElement(
+ TranslateHelper
+ .getPureBpmnID(
+ bpmnID,
+ B2JMessages.Jpdl_Element_Decision_Suffix),
+ eleList);
+ xIncre = 150;
+ yIncre = 100;
+ } else if (bpmnID
+ .endsWith(B2JMessages.Jpdl_Element_Complete_Suffix)) {
+ bpmnGpdEle = TranslateHelper
+ .getDiagramLayoutElement(
+ TranslateHelper
+ .getPureBpmnID(
+ bpmnID,
+ B2JMessages.Jpdl_Element_Complete_Suffix),
+ eleList);
+ xIncre = 300;
+ yIncre = 0;
+ } else if (bpmnID
+ .endsWith(B2JMessages.Jpdl_Element_Cancel_Suffix)) {
+ bpmnGpdEle = TranslateHelper
+ .getDiagramLayoutElement(
+ TranslateHelper
+ .getPureBpmnID(
+ bpmnID,
+ B2JMessages.Jpdl_Element_Cancel_Suffix),
+ eleList);
+ xIncre = 300;
+ yIncre = 200;
+ }
+ }
+ if (bpmnGpdEle == null) {
+ continue;
+ }
+ translateGraphicalElement(TranslateHelper.getXY(bpmnGpdEle,
+ xIncre, yIncre), map.get(bpmnID), eleList);
+ }
+ }
+
+ }
+
+ private void translateGraphicalElement(String[] xy, Element jpdlEle,
+ List<Element> eleList) {
+ if (jpdlEle == null) {
+ return;
+ }
+
+ // if not translate, then translate the pool of the element
+ if (!gpdPoolNames.contains(jpdlEle.getParent().attributeValue(
+ B2JMessages.Dom_Element_Name))
+ && B2JMessages.Jpdl_Process_Definition_Element_Name
+ .equals(jpdlEle.getParent().getName())) {
+ translatePool(eleList, jpdlEle);
+ }
+
+ // translate the bpmn graphical element
+ Element poolEle = null;
+ for (Document doc : gpdDefs) {
+ if (doc.getRootElement().attributeValue(
+ B2JMessages.Dom_Element_Name).equals(
+ jpdlEle.getParent().attributeValue(
+ B2JMessages.Dom_Element_Name))) {
+ poolEle = doc.getRootElement();
+ }
+ }
+ Element pgdEle = TranslateHelper.createNode(poolEle,
+ B2JMessages.Jpdl_Node_Element_Name, jpdlEle);
+
+ TranslateHelper.mapXY(pgdEle, xy[0], xy[1]);
+
+ // translate the sequence flow of the element
+ for (Object ele : jpdlEle.elements(B2JMessages.Jpdl_Transition_Element)) {
+ TranslateHelper.createTransition(pgdEle,
+ B2JMessages.Jpdl_Transition_Element, (Element) ele);
+ }
+ }
+
+ private void translatePool(List<Element> eleList, Element jpdlEle) {
+ // get the bpmn pool id
+ String poolBpmnID = null;
+ for (String id : map.keySet()) {
+ if (map.get(id) == jpdlEle.getParent()) {
+ poolBpmnID = TranslateHelper.getPureBpmnID(id,
+ B2JMessages.Bpmn_Pool_Element_Name);
+ break;
+ }
+ }
+ // get the bpmn pool graphical element
+ if (poolBpmnID != null) {
+ Element poolBpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
+ poolBpmnID, eleList);
+ Document processDiagramDef = DomXmlWriter.createDomTree(false,
+ null, B2JMessages.Gpd_Process_Diagram_Name);
+ Element poolEle = processDiagramDef.getRootElement();
+ DomXmlWriter.mapAttribute(poolEle, B2JMessages.Dom_Element_Name,
+ jpdlEle.getParent());
+ DomXmlWriter.mapAttribute(poolEle,
+ B2JMessages.Width_Attribute_Name, poolBpmnGpdEle);
+ DomXmlWriter.mapAttribute(poolEle,
+ B2JMessages.Height_Attribute_Name, poolBpmnGpdEle);
+
+ gpdDefs.add(processDiagramDef);
+ gpdPoolNames.add(poolEle
+ .attributeValue(B2JMessages.Dom_Element_Name));
+ }
+
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.b2j.translate;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
+import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
+
+/**
+ * @author Grid Qian
+ *
+ * this is a helper class for bpmn ->jpdl
+ */
+public class TranslateHelper {
+
+ // the map for the bpmn element id : the corresponding generated element
+ static Map<String, Integer> nameMap = new HashMap<String, Integer>();
+
+ public static void setNameMap(Map<String, Integer> nameMap) {
+ TranslateHelper.nameMap = nameMap;
+ }
+
+ /*
+ * get the bpmn_diagram file name
+ */
+ public static String getBpmnDiagramName(String bpmnFileName) {
+ return bpmnFileName + B2JMessages.Bpmn_Diagram_Name_Suffix;
+ }
+
+ /*
+ * create a jpdl dom tree
+ */
+ public static Document createJpdlDomTree(boolean useNamespace) {
+ return DomXmlWriter.createDomTree(useNamespace,
+ B2JMessages.Jpdl_32_Namespace_Url,
+ B2JMessages.Jpdl_Process_Definition_Element_Name);
+
+ }
+
+ /*
+ * create translated files from dom strings
+ */
+ public static File[] createFiles(String parentFolder, String bpmnFileName,
+ String[] strsForGenerate, String[] fileFolders, String fileName,
+ boolean isOverWrite) throws IOException {
+ File jpdlFolder = BPMNToUtil.createFile(parentFolder,
+ B2JMessages.Jpdl_Suffix, null, isOverWrite);
+ File diagramFolder = BPMNToUtil.createFile(
+ jpdlFolder.getAbsolutePath(), bpmnFileName, null, isOverWrite);
+
+ File[] files = new File[strsForGenerate.length];
+ File processFolder = null;
+ int i = 0;
+ for (String str : strsForGenerate) {
+ processFolder = BPMNToUtil.createFile(diagramFolder
+ .getAbsolutePath(), fileFolders[i], null, isOverWrite);
+ files[i] = BPMNToUtil.createFile(processFolder.getAbsolutePath(),
+ fileName, str, isOverWrite);
+ i++;
+ }
+ return files;
+ }
+
+ /*
+ * generate a process definition name. the name is composed of the names
+ * from bpmn diagram to the element
+ */
+ public static String generateProcessName(Element graph) {
+ if ("BpmnDiagram".equals(graph.getName())) {
+ return graph.attributeValue(B2JMessages.Dom_Element_Name);
+ } else {
+ String str = generateProcessName(graph.getParent());
+ if (str == null) {
+ return graph.attributeValue(B2JMessages.Dom_Element_Name);
+ } else {
+ return str + B2JMessages.Folder_Name_Separator
+ + graph.attributeValue(B2JMessages.Dom_Element_Name);
+ }
+ }
+
+ }
+
+ /*
+ * check the bpmn element name is null or "" or same to another element name
+ * and generate a different name
+ */
+ public static boolean check_mapElementName(Element graph, Element graphEle) {
+
+ boolean isOk = true;
+ String name = graph.attributeValue(B2JMessages.Dom_Element_Name);
+
+ if (name == null || "".equals(name)) {
+ name = "jboss_autogen";
+ isOk = false;
+ }
+ Integer i = nameMap.get(name);
+ if (i == null) {
+ DomXmlWriter.addAttribute(graphEle, B2JMessages.Dom_Element_Name,
+ name);
+ nameMap.put(name, new Integer("1"));
+ } else {
+ DomXmlWriter.addAttribute(graphEle, B2JMessages.Dom_Element_Name,
+ name + "_" + i);
+ nameMap.put(name, ++i);
+ isOk = false;
+ }
+
+ return isOk;
+
+ }
+
+ /*
+ * select the elements from process. These elements have no transitions sub
+ * element or have transtions to end-state.
+ */
+ public static List<Element> locateLastElements(Element processRoot) {
+ List<Element> list = new ArrayList<Element>();
+
+ if (processRoot.element(B2JMessages.Jpdl_End_Element_Name) != null) {
+ Element endState = processRoot
+ .element(B2JMessages.Jpdl_End_Element_Name);
+ for (Object ele : processRoot.elements()) {
+ Element subEle = ((Element) ele)
+ .element(B2JMessages.Jpdl_Transition_Element);
+ if (subEle != null
+ && endState
+ .attributeValue(B2JMessages.Dom_Element_Name)
+ .equals(subEle.attributeValue(B2JMessages.To))) {
+ list.add((Element) ele);
+ }
+ }
+ } else {
+ for (Object ele : processRoot.elements()) {
+ if (((Element) ele)
+ .element(B2JMessages.Jpdl_Transition_Element) == null) {
+ list.add((Element) ele);
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /*
+ * get the layout element from bpmn_diagram file by id
+ */
+ public static Element getDiagramLayoutElement(String bpmnID,
+ List<Element> eleList) {
+ Element element = null;
+ for (Element ele : eleList) {
+ String str = ele
+ .attributeValue(B2JMessages.Bpmn_Href_Attribute_Name);
+ if (str != null && str.contains(bpmnID)) {
+ element = ele;
+ break;
+ }
+ }
+
+ if (element != null
+ && element.getParent().element(
+ B2JMessages.Gpd_Layout_Element_Name) != null) {
+ return element.getParent().element(
+ B2JMessages.Gpd_Layout_Element_Name);
+ }
+
+ return null;
+ }
+
+ /*
+ * create a graphical jpdl transition
+ */
+ public static Element createTransition(Element parentEle, String name,
+ Element jpdlEle) {
+ Element ele = DomXmlWriter.addElement(parentEle, name);
+ DomXmlWriter.mapAttribute(ele, B2JMessages.Dom_Element_Name, jpdlEle);
+
+ Element label = DomXmlWriter.addElement(ele,
+ B2JMessages.Gpd_Label_Element_Name);
+ TranslateHelper.mapXY(label, "5", "-10");
+ return ele;
+ }
+
+ /*
+ * create graphical jpdl element
+ */
+ private static Element createElement(Element parentEle, String name,
+ String width, String height) {
+ Element ele = DomXmlWriter.addElement(parentEle, name);
+ DomXmlWriter.addAttribute(ele, B2JMessages.Width_Attribute_Name, width);
+ DomXmlWriter.addAttribute(ele, B2JMessages.Height_Attribute_Name,
+ height);
+ return ele;
+ }
+
+ /*
+ * create graphical jpdl node
+ */
+ public static Element createNode(Element rootEle, String name,
+ Element jpdlEle) {
+ Element ele = TranslateHelper.createElement(rootEle, name, "100",
"40");
+ DomXmlWriter.mapAttribute(ele, B2JMessages.Dom_Element_Name, jpdlEle);
+ return ele;
+ }
+
+ /*
+ * map bpmn x,y attribute to jpdl graphical element
+ */
+ public static void mapXY(Element pgdEle, String x, String y) {
+ DomXmlWriter.addAttribute(pgdEle, B2JMessages.X_Attribute_Name,
+ x == null ? "0" : x);
+ DomXmlWriter.addAttribute(pgdEle, B2JMessages.Y_Attribute_Name,
+ y == null ? "0" : y);
+
+ }
+
+ /*
+ * get a bpmn element id from a given string by subtract suffix for example
+ * bpmn pool has pools suffix a bpmn loop activity has vertices suffix
+ */
+ public static String getPureBpmnID(String bpmnID, String suffix) {
+ return bpmnID.substring(0, bpmnID.length() - suffix.length());
+ }
+
+ /*
+ * get (x,y) from a graphical element and add increments
+ */
+ public static String[] getXY(Element bpmnGpdEle, int xIncre, int yIncre) {
+ String xy[] = new String[2];
+ xy[0] = String.valueOf(Integer.parseInt(bpmnGpdEle
+ .attributeValue(B2JMessages.X_Attribute_Name) == null ? "0"
+ : bpmnGpdEle.attributeValue(B2JMessages.X_Attribute_Name))
+ + xIncre);
+ xy[1] = String.valueOf(Integer.parseInt(bpmnGpdEle
+ .attributeValue(B2JMessages.Y_Attribute_Name) == null ? "0"
+ : bpmnGpdEle.attributeValue(B2JMessages.Y_Attribute_Name))
+ + yIncre);
+ return xy;
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.b2j.wizard;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.dom4j.Document;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
+import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
+import org.jboss.tools.jbpm.convert.b2j.translate.BPMN2JPDL;
+import org.jboss.tools.jbpm.convert.b2j.translate.GraphicalFileGenerator;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.BpmnToWizard;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizard for bpmn to jpdl translation
+ */
+public class B2JExportWizard extends BpmnToWizard {
+
+ private List<String> strForProcessList = new ArrayList<String>();
+ private List<String> strForGpdList = new ArrayList<String>();
+ private List<String> generatedFoldersList = new ArrayList<String>();
+
+ public void createGeneratedFile(boolean isOverWrite) {
+ String[] jpdlFolderNames = new String[this.generatedFoldersList.size()];
+
+ int i = 0;
+ for (String name : this.generatedFoldersList) {
+ jpdlFolderNames[i] = name;
+ i++;
+ }
+
+ String location = super.getContainerPath((IContainer) super
+ .getTargetLocationSelection().getFirstElement());
+
+ if (this.strForProcessList.size() > 0) {
+ i = 0;
+ String[] strs = new String[strForProcessList.size()];
+ for (String pro : this.strForProcessList) {
+ strs[i] = pro;
+ i++;
+ }
+ try {
+ TranslateHelper.createFiles(location, bpmnFileName, strs,
+ jpdlFolderNames,
+ B2JMessages.Jpdl_Process_Definition_Name, isOverWrite);
+ } catch (Exception e) {
+ BpmnToPlugin.getDefault().logError(e.getMessage());
+ }
+ }
+
+ if (this.strForGpdList.size() > 0) {
+ i = 0;
+ String[] strs = new String[strForGpdList.size()];
+ for (String pro : this.strForGpdList) {
+ strs[i] = pro;
+ i++;
+ }
+ try {
+ TranslateHelper.createFiles(location, bpmnFileName, strs,
+ jpdlFolderNames, B2JMessages.Gpd_Definition_Name, isOverWrite);
+ } catch (Exception e) {
+ BpmnToPlugin.getDefault().logError(e.getMessage());
+ }
+ }
+
+ }
+
+ public List<String> translateBpmnToStrings() {
+ List<String> warningList = new ArrayList<String>();
+ List<String> errorList = new ArrayList<String>();
+
+ Document bpmnDocument = null;
+ try {
+ bpmnDocument = getDocument(bpmnFileParentPath, bpmnFileName);
+ } catch (Exception e) {
+ errorList.add(NLS.bind(B2JMessages.Translate_Error_File_CanNotRead,
+ bpmnFileName));
+ }
+
+ BPMN2JPDL translator = new BPMN2JPDL(bpmnFileName, bpmnFileParentPath,
+ poolIdList, bpmnDocument);
+
+ this.setStrForProcessList(Arrays
+ .asList(translator.translateToStrings()));
+
+ for (Document def : translator.getProcessDefs()) {
+ this.generatedFoldersList.add(def.getName());
+ }
+
+ warningList.addAll(translator.getWarnings());
+ errorList.addAll(translator.getErrors());
+
+ // generate jpdl gpd file from *.bpmn_diagram
+ Document bpmnDiagramDocument = null;
+ try {
+ bpmnDiagramDocument = getDocument(bpmnFileParentPath,
+ TranslateHelper.getBpmnDiagramName(bpmnFileName));
+ } catch (Exception e) {
+ errorList.add(NLS.bind(B2JMessages.Translate_Error_File_CanNotRead,
+ TranslateHelper.getBpmnDiagramName(bpmnFileName)));
+ }
+ GraphicalFileGenerator generator = new GraphicalFileGenerator(
+ bpmnDiagramDocument, translator.getMap(), bpmnFileParentPath,
+ bpmnFileName);
+
+ this.setStrForGpdList(Arrays.asList(generator.translateToStrings()));
+
+ warningList.addAll(generator.getWarnings());
+ errorList.addAll(generator.getErrors());
+
+ List<String> list = new ArrayList<String>();
+ list.addAll(errorList);
+ list.addAll(warningList);
+
+ return list;
+ }
+
+ public List<String> getStrForProcessList() {
+ return strForProcessList;
+ }
+
+ public void setStrForProcessList(List<String> strForProcessList) {
+ this.strForProcessList = strForProcessList;
+ }
+
+ public List<String> getStrForGpdList() {
+ return strForGpdList;
+ }
+
+ public void setStrForGpdList(List<String> strForGpdList) {
+ this.strForGpdList = strForGpdList;
+ }
+
+ public List<String> getGeneratedFoldersList() {
+ return generatedFoldersList;
+ }
+
+ public void setGeneratedFoldersList(List<String> generatedFoldersList) {
+ this.generatedFoldersList = generatedFoldersList;
+ }
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/BpmnToPlugin.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto;
+
+import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Grid Qian
+ *
+ * this a plugin class
+ */
+public class BpmnToPlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.jbpm.convert.bpmnto";
+
+ // The shared instance
+ private static BpmnToPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public BpmnToPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static BpmnToPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/translate/BPMNTranslator.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.translate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Grid Qian
+ *
+ * this is a root translator. You should extend it and realize the
+ * method: translateDiagram.
+ */
+public abstract class BPMNTranslator {
+
+ // the bpmn file name
+ public String bpmnFileName;
+
+ //the location of the folder containing the bpmn file
+ public String rootLocation;
+
+ // the bpmn pool's id list that are translated
+ public List<String> poolIDList;
+
+
+ // the warning messages when translate
+ public List<String> warnings = new ArrayList<String>();
+
+ // the error messages when translate
+ public List<String> errors = new ArrayList<String>();
+
+ public List<String> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(List<String> errors) {
+ this.errors = errors;
+ }
+
+ public List<String> getWarnings() {
+ return warnings;
+ }
+
+ public void setWarnings(List<String> warnings) {
+ this.warnings = warnings;
+ }
+
+ public BPMNTranslator() {
+ }
+
+ public BPMNTranslator(String bpmnFileName, String bpmnFilePath) {
+ this(bpmnFileName, bpmnFilePath, null);
+ }
+
+ public BPMNTranslator(String bpmnFileName, String bpmnFilePath,
+ List<String> poolIDList) {
+ this.bpmnFileName = bpmnFileName;
+ this.rootLocation = bpmnFilePath;
+ this.poolIDList = poolIDList;
+ }
+
+ /*
+ * Translate a bpmn diagram to anything
+ */
+ public abstract void translateDiagram();
+}
\ No newline at end of file
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * @author Grid Qian
+ *
+ * this a util class
+ */
+public class BPMNToUtil {
+
+ /*
+ * create a file
+ */
+ public static File createFile(String parentFolder, String fileName,
+ String inputStr, boolean isOverWrite) throws IOException {
+ File child = new File(parentFolder, fileName);
+ if (inputStr == null) {
+ if (!child.exists() || isOverWrite) {
+ child.mkdir();
+ }
+ } else {
+ if (!child.exists() || isOverWrite) {
+ child.createNewFile();
+ }
+ FileWriter childWriter = new FileWriter(child);
+ PrintWriter printFile = new PrintWriter(childWriter);
+ printFile.println(inputStr);
+ printFile.close();
+ childWriter.close();
+
+ }
+ return child;
+ }
+
+ /*
+ * get a sax input source
+ */
+ public static InputSource getInputSource(String parentFolder,
+ String fileName) throws FileNotFoundException {
+ return new InputSource(BPMNToUtil
+ .getInputStream(parentFolder, fileName));
+
+ }
+
+ /*
+ * get a input stream
+ */
+ public static InputStream getInputStream(String parentFolder,
+ String fileName) throws FileNotFoundException {
+ File file = new File(parentFolder, fileName);
+ InputStream input = new FileInputStream(file);
+ return input;
+
+ }
+
+ /*
+ * parse a file to a dom document
+ */
+ public static Document parse(String parentFolder, String fileName)
+ throws Exception {
+ Document document = null;
+ SAXReader saxReader = createSaxReader();
+ document = saxReader.read(BPMNToUtil.getInputSource(parentFolder,
+ fileName));
+ return document;
+ }
+
+ /*
+ * create a sax reader
+ */
+ public static SAXReader createSaxReader() throws Exception {
+ XMLReader xmlReader = createXmlReader();
+ SAXReader saxReader = new SAXReader(xmlReader);
+ return saxReader;
+ }
+
+ /*
+ * create a sax xml reader
+ */
+ public static XMLReader createXmlReader() throws Exception {
+
+ SAXParser saxParser = createSaxParserFactory().newSAXParser();
+ XMLReader xmlReader = saxParser.getXMLReader();
+
+ saxParser.setProperty(
+ "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+ "http://www.w3.org/2001/XMLSchema");
+
+ xmlReader.setFeature(
+ "http://apache.org/xml/features/validation/dynamic", true);
+
+ return xmlReader;
+ }
+
+ /*
+ * create a sax parser factory
+ */
+ private static SAXParserFactory createSaxParserFactory() {
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ saxParserFactory.setValidating(true);
+ saxParserFactory.setNamespaceAware(true);
+ return saxParserFactory;
+ }
+
+ /*
+ * get bpmn pool id list from a dom document
+ */
+ public static Map<String, String> getPoolIDsFromDocument(Document document) {
+ Map<String, String> poolIDMap = new HashMap<String, String>();
+ Element diagram = document.getRootElement();
+ for (Object pool : diagram.elements(B2JMessages.Bpmn_Pool_Element_Name)) {
+ if (((Element) pool).attributeValue(B2JMessages.Bpmn_Element_ID) != null) {
+ poolIDMap.put(((Element) pool)
+ .attributeValue(B2JMessages.Bpmn_Element_ID),
+ ((Element) pool)
+ .attributeValue(B2JMessages.Dom_Element_Name));
+ }
+ }
+ return poolIDMap;
+ }
+
+ public static Composite createComposite(Composite parent, int numColumns) {
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ return composite;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static boolean checkSelectedResources(ISelection selectedResources) {
+ boolean res = true;
+ if (selectedResources instanceof IStructuredSelection
+ && !selectedResources.isEmpty()) {
+ IStructuredSelection ss = (IStructuredSelection) selectedResources;
+ for (Iterator it = ss.iterator(); it.hasNext();) {
+ Object o = it.next();
+ if (o instanceof IFile) {
+ if (!((IFile) o).getFileExtension()
+ .equalsIgnoreCase("bpmn")) {
+ res = false;
+ break;
+ }
+ } else {
+ res = false;
+ break;
+ }
+ }
+ } else {
+ res = false;
+ }
+ return res;
+ }
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.util;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dom4j.*;
+import org.dom4j.io.*;
+import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
+
+/**
+ * @author Grid Qian
+ *
+ * this is for generating dom element or attribute
+ */
+public class DomXmlWriter {
+
+ /*
+ * map a dom document to a string
+ */
+ public static String toString(Document document) throws IOException {
+ OutputFormat outputFormat = new OutputFormat(" ", true);
+ Writer writer = new StringWriter();
+ XMLWriter xmlWriter = new XMLWriter(writer, outputFormat);
+ xmlWriter.write(document);
+ xmlWriter.flush();
+ writer.flush();
+ return writer.toString();
+ }
+
+ /*
+ * create a dom tree
+ */
+ public static Document createDomTree(boolean useNamespace, String url,
+ String rootElementName) {
+ Document document = DocumentHelper.createDocument();
+ Element root = null;
+
+ if (useNamespace) {
+ Namespace jbpmNamespace = new Namespace(null, url);
+ root = document.addElement(rootElementName, jbpmNamespace.getURI());
+ } else {
+ root = document.addElement(rootElementName);
+ }
+ root.addText(System.getProperty("line.separator"));
+
+ return document;
+ }
+
+ /*
+ * add a new element to a dom element
+ */
+ public static Element addElement(Element element, String elementName) {
+ Element newElement = element.addElement(elementName);
+ return newElement;
+ }
+
+ /*
+ * add a new element to the location of a dom element
+ */
+ @SuppressWarnings("unchecked")
+ public static Element addElement(Element element, String elementName,
+ int location) {
+ Element newElement = null;
+ if (element.elements(elementName) != null
+ && element.elements(elementName).size() > location
+ && location >= 0) {
+ newElement = DocumentHelper.createElement(elementName);
+ element.elements(elementName).add(location, newElement);
+ }
+ return newElement;
+ }
+
+ /*
+ * add a attribute to a dom element
+ */
+ public static void addAttribute(Element e, String attributeName,
+ String value) {
+ if (value != null) {
+ e.addAttribute(attributeName, value);
+ }
+ }
+
+ /*
+ * get a named element from a element (any depth)
+ */
+ public static List<Element> getElementsByName(Element element, String name) {
+ List<Element> list = new ArrayList<Element>();
+ for (Object ele : element.elements()) {
+ if (name.equals(((Element) ele).getName())) {
+ list.add((Element) ele);
+ }
+ list.addAll(getElementsByName((Element) ele, name));
+ }
+ return list;
+ }
+
+ /*
+ * set a element attribute using a same name attribute of other element
+ */
+ public static void mapAttribute(Element ele, String attrName, Element sourceEle){
+ DomXmlWriter.addAttribute(ele, attrName,sourceEle.attributeValue(attrName));
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.wizard;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.BpmnToWizard;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.ProjectFilter;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage used by user to choose the bpmn file
+ */
+public class BPMNResourcesChoicePage extends WizardPage {
+
+ private TreeViewer viewer;
+ private ISelection currentSelection;
+ private IWizard wizard;
+
+ public BPMNResourcesChoicePage(String pageName, String title,
+ String description) {
+ super(pageName);
+ this.setTitle(title);
+ this.setDescription(description);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+
+ createListTitleArea(composite);
+ createListViewer(composite);
+ super.setControl(composite);
+
+ initializePage();
+ }
+
+ private Label createListTitleArea(Composite composite) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(B2JMessages.Bpmn_File_Choose_WizardPage_ViewerTitle);
+ label.setFont(composite.getFont());
+ return label;
+ }
+
+ private void createListViewer(Composite composite) {
+ viewer = new TreeViewer(composite, SWT.BORDER | SWT.MULTI
+ | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ viewer.setLabelProvider(new WorkbenchLabelProvider());
+ WorkbenchContentProvider cp = new WorkbenchContentProvider();
+ viewer.setContentProvider(cp);
+ viewer.setFilters(new ViewerFilter[] { new ProjectFilter() });
+ viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateControls();
+ currentSelection = viewer.getSelection();
+ ((BpmnToWizard) wizard)
+ .setSelection((IStructuredSelection) currentSelection);
+
+ }
+ });
+ }
+
+ private void initializePage() {
+ wizard = this.getWizard();
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+ if (this.currentSelection != null) {
+ viewer.setSelection(currentSelection, true);
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (viewer != null) {
+ return BPMNToUtil.checkSelectedResources(viewer.getSelection());
+ }
+ return super.isPageComplete();
+ }
+
+ private void updateControls() {
+ super.getWizard().getContainer().updateButtons();
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public void setSelection(ISelection selection) {
+ this.currentSelection = selection;
+ }
+
+ public ISelection getSelection() {
+ return currentSelection;
+ }
+}
+
+class ProjectFilter extends ViewerFilter {
+ @Override
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ boolean res = false;
+ if (element instanceof IFile) {
+ IFile file = (IFile) element;
+ if (file.getFileExtension().equalsIgnoreCase("bpmn")) {
+ res = true;
+ }
+ }
+ if (element instanceof IContainer) {
+ res = true;
+ }
+ return res;
+ }
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnPoolsChoicePage.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.wizard;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.BpmnToWizard;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage used by user to choose the bpmn pool from a bpmn diagram
+ */
+public class BpmnPoolsChoicePage extends WizardPage {
+
+ CheckboxTableViewer listViewer;
+ String listTitle;
+ private Map<String, String> idMap;
+
+ private IWizard wizard;
+
+ public BpmnPoolsChoicePage(String pageName, String title, String listTitle) {
+ super(pageName);
+ this.listTitle = listTitle;
+ this.setTitle(title);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+
+ createListTitleArea(composite);
+ createListViewer(composite);
+ addSelectionButtons(composite);
+ setControl(composite);
+
+ initializePage();
+ initializeViewer();
+ }
+
+ private Label createListTitleArea(Composite composite) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(listTitle);
+ label.setFont(composite.getFont());
+ return label;
+ }
+
+ private void createListViewer(Composite composite) {
+ listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 250;
+ data.widthHint = 300;
+ listViewer.getTable().setLayoutData(data);
+
+ listViewer.setLabelProvider(new LabelProvider());
+ listViewer.setContentProvider(new ArrayContentProvider());
+ listViewer.addCheckStateListener(new ICheckStateListener() {
+ @SuppressWarnings("unchecked")
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getChecked()) {
+ (((BpmnToWizard) wizard)).getPoolIdList().add(
+ ((Entry<String, String>) event.getElement())
+ .getKey());
+ } else {
+ (((BpmnToWizard) wizard)).getPoolIdList().remove(
+ ((Entry<String, String>) event.getElement())
+ .getKey());
+ }
+ changeComplete();
+ }
+ });
+ }
+
+ private void addSelectionButtons(Composite composite) {
+ Composite buttonComposite = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 4;
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true,
+ false));
+
+ Button selectButton = createButton(buttonComposite,
+ B2JMessages.Label_Select_All, false);
+
+ SelectionListener listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ listViewer.setAllChecked(true);
+ (((BpmnToWizard) wizard)).getPoolIdList()
+ .addAll(idMap.keySet());
+ changeComplete();
+ }
+ };
+ selectButton.addSelectionListener(listener);
+
+ Button deselectButton = createButton(buttonComposite,
+ B2JMessages.Label_Deselect_All, false);
+
+ listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ listViewer.setAllChecked(false);
+ (((BpmnToWizard) wizard)).getPoolIdList().clear();
+ changeComplete();
+ }
+ };
+ deselectButton.addSelectionListener(listener);
+ }
+
+ private Button createButton(Composite parent, String label,
+ boolean defaultButton) {
+ // increment the number of columns in the button bar
+ ((GridLayout) parent.getLayout()).numColumns++;
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(label);
+ if (defaultButton) {
+ Shell shell = parent.getShell();
+ if (shell != null) {
+ shell.setDefaultButton(button);
+ }
+ }
+ setButtonLayoutData(button);
+ return button;
+ }
+
+ private void initializePage() {
+ setPageComplete(false);
+ }
+
+ private void initializeViewer() {
+ if (listViewer == null) {
+ return;
+ }
+ listViewer.setInput(idMap.entrySet());
+ wizard = this.getWizard();
+ List<String> poolIdList = ((BpmnToWizard) wizard).getPoolIdList();
+ if (poolIdList.size() == 0) {
+ listViewer.setAllChecked(false);
+ } else {
+ for (String id : poolIdList) {
+ Set<Entry<String, String>> set = idMap.entrySet();
+ Entry<String, String> selectedEntry = null;
+ for (Entry<String, String> entry : set) {
+ if (entry.getKey().equals(id)) {
+ selectedEntry = entry;
+ break;
+ }
+ }
+ listViewer.setChecked(selectedEntry, true);
+ }
+ }
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public void changeComplete() {
+ if (listViewer.getCheckedElements().length != 0) {
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+ }
+
+ public Map<String, String> getIdMap() {
+ return idMap;
+ }
+
+ public void setIdMap(Map<String, String> idMap) {
+ this.idMap = idMap;
+ initializeViewer();
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.BpmnPoolsChoicePage;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.ErrorMessagesPage;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.GeneratedFileLocationPage;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.BPMNResourcesChoicePage;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizard for bpmn translation
+ */
+public abstract class BpmnToWizard extends Wizard implements IExportWizard {
+
+ private BPMNResourcesChoicePage bpmnResPage;
+ private BpmnPoolsChoicePage poolsPage;
+ private GeneratedFileLocationPage locationPage;
+ private ErrorMessagesPage errorPage;
+
+ // the selected *.bpmn file
+ private IStructuredSelection selection;
+ // the selected folder to save these generated files
+ private IStructuredSelection targetLocationSelection;
+ // bpmn pool id:name map
+ private Map<String, String> idMap;
+
+ protected String bpmnFileName;
+ protected String bpmnFileParentPath;
+ protected List<String> poolIdList = new ArrayList<String>();
+ // the list contains errors or warnings when generating
+ protected List<String> errorList = new ArrayList<String>();
+
+ public BpmnToWizard() {
+ super();
+ super.setWindowTitle(B2JMessages.Bpmn_Wizard_Title);
+ }
+
+ public void addPages() {
+ super.addPages();
+
+ bpmnResPage = new BPMNResourcesChoicePage(
+ B2JMessages.Bpmn_File_Choose_WizardPage_Name,
+ B2JMessages.Bpmn_File_Choose_WizardPage_Title,
+ B2JMessages.Bpmn_File_Choose_WizardPage_Message);
+ bpmnResPage.setSelection(selection);
+ poolsPage = new BpmnPoolsChoicePage(
+ B2JMessages.Bpmn_Pool_Choose_WizardPage_Name,
+ B2JMessages.Bpmn_Pool_Choose_WizardPage_Title,
+ B2JMessages.Bpmn_Pool_Choose_WizardPage_Message);
+ errorPage = new ErrorMessagesPage(
+ B2JMessages.Bpmn_Translate_Message_WizardPage_Name,
+ B2JMessages.Bpmn_Translate_Message_WizardPage_Title,
+ B2JMessages.Bpmn_Translate_Message_WizardPage_Message);
+ locationPage = new GeneratedFileLocationPage(
+ B2JMessages.Bpmn_GeneratedFile_Location_WizardPage_Name,
+ B2JMessages.Bpmn_GeneratedFile_Location_WizardPage_Title,
+ B2JMessages.Bpmn_GeneratedFile_Location_WizardPage_Message);
+ locationPage.setSelection(selection);
+ addPage(bpmnResPage);
+ addPage(poolsPage);
+ addPage(errorPage);
+ addPage(locationPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ initialize();
+ }
+
+ /*
+ * do some initial tasks
+ */
+ private void initialize() {
+ if (selection.getFirstElement() instanceof IFile) {
+ IFile bpmnFile = (IFile) selection.getFirstElement();
+ bpmnFileName = bpmnFile.getName();
+ bpmnFileParentPath = bpmnFile.getParent().getLocation()
+ .toOSString();
+ try {
+ idMap = BPMNToUtil.getPoolIDsFromDocument(getDocument(
+ bpmnFileParentPath, bpmnFileName));
+ poolIdList.clear();
+ } catch (Exception e) {
+ errorList.add(0, NLS.bind(
+ B2JMessages.Translate_Error_File_CanNotRead,
+ bpmnFileName));
+ e.printStackTrace();
+ }
+ }
+ if (poolsPage != null) {
+ poolsPage.setIdMap(idMap);
+ }
+ }
+
+ public IWizardPage getNextPage(IWizardPage page) {
+ if (page.getName()
+ .equals(B2JMessages.Bpmn_Pool_Choose_WizardPage_Name)) {
+ errorList = translateBpmnToStrings();
+ if (errorList.size() == 0) {
+ return locationPage;
+ }
+ errorPage.getListViewer().setInput(errorList);
+ return super.getNextPage(page);
+ } else {
+ return super.getNextPage(page);
+ }
+
+ }
+
+ public boolean performFinish() {
+
+ createGeneratedFile(locationPage.isOverWrite());
+ refreshWorkspace();
+ return true;
+ }
+
+ /*
+ * do the translation from bpmn to string list the sub class need to create
+ * a string list to reserve these strings
+ * the return list is error or warning messages
+ */
+ public abstract List<String> translateBpmnToStrings();
+
+ /*
+ * write the generated strings to the files
+ */
+ public abstract void createGeneratedFile(boolean b);
+
+ /*
+ * get the path of the eclipse workspace container
+ */
+ protected String getContainerPath(IContainer container) {
+ return container.getLocation().toOSString();
+ }
+
+ /*
+ * get the dom document from a given path and file name
+ */
+ public Document getDocument(String bpmnFileParentPath, String bpmnFileName)
+ throws Exception {
+ Document bpmnDocument = null;
+ bpmnDocument = BPMNToUtil.parse(bpmnFileParentPath, bpmnFileName);
+ return bpmnDocument;
+ }
+
+ /*
+ * refresh eclipse workspace
+ */
+ public void refreshWorkspace() {
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(
+ IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public List<String> getPoolIdList() {
+ return poolIdList;
+ }
+
+ public void setPoolIdList(List<String> poolIdList) {
+ this.poolIdList = poolIdList;
+ }
+
+ public List<String> getErrorList() {
+ return errorList;
+ }
+
+ public void setErrorList(List<String> errorList) {
+ this.errorList = errorList;
+ }
+
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ this.selection = selection;
+ initialize();
+ }
+
+ public String getBpmnFileName() {
+ return bpmnFileName;
+ }
+
+ public void setBpmnFileName(String bpmnFileName) {
+ this.bpmnFileName = bpmnFileName;
+ }
+
+ public String getBpmnFileParentPath() {
+ return bpmnFileParentPath;
+ }
+
+ public void setBpmnFileParentPath(String bpmnFileParentPath) {
+ this.bpmnFileParentPath = bpmnFileParentPath;
+ }
+
+ public IStructuredSelection getTargetLocationSelection() {
+ return targetLocationSelection;
+ }
+
+ public void setTargetLocationSelection(
+ IStructuredSelection targetLocationSelection) {
+ this.targetLocationSelection = targetLocationSelection;
+ }
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/ErrorMessagesPage.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.wizard;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage for showing the error and warning messages from translating
+ */
+public class ErrorMessagesPage extends WizardPage {
+
+ private TableViewer listViewer;
+
+ protected ErrorMessagesPage(String pageName, String title, String description) {
+ super(pageName);
+ this.setDescription(description);
+ this.setTitle(title);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+
+ createListTitleArea(composite);
+ createListViewer(composite);
+ setControl(composite);
+
+ }
+
+ private Label createListTitleArea(Composite composite) {
+ Label label = new Label(composite, SWT.NONE);
+ label
+ .setText(B2JMessages.Bpmn_Translate_Message_WizardpageViewer_Title);
+ label.setFont(composite.getFont());
+ return label;
+ }
+
+ private void createListViewer(Composite composite) {
+ listViewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 250;
+ data.widthHint = 300;
+ listViewer.getTable().setLayoutData(data);
+
+ listViewer.setLabelProvider(new LabelProvider());
+ listViewer.setContentProvider(new ArrayContentProvider());
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public boolean isPageComplete() {
+ return true;
+ }
+
+
+ public TableViewer getListViewer() {
+ return listViewer;
+ }
+
+ public void setListViewer(TableViewer listViewer) {
+ this.listViewer = listViewer;
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/GeneratedFileLocationPage.java 2008-10-14
02:40:34 UTC (rev 10817)
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.bpmnto.wizard;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.BpmnToWizard;
+import org.jboss.tools.jbpm.convert.bpmnto.wizard.ProFilter;
+
+/**
+ * @author Grid Qian
+ *
+ * the wizardpage for the generated file location
+ */
+public class GeneratedFileLocationPage extends WizardPage {
+
+ private TreeViewer viewer;
+ private ISelection currentSelection;
+ private Button button;
+ private IWizard wizard;
+ private boolean isOverWrite;
+
+
+ protected GeneratedFileLocationPage(String pageName, String title,
+ String description) {
+ super(pageName);
+ this.setDescription(description);
+ this.setTitle(title);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+
+ createListTitleArea(composite);
+ createListViewer(composite);
+ createCheckbox(composite);
+ super.setControl(composite);
+
+ initializePage();
+
+ }
+
+ private Label createListTitleArea(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label
+ .setText(B2JMessages.Bpmn_GeneratedFile_Location_WizardPage_ViewerTitle);
+ label.setFont(parent.getFont());
+ return label;
+ }
+
+ private void createListViewer(Composite composite) {
+ viewer = new TreeViewer(composite, SWT.BORDER | SWT.MULTI
+ | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ viewer.setLabelProvider(new WorkbenchLabelProvider());
+ WorkbenchContentProvider cp = new WorkbenchContentProvider();
+ viewer.setContentProvider(cp);
+ viewer.setFilters(new ViewerFilter[] { new ProFilter() });
+ viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateControls();
+ currentSelection = viewer.getSelection();
+ ((BpmnToWizard) wizard)
+ .setTargetLocationSelection((IStructuredSelection) currentSelection);
+
+ }
+ });
+ }
+
+ private Button createCheckbox(Composite parent) {
+ button = new Button(parent, SWT.CHECK | SWT.NONE);
+ button
+ .setText(B2JMessages.Bpmn_GeneratedFile_Location_WizardPage_CheckBox);
+ button.setFont(parent.getFont());
+ button.addSelectionListener(new SelectionListener(){
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ }
+ public void widgetSelected(SelectionEvent arg0) {
+ isOverWrite = button.getSelection();
+ }});
+ return button;
+ }
+
+ private void initializePage() {
+ wizard = this.getWizard();
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+ if (this.currentSelection != null) {
+ if (currentSelection != null
+ && currentSelection instanceof ITreeSelection) {
+ // Select the parent project of this first bpmn file chosen
+ ITreeSelection node = (ITreeSelection) currentSelection;
+ TreePath[] paths = node.getPaths();
+ TreePath projPath = new TreePath(new Object[] { paths[0]
+ .getFirstSegment() });
+ TreeSelection projSel = new TreeSelection(projPath);
+ viewer.setSelection(projSel, true);
+ }
+ }
+ button.setSelection(true);
+ }
+
+ private void updateControls() {
+ super.getWizard().getContainer().updateButtons();
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ public boolean isPageComplete() {
+ if (viewer != null && viewer.getSelection() == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public ISelection getSelection() {
+ return currentSelection;
+ }
+
+ public void setSelection(ISelection currentSelection) {
+ this.currentSelection = currentSelection;
+ }
+
+
+ public boolean isOverWrite() {
+ return isOverWrite;
+ }
+
+ public void setOverWrite(boolean isOverWrite) {
+ this.isOverWrite = isOverWrite;
+ }
+
+}
+
+class ProFilter extends ViewerFilter {
+ @Override
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ return element instanceof IContainer;
+ }
+}