Author: Grid.Qian
Date: 2009-12-14 21:07:40 -0500 (Mon, 14 Dec 2009)
New Revision: 19267
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java
Log:
JBIDE-5456: namespace not saved when creating new process
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java 2009-12-15
02:04:51 UTC (rev 19266)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java 2009-12-15
02:07:40 UTC (rev 19267)
@@ -15,6 +15,8 @@
import java.util.Date;
import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import org.eclipse.bpel.model.util.BPELConstants;
@@ -73,6 +75,9 @@
private Map<String,Object> mArgs = new HashMap<String,Object> (3);
+ private String[] lastNS;
+ private List<String> temNS;
+
private Listener validateListner = new Listener() {
@@ -134,10 +139,7 @@
* @param parent the parent composite
*/
private final void createProjectGroup(Composite parent)
- {
- // project specification group
- IDialogSettings settings = getWizard().getDialogSettings();
-
+ {
Group projectGroup = new Group(parent, SWT.NONE);
projectGroup.setText(Messages.NewFileWizardPage1_4);
projectGroup.setLayout(new GridLayout());
@@ -175,15 +177,20 @@
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
processNamespaceField.setLayoutData(data);
processNamespaceField.setFont(parent.getFont());
- String lastNamespace = settings.get( LAST_NAMESPACE_KEY );
- if (lastNamespace != null) {
- processNamespaceField.setText( lastNamespace );
- }
// add the namespace values
- processNamespaceField.setItems(
BPELUIPlugin.INSTANCE.getTemplates().getNamespaceNames() );
+ 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);
@@ -241,9 +248,27 @@
}
-
+ private String[] getProcessNameSpaces() {
+ // project specification group
+ IDialogSettings settings = getWizard().getDialogSettings();
+ String ns = settings.get( LAST_NAMESPACE_KEY );
+ ArrayList<String> list = new ArrayList<String>();
+ if(ns != null && !"".equals(ns)) {
+ lastNS = ns.split(";");
+ for(String str : lastNS){
+ list.add(str);
+ }
+ }
+ temNS = new ArrayList<String>();
+ 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.
*
@@ -344,7 +369,7 @@
BPELConstants.NAMESPACE_ABSTRACT_2007: BPELConstants.NAMESPACE;
// settings for next time the dialog is used.
- settings.put( LAST_NAMESPACE_KEY , namespace) ;
+ settings.put( LAST_NAMESPACE_KEY , addNSToDefault(namespace)) ;
// Template arguments
mArgs.put("processName", processName ); //$NON-NLS-1$
@@ -356,8 +381,39 @@
return true;
}
-
/**
+ * 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() {
Show replies by date