JBoss Tools SVN: r16734 - in trunk/smooks: plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-07-22 06:29:19 -0400 (Wed, 22 Jul 2009)
New Revision: 16734
Added:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/EDIParserTest.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/input-message.edi
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml.ext
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
Log:
JBIDE-4217
Add new unit test case for EDI parser
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-07-22 09:34:47 UTC (rev 16733)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-07-22 10:29:19 UTC (rev 16734)
@@ -35,6 +35,7 @@
.
Export-Package: org.jboss.tools.smooks.configuration.editors,
org.jboss.tools.smooks.configuration.editors.csv,
+ org.jboss.tools.smooks.configuration.editors.edi,
org.jboss.tools.smooks.configuration.editors.javabean,
org.jboss.tools.smooks.configuration.editors.uitls,
org.jboss.tools.smooks.configuration.editors.xml
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-07-22 09:34:47 UTC (rev 16733)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-07-22 10:29:19 UTC (rev 16734)
@@ -26,6 +26,7 @@
import org.dom4j.DocumentException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.emf.ecore.EObject;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
@@ -53,7 +54,51 @@
public static final String ENCODING = "encoding";
public static final Object MAPPING_MODEL = "mappingModelFile";
+
+ public TagList parseEDIFile(InputStream stream, InputType inputType,SmooksResourceListType resourceList , IProject project)
+ throws IOException, DocumentException {
+ List<ParamType> paramList = inputType.getParam();
+ String encoding = null;
+ String mappingModel = null;
+ for (Iterator<?> iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType paramType = (ParamType) iterator.next();
+ if (paramType.getName().equals(USE_AVAILABEL_READER)) {
+ if (paramType.getValue().equalsIgnoreCase("true") && resourceList != null) {
+ List<AbstractReader> readers = resourceList.getAbstractReader();
+ int count = 0;
+ int index = -1;
+ for (Iterator<?> iterator2 = readers.iterator(); iterator2.hasNext();) {
+ AbstractReader abstractReader = (AbstractReader) iterator2.next();
+ if (abstractReader instanceof EDIReader) {
+ count++;
+ if (index == -1) {
+ index = readers.indexOf(abstractReader);
+ }
+ }
+ }
+
+ if (count > 1) {
+ // throw new
+ // RuntimeException("The smooks config file should have only one JSON reader");
+ }
+ if (index != -1) {
+ return parseEDIFile(stream, (EDIReader) readers.get(index) , project);
+ }
+
+ }
+ }
+ if (paramType.getName().equals(ENCODING)) {
+ encoding = paramType.getValue();
+ }
+ if (paramType.getName().equals(MAPPING_MODEL)) {
+ mappingModel = paramType.getValue();
+ }
+ }
+
+ return parseEDIFile(stream, mappingModel, encoding, project);
+ }
+
public TagList parseEDIFile(InputStream stream, InputType inputType, SmooksResourceListType resourceList)
throws IOException, DocumentException {
@@ -98,6 +143,11 @@
return parseEDIFile(stream, mappingModel, encoding, resourceList);
}
+ public TagList parseEDIFile(InputStream ediInputStream, EDIReader reader , IProject project) throws IOException, DocumentException {
+ String encoding = reader.getEncoding();
+ String mappingModel = reader.getMappingModel();
+ return parseEDIFile(ediInputStream, mappingModel, encoding, project);
+ }
public TagList parseEDIFile(InputStream ediInputStream, EDIReader reader) throws IOException, DocumentException {
String encoding = reader.getEncoding();
@@ -107,6 +157,16 @@
public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String ediFileEncoding, EObject emodel)
throws IOException, DocumentException {
+ IResource resource = SmooksUIUtils.getResource(emodel);
+ IProject project = null;
+ if (resource != null) {
+ project = resource.getProject();
+ }
+ return parseEDIFile(ediInputStream, mappingModel, ediFileEncoding, project);
+ }
+
+ public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String ediFileEncoding,
+ IProject project) throws IOException, DocumentException {
Smooks smooks = new Smooks();
SmooksResourceConfiguration readerConfig = new SmooksResourceConfiguration("org.xml.sax.driver",
@@ -116,12 +176,9 @@
if (f.exists()) {
modelPath = f.toURI().toString();
} else {
- IResource resource = SmooksUIUtils.getResource(emodel);
- if (resource != null) {
- IFile tf = SmooksUIUtils.getFile(mappingModel, resource.getProject());
- if (tf != null) {
- modelPath = tf.getLocation().toFile().toURI().toString();
- }
+ IFile tf = SmooksUIUtils.getFile(mappingModel, project);
+ if (tf != null) {
+ modelPath = tf.getLocation().toFile().toURI().toString();
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-22 09:34:47 UTC (rev 16733)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-22 10:29:19 UTC (rev 16734)
@@ -1105,6 +1105,8 @@
if (resource == null)
return null;
URI uri = resource.getURI();
+
+ if(uri == null) return null;
IResource workspaceResource = null;
if (uri.isPlatformResource()) {
String path = uri.toPlatformString(true);
@@ -1483,6 +1485,7 @@
}
public static IFile getFile(String uri, IProject project) {
+ if(project == null) return null;
if (uri.charAt(0) == '\\' || uri.charAt(0) == '/') {
uri = uri.substring(1);
}
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/EDIParserTest.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/EDIParserTest.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/EDIParserTest.java 2009-07-22 10:29:19 UTC (rev 16734)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.smooks.test.ediparser;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.dom4j.DocumentException;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.jboss.tools.smooks.configuration.editors.edi.EDIDataParser;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.editors.xml.TagList;
+import org.jboss.tools.smooks.model.graphics.ext.InputType;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphExtensionDocumentRoot;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+import org.jboss.tools.smooks.model.graphics.ext.util.SmooksGraphicsExtResourceFactoryImpl;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+import org.jboss.tools.smooks.model.smooks.util.SmooksResourceFactoryImpl;
+import org.jboss.tools.smooks.test.model11.BaseTestCase;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIParserTest extends BaseTestCase {
+
+ public void testEDIParser() throws IOException, DocumentException, ParserConfigurationException {
+ Resource extResource = new SmooksGraphicsExtResourceFactoryImpl().createResource(null);
+ extResource.load(EDIParserTest.class.getResourceAsStream("smooks-config.xml.ext"), null);
+ SmooksGraphicsExtType extType = ((SmooksGraphExtensionDocumentRoot) extResource.getContents().get(0))
+ .getSmooksGraphicsExt();
+ Resource smooksResource = new SmooksResourceFactoryImpl().createResource(null);
+
+ assertNotNull(extType);
+ InputType inputType = null;
+ List<?> ilist = extType.getInput();
+ for (Iterator<?> iterator = ilist.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof InputType) {
+ if ("EDI".equalsIgnoreCase(((InputType) object).getType())) {
+ inputType = (InputType) object;
+ break;
+ }
+ }
+ }
+ assertNotNull(inputType);
+
+
+ smooksResource.load(EDIParserTest.class.getResourceAsStream("smooks-config.xml"), null);
+
+ SmooksResourceListType resourceList = ((org.jboss.tools.smooks.model.smooks.DocumentRoot) smooksResource
+ .getContents().get(0)).getSmooksResourceList();
+ assertNotNull(resourceList);
+
+ EDIDataParser parser = new EDIDataParser();
+ TagList tagList = parser.parseEDIFile(EDIParserTest.class.getResourceAsStream("input-message.edi"), inputType,resourceList);
+ assertNotNull(tagList);
+ List<String> namesList = new ArrayList<String>();
+ namesList.add("Orderaaa");
+ checkTagList1(tagList.getChildren(), namesList, new String[] { "header", "customer-details", "order-item" });
+
+ for (Iterator<?> iterator = ilist.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof InputType) {
+ if ("EDI".equalsIgnoreCase(((InputType) object).getType()) && object != inputType) {
+ inputType = (InputType) object;
+ break;
+ }
+ }
+ }
+
+ parser = new EDIDataParser();
+ tagList = parser.parseEDIFile(EDIParserTest.class.getResourceAsStream("input-message.edi"), inputType,
+ resourceList);
+ assertNotNull(tagList);
+ checkTagList1(tagList.getChildren(), namesList, new String[] { "header", "customer-details", "order-item" });
+ }
+
+ private void checkChildrenNode(String requiredSelector, String nodeName, IXMLStructuredObject tag) {
+ IXMLStructuredObject node1 = SmooksUIUtils.localXMLNodeWithNodeName(nodeName, tag);
+ assertNotNull(node1);
+ String selector = SmooksUIUtils.generateFullPath(node1, "/");
+ assertEquals(requiredSelector, selector);
+ }
+
+ private void checkTagList1(List<?> tagList, List<String> requiredRootTagName, String[] childrenNodesNames) {
+ for (Iterator<?> iterator = tagList.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof IXMLStructuredObject) {
+ IXMLStructuredObject tag = (IXMLStructuredObject) object;
+ assertEquals(requiredRootTagName.get(tagList.indexOf(tag)), tag.getNodeName());
+ String n = SmooksUIUtils.generateFullPath(tag, "/");
+ for (int i = 0; i < childrenNodesNames.length; i++) {
+ checkChildrenNode("/" + n + "/" + childrenNodesNames[i], childrenNodesNames[i], tag);
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/EDIParserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml 2009-07-22 10:29:19 UTC (rev 16734)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<medi:edimap xmlns:medi="http://www.milyn.org/schema/edi-message-mapping-1.0.xsd">
+ <medi:description name="DVD Order" version="1.0"/>
+ <medi:delimiters component="^" field="*" segment="
" sub-component="~"/>
+ <medi:segments xmltag="Orderaaa">
+ <medi:segment xmltag="header" segcode="HDR">
+ <medi:field xmltag="order-id"/>
+ <medi:field xmltag="status-code"/>
+ <medi:field xmltag="net-amount"/>
+ <medi:field xmltag="total-amount"/>
+ <medi:field xmltag="tax"/>
+ <medi:field xmltag="date"/>
+ </medi:segment>
+ <medi:segment xmltag="customer-details" segcode="CUS">
+ <medi:field xmltag="username"/>
+ <medi:field xmltag="name">
+ <medi:component xmltag="firstname"/>
+ <medi:component xmltag="lastname"/>
+ </medi:field>
+ <medi:field xmltag="state"/>
+ </medi:segment>
+ <medi:segment xmltag="order-item" maxOccurs="-1" segcode="ORD">
+ <medi:field xmltag="position"/>
+ <medi:field xmltag="product-id"/>
+ <medi:field xmltag="title"/>
+ <medi:field xmltag="ordername"/>
+ <medi:field xmltag="price"/>
+ </medi:segment>
+ </medi:segments>
+</medi:edimap>
\ No newline at end of file
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/input-message.edi
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/input-message.edi (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/input-message.edi 2009-07-22 10:29:19 UTC (rev 16734)
@@ -0,0 +1,4 @@
+HDR*1*0*59.97*64.92*4.95*Wed Nov 15 13:45:28 EST 2006
+CUS*user1*Harry^Fletcher*SD
+ORD*1*1*364*The 40-Year-Old Virgin*29.98
+ORD*2*1*299*Pulp Fiction*29.99
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml 2009-07-22 10:29:19 UTC (rev 16734)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<smooks-resource-list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:edi="http://www.milyn.org/xsd/smooks/edi-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.1.xsd">
+ <params>
+ <param name="stream.filter.type">SAX</param>
+ </params>
+ <abstract-reader xsi:type="edi:reader" encoding="UTF-8" mappingModel="/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml"/>
+ <jb:bindings beanId="a" class="example.A">
+ <jb:value data="a" property="name"/>
+ <jb:wiring beanIdRef="a" property="b"/>
+ </jb:bindings>
+</smooks-resource-list>
\ No newline at end of file
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml.ext
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml.ext (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/ediparser/smooks-config.xml.ext 2009-07-22 10:29:19 UTC (rev 16734)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<smooks-graphics-ext xmlns="http://www.jboss.org/jbosstools/smooks/smooks-graphics-ext.xsd">
+ <input type="EDI">
+ <param name="path">Workspace://javabean_test/src/example/input-message.edi</param>
+ <param name="use_availableReader">true</param>
+ </input>
+ <input type="EDI">
+ <param name="path">Workspace://javabean_test/src/example/input-message.edi</param>
+ <param name="encoding">UTF-8</param>
+ <param name="mappingModelFile">/org/jboss/tools/smooks/test/ediparser/edi-to-xml-order-mapping.xml</param>
+ </input>
+</smooks-graphics-ext>
\ No newline at end of file
16 years, 9 months
JBoss Tools SVN: r16733 - trunk/jst/plugins/org.jboss.tools.jst.css.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-07-22 05:34:47 -0400 (Wed, 22 Jul 2009)
New Revision: 16733
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4641
Modified: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml 2009-07-22 08:14:09 UTC (rev 16732)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml 2009-07-22 09:34:47 UTC (rev 16733)
@@ -71,13 +71,13 @@
</extension>
<extension point="org.eclipse.ui.views">
<view class="org.jboss.tools.jst.css.view.CSSEditorView" id="org.jboss.tools.jst.css.view.editor"
- name="%css.editor_name" restorable="true">
+ name="%css.editor_name" restorable="true" category="web.views.category.id">
</view>
<view
class="org.jboss.tools.jst.css.view.CSSPreview"
id="org.jboss.tools.jst.css.view.preview"
name="%css.preview_name"
- restorable="true">
+ restorable="true" category="web.views.category.id">
</view>
</extension>
</plugin>
16 years, 9 months
JBoss Tools SVN: r16732 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors: edi and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-07-22 04:14:09 -0400 (Wed, 22 Jul 2009)
New Revision: 16732
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
Log:
JBIDE-4640
Change the "ClasspathFileProcessor" to caculate the correct file's path
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java 2009-07-22 06:38:03 UTC (rev 16731)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java 2009-07-22 08:14:09 UTC (rev 16732)
@@ -48,7 +48,7 @@
IPath filePath = file.getFullPath();
String sp = sourcePath.toPortableString();
String fp = filePath.toPortableString();
- path = fp.substring(0, sp.length());
+ path = fp.substring(sp.length(), fp.length());
break;
}
// }
@@ -61,7 +61,9 @@
if(path == null){
path = file.getFullPath().removeFirstSegments(1).toPortableString();
}
- if(path.charAt(0) != '\\' || path.charAt(0) != '/' ){
+ if(path.charAt(0) == '\\' || path.charAt(0) == '/' ){
+
+ }else{
path = "/" + path;
}
return path;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-07-22 06:38:03 UTC (rev 16731)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-07-22 08:14:09 UTC (rev 16732)
@@ -25,6 +25,9 @@
import javax.xml.transform.stream.StreamSource;
import org.dom4j.DocumentException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.ecore.EObject;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
@@ -93,26 +96,34 @@
}
}
- return parseEDIFile(stream, mappingModel, encoding);
+ return parseEDIFile(stream, mappingModel, encoding, resourceList);
}
public TagList parseEDIFile(InputStream ediInputStream, EDIReader reader) throws IOException, DocumentException {
String encoding = reader.getEncoding();
String mappingModel = reader.getMappingModel();
- return parseEDIFile(ediInputStream, mappingModel, encoding);
+ return parseEDIFile(ediInputStream, mappingModel, encoding, reader);
}
- public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String ediFileEncoding)
+ public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String ediFileEncoding, EObject emodel)
throws IOException, DocumentException {
Smooks smooks = new Smooks();
SmooksResourceConfiguration readerConfig = new SmooksResourceConfiguration("org.xml.sax.driver",
SmooksEDIReader.class.getName());
- File f = new File(mappingModel);
- String modelPath = mappingModel;
- if(f.exists()){
- modelPath = f.toURI().toString();
- }
+ File f = new File(mappingModel);
+ String modelPath = mappingModel;
+ if (f.exists()) {
+ modelPath = f.toURI().toString();
+ } else {
+ IResource resource = SmooksUIUtils.getResource(emodel);
+ if (resource != null) {
+ IFile tf = SmooksUIUtils.getFile(mappingModel, resource.getProject());
+ if (tf != null) {
+ modelPath = tf.getLocation().toFile().toURI().toString();
+ }
+ }
+ }
readerConfig.setParameter("mapping-model", modelPath);
if (ediFileEncoding == null || ediFileEncoding.trim().length() == 0) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-22 06:38:03 UTC (rev 16731)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-22 08:14:09 UTC (rev 16732)
@@ -1482,12 +1482,11 @@
openFile(uri, project, null);
}
- public static void openFile(String uri, IProject project, String editorID) throws PartInitException {
+ public static IFile getFile(String uri, IProject project) {
if (uri.charAt(0) == '\\' || uri.charAt(0) == '/') {
uri = uri.substring(1);
}
IFile file = project.getFile(uri);
- IWorkbenchWindow window = SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
// it's workspace resource
if (file.exists()) {
@@ -1514,6 +1513,15 @@
}
}
if (file.exists()) {
+ return file;
+ }
+ return null;
+ }
+
+ public static void openFile(String uri, IProject project, String editorID) throws PartInitException {
+ IFile file = getFile(uri, project);
+ IWorkbenchWindow window = SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (file != null && window != null) {
FileEditorInput editorInput = new FileEditorInput(file);
if (editorID != null) {
window.getActivePage().openEditor(editorInput, editorID);
@@ -2276,7 +2284,8 @@
parentList = null;
continue;
}
- if(parentList.isEmpty()) continue;
+ if (parentList.isEmpty())
+ continue;
parentList.remove(parentList.size() - 1);
((TreeNodeEditPart) rootEditPart).expandNode();
for (int i = parentList.size() - 1; i >= 0; i--) {
16 years, 9 months
JBoss Tools SVN: r16731 - trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2009-07-22 02:38:03 -0400 (Wed, 22 Jul 2009)
New Revision: 16731
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java
Log:
JBIDE-4636: Don't refresh the outline view when delete or add variables, partnerlinks and so on to a scope element
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java 2009-07-22 03:05:46 UTC (rev 16730)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/adapters/ScopeAdapter.java 2009-07-22 06:38:03 UTC (rev 16731)
@@ -10,12 +10,20 @@
*******************************************************************************/
package org.eclipse.bpel.ui.adapters;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.bpel.model.BPELPackage;
import org.eclipse.bpel.model.CompensationHandler;
+import org.eclipse.bpel.model.CorrelationSets;
import org.eclipse.bpel.model.EventHandler;
+import org.eclipse.bpel.model.ExtensibleElement;
import org.eclipse.bpel.model.FaultHandler;
+import org.eclipse.bpel.model.MessageExchanges;
+import org.eclipse.bpel.model.PartnerLinks;
import org.eclipse.bpel.model.Scope;
import org.eclipse.bpel.model.TerminationHandler;
+import org.eclipse.bpel.model.Variables;
import org.eclipse.bpel.ui.adapters.delegates.ActivityContainer;
import org.eclipse.bpel.ui.adapters.delegates.MultiContainer;
import org.eclipse.bpel.ui.adapters.delegates.OptionalIndirectContainer;
@@ -104,8 +112,42 @@
/* IOutlineEditPartFactory */
@Override
- public EditPart createOutlineEditPart(EditPart context, Object model) {
- EditPart result = new OutlineTreeEditPart();
+ public EditPart createOutlineEditPart(EditPart context, final Object model) {
+ EditPart result = new OutlineTreeEditPart(){
+ // add the getModelChildren() method by Grid.Qian to refresh the scope when
+ // these partner, varaible, and so on change
+ @SuppressWarnings("unchecked")
+ @Override
+ protected List<ExtensibleElement> getModelChildren() {
+ Scope scope = (Scope)model;
+ List<ExtensibleElement> list = new ArrayList<ExtensibleElement>();
+
+ PartnerLinks links = scope.getPartnerLinks();
+ if (links != null) {
+ list.add(links);
+ }
+
+ Variables variables = scope.getVariables();
+ if (variables != null) {
+ list.add(variables);
+ }
+
+ CorrelationSets sets = scope.getCorrelationSets();
+ if (sets != null) {
+ list.add(sets);
+ }
+
+ MessageExchanges exchanges = scope.getMessageExchanges();
+ if (exchanges != null) {
+ list.add(exchanges);
+ }
+
+ IContainer container = new ActivityContainer(BPELPackage.eINSTANCE.getScope_Activity());
+ List<ExtensibleElement> list2 = container.getChildren(scope);
+ list.addAll(list2);
+ return list;
+ }
+ };
result.setModel(model);
return result;
}
16 years, 9 months
JBoss Tools SVN: r16730 - in trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src: org and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2009-07-21 23:05:46 -0400 (Tue, 21 Jul 2009)
New Revision: 16730
Added:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java
Log:
recommit the source codes
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.bpel.apache.ode.deploy.ui"; //$NON-NLS-1$
+
+ // The editor ID
+ public static final String EDITOR_ID = "org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ // shared images
+ public static final String IMG_ODE = "ode16"; //$NON-NLS-1$
+ public static final String IMG_CHECKED = "checked"; //$NON-NLS-1$
+ public static final String IMG_UNCHECKED = "unchecked"; //$NON-NLS-1$
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (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 Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ super.initializeImageRegistry(reg);
+ reg.put(IMG_ODE, getImageDescriptor("icons/obj16/ode.gif")); //$NON-NLS-1$
+ reg.put(IMG_CHECKED, getImageDescriptor("icons/obj16/checked.gif")); //$NON-NLS-1$
+ reg.put(IMG_UNCHECKED, getImageDescriptor("icons/obj16/unchecked.gif")); //$NON-NLS-1$
+ }
+
+
+}
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.editors;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.DocumentRoot;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TDeployment;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceFactoryImpl;
+import org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * A multipage editor for Apache ODE deployment descriptors.
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class ODEDeployMultiPageEditor extends FormEditor implements IEditingDomainProvider {
+
+ protected TDeployment deployDescriptor = null;
+
+ protected AdapterFactoryEditingDomain editingDomain;
+ protected ComposedAdapterFactory adapterFactory;
+
+
+ /**
+ * Creates a multi-page editor example.
+ */
+ public ODEDeployMultiPageEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * Saves the deployment descriptor
+ */
+ public void doSave(IProgressMonitor monitor) {
+ commitPages(true);
+ saveDeploymentDescriptor();
+ ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ }
+
+ /**
+ * SaveAs is not supported.
+ */
+ public void doSaveAs() {
+ throw new UnsupportedOperationException("SaveAs is not allowed."); //$NON-NLS-1$
+ }
+
+ /**
+ * The implementation of this method checks that the input is an
+ * instance of <code>IFileEditorInput</code> and creates the data model.
+ */
+ public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
+ super.init(site, editorInput);
+ setPartName(editorInput.getName());
+
+ if (!(editorInput instanceof IFileEditorInput)) {
+ throw new PartInitException("Invalid Input: Must be IFileEditorInput"); //$NON-NLS-1$
+ }
+
+ createModel();
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public void saveDeploymentDescriptor() {
+ try {
+ deployDescriptor.eResource().save(null);
+ }
+ catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ protected org.eclipse.bpel.model.Process loadBPEL(IFile bpelFile) {
+ IPath fullProcessPath = bpelFile.getFullPath();
+ URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(), false);
+ Resource bpelResource = editingDomain.getResourceSet().getResource(uri, true);
+
+ try {
+ bpelResource.load(Collections.EMPTY_MAP);
+ EList<EObject> contents = bpelResource.getContents();
+ if (!contents.isEmpty()) {
+ return (org.eclipse.bpel.model.Process) contents.get(0);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+ @Override
+ protected void addPages() {
+ try {
+ for (ProcessType pt : deployDescriptor.getProcess()) {
+ addPage(new ProcessPage(this, pt));
+ }
+ }
+ catch (PartInitException e) {
+ // ~
+ }
+ }
+
+ public TDeployment getDeploymentModel(){
+ return deployDescriptor;
+ }
+
+ protected void initializeEditingDomain() {
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ // Create the command stack that will notify this editor as commands are executed.
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ commandStack.addCommandStackListener
+ (new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ editorDirtyStateChanged();
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
+ }
+
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ @Override
+ public void setFocus() {
+ if (getActivePage() != -1 && getControl(getActivePage()) != null) {
+ getControl(getActivePage()).setFocus();
+ }
+ }
+
+ protected void createModel() throws PartInitException {
+ URI resourceURI = EditUIUtil.getURI(getEditorInput());
+ Resource resource = null;
+
+ ddResourceFactoryImpl fac = new ddResourceFactoryImpl();
+ resource = fac.createResource(resourceURI);
+ editingDomain.getResourceSet().getResources().add(resource);
+ try {
+ resource.load(Collections.EMPTY_MAP);
+
+ EList<EObject> contents = resource.getContents();
+ if (!contents.isEmpty() && contents.get(0) instanceof DocumentRoot) {
+ deployDescriptor = ((DocumentRoot) contents.get(0)).getDeploy();
+
+ populateModel();
+
+ //TODO: what to do with processtypes in DD without a corresponding BPEL file available?
+ }
+ } catch (CoreException e) {
+ throw new PartInitException(e.getStatus());
+ } catch (IOException e) {
+ throw new PartInitException(e.getMessage(), e);
+ }
+ }
+
+ public void populateModel() throws CoreException {
+ ((IFileEditorInput)getEditorInput()).getFile().getProject().accept(new IResourceVisitor() {
+ public boolean visit(IResource bpelfile) throws CoreException {
+ if (bpelfile.getType() == IResource.FILE
+ && bpelfile.getFileExtension().equalsIgnoreCase("bpel")) { //$NON-NLS-1$
+ org.eclipse.bpel.model.Process p = DeployUtils.loadBPEL((IFile)bpelfile, editingDomain.getResourceSet());
+ if (p != null) {
+ // add process to DD unless it it not already there.
+ ProcessType pt = DeployUtils.findProcessTypeInDD(p, deployDescriptor);
+ if (pt == null) {
+ pt = DeployUtils.createProcessStub(p);
+ deployDescriptor.getProcess().add(pt);
+ }
+ // set model
+ pt.setModel(p);
+
+ }
+ }
+ return true;
+ }
+ });
+ }
+
+}
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.editors;
+
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+
+/**
+ * No-op editor contributor
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class ODEDeployMultiPageEditorContributor extends EditingDomainActionBarContributor {
+
+ public ODEDeployMultiPageEditorContributor() {
+ super();
+ createActions();
+ }
+
+ private void createActions() {
+ // new actions go here
+ }
+
+ public void contributeToMenu(IMenuManager manager) {
+ // contribute here
+ }
+
+ public void contributeToToolBar(IToolBarManager manager) {
+ // contribute here
+ }
+}
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,961 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.pages;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.xml.namespace.QName;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.GenerateType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TInvoke;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TProcessEvents;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TProvide;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TScopeEvents;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TService;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddFactory;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddPackage;
+import org.eclipse.bpel.apache.ode.deploy.ui.Activator;
+import org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.PartnerLink;
+import org.eclipse.bpel.model.PartnerLinks;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.bpel.model.Scope;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.bpel.ui.util.BPELUtil;
+import org.eclipse.bpel.ui.util.IModelVisitor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.OwnerDrawLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.wsdl.Port;
+import org.eclipse.wst.wsdl.Service;
+
+/**
+ * Main process page, renders UI for all relevant deployment settings.
+ *
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class ProcessPage extends FormPage implements IResourceChangeListener {
+ public static final int PARTNER_LINK_COLUMN = 0;
+ public static final int PORT_COLUMN = 1;
+ public static final int SERVICE_COLUMN = 2;
+ public static final int BINDING_COLUMN = 3;
+
+ public static final String INSTANCE_LIFECYCLE_NAME = "instanceLifecycle"; //$NON-NLS-1$
+ public static final String ACTIVITY_LIFECYCLE_NAME = "activityLifecycle"; //$NON-NLS-1$
+ public static final String DATA_HANDLING_NAME = "dataHandling"; //$NON-NLS-1$
+ public static final String SCOPE_HANDLING_NAME = "scopeHandling"; //$NON-NLS-1$
+ public static final String CORRELATION_NAME = "correlation"; //$NON-NLS-1$
+
+ public static final String[] PROCESS_STATUS = new String[] {"activated", "deactivated", "retired"};
+ public static final int STATUS_ACTIVATED = 0;
+ public static final int STATUS_DEACTIVATED = 1;
+ public static final int STATUS_RETIRED = 2;
+
+ public static final Map<String, String> eventNameById = new HashMap<String, String>();
+ static {
+ eventNameById.put(INSTANCE_LIFECYCLE_NAME, "Instance life cycle");
+ eventNameById.put(ACTIVITY_LIFECYCLE_NAME, "Activity life cycle");
+ eventNameById.put(DATA_HANDLING_NAME, "Data handling");
+ eventNameById.put(SCOPE_HANDLING_NAME, "Scope handling");
+ eventNameById.put(CORRELATION_NAME, "Correlation");
+ }
+
+ protected ODEDeployMultiPageEditor editor;
+ protected ProcessType processType;
+ protected FormToolkit toolkit;
+ private EditingDomain domain;
+ private TableViewer scopeTableViewer;
+ private Form mainform;
+
+ public ProcessPage(FormEditor editor, ProcessType pt) {
+ super(editor, "ODED" + pt.getName().toString(), pt.getName().getLocalPart()); //$NON-NLS-1$
+ this.processType = pt;
+ this.editor = (ODEDeployMultiPageEditor)editor;
+
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+
+ this.domain = this.editor.getEditingDomain();
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ toolkit = managedForm.getToolkit();
+ ScrolledForm form = managedForm.getForm();
+ form.setText(MessageFormat.format("Process {0} - {1}", processType.getName().getLocalPart(), processType.getName().getNamespaceURI()));
+ toolkit.decorateFormHeading(form.getForm());
+ mainform = form.getForm();
+ mainform.addMessageHyperlinkListener(new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ refreshModel();
+ }
+
+ });
+
+ form.setImage(BPELUIPlugin.INSTANCE.getImage(IBPELUIConstants.ICON_PROCESS_32));
+
+ RowLayout layout = new RowLayout();
+ layout.wrap = false;
+ layout.pack = true;
+ layout.justify = false;
+ layout.fill = true;
+ layout.type = SWT.VERTICAL;
+ layout.marginLeft = 5;
+ layout.marginTop = 5;
+ layout.marginRight = 5;
+ layout.marginBottom = 5;
+ layout.spacing = 5;
+
+ form.getBody().setLayout(layout);
+ Dialog.applyDialogFont(form.getBody());
+
+ Composite client = createSection(form.getBody(), "General", null, 1);
+
+ final Composite statusArea = new Composite(client, SWT.NONE);
+ statusArea.setLayout(new GridLayout(2, false));
+ toolkit.createLabel(statusArea, "This process is ");
+ final Combo comboStatus = new Combo(statusArea, SWT.READ_ONLY);
+ toolkit.adapt(comboStatus);
+ comboStatus.setItems(PROCESS_STATUS);
+ if (processType.isActive()) {
+ comboStatus.select(STATUS_ACTIVATED);
+ } else {
+ if (processType.isRetired()) {
+ comboStatus.select(STATUS_RETIRED);
+ } else {
+ comboStatus.select(STATUS_DEACTIVATED);
+ }
+ }
+ comboStatus.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Command setActiveCommand = SetCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_Active(), comboStatus.getSelectionIndex() == STATUS_ACTIVATED);
+ Command setRetiredCommand = SetCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_Retired(), comboStatus.getSelectionIndex() == STATUS_RETIRED);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(setActiveCommand);
+ compoundCommand.append(setRetiredCommand);
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ });
+
+ final Button btnRunInMemory = toolkit.createButton(client, "Run this process in memory", SWT.CHECK);
+ btnRunInMemory.setToolTipText("Define a process as being executed only in-memory. This gives better performance, but the processes cannot be queried by using the ODE Management API.");
+ btnRunInMemory.setSelection(processType.isInMemory());
+ btnRunInMemory.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Command setInMemoryCommand = SetCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_InMemory(), btnRunInMemory.getSelection());
+ domain.getCommandStack().execute(setInMemoryCommand);
+ }
+
+ });
+
+ String serviceDescription = "The table contains interfaces the process provides. Specify the service, port and binding you want to use for each PartnerLink listed";
+ createInterfaceWidget(form.getBody(), processType, managedForm, "Inbound Interfaces (Services)", serviceDescription, true);
+ String invokeDescription = "The table contains interfaces the process invokes. Specify the service, port and binding you want to use for each PartnerLink listed";
+ createInterfaceWidget(form.getBody(), processType, managedForm, "Outbound Interfaces (Invokes)", invokeDescription, false);
+
+ createProcessMonitoringSection(form.getBody());
+ createScopeMonitoringSection(form.getBody());
+
+ form.reflow(true);
+ }
+
+ private void createInterfaceWidget(Composite fClient, ProcessType current, final IManagedForm managedForm, String title, String description, boolean isInbound) {
+
+ // Set column names
+ String[] columnNames = new String[] {
+ //"Partner Link (click on entry to open definition)",
+ "Partner Link",
+ "Associated Port",
+ "Related Service",
+ "Binding Used"
+ };
+
+ Section section = toolkit.createSection(fClient, Section.TWISTIE | Section.EXPANDED | Section.DESCRIPTION | Section.TITLE_BAR);
+ section.setText(title);
+ section.setDescription(description);
+ section.marginHeight = 5;
+
+ Composite client = toolkit.createComposite(section, SWT.WRAP);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout(layout);
+ final Table t = toolkit.createTable(client, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
+
+ TableColumn tc1 = new TableColumn(t, SWT.CENTER);
+ tc1.setText(columnNames[0]);
+
+ TableColumn tc2 = new TableColumn(t, SWT.CENTER);
+ tc2.setText(columnNames[1]);
+
+ TableColumn tc3 = new TableColumn(t, SWT.CENTER);
+ tc3.setText(columnNames[2]);
+
+ TableColumn tc4 = new TableColumn(t, SWT.CENTER);
+ tc4.setText(columnNames[3]);
+
+ t.setHeaderVisible(true);
+ t.setLinesVisible(true);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ t.setLayoutData(gd);
+ toolkit.paintBordersFor(client);
+
+ section.setClient(client);
+ final SectionPart spart = new SectionPart(section);
+ managedForm.addPart(spart);
+
+
+ URI deployDescriptorURI = current.eResource().getURI();
+ IFile ddFile = DeployUtils.getIFileForURI(deployDescriptorURI);
+
+ TableViewer viewer = new TableViewer(t);
+ viewer.setUseHashlookup(true);
+ viewer.setColumnProperties(columnNames);
+ viewer.setContentProvider(new PortTypeContentProvider(isInbound));
+ viewer.setLabelProvider(new PortTypeLabelProvider(ddFile.getProject(), current.eResource().getResourceSet()));
+ viewer.setInput(current);
+
+ for (int i = 0, n = t.getColumnCount(); i < n; i++) {
+ t.getColumn(i).pack();
+ }
+
+ // Create the cell editors
+ CellEditor[] editors = new CellEditor[columnNames.length];
+
+ // TODO: Column 1 : HyperLink Listener
+// final TableEditor editor = new TableEditor(t);
+// editor.horizontalAlignment = SWT.LEFT;
+// editor.grabHorizontal = true;
+// IWorkbenchPage wbPage= getEditor().getSite().getPage();
+// InterfaceTableListener tableListener = new InterfaceTableListener(current, t, editor, toolkit, wbPage, isInbound);
+// t.addListener(SWT.MouseDown, tableListener);
+
+ // Column 2 : Associate Service (ComboBox)
+ ServiceCellEditor sCellEditor = new ServiceCellEditor(t, ddFile.getProject(), current.eResource().getResourceSet());
+ editors[1] = sCellEditor;
+
+ // Assign the cell editors to the viewer
+ viewer.setCellEditors(editors);
+
+ // Set the cell modifier for the viewer
+ viewer.setCellModifier(new InterfaceWidgetCellModifier(viewer, columnNames));
+
+ }
+
+
+ class InterfaceWidgetCellModifier implements ICellModifier {
+ private Viewer viewer;
+ private String[] columnNames;
+
+ public InterfaceWidgetCellModifier(Viewer viewer, String[] columnNames) {
+ this.viewer = viewer;
+ this.columnNames = columnNames;
+ }
+
+ public boolean canModify(Object element, String property) {
+ if (property.equals(columnNames[1])) {
+ return true;
+ }
+ return false;
+ }
+
+ public Object getValue(Object element, String property) {
+ if (!property.equals(columnNames[1])) {
+ return null;
+ }
+ if (element instanceof TProvide) {
+ TProvide provide = (TProvide) element;
+ return provide.getService();
+ }
+ else if (element instanceof TInvoke) {
+ TInvoke invoke = (TInvoke) element;
+ return invoke.getService();
+ }
+ else {
+ return null;
+ }
+
+ }
+
+ public void modify(Object element, String property, Object value) {
+ assert element instanceof Item;
+ if (!property.equals(columnNames[1])) {
+ return;
+ }
+
+ Item item = (Item) element;
+ Object o = item.getData();
+ if (o instanceof TProvide) {
+ TProvide provide = (TProvide) o;
+
+ TService service = provide.getService();
+ if (service == null) {
+ service = ddFactory.eINSTANCE.createTService();
+ provide.setService(service);
+ }
+
+ if (value == null) {
+ Command unsetServiceCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Name(), SetCommand.UNSET_VALUE);
+ Command unsetPortCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Port(), SetCommand.UNSET_VALUE);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(unsetServiceCommand);
+ compoundCommand.append(unsetPortCommand);
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ else {
+ Port port = (Port) value;
+ String portName = port.getName();
+
+ Command setPortCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Port(), portName);
+
+ Service wsdlService = (Service) port.eContainer();
+ QName qname = wsdlService.getQName();
+ Command setServiceCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Name(), qname);
+
+
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(setServiceCommand);
+ compoundCommand.append(setPortCommand);
+
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ }
+ else if (o instanceof TInvoke) {
+ TInvoke invoke = (TInvoke) o;
+
+ TService service = invoke.getService();
+ if (service == null) {
+ service = ddFactory.eINSTANCE.createTService();
+ invoke.setService(service);
+ }
+
+ if (value == null) {
+ Command unsetServiceCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Name(), SetCommand.UNSET_VALUE);
+ Command unsetPortCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Port(), SetCommand.UNSET_VALUE);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(unsetServiceCommand);
+ compoundCommand.append(unsetPortCommand);
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ else {
+ Port port = (Port) value;
+ String portName = port.getName();
+
+ Command setPortCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Port(), portName);
+
+ Service wsdlService = (Service) port.eContainer();
+ QName qname = wsdlService.getQName();
+ Command setServiceCommand = SetCommand.create(domain, service, ddPackage.eINSTANCE.getTService_Name(), qname);
+
+
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(setServiceCommand);
+ compoundCommand.append(setPortCommand);
+
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ }
+
+ viewer.refresh();
+ }
+
+ }
+
+ private Composite createSection(Composite parent, String title, String desc, int numColumns) {
+
+ Section section = null;
+ if (desc != null) {
+ section = toolkit.createSection(parent, Section.TWISTIE | Section.TITLE_BAR | Section.DESCRIPTION | Section.EXPANDED);
+ section.setDescription(desc);
+ } else {
+ section = toolkit.createSection(parent, Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED);
+ }
+ section.setText(title);
+
+ Composite client = toolkit.createComposite(section);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ layout.numColumns = numColumns;
+ client.setLayout(layout);
+ section.setClient(client);
+
+ return client;
+ }
+
+ private void createProcessMonitoringSection(Composite parent) {
+ final Composite client = createSection(parent, "Process-level Monitoring Events", null, 2);
+ final Composite group = toolkit.createComposite(client);
+ group.setLayout(new RowLayout(SWT.VERTICAL));
+ GridData gd = new GridData();
+ gd.verticalAlignment = SWT.BEGINNING;
+ gd.horizontalIndent = 5;
+ group.setLayoutData(gd);
+
+ final Button btnNone = toolkit.createButton(group, "None", SWT.RADIO);
+ final Button btnAll = toolkit.createButton(group, "All", SWT.RADIO);
+ final Button btnSelected = toolkit.createButton(group, "Selected", SWT.RADIO);
+
+ Composite wrapper = toolkit.createComposite(client);
+ wrapper.setLayout(new RowLayout());
+ final CheckboxTableViewer ctv = CheckboxTableViewer.newCheckList(wrapper, SWT.NONE);
+ wrapper.setLayoutData(gd);
+ toolkit.paintBordersFor(wrapper);
+
+ ctv.setContentProvider(new ArrayContentProvider());
+ ctv.setLabelProvider(new LabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ return eventNameById.get(element);
+ }
+
+ });
+ ctv.setInput(new String[] {INSTANCE_LIFECYCLE_NAME, ACTIVITY_LIFECYCLE_NAME,
+ DATA_HANDLING_NAME, SCOPE_HANDLING_NAME, CORRELATION_NAME});
+
+ //create defaulting process event settings
+ if (processType.getProcessEvents() == null) {
+ TProcessEvents pe = ddFactory.eINSTANCE.createTProcessEvents();
+ pe.setGenerate(GenerateType.ALL);
+ processType.setProcessEvents(pe);
+ }
+
+ if (processType.getProcessEvents().isSetGenerate()) {
+ switch (processType.getProcessEvents().getGenerate()) {
+ case ALL:
+ btnAll.setSelection(true);
+ ctv.getControl().setEnabled(false);
+ break;
+ case NONE:
+ btnNone.setSelection(true);
+ ctv.getControl().setEnabled(false);
+ break;
+ }
+ } else {
+ btnSelected.setSelection(true);
+ ctv.getControl().setEnabled(true);
+ }
+
+ final SelectionAdapter sa = new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (btnAll == e.getSource()) {
+ ctv.getControl().setEnabled(false);
+ Command command = SetCommand.create(domain, processType.getProcessEvents(), ddPackage.eINSTANCE.getTProcessEvents_Generate(), GenerateType.ALL);
+ domain.getCommandStack().execute(command);
+ } else if (btnNone == e.getSource()) {
+ ctv.getControl().setEnabled(false);
+ Command command = SetCommand.create(domain, processType.getProcessEvents(), ddPackage.eINSTANCE.getTProcessEvents_Generate(), GenerateType.NONE);
+ domain.getCommandStack().execute(command);
+ } else {
+ ctv.getControl().setEnabled(true);
+ Command command = SetCommand.create(domain, processType.getProcessEvents(), ddPackage.eINSTANCE.getTProcessEvents_Generate(), SetCommand.UNSET_VALUE);
+ domain.getCommandStack().execute(command);
+ }
+ }
+ };
+
+ btnAll.addSelectionListener(sa);
+ btnNone.addSelectionListener(sa);
+ btnSelected.addSelectionListener(sa);
+
+ ctv.setCheckedElements(processType.getProcessEvents().getEnableEvent().toArray());
+ final ISelectionChangedListener scl = new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ Command command = SetCommand.create(domain, processType.getProcessEvents(), ddPackage.eINSTANCE.getTEnableEventList_EnableEvent(), Arrays.asList(ctv.getCheckedElements()));
+ domain.getCommandStack().execute(command);
+ }
+
+ };
+
+ ctv.addSelectionChangedListener(scl);
+ }
+
+ private void createScopeMonitoringSection(Composite parent) {
+ Composite client = createSection(parent, "Scope-level Monitoring Events", null, 1);
+
+ scopeTableViewer = new TableViewer(toolkit.createTable(client, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL |
+ SWT.FULL_SELECTION | SWT.HIDE_SELECTION));
+ Table table = scopeTableViewer.getTable();
+ scopeTableViewer.setContentProvider(new ScopeMonitoringEventContentProvider());
+ scopeTableViewer.setUseHashlookup(true);
+ TableViewerColumn column = new TableViewerColumn(scopeTableViewer, SWT.NONE);
+ column.getColumn().setText("Scope");
+ column.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ return ((Scope)element).getName();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return BPELUIPlugin.INSTANCE.getImage(IBPELUIConstants.ICON_SCOPE_16);
+ }
+ });
+
+ String[] columns = new String[] {INSTANCE_LIFECYCLE_NAME, ACTIVITY_LIFECYCLE_NAME, DATA_HANDLING_NAME, SCOPE_HANDLING_NAME, CORRELATION_NAME};
+ for (String columnId : columns) {
+ column = new TableViewerColumn(scopeTableViewer, SWT.NONE);
+ column.getColumn().setText(eventNameById.get(columnId));
+ column.setLabelProvider(new ScopeEventCheckboxColumnLabelProvider(columnId));
+ column.setEditingSupport(new ScopeEventEditingSupport(scopeTableViewer, columnId));
+ }
+
+ OwnerDrawLabelProvider.setUpOwnerDraw(scopeTableViewer);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ scopeTableViewer.setInput(processType);
+
+ for (int i = 0, n = table.getColumnCount(); i < n; i++) {
+ table.getColumn(i).pack();
+ }
+ }
+
+ class PortTypeLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ protected IProject bpelProject = null;
+ protected ResourceSet resourceSet = null;
+
+ public PortTypeLabelProvider(IProject bpelProject, ResourceSet resourceSet){
+ this.bpelProject = bpelProject;
+ this.resourceSet = resourceSet;
+ }
+
+ public String getColumnText(Object obj, int index) {
+
+ if (obj instanceof TProvide && index == PARTNER_LINK_COLUMN){
+ TProvide current = (TProvide) obj;
+ return current.getPartnerLink();
+ }
+ else if (obj instanceof TProvide && index == SERVICE_COLUMN){
+ TProvide current = (TProvide) obj;
+ TService service = current.getService();
+ if (service != null) {
+ QName serviceQName = service.getName();
+ if (serviceQName != null) {
+ return serviceQName.toString();
+ }
+ }
+ }
+ else if (obj instanceof TProvide && index == PORT_COLUMN){
+ TProvide current = (TProvide) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ return portName;
+ }
+ }
+ }
+ else if (obj instanceof TProvide && index == BINDING_COLUMN){
+ TProvide current = (TProvide) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ Port port = DeployUtils.findPortByName(portName, this.bpelProject, this.resourceSet);
+ if (port != null) {
+ Binding binding = port.getBinding();
+ QName bindingQName = binding.getQName();
+ if (bindingQName != null) {
+ return bindingQName.getLocalPart();
+ }
+ }
+ }
+ }
+ }
+
+ if (obj instanceof TInvoke && index == PARTNER_LINK_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ return current.getPartnerLink();
+ }
+ else if (obj instanceof TInvoke && index == SERVICE_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ TService service = current.getService();
+ if (service != null) {
+ QName serviceQName = service.getName();
+ if (serviceQName != null) {
+ return serviceQName.toString();
+ }
+ }
+ }
+ else if (obj instanceof TInvoke && index == PORT_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ return portName;
+ }
+ }
+ }
+ else if (obj instanceof TInvoke && index == BINDING_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ Port port = DeployUtils.findPortByName(portName, this.bpelProject, this.resourceSet);
+ if (port != null) {
+ Binding binding = port.getBinding();
+ QName bindingQName = binding.getQName();
+ if (bindingQName != null) {
+ return bindingQName.getLocalPart();
+ }
+ }
+ }
+ }
+ }
+
+ return DeployUtils.NONE_STRING;
+ }
+
+ public Image getColumnImage(Object obj, int index) {
+ return null;
+ }
+ }
+
+ class PortTypeContentProvider implements IStructuredContentProvider {
+
+ protected boolean forInbound = false;
+
+ public PortTypeContentProvider(boolean bForInbound){
+ forInbound = bForInbound;
+ }
+
+ public Object[] getElements(Object inputElement) {
+
+ if (inputElement instanceof ProcessType){
+ ProcessType type = (ProcessType) inputElement;
+ if (forInbound){
+ EList<TProvide> provide = type.getProvide();
+
+ if (provide.isEmpty()){
+ Process process = type.getModel();
+ PartnerLinks pls = process.getPartnerLinks();
+ EList<PartnerLink> plList = pls.getChildren();
+ for (Iterator<PartnerLink> iterator = plList.iterator(); iterator.hasNext();) {
+ PartnerLink current = (PartnerLink) iterator.next();
+ if (current.getMyRole() != null){
+ TProvide currentProvide = ddFactory.eINSTANCE.createTProvide();
+ currentProvide.setPartnerLink(current.getName());
+ provide.add(currentProvide);
+ }
+ }
+ }
+
+ return provide.toArray();
+ }
+ else {
+ EList<TInvoke> invoke = type.getInvoke();
+
+ if (invoke.isEmpty()){
+ Process process = type.getModel();
+ PartnerLinks pls = process.getPartnerLinks();
+ if (pls != null) {
+ EList<PartnerLink> plList = pls.getChildren();
+ for (Iterator<PartnerLink> iterator = plList.iterator(); iterator
+ .hasNext();) {
+ PartnerLink current = (PartnerLink) iterator
+ .next();
+ if (current.getPartnerRole() != null) {
+ TInvoke currentInvoke = ddFactory.eINSTANCE
+ .createTInvoke();
+ currentInvoke.setPartnerLink(current
+ .getName());
+ invoke.add(currentInvoke);
+ }
+ }
+ }
+ }
+
+ return invoke.toArray();
+ }
+ }
+ else {
+ return new String[1];
+ }
+ }
+
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ class ScopeMonitoringEventContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ final List<Object> scopes = new ArrayList<Object>();
+
+ BPELUtil.visitModelDepthFirst(processType.getModel(), new IModelVisitor() {
+ public boolean visit(Object modelObject) {
+ if ((modelObject instanceof Scope) &&
+ (((Scope)modelObject).getName() != null)) {
+ scopes.add(modelObject);
+ }
+ return true;
+ }
+ });
+
+ return scopes.toArray();
+ }
+
+ public void dispose() {}
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+
+ }
+
+ protected void refreshModel() {
+
+ try {
+ editor.populateModel();
+ scopeTableViewer.refresh();
+ mainform.setMessage(null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void resourceChanged(IResourceChangeEvent event) {
+
+ IResourceDeltaVisitor rdv = new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) {
+ IResource res = delta.getResource();
+ if ("bpel".equalsIgnoreCase(res.getFileExtension())) { //$NON-NLS-1$
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ mainform.setMessage("Associated BPEL and/or WSDL has been changed, click to update!", IMessageProvider.WARNING);
+ }
+ });
+ }
+
+ return true; // visit the children
+ }
+ };
+ try {
+ event.getDelta().accept(rdv);
+ } catch (CoreException e) {
+ //ignore
+ }
+ }
+
+ @Override
+ public void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ super.dispose();
+ }
+
+ class ScopeEventEditingSupport extends EditingSupport {
+
+ private String eventType;
+ private CheckboxCellEditor checkboxCellEditor;
+ public ScopeEventEditingSupport(TableViewer viewer, String eventType) {
+ super(viewer);
+ this.eventType = eventType;
+ this.checkboxCellEditor = new CheckboxCellEditor(viewer.getTable());
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ String scName = ((Scope)element).getName();
+ return scName != null && !"".equals(scName); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return checkboxCellEditor;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ String scName = ((Scope)element).getName();
+ for (TScopeEvents se : processType.getProcessEvents().getScopeEvents()) {
+ if (scName.equals(se.getName()) &&
+ se.getEnableEvent().contains(eventType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ String scName = ((Scope)element).getName();
+ TScopeEvents match = null;
+ for (TScopeEvents se : processType.getProcessEvents().getScopeEvents()) {
+ if (scName.equals(se.getName())) {
+ match = se;
+ break;
+ }
+ }
+
+ if (match == null) {
+ match = ddFactory.eINSTANCE.createTScopeEvents();
+ match.setName(scName);
+ processType.getProcessEvents().getScopeEvents().add(match);
+ }
+
+ if (((Boolean)value).booleanValue()) {
+ if (!match.getEnableEvent().contains(eventType)) {
+ Command command = AddCommand.create(domain, match, ddPackage.eINSTANCE.getTEnableEventList_EnableEvent(), eventType);
+ domain.getCommandStack().execute(command);
+ }
+ } else {
+ Command command = RemoveCommand.create(domain, match, ddPackage.eINSTANCE.getTEnableEventList_EnableEvent(), eventType);
+ domain.getCommandStack().execute(command);
+ }
+
+ getViewer().refresh();
+ }
+ }
+
+ class ScopeEventCheckboxColumnLabelProvider extends OwnerDrawLabelProvider {
+
+ private String eventType;
+
+ public ScopeEventCheckboxColumnLabelProvider(String eventType) {
+ this.eventType = eventType;
+ }
+
+ protected void measure(Event event, Object element) {
+ Image img = getImage(element);
+ event.setBounds(new Rectangle(event.x, event.y, img.getBounds().width,
+ img.getBounds().height));
+
+ }
+
+ protected void paint(Event event, Object element) {
+
+ Image img = getImage(element);
+
+ if (img != null) {
+ Rectangle bounds = ((TableItem) event.item)
+ .getBounds(event.index);
+ Rectangle imgBounds = img.getBounds();
+ bounds.width /= 2;
+ bounds.width -= imgBounds.width / 2;
+ bounds.height /= 2;
+ bounds.height -= imgBounds.height / 2;
+
+ int x = bounds.width > 0 ? bounds.x + bounds.width : bounds.x;
+ int y = bounds.height > 0 ? bounds.y + bounds.height : bounds.y;
+
+ event.gc.drawImage(img, x, y);
+ }
+ }
+
+
+ public Image getImage(Object element) {
+ if (isChecked(element)) {
+ return Activator.getDefault().getImageRegistry().get(Activator.IMG_CHECKED);
+ } else {
+ return Activator.getDefault().getImageRegistry().get(Activator.IMG_UNCHECKED);
+ }
+ }
+
+ public boolean isChecked(Object element) {
+ String scName = ((Scope)element).getName();
+ for (TScopeEvents se : processType.getProcessEvents().getScopeEvents()) {
+ if (se.getName().equals(scName) &&
+ se.getEnableEvent().contains(eventType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ }
+
+
+}
\ No newline at end of file
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,134 @@
+package org.eclipse.bpel.apache.ode.deploy.ui.pages;
+
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TService;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Port;
+import org.eclipse.wst.wsdl.Service;
+
+/**
+ * In-place editor for WSDL services in tables.
+ *
+ * @author Simon Moser (IBM)
+ */
+public class ServiceCellEditor extends ComboBoxCellEditor {
+
+ IProject bpelProject = null;
+ ResourceSet resourceSet = null;
+ List<Port> portList = null;
+
+ public ServiceCellEditor(Table parent, IProject bpelProject, ResourceSet resourceSet)
+ {
+ super(parent, new String[]{}, SWT.READ_ONLY);
+ this.bpelProject = bpelProject;
+ if (resourceSet != null) {
+ this.resourceSet = resourceSet;
+ }
+ else {
+ this.resourceSet = new ResourceSetImpl();
+ }
+ }
+
+ @Override
+ protected Object doGetValue() {
+
+ Integer integer = (Integer) super.doGetValue();
+
+ CCombo combo = (CCombo) getControl();
+ String string = combo.getItem(integer.intValue());
+
+ Port port = findPortByName(string);
+
+ return port;
+ }
+
+ private Port findPortByName(String string) {
+
+ for (Iterator<Port> iterator = portList.iterator(); iterator.hasNext();) {
+ Port currentPort = iterator.next();
+ if (currentPort.getName().equals(string)){
+ return currentPort;
+ }
+ }
+
+ return null;
+ }
+
+ @SuppressWarnings("unchecked") //$NON-NLS-1$
+ @Override
+ protected void doSetValue(Object value) {
+
+ List<Service> serviceList = new ArrayList();
+ portList = new ArrayList<Port>();
+
+ //load WSDL's
+ List<Definition> wsdlDefs = DeployUtils.loadAllWSDLFromProject(this.bpelProject, this.resourceSet);
+ //Assemble All Services from WSDL's
+ for (Iterator<Definition> iterator = wsdlDefs.iterator(); iterator.hasNext();) {
+ Definition current = (Definition) iterator.next();
+ Map services = current.getServices();
+ if (!services.isEmpty()){
+ Collection values = services.values();
+ for (Iterator<Service> iterator2 = values.iterator(); iterator2.hasNext();) {
+ Service name = iterator2.next();
+ serviceList.add(name);
+ }
+ }
+ }
+
+ //now we have all services in a List .. get All Ports from these services
+ for (Iterator<Service> iterator = serviceList.iterator(); iterator.hasNext();) {
+ Service currentService = iterator.next();
+ Map portMap = currentService.getPorts();
+ Collection<Port> ports = portMap.values();
+ portList.addAll(ports);
+ }
+
+ String[] items = new String[portList.size() + 1];
+ items[0] = DeployUtils.NONE_STRING;
+
+ for (int i=1; i<portList.size()+1; i++){
+ Port currentPort = (Port) portList.get(i-1);
+ items[i] = currentPort.getName();
+ }
+
+ setItems(items);
+
+ if (value != null){
+ TService service = (TService) value;
+ for (int i = 0; i < portList.size(); i++) {
+ Port p = portList.get(i);
+ if (p.getName().equals(service.getPort()) &&
+ ((Service)p.getContainer()).getQName().equals(service.getName())) {
+ super.doSetValue(i+1);
+ return;
+ }
+ }
+ }
+ super.doSetValue(0);
+ }
+}
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TDeployment;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddFactory;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Port;
+import org.eclipse.wst.wsdl.Service;
+
+/**
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class DeployUtils {
+
+ public static final String URL_PREFIX_FILE = "file"; //$NON-NLS-1$
+ public static final String URL_PREFIX_PLATFORM = "platform"; //$NON-NLS-1$
+ public static final String URL_PREFIX_RESOURCE = "resource"; //$NON-NLS-1$
+ public static final String NONE_STRING = "-- none -- "; //$NON-NLS-1$
+
+
+ public static ProcessType findProcessTypeInDD(org.eclipse.bpel.model.Process process, TDeployment dd) {
+ for (ProcessType pt : dd.getProcess()) {
+ if ( pt.getName().getLocalPart().equals(process.getName())
+ && pt.getName().getNamespaceURI().equals(process.getTargetNamespace())) {
+ return pt;
+ }
+ }
+ return null;
+ }
+
+ public static ProcessType createProcessStub(org.eclipse.bpel.model.Process process) {
+ ProcessType pt = ddFactory.eINSTANCE.createProcessType();
+ QName processQName = new QName(process.getTargetNamespace(),process.getName() );
+ pt.setName(processQName);
+ return pt;
+ }
+
+ public static QName getQNameFromSerialzedForm(String qNameAsString) {
+
+ int pos = qNameAsString.lastIndexOf("}"); //$NON-NLS-1$
+
+ String ns = qNameAsString.substring(1, pos);
+ String name = qNameAsString.substring(pos+1, qNameAsString.length());
+
+ QName qName = new QName(ns, name);
+
+ return qName;
+ }
+
+
+ @SuppressWarnings("unchecked") //$NON-NLS-1$
+ public static Port findPortByName(String name, IProject bpelProject, ResourceSet resourceSet){
+
+ List serviceList = new ArrayList();
+ List portList = new ArrayList();
+
+ List<Definition> wsdlDefs = DeployUtils.loadAllWSDLFromProject(bpelProject, resourceSet);
+ //Assemble All Services from WSDL's
+ for (Iterator<Definition> iterator = wsdlDefs.iterator(); iterator.hasNext();) {
+ Definition current = (Definition) iterator.next();
+ Map services = current.getServices();
+ if (!services.isEmpty()){
+ Collection values = services.values();
+ for (Iterator iterator2 = values.iterator(); iterator2.hasNext();) {
+ Service name2 =(Service) iterator2.next();
+ serviceList.add(name2);
+ }
+ }
+ }
+
+ //now we have all services in a List .. get All Ports from these services
+ for (Iterator iterator = serviceList.iterator(); iterator.hasNext();) {
+ Service currentService = (Service) iterator.next();
+ Map portMap = currentService.getPorts();
+ Collection ports = portMap.values();
+ portList.addAll(ports);
+ }
+
+ for (Iterator iterator = portList.iterator(); iterator.hasNext();) {
+ Port currentPort = (Port) iterator.next();
+ if (currentPort.getName().equals(name)){
+ return currentPort;
+ }
+ }
+
+ return null;
+
+ }
+
+ public static Process loadBPEL(IFile bpelFile, ResourceSet resourceSet) {
+
+ IPath fullProcessPath = bpelFile.getFullPath();
+ URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(), false);
+ Resource bpelResource = resourceSet.getResource(uri, true);
+
+ EcorePackage instance = EcorePackage.eINSTANCE;
+ instance.eAdapters();
+
+ try {
+ if (bpelResource.isLoaded()) {
+ bpelResource.unload();
+ }
+ bpelResource.load(Collections.EMPTY_MAP);
+ EList<EObject> contents = bpelResource.getContents();
+ if (!contents.isEmpty()) {
+ return (Process) contents.get(0);
+ }
+ } catch (Exception e) {
+ //swallow exception
+ }
+
+ return null;
+ }
+
+ public static Definition loadWSDL(IFile wsdlFile, ResourceSet resourceSet) {
+
+ IPath fullProcessPath = wsdlFile.getFullPath();
+ URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(), false);
+ Resource wsdlResource = resourceSet.getResource(uri, true);
+
+ EcorePackage instance = EcorePackage.eINSTANCE;
+ instance.eAdapters();
+
+ try {
+ wsdlResource.load(Collections.EMPTY_MAP);
+ EList<EObject> contents = wsdlResource.getContents();
+ if (!contents.isEmpty()) {
+ return (Definition) contents.get(0);
+ }
+ } catch (Exception e) {
+ //swallow exception
+ }
+
+ return null;
+ }
+
+ public static List<Definition> loadAllWSDLFromProject(IProject project, ResourceSet resourceSet)
+ {
+ List<Definition> wsdlFiles = new ArrayList<Definition>();
+
+ List<IFile> allFiles = DeployUtils.getAllFilesInProject(project);
+
+ for (IFile file : allFiles) {
+
+ if (file.getFileExtension().equalsIgnoreCase("wsdl")) { //$NON-NLS-1$
+// load it
+ Definition currentDef = loadWSDL(file, resourceSet);
+// stuff it in wsdlFiles
+ wsdlFiles.add(currentDef);
+ }
+ }
+
+ return wsdlFiles;
+ }
+
+ public static List<Process> loadAllBPELFromProject(IProject project, ResourceSet resourceSet)
+ {
+ List<Process> bpelFiles = new ArrayList<Process>();
+
+ List<IFile> allFiles = DeployUtils.getAllFilesInProject(project);
+
+ for (IFile file : allFiles) {
+
+ if (file.getFileExtension().equalsIgnoreCase("bpel")) { //$NON-NLS-1$
+// load it
+ Process currentProcess = loadBPEL(file, resourceSet);
+// stuff it in bpelFiles
+ bpelFiles.add(currentProcess);
+ }
+ }
+
+ return bpelFiles;
+ }
+
+
+ public static List<IFile> getAllFilesInProject(IProject project) {
+ final List<IFile> files = new ArrayList<IFile>();
+ IResourceVisitor visitor = new IResourceVisitor() {
+ public boolean visit(org.eclipse.core.resources.IResource resource) throws org.eclipse.core.runtime.CoreException {
+ if (resource.getType() == IResource.FILE) {
+ files.add((IFile)resource);
+ }
+ return true;
+ }
+ };
+ try {
+ project.accept(visitor);
+ }
+ catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return files;
+ }
+
+ public static IFile getIFileForURI(URI uri) {
+
+ if(uri == null) return null;
+
+ String filePath = null;
+ String scheme = uri.scheme();
+
+ if (URL_PREFIX_FILE.equals(scheme)) {
+ filePath = uri.toFileString();
+ } else if (URL_PREFIX_PLATFORM.equals(scheme) && uri.segmentCount() > 1 && URL_PREFIX_RESOURCE.equals(uri.segment(0))) {
+ StringBuffer platformResourcePath = new StringBuffer();
+ for (int i = 1, size = uri.segmentCount(); i < size; ++i) {
+ platformResourcePath.append('/');
+ platformResourcePath.append(uri.segment(i));
+ }
+ filePath = URI.decode(platformResourcePath.toString());
+ }
+
+ if (filePath == null)
+ return null;
+
+ IFile file = null;
+
+ if (URL_PREFIX_FILE.equals(scheme)){ //44110
+ if(uri.device()!= null){
+ filePath = filePath.substring(filePath.indexOf(uri.device()));
+ }
+ file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(filePath));
+ }else
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
+
+ return file;
+ }
+
+}
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.util;
+
+import java.util.Iterator;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage;
+import org.eclipse.bpel.model.PartnerLink;
+import org.eclipse.bpel.model.PartnerLinks;
+import org.eclipse.bpel.model.partnerlinktype.Role;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.wsdl.PortType;
+
+public class InterfaceTableListener implements Listener {
+
+ protected ProcessType processType = null;
+ protected Table table = null;
+ protected TableEditor editor = null;
+ protected FormToolkit toolkit = null;
+ protected IWorkbenchPage page = null;
+ protected boolean isInbound = false;
+
+ public InterfaceTableListener(ProcessType fProcessType, Table fTable, TableEditor fEditor, FormToolkit fToolkit, IWorkbenchPage fPage, boolean bIsInbound){
+ processType = fProcessType;
+ table = fTable;
+ editor = fEditor;
+ toolkit = fToolkit;
+ page = fPage;
+ isInbound = bIsInbound;
+ }
+
+ public void handleEvent(Event event) {
+ Rectangle clientArea = table.getClientArea();
+ Point pt = new Point(event.x, event.y);
+ int index = table.getTopIndex();
+ while (index < table.getItemCount()) {
+ boolean visible = false;
+ final TableItem item = table.getItem(index);
+ for (int i = 0; i < table.getColumnCount(); i++) {
+ Rectangle rect = item.getBounds(i);
+ if (rect.contains(pt)) {
+
+ final int column = i;
+
+ System.out.println("A cell in column " + (i+1) + " has been pressed");
+
+ if (i == ProcessPage.PARTNER_LINK_COLUMN) {
+ System.out.println("PORT_TYPE_COLUMN has been pressed");
+ final Hyperlink link = toolkit.createHyperlink(table, "", SWT.NONE); //$NON-NLS-1$
+ IHyperlinkListener listener = new HyperlinkAdapter(){
+ public void linkActivated(HyperlinkEvent e) {
+
+ System.out.println("Hyper clicked!");
+
+ String partnerLinkName = e.getLabel();
+ PartnerLink theOne = null;
+
+ PartnerLinks partnerLinksElm = processType.getModel().getPartnerLinks();
+ EList<PartnerLink> partnerLinks = partnerLinksElm.getChildren();
+ for (Iterator<PartnerLink> iterator = partnerLinks.iterator(); iterator.hasNext();) {
+ PartnerLink currentPL = iterator.next();
+ if (currentPL.getName().equals(partnerLinkName)){
+ theOne = currentPL;
+ break;
+ }
+ }
+
+ if (theOne != null) {
+
+ Role role = null;
+
+ if (isInbound) {
+ role = theOne.getMyRole();
+ }
+ else {
+ role = theOne.getPartnerRole();
+ }
+
+ if (role != null) {
+ PortType portType = (PortType) role.getPortType();
+ Resource resource = portType.eResource();
+ IFile file = DeployUtils.getIFileForURI(resource.getURI());;
+ try {
+ IDE.openEditor(page, file);
+ }
+ catch (PartInitException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+ };
+ link.addHyperlinkListener(listener);
+ editor.setEditor(link, item, i);
+ link.setText(item.getText(i));
+ link.setFocus();
+ }
+ else {
+ final Text text = new Text(table, SWT.NONE);
+ Listener textListener = new Listener() {
+ public void handleEvent(final Event e) {
+ switch (e.type) {
+ case SWT.FocusOut:
+ item.setText(column, text.getText());
+ text.dispose();
+ break;
+ case SWT.Traverse:
+ switch (e.detail) {
+ case SWT.TRAVERSE_RETURN:
+ item.setText(column, text.getText());
+ // FALL THROUGH
+ case SWT.TRAVERSE_ESCAPE:
+ text.dispose();
+ e.doit = false;
+ }
+ break;
+ }
+ }
+ };
+ text.addListener(SWT.FocusOut, textListener);
+ text.addListener(SWT.Traverse, textListener);
+ editor.setEditor(text, item, i);
+ text.setText(item.getText(i));
+ text.selectAll();
+ text.setFocus();
+ }
+
+ return;
+ }
+ if (!visible && rect.intersects(clientArea)) {
+ visible = true;
+ }
+ }
+ if (!visible)
+ return;
+ index++;
+ }
+ }
+}
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,199 @@
+package org.eclipse.bpel.apache.ode.deploy.ui.wizards;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.DocumentRoot;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TDeployment;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddFactory;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceFactoryImpl;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceImpl;
+import org.eclipse.bpel.apache.ode.deploy.ui.Activator;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * Wizard that enables creating new deployment descriptors for Apache ODE.
+ *
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class NewODEDeployWizard extends Wizard implements INewWizard {
+ private ODEDeployWizardPage page;
+ private ISelection selection;
+
+ /**
+ * Constructor for NewODEDeployWizard.
+ */
+ public NewODEDeployWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+ page = new ODEDeployWizardPage(selection);
+ addPage(page);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in
+ * the wizard. We will create an operation and run it
+ * using wizard as execution context.
+ */
+ public boolean performFinish() {
+ final String containerName = page.getContainerName();
+ final String fileName = page.getFileName();
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ doFinish(containerName, fileName, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * The worker method. It will find the container, create the
+ * file if missing or just replace its contents, and open
+ * the editor on the newly created file.
+ */
+
+ private void doFinish(
+ String containerName,
+ String fileName,
+ IProgressMonitor monitor)
+ throws CoreException {
+
+ // create a sample file
+ monitor.beginTask("Creating " + fileName, 2);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = root.findMember(new Path(containerName));
+ if (!resource.exists() || !(resource instanceof IContainer)) {
+ throwCoreException("Container \"" + containerName + "\" does not exist.");
+ }
+ IContainer container = (IContainer) resource;
+ final IFile file = container.getFile(new Path(fileName));
+
+ try {
+ Resource emfResource = createBaseDeploymentDescriptor(file);
+ emfResource.save(null);
+ }
+ catch (IOException e) {
+ throwCoreException(e.getMessage());
+ }
+
+ monitor.worked(1);
+ monitor.setTaskName("Opening file for editing...");
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, file, Activator.EDITOR_ID, true);
+ } catch (PartInitException e) {
+ }
+ }
+ });
+ monitor.worked(1);
+ }
+
+
+ /**
+ * Purpose of this method is to create a new empty deployment descriptor
+ * in the targetDir
+ */
+ public Resource createBaseDeploymentDescriptor(IFile file)
+ {
+ URI fileURI = URI.createURI(file.getFullPath().toString());
+
+ //generate Resource Factory
+ ddResourceFactoryImpl fac = new ddResourceFactoryImpl();
+ //URI ddFileLocation = URI.createFileURI(this.deployDirectory + System.getProperty("file.separator") + DD_FILENAME );
+
+ ddResourceImpl ddResource = (ddResourceImpl) fac.createResource(fileURI);
+ ddResource.setEncoding("UTF-8");
+ DocumentRoot rootElm = ddFactory.eINSTANCE.createDocumentRoot();
+ TDeployment deployElement = ddFactory.eINSTANCE.createTDeployment();
+ rootElm.setDeploy(deployElement);
+ ddResource.getContents().add(rootElm);
+
+ //bugzilla 250057: parse the project, and if we find a BPEL file, create
+ //a base "process" tag that has
+ // <active>true</active>
+ // <retired>false</retired>
+ IProject project = file.getProject();
+ List<Process> processes = DeployUtils.loadAllBPELFromProject(project, new ResourceSetImpl());
+ for (Iterator iterator = processes.iterator(); iterator.hasNext();) {
+ Process process = (Process) iterator.next();
+ ProcessType pt = DeployUtils.createProcessStub(process);
+ pt.setActive(true);
+ pt.setRetired(false);
+ pt.setModel(process);
+ deployElement.getProcess().add(pt);
+ }
+
+ return ddResource;
+ }
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status =
+ new Status(IStatus.ERROR, "org.eclipse.bpel.apache.ode.deploy.ui", IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if
+ * we can initialize from it.
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+}
\ No newline at end of file
Added: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java 2009-07-22 03:05:46 UTC (rev 16730)
@@ -0,0 +1,181 @@
+package org.eclipse.bpel.apache.ode.deploy.ui.wizards;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+/**
+ * ODE deployment descriptor wizard page.
+ *
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class ODEDeployWizardPage extends WizardPage {
+ private Text containerText;
+
+ private Text fileText;
+
+ private ISelection selection;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public ODEDeployWizardPage(ISelection selection) {
+ super("ODEDeployDescriptorWizardPage");
+ setTitle("Apache ODE Deployment Descriptor");
+ setDescription("This wizard creates a new Apache ODE deployment descriptor file (deploy.xml). Note that the file name cannot be changed.");
+ this.selection = selection;
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 3;
+ layout.verticalSpacing = 9;
+ Label label = new Label(container, SWT.NULL);
+ label.setText("BPEL &Project:");
+
+ containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ containerText.setLayoutData(gd);
+ containerText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+
+ Button button = new Button(container, SWT.PUSH);
+ button.setText("Browse...");
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse();
+ }
+ });
+ label = new Label(container, SWT.NULL);
+ label.setText("&File name:");
+
+ fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ fileText.setText("deploy.xml");
+ fileText.setEditable(false);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize() {
+ if (selection != null && selection.isEmpty() == false
+ && selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() > 1)
+ return;
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof IResource) {
+ IContainer container;
+ if (obj instanceof IContainer)
+ container = (IContainer) obj;
+ else
+ container = ((IResource) obj).getParent();
+ containerText.setText(container.getFullPath().toString());
+ }
+ }
+ }
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+
+ private void handleBrowse() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ "Select a BPEL Project that hosts the deployment descriptor");
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] result = dialog.getResult();
+ if (result.length == 1) {
+ containerText.setText(((Path) result[0]).toString());
+ }
+ }
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged() {
+ IResource container = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(getContainerName()));
+ String fileName = getFileName();
+
+ if (getContainerName().length() == 0) {
+ updateStatus("BPEL Project must be specified");
+ return;
+ }
+ if (container == null
+ || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+ updateStatus("BPEL Project must exist");
+ return;
+ }
+ if (!container.isAccessible()) {
+ updateStatus("BPEL Project must be writable");
+ return;
+ }
+ if (fileName.length() == 0) {
+ updateStatus("File name must be specified");
+ return;
+ }
+ if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
+ updateStatus("File name must be valid");
+ return;
+ }
+ int dotLoc = fileName.lastIndexOf('.');
+ if (dotLoc != -1) {
+ String ext = fileName.substring(dotLoc + 1);
+ if (ext.equalsIgnoreCase("xml") == false) {
+ updateStatus("File extension must be \"xml\"");
+ return;
+ }
+ }
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ public String getContainerName() {
+ return containerText.getText();
+ }
+
+ public String getFileName() {
+ return fileText.getText();
+ }
+}
\ No newline at end of file
16 years, 9 months
JBoss Tools SVN: r16729 - trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2009-07-21 20:20:16 -0400 (Tue, 21 Jul 2009)
New Revision: 16729
Removed:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/
Log:
svn:ignore
Property changes on: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src
___________________________________________________________________
Name: svn:ignore
+ *.class
*/*.class
**/*.class
16 years, 9 months
JBoss Tools SVN: r16728 - trunk/bpel/plugins/org.eclipse.bpel.common.model/src.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2009-07-21 20:18:43 -0400 (Tue, 21 Jul 2009)
New Revision: 16728
Removed:
trunk/bpel/plugins/org.eclipse.bpel.common.model/src/model/
trunk/bpel/plugins/org.eclipse.bpel.common.model/src/org/
Modified:
trunk/bpel/plugins/org.eclipse.bpel.common.model/src/
Log:
svn:ignore
Property changes on: trunk/bpel/plugins/org.eclipse.bpel.common.model/src
___________________________________________________________________
Name: svn:ignore
- *
bin
*.class
+ *.class
*/*.class
**/*.class
16 years, 9 months
JBoss Tools SVN: r16727 - trunk/bpel/plugins/org.eclipse.bpel.validator.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2009-07-21 20:05:28 -0400 (Tue, 21 Jul 2009)
New Revision: 16727
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/
Log:
svn:ignore
Property changes on: trunk/bpel/plugins/org.eclipse.bpel.validator
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
bin/*
16 years, 9 months
JBoss Tools SVN: r16726 - trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2009-07-21 20:05:14 -0400 (Tue, 21 Jul 2009)
New Revision: 16726
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/
Log:
svn:ignore
Property changes on: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
bin/*
16 years, 9 months
JBoss Tools SVN: r16725 - trunk/bpel/plugins/org.eclipse.bpel.apache.ode.runtime.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2009-07-21 20:04:58 -0400 (Tue, 21 Jul 2009)
New Revision: 16725
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.runtime/
Log:
svn:ignore
Property changes on: trunk/bpel/plugins/org.eclipse.bpel.apache.ode.runtime
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
bin/*
16 years, 9 months