JBoss Tools SVN: r9840 - in workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools: b2j and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-08-21 03:03:42 -0400 (Thu, 21 Aug 2008)
New Revision: 9840
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/BpmnToPlugin.java
Removed:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/B2J.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/action/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/messages/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/translate/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/util/
Modified:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java
Log:
Copied: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action (from rev 9839, workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/action)
Copied: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages (from rev 9839, workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/messages)
Copied: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate (from rev 9839, workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/translate)
Modified: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/translate/BPMN2JPDL.java 2008-08-21 06:58:14 UTC (rev 9839)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java 2008-08-21 07:03:42 UTC (rev 9840)
@@ -20,7 +20,7 @@
import org.dom4j.Document;
import org.dom4j.Element;
-import org.jboss.tools.b2j.B2J;
+import org.jboss.tools.bpmnTo.*;
import org.jboss.tools.b2j.messages.B2JMessages;
/**
@@ -129,13 +129,13 @@
if (errors.size() != 0) {
for (String str : errors) {
- B2J.getDefault().logError(str);
+ BpmnToPlugin.getDefault().logError(str);
}
}
if (warnings.size() != 0) {
for (String str : warnings) {
- B2J.getDefault().logWarning(str);
+ BpmnToPlugin.getDefault().logWarning(str);
}
}
}
Modified: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/translate/GraphicalFileGenerator.java 2008-08-21 06:58:14 UTC (rev 9839)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java 2008-08-21 07:03:42 UTC (rev 9840)
@@ -20,7 +20,7 @@
import org.dom4j.Document;
import org.dom4j.Element;
-import org.jboss.tools.b2j.B2J;
+import org.jboss.tools.bpmnTo.BpmnToPlugin;
import org.jboss.tools.b2j.messages.B2JMessages;
/**
@@ -114,13 +114,13 @@
if (errors.size() != 0) {
for (String str : errors) {
- B2J.getDefault().logError(str);
+ BpmnToPlugin.getDefault().logError(str);
}
}
if (warnings.size() != 0) {
for (String str : warnings) {
- B2J.getDefault().logWarning(str);
+ BpmnToPlugin.getDefault().logWarning(str);
}
}
}
Copied: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util (from rev 9839, workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/util)
Deleted: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/B2J.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/B2J.java 2008-08-21 06:58:14 UTC (rev 9839)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/B2J.java 2008-08-21 07:03:42 UTC (rev 9840)
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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.b2j;
-
-import org.jboss.tools.common.log.BaseUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * @author Grid Qian
- *
- * this a plugin class
- */
-public class B2J extends BaseUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.b2j";
-
- // The shared instance
- private static B2J plugin;
-
- /**
- * The constructor
- */
- public B2J() {
- }
-
- /*
- * (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 B2J getDefault() {
- return plugin;
- }
-
-}
Copied: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/BpmnToPlugin.java (from rev 9839, workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/B2J.java)
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/BpmnToPlugin.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/BpmnToPlugin.java 2008-08-21 07:03:42 UTC (rev 9840)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.bpmnTo;
+
+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.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;
+ }
+
+}
17 years, 8 months
JBoss Tools SVN: r9839 - in workspace/grid/org.jboss.tools.bpmnTo: src/org/jboss/tools and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-08-21 02:58:14 -0400 (Thu, 21 Aug 2008)
New Revision: 9839
Added:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo/
Removed:
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/
Modified:
workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF
Log:
Modified: workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF 2008-08-21 06:47:54 UTC (rev 9838)
+++ workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF 2008-08-21 06:58:14 UTC (rev 9839)
@@ -4,7 +4,7 @@
Bundle-SymbolicName: org.jboss.tools.bpmnTo;singleton:=true
Bundle-Version: 1.0.0
Bundle-Localization: plugin
-Bundle-Activator: org.jboss.tools.b2j.B2J
+Bundle-Activator: org.jboss.tools.bpmnTo.BpmnTo
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.jboss.tools.common;bundle-version="2.0.0"
Copied: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/bpmnTo (from rev 9837, workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j)
17 years, 8 months
JBoss Tools SVN: r9838 - in workspace/grid: org.jboss.tools.b2j and 14 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-08-21 02:47:54 -0400 (Thu, 21 Aug 2008)
New Revision: 9838
Added:
workspace/grid/org.jboss.tools.b2j/
workspace/grid/org.jboss.tools.b2j/.classpath
workspace/grid/org.jboss.tools.b2j/.project
workspace/grid/org.jboss.tools.b2j/.settings/
workspace/grid/org.jboss.tools.b2j/.settings/org.eclipse.jdt.core.prefs
workspace/grid/org.jboss.tools.b2j/META-INF/
workspace/grid/org.jboss.tools.b2j/META-INF/MANIFEST.MF
workspace/grid/org.jboss.tools.b2j/bin/
workspace/grid/org.jboss.tools.b2j/build.properties
workspace/grid/org.jboss.tools.b2j/lib/
workspace/grid/org.jboss.tools.b2j/lib/commons-logging.jar
workspace/grid/org.jboss.tools.b2j/lib/dom4j-1.6.1.jar
workspace/grid/org.jboss.tools.b2j/lib/jbpm-jpdl.jar
workspace/grid/org.jboss.tools.b2j/lib/jbpm.cfg.xml
workspace/grid/org.jboss.tools.b2j/lib/org/
workspace/grid/org.jboss.tools.b2j/lib/org/jbpm/
workspace/grid/org.jboss.tools.b2j/lib/org/jbpm/default.jbpm.cfg.xml
workspace/grid/org.jboss.tools.b2j/plugin.properties
workspace/grid/org.jboss.tools.b2j/plugin.xml
workspace/grid/org.jboss.tools.b2j/src/
workspace/grid/org.jboss.tools.b2j/src/org/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/B2J.java
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/action/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/action/B2JAction.java
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2J.properties
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2JMessages.java
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/JpdlXmlWriter.java
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/TranslateHelper.java
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/util/
workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/util/B2JUtil.java
Log:
add emf translator
Added: workspace/grid/org.jboss.tools.b2j/.classpath
===================================================================
--- workspace/grid/org.jboss.tools.b2j/.classpath (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/.classpath 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib" path="lib/"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-logging.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/dom4j-1.6.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jbpm-jpdl.jar" sourcepath="D:/sources/jbpm/trunk/modules/jpdl"/>
+ <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: workspace/grid/org.jboss.tools.b2j/.project
===================================================================
--- workspace/grid/org.jboss.tools.b2j/.project (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/.project 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.b2j</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: workspace/grid/org.jboss.tools.b2j/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- workspace/grid/org.jboss.tools.b2j/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/.settings/org.eclipse.jdt.core.prefs 2008-08-21 06:47:54 UTC (rev 9838)
@@ -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: workspace/grid/org.jboss.tools.b2j/META-INF/MANIFEST.MF
===================================================================
--- workspace/grid/org.jboss.tools.b2j/META-INF/MANIFEST.MF (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/META-INF/MANIFEST.MF 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: B2j Plug-in
+Bundle-SymbolicName: org.jboss.tools.b2j;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Activator: org.jboss.tools.b2j.B2J
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.stp.bpmn;bundle-version="1.0.0",
+ org.jboss.tools.common;bundle-version="2.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ClassPath: lib/jbpm-jpdl.jar,
+ .,
+ lib/dom4j-1.6.1.jar,
+ lib/commons-logging.jar,
+ lib/
Added: workspace/grid/org.jboss.tools.b2j/build.properties
===================================================================
--- workspace/grid/org.jboss.tools.b2j/build.properties (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/build.properties 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ lib/jbpm-jpdl.jar,\
+ lib/dom4j-1.6.1.jar,\
+ lib/commons-logging.jar,\
+ lib/,\
+ plugin.properties
Added: workspace/grid/org.jboss.tools.b2j/lib/commons-logging.jar
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.b2j/lib/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.b2j/lib/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.b2j/lib/dom4j-1.6.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.b2j/lib/jbpm-jpdl.jar
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.b2j/lib/jbpm-jpdl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.b2j/lib/jbpm.cfg.xml
===================================================================
--- workspace/grid/org.jboss.tools.b2j/lib/jbpm.cfg.xml (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/lib/jbpm.cfg.xml 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,52 @@
+<jbpm-configuration>
+
+ <!--
+ This configuration is used when there is no jbpm.cfg.xml file found in the
+ root of the classpath. It is a very basic configuration without persistence
+ and message services. Only the authorization service installed.
+ You can parse and create processes, but when you try to use one of the
+ unavailable services, you'll get an exception.
+ -->
+
+ <jbpm-context>
+ <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
+ <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
+ <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
+ <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
+ <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
+ <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
+ </jbpm-context>
+
+ <!-- configuration property used by persistence service impl org.jbpm.persistence.db.DbPersistenceServiceFactory -->
+ <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />
+
+ <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
+ <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
+ <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
+ <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
+ <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
+ <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
+ <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
+ <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
+ <string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
+
+ <int name="jbpm.byte.block.size" value="1024" singleton="true" />
+ <bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
+ <bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
+ <string name="jbpm.mail.smtp.host" value="localhost" />
+ <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
+ <string name="jbpm.mail.from.address" value="jbpm@noreply" />
+
+ <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">
+ <field name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></field>
+ <field name="name"><string value="JbpmJobExector" /></field>
+ <field name="nbrOfThreads"><int value="1" /></field>
+ <field name="idleInterval"><int value="5000" /></field>
+ <field name="maxIdleInterval"><int value="3600000" /></field> <!-- 1 hour -->
+ <field name="historyMaxSize"><int value="20" /></field>
+ <field name="maxLockTime"><int value="600000" /></field> <!-- 10 minutes -->
+ <field name="lockMonitorInterval"><int value="60000" /></field> <!-- 1 minute -->
+ <field name="lockBufferTime"><int value="5000" /></field> <!-- 5 seconds -->
+ </bean>
+
+</jbpm-configuration>
Added: workspace/grid/org.jboss.tools.b2j/lib/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- workspace/grid/org.jboss.tools.b2j/lib/org/jbpm/default.jbpm.cfg.xml (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/lib/org/jbpm/default.jbpm.cfg.xml 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,52 @@
+<jbpm-configuration>
+
+ <!--
+ This configuration is used when there is no jbpm.cfg.xml file found in the
+ root of the classpath. It is a very basic configuration without persistence
+ and message services. Only the authorization service installed.
+ You can parse and create processes, but when you try to use one of the
+ unavailable services, you'll get an exception.
+ -->
+
+ <jbpm-context>
+ <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
+ <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
+ <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
+ <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
+ <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
+ <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
+ </jbpm-context>
+
+ <!-- configuration property used by persistence service impl org.jbpm.persistence.db.DbPersistenceServiceFactory -->
+ <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />
+
+ <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
+ <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
+ <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
+ <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
+ <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
+ <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
+ <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
+ <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
+ <string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
+
+ <int name="jbpm.byte.block.size" value="1024" singleton="true" />
+ <bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
+ <bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
+ <string name="jbpm.mail.smtp.host" value="localhost" />
+ <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
+ <string name="jbpm.mail.from.address" value="jbpm@noreply" />
+
+ <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">
+ <field name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></field>
+ <field name="name"><string value="JbpmJobExector" /></field>
+ <field name="nbrOfThreads"><int value="1" /></field>
+ <field name="idleInterval"><int value="5000" /></field>
+ <field name="maxIdleInterval"><int value="3600000" /></field> <!-- 1 hour -->
+ <field name="historyMaxSize"><int value="20" /></field>
+ <field name="maxLockTime"><int value="600000" /></field> <!-- 10 minutes -->
+ <field name="lockMonitorInterval"><int value="60000" /></field> <!-- 1 minute -->
+ <field name="lockBufferTime"><int value="5000" /></field> <!-- 5 seconds -->
+ </bean>
+
+</jbpm-configuration>
Added: workspace/grid/org.jboss.tools.b2j/plugin.properties
===================================================================
--- workspace/grid/org.jboss.tools.b2j/plugin.properties (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/plugin.properties 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1 @@
+b2jaction=BPMN -> JPDL
\ No newline at end of file
Added: workspace/grid/org.jboss.tools.b2j/plugin.xml
===================================================================
--- workspace/grid/org.jboss.tools.b2j/plugin.xml (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/plugin.xml 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.jboss.tools.b2j.objectContribution.bpmnfile"
+ nameFilter="*.bpmn"
+ objectClass="org.eclipse.core.resources.IFile">
+ <action
+ label="%b2jaction"
+ class="org.jboss.tools.b2j.action.B2JAction"
+ menubarPath="additions"
+ enablesFor="1"
+ id="org.jboss.tools.b2j.Bpmn2JpdlAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/B2J.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/B2J.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/B2J.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,50 @@
+package org.jboss.tools.b2j;
+
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class B2J extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.b2j";
+
+ // The shared instance
+ private static B2J plugin;
+
+ /**
+ * The constructor
+ */
+ public B2J() {
+ }
+
+ /*
+ * (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 B2J getDefault() {
+ return plugin;
+ }
+
+}
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/action/B2JAction.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/action/B2JAction.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/action/B2JAction.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,30 @@
+package org.jboss.tools.b2j.action;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.b2j.translate.BPMN2JPDL;
+
+public class B2JAction implements IObjectActionDelegate{
+
+ //private IWorkbenchPart myPart;
+ private IFile bpmnFile;
+
+ public void setActivePart(IAction arg0, IWorkbenchPart part) {
+ //myPart = part;
+ }
+
+ public void run(IAction arg0) {
+ BPMN2JPDL translator = new BPMN2JPDL();
+ translator.setBpmnFile(bpmnFile);
+ translator.translateToFiles();
+ }
+
+ public void selectionChanged(IAction arg0, ISelection selection) {
+ bpmnFile = (IFile) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+}
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2J.properties
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2J.properties (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2J.properties 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,21 @@
+Loop_Decision=Loop Decition
+Loop_Decision_Description=this decision is for mocking bpmn loop activity
+To=to
+Bpmn_Suffix=bpmn
+Workspace_Prefix=platform:/resource
+Jpdl_Suffix=jpdl
+Jpdl_Process_Definition_Name=processdefinition.xml
+Jpdl_32_Namespace_Url=urn:jbpm.org:jpdl-3.2
+Jpdl_Element_Name=name
+Jpdl_Process_Definition_Element=process-definition
+Jpdl_Transition_Element=transition
+Jpdl_ProcessState_Element_Name=process-state
+Jpdl_SubProcess_Element_Name=sub-process
+Folder_Name_Separator=.
+Translate_Error_JpdlWriter_Null=The JPDL Writer is null.
+Translate_Error_JpdlProcess_Definition_Null=The JPDL process definition is null.
+Translate_Error_JpdlFile_CanNotGenerate=Couldn't write process definition xml:
+Translate_Error_JpdlFile_CanNotWrite=Couldn't write process definition to a jpdl file:
+Translate_Error_BpmnFile_CanNotRead=Couldn't read bpmn file:
+Translate_Error_Bpmn_Element_Name= The bpmn element's name is null or same to another element's name:
+Translate_Warning_Bpmn_Element_Type=The type of this bpmn element is not translated to corresponding jpdl element:
\ No newline at end of file
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2JMessages.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2JMessages.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/messages/B2JMessages.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,39 @@
+package org.jboss.tools.b2j.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class B2JMessages {
+
+ private static final String BUNDLE_NAME = "org.jboss.tools.b2j.messages.B2J"; //$NON-NLS-1$
+
+ private B2JMessages() {
+ // Do not instantiate
+ }
+
+ public static String Loop_Decision;
+ public static String Loop_Decision_Description;
+ public static String To;
+ public static String Bpmn_Suffix;
+ public static String Workspace_Prefix;
+ public static String Folder_Name_Separator;
+ 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;
+ public static String Jpdl_Transition_Element;
+ public static String Jpdl_Element_Name;
+ public static String Translate_Error_JpdlWriter_Null;
+ 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_BpmnFile_CanNotRead;
+ public static String Translate_Error_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: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,321 @@
+package org.jboss.tools.b2j.translate;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.stp.bpmn.*;
+import org.jboss.tools.b2j.B2J;
+import org.jboss.tools.b2j.messages.B2JMessages;
+import org.jbpm.graph.def.*;
+import org.jbpm.graph.node.*;
+
+public class BPMN2JPDL {
+
+ IFile bpmnFile;
+ IFile[] jpdlFiles;
+ List<ProcessDefinition> processDefs = new LinkedList<ProcessDefinition>();
+ Map<String, String> map = new HashMap<String, String>();
+
+ List<String> warnings = new ArrayList<String>();
+ 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 IFile[] getJpdlFiles() {
+ return jpdlFiles;
+ }
+
+ public IFile getBpmnFile() {
+ return bpmnFile;
+ }
+
+ public void setBpmnFile(IFile bpmnFile) {
+ this.bpmnFile = bpmnFile;
+ }
+
+ public BPMN2JPDL() {
+ }
+
+ public BPMN2JPDL(IFile bpmnFile) {
+ this.bpmnFile = bpmnFile;
+ }
+
+ /*
+ * Translate a bpmn diagram to string[]. Every string is jpdl process
+ * definition
+ */
+ public String[] translateToStrings() {
+ this.translateDiagram(this.bpmnFile);
+ String[] strForProcessDefs = new String[processDefs.size()];
+
+ JpdlXmlWriter writer = new JpdlXmlWriter();
+ int i = 0;
+ for (ProcessDefinition def : processDefs) {
+ writer.setWriter(new StringWriter());
+ writer.setUseNamespace(true);
+ strForProcessDefs[i] = translatetoString(writer, def);
+ this.errors.addAll(writer.getProblems());
+ i++;
+ }
+
+ return strForProcessDefs;
+ }
+
+ /*
+ * Tranlate a jpdl process definition to a string
+ */
+ private String translatetoString(JpdlXmlWriter writer, ProcessDefinition def) {
+ return writer.toString(def);
+ }
+
+ /*
+ * Translate a bpmn diagram to file[]. Every file is a jpdl file
+ */
+ public void translateToFiles() {
+ String[] strForProcessDefs = translateToStrings();
+ String[] jpdlFileNames = new String[processDefs.size()];
+
+ int i = 0;
+ for (ProcessDefinition def : processDefs) {
+ jpdlFileNames[i] = def.getName();
+ i++;
+ }
+
+ try {
+ jpdlFiles = TranslateHelper.createJpdlFiles(this.getBpmnFile(),
+ strForProcessDefs, jpdlFileNames);
+ } catch (CoreException e) {
+ errors.add(B2JMessages.Translate_Error_JpdlFile_CanNotWrite
+ + e.getMessage());
+ }
+
+ if (errors.size() != 0) {
+ for (String str : errors) {
+ B2J.getDefault().logError(str);
+ }
+ }
+
+ if (warnings.size() != 0) {
+ for (String str : warnings) {
+ B2J.getDefault().logWarning(str);
+ }
+ }
+ }
+
+ /*
+ * Translate a bpmn diagram to jpdl process definitions
+ */
+ public void translateDiagram(IFile bpmnFile) {
+ BpmnDiagram bpmnDiagram = null;
+ try {
+ bpmnDiagram = TranslateHelper.getBpmnDiagram(bpmnFile);
+ } catch (IOException e) {
+ errors.add(B2JMessages.Translate_Error_BpmnFile_CanNotRead
+ + e.getMessage());
+ }
+ for (Pool pool : bpmnDiagram.getPools()) {
+ ProcessDefinition processDef = new ProcessDefinition();
+ translateGraph(pool, processDef);
+ }
+
+ }
+
+ /*
+ * Translate a bpmn graph(pool or subprocess) to a jpdl process difinition
+ */
+ private void translateGraph(Graph graph, ProcessDefinition processDef) {
+
+ processDef.setName(TranslateHelper
+ .generateProcessName((NamedBpmnObject) graph));
+ processDef.setDescription(graph.getDocumentation());
+
+ for (Vertex activity : graph.getVertices()) {
+ if (activity instanceof Activity) {
+ translateActivity((Activity) activity, processDef);
+ }
+ }
+ translateSequenceFlows(graph, processDef);
+ processDefs.add(processDef);
+
+ }
+
+ /*
+ * Translate a bpmn activity to a jpdl node according to activity type
+ */
+ private void translateActivity(Activity activity,
+ ProcessDefinition processDef) {
+ ActivityType type = activity.getActivityType();
+ Node 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 (ActivityType.TASK == type.getValue()) {
+ element = new Node();
+ } else if (ActivityType.SUB_PROCESS == type.getValue()) {
+ element = new ProcessState();
+ translateSubprocess((Graph) activity, (ProcessState) element);
+ } else if (ActivityType.EVENT_START_EMPTY <= type.getValue()
+ && type.getValue() <= ActivityType.EVENT_START_TIMER
+ || ActivityType.EVENT_START_SIGNAL == type.getValue()) {
+ element = new StartState();
+ if (type.getValue() != ActivityType.EVENT_START_EMPTY) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + type.getName());
+ }
+ } else if (ActivityType.EVENT_INTERMEDIATE_EMPTY <= type.getValue()
+ && type.getValue() <= ActivityType.EVENT_INTERMEDIATE_CANCEL
+ || ActivityType.EVENT_INTERMEDIATE_SIGNAL == type.getValue()) {
+ element = new State();
+ if (type.getValue() != ActivityType.EVENT_INTERMEDIATE_EMPTY) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + type.getName());
+ }
+ } else if (ActivityType.EVENT_END_EMPTY <= type.getValue()
+ && type.getValue() <= ActivityType.EVENT_END_CANCEL
+ || ActivityType.EVENT_END_SIGNAL == type.getValue()) {
+ element = new EndState();
+ if (type.getValue() != ActivityType.EVENT_END_EMPTY) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + type.getName());
+ }
+ } else if (ActivityType.GATEWAY_DATA_BASED_EXCLUSIVE <= type.getValue()
+ && type.getValue() <= ActivityType.GATEWAY_EVENT_BASED_EXCLUSIVE
+ || ActivityType.GATEWAY_COMPLEX == type.getValue()) {
+ element = new Decision();
+ if (type.getValue() != ActivityType.GATEWAY_DATA_BASED_EXCLUSIVE) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + type.getName());
+ }
+ } else if (ActivityType.GATEWAY_PARALLEL == type.getValue()
+ || ActivityType.GATEWAY_DATA_BASED_INCLUSIVE == type.getValue()) {
+ if (activity.getIncomingEdges().size() <= 1) {
+ element = new Fork();
+ } else {
+ element = new Join();
+ }
+ if (type.getValue() != ActivityType.GATEWAY_PARALLEL) {
+ warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ + type.getName());
+ }
+ }
+
+ element.setProcessDefinition(processDef);
+ processDef.addNode(element);
+ if (!TranslateHelper.check_mapElementName((NamedBpmnObject) activity,
+ (GraphElement) element)) {
+ warnings.add(B2JMessages.Translate_Error_Bpmn_Element_Name
+ + activity.getID());
+ }
+ map.put(activity.getID(), element.getName());
+
+ // If bpmn activity is loop type, then create a structure to mock it.
+ if (activity.isLooping()) {
+ createMockLoop(activity, element);
+ }
+ activity.getID();
+ }
+
+ /*
+ * Translate a bpmn subprocess to a jpdl processstate and a new jpdl process
+ * difinition
+ */
+ private void translateSubprocess(Graph subProcess, ProcessState element) {
+ ProcessDefinition processDef = new ProcessDefinition();
+ translateGraph(subProcess, processDef);
+ element.setSubProcessDefinition(processDef);
+ }
+
+ /*
+ * Translate bpmn sequenceflows to jpdl transitions
+ */
+ private void translateSequenceFlows(Graph graph,
+ ProcessDefinition processDef) {
+ for (SequenceEdge edge : graph.getSequenceEdges()) {
+ translateSequenceFlow(edge, processDef);
+ }
+ }
+
+ /*
+ * Translate a bpmn sequenceflow to a jpdl transition
+ */
+ private void translateSequenceFlow(SequenceEdge edge,
+ ProcessDefinition processDef) {
+ Transition transition = new Transition();
+ System.out.println(edge.getSource().getID());
+ Node element = processDef.getNode(map.get(edge.getSource().getID()));
+ if (!TranslateHelper.check_mapElementName((NamedBpmnObject) edge,
+ (GraphElement) transition)) {
+ warnings.add(B2JMessages.Translate_Error_Bpmn_Element_Name
+ + edge.getID());
+ }
+ transition.setProcessDefinition(processDef);
+
+ transition.setFrom(element);
+ transition.setTo(processDef.getNode(map.get(edge.getTarget().getID())));
+ element.addLeavingTransition(transition);
+ if (SequenceFlowConditionType.DEFAULT == edge.getConditionType()
+ .getValue()) {
+ // move default transition to the first of transition list
+ element.reorderLeavingTransition(element.getLeavingTransitions()
+ .size() - 1, 0);
+ } else if (SequenceFlowConditionType.EXPRESSION == edge
+ .getConditionType().getValue()) {
+ transition.setCondition("");
+ }
+ }
+
+ /*
+ * create a jpdl decision structure to map bpmn loop activity
+ */
+ private void createMockLoop(Activity activity, Node element) {
+
+ // create a decision
+ Decision decision = new Decision();
+ String name = activity.getName() + B2JMessages.Loop_Decision;
+ decision.setName(name);
+ decision.setDescription(B2JMessages.Loop_Decision_Description);
+ decision.setProcessDefinition(element.getProcessDefinition());
+ element.getProcessDefinition().addNode(decision);
+ map.put(activity.getID(), name);
+
+ // create a transition from element to decision
+ Transition first = new Transition();
+ first.setName(B2JMessages.To + name);
+ first.setFrom(element);
+ first.setTo(decision);
+ first.setProcessDefinition(element.getProcessDefinition());
+ element.addLeavingTransition(first);
+
+ // create a transition from decision to element
+ Transition second = new Transition();
+ second.setName(B2JMessages.To + element.getName());
+ second.setFrom(decision);
+ second.setTo(element);
+ second.setProcessDefinition(element.getProcessDefinition());
+ decision.addLeavingTransition(second);
+
+ }
+
+}
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/JpdlXmlWriter.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/JpdlXmlWriter.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/JpdlXmlWriter.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tools.b2j.translate;
+
+import java.io.*;
+import java.util.*;
+
+import org.dom4j.*;
+import org.dom4j.io.*;
+import org.jboss.tools.b2j.messages.B2JMessages;
+import org.jbpm.graph.def.*;
+import org.jbpm.graph.node.*;
+
+public class JpdlXmlWriter {
+
+ Namespace jbpmNamespace = new Namespace(null,
+ B2JMessages.Jpdl_32_Namespace_Url);
+ Writer writer;
+ boolean useNamespace = false;
+
+ List<String> errors;
+
+ public List<String> getProblems() {
+ return errors;
+ }
+
+ public void setProblems(List<String> errors) {
+ this.errors = errors;
+ }
+
+ public Namespace getJbpmNamespace() {
+ return jbpmNamespace;
+ }
+
+ public void setJbpmNamespace(Namespace jbpmNamespace) {
+ this.jbpmNamespace = jbpmNamespace;
+ }
+
+ public JpdlXmlWriter() {
+ }
+
+ public void addError(String msg) {
+ errors.add(msg);
+ }
+
+ public String toString(ProcessDefinition processDefinition) {
+ write(processDefinition);
+ return writer.toString();
+ }
+
+ public void setUseNamespace(boolean useNamespace) {
+ this.useNamespace = useNamespace;
+ }
+
+ public void write(ProcessDefinition processDefinition) {
+ errors = new ArrayList<String>();
+ if (writer == null) {
+ addError(B2JMessages.Translate_Error_JpdlWriter_Null);
+ }
+ if (processDefinition == null) {
+ addError(B2JMessages.Translate_Error_JpdlProcess_Definition_Null);
+ }
+ try {
+ // collect the actions of the process definition
+ // we will remove each named event action and the remaining ones
+ // will be written
+ // on the process definition.
+ // create a dom4j dom-tree for the process definition
+ Document document = createDomTree(processDefinition);
+
+ // write the dom-tree to the given writer
+ OutputFormat outputFormat = new OutputFormat(" ", true);
+ // OutputFormat outputFormat = OutputFormat.createPrettyPrint();
+ XMLWriter xmlWriter = new XMLWriter(writer, outputFormat);
+ xmlWriter.write(document);
+ xmlWriter.flush();
+ writer.flush();
+ } catch (IOException e) {
+ addError(B2JMessages.Translate_Error_JpdlFile_CanNotGenerate
+ + e.getMessage());
+ }
+ }
+
+ private Document createDomTree(ProcessDefinition processDefinition) {
+ Document document = DocumentHelper.createDocument();
+ Element root = null;
+
+ if (useNamespace) {
+ root = document.addElement(
+ B2JMessages.Jpdl_Process_Definition_Element, jbpmNamespace
+ .getURI());
+ } else {
+ root = document
+ .addElement(B2JMessages.Jpdl_Process_Definition_Element);
+ }
+ addAttribute(root, B2JMessages.Jpdl_Element_Name, processDefinition
+ .getName());
+
+ // write the start-state
+ if (processDefinition.getStartState() != null) {
+ writeStartNode(root, (StartState) processDefinition.getStartState());
+ }
+
+ // write the nodeMap
+ if ((processDefinition.getNodes() != null)
+ && (processDefinition.getNodes().size() > 0)) {
+ writeNodes(root, processDefinition.getNodes());
+ }
+
+ root.addText(System.getProperty("line.separator"));
+
+ return document;
+ }
+
+ private void writeStartNode(Element element, StartState startState) {
+ if (startState != null) {
+ writeNode(addElement(element, getTypeName(startState)), startState);
+ }
+ }
+
+ private void writeNodes(Element parentElement, Collection<?> nodes) {
+ Iterator<?> iter = nodes.iterator();
+ while (iter.hasNext()) {
+ org.jbpm.graph.def.Node node = (org.jbpm.graph.def.Node) iter
+ .next();
+ if (!(node instanceof StartState)) {
+ Element nodeElement = addElement(parentElement, ProcessFactory
+ .getTypeName(node));
+ node.write(nodeElement);
+ writeNode(nodeElement, node);
+ }
+ }
+ }
+
+ private void writeNode(Element element, org.jbpm.graph.def.Node node) {
+ addAttribute(element, B2JMessages.Jpdl_Element_Name, node.getName());
+
+ if (B2JMessages.Jpdl_ProcessState_Element_Name
+ .equals(getTypeName(node))) {
+ Element ele = addElement(element,
+ B2JMessages.Jpdl_SubProcess_Element_Name);
+ addAttribute(ele, B2JMessages.Jpdl_Element_Name,
+ ((ProcessState) node).getSubProcessDefinition().getName());
+ }
+
+ writeTransitions(element, node);
+ }
+
+ private void writeTransitions(Element element, org.jbpm.graph.def.Node node) {
+ if (node.getLeavingTransitionsMap() != null) {
+ Iterator<?> iter = node.getLeavingTransitionsList().iterator();
+ while (iter.hasNext()) {
+ Transition transition = (Transition) iter.next();
+ writeTransition(element
+ .addElement(B2JMessages.Jpdl_Transition_Element),
+ transition);
+ }
+ }
+ }
+
+ private void writeTransition(Element transitionElement,
+ Transition transition) {
+ if (transition.getTo() != null) {
+ transitionElement.addAttribute(B2JMessages.To, transition.getTo()
+ .getName());
+ }
+ if (transition.getName() != null) {
+ transitionElement.addAttribute(B2JMessages.Jpdl_Element_Name,
+ transition.getName());
+ }
+ }
+
+ private Element addElement(Element element, String elementName) {
+ Element newElement = element.addElement(elementName);
+ return newElement;
+ }
+
+ private void addAttribute(Element e, String attributeName, String value) {
+ if (value != null) {
+ e.addAttribute(attributeName, value);
+ }
+ }
+
+ private String getTypeName(Object o) {
+ return ProcessFactory.getTypeName((org.jbpm.graph.def.Node) o);
+ }
+
+ public void setWriter(Writer writer) {
+ this.writer = writer;
+ }
+
+}
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/TranslateHelper.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/TranslateHelper.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/translate/TranslateHelper.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,111 @@
+package org.jboss.tools.b2j.translate;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
+import org.eclipse.stp.bpmn.BpmnDiagram;
+import org.eclipse.stp.bpmn.NamedBpmnObject;
+import org.jboss.tools.b2j.messages.B2JMessages;
+import org.jboss.tools.b2j.util.B2JUtil;
+import org.jbpm.graph.def.GraphElement;
+
+public class TranslateHelper {
+
+ // the map for the bpmn element id : the corresponding generated element
+ static Map<String, Integer> nameMap = new HashMap<String, Integer>();
+
+ /*
+ * get a bpmn diagram from a bpmn file
+ */
+ public static BpmnDiagram getBpmnDiagram(IFile bpmnFile) throws IOException {
+ nameMap.clear();
+ GMFResourceFactory RESOURCE_FACTORY = new GMFResourceFactory();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put(B2JMessages.Bpmn_Suffix, RESOURCE_FACTORY);
+ URI uriBpmn = URI.createURI(B2JMessages.Workspace_Prefix
+ + bpmnFile.getFullPath());
+ Resource resBpmn = resourceSet.createResource(uriBpmn);
+ resBpmn.load(GMFResourceFactory.getDefaultLoadOptions());
+ return (BpmnDiagram) resBpmn.getContents().get(0);
+ }
+
+ /*
+ * map bpmn's NamedBpmnObject to jpdl's GraphElement
+ */
+ public static boolean check_mapElementName(NamedBpmnObject namedObject,
+ GraphElement graphEle) {
+ boolean isOk = true;
+ String name = namedObject.getName();
+
+ if (name == null || "".equals(name)) {
+ name = "jboss_autogen";
+ isOk = false;
+ }
+ Integer i = nameMap.get(name);
+ if (i == null) {
+ graphEle.setName(name);
+ nameMap.put(name, new Integer("1"));
+ } else {
+ graphEle.setName(name + "_" + i);
+ nameMap.put(name, ++i);
+ isOk = false;
+ }
+
+ return isOk;
+ }
+
+ public static IFile[] createJpdlFiles(IFile bpmnFile,
+ String[] strForProcessDefs, String[] jpdlFileNames)
+ throws CoreException {
+ IFolder jpdlFolder = B2JUtil.createFolder(bpmnFile.getParent(),
+ B2JMessages.Jpdl_Suffix);
+ IFolder diagramFolder = B2JUtil.createFolder(jpdlFolder, bpmnFile
+ .getName());
+
+ IFile[] jpdlFiles = new IFile[strForProcessDefs.length];
+ IFolder processFolder = null;
+ int i = 0;
+ ByteArrayInputStream bytes = null;
+ for (String str : strForProcessDefs) {
+ bytes = new ByteArrayInputStream(str.getBytes());
+ processFolder = B2JUtil.createFolder(diagramFolder,
+ jpdlFileNames[i]);
+ jpdlFiles[i] = B2JUtil.createFile(processFolder,
+ B2JMessages.Jpdl_Process_Definition_Name, bytes);
+ i++;
+ }
+ return jpdlFiles;
+ }
+
+ /*
+ * generate a process definition name. the name is composed of the names
+ * from bpmn diagram to the element
+ */
+ public static String generateProcessName(NamedBpmnObject graph) {
+ if (graph instanceof BpmnDiagram) {
+ return graph.getName();
+ } else {
+ String str = generateProcessName((NamedBpmnObject) graph
+ .eContainer());
+ if (str == null) {
+ return graph.getName();
+ } else {
+ return str + B2JMessages.Folder_Name_Separator
+ + graph.getName();
+ }
+ }
+
+ }
+
+}
Added: workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/util/B2JUtil.java
===================================================================
--- workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/util/B2JUtil.java (rev 0)
+++ workspace/grid/org.jboss.tools.b2j/src/org/jboss/tools/b2j/util/B2JUtil.java 2008-08-21 06:47:54 UTC (rev 9838)
@@ -0,0 +1,61 @@
+package org.jboss.tools.b2j.util;
+
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+public class B2JUtil {
+
+ public static IFolder createFolder(IContainer parent, String folderName)
+ throws CoreException {
+ IResource child = parent.findMember(folderName);
+ if (child == null) {
+ IFolder folder = parent.getFolder(new Path(folderName));
+ folder.create(true, true, null);
+ return folder;
+ } else {
+ if (child.getType() == IResource.FOLDER) {
+ return (IFolder) child;
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public static IFile createFile(IContainer parent, String fileName,
+ InputStream inputStream) throws CoreException {
+ IResource child = parent.findMember(fileName);
+
+ if (child != null) {
+ if (child.getType() == IResource.FILE) {
+
+ // We have permission to overwrite so check if file is read-only
+ if (child.getResourceAttributes() != null
+ && child.getResourceAttributes().isReadOnly()) {
+ IFile[] files = new IFile[1];
+ files[0] = (IFile) child;
+ }
+
+ // Change the contents of the existing file.
+ IFile file = parent.getFile(new Path(fileName));
+ file.setContents(inputStream, true, true, null);
+
+ return file;
+
+ } else {
+ return null;
+ }
+ } else {
+ // Create a new file.
+ IFile file = parent.getFile(new Path(fileName));
+ file.create(inputStream, true, null);
+ return file;
+ }
+ }
+
+}
17 years, 8 months
JBoss Tools SVN: r9837 - in workspace/grid: org.jboss.tools.bpmnTo and 21 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-08-21 02:44:26 -0400 (Thu, 21 Aug 2008)
New Revision: 9837
Added:
workspace/grid/org.jboss.tools.bpmnTo/
workspace/grid/org.jboss.tools.bpmnTo/.classpath
workspace/grid/org.jboss.tools.bpmnTo/.project
workspace/grid/org.jboss.tools.bpmnTo/.settings/
workspace/grid/org.jboss.tools.bpmnTo/.settings/org.eclipse.jdt.core.prefs
workspace/grid/org.jboss.tools.bpmnTo/META-INF/
workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF
workspace/grid/org.jboss.tools.bpmnTo/bin/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/B2J.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/action/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/action/B2JAction.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2J.properties
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2JMessages.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/BPMN2JPDL.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/DomXmlWriter.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/GraphicalFileGenerator.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/TranslateHelper.class
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/util/
workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/util/B2JUtil.class
workspace/grid/org.jboss.tools.bpmnTo/build.properties
workspace/grid/org.jboss.tools.bpmnTo/lib/
workspace/grid/org.jboss.tools.bpmnTo/lib/dom4j-1.6.1.jar
workspace/grid/org.jboss.tools.bpmnTo/plugin.properties
workspace/grid/org.jboss.tools.bpmnTo/plugin.xml
workspace/grid/org.jboss.tools.bpmnTo/src/
workspace/grid/org.jboss.tools.bpmnTo/src/org/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/B2J.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action/B2JAction.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/DomXmlWriter.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/TranslateHelper.java
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util/
workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util/B2JUtil.java
Removed:
workspace/grid/org.jboss.tools.b2j/
workspace/grid/org.jboss.tools.bpmn2jpdl/
Log:
test dom translator
Added: workspace/grid/org.jboss.tools.bpmnTo/.classpath
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/.classpath (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/.classpath 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <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: workspace/grid/org.jboss.tools.bpmnTo/.project
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/.project (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/.project 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.bpmnTo</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: workspace/grid/org.jboss.tools.bpmnTo/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/.settings/org.eclipse.jdt.core.prefs 2008-08-21 06:44:26 UTC (rev 9837)
@@ -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: workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/META-INF/MANIFEST.MF 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %PLUGIN_NAME
+Bundle-SymbolicName: org.jboss.tools.bpmnTo;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Activator: org.jboss.tools.b2j.B2J
+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
+Bundle-Vendor: %PLUGIN_PROVIDER
+Import-Package: org.eclipse.core.resources
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/B2J.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/B2J.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/action/B2JAction.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/action/B2JAction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2J.properties
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2J.properties (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2J.properties 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,52 @@
+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
+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
+Jpdl_Suffix=jpdl
+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=Couldn't write gpd.xml:
+Translate_Error_GpdFile_CanNotWrite=Couldn't write gpd definition to a gpd.xml:
+Translate_Error_JpdlProcess_Definition_Null=The JPDL process definition is null.
+Translate_Error_JpdlFile_CanNotGenerate=Couldn't write process definition xml:
+Translate_Error_JpdlFile_CanNotWrite=Couldn't write process definition to a jpdl file:
+Translate_Error_BpmnFile_CanNotRead=Couldn't read or parse bpmn file to a DOM document:
+Translate_Error_BpmnDiagramFile_CanNotRead=Couldn't read or parse bpmn_diagram file to a DOM document:
+Translate_Warning_Bpmn_Element_Name= The bpmn element's name is null or same to another element's name:
+Translate_Warning_Bpmn_Element_Type=The type of this bpmn element is not translated to corresponding jpdl element:
\ No newline at end of file
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2JMessages.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/messages/B2JMessages.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/BPMN2JPDL.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/BPMN2JPDL.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/DomXmlWriter.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/DomXmlWriter.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/GraphicalFileGenerator.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/GraphicalFileGenerator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/TranslateHelper.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/translate/TranslateHelper.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/util/B2JUtil.class
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/bin/org/jboss/tools/b2j/util/B2JUtil.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/build.properties
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/build.properties (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/build.properties 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ lib/dom4j-1.6.1.jar
Added: workspace/grid/org.jboss.tools.bpmnTo/lib/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Property changes on: workspace/grid/org.jboss.tools.bpmnTo/lib/dom4j-1.6.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/grid/org.jboss.tools.bpmnTo/plugin.properties
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/plugin.properties (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/plugin.properties 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,3 @@
+b2jaction=BPMN -> JPDL
+PLUGIN_NAME=BPMNTO
+PLUGIN_PROVIDER=Red Hat, Inc.
\ No newline at end of file
Added: workspace/grid/org.jboss.tools.bpmnTo/plugin.xml
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/plugin.xml (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/plugin.xml 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.jboss.tools.b2j.objectContribution.bpmnfile"
+ nameFilter="*.bpmn"
+ objectClass="org.eclipse.core.resources.IFile">
+ <action
+ label="%b2jaction"
+ class="org.jboss.tools.b2j.action.B2JAction"
+ menubarPath="additions"
+ enablesFor="1"
+ id="org.jboss.tools.b2j.Bpmn2JpdlAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/B2J.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/B2J.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/B2J.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.b2j;
+
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Grid Qian
+ *
+ * this a plugin class
+ */
+public class B2J extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.b2j";
+
+ // The shared instance
+ private static B2J plugin;
+
+ /**
+ * The constructor
+ */
+ public B2J() {
+ }
+
+ /*
+ * (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 B2J getDefault() {
+ return plugin;
+ }
+
+}
Added: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action/B2JAction.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action/B2JAction.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/action/B2JAction.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.b2j.action;
+
+import org.dom4j.Document;
+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.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.b2j.messages.B2JMessages;
+import org.jboss.tools.b2j.translate.BPMN2JPDL;
+import org.jboss.tools.b2j.translate.GraphicalFileGenerator;
+import org.jboss.tools.b2j.translate.TranslateHelper;
+import org.jboss.tools.b2j.util.B2JUtil;
+
+/**
+ * @author Grid Qian
+ *
+ * the popup menu action for bpmn ->jpdl
+ */
+public class B2JAction implements IObjectActionDelegate {
+
+ private IFile bpmnFile;
+
+ public void setActivePart(IAction arg0, IWorkbenchPart part) {
+ // myPart = part;
+ }
+
+ public void run(IAction arg0) {
+ String bpmnFileName = bpmnFile.getName();
+ String bpmnFileParentPath = bpmnFile.getParent().getLocation()
+ .toOSString();
+ Document bpmnDocument = null;
+ try {
+ bpmnDocument = B2JUtil.parse(bpmnFileParentPath, bpmnFileName);
+ } catch (Exception e1) {
+ System.out.println(B2JMessages.Translate_Error_BpmnFile_CanNotRead
+ + e1.getMessage());
+ }
+ BPMN2JPDL translator = new BPMN2JPDL(bpmnFileName, bpmnFileParentPath,
+ bpmnDocument);
+ translator.translateToFiles();
+
+ // generate jpdl gpd file from *.bpmn_diagram
+ String bpmnDiagramFileName = TranslateHelper
+ .getBpmnDiagramName(bpmnFileName);
+ Document bpmnDiagramDocument = null;
+ try {
+ bpmnDiagramDocument = B2JUtil.parse(bpmnFileParentPath,
+ bpmnDiagramFileName);
+ } catch (Exception e1) {
+ System.out
+ .println(B2JMessages.Translate_Error_BpmnDiagramFile_CanNotRead
+ + e1.getMessage());
+ }
+ GraphicalFileGenerator generator = new GraphicalFileGenerator(
+ bpmnDiagramDocument, translator.getMap(), bpmnFileParentPath,
+ bpmnFileName);
+ generator.translateToFiles();
+
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(
+ IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void selectionChanged(IAction arg0, ISelection selection) {
+ bpmnFile = (IFile) ((IStructuredSelection) selection).getFirstElement();
+ }
+
+}
Added: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2J.properties 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,52 @@
+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
+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
+Jpdl_Suffix=jpdl
+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=Couldn't write gpd.xml:
+Translate_Error_GpdFile_CanNotWrite=Couldn't write gpd definition to a gpd.xml:
+Translate_Error_JpdlProcess_Definition_Null=The JPDL process definition is null.
+Translate_Error_JpdlFile_CanNotGenerate=Couldn't write process definition xml:
+Translate_Error_JpdlFile_CanNotWrite=Couldn't write process definition to a jpdl file:
+Translate_Error_BpmnFile_CanNotRead=Couldn't read or parse bpmn file to a DOM document:
+Translate_Error_BpmnDiagramFile_CanNotRead=Couldn't read or parse bpmn_diagram file to a DOM document:
+Translate_Warning_Bpmn_Element_Name= The bpmn element's name is null or same to another element's name:
+Translate_Warning_Bpmn_Element_Type=The type of this bpmn element is not translated to corresponding jpdl element:
\ No newline at end of file
Added: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/messages/B2JMessages.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.b2j.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public class B2JMessages {
+
+ private static final String BUNDLE_NAME = "org.jboss.tools.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 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 Width_Attribute_Name;
+ public static String Height_Attribute_Name;
+ public static String X_Attribute_Name;
+ public static String Y_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 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_BpmnFile_CanNotRead;
+ public static String Translate_Error_BpmnDiagramFile_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: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/BPMN2JPDL.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,402 @@
+/*******************************************************************************
+ * 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.b2j.translate;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.b2j.B2J;
+import org.jboss.tools.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ *
+ * this is a translator for bpmn ->jpdl
+ */
+public class BPMN2JPDL {
+
+ String bpmnFileName;
+ String rootLocation;
+ Document bpmnDocument;
+ List<String> poolIDList;
+ List<Document> processDefs = new LinkedList<Document>();
+ Map<String, Element> map = new HashMap<String, Element>();
+
+ // the warning messages when translate
+ List<String> warnings = new ArrayList<String>();
+
+ // the error messages when translate
+ 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 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) {
+ this.bpmnFileName = bpmnFileName;
+ this.rootLocation = bpmnFilePath;
+ this.poolIDList = poolIDList;
+ this.bpmnDocument = bpmnDocument;
+ }
+
+ /*
+ * Translate a bpmn diagram to string[]. Every string is jpdl process
+ * definition
+ */
+ public String[] translateToStrings() {
+ this.translateDiagram(this.bpmnDocument);
+ 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[] strForProcessDefs = translateToStrings();
+ String[] jpdlFileNames = new String[processDefs.size()];
+
+ int i = 0;
+ for (Document def : processDefs) {
+ jpdlFileNames[i] = def.getName();
+ i++;
+ }
+
+ try {
+ TranslateHelper.createFiles(rootLocation, bpmnFileName,
+ strForProcessDefs, jpdlFileNames,
+ B2JMessages.Jpdl_Process_Definition_Name);
+ } catch (Exception e) {
+ errors.add(B2JMessages.Translate_Error_JpdlFile_CanNotWrite
+ + e.getMessage());
+ }
+
+ if (errors.size() != 0) {
+ for (String str : errors) {
+ B2J.getDefault().logError(str);
+ }
+ }
+
+ if (warnings.size() != 0) {
+ for (String str : warnings) {
+ B2J.getDefault().logWarning(str);
+ }
+ }
+ }
+
+ /*
+ * Translate a bpmn diagram Domument tree to some jpdl process Dom trees
+ */
+ public void translateDiagram(Document bpmnDocument) {
+
+ // 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 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.Space + 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.Space
+ + element.attributeValue(B2JMessages.Dom_Element_Name));
+ second.addAttribute(B2JMessages.To, element
+ .attributeValue(B2JMessages.Dom_Element_Name));
+
+ }
+
+}
Added: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/DomXmlWriter.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/DomXmlWriter.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/DomXmlWriter.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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.b2j.translate;
+
+import java.io.*;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.dom4j.*;
+import org.dom4j.io.*;
+
+/**
+ * @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 LinkedList<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: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/GraphicalFileGenerator.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * 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.b2j.translate;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.b2j.B2J;
+import org.jboss.tools.b2j.messages.B2JMessages;
+
+/**
+ * @author Grid Qian
+ *
+ * this is a translator for bpmn_diagram to gpd of jpdl
+ */
+public class GraphicalFileGenerator {
+
+ String rootLocation;
+ String bpmnFileName;
+ Document document;
+
+ // gpd.xml documents list
+ List<Document> gpdDefs = new LinkedList<Document>();
+ // the pool of gpd.xml name
+ List<String> gpdPoolNames = new LinkedList<String>();
+ Map<String, Element> map = new HashMap<String, Element>();
+
+ // the warning messages when translate
+ List<String> warnings = new ArrayList<String>();
+
+ // the error messages when translate
+ 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 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(this.document);
+ 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[] 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(rootLocation, bpmnFileName,
+ strForGpdDefs, gpdFileNames,
+ B2JMessages.Gpd_Definition_Name);
+ } catch (Exception e) {
+ errors.add(B2JMessages.Translate_Error_GpdFile_CanNotWrite
+ + e.getMessage());
+ }
+
+ if (errors.size() != 0) {
+ for (String str : errors) {
+ B2J.getDefault().logError(str);
+ }
+ }
+
+ if (warnings.size() != 0) {
+ for (String str : warnings) {
+ B2J.getDefault().logWarning(str);
+ }
+ }
+ }
+
+ /*
+ * translate the graphical bpmn_diagram document
+ */
+ private void translateDiagram(Document diagramDocument) {
+ Element rootElement = diagramDocument.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.
+ // For this 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
+ && bpmnID
+ .endsWith(B2JMessages.Bpmn_Vertice_Element_Name)) {
+ bpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
+ TranslateHelper.getPureBpmnID(bpmnID,
+ B2JMessages.Bpmn_Vertice_Element_Name),
+ eleList);
+ xIncre = 50;
+ yIncre = 50;
+ }
+ 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: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/TranslateHelper.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/TranslateHelper.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/translate/TranslateHelper.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * 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.b2j.translate;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.b2j.messages.B2JMessages;
+import org.jboss.tools.b2j.util.B2JUtil;
+
+/**
+ * @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)
+ throws IOException {
+ File jpdlFolder = B2JUtil.createFile(parentFolder,
+ B2JMessages.Jpdl_Suffix, null);
+ File diagramFolder = B2JUtil.createFile(jpdlFolder.getAbsolutePath(),
+ bpmnFileName, null);
+
+ File[] files = new File[strsForGenerate.length];
+ File processFolder = null;
+ int i = 0;
+ for (String str : strsForGenerate) {
+ processFolder = B2JUtil.createFile(diagramFolder.getAbsolutePath(),
+ fileFolders[i], null);
+ files[i] = B2JUtil.createFile(processFolder.getAbsolutePath(),
+ fileName, str);
+ 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;
+
+ }
+
+ /*
+ * 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: workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util/B2JUtil.java
===================================================================
--- workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util/B2JUtil.java (rev 0)
+++ workspace/grid/org.jboss.tools.bpmnTo/src/org/jboss/tools/b2j/util/B2JUtil.java 2008-08-21 06:44:26 UTC (rev 9837)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.b2j.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 javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * @author Grid Qian
+ *
+ * this a util class
+ */
+public class B2JUtil {
+
+ /*
+ * create a file
+ */
+ public static File createFile(String parentFolder, String fileName,
+ String inputStr) throws IOException {
+ File child = new File(parentFolder, fileName);
+ if (inputStr == null) {
+ if (!child.exists()) {
+ child.mkdir();
+ }
+ } else {
+ if (!child.exists()) {
+ 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(B2JUtil.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(B2JUtil
+ .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;
+ }
+
+}
17 years, 8 months
JBoss Tools SVN: r9836 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-08-20 12:48:39 -0400 (Wed, 20 Aug 2008)
New Revision: 9836
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
Log:
PMD violations fix.
catch(Exception ex) blocks changed to catching particular exceptions.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2008-08-20 16:21:32 UTC (rev 9835)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2008-08-20 16:48:39 UTC (rev 9836)
@@ -466,8 +466,8 @@
} else if(object.getParent() instanceof FolderImpl) {
((FolderImpl)object.getParent()).discardChildFile(object);
}
- } catch (Exception e) {
- //ignore
+ } catch (XModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
}
}
if (outline!=null) outline.dispose();
@@ -508,10 +508,9 @@
while(needsUpdate()) {
update0();
}
- } catch (Exception t) {
- ModelUIPlugin.getPluginLog().logError("Error in updating editor", t);
+ } finally {
+ lock2 = false;
}
- lock2 = false;
}
}
@@ -774,7 +773,7 @@
this.fModificationStamp = ((IFileEditorInput)input).getFile()
.getLocation().toFile().lastModified();
}
- } catch (Exception ex) {
+ } finally {
this.fModificationStamp = -1;
}
}
@@ -879,7 +878,7 @@
selectionProvider.addHost("treeEditor", formPage.getSelectionProvider());
//Activate key binding service here
formPage.getEditorSite().getKeyBindingService();
- } catch (Exception ex) {
+ } catch (PartInitException ex) {
ModelUIPlugin.getPluginLog().logError(ex);
}
//getSite().setSelectionProvider(formPage.getSelectionProvider());
17 years, 8 months
JBoss Tools SVN: r9835 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-08-20 12:21:32 -0400 (Wed, 20 Aug 2008)
New Revision: 9835
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/SliderFieldEditor2.java
Log:
PMD violations fix.
catch(Exception ex) blocks changed to catching NumberFormatException.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/SliderFieldEditor2.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/SliderFieldEditor2.java 2008-08-20 14:45:45 UTC (rev 9834)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/SliderFieldEditor2.java 2008-08-20 16:21:32 UTC (rev 9835)
@@ -71,7 +71,7 @@
*/
try {
intValue = Integer.parseInt(valueProvider.getStringValue(true));
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
// Do nothing
}
setPropertyChangeListener(this);
@@ -211,7 +211,7 @@
slider.addSelectionListener(selectionListener);
try {
intValue = Integer.parseInt(valueProvider.getStringValue(true).toString());
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
intValue = DEFAULT_SLIDER_VALUE;
}
@@ -258,7 +258,7 @@
if (null != sliderLabel) {
sliderLabel.setText(weightsString);
}
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
// Do nothing
}
}
17 years, 8 months
JBoss Tools SVN: r9834 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-08-20 10:45:45 -0400 (Wed, 20 Aug 2008)
New Revision: 9834
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
Implements JBIDE-2443 issue.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-08-20 14:43:38 UTC (rev 9833)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-08-20 14:45:45 UTC (rev 9834)
@@ -46,6 +46,7 @@
import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
@@ -89,12 +90,15 @@
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.model.ui.dnd.DnDUtil;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
import org.jboss.tools.common.model.ui.editors.dnd.DropData;
import org.jboss.tools.common.model.ui.editors.dnd.IDropCommand;
import org.jboss.tools.common.model.ui.editors.dnd.JSPTagProposalFactory;
+import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
+import org.jboss.tools.common.model.ui.editors.dnd.context.IDNDTextEditor;
import org.jboss.tools.common.model.ui.editors.dnd.context.InnerDragBuffer;
import org.jboss.tools.common.model.ui.objecteditor.ExtendedProperties;
import org.jboss.tools.common.model.ui.objecteditor.ExtendedPropertiesWizard;
@@ -155,6 +159,7 @@
import org.mozilla.interfaces.nsIDOMMouseEvent;
import org.mozilla.interfaces.nsIDOMMutationEvent;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIFile;
import org.mozilla.interfaces.nsISelection;
import org.mozilla.interfaces.nsISelectionListener;
import org.mozilla.interfaces.nsISupports;
@@ -2772,53 +2777,67 @@
}
public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor,
- String data) {
- onHideTooltip();
+ String data) {
+ onHideTooltip();
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
- visualDropInfo.getDropContainer(), (int) visualDropInfo
- .getDropOffset());
- VpeSourceInnerDropInfo sourceDropInfo = null;
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+ visualDropInfo.getDropContainer(), (int) visualDropInfo
+ .getDropOffset());
+ VpeSourceInnerDropInfo sourceDropInfo = null;
- if (MODEL_FLAVOR.equals(flavor)) {
- XModelObject object = PreferenceModelUtilities.getPreferenceModel()
- .getModelBuffer().source();
- if (object.getFileType() == XModelObject.FILE
- && !TLDUtil.isTaglib(object)) {
- flavor = "application/x-moz-file"; //$NON-NLS-1$
- IFile f = (IFile) EclipseResourceUtil.getResource(object);
- try {
- data = f.getLocation().toFile().toURL().toString();
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- } else {
- String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document) getModel().getAdapter(
- Document.class)).createElement(tagname);
- if (visualDropInfo.getDropContainer() != null) {
- sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
- sourceDragNode, visualDropInfo, true);
- range = selectionBuilder.getSourceSelectionRange(
- sourceDropInfo.getContainer(), sourceDropInfo
- .getOffset());
- }
- }
- }
+// if (MODEL_FLAVOR.equals(flavor)) {
+// XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+// .getModelBuffer().source();
+// if(object == null)
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
- }
- externalDropAny(flavor, data, range, sourceDropInfo == null ? null
- : sourceDropInfo.getContainer());
- }
- }
+ nsIFile aFile = DnDUtil.getDnDFile(mouseEvent);
+ if(aFile!=null){
+ data = aFile.getPath();
+ }
+// if (object.getFileType() == XModelObject.FILE
+// && !TLDUtil.isTaglib(object)) {
+// flavor = "application/x-moz-file"; //$NON-NLS-1$
+// IFile f = (IFile) EclipseResourceUtil.getResource(object);
+// try {
+// data = f.getLocation().toFile().toURL().toString();
+// } catch (Exception e) {
+// VpePlugin.getPluginLog().logError(e);
+// }
+// } else {
+// String tagname = getTagName(object);
+// if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
+// Node sourceDragNode = ((Document) getModel().getAdapter(
+// Document.class)).createElement(tagname);
+// if (visualDropInfo.getDropContainer() != null) {
+// sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
+// sourceDragNode, visualDropInfo, true);
+// range = selectionBuilder.getSourceSelectionRange(
+// sourceDropInfo.getContainer(), sourceDropInfo
+// .getOffset());
+// }
+// }
+
+ if (visualDropInfo.getDropContainer() != null && data!=null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ }
+ externalDropAny(flavor, data, range, sourceDropInfo == null ? null
+ : sourceDropInfo.getContainer());
+
+ DropContext dropContext = new DropContext();
+ IDNDTextEditor textEditor = (IDNDTextEditor) VpeController.this.editPart.getSourceEditor();
+
+ TypedEvent tEvent = new TypedEvent(mouseEvent);
+ dropContext.setFlavor(DnDUtil.kFileMime);
+ dropContext.setMimeData(data);
+ DnDUtil.fireDnDEvent(dropContext, textEditor, tEvent);
+ }
+ }
+
public void onShowTooltip(int x, int y, final String text) {
if (tip != null && !tip.isDisposed())
17 years, 8 months
JBoss Tools SVN: r9833 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-08-20 10:43:38 -0400 (Wed, 20 Aug 2008)
New Revision: 9833
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
Log:
Implements JBIDE-2443 issue.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2008-08-20 14:36:41 UTC (rev 9832)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2008-08-20 14:43:38 UTC (rev 9833)
@@ -140,7 +140,7 @@
* @param event
*/
public void dragOver(nsIDOMEvent event, EditorDomEventListener editorDomEventListener) {
- boolean canDrop = false;
+ boolean canDrop = true;
nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
//in this condition early was check for xulelement
17 years, 8 months
JBoss Tools SVN: r9832 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-08-20 10:36:41 -0400 (Wed, 20 Aug 2008)
New Revision: 9832
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
Log:
Implements JBIDE-2443 issue.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2008-08-20 14:34:55 UTC (rev 9831)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2008-08-20 14:36:41 UTC (rev 9832)
@@ -95,6 +95,7 @@
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.ui.dnd.DnDUtil;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
@@ -864,9 +865,10 @@
}
public void drop(DropTargetEvent event) {
- int offset = getPosition(event.x, event.y);
- selectAndReveal(offset, 0);
- dropContext.runDropCommand(JSPTextEditor.this, event);
+ int offset = getPosition(event.x, event.y);
+ selectAndReveal(offset, 0);
+ DnDUtil.fireDnDEvent(dropContext,JSPTextEditor.this,event);
+
}
public void dropAccept(DropTargetEvent event) {
17 years, 8 months
JBoss Tools SVN: r9831 - in trunk/common/plugins/org.jboss.tools.common.model.ui: src/org/jboss/tools/common/model/ui/dnd and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-08-20 10:34:55 -0400 (Wed, 20 Aug 2008)
New Revision: 9831
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/VpeDnDEvent.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/DnDUtil.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java
Log:
Implements JBIDE-2443 issue.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2008-08-20 13:36:48 UTC (rev 9830)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2008-08-20 14:34:55 UTC (rev 9831)
@@ -113,6 +113,8 @@
org.eclipse.ant.ui,
org.eclipse.core.expressions,
org.eclipse.core.filesystem,
- org.eclipse.wst.html.core
+ org.jboss.tools.vpe.xulrunner,
+ org.eclipse.wst.html.core,
+ org.mozilla.xpcom
Bundle-Version: 2.0.0
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/DnDUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/DnDUtil.java 2008-08-20 13:36:48 UTC (rev 9830)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/DnDUtil.java 2008-08-20 14:34:55 UTC (rev 9831)
@@ -7,61 +7,255 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
+
+
package org.jboss.tools.common.model.ui.dnd;
-import java.util.*;
-import org.jboss.tools.common.model.*;
-import org.jboss.tools.common.meta.action.*;
+import java.util.Properties;
+
+import org.eclipse.swt.events.TypedEvent;
+import org.jboss.tools.common.meta.action.XAction;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
+import org.jboss.tools.common.model.ui.editors.dnd.context.IDNDTextEditor;
+import org.jboss.tools.vpe.xulrunner.XPCOM;
+import org.mozilla.interfaces.nsIComponentManager;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDragService;
+import org.mozilla.interfaces.nsIDragSession;
+import org.mozilla.interfaces.nsIFile;
+import org.mozilla.interfaces.nsIServiceManager;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsITransferable;
+import org.mozilla.xpcom.Mozilla;
+
+
+/**
+ * The Class DnDUtil.
+ */
public class DnDUtil {
-
- public static XAction getEnabledAction(XModelObject object, XModelObject[] targets, String actionpath) {
- if(object == null) return null;
- XAction action = object.getModelEntity().getActionList().getAction(actionpath);
- if(action == null) return null;
- return (targets == null)
- ? ((!action.isEnabled(object)) ? null : action)
- : ((!action.isEnabled(object, targets)) ? null : action);
- }
-
- public static boolean isCopyEnabled(XModelObject object, XModelObject[] targets) {
- return getEnabledCopyAction(object, targets) != null;
- }
-
- public static XAction getEnabledCopyAction(XModelObject object, XModelObject[] targets) {
- return getEnabledAction(object, targets, "CopyActions.Copy");
- }
-
- public static boolean copy(XModelObject object, XModelObject[] targets) {
- XAction copy = getEnabledCopyAction(object, targets);
- if(copy == null) return false;
- try {
- Properties p = new Properties();
- p.setProperty("isDrag", "true");
- if(targets == null) {
- copy.executeHandler(object, p);
- } else {
- copy.executeHandler(object, targets, p);
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public static boolean isPasteEnabled(XModelObject object) {
- return getEnabledPasteAction(object) != null;
- }
-
- public static XAction getEnabledPasteAction(XModelObject object) {
- XAction action = getEnabledAction(object, null, "CopyActions.Paste");
- return (action != null) ? action : getEnabledAction(object, null, "MoveActions.Move");
- }
-
- public static void paste(XModelObject object, Properties properties) throws XModelException {
- XAction paste = getEnabledPasteAction(object);
- if(paste != null) paste.executeHandler(object, properties);
- }
+ /** The Constant kTextMime. */
+ public static final String kTextMime = "text/plain"; //$NON-NLS-1$
+
+ /** The Constant kUnicodeMime. */
+ public static final String kUnicodeMime = "text/unicode"; //$NON-NLS-1$
+
+ /** The Constant kHTMLMime. */
+ public static final String kHTMLMime = "text/html"; //$NON-NLS-1$
+
+ /** The Constant kAOLMailMime. */
+ public static final String kAOLMailMime = "AOLMAIL"; //$NON-NLS-1$
+
+ /** The Constant kPNGImageMime. */
+ public static final String kPNGImageMime = "image/png"; //$NON-NLS-1$
+
+ /** The Constant kJPEGImageMime. */
+ public static final String kJPEGImageMime = "image/jpg"; //$NON-NLS-1$
+
+ /** The Constant kGIFImageMime. */
+ public static final String kGIFImageMime = "image/gif"; //$NON-NLS-1$
+
+ /** The Constant kFileMime. */
+ public static final String kFileMime = "application/x-moz-file"; //$NON-NLS-1$
+
+ /** The Constant kURLMime. */
+ public static final String kURLMime = "text/x-moz-url"; //$NON-NLS-1$
+
+ /** The Constant kURLDataMime. */
+ public static final String kURLDataMime = "text/x-moz-url-data"; //$NON-NLS-1$
+
+ /** The Constant kURLDescriptionMime. */
+ public static final String kURLDescriptionMime = "text/x-moz-url-desc"; //$NON-NLS-1$
+
+ /** The Constant kNativeImageMime. */
+ public static final String kNativeImageMime = "application/x-moz-nativeimage"; //$NON-NLS-1$
+
+ /** The Constant kNativeHTMLMime. */
+ public static final String kNativeHTMLMime = "application/x-moz-nativehtml"; //$NON-NLS-1$
+
+ /** The Constant kFilePromiseURLMime. */
+ public static final String kFilePromiseURLMime = "application/x-moz-file-promise-url"; //$NON-NLS-1$
+
+ /** The Constant kFilePromiseMime. */
+ public static final String kFilePromiseMime = "application/x-moz-file-promise"; //$NON-NLS-1$
+
+ /** The Constant kFilePromiseDirectoryMime. */
+ public static final String kFilePromiseDirectoryMime = "application/x-moz-file-promise-dir"; //$NON-NLS-1$
+
+ /** The Constant FLAVORS. */
+ public static final String[] FLAVORS = { kTextMime, kUnicodeMime, kHTMLMime, kAOLMailMime, kPNGImageMime, kJPEGImageMime,
+ kGIFImageMime, kFileMime, kURLMime, kURLDataMime, kURLDescriptionMime, kNativeImageMime, kNativeHTMLMime, kFilePromiseURLMime,
+ kFilePromiseMime, kFilePromiseDirectoryMime };
+
+ /**
+ * Gets the enabled action.
+ *
+ * @param actionpath the actionpath
+ * @param object the object
+ * @param targets the targets
+ *
+ * @return the enabled action
+ */
+ public static XAction getEnabledAction(XModelObject object, XModelObject[] targets, String actionpath) {
+ if (object == null)
+ return null;
+ XAction action = object.getModelEntity().getActionList().getAction(actionpath);
+ if (action == null)
+ return null;
+ return (targets == null) ? ((!action.isEnabled(object)) ? null : action) : ((!action.isEnabled(object, targets)) ? null : action);
+ }
+
+ /**
+ * Checks if is copy enabled.
+ *
+ * @param object the object
+ * @param targets the targets
+ *
+ * @return true, if is copy enabled
+ */
+ public static boolean isCopyEnabled(XModelObject object, XModelObject[] targets) {
+ return getEnabledCopyAction(object, targets) != null;
+ }
+
+ /**
+ * Gets the enabled copy action.
+ *
+ * @param object the object
+ * @param targets the targets
+ *
+ * @return the enabled copy action
+ */
+ public static XAction getEnabledCopyAction(XModelObject object, XModelObject[] targets) {
+ return getEnabledAction(object, targets, "CopyActions.Copy"); //$NON-NLS-1$
+ }
+
+ /**
+ * Copy.
+ *
+ * @param object the object
+ * @param targets the targets
+ *
+ * @return true, if copy
+ */
+ public static boolean copy(XModelObject object, XModelObject[] targets) {
+ XAction copy = getEnabledCopyAction(object, targets);
+ if (copy == null)
+ return false;
+ try {
+ Properties p = new Properties();
+ p.setProperty("isDrag", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (targets == null) {
+ copy.executeHandler(object, p);
+ } else {
+ copy.executeHandler(object, targets, p);
+ }
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if is paste enabled.
+ *
+ * @param object the object
+ *
+ * @return true, if is paste enabled
+ */
+ public static boolean isPasteEnabled(XModelObject object) {
+ return getEnabledPasteAction(object) != null;
+ }
+
+ /**
+ * Gets the enabled paste action.
+ *
+ * @param object the object
+ *
+ * @return the enabled paste action
+ */
+ public static XAction getEnabledPasteAction(XModelObject object) {
+ XAction action = getEnabledAction(object, null, "CopyActions.Paste"); //$NON-NLS-1$
+ return (action != null) ? action : getEnabledAction(object, null, "MoveActions.Move"); //$NON-NLS-1$
+ }
+
+ /**
+ * Paste.
+ *
+ * @param object the object
+ * @param properties the properties
+ *
+ * @throws XModelException the X model exception
+ */
+ public static void paste(XModelObject object, Properties properties) throws XModelException {
+ XAction paste = getEnabledPasteAction(object);
+ if (paste != null)
+ paste.executeHandler(object, properties);
+ }
+
+ /**
+ * Convert2 vpe dn D event.
+ *
+ * @param event the event
+ *
+ * @return the vpe dn D event
+ */
+ public static VpeDnDEvent convert2VpeDnDEvent(nsIDOMEvent event) {
+ return null;
+
+ }
+
+ /**
+ * Fire dn D event.
+ *
+ * @param dropContext the drop context
+ * @param event the event
+ * @param textEditor the text editor
+ */
+ public static void fireDnDEvent(DropContext dropContext, IDNDTextEditor textEditor, TypedEvent event) {
+
+ dropContext.runDropCommand(textEditor, event);
+ }
+
+ /**
+ * Gets the dn D file.
+ *
+ * @param event the event
+ *
+ * @return the dn D file
+ */
+ public static nsIFile getDnDFile(nsIDOMEvent event) {
+ nsIFile aFile = null;
+ nsIServiceManager serviceManager = Mozilla.getInstance().getServiceManager();
+ nsIComponentManager componentManager = Mozilla.getInstance().getComponentManager();
+ nsIDragService dragService = (nsIDragService) serviceManager.getServiceByContractID("@mozilla.org/widget/dragservice;1", //$NON-NLS-1$
+ nsIDragService.NS_IDRAGSERVICE_IID);
+ final nsIDragSession dragSession = dragService.getCurrentSession();
+
+ final nsITransferable iTransferable = (nsITransferable) componentManager.createInstanceByContractID(
+ XPCOM.NS_TRANSFERABLE_CONTRACTID, null, nsITransferable.NS_ITRANSFERABLE_IID);
+
+ for (String flavor1 : FLAVORS) {
+ if (dragSession.isDataFlavorSupported(flavor1)) {
+ iTransferable.addDataFlavor(flavor1);
+ System.out.println("\n->" + flavor1); //$NON-NLS-1$
+ }
+ }
+ String[] aFlavor = { "" }; //$NON-NLS-1$
+ long[] aDataLen = { 0 };
+ nsISupports[] aData = { null };
+
+ dragSession.getData(iTransferable, 0);
+
+ iTransferable.getAnyTransferData(aFlavor, aData, aDataLen);
+ System.out.println("aData[0] className = " + aData[0].getClass().getName()); //$NON-NLS-1$
+
+
+ aFile = (nsIFile) aData[0].queryInterface(nsIFile.NS_IFILE_IID);
+ return aFile;
+ }
+
}
Added: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/VpeDnDEvent.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/VpeDnDEvent.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/VpeDnDEvent.java 2008-08-20 14:34:55 UTC (rev 9831)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.common.model.ui.dnd;
+
+
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.events.TypedEvent;
+
+
+/**
+ * The Class VpeDnDEvent.
+ *
+ * @author Evgenij Stherbin
+ */
+public class VpeDnDEvent extends TypedEvent {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 4032394561953756746L;
+
+ /** The x-cordinate of the cursor relative to the <code>Display</code>. */
+ private int x;
+
+ /** The y-cordinate of the cursor relative to the <code>Display</code>. */
+ private int y;
+
+ /** A list of the types of data that the DragSource is capable of providing. The currentDataType must be a member of this list. */
+ private TransferData[] dataTypes;
+
+ /** The type of data that will be dropped. */
+ public TransferData currentDataType;
+
+ /**
+ * Gets the current data type.
+ *
+ * @return the current data type
+ */
+ public TransferData getCurrentDataType() {
+ return currentDataType;
+ }
+
+ /**
+ * Sets the current data type.
+ *
+ * @param currentDataType the current data type
+ */
+ public void setCurrentDataType(TransferData currentDataType) {
+ this.currentDataType = currentDataType;
+ }
+
+ /**
+ * Gets the data types.
+ *
+ * @return the data types
+ */
+ public TransferData[] getDataTypes() {
+ return dataTypes;
+ }
+
+ /**
+ * Sets the data types.
+ *
+ * @param dataTypes the data types
+ */
+ public void setDataTypes(TransferData[] dataTypes) {
+ this.dataTypes = dataTypes;
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param source the source
+ */
+ public VpeDnDEvent(Object source) {
+ super(source);
+
+ }
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/VpeDnDEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java 2008-08-20 13:36:48 UTC (rev 9830)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java 2008-08-20 14:34:55 UTC (rev 9831)
@@ -171,7 +171,7 @@
// VpePlugin.reportProblem(e);
ModelUIPlugin.getPluginLog().logError(e);
}
- IFile file = EclipseResourceUtil.getFile(newUrl.getPath());
+ IFile file = EclipseResourceUtil.getFile(newUrl == null ? dropData.getMimeData() : newUrl.getPath());
if(file != null && file.exists()) return file;
file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
new Path(newUrl.getPath())
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java 2008-08-20 13:36:48 UTC (rev 9830)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java 2008-08-20 14:34:55 UTC (rev 9831)
@@ -20,21 +20,22 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.HTMLTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.events.TypedEvent;
import org.eclipse.wst.sse.ui.internal.TextDropAction;
-
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.XModelTransferBuffer;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
+import org.jboss.tools.common.model.ui.dnd.VpeDnDEvent;
+import org.jboss.tools.common.model.ui.editors.dnd.FileTagProposalLoader;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.model.ui.editors.dnd.FileTagProposalLoader;
import org.jboss.tools.jst.web.tld.TLDUtil;
/**
@@ -46,9 +47,17 @@
private String attributeName = null;
private String flavor = null;
private String mimeData = null;
- private DropTargetEvent event;
+ private TypedEvent event;
- public void clean() {
+ public void setFlavor(String flavor) {
+ this.flavor = flavor;
+ }
+
+ public void setMimeData(String mimeData) {
+ this.mimeData = mimeData;
+ }
+
+ public void clean() {
isOverAttributeValue = false;
flavor = null;
mimeData = null;
@@ -87,19 +96,28 @@
new TransferHolder(TextTransfer.getInstance(), new TextTransferProcessor()),
};
- public void setDropTargetEvent(DropTargetEvent event) {
+ public void setDropTargetEvent(TypedEvent event) {
this.event = event;
- TransferData[] ds = event.dataTypes;
+
+ TransferData[] ds = null;
+ if(this.event instanceof DropTargetEvent){
+ ds = ((DropTargetEvent)event).dataTypes;
+ }else if(this.event instanceof VpeDnDEvent){
+ ds = ((VpeDnDEvent)this.event).getDataTypes();
+ }
+ if(ds!=null){
for (int i = 0; i < TRANSFERS.length; i++) {
TransferData data = TRANSFERS[i].getSupportedData(ds);
if(data != null) {
TRANSFERS[i].process(data);
break;
- }
+ }
+
}
+ }
}
- private String getURL(DropTargetEvent event) {
+ private String getURL(TypedEvent event) {
String[] s = (String[])event.data;
if(s == null || s.length == 0) return null;
File f = new File(s[0]);
@@ -109,7 +127,7 @@
return s[0];
}
}
- private File getFile(DropTargetEvent event) {
+ private File getFile(TypedEvent event) {
String[] s = (String[])event.data;
return(s == null || s.length == 0) ? null : new File(s[0]);
}
@@ -127,7 +145,7 @@
return null;
}
- public void runDropCommand(IDNDTextEditor editor, DropTargetEvent event) {
+ public void runDropCommand(IDNDTextEditor editor, TypedEvent event) {
setDropTargetEvent(event);
runDropCommand(editor);
}
@@ -135,8 +153,9 @@
public void runDropCommand(IDNDTextEditor editor) {
if(event == null) return;
if(getFlavor() == null) {
- } else if (getFlavor().equals("text/html")) {
- new TextDropAction().run(event, editor);
+ return;
+ } else if (getFlavor().equals("text/html") && this.event instanceof DropTargetEvent) {
+ new TextDropAction().run((DropTargetEvent) event, editor);
} else {
editor.runDropCommand(getFlavor(), getMimeData());
}
@@ -191,7 +210,14 @@
class HTMLTransferProcessor extends TransferProcessor {
public void process(TransferData data) {
flavor = "text/html";
- Object ooo = HTMLTransfer.getInstance().nativeToJava(event.currentDataType);
+ TransferData currentDataType = null;
+ if(event instanceof DropTargetEvent){
+ currentDataType = (( DropTargetEvent)event).currentDataType;
+ }else if(event instanceof VpeDnDEvent){
+ currentDataType = ((VpeDnDEvent)event).currentDataType;
+ }
+ Object ooo = HTMLTransfer.getInstance().nativeToJava(currentDataType);
+
mimeData = ooo == null ? null : ooo.toString();
if(mimeData == null) {
flavor = null;
17 years, 8 months