Index: src/org/eclipse/bpel/ui/Templates.java =================================================================== --- src/org/eclipse/bpel/ui/Templates.java (revision 21569) +++ src/org/eclipse/bpel/ui/Templates.java (working copy) @@ -10,7 +10,6 @@ * Oracle Corporation *******************************************************************************/ - package org.eclipse.bpel.ui; import java.io.IOException; @@ -28,331 +27,329 @@ import java.util.TreeMap; import java.util.TreeSet; +import org.eclipse.bpel.ui.wizards.WSDLServiceDetail; import org.osgi.framework.Bundle; /** - * You can think of BPEL templates as a 1 dimensional list of stencils that are used - * to create an initial BPEL process. + * You can think of BPEL templates as a 1 dimensional list of stencils that are + * used to create an initial BPEL process. *

- * Each template for a process may contain just 1 resource - just the template for - * the BPEL process itself. But it may also contain other resources which are useful - * in creating that particular process from that particular template. - * Simply put, a template may have 1-N template resources that need to be created - * as a result of creating what appears to be a single process file. - * + * Each template for a process may contain just 1 resource - just the template + * for the BPEL process itself. But it may also contain other resources which + * are useful in creating that particular process from that particular template. + * Simply put, a template may have 1-N template resources that need to be + * created as a result of creating what appears to be a single process file. + * * @author Michal Chmielewski (michal.chmielewski@oracle.com) */ public class Templates { /** this file defines the properties for a particular template */ - static final String TEMPLATE_PROPERTIES = "template.properties"; //$NON-NLS-1$ - - /** location within the bundle where we look for templates */ - static final String TEMPLATE_LOCATION = "/templates/"; //$NON-NLS-1$ - + static final String TEMPLATE_PROPERTIES = "template.properties"; //$NON-NLS-1$ + + /** location within the bundle where we look for templates */ + static final String TEMPLATE_LOCATION = "/templates/"; //$NON-NLS-1$ + /** default template file encoding, for a given set of template resources */ - static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$ - + static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$ + /** the main bpel file has this extension */ - @Deprecated // use content type instead of bpel file extensions - static final String BPEL_FILE_EXTENSION = ".bpel"; //$NON-NLS-1$ - + @Deprecated + // use content type instead of bpel file extensions + static final String BPEL_FILE_EXTENSION = ".bpel"; //$NON-NLS-1$ + /** Entries which are directories of the bundle */ static final String BUNDLE_DIRECTORY = "/"; //$NON-NLS-1$ - + /** Key or property under which the name of the template is present */ - static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ - + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ + /** The key name of the template */ static final String PROPERTY_KEY = "key"; //$NON-NLS-1$ - - /** Key or property under which the encoding information for the template resources is present */ + + /** + * Key or property under which the encoding information for the template + * resources is present + */ static final String PROPERTY_ENCODING = "encoding"; //$NON-NLS-1$ /** Key or property under which the description of the template is present */ static final String PROPERTY_DESCRIPTION = "description"; //$NON-NLS-1$ - + /** avoid empty string */ static final String EMPTY = ""; //$NON-NLS-1$ - + static final String[] EMPTY_NAMES = {}; - + /** Templates contribute namespaces to the new file wizard */ Set mNamespaceNames = new TreeSet(); - - /** Templates indexed by name, sorted by name, according to the natural ordering */ - Map mTemplateByName = new TreeMap(); + + /** + * Templates indexed by name, sorted by name, according to the natural + * ordering + */ + Map mTemplateByName = new TreeMap(); /** Templates indexed by id, sorted by name */ - Map mTemplateByKey = new HashMap(); + Map mTemplateByKey = new HashMap(); - /** - * Initialize the template information from the bundle passed. - * This is typically the bundle of the plugin. - * - * @author Michal Chmielewski (michal.chmielewski@oracle.com) - * @param bundle the bundle where the template information ought to be looked for + * Initialize the template information from the bundle passed. This is + * typically the bundle of the plugin. + * + * @author Michal Chmielewski (michal.chmielewski@oracle.com) + * @param bundle + * the bundle where the template information ought to be looked + * for */ - + @SuppressWarnings("nls") - public void initializeFrom ( Bundle bundle ) - { + public void initializeFrom(Bundle bundle) { initializeFrom(bundle, TEMPLATE_LOCATION); } - + /** * @param templateLocation */ - - public void initializeFrom ( String templateLocation ) { + + public void initializeFrom(String templateLocation) { initializeFrom(BPELUIPlugin.INSTANCE.getBundle(), templateLocation); } - + /** * @param bundle * @param templateLocation */ - - @SuppressWarnings({ "nls", "boxing" }) - public void initializeFrom (Bundle bundle, String templateLocation ) { - - Enumeration list = bundle.getEntryPaths( templateLocation ); + + @SuppressWarnings( { "nls", "boxing" }) + public void initializeFrom(Bundle bundle, String templateLocation) { + + Enumeration list = bundle.getEntryPaths(templateLocation); if (list == null) { - return ; + return; } // got some elements, look for "template.properties" - + int count = 0; - + while (list.hasMoreElements()) { String nextRoot = list.nextElement(); - if ( nextRoot.endsWith(BUNDLE_DIRECTORY) == false ) { + if (nextRoot.endsWith(BUNDLE_DIRECTORY) == false) { continue; } - + String nextEntry = nextRoot + TEMPLATE_PROPERTIES; // found another template - + URL nextURL = bundle.getEntry(nextEntry); if (nextURL == null) { // no such thing continue; } - + // looks like we have properties count += 1; - - Properties props = new Properties (); + + Properties props = new Properties(); InputStream is = null; - + try { is = nextURL.openStream(); - props.load( is ); + props.load(is); } catch (IOException e) { BPELUIPlugin.log(e); - - + // skip to the next entry continue; - + } finally { - try { is.close() ; } catch (Throwable t) {} + try { + is.close(); + } catch (Throwable t) { + } } - - + String name = props.getProperty(PROPERTY_NAME); - + // No name, no game. if (name == null) { - continue ; + continue; } - - - String enc = props.getProperty(PROPERTY_ENCODING,DEFAULT_ENCODING); - String desc = props.getProperty(PROPERTY_DESCRIPTION,EMPTY); - - + + String enc = props.getProperty(PROPERTY_ENCODING, DEFAULT_ENCODING); + String desc = props.getProperty(PROPERTY_DESCRIPTION, EMPTY); + // add any namespaces we are supplying ... - mNamespaceNames.addAll( findProperties (props,"namespace.{0}") ); - + mNamespaceNames.addAll(findProperties(props, "namespace.{0}")); + Template template = new Template(); template.mName = name; template.mDescription = desc; template.mProperties = (Map) props; - - mTemplateByName.put ( name, template ); - String id = props.getProperty(PROPERTY_KEY); + + mTemplateByName.put(name, template); + String id = props.getProperty(PROPERTY_KEY); if (id != null) { - mTemplateByKey.put ( id, template ); + mTemplateByKey.put(id, template); } - - + int hole = 3; - for(int i=0; hole >= 0; i++) { - String key = MessageFormat.format("resource.{0}",i); + for (int i = 0; hole >= 0; i++) { + String key = MessageFormat.format("resource.{0}", i); String resourceName = props.getProperty(key); if (resourceName == null) { hole--; continue; } hole = 3; - + key = MessageFormat.format("resource.{0}.name", i); String nameTemplate = props.getProperty(key); - + String entryLoc = nextRoot + resourceName; - - TemplateResource resource = new TemplateResource() ; + + TemplateResource resource = new TemplateResource(); resource.mName = resourceName; - resource.mContent = slurpContent ( bundle.getEntry(entryLoc), enc ); - resource.mNameTemplate = nameTemplate ; - - // add the resource which makes up this "template" - template.add ( resource ); - + resource.mContent = slurpContent(bundle.getEntry(entryLoc), enc); + resource.mNameTemplate = nameTemplate; + + // add the resource which makes up this "template" + template.add(resource); + } - + } - + } - - + /** * Slurp the resource into memory and return as a String. If an exception * occurs, it is logged, and the return value is empty string. * - * @param loc the location from which we should slurp ... - * @param enc the encoding to use - * @return the text + * @param loc + * the location from which we should slurp ... + * @param enc + * the encoding to use + * @return the text */ - - String slurpContent ( URL loc, String enc) { - + + String slurpContent(URL loc, String enc) { + if (loc == null) { return null; } - - StringBuilder sb = new StringBuilder ( 2 * 1048 ); - char[] buf = new char[ 256 ]; + + StringBuilder sb = new StringBuilder(2 * 1048); + char[] buf = new char[256]; InputStreamReader isr = null; - + try { - isr = new InputStreamReader ( loc.openStream(), enc); - + isr = new InputStreamReader(loc.openStream(), enc); + do { int cnt = isr.read(buf); if (cnt < 0) { break; } - sb.append( buf, 0, cnt ); + sb.append(buf, 0, cnt); } while (true); - + } catch (Exception ex) { BPELUIPlugin.log(ex); } finally { - try {isr.close(); } catch (Throwable t) {} + try { + isr.close(); + } catch (Throwable t) { + } } - - - return sb.toString(); + + return sb.toString(); } - - - - - List findProperties ( Properties props, String pattern ) { - + + List findProperties(Properties props, String pattern) { + List list = new ArrayList(); int hole = 3; - - for(int i=0; hole >= 0; i++) { - - String key = MessageFormat.format(pattern, new Object[] { new Integer(i) } ); - String val = props.getProperty(key,null); + + for (int i = 0; hole >= 0; i++) { + + String key = MessageFormat.format(pattern, + new Object[] { new Integer(i) }); + String val = props.getProperty(key, null); if (val != null) { - list.add ( val ); + list.add(val); hole = 3; } else { hole--; } } - + return list; } - + /** * @param key * @return the template whose key is key */ - - public Template getTemplateByKey ( String key ) { + + public Template getTemplateByKey(String key) { return mTemplateByKey.get(key); } - - - /** - * Return the template definition (which includes other resources that - * may be present) to the caller. + + /** + * Return the template definition (which includes other resources that may + * be present) to the caller. * - * @param name name of the template + * @param name + * name of the template * @return the template definition, including template resources */ - - public Template getTemplateByName ( String name ) - { + + public Template getTemplateByName(String name) { return mTemplateByName.get(name); } - - - /** - * - * @return Return the namespaces contributed by the templates. + + /** + * + * @return Return the namespaces contributed by the templates. */ - - public String[] getNamespaceNames () - { - return mNamespaceNames.toArray( EMPTY_NAMES ); + + public String[] getNamespaceNames() { + return mNamespaceNames.toArray(EMPTY_NAMES); } - - - + /** * Return the template names that have been discovered. * * @return Return the template names. */ - - public String [] getTemplateNames () - { - return mTemplateByName.keySet().toArray( EMPTY_NAMES ); + + public String[] getTemplateNames() { + return mTemplateByName.keySet().toArray(EMPTY_NAMES); } - - - + /** - * A given "BPEL Process" Template has a name, description, and - * a list of resources (file templates) that will be used to create the initial + * A given "BPEL Process" Template has a name, description, and a list of + * resources (file templates) that will be used to create the initial * process source file. * - * @author Michal Chmielewski (michal.chmielewski@oracle.com) - * + * @author Michal Chmielewski (michal.chmielewski@oracle.com) + * */ - + public class Template { - + /** Name of the process template */ String mName; - + /** Description of this process template */ - String mDescription ; - - Map mProperties ; - - /** list of resources that this template has (1-N) */ - List mResources = new ArrayList(); + String mDescription; + + Map mProperties; + /** list of resources that this template has (1-N) */ + List mResources = new ArrayList(); /** * @return the name @@ -361,12 +358,11 @@ return mName; } - - void add ( TemplateResource resource ) { + void add(TemplateResource resource) { mResources.add(resource); resource.mTemplate = this; } - + /** * @return the template resources */ @@ -379,20 +375,20 @@ */ public String getDescription() { return mDescription; - } - + } + /** * Return the property under the key or null if not found. + * * @param key * @return the property under the key, or null. */ - - public String getProperty ( String key ) { + + public String getProperty(String key) { return mProperties.get(key); } - - TemplateResource lookupResource ( String name ) { + TemplateResource lookupResource(String name) { String name2 = mProperties.get(name); for (TemplateResource resource : mResources) { if (name.equals(resource.mName)) { @@ -404,104 +400,125 @@ } return null; } - + } - + /** - * A template resource is the actual file which will be used to create - * the source file or other auxiliary files for the BPEL process source. + * A template resource is the actual file which will be used to create the + * source file or other auxiliary files for the BPEL process source. * * @author Michal Chmielewski, (michal.chmielewski@oracle.com) * */ - + public class TemplateResource { - + /** The template I belong to */ Template mTemplate = null; - + /** Name of the resource (from the bundle) */ - String mName ; - + String mName; + /** The content of the resource (slurped from the bundle) */ String mContent; - /** The name template, that is, the file name template if depended on process name */ + /** + * The name template, that is, the file name template if depended on + * process name + */ String mNameTemplate; - + /** * @return the content */ public String getContent() { return mContent; } - + /** * @return the name */ public String getName() { return mName; } - - + /** * Process the content of the template and replace anything within * ${...} by the corresponding key prent in the map passed. * - * @param args the keys that will be replaced in the content + * @param args + * the keys that will be replaced in the content * @return the replaced content */ - - public String process ( Map args ) { - - return process ( mContent, args ); + + public String process(Map args) { + + return process(mContent, args); } - - + /** * Process the content of the template and replace anything within * ${...} by the corresponding key present in the map passed. * - * @param args the keys that will be replaced in the content + * @param args + * the keys that will be replaced in the content * @return the replaced content */ - + @SuppressWarnings("nls") - String process (String src, Map args ) - { + String process(String src, Map args) { // empty content, empty result if (src == null) { return ""; } - StringBuilder sb = new StringBuilder ( src.length() ); - int cursor = 0; + + // add the service and binding content + int start = src.indexOf(""); + if (start > 0) { + StringBuffer ss = new StringBuffer(src.substring(0, start)); + if ("Asynchronous BPEL Process".equals(args.get("type"))) { + if ("soap".equals(args.get("protocol"))) { + ss.append(WSDLServiceDetail.Async_SOAPDetail); + } else { + ss.append(WSDLServiceDetail.Async_HTTPDetail); + } + } else if ("Synchronous BPEL Process".equals(args.get("type"))) { + if ("soap".equals(args.get("protocol"))) { + ss.append(WSDLServiceDetail.Sync_SOAPDetail); + } else { + ss.append(WSDLServiceDetail.Sync_HTTPDetail); + } + } + ss.append(""); + src = ss.toString(); + } + StringBuilder sb = new StringBuilder(src.length()); + int cursor = 0; do { - int openReplace = src.indexOf("${", cursor); + int openReplace = src.indexOf("${", cursor); if (openReplace < 0) { break; } - sb.append( src.substring(cursor,openReplace)); + sb.append(src.substring(cursor, openReplace)); cursor = openReplace + 2; - int closeReplace = src.indexOf("}",cursor); - if (closeReplace < 0) { + int closeReplace = src.indexOf("}", cursor); + if (closeReplace < 0) { return sb.toString(); } - - String expr = src.substring(cursor, closeReplace).trim() ; - sb.append( lookup(expr,args) ); - + + String expr = src.substring(cursor, closeReplace).trim(); + sb.append(lookup(expr, args)); + cursor = closeReplace + 1; } while (true); - + // the last segment - sb.append( src.substring(cursor) ); + sb.append(src.substring(cursor)); return sb.toString(); } - @SuppressWarnings("nls") - - Object lookup ( String key, Map args) { + Object lookup(String key, Map args) { Object value = null; TemplateResource r = null; if (key.startsWith(":include:")) { @@ -512,46 +529,45 @@ } } else if (key.startsWith(":parse:")) { key = key.substring(7); - r = mTemplate.lookupResource (key); + r = mTemplate.lookupResource(key); /** Avoid recursion at this point */ if (r != null && r != this) { - value = r.process( args ); + value = r.process(args); } - } else { + } else { value = args.get(key); if (value == null) { value = mTemplate.mProperties.get(key); - } + } } return value; } - + /** - * Return the name of the resource + * Return the name of the resource * - * @param args map of arguments that are used in replacing + * @param args + * map of arguments that are used in replacing * @return the name of the resource, after token replacement. */ - - public String getName (Map args) { - + + public String getName(Map args) { + if (mNameTemplate == null) { return mName; - } - return process (mNameTemplate, args); + } + return process(mNameTemplate, args); } - - + /** - * Ask if this TemplateResource is specifically a BPEL source file. + * Ask if this TemplateResource is specifically a BPEL source file. * - * @return Answer true if the extension is .bpel + * @return Answer true if the extension is .bpel */ - - public boolean isProcess() - { - return mName.endsWith( BPEL_FILE_EXTENSION ); - } + + public boolean isProcess() { + return mName.endsWith(BPEL_FILE_EXTENSION); + } } - + } Index: src/org/eclipse/bpel/ui/wizards/NewFileWizardPage2.java =================================================================== --- src/org/eclipse/bpel/ui/wizards/NewFileWizardPage2.java (revision 21569) +++ src/org/eclipse/bpel/ui/wizards/NewFileWizardPage2.java (working copy) @@ -43,7 +43,7 @@ super(pageName); setPageComplete(false); - setTitle(Messages.NewFileWizardPage1_2); + setTitle(Messages.NewFileWizardPage2_3); setDescription(Messages.NewFileWizardPage2_0); setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER )); Index: src/org/eclipse/bpel/ui/wizards/WSDLServiceDetail.java =================================================================== --- src/org/eclipse/bpel/ui/wizards/WSDLServiceDetail.java (revision 0) +++ src/org/eclipse/bpel/ui/wizards/WSDLServiceDetail.java (revision 0) @@ -0,0 +1,11 @@ +package org.eclipse.bpel.ui.wizards; + +public class WSDLServiceDetail { + + public static final String Sync_SOAPDetail = "\n\n \n \n \n \n \n \n \n \n \n \n \n \n\n\n \n \n \n \n \n"; + public static final String Sync_HTTPDetail = "\n\n \n \n \n \n \n \n \n \n \n \n \n \n\n\n \n \n \n \n \n"; + public static final String Async_SOAPDetail = "\n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n\n\n \n \n \n \n \n\n \n \n \n \n \n"; + public static final String Async_HTTPDetail = "\n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n\n\n \n \n \n \n \n\n \n \n \n \n \n"; + + +} Index: src/org/eclipse/bpel/ui/wizards/messages.properties =================================================================== --- src/org/eclipse/bpel/ui/wizards/messages.properties (revision 21569) +++ src/org/eclipse/bpel/ui/wizards/messages.properties (working copy) @@ -1,4 +1,5 @@ NewFileWizard_1=New BPEL Process +NewFileWizardPage1_Name=ProcessPage NewFileWizardPage1_2=Create a BPEL Process File NewFileWizardPage1_3=Create a 2.0 BPEL file. NewFileWizardPage1_4=Process Details @@ -7,11 +8,24 @@ NewFileWizardPage1_7=Template: NewFileWizardPage1_8=Specify the name of this BPEL file. NewFileWizardPage1_9=Abstract Process -NewFileWizardPage2_0=Select location for the BPEL source file. -NewFileWizardPage2_1=Select Project or Folder for the BPEL file. +NewFileWizardPage2_Name=LocationPage +NewFileWizardPage2_0=Select location for the BPEL source files. +NewFileWizardPage2_1=Select Project or Folder for the BPEL files. NewFileWizardPage2_2= +NewFileWizardPage2_3=Select Files Location NewFileWizardPage1_10=Name must not include a space. NewFileWizardPage1_11=Namespace of the process cannot be empty. +NewFileWizard_WSDLCustomPage_Name=WSDLPage +NewFileWizard_WSDLCustomPage_Title=Create a WSDL File +NewFileWizard_WSDLCustomPage_Description=Create a WSDL File for the BPEL Process +NewFileWizard_WSDLCustomPage_WSDLGroup=WSDL Details +NewFileWizard_WSDLCustomPage_ServiceLable=Service Name +NewFileWizard_WSDLCustomPage_PortLabel=Port Name +NewFileWizard_WSDLCustomPage_AddressLabel=Service Address +NewFileWizard_WSDLCustomPage_BindingLabel=Binding Protocol +Error_NewFileWizard_WSDLCustomPage_Name_Empty=Specify a {0} for the BPEL process in the WSDL file. +Error_NewFileWizard_WSDLCustomPage_Name_Space={0} must not include a space. +Error_NewFileWizard_WSDLCustomPage_Protocol=The Binding Protocol must be 'SOAP' or 'HTTP'. BPELCreateOperation_0=Creating process from template ... CreatePartnerLinkWizard_0=Create Partner Link Type CreatePartnerLinkWizard_2=Create new Partner Link Type Index: src/org/eclipse/bpel/ui/wizards/WSDLCustomPage.java =================================================================== --- src/org/eclipse/bpel/ui/wizards/WSDLCustomPage.java (revision 0) +++ src/org/eclipse/bpel/ui/wizards/WSDLCustomPage.java (revision 0) @@ -0,0 +1,210 @@ +package org.eclipse.bpel.ui.wizards; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.bpel.ui.BPELUIPlugin; +import org.eclipse.bpel.ui.IBPELUIConstants; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +public class WSDLCustomPage extends WizardPage { + + /** Service name field */ + private Text serviceNameField; + + /** Port name field */ + private Text portNameField; + + /** Address name field */ + private Text addressField; + + /** binding protocol */ + Combo bindingField; + + private Map mArgs = new HashMap(); + + static final String EMPTY = ""; + static final String SOAP_NAMESPACE="http://schemas.xmlsoap.org/wsdl/soap/"; + static final String HTTP_NAMESPACE="http://schemas.xmlsoap.org/wsdl/http/"; + + private static final int SIZING_TEXT_FIELD_WIDTH = 250; + + private Listener validateListner = new Listener() { + public void handleEvent(Event event) { + setPageComplete(validatePage()); + } + }; + + /** + * New File Wizard,wsdl page that custom the generated wsdl file + * + * @param pageName + */ + protected WSDLCustomPage(String pageName) { + super(pageName); + setTitle(Messages.NewFileWizard_WSDLCustomPage_Title); + setDescription(Messages.NewFileWizard_WSDLCustomPage_Description); + setImageDescriptor(BPELUIPlugin.INSTANCE + .getImageDescriptor(IBPELUIConstants.ICON_WIZARD_BANNER)); + } + + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + composite.setFont(parent.getFont()); + initializeDialogUnits(parent); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + createWSDLGroup(composite); + setErrorMessage(null); + setMessage(null); + setControl(composite); + } + + private final void createWSDLGroup(Composite parent) { + Group wsdlGroup = new Group(parent, SWT.NONE); + wsdlGroup.setText(Messages.NewFileWizard_WSDLCustomPage_WSDLGroup); + wsdlGroup.setLayout(new GridLayout()); + wsdlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Composite fields = new Composite(wsdlGroup, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + fields.setLayout(layout); + fields.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // new service label + Label serviceLabel = new Label(fields, SWT.NONE); + serviceLabel + .setText(Messages.NewFileWizard_WSDLCustomPage_ServiceLable); + serviceLabel.setFont(parent.getFont()); + + // new service name entry field + serviceNameField = new Text(fields, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + serviceNameField.setLayoutData(data); + serviceNameField.setFont(parent.getFont()); + serviceNameField.addListener(SWT.Modify, validateListner); + + // new port label + Label portLabel = new Label(fields, SWT.NONE); + portLabel.setText(Messages.NewFileWizard_WSDLCustomPage_PortLabel); + portLabel.setFont(parent.getFont()); + + // new port name entry field + portNameField = new Text(fields, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + portNameField.setLayoutData(data); + portNameField.setFont(parent.getFont()); + portNameField.addListener(SWT.Modify, validateListner); + + // new address label + Label addressLabel = new Label(fields, SWT.NONE); + addressLabel + .setText(Messages.NewFileWizard_WSDLCustomPage_AddressLabel); + addressLabel.setFont(parent.getFont()); + + // new address name entry field + addressField = new Text(fields, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + addressField.setLayoutData(data); + addressField.setFont(parent.getFont()); + addressField.addListener(SWT.Modify, validateListner); + + Label bindingLabel = new Label(fields, SWT.NONE); + bindingLabel + .setText(Messages.NewFileWizard_WSDLCustomPage_BindingLabel); + bindingLabel.setFont(parent.getFont()); + // new binding protocol entry field + bindingField = new Combo(fields, SWT.DROP_DOWN | SWT.SIMPLE); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + bindingField.setLayoutData(data); + bindingField.setFont(parent.getFont()); + + // add the binding protocol values + bindingField.setItems(new String[] { "SOAP", "HTTP" }); + bindingField.setText("SOAP"); + bindingField.addListener(SWT.Modify, validateListner); + } + + protected boolean validatePage() { + String serviceName = serviceNameField.getText().trim(); + if (isEmptyOrSpace(serviceName, "Service Name")) { + return false; + } + String portName = portNameField.getText().trim(); + if (isEmptyOrSpace(portName, "Port Name")) { + return false; + } + String addressName = addressField.getText().trim(); + if (isEmptyOrSpace(addressName, "Service Address")) { + return false; + } + String protocol = bindingField.getText().trim(); + if (!("SOAP".equals(protocol) || "HTTP".equals(protocol))) { + setErrorMessage(Messages.Error_NewFileWizard_WSDLCustomPage_Protocol); + return false; + } + setErrorMessage(null); + + // Template arguments + mArgs.put("serviceName", serviceName); //$NON-NLS-1$ + mArgs.put("portName", portName); //$NON-NLS-1$ + mArgs.put("address", addressName); //$NON-NLS-1$ + mArgs.put("protocol", protocol.toLowerCase()); //$NON-NLS-1$ + if("SOAP".equals(protocol)){ + mArgs.put("protocolNamespace", SOAP_NAMESPACE); + } else { + mArgs.put("protocolNamespace", HTTP_NAMESPACE); + } + return true; + } + + private boolean isEmptyOrSpace(String name, String element) { + if (name.equals(EMPTY)) { + setErrorMessage(NLS.bind( + Messages.Error_NewFileWizard_WSDLCustomPage_Name_Empty, + element)); + return true; + } + + if (name.indexOf(" ") > -1) { + setErrorMessage(NLS.bind( + Messages.Error_NewFileWizard_WSDLCustomPage_Name_Space, + element)); + return true; + } + return false; + } + + public Text getServiceNameField() { + return serviceNameField; + } + + public Text getPortNameField() { + return portNameField; + } + + public Text getAddressField() { + return addressField; + } + + public Map getMap() { + return mArgs; + } + +} Index: src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java =================================================================== --- src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java (revision 21569) +++ src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java (working copy) @@ -10,12 +10,11 @@ * Oracle Corporation *******************************************************************************/ - package org.eclipse.bpel.ui.wizards; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -27,8 +26,11 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -39,419 +41,437 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; - import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; /** * - * @author Michal Chmielewski (michal.chmielewski@oracle.com) - * + * @author Michal Chmielewski (michal.chmielewski@oracle.com) + * */ -public class NewFileWizardPage1 extends WizardPage -{ +@SuppressWarnings("restriction") +public class NewFileWizardPage1 extends WizardPage { static final String EMPTY = ""; //$NON-NLS-1$ - + /** last namespace used in creating a project, saved in dialog settings */ static final String LAST_NAMESPACE_KEY = "last.namespace.used"; //$NON-NLS-1$ /** Process name field */ - private Text processNameField; + private Text processNameField; - /** which namespace to use to create the process */ - Combo processNamespaceField; + /** which namespace to use to create the process */ + Combo processNamespaceField; - /** which template to use to create a process */ - Combo processTemplateField; - - /** Template description, in summary */ - Text templateDescription; + /** which template to use to create a process */ + Combo processTemplateField; - /** option for creating an abstract process */ - Button processAbstractOptionButton; - - private Map mArgs = new HashMap (3); - - private String[] lastNS; - private List temNS; - - - - private Listener validateListner = new Listener() { + /** Template description, in summary */ + Text templateDescription; + + /** option for creating an abstract process */ + Button processAbstractOptionButton; + + private Map mArgs = new HashMap(3); + + private String[] lastNS; + private List temNS; + + private Listener validateListner = new Listener() { public void handleEvent(Event event) { - setPageComplete(validatePage()); + setPageComplete(validatePage()); } - }; - - - // constants - private static final int SIZING_TEXT_FIELD_WIDTH = 250; + }; + + // constants + private static final int SIZING_TEXT_FIELD_WIDTH = 250; - /** - * Creates a new project creation wizard page. - * - * @param pageName the name of this page - */ - public NewFileWizardPage1(String pageName) - { - super(pageName); - setPageComplete(false); - + /** + * Creates a new project creation wizard page. + * + * @param pageName + * the name of this page + */ + public NewFileWizardPage1(String pageName) { + super(pageName); + setPageComplete(false); + setTitle(Messages.NewFileWizardPage1_2); setDescription(Messages.NewFileWizardPage1_3); - - setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER )); - } - - /** - * Method declared on IDialogPage. - * @param parent the parent composite that we must attach ourselves to - */ - - public void createControl (Composite parent) - { - Composite composite = new Composite(parent, SWT.NULL); - composite.setFont(parent.getFont()); - initializeDialogUnits(parent); + setImageDescriptor(BPELUIPlugin.INSTANCE + .getImageDescriptor(IBPELUIConstants.ICON_WIZARD_BANNER)); + } - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + /** + * Method declared on IDialogPage. + * + * @param parent + * the parent composite that we must attach ourselves to + */ + + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + composite.setFont(parent.getFont()); + + initializeDialogUnits(parent); - createProjectGroup(composite); - - setPageComplete( validatePage() ); - - // no errors on opening up the wizard - setErrorMessage(null); - setMessage(null); - setControl(composite); - - // figure out the what needs to go - } - - /** - * Creates the project name specification controls. - * - * @param parent the parent composite - */ - private final void createProjectGroup(Composite parent) - { - Group projectGroup = new Group(parent, SWT.NONE); - projectGroup.setText(Messages.NewFileWizardPage1_4); - projectGroup.setLayout(new GridLayout()); - projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - - Composite fields = new Composite ( projectGroup, SWT.NONE ); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - fields.setLayout(layout); - fields.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - // new project label - Label projectLabel = new Label(fields, SWT.NONE); - projectLabel.setText( Messages.NewFileWizardPage1_5); - projectLabel.setFont( parent.getFont() ); + createProjectGroup(composite); - // new project name entry field - processNameField = new Text(fields, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - processNameField.setLayoutData(data); - processNameField.setFont(parent.getFont()); + setPageComplete(validatePage()); - processNameField.addListener(SWT.Modify, validateListner); + // no errors on opening up the wizard + setErrorMessage(null); + setMessage(null); + setControl(composite); - // new project label - Label namespaceLabel = new Label(fields, SWT.NONE); - namespaceLabel.setText( Messages.NewFileWizardPage1_6); - namespaceLabel.setFont(parent.getFont()); - - // new project name entry field - processNamespaceField = new Combo( fields, SWT.DROP_DOWN | SWT.SIMPLE ); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - processNamespaceField.setLayoutData(data); - processNamespaceField.setFont(parent.getFont()); - - // add the namespace values - processNamespaceField.setItems( getProcessNameSpaces() ); - processNamespaceField.addListener(SWT.Modify, validateListner); - - String lastNamespace = null; - if(lastNS != null){ - if(lastNS.length > 0){ - lastNamespace = lastNS[0]; - } - } - if (lastNamespace != null) { - processNamespaceField.setText( lastNamespace ); - } + // figure out the what needs to go + } - // new project type - Label typeLabel = new Label(fields, SWT.NONE); - typeLabel.setText( Messages.NewFileWizardPage1_7); - typeLabel.setFont( parent.getFont() ); + /** + * Creates the project name specification controls. + * + * @param parent + * the parent composite + */ + private final void createProjectGroup(Composite parent) { + Group projectGroup = new Group(parent, SWT.NONE); + projectGroup.setText(Messages.NewFileWizardPage1_4); + projectGroup.setLayout(new GridLayout()); + projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // new project type selector - processTemplateField = new Combo( fields, SWT.DROP_DOWN | SWT.SIMPLE | SWT.READ_ONLY ); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - processTemplateField.setLayoutData( data ); - - processTemplateField.addListener(SWT.Modify, new Listener () { + Composite fields = new Composite(projectGroup, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + fields.setLayout(layout); + fields.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // new project label + Label projectLabel = new Label(fields, SWT.NONE); + projectLabel.setText(Messages.NewFileWizardPage1_5); + projectLabel.setFont(parent.getFont()); + + // new project name entry field + processNameField = new Text(fields, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + processNameField.setLayoutData(data); + processNameField.setFont(parent.getFont()); + + processNameField.addListener(SWT.Modify, validateListner); + + // new project label + Label namespaceLabel = new Label(fields, SWT.NONE); + namespaceLabel.setText(Messages.NewFileWizardPage1_6); + namespaceLabel.setFont(parent.getFont()); + + // new project name entry field + processNamespaceField = new Combo(fields, SWT.DROP_DOWN | SWT.SIMPLE); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + processNamespaceField.setLayoutData(data); + processNamespaceField.setFont(parent.getFont()); + + // add the namespace values + processNamespaceField.setItems(getProcessNameSpaces()); + processNamespaceField.addListener(SWT.Modify, validateListner); + + String lastNamespace = null; + if (lastNS != null) { + if (lastNS.length > 0) { + lastNamespace = lastNS[0]; + } + } + if (lastNamespace != null) { + processNamespaceField.setText(lastNamespace); + } + + // new project type + Label typeLabel = new Label(fields, SWT.NONE); + typeLabel.setText(Messages.NewFileWizardPage1_7); + typeLabel.setFont(parent.getFont()); + + // new project type selector + processTemplateField = new Combo(fields, SWT.DROP_DOWN | SWT.SIMPLE + | SWT.READ_ONLY); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + processTemplateField.setLayoutData(data); + + processTemplateField.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { String val = processTemplateField.getText().trim(); - Template template = BPELUIPlugin.INSTANCE.getTemplates().getTemplateByName( val ); + mArgs.put("type", val); + Template template = BPELUIPlugin.INSTANCE.getTemplates() + .getTemplateByName(val); if (template != null) { String txt = template.getDescription(); - templateDescription.setText ( txt == null ? EMPTY : txt); + templateDescription.setText(txt == null ? EMPTY : txt); } - - } - }); - - - - templateDescription = new Text(projectGroup,SWT.READ_ONLY | SWT.WRAP | SWT.SCROLL_LINE ); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - data.heightHint = 60; - templateDescription.setLayoutData(data); - templateDescription.setFont(parent.getFont()); - - // Scan directories in the "templates" folder - // and built up a list - - String templates[] = BPELUIPlugin.INSTANCE.getTemplates().getTemplateNames(); - processTemplateField.setItems(templates); - - // Select the top one. - if (templates.length > 0) { - processTemplateField.select(0); - } - - //add checkbox for abstract process option - processAbstractOptionButton = new Button(projectGroup, SWT.CHECK ); - processAbstractOptionButton.setText(Messages.NewFileWizardPage1_9); - processAbstractOptionButton.setFont(parent.getFont() ); - processAbstractOptionButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent event) { - setPageComplete(validatePage()); - } - }); - } - + + } + }); + + templateDescription = new Text(projectGroup, SWT.READ_ONLY | SWT.WRAP + | SWT.SCROLL_LINE); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + data.heightHint = 60; + templateDescription.setLayoutData(data); + templateDescription.setFont(parent.getFont()); + + // Scan directories in the "templates" folder + // and built up a list + + String templates[] = BPELUIPlugin.INSTANCE.getTemplates() + .getTemplateNames(); + processTemplateField.setItems(templates); - private String[] getProcessNameSpaces() { - // project specification group - IDialogSettings settings = getWizard().getDialogSettings(); - String ns = settings.get( LAST_NAMESPACE_KEY ); - ArrayList list = new ArrayList(); - if(ns != null && !"".equals(ns)) { - lastNS = ns.split(";"); - for(String str : lastNS){ - list.add(str); - } - } - temNS = new ArrayList(); - for(String str : BPELUIPlugin.INSTANCE.getTemplates().getNamespaceNames()){ - temNS.add(str); - } - list.addAll(temNS); - String[] a = new String[(lastNS == null ? 0 : lastNS.length) + temNS.size()]; + // Select the top one. + if (templates.length > 0) { + processTemplateField.select(0); + } + + // add checkbox for abstract process option + processAbstractOptionButton = new Button(projectGroup, SWT.CHECK); + processAbstractOptionButton.setText(Messages.NewFileWizardPage1_9); + processAbstractOptionButton.setFont(parent.getFont()); + processAbstractOptionButton + .addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + setPageComplete(validatePage()); + } + }); + } + + private String[] getProcessNameSpaces() { + // project specification group + IDialogSettings settings = getWizard().getDialogSettings(); + String ns = settings.get(LAST_NAMESPACE_KEY); + ArrayList list = new ArrayList(); + if (ns != null && !"".equals(ns)) { + lastNS = ns.split(";"); + for (String str : lastNS) { + list.add(str); + } + } + temNS = new ArrayList(); + for (String str : BPELUIPlugin.INSTANCE.getTemplates() + .getNamespaceNames()) { + temNS.add(str); + } + list.addAll(temNS); + String[] a = new String[(lastNS == null ? 0 : lastNS.length) + + temNS.size()]; return list.toArray(a); } /** - * Returns the current project name as entered by the user, or its anticipated - * initial value. - * - * @return the project name, its anticipated initial value, or null - * if no project name is known - */ - public String getProjectName() { - return getProjectNameFieldValue(); - } - - /** - * Returns the value of the project name field - * with leading and trailing spaces removed. - * - * @return the project name in the field - */ - private String getProjectNameFieldValue() { - - if (processNameField == null) { - return EMPTY; - } - return processNameField.getText().trim(); - } - + * Returns the current project name as entered by the user, or its + * anticipated initial value. + * + * @return the project name, its anticipated initial value, or + * null if no project name is known + */ + public String getProjectName() { + return getProjectNameFieldValue(); + } + + /** + * Returns the value of the project name field with leading and trailing + * spaces removed. + * + * @return the project name in the field + */ + private String getProjectNameFieldValue() { + + if (processNameField == null) { + return EMPTY; + } + return processNameField.getText().trim(); + } + + /** + * Returns the current project name as entered by the user, or its + * anticipated initial value. + * + * @return the project name, its anticipated initial value, or + * null if no project name is known + */ + public String getProjectNamespace() { - - /** - * Returns the current project name as entered by the user, or its anticipated - * initial value. - * - * @return the project name, its anticipated initial value, or null - * if no project name is known - */ - public String getProjectNamespace() { - - return getProjectNamespaceFieldValue(); - } - /** - * Returns the value of the project name field - * with leading and trailing spaces removed. - * - * @return the project name in the field - */ - private String getProjectNamespaceFieldValue() { - if (processNameField == null) { - return EMPTY; - } - return processNamespaceField.getText().trim(); - } + return getProjectNamespaceFieldValue(); + } - - /** - * Returns whether this page's controls currently all contain valid - * values. - * - * @return true if all controls are valid, and - * false if at least one is invalid - */ - protected boolean validatePage() { - - IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); + /** + * Returns the value of the project name field with leading and trailing + * spaces removed. + * + * @return the project name in the field + */ + private String getProjectNamespaceFieldValue() { + if (processNameField == null) { + return EMPTY; + } + return processNamespaceField.getText().trim(); + } - IDialogSettings settings = getWizard().getDialogSettings(); - - String processName = processNameField.getText(); - - if (processName.equals(EMPTY)) { - setErrorMessage(null); - setMessage( Messages.NewFileWizardPage1_8); - return false; - } + /** + * Returns whether this page's controls currently all contain valid values. + * + * @return true if all controls are valid, and + * false if at least one is invalid + */ + protected boolean validatePage() { - IStatus nameStatus = - workspace.validateName(processName, IResource.FILE); - - if (!nameStatus.isOK()) { - setErrorMessage(nameStatus.getMessage()); - return false; - } - - // Make sure that there are no spaces in the name - if( processName.indexOf( " " ) > -1 ) //$NON-NLS-1$ - { - setErrorMessage(Messages.NewFileWizardPage1_10); - return false; - } - - setErrorMessage(null); - setMessage(null); - - String namespace = processNamespaceField.getText().trim(); - if (namespace.length() < 1) { - setErrorMessage(Messages.NewFileWizardPage1_11); - return false; - } - - String bpelNamespace = (isAbstractOptionButtonChecked())? - BPELConstants.NAMESPACE_ABSTRACT_2007: BPELConstants.NAMESPACE; - - // settings for next time the dialog is used. - settings.put( LAST_NAMESPACE_KEY , addNSToDefault(namespace)) ; - - // Template arguments - mArgs.put("processName", processName ); //$NON-NLS-1$ - mArgs.put("namespace", namespace ); //$NON-NLS-1$ - mArgs.put("bpelNamespace", bpelNamespace ); //$NON-NLS-1$ - mArgs.put("date", new Date() ); //$NON-NLS-1$ + IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); - - return true; - } + IDialogSettings settings = getWizard().getDialogSettings(); - /** - * add the last namespace to the default namespace array - * - * @param namespace - * @return - */ - private String addNSToDefault(String namespace) { - StringBuffer ns = new StringBuffer(); - if(!"".equals(namespace)&& !temNS.contains(namespace)){ - ns.append(namespace).append(";");; - if(lastNS != null){ - for(int i = 0 ; i 8){ - break; - } - } - } - } - } else { - if(lastNS != null){ - for(String str : lastNS){ - ns.append(str).append(";"); - } - } - } + String processName = processNameField.getText(); + + if (processName.equals(EMPTY)) { + setErrorMessage(null); + setMessage(Messages.NewFileWizardPage1_8); + return false; + } + + IStatus nameStatus = workspace + .validateName(processName, IResource.FILE); + + if (!nameStatus.isOK()) { + setErrorMessage(nameStatus.getMessage()); + return false; + } + + // Make sure that there are no spaces in the name + if (processName.indexOf(" ") > -1) //$NON-NLS-1$ + { + setErrorMessage(Messages.NewFileWizardPage1_10); + return false; + } + + setErrorMessage(null); + setMessage(null); + + String namespace = processNamespaceField.getText().trim(); + if (namespace.length() < 1) { + setErrorMessage(Messages.NewFileWizardPage1_11); + return false; + } + + String bpelNamespace = (isAbstractOptionButtonChecked()) ? BPELConstants.NAMESPACE_ABSTRACT_2007 + : BPELConstants.NAMESPACE; + + // settings for next time the dialog is used. + settings.put(LAST_NAMESPACE_KEY, addNSToDefault(namespace)); + + // Template arguments + mArgs.put("processName", processName); //$NON-NLS-1$ + mArgs.put("namespace", namespace); //$NON-NLS-1$ + mArgs.put("bpelNamespace", bpelNamespace); //$NON-NLS-1$ + mArgs.put("date", new Date()); //$NON-NLS-1$ + + // set the default value of the wsdlpage + setValuesForWSDLPage(processName); + + return true; + } + + private void setValuesForWSDLPage(String processName) { + WSDLCustomPage page = (WSDLCustomPage) this.getWizard().getPage( + Messages.NewFileWizard_WSDLCustomPage_Name); + if (page != null) { + page.getServiceNameField().setText(processName); + page.getPortNameField().setText(processName + "Port"); + page.getAddressField().setText( + "http://localhost:8080/" + processName); + } + } + + public IWizardPage getNextPage() { + if (processAbstractOptionButton.getSelection()) { + return this.getWizard().getPage(Messages.NewFileWizardPage2_Name); + } + return super.getNextPage(); + } + + /** + * add the last namespace to the default namespace array + * + * @param namespace + * @return + */ + private String addNSToDefault(String namespace) { + StringBuffer ns = new StringBuffer(); + if (!"".equals(namespace) && !temNS.contains(namespace)) { + ns.append(namespace).append(";"); + ; + if (lastNS != null) { + for (int i = 0; i < lastNS.length; i++) { + if (namespace.equals(lastNS[i])) { + continue; + } else { + ns.append(lastNS[i]).append(";"); + if (i > 8) { + break; + } + } + } + } + } else { + if (lastNS != null) { + for (String str : lastNS) { + ns.append(str).append(";"); + } + } + } return ns.toString(); } /** - * @return true if Option for abstract process is checked - */ - private boolean isAbstractOptionButtonChecked() { - return processAbstractOptionButton.getSelection(); - } - - /** - * see @DialogPage.setVisible(boolean) - * @param visible whether should be visible or not - * - */ - - @Override - public void setVisible (boolean visible) { - super.setVisible(visible); - if (visible) { - processNameField.setFocus(); - } - } + * @return true if Option for abstract process is checked + */ + private boolean isAbstractOptionButtonChecked() { + return processAbstractOptionButton.getSelection(); + } + + /** + * see @DialogPage.setVisible(boolean) + * + * @param visible + * whether should be visible or not + * + */ + + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + processNameField.setFocus(); + } + } /** * @return the actual selected template. */ - + public Template getSelectedTemplate() { String txt = processTemplateField.getText().trim(); - return BPELUIPlugin.INSTANCE.getTemplates().getTemplateByName( txt ); + return BPELUIPlugin.INSTANCE.getTemplates().getTemplateByName(txt); } /** * @return the arguments that need to be supplied to the template mechanism. */ - - public Map getArgs() { - + + public Map getArgs() { + return mArgs; } - - } Index: src/org/eclipse/bpel/ui/wizards/Messages.java =================================================================== --- src/org/eclipse/bpel/ui/wizards/Messages.java (revision 21569) +++ src/org/eclipse/bpel/ui/wizards/Messages.java (working copy) @@ -53,4 +53,19 @@ public static String NewFileWizardPage2_0; public static String NewFileWizardPage2_1; public static String NewFileWizardPage2_2; + public static String NewFileWizardPage2_3; + public static String NewFileWizardPage1_Name; + public static String NewFileWizardPage2_Name; + public static String NewFileWizard_WSDLCustomPage_Name; + public static String NewFileWizard_WSDLCustomPage_Title; + public static String NewFileWizard_WSDLCustomPage_Description; + public static String NewFileWizard_WSDLCustomPage_ServiceLable; + public static String NewFileWizard_WSDLCustomPage_PortLabel; + public static String NewFileWizard_WSDLCustomPage_AddressLabel; + public static String NewFileWizard_WSDLCustomPage_WSDLGroup; + public static String NewFileWizard_WSDLCustomPage_BindingLabel; + + public static String Error_NewFileWizard_WSDLCustomPage_Name_Empty; + public static String Error_NewFileWizard_WSDLCustomPage_Name_Space; + public static String Error_NewFileWizard_WSDLCustomPage_Protocol; } Index: src/org/eclipse/bpel/ui/wizards/NewFileWizard.java =================================================================== --- src/org/eclipse/bpel/ui/wizards/NewFileWizard.java (revision 21569) +++ src/org/eclipse/bpel/ui/wizards/NewFileWizard.java (working copy) @@ -10,10 +10,10 @@ * Oracle Corporation *******************************************************************************/ - package org.eclipse.bpel.ui.wizards; import java.lang.reflect.InvocationTargetException; +import java.util.Map; import org.eclipse.bpel.ui.BPELUIPlugin; import org.eclipse.core.resources.IContainer; @@ -31,41 +31,43 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; - /** - * Wizard for the new process template. - * - * @author Michal Chmielewski (michal.chmielewski@oracle.com) - * + * Wizard for the new process template. + * + * @author Michal Chmielewski (michal.chmielewski@oracle.com) + * */ public class NewFileWizard extends Wizard implements INewWizard { /** The id of our BPEL editor */ static protected final String BPEL_EDITOR_ID = "org.eclipse.bpel.ui.bpeleditor"; //$NON-NLS-1$ - + /** The container where the file(s) will be created */ - private IContainer mContainer ; - + private IContainer mContainer; + private IWorkbench fWorkbench; - + /** The 1st page of the wizard */ private NewFileWizardPage1 fMainPage; /** The 2nd page of the wizard */ private NewFileWizardPage2 fContainerPage; - + /** The 3nd page of the wizard */ + private WSDLCustomPage wsdlPage; + /** * Create a brand new shining Create Project Wizard for BPEL. */ public NewFileWizard() { - + setNeedsProgressMonitor(true); - setDialogSettings(BPELUIPlugin.INSTANCE.getDialogSettingsFor(this)); + setDialogSettings(BPELUIPlugin.INSTANCE.getDialogSettingsFor(this)); setHelpAvailable(false); - + this.setWindowTitle(Messages.NewFileWizard_1); + } /** @@ -83,15 +85,14 @@ public void init(IWorkbench workbench, IStructuredSelection currentSelection) { fWorkbench = workbench; - mContainer = getBPELContainer( currentSelection.getFirstElement() ); + mContainer = getBPELContainer(currentSelection.getFirstElement()); } - protected void selectAndReveal(IResource newResource) { - BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow()); + BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench + .getActiveWorkbenchWindow()); } - protected void openResource(final IFile resource) { if (resource.getType() != IResource.FILE) { return; @@ -107,9 +108,10 @@ final Display display = getShell().getDisplay(); display.asyncExec(new Runnable() { public void run() { - try { - IDE.openEditor(activePage, resource, BPEL_EDITOR_ID, true); - // IDE.openEditor(activePage, resource, true); + try { + IDE.openEditor(activePage, resource, BPEL_EDITOR_ID, + true); + // IDE.openEditor(activePage, resource, true); } catch (PartInitException e) { BPELUIPlugin.log(e); } @@ -120,7 +122,6 @@ } } - /** * Perform cancel. Close the wizard and don't do anything else. * @@ -138,14 +139,18 @@ @Override public void addPages() { - - fMainPage = new NewFileWizardPage1(Messages.NewFileWizard_1); - fContainerPage = new NewFileWizardPage2(Messages.NewFileWizard_1); - + + fMainPage = new NewFileWizardPage1(Messages.NewFileWizardPage1_Name); + fContainerPage = new NewFileWizardPage2( + Messages.NewFileWizardPage2_Name); + wsdlPage = new WSDLCustomPage( + Messages.NewFileWizard_WSDLCustomPage_Name); + addPage(fMainPage); + addPage(wsdlPage); addPage(fContainerPage); - - fContainerPage.setPreviousPage( fMainPage ); + wsdlPage.setPreviousPage(fMainPage); + fContainerPage.setPreviousPage(wsdlPage); } /** @@ -160,21 +165,24 @@ public boolean performFinish() { BPELCreateOperation runnable = new BPELCreateOperation(); - + // The container either comes from the 2nd page, explicitely defined // or it comes as the context in the current selection. - + IContainer container = fContainerPage.getResourceContainer(); if (container == null) { container = mContainer; } - - runnable.setContainer( container ); - runnable.setTemplate( fMainPage.getSelectedTemplate () ); - runnable.setArgs( fMainPage.getArgs () ) ; + + runnable.setContainer(container); + runnable.setTemplate(fMainPage.getSelectedTemplate()); + Map map = fMainPage.getArgs(); + map.putAll(wsdlPage.getMap()); + runnable.setArgs(map); + try { - getContainer().run(false, true, runnable); + getContainer().run(false, true, runnable); } catch (InvocationTargetException e) { BPELUIPlugin.log(e); return false; @@ -184,22 +192,21 @@ } IFile res = (IFile) runnable.getElementToOpen(); - if (res != null) { + if (res != null && res.exists()) { openResource(res); } return true; } - /** - * Return the BPEL files container in which we can generate - * process from the template. + * Return the BPEL files container in which we can generate process from the + * template. * * @return the BPEL files IContainer */ - - IContainer getBPELContainer ( Object obj ) { - + + IContainer getBPELContainer(Object obj) { + if (obj == null) { return null; } @@ -209,7 +216,7 @@ project = file.getProject(); } if (obj instanceof IContainer) { - IContainer container = (IContainer)obj; + IContainer container = (IContainer) obj; project = container.getProject(); } if (project != null) { @@ -218,19 +225,18 @@ return bpelContent; } } - return null; + return null; } - /** - * + * * Final condition for the wizard to finish */ - + @Override public boolean canFinish() { - return (fMainPage.isPageComplete() && mContainer != null) || super.canFinish(); + return (fMainPage.isPageComplete() && wsdlPage.isPageComplete() && mContainer != null) + || super.canFinish(); } - - + } Index: templates/sync/sample.wsdl =================================================================== --- templates/sync/sample.wsdl (revision 21682) +++ templates/sync/sample.wsdl (working copy) @@ -4,6 +4,7 @@ xmlns:tns="${namespace}" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:${protocol}="${protocolNamespace}" > Index: templates/async/sample.wsdl =================================================================== --- templates/async/sample.wsdl (revision 21569) +++ templates/async/sample.wsdl (working copy) @@ -4,6 +4,7 @@ xmlns:tns="${namespace}" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:${protocol}="${protocolNamespace}" >