Author: objectiser
Date: 2008-10-22 13:46:47 -0400 (Wed, 22 Oct 2008)
New Revision: 414
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/.settings/org.eclipse.jdt.ui.prefs
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/actions/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/actions/GenerateValidatorAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/dialogs/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/dialogs/GenerateValidatorDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/generator/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/generator/ValidatorGenerator.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/plugin.xml
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/eclipse/Activator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/annotations/cdl/jbossesb.presentation
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/plugin.xml
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/eclipse/Activator.java
Log:
Added dialog and generator for the validator configuration file.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/plugin.xml
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/plugin.xml 2008-10-22
17:21:14 UTC (rev 413)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/plugin.xml 2008-10-22
17:46:47 UTC (rev 414)
@@ -25,7 +25,7 @@
<separator name="group2"/>
</menu>
<action
- label="Generate"
+ label="Generate ESB Services"
class="org.jboss.tools.overlord.cdl.runtime.jbossesb.actions.GenerateAction"
menubarPath="org.jboss.tools.overlord.menu/jbossesb.menu/group2"
enablesFor="1"
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/eclipse/Activator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/eclipse/Activator.java 2008-10-22
17:21:14 UTC (rev 413)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/eclipse/Activator.java 2008-10-22
17:46:47 UTC (rev 414)
@@ -88,5 +88,5 @@
(t == null ? "" : ": "+t));
}
- private static Logger logger =
Logger.getLogger("org.pi4soa.service.generation.eclipse");
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.eclipse");
}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/.settings/org.eclipse.jdt.ui.prefs
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/.settings/org.eclipse.jdt.ui.prefs
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/.settings/org.eclipse.jdt.ui.prefs 2008-10-22
17:46:47 UTC (rev 414)
@@ -0,0 +1,4 @@
+#Wed Oct 22 11:13:10 BST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0"
encoding\="UTF-8"?><templates><template autoinsert\="true"
context\="gettercomment_context" deleted\="false"
description\="Comment for getter method" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n
*/</template><template autoinsert\="true"
context\="settercomment_context" deleted\="false"
description\="Comment for setter method" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.settercomment"
name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to
set\r\n */</template><template autoinsert\="true"
context\="constructorcomment_context" deleted\="false"
description\="Comment for created constructors" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"
name\="constructorcomment">/**\r\n * ${tags}\r\n
*/</template><template autoinsert\="true"
context\="filecomment_cont!
ext" deleted\="false" description\="Comment for created Java
files" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.filecomment"
name\="filecomment">/**\r\n * \r\n */</template><template
autoinsert\="false" context\="typecomment_context"
deleted\="false" description\="Comment for created types"
enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.typecomment"
name\="typecomment">/**\r\n *\r\n * ${tags}\r\n
*/</template><template autoinsert\="true"
context\="fieldcomment_context" deleted\="false"
description\="Comment for fields" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"
name\="fieldcomment">/**\r\n * \r\n */</template><template
autoinsert\="true" context\="methodcomment_context"
deleted\="false" description\="Comment for non-overriding methods"
enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment"
name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template
autoinsert\="true" context\="overridecomment!
_context" deleted\="false" description\="Comment for overriding
method
s" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n
*/</template><template autoinsert\="true"
context\="delegatecomment_context" deleted\="false"
description\="Comment for delegate methods" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n
*/</template><template autoinsert\="false"
context\="newtype_context" deleted\="false" description\="Newly
created files" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.newtype"
name\="newtype">/*\r\n * JBoss, Home of Professional Open Source\r\n *
Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated\r\n * by the
@authors tag. All rights reserved.\r\n * See the copyright.txt in the distribution for
a\r\n * full listing of individual contributors.\r\n * This copyrighted material is made
available to anyone wishing !
to use,\r\n * modify, copy, or redistribute it subject to the terms and conditions\r\n *
of the GNU Lesser General Public License, v. 2.1.\r\n * This program is distributed in the
hope that it will be useful, but WITHOUT A\r\n * WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A\r\n * PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.\r\n * You should have received a copy of the GNU
Lesser General Public License,\r\n * v.2.1 along with this distribution; if not, write to
the Free Software\r\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\r\n *
MA 02110-1301, USA.\r\n
*/\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template
autoinsert\="true" context\="classbody_context"
deleted\="false" description\="Code in new class type bodies"
enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody"
name\="classbody">\r\n</template><template
autoinsert\="true" con!
text\="interfacebody_context" deleted\="false"
description\="Code in n
ew interface type bodies" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody"
name\="interfacebody">\r\n</template><template
autoinsert\="true" context\="enumbody_context"
deleted\="false" description\="Code in new enum type bodies"
enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody"
name\="enumbody">\r\n</template><template
autoinsert\="true" context\="annotationbody_context"
deleted\="false" description\="Code in new annotation type bodies"
enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody"
name\="annotationbody">\r\n</template><template
autoinsert\="true" context\="catchblock_context"
deleted\="false" description\="Code in new catch blocks"
enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock"
name\="catchblock">// ${todo} Auto-generated catch
block\r\n${exception_var}.printStackTrace();</template><template
autoinsert\="true" context\="methodbody_context"
deleted\="false" description\="Code in!
created method stubs" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.methodbody"
name\="methodbody">// ${todo} Auto-generated method
stub\r\n${body_statement}</template><template autoinsert\="true"
context\="constructorbody_context" deleted\="false"
description\="Code in created constructor stubs" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody"
name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated
constructor stub</template><template autoinsert\="true"
context\="getterbody_context" deleted\="false" description\="Code
in created getters" enabled\="true"
id\="org.eclipse.jdt.ui.text.codetemplates.getterbody"
name\="getterbody">return ${field};</template><template
autoinsert\="true" context\="setterbody_context"
deleted\="false" description\="Code in created setters"
enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody"
name\="setterbody">${field} \= ${param};</template><template
autoinsert\="true" cont!
ext\="gettercomment_context" deleted\="false"
description\="Comment fo
r getter function" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.gettercomment"
name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n
*/</template><template autoinsert\="true"
context\="settercomment_context" deleted\="false"
description\="Comment for setter function" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.settercomment"
name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to
set\r\n */</template><template autoinsert\="true"
context\="constructorcomment_context" deleted\="false"
description\="Comment for created constructors" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorcomment"
name\="constructorcomment">/**\r\n * ${tags}\r\n
*/</template><template autoinsert\="true"
context\="filecomment_context" deleted\="false"
description\="Comment for created JavaScript files" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.filecomment"
name\="filecomment">/**\r\n * \!
r\n */</template><template autoinsert\="true"
context\="typecomment_context" deleted\="false"
description\="Comment for created types" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.typecomment"
name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n
*/</template><template autoinsert\="true"
context\="fieldcomment_context" deleted\="false"
description\="Comment for vars" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.fieldcomment"
name\="fieldcomment">/**\r\n * \r\n */</template><template
autoinsert\="true" context\="methodcomment_context"
deleted\="false" description\="Comment for non-overriding function"
enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodcomment"
name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template
autoinsert\="true" context\="overridecomment_context"
deleted\="false" description\="Comment for overriding functions"
enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplat!
es.overridecomment" name\="overridecomment">/* (non-Jsdoc)\r\n * ${see
_to_overridden}\r\n */</template><template autoinsert\="true"
context\="delegatecomment_context" deleted\="false"
description\="Comment for delegate functions" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.delegatecomment"
name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n
*/</template><template autoinsert\="true"
context\="newtype_context" deleted\="false" description\="Newly
created files" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.newtype"
name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template
autoinsert\="true" context\="classbody_context"
deleted\="false" description\="Code in new class type bodies"
enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.classbody"
name\="classbody">\r\n</template><template
autoinsert\="true" context\="catchblock_context"
deleted\="false" description\="Code in new catch blocks"
enabled\="true" id\="org.ecli!
pse.wst.jsdt.ui.text.codetemplates.catchblock" name\="catchblock">//
${todo} Auto-generated catch
block\r\n${exception_var}.printStackTrace();</template><template
autoinsert\="true" context\="methodbody_context"
deleted\="false" description\="Code in created function stubs"
enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodbody"
name\="methodbody">// ${todo} Auto-generated function
stub\r\n${body_statement}</template><template autoinsert\="true"
context\="constructorbody_context" deleted\="false"
description\="Code in created constructor stubs" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorbody"
name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated
constructor stub</template><template autoinsert\="true"
context\="getterbody_context" deleted\="false" description\="Code
in created getters" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.getterbody"
name\="getterbody">return ${field};</template><!
template autoinsert\="true" context\="setterbody_context"
deleted\="fa
lse" description\="Code in created setters" enabled\="true"
id\="org.eclipse.wst.jsdt.ui.text.codetemplates.setterbody"
name\="setterbody">${field} \= ${param};</template></templates>
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/META-INF/MANIFEST.MF
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/META-INF/MANIFEST.MF 2008-10-22
17:21:14 UTC (rev 413)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/META-INF/MANIFEST.MF 2008-10-22
17:46:47 UTC (rev 414)
@@ -7,6 +7,8 @@
Bundle-Vendor:
www.jboss.org
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.pi4soa.common;bundle-version="2.0.0"
+ org.pi4soa.common;bundle-version="2.0.0",
+ org.eclipse.core.resources;bundle-version="3.4.0",
+ org.pi4soa.cdl;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/annotations/cdl/jbossesb.presentation
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/annotations/cdl/jbossesb.presentation 2008-10-22
17:21:14 UTC (rev 413)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/annotations/cdl/jbossesb.presentation 2008-10-22
17:46:47 UTC (rev 414)
@@ -1,5 +1,3 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
-The JBossESB Service destination is <xsl:if test="jbossesb/destination/@name !=
''" >'<xsl:value-of select="jbossesb/destination/@name"
/>' </xsl:if><xsl:if test="jbossesb/destination/@name =
''" >'undefined' </xsl:if> [temporary=<xsl:value-of
select="jbossesb/destination/@temporary"/>]
-</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+The JBossESB Service destination is <xsl:if test="jbossesb/destination/@name !=
''" >'<xsl:value-of select="jbossesb/destination/@name"
/>' </xsl:if><xsl:if test="jbossesb/destination/@name =
''" >'undefined' </xsl:if> [temporary=<xsl:value-of
select="jbossesb/destination/@temporary"/>]</xsl:template></xsl:stylesheet>
\ No newline at end of file
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/plugin.xml
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/plugin.xml 2008-10-22
17:21:14 UTC (rev 413)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/plugin.xml 2008-10-22
17:46:47 UTC (rev 414)
@@ -8,4 +8,36 @@
</annotationsManager>
</extension>
+ <extension
+ id="org.jboss.tools.overlord.cdl.validator.jbossesb.extension"
+ name="Overlord CDL Validator JBossESB extension"
+ point="org.scribble.extension">
+ </extension>
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.jboss.tools.overlord.cdl.validator.jbossesb.object.contribution"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.cdm">
+ <menu
+ id="org.jboss.tools.overlord.menu"
+ label="Overlord"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <menu
+ id="jbossesb.menu"
+ label="JBossESB"
+ path="org.jboss.tools.overlord.menu/additions">
+ <separator name="group2"/>
+ </menu>
+ <action
+ label="Generate Validator"
+
class="org.jboss.tools.overlord.cdl.validator.jbossesb.actions.GenerateValidatorAction"
+ menubarPath="org.jboss.tools.overlord.menu/jbossesb.menu/group2"
+ enablesFor="1"
+
id="org.jboss.tools.overlord.cdl.validator.jbossesb.actions.GenerateAction">
+ </action>
+ </objectContribution>
+ </extension>
</plugin>
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/actions/GenerateValidatorAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/actions/GenerateValidatorAction.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/actions/GenerateValidatorAction.java 2008-10-22
17:46:47 UTC (rev 414)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.validator.jbossesb.actions;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.pi4soa.common.resource.eclipse.*;
+
+import org.jboss.tools.overlord.cdl.validator.jbossesb.dialogs.*;
+
+/**
+ * This class implements the action to generate the JBossESB
+ * validator configuration associated with a supplied choreography.
+ */
+public class GenerateValidatorAction implements IObjectActionDelegate {
+
+ private static final String CANNOT_GENERATE = "Choreography has errors, so cannot
generate";
+
+ public GenerateValidatorAction() {
+ }
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ if (res instanceof IFile) {
+
+ if (ResourceUtil.hasErrors(res) == false) {
+
+ // Load the CDL model
+ org.pi4soa.cdl.Package cdlpack=null;
+ String path=res.getLocation().toOSString();
+
+ try {
+ cdlpack = org.pi4soa.cdl.CDLManager.load(path);
+
+ } catch(java.io.IOException ioe) {
+ logger.severe("Failed to load CDL '"+path+"': "+ioe);
+ }
+
+ GenerateValidatorDialog dialog=
+ new GenerateValidatorDialog(m_targetPart.getSite().getShell(),
+ (IFile)res, cdlpack);
+
+ try {
+ dialog.open();
+ } catch(Throwable e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to open generate dialog", e);
+ }
+ } else {
+ warn(CANNOT_GENERATE);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+
+ /**
+ * This method is used to report a warning.
+ *
+ * @param mesg The warning message
+ */
+ public void warn(String mesg) {
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_WARNING|SWT.OK);
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.validator.jbossesb.actions");
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/dialogs/GenerateValidatorDialog.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/dialogs/GenerateValidatorDialog.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/dialogs/GenerateValidatorDialog.java 2008-10-22
17:46:47 UTC (rev 414)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.validator.jbossesb.dialogs;
+
+import java.util.logging.Logger;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.overlord.cdl.validator.jbossesb.generator.*;
+
+/**
+ * This class provides the dialog for generating JBossESB
+ * service artefacts.
+ */
+public class GenerateValidatorDialog extends org.eclipse.jface.dialogs.Dialog {
+
+ /**
+ * This is the constructor for the generate dialog.
+ *
+ * @param shell The shell
+ * @param cdlpack The CDL
+ */
+ public GenerateValidatorDialog(Shell shell, IFile file,
+ org.pi4soa.cdl.Package cdlpack) {
+ super(shell);
+
+ m_file = file;
+ m_choreography = cdlpack;
+ }
+
+ /**
+ * Configure the dialog shell.
+ *
+ * @param shell The shell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ newShell.setText("Generate Validator for "+
+ m_choreography.getName());
+ }
+
+ /**
+ * This method creates the dialog details.
+ *
+ * @param parent The parent control
+ * @return The control containing the dialog components
+ */
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite=(Composite)super.createDialogArea(parent);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+
+ GridData gd=null;
+
+ Group group=new Group(composite, SWT.H_SCROLL|SWT.V_SCROLL);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.widthHint = 500;
+ gd.grabExcessHorizontalSpace = true;
+ group.setLayoutData(gd);
+
+ layout = new GridLayout();
+ layout.numColumns = 4;
+ group.setLayout(layout);
+
+ Label label2=new Label(group, SWT.NONE);
+ label2.setText("File path:");
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.grabExcessHorizontalSpace = true;
+ gd.widthHint = 100;
+ label2.setLayoutData(gd);
+
+ // Path
+ m_path = new Text(group, SWT.SINGLE | SWT.BORDER);
+ m_path.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL |
GridData.HORIZONTAL_ALIGN_FILL));
+
+ m_path.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ checkStatus();
+ }
+ });
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.horizontalSpan = 3;
+ gd.grabExcessHorizontalSpace = true;
+ gd.widthHint = 500;
+ m_path.setLayoutData(gd);
+
+ // Create a 'browse' button
+ m_browseButton=new Button(group, 0);
+
+ m_browseButton.setText("Browse");
+ m_browseButton.setToolTipText("Browse file system to locate or create "+
+ VALIDATOR_CONFIG_XML+" file");
+
+ m_browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
+ public void widgetSelected(SelectionEvent evt) {
+ FileDialog dialog=new FileDialog(getShell());
+
+ String filename=dialog.open();
+
+ if (filename != null) {
+
+ m_path.setText(filename);
+ }
+
+ checkStatus();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent evt) {
+ }
+ });
+
+ return(composite);
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control ret=super.createButtonBar(parent);
+
+ checkStatus();
+
+ return(ret);
+ }
+
+ protected void checkStatus() {
+ boolean f_error=false;
+
+ if (m_path.getText().trim().length() == 0) {
+ f_error = true;
+ } else {
+ java.io.File f=new java.io.File(m_path.getText());
+
+ if (f.getName().equals(VALIDATOR_CONFIG_XML) == false) {
+ f_error = true;
+ }
+ }
+
+ if (f_error) {
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ } else {
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+ }
+
+ /**
+ * The ok button has been pressed.
+ */
+ public void okPressed() {
+
+ try {
+ ValidatorGenerator generator=new ValidatorGenerator();
+
+ generator.generate(m_choreography, m_file.getName(),
+ m_path.getText());
+
+ super.okPressed();
+ } catch(Exception e) {
+ error("Failed to generate ESB validator configuration", e);
+ }
+ }
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ * @param ex The exception
+ */
+ public void error(String mesg, Exception ex) {
+
+ org.jboss.tools.overlord.cdl.validator.jbossesb.eclipse.Activator.logError(mesg, ex);
+
+ MessageBox mbox=new MessageBox(getShell(),
+ SWT.ICON_ERROR|SWT.OK);
+ mbox.setMessage(mesg);
+ mbox.open();
+
+ logger.log(java.util.logging.Level.SEVERE, mesg, ex);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.validator.jbossesb.dialogs");
+
+ private static final String VALIDATOR_CONFIG_XML="validator-config.xml";
+
+ private org.pi4soa.cdl.Package m_choreography=null;
+ private Text m_path=null;
+ private Button m_browseButton=null;
+ private IFile m_file=null;
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/eclipse/Activator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/eclipse/Activator.java 2008-10-22
17:21:14 UTC (rev 413)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/eclipse/Activator.java 2008-10-22
17:46:47 UTC (rev 414)
@@ -1,5 +1,9 @@
package org.jboss.tools.overlord.cdl.validator.jbossesb.eclipse;
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -47,4 +51,24 @@
return plugin;
}
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.severe("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t));
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.validator.jbossesb.eclipse");
}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/generator/ValidatorGenerator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/generator/ValidatorGenerator.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb/src/java/org/jboss/tools/overlord/cdl/validator/jbossesb/generator/ValidatorGenerator.java 2008-10-22
17:46:47 UTC (rev 414)
@@ -0,0 +1,279 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.validator.jbossesb.generator;
+
+import java.util.Collections;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.common.annotations.*;
+import org.pi4soa.common.xml.XMLUtils;
+
+/**
+ * This class provides a generator for the JBossESB Validator
+ * configuration.
+ */
+public class ValidatorGenerator {
+
+ private static final String CDM_FILE_PATH_ATTR = "cdmFilePath";
+ private static final String FILE_PATH_PREFIX = "models/";
+ private static final String SERVICE_ELEMENT = "service";
+ private static final String VALIDATOR_ELEMENT = "validator";
+
+ public ValidatorGenerator() {
+ }
+
+ public void generate(org.pi4soa.cdl.Package cdlpack, String cdmFileName,
+ String path) {
+
+ try {
+ org.w3c.dom.Element validator=loadValidatorConfig(path);
+
+ String cdmFilePath=getFilePath(cdmFileName);
+
+ // Clear out previous configuration for this choreography
+ clearEntries(validator, cdmFilePath);
+
+ // Create the new entries for the supplied choreography
+ createEntries(validator, cdmFilePath, cdlpack);
+
+ // Save the validator configuration
+ saveValidatorConfig(validator, path);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected org.w3c.dom.Element loadValidatorConfig(String path)
+ throws Exception {
+ org.w3c.dom.Element ret=null;
+
+ // Check if file exists
+ java.io.File f=new java.io.File(path);
+
+ if (f.exists()) {
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=
+ builder.parse(new java.io.FileInputStream(f));
+
+ if (doc.getDocumentElement() != null &&
+ doc.getDocumentElement().getNodeName().equals(
+ VALIDATOR_ELEMENT)) {
+ ret = doc.getDocumentElement();
+ }
+ } else {
+ org.w3c.dom.Document doc=
+ javax.xml.parsers.DocumentBuilderFactory.
+ newInstance().newDocumentBuilder().newDocument();
+
+ ret = doc.createElement(VALIDATOR_ELEMENT);
+
+ doc.appendChild(ret);
+ }
+
+ return(ret);
+ }
+
+ protected void saveValidatorConfig(org.w3c.dom.Element validator,
+ String cdmFilePath) throws Exception {
+ XMLUtils.saveDocument(validator.getOwnerDocument(),
+ new java.io.FileOutputStream(cdmFilePath), true);
+ }
+
+ protected void clearEntries(org.w3c.dom.Element validator,
+ String cdmFilePath) {
+
+ org.w3c.dom.NodeList nl=validator.getChildNodes();
+ java.util.List<org.w3c.dom.Element> toRemove=
+ new java.util.Vector<org.w3c.dom.Element>();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i).getNodeName().equals(SERVICE_ELEMENT) &&
+ nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element service=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (service.getAttribute(CDM_FILE_PATH_ATTR).equals(cdmFilePath)) {
+ toRemove.add(service);
+ }
+ }
+ }
+
+ for (int i=0; i < toRemove.size(); i++) {
+ validator.removeChild(toRemove.get(i));
+ }
+ }
+
+ protected void createEntries(org.w3c.dom.Element validator,
+ String cdmFilePath, org.pi4soa.cdl.Package cdlpack) {
+
+ for (int i=0; i < cdlpack.getTypeDefinitions().getParticipantTypes().size(); i++) {
+ org.pi4soa.cdl.ParticipantType ptype=
+ cdlpack.getTypeDefinitions().getParticipantTypes().get(i);
+
+ org.w3c.dom.Element service=
+ validator.getOwnerDocument().createElement(SERVICE_ELEMENT);
+
+ validator.appendChild(service);
+
+ service.setAttribute(CDM_FILE_PATH_ATTR, cdmFilePath);
+ service.setAttribute("participantType", ptype.getName());
+
+ cdlpack.visit(new InputOutputAnalyser(ptype, service));
+ }
+ }
+
+ protected String getFilePath(String cdmFileName) {
+ return(FILE_PATH_PREFIX+cdmFileName);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.validator.jbossesb.actions");
+
+ public class InputOutputAnalyser extends DefaultCDLVisitor {
+
+ private static final String JBOSSESB_ANNOTATION = "jbossesb";
+ private static final String JBOSSESB_ELEMENT = "jbossesb";
+ private static final String DESTINATION_ELEMENT = "destination";
+ private static final String NAME_ATTR = "name";
+ private static final String EPR_ATTR = "epr";
+ private static final String INPUT_ELEMENT = "input";
+ private static final String OUTPUT_ELEMENT = "output";
+
+ public InputOutputAnalyser(org.pi4soa.cdl.ParticipantType ptype,
+ org.w3c.dom.Element service) {
+ m_participantType = ptype;
+ m_service = service;
+
+ m_templateProcessor =
+ org.pi4soa.common.annotations.AnnotationsManagerFactory.getAnnotationsManager().getTemplateProcessor(JBOSSESB_ANNOTATION);
+ }
+
+ public void interaction(Interaction interaction) {
+ if (m_participantType.getRoleTypes().contains(interaction.getFromRoleType()) ||
+ (interaction.getFromParticipant() != null &&
+ Collections.disjoint(m_participantType.getRoleTypes(),
+ interaction.getFromParticipant().getRoleTypes()) == false)) {
+
+ for (int i=0; i < interaction.getExchangeDetails().size(); i++) {
+ processExchangeDetails(interaction.getExchangeDetails().get(i), true);
+ }
+ } else if (m_participantType.getRoleTypes().contains(interaction.getToRoleType()) ||
+ (interaction.getToParticipant() != null &&
+ Collections.disjoint(m_participantType.getRoleTypes(),
+ interaction.getToParticipant().getRoleTypes()) == false)) {
+ for (int i=0; i < interaction.getExchangeDetails().size(); i++) {
+ processExchangeDetails(interaction.getExchangeDetails().get(i), false);
+ }
+ }
+ }
+
+ protected void processExchangeDetails(ExchangeDetails details, boolean from) {
+
+ for (int i=0; i < details.getSemanticAnnotations().size(); i++) {
+ SemanticAnnotation sa=details.getSemanticAnnotations().get(i);
+ org.w3c.dom.Element dest=null;
+
+ if (sa.getAnnotation() != null && sa.getName() != null &&
+ sa.getName().equals(JBOSSESB_ANNOTATION)) {
+ try {
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=
+ builder.parse(new java.io.ByteArrayInputStream(
+ sa.getAnnotation().getBytes()));
+
+ if (doc.getDocumentElement() != null &&
+ doc.getDocumentElement().getNodeName().equals(
+ JBOSSESB_ELEMENT)) {
+ org.w3c.dom.NodeList nl=
+ doc.getDocumentElement().getElementsByTagName(DESTINATION_ELEMENT);
+
+ if (nl.getLength() == 1) {
+ dest = (org.w3c.dom.Element)nl.item(0);
+ } else if (nl.getLength() > 1) {
+ logger.severe("Too many destination elements ("+
+ nl.getLength()+") found");
+ } else {
+ logger.severe("No destinations found");
+ }
+ }
+
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load jbossesb annotation", e);
+ }
+ }
+
+ if (dest != null) {
+ processDestination(details, dest, from);
+ }
+ }
+ }
+
+ protected void processDestination(ExchangeDetails details,
+ org.w3c.dom.Element dest, boolean from) {
+ String elemName=null;
+
+ if (dest != null &&
+ dest.getAttribute("temporary").equalsIgnoreCase("true") ==
false) {
+ if (from) {
+ if (details.getAction() == ExchangeActionType.REQUEST) {
+ elemName = OUTPUT_ELEMENT;
+ } else {
+ elemName = INPUT_ELEMENT;
+ }
+ } else {
+ if (details.getAction() == ExchangeActionType.REQUEST) {
+ elemName = INPUT_ELEMENT;
+ } else {
+ elemName = OUTPUT_ELEMENT;
+ }
+ }
+
+ // Parameter has been stored in a structured manner
+ // to support use of templates and presentations,
+ // so need to extract the value
+ java.util.List<TemplateParameter> params=
+ m_templateProcessor.getTemplateParameters(dest.getAttribute(NAME_ATTR));
+
+ if (params != null && params.size() > 0) {
+ org.w3c.dom.Element elem=m_service.getOwnerDocument().createElement(elemName);
+ elem.setAttribute(EPR_ATTR, params.get(0).getValue());
+
+ m_service.appendChild(elem);
+ }
+ }
+ }
+
+ private ParticipantType m_participantType=null;
+ private org.w3c.dom.Element m_service=null;
+ private org.pi4soa.common.annotations.TemplateProcessor m_templateProcessor=null;
+ }
+}