ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r190352 - in /webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen: eclipse/CodeGenWizard.java eclipse/ui/OptionsPage.java eclipse/ui/OutputPage.java eclipse/ui/WSDLFileSelectionPage.java resource/Codegen.properties
Date Mon, 13 Jun 2005 05:09:30 GMT
Author: ajith
Date: Sun Jun 12 22:09:30 2005
New Revision: 190352

URL: http://svn.apache.org/viewcvs?rev=190352&view=rev
Log:
Checking in the following changes by courtesy of Mike Haller
1.Commented the code
2.Added persistent support for the wizard
3.Fixed some minor bugs

Modified:
    webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/CodeGenWizard.java
    webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OptionsPage.java
    webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OutputPage.java
    webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java
    webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/resource/Codegen.properties

Modified: webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/CodeGenWizard.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/CodeGenWizard.java?rev=190352&r1=190351&r2=190352&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/CodeGenWizard.java (original)
+++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/CodeGenWizard.java Sun Jun 12 22:09:30 2005
@@ -1,9 +1,11 @@
+
 package org.apache.axis.tool.codegen.eclipse;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -20,6 +22,8 @@
 import org.apache.axis.wsdl.codegen.CommandLineOption;
 import org.apache.axis.wsdl.codegen.CommandLineOptionConstants;
 import org.apache.wsdl.WSDLDescription;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -27,183 +31,254 @@
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
 /**
  * The main wizard for the codegen wizard
  */
 
-public class CodeGenWizard extends Wizard implements INewWizard {
-    private WSDLFileSelectionPage page1;
-
-    private OptionsPage page2;
-
-    private OutputPage page3;
-
-    private ISelection selection;
-
-    private boolean canFinish = false;
-
-    /**
-     * Constructor for CodeGenWizard.
-     */
-    public CodeGenWizard() {
-        super();
-        setNeedsProgressMonitor(true);
-        this.setWindowTitle(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
-                .getResourceString("general.name"));
-    }
-
-    /**
-     * Adding the page to the wizard.
-     */
-
-    public void addPages() {
-        page1 = new WSDLFileSelectionPage(selection);
-        addPage(page1);
-        page2 = new OptionsPage();
-        addPage(page2);
-        page3 = new OutputPage();
-        addPage(page3);
-
-    }
-
-    /**
-     * 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() {
-
-        try {
-            // getContainer().run(true, false, op);
-            doFinish();
-        } catch (Exception e) {
-            e.printStackTrace();
-            MessageDialog.openError(getShell(), CodegenWizardPlugin
-                    .getResourceString("general.Error"), e.getMessage());
-            return false;
-        }
-        MessageDialog.openInformation(this.getShell(), CodegenWizardPlugin
-                .getResourceString("general.name"), CodegenWizardPlugin
-                .getResourceString("wizard.success"));
-        return true;
-    }
-
-    /**
-     * The worker method.
-     */
-
-    private void doFinish() {
-  
-        try {
-            WSDLDescription wom = this.getWOM(page1.getFileName());
-            Map optionsMap = fillOptionMap();
-            CodeGenConfiguration codegenConfig = new CodeGenConfiguration(wom,
-                    optionsMap);
-            new CodeGenerationEngine(codegenConfig).generate();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
-    }
-
-    /**
-     *  
-     */
-    private Map fillOptionMap() {
-        Map optionMap = new HashMap();
-
-        optionMap.put(CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION,
-                new CommandLineOption(
-                        CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION,
-                        getStringArray(page1.getFileName())));
-
-        if (page2.isAsyncOnlyOn()) {
-            optionMap
-                    .put(
-                            CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION,
-                            new CommandLineOption(
-                                    CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION,
-                                    new String[0]));
-        }
-        if (page2.isSyncOnlyOn()) {
-            optionMap
-                    .put(
-                            CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION,
-                            new CommandLineOption(
-                                    CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION,
-                                    new String[0]));
-        }
-        optionMap.put(CommandLineOptionConstants.PACKAGE_OPTION,
-                new CommandLineOption(
-                        CommandLineOptionConstants.PACKAGE_OPTION,
-                        getStringArray(page2.getPackageName())));
-        optionMap.put(CommandLineOptionConstants.STUB_LANGUAGE_OPTION,
-                new CommandLineOption(
-                        CommandLineOptionConstants.STUB_LANGUAGE_OPTION,
-                        getStringArray(mapLanguagesWithCombo(page2
-                                .getSelectedLanguage()))));
-        optionMap.put(CommandLineOptionConstants.OUTPUT_LOCATION_OPTION,
-                new CommandLineOption(
-                        CommandLineOptionConstants.OUTPUT_LOCATION_OPTION,
-                        getStringArray(page3.getOutputLocation())));
-        if (page2.isServerside()) {
-            optionMap.put(CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION,
-                    new CommandLineOption(
-                            CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION,
-                            new String[0]));
-
-            if (page2.isServerXML()) {
-                optionMap
-                        .put(
-                                CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
-                                new CommandLineOption(
-                                        CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
-                                        new String[0]));
+public class CodeGenWizard extends Wizard implements INewWizard
+{
+   private WSDLFileSelectionPage page1;
+
+   private OptionsPage page2;
+
+   private OutputPage page3;
+
+   private ISelection selection;
+
+   private boolean canFinish = false;
+
+   /**
+    * Constructor for CodeGenWizard.
+    */
+   public CodeGenWizard()
+   {
+      super();
+      setNeedsProgressMonitor(true);
+      this.setWindowTitle(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+         .getResourceString("general.name"));
+   }
+
+   /**
+    * Adding the page to the wizard.
+    */
+
+   public void addPages()
+   {
+      page1 = new WSDLFileSelectionPage(selection);
+      addPage(page1);
+      page2 = new OptionsPage();
+      addPage(page2);
+      page3 = new OutputPage();
+      addPage(page3);
+
+   }
+
+   /**
+    * 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()
+   {
+      try
+      {
+         // getContainer().run(true, false, op);
+         doFinish();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         MessageDialog.openError(getShell(), CodegenWizardPlugin.getResourceString("general.Error"), e.getMessage());
+         return false;
+      }
+      MessageDialog.openInformation(this.getShell(), CodegenWizardPlugin.getResourceString("general.name"),
+         CodegenWizardPlugin.getResourceString("wizard.success"));
+      return true;
+   }
+
+   /**
+    * The worker method, generates the code itself.
+    */
+   private void doFinish()
+   {
+
+      WorkspaceModifyOperation op = new WorkspaceModifyOperation()
+      {
+         protected void execute(IProgressMonitor monitor)
+         {
+            if (monitor == null)
+               monitor = new NullProgressMonitor();
+
+            /*
+             * "3" is the total amount of steps, see below monitor.worked(amount)
+             */
+            monitor.beginTask(CodegenWizardPlugin.getResourceString("generator.generating"), 3);
+
+            try
+            {
+               /*
+                * TODO: Introduce a progress monitor interface for CodeGenerationEngine.
+                * Since this monitor here doesn't make much sense, we
+                * should either remove the progress monitor from the CodeGenWizard,
+                * or give a (custom) progress monitor to the generate() method, so
+                * we will be informed by Axis2 about the progress of code generation.  
+                */
+               monitor.subTask(CodegenWizardPlugin.getResourceString("generator.readingWOM"));
+               WSDLDescription wom = getWOM(page1.getFileName());
+               monitor.worked(1);
+               Map optionsMap = fillOptionMap();
+               CodeGenConfiguration codegenConfig = new CodeGenConfiguration(wom, optionsMap);
+               monitor.worked(1);
+               monitor.subTask(CodegenWizardPlugin.getResourceString("generator.generating"));
+               new CodeGenerationEngine(codegenConfig).generate();
+               monitor.worked(1);
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
             }
-        }
-        if (page2.isGenerateTestCase()){
-            optionMap
-            .put(
-                    CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION,
-                    new CommandLineOption(
-                            CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION,
-                            new String[0])); 
-        }
-        //System.out.println(page3.getOutputLocation());
-        return optionMap;
-    }
-
-    private String mapLanguagesWithCombo(String UILangValue) {
-        if (UIConstants.JAVA.equals(UILangValue)) {
-            return CommandLineOptionConstants.LanguageNames.JAVA;
-        } else if (UIConstants.C_SHARP.equals(UILangValue)) {
-            return CommandLineOptionConstants.LanguageNames.C_SHARP;
-        } else if (UIConstants.C_PLUS_PLUS.equals(UILangValue)) {
-            return CommandLineOptionConstants.LanguageNames.C_PLUS_PLUS;
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * 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;
-    }
-
-    private WSDLDescription getWOM(String wsdlLocation) throws WSDLException,
-            IOException {
-        InputStream in = new FileInputStream(new File(wsdlLocation));
-        return WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
-    }
-
-    private String[] getStringArray(String value) {
-        String[] values = new String[1];
-        values[0] = value;
-        return values;
-    }
+
+            monitor.done();
+         }
+      };
+
+
+      /*
+       * Start the generation as new Workbench Operation, so the user
+       * can see the progress and, if needed, can stop the operation.
+       */
+      try
+      {
+         getContainer().run(false, true, op);
+      }
+      catch (InvocationTargetException e1)
+      {
+         e1.printStackTrace();
+      }
+      catch (InterruptedException e1)
+      {
+         /*
+          * Thrown when the user aborts the progress
+          */
+         e1.printStackTrace();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /**
+    * Creates a list of parameters for the code generator based on the decisions made by the user on the OptionsPage
+    * (page2). For each setting, there is a Command-Line option for the Axis2 code generator.
+    * 
+    * @return a Map with keys from CommandLineOptionConstants with the values entered by the user on the Options Page.
+    */
+   private Map fillOptionMap()
+   {
+      Map optionMap = new HashMap();
+
+      optionMap.put(CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, new CommandLineOption(
+         CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, getStringArray(page1.getFileName())));
+
+      if (page2.isAsyncOnlyOn())
+      {
+         optionMap.put(CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION, new CommandLineOption(
+            CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION, new String[0]));
+      }
+      if (page2.isSyncOnlyOn())
+      {
+         optionMap.put(CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION, new CommandLineOption(
+            CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION, new String[0]));
+      }
+      optionMap.put(CommandLineOptionConstants.PACKAGE_OPTION, new CommandLineOption(
+         CommandLineOptionConstants.PACKAGE_OPTION, getStringArray(page2.getPackageName())));
+      optionMap.put(CommandLineOptionConstants.STUB_LANGUAGE_OPTION, new CommandLineOption(
+         CommandLineOptionConstants.STUB_LANGUAGE_OPTION, getStringArray(mapLanguagesWithCombo(page2
+            .getSelectedLanguage()))));
+      optionMap.put(CommandLineOptionConstants.OUTPUT_LOCATION_OPTION, new CommandLineOption(
+         CommandLineOptionConstants.OUTPUT_LOCATION_OPTION, getStringArray(page3.getOutputLocation())));
+      if (page2.isServerside())
+      {
+         optionMap.put(CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION, new CommandLineOption(
+            CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION, new String[0]));
+
+         if (page2.isServerXML())
+         {
+            optionMap.put(CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPTION, new CommandLineOption(
+               CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPTION, new String[0]));
+         }
+      }
+      if (page2.isGenerateTestCase())
+      {
+         optionMap.put(CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION, new CommandLineOption(
+            CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION, new String[0]));
+      }
+      // System.out.println(page3.getOutputLocation());
+      return optionMap;
+   }
+
+   /**
+    * Maps a string containing the name of a language to a constant defined in CommandLineOptionConstants.LanguageNames
+    * 
+    * @param UILangValue a string containg a language, e.g. "java", "cs", "cpp" or "vb"
+    * @return a normalized string constant
+    */
+   private String mapLanguagesWithCombo(String UILangValue)
+   {
+      if (UIConstants.JAVA.equals(UILangValue))
+      {
+         return CommandLineOptionConstants.LanguageNames.JAVA;
+      }
+      else if (UIConstants.C_SHARP.equals(UILangValue))
+      {
+         return CommandLineOptionConstants.LanguageNames.C_SHARP;
+      }
+      else if (UIConstants.C_PLUS_PLUS.equals(UILangValue))
+      {
+         return CommandLineOptionConstants.LanguageNames.C_PLUS_PLUS;
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   /**
+    * 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;
+   }
+
+   /**
+    * Reads the WSDL Object Model from the given location.
+    * 
+    * @param wsdlLocation the filesystem location (full path) of the WSDL file to read in.
+    * @return the WSDLDescription object containing the WSDL Object Model of the given WSDL file
+    * @throws WSDLException when WSDL File is invalid
+    * @throws IOException on errors reading the WSDL file
+    */
+   private WSDLDescription getWOM(String wsdlLocation) throws WSDLException, IOException
+   {
+      InputStream in = new FileInputStream(new File(wsdlLocation));
+      return WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
+   }
+
+   /**
+    * Converts a single String into a String Array
+    * 
+    * @param value a single string
+    * @return an array containing only one element
+    */
+   private String[] getStringArray(String value)
+   {
+      String[] values = new String[1];
+      values[0] = value;
+      return values;
+   }
 }

Modified: webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OptionsPage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OptionsPage.java?rev=190352&r1=190351&r2=190352&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OptionsPage.java (original)
+++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OptionsPage.java Sun Jun 12 22:09:30 2005
@@ -1,25 +1,26 @@
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
  */
+
 package org.apache.axis.tool.codegen.eclipse.ui;
 
 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
 import org.apache.axis.tool.codegen.eclipse.util.UIConstants;
 import org.apache.axis.wsdl.util.URLProcessor;
+import org.eclipse.jface.dialogs.IDialogSettings;
 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.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
@@ -30,191 +31,415 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
-public class OptionsPage extends WizardPage implements UIConstants {
-
-    private Combo languageSelectionComboBox;
-
-    private Button syncAndAsyncRadioButton;
-
-    private Button syncOnlyRadioButton;
-
-    private Button asyncOnlyRadioButton;
-
-    private Text packageText;
-
-    private Button serverSideCheckBoxButton;
-    
-    private Button testCaseCheckBoxButton;
-
-    private Button serverXMLCheckBoxButton;
-
-    /**
-     * @param pageName
-     */
-    public OptionsPage() {
-        super(CodegenWizardPlugin.getResourceString("page2.name"));
-        setTitle(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page2.title"));
-        setDescription(CodegenWizardPlugin.getResourceString("page2.desc"));
-        setImageDescriptor(CodegenWizardPlugin.getWizardImageDescriptor());
-
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.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;
-
-        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-        gd.horizontalSpan = 2;
-
-        Label label = new Label(container, SWT.NULL);
-        label.setText(CodegenWizardPlugin
-                .getResourceString("page2.language.caption"));
-
-        languageSelectionComboBox = new Combo(container, SWT.DROP_DOWN
-                | SWT.BORDER | SWT.READ_ONLY);
-        //fill the combo
-        this.fillLanguageCombo();
-        languageSelectionComboBox.setLayoutData(gd);
-
-        syncAndAsyncRadioButton = new Button(container, SWT.RADIO);
-        syncAndAsyncRadioButton.setText(CodegenWizardPlugin
-                .getResourceString("page2.syncAsync.caption"));
-        syncAndAsyncRadioButton.setSelection(true);
-
-        syncOnlyRadioButton = new Button(container, SWT.RADIO);
-        syncOnlyRadioButton.setText(CodegenWizardPlugin
-                .getResourceString("page2.sync.caption"));
-
-        asyncOnlyRadioButton = new Button(container, SWT.RADIO);
-        asyncOnlyRadioButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
-                .getResourceString("page2.async.caption"));
-
-        label = new Label(container, SWT.NULL);
-        label.setText(CodegenWizardPlugin
-                .getResourceString("page2.package.caption"));
-
-        packageText = new Text(container, SWT.BORDER);
-        gd = new GridData(GridData.FILL_HORIZONTAL);
-        gd.horizontalSpan = 2;
-
-        packageText.setLayoutData(gd);
-        packageText.setText(URLProcessor.getNameSpaceFromURL(""));//get this text from the URLProcessor
-        
-        
-        gd = new GridData(GridData.FILL_HORIZONTAL);
-        gd.horizontalSpan = 3;
-        testCaseCheckBoxButton = new Button(container, SWT.CHECK);
-        testCaseCheckBoxButton.setLayoutData(gd);
-        testCaseCheckBoxButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
-                .getResourceString("page2.testcase.caption"));
-        
-        
-        
-        
-        serverSideCheckBoxButton = new Button(container, SWT.CHECK);
-        serverSideCheckBoxButton.setText(CodegenWizardPlugin
-                .getResourceString("page2.serverside.caption"));
-        serverSideCheckBoxButton.addSelectionListener(new SelectionListener() {
-            public void widgetSelected(SelectionEvent e) {
-                handleServersideSelection();
-            }
-
-            public void widgetDefaultSelected(SelectionEvent e) {
-            }
-        });
-
-        serverXMLCheckBoxButton = new Button(container, SWT.CHECK);
-        serverXMLCheckBoxButton.setText(CodegenWizardPlugin
-                .getResourceString("page2.serviceXML.caption"));
-        serverXMLCheckBoxButton.setEnabled(false);
-
-        setControl(container);
-        setPageComplete(true);
-
-    }
-
-    /**
-     * Fill the combo with proper language names
-     *  
-     */
-    private void fillLanguageCombo() {
-
-        languageSelectionComboBox.add(JAVA);
-        languageSelectionComboBox.add(C_SHARP);
-        languageSelectionComboBox.add(C_PLUS_PLUS);
-
-        languageSelectionComboBox.setText(languageSelectionComboBox.getItem(0));
-    }
-
-    private void handleServersideSelection() {
-        if (this.serverSideCheckBoxButton.getSelection()) {
-            this.serverXMLCheckBoxButton.setEnabled(true);
-        } else {
-            this.serverXMLCheckBoxButton.setEnabled(false);
-        }
-    }
-
-    /**
-     * Get the selected language
-     * 
-     * @return
-     */
-    public String getSelectedLanguage() {
-        return languageSelectionComboBox.getItem(languageSelectionComboBox
-                .getSelectionIndex());
-    }
-
-    /**
-     * the async only status
-     * 
-     * @return
-     */
-    public boolean isAsyncOnlyOn() {
-        return asyncOnlyRadioButton.getSelection();
-    }
-
-    /**
-     * the sync only status
-     * 
-     * @return
-     */
-    public boolean isSyncOnlyOn() {
-        return syncOnlyRadioButton.getSelection();
-    }
-
-    /**
-     * return the package name
-     * 
-     * @return
-     */
-    public String getPackageName() {
-        return this.packageText.getText();
-    }
-
-    /**
-     * The serverside status
-     * @return
-     */
-    public boolean isServerside() {
-        return this.serverSideCheckBoxButton.getSelection();
-    }
-
-    public boolean isServerXML() {
-        if (this.serverXMLCheckBoxButton.isEnabled())
-            return this.serverXMLCheckBoxButton.getSelection();
-        else
-            return false;
-    }
-    public boolean isGenerateTestCase(){
-        return this.testCaseCheckBoxButton.getSelection();
-    }
+/**
+ * Options Page lets the user change general settings on the code generation. It is used in the CodegenWizardPlugin,
+ * CodeGenWizard.
+ * 
+ */
+public class OptionsPage extends WizardPage implements UIConstants
+{
+   /**
+    * Position in the combox for choosing the target programming language. Default is 0
+    */
+   private static final String PREF_LANGUAGE_INDEX = "PREF_LANGUAGE_INDEX";
+
+   /**
+    * Three radio buttons: Generate Code for Sync calls, Async and Both. Both is default.
+    */
+   private static final String PREF_RADIO_SYNC_AND_ASYNC = "PREF_RADIO_SYNC_AND_ASYNC";
+
+   /**
+    * Three radio buttons: Generate Code for Sync calls, Async and Both. Both is default.
+    */
+   private static final String PREF_RADIO_SYNC_ONLY = "PREF_RADIO_SYNC_ONLY";
+
+   /**
+    * Three radio buttons: Generate Code for Sync calls, Async and Both. Both is default.
+    */
+   private static final String PREF_RADIO_ASYNC_ONLY = "PREF_RADIO_ASYNC_ONLY";
+
+   /**
+    * Specifies the full qualified package name for the generated source code.
+    */
+   private static final String PREF_PACKAGE_NAME = "PREF_PACKAGE_NAME";
+
+   /**
+    * A boolean value whether JUnit test classes are generated or not.
+    */
+   private static final String PREF_CHECK_GENERATE_TESTCASE = "PREF_CHECK_GENERATE_TESTCASE";
+
+   /**
+    * A boolean value whether the server-side skeletons are generated or not
+    */
+   private static final String PREF_CHECK_GENERATE_SERVERSIDE = "PREF_CHECK_GENERATE_SERVERSIDE";
+
+   /**
+    * A boolean value whether the server-side configuration file for Axis2 (server.xml) will be generated or not.
+    */
+   private static final String PREF_CHECK_GENERATE_SERVERCONFIG = "PREF_CHECK_GENERATE_SERVERCONFIG";
+
+   /**
+    * Selection list for target languages
+    */
+   private Combo languageSelectionComboBox;
+
+   /**
+    * A radio button to enable/disable code generation for synchronous and asynchronous calls.
+    */
+   private Button syncAndAsyncRadioButton;
+
+   /**
+    * A radio button to choose "synchronous only" code generation
+    */
+   private Button syncOnlyRadioButton;
+
+   /**
+    * A radio button to choose "asynchronous only" code generation
+    */
+   private Button asyncOnlyRadioButton;
+
+   /**
+    * Label holding the full qualified package name for generated code
+    */
+   private Text packageText;
+
+   /**
+    * Checkbox to enable server-side skeleton code generation. If enabled, generates an empty implementation of the
+    * service
+    */
+   private Button serverSideCheckBoxButton;
+
+   /**
+    * Checkbox to enable the generation of test case classes for the generated implementation of the webservice.
+    */
+   private Button testCaseCheckBoxButton;
+
+   /**
+    * Checkbox to enable the generation of a default server.xml configuration file
+    */
+   private Button serverXMLCheckBoxButton;
+
+   /**
+    * Saves the settings in the plugin's default store, so the user doesn't have to type them in all over again next
+    * time he uses the wizard
+    */
+   private IDialogSettings settings;
+
+   /**
+    * Creates the page and initialize some settings
+    */
+   public OptionsPage()
+   {
+      super(CodegenWizardPlugin.getResourceString("page2.name"));
+      setTitle(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page2.title"));
+      setDescription(CodegenWizardPlugin.getResourceString("page2.desc"));
+      setImageDescriptor(CodegenWizardPlugin.getWizardImageDescriptor());
+
+      /*
+       * Get the settings for this page. If there is no section in the Plugin's settings for this OptionsPage, create a
+       * new section
+       */
+      IDialogSettings rootSettings = CodegenWizardPlugin.getDefault().getDialogSettings();
+      IDialogSettings section = rootSettings.getSection(this.getClass().getName());
+      if (section == null)
+      {
+         settings = rootSettings.addNewSection(this.getClass().getName());
+         initializeDefaultSettings();
+      }
+      else
+      {
+         settings = section;
+      }
+   }
+
+   /**
+    * Sets the default values for the Options page
+    * 
+    * @param settings2 the settings store to save the values to
+    */
+   private void initializeDefaultSettings()
+   {
+      settings.put(OptionsPage.PREF_CHECK_GENERATE_SERVERCONFIG, false);
+      settings.put(OptionsPage.PREF_CHECK_GENERATE_SERVERSIDE, false);
+      settings.put(OptionsPage.PREF_CHECK_GENERATE_TESTCASE, false);
+      settings.put(OptionsPage.PREF_LANGUAGE_INDEX, 0);
+      settings.put(OptionsPage.PREF_PACKAGE_NAME, "org.example.webservice");
+      settings.put(OptionsPage.PREF_RADIO_ASYNC_ONLY, false);
+      settings.put(OptionsPage.PREF_RADIO_SYNC_AND_ASYNC, true);
+      settings.put(OptionsPage.PREF_RADIO_SYNC_ONLY, false);
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.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;
+
+      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+      gd.horizontalSpan = 2;
+
+      Label label = new Label(container, SWT.NULL);
+      label.setText(CodegenWizardPlugin.getResourceString("page2.language.caption"));
+
+      languageSelectionComboBox = new Combo(container, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
+      // fill the combo
+      this.fillLanguageCombo();
+      languageSelectionComboBox.setLayoutData(gd);
+      languageSelectionComboBox.select(settings.getInt(PREF_LANGUAGE_INDEX));
+      languageSelectionComboBox.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            settings.put(PREF_LANGUAGE_INDEX, languageSelectionComboBox.getSelectionIndex());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      syncAndAsyncRadioButton = new Button(container, SWT.RADIO);
+      syncAndAsyncRadioButton.setText(CodegenWizardPlugin.getResourceString("page2.syncAsync.caption"));
+      syncAndAsyncRadioButton.setSelection(settings.getBoolean(PREF_RADIO_SYNC_AND_ASYNC));
+      syncAndAsyncRadioButton.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            settings.put(PREF_RADIO_SYNC_AND_ASYNC, syncAndAsyncRadioButton.getSelection());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      syncOnlyRadioButton = new Button(container, SWT.RADIO);
+      syncOnlyRadioButton.setText(CodegenWizardPlugin.getResourceString("page2.sync.caption"));
+      syncOnlyRadioButton.setSelection(settings.getBoolean(PREF_RADIO_SYNC_ONLY));
+      syncOnlyRadioButton.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            settings.put(PREF_RADIO_SYNC_ONLY, syncOnlyRadioButton.getSelection());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      asyncOnlyRadioButton = new Button(container, SWT.RADIO);
+      asyncOnlyRadioButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+         .getResourceString("page2.async.caption"));
+      asyncOnlyRadioButton.setSelection(settings.getBoolean(PREF_RADIO_ASYNC_ONLY));
+      asyncOnlyRadioButton.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            settings.put(PREF_RADIO_ASYNC_ONLY, asyncOnlyRadioButton.getSelection());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      label = new Label(container, SWT.NULL);
+      label.setText(CodegenWizardPlugin.getResourceString("page2.package.caption"));
+
+      packageText = new Text(container, SWT.BORDER);
+      gd = new GridData(GridData.FILL_HORIZONTAL);
+      gd.horizontalSpan = 2;
+
+      packageText.setLayoutData(gd);
+      String packageName;
+      String storedPackageName = settings.get(PREF_PACKAGE_NAME);
+      if (storedPackageName.equals(""))
+      {
+         packageName = URLProcessor.getNameSpaceFromURL("");
+      }
+      else
+      {
+         packageName = storedPackageName;
+      }
+      packageText.setText(packageName); // get this text from the URLProcessor
+      packageText.addModifyListener(new ModifyListener()
+      {
+         public void modifyText(ModifyEvent e)
+         {
+            settings.put(PREF_PACKAGE_NAME, packageText.getText());
+         }
+      });
+
+
+      gd = new GridData(GridData.FILL_HORIZONTAL);
+      gd.horizontalSpan = 3;
+      testCaseCheckBoxButton = new Button(container, SWT.CHECK);
+      testCaseCheckBoxButton.setLayoutData(gd);
+      testCaseCheckBoxButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+         .getResourceString("page2.testcase.caption"));
+      testCaseCheckBoxButton.setSelection(settings.getBoolean(PREF_CHECK_GENERATE_TESTCASE));
+      testCaseCheckBoxButton.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            settings.put(PREF_CHECK_GENERATE_TESTCASE, testCaseCheckBoxButton.getEnabled());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      serverSideCheckBoxButton = new Button(container, SWT.CHECK);
+      serverSideCheckBoxButton.setText(CodegenWizardPlugin.getResourceString("page2.serverside.caption"));
+      serverSideCheckBoxButton.setSelection(settings.getBoolean(PREF_CHECK_GENERATE_SERVERSIDE));
+      serverSideCheckBoxButton.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            handleServersideSelection();
+            settings.put(PREF_CHECK_GENERATE_SERVERSIDE, serverSideCheckBoxButton.getEnabled());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      serverXMLCheckBoxButton = new Button(container, SWT.CHECK);
+      serverXMLCheckBoxButton.setSelection(settings.getBoolean(PREF_CHECK_GENERATE_SERVERCONFIG));
+      serverXMLCheckBoxButton.setText(CodegenWizardPlugin.getResourceString("page2.serviceXML.caption"));
+      serverXMLCheckBoxButton.addSelectionListener(new SelectionListener()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            settings.put(PREF_CHECK_GENERATE_SERVERCONFIG, serverXMLCheckBoxButton.getEnabled());
+         }
+
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+         }
+      });
+
+      /*
+       * Check the state of server-side selection, so we can enable/disable
+       * the serverXML checkbox button.
+       */
+      handleServersideSelection();
+
+      
+      setControl(container);
+      setPageComplete(true);
+
+   }
+
+   /**
+    * Fill the combo with proper language names
+    * 
+    */
+   private void fillLanguageCombo()
+   {
+
+      languageSelectionComboBox.add(JAVA);
+      languageSelectionComboBox.add(C_SHARP);
+      languageSelectionComboBox.add(C_PLUS_PLUS);
+
+      languageSelectionComboBox.select(0);
+   }
+
+   /**
+    * Validates the status of the server-side checkbox, and enables/disables
+    * the generation checkbox for XML configuration file
+    */
+   private void handleServersideSelection()
+   {
+      if (this.serverSideCheckBoxButton.getSelection())
+      {
+         this.serverXMLCheckBoxButton.setEnabled(true);
+      }
+      else
+      {
+         this.serverXMLCheckBoxButton.setEnabled(false);
+      }
+   }
+
+   /**
+    * Get the selected language
+    * 
+    * @return a string containing the name of the target language
+    */
+   public String getSelectedLanguage()
+   {
+      return languageSelectionComboBox.getItem(languageSelectionComboBox.getSelectionIndex());
+   }
+
+   /**
+    * the async only status
+    * 
+    * @return true if "Generate asynchronous code only" is checked
+    */
+   public boolean isAsyncOnlyOn()
+   {
+      return asyncOnlyRadioButton.getSelection();
+   }
+
+   /**
+    * the sync only status
+    * 
+    * @return true if "Generate synchronous code only" is checked
+    */
+   public boolean isSyncOnlyOn()
+   {
+      return syncOnlyRadioButton.getSelection();
+   }
+
+   /**
+    * return the package name
+    * 
+    * @return a string containing the package name to use for code generation
+    */
+   public String getPackageName()
+   {
+      return this.packageText.getText();
+   }
+
+   /**
+    * The serverside status
+    * 
+    * @return true if "Generate Server-Side" is checked
+    */
+   public boolean isServerside()
+   {
+      return this.serverSideCheckBoxButton.getSelection();
+   }
+
+   /**
+    * 
+    * @return true if "Generate XML configuration file" is checked
+    */
+   public boolean isServerXML()
+   {
+      if (this.serverXMLCheckBoxButton.isEnabled())
+         return this.serverXMLCheckBoxButton.getSelection();
+      else
+         return false;
+   }
+
+   /**
+    * 
+    * @return true if "Generate test case" is checked
+    */
+   public boolean isGenerateTestCase()
+   {
+      return this.testCaseCheckBoxButton.getSelection();
+   }
 }

Modified: webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OutputPage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OutputPage.java?rev=190352&r1=190351&r2=190352&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OutputPage.java (original)
+++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/OutputPage.java Sun Jun 12 22:09:30 2005
@@ -1,23 +1,22 @@
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
  */
+
 package org.apache.axis.tool.codegen.eclipse.ui;
 
 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -33,122 +32,184 @@
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.dialogs.ContainerSelectionDialog;
 
-public class OutputPage extends WizardPage {
-    private Text outputLocation;
-    private Button browseButton;
-    private Button locationSelectCheckBox;
-
-    /**
-     * @param pageName
-     */
-    public OutputPage() {
-        super(CodegenWizardPlugin.getResourceString("page3.name"));
-        setTitle(CodegenWizardPlugin.getResourceString("page3.title"));
-        setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.desc"));
-        setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getWizardImageDescriptor());
-        //set the page complete status to false at initilaization
-        setPageComplete(false);
-
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.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;
-
-        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-        Label label = new Label(container, SWT.NULL);
-        label.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
-                .getResourceString("page3.output.caption"));
-
-        outputLocation = new Text(container, SWT.BORDER);
-        outputLocation.setLayoutData(gd);
-        outputLocation.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                handleModifyEvent();
-            }
-        });
-
-        browseButton = new Button(container, SWT.PUSH);
-        browseButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
-                .getResourceString("page3.outselection.browse"));
-        browseButton.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent e) {
-                handleBrowse();
-            }
-        });
-
-//        locationSelectCheckBox = new Button(container, SWT.CHECK);
-//        locationSelectCheckBox.setText("Workspace projects only");
-
-        setControl(container);
-        
-
-    }
-    
-    /**
-     * get the output location
-     * @return
-     */
-    public String getOutputLocation() {
-        return outputLocation.getText();
-    }
-
-    /**
-     * Worker method for handling modifications to the 
-     * textbox
-     *
-     */
-    private void handleModifyEvent() {
-        String text = this.outputLocation.getText();
-        if ((text == null) || (text.trim().equals(""))) {
-            updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
-                    .getResourceString("page3.error.nolocation"));
-            return;
-        }
-        updateStatus(null);
-    }
-
-    /**
-     * Updates the wizard page error messages
-     * @param message
-     */
-    private void updateStatus(String message) {
-        setErrorMessage(message);
-        setPageComplete(message == null);
-    }
-
-    /**
-     * Handle the browse button events
-     *
-     */
-    private void handleBrowse() {
-        boolean location = false;//locationSelectCheckBox.getSelection();
-        if (!location) {
-            DirectoryDialog dialog = new DirectoryDialog(this.getShell());
-            String returnString = dialog.open();
-            if (returnString != null) {
-                outputLocation.setText(returnString);
+public class OutputPage extends WizardPage
+{
+   /**
+    * The key to store the output location in the settings
+    * 
+    */
+   private static final String PREF_OUTPUT_LOCATION = "PREF_OUTPUT_LOCATION";
+   private Text outputLocation;
+   private Button browseButton;
+   private Button locationSelectCheckBox;
+   
+   /**
+    * The dialog settings of this page, which are stored in the plugin's meta
+    * folder.
+    */
+   private IDialogSettings settings;
+
+   /**
+    * 
+    */
+   public OutputPage()
+   {
+      super(CodegenWizardPlugin.getResourceString("page3.name"));
+      setTitle(CodegenWizardPlugin.getResourceString("page3.title"));
+      setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.desc"));
+      setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getWizardImageDescriptor());
+      // set the page complete status to false at initilaization
+      setPageComplete(false);
+
+      /*
+       * Get the settings for this page. If there is no section in the Plugin's settings for this OptionsPage, create a
+       * new section
+       */
+      IDialogSettings rootSettings = CodegenWizardPlugin.getDefault().getDialogSettings();
+      IDialogSettings section = rootSettings.getSection(this.getClass().getName());
+      if (section == null)
+      {
+         settings = rootSettings.addNewSection(this.getClass().getName());
+         initializeDefaultSettings();
+      }
+      else
+      {
+         settings = section;
+      }
+
+
+   }
+
+
+   /**
+    * Creates some initial values for the settings. On the output page, this
+    * is not very much.
+    */
+   private void initializeDefaultSettings()
+   {
+      settings.put(PREF_OUTPUT_LOCATION,"");
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.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;
+      
+      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+      Label label = new Label(container, SWT.NULL);
+      label.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+         .getResourceString("page3.output.caption"));
+
+      outputLocation = new Text(container, SWT.BORDER);
+      outputLocation.setLayoutData(gd);
+      outputLocation.setText(settings.get(PREF_OUTPUT_LOCATION));
+      outputLocation.addModifyListener(new ModifyListener()
+      {
+         public void modifyText(ModifyEvent e)
+         {
+            settings.put(PREF_OUTPUT_LOCATION,outputLocation.getText());
+            handleModifyEvent();
+         }
+      });
+
+      browseButton = new Button(container, SWT.PUSH);
+      browseButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+         .getResourceString("page3.outselection.browse"));
+      browseButton.addSelectionListener(new SelectionAdapter()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            handleBrowse();
+         }
+      });
+
+      // locationSelectCheckBox = new Button(container, SWT.CHECK);
+      // locationSelectCheckBox.setText("Workspace projects only");
+
+      setControl(container);
+      
+      /*
+       * Update the buttons, because we could have get a valid path from
+       * the settings store.
+       */
+      handleModifyEvent();
+   }
+
+   /**
+    * get the output location
+    * 
+    * @return a string containing the full pathname of the output location
+    */
+   public String getOutputLocation()
+   {
+      return outputLocation.getText();
+   }
+
+   /**
+    * Worker method for handling modifications to the textbox
+    * 
+    */
+   private void handleModifyEvent()
+   {
+      String text = this.outputLocation.getText();
+      if ((text == null) || (text.trim().equals("")))
+      {
+         updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+            .getResourceString("page3.error.nolocation"));
+         return;
+      }
+      updateStatus(null);
+   }
+
+   /**
+    * Updates the wizard page error messages
+    * 
+    * @param message an error message to display in the dialog
+    */
+   private void updateStatus(String message)
+   {
+      setErrorMessage(message);
+      setPageComplete(message == null);
+   }
+
+   /**
+    * Handle the browse button events: opens a dialog where the user
+    * can choose an external directory location
+    * 
+    */
+   private void handleBrowse()
+   {
+      boolean location = false;// locationSelectCheckBox.getSelection();
+      if (!location)
+      {
+         DirectoryDialog dialog = new DirectoryDialog(this.getShell());
+         String returnString = dialog.open();
+         if (returnString != null)
+         {
+            outputLocation.setText(returnString);
+         }
+      }
+      else
+      {
+         ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace()
+            .getRoot(), false, org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+            .getResourceString("page3.containerbox.title"));
+         if (dialog.open() == ContainerSelectionDialog.OK)
+         {
+            Object[] result = dialog.getResult();
+            if (result.length == 1)
+            {
+               outputLocation.setText(((Path) result[0]).toOSString());
             }
-        } else {
-            ContainerSelectionDialog dialog =
-    			new ContainerSelectionDialog(
-    				getShell(),
-    				ResourcesPlugin.getWorkspace().getRoot(),
-    				false,
-    				org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.containerbox.title"));
-    		if (dialog.open() == ContainerSelectionDialog.OK) {
-    			Object[] result = dialog.getResult();
-    			if (result.length == 1) {
-    				outputLocation.setText(((Path)result[0]).toOSString());
-    			}
-    		}
-        }
-    }
+         }
+      }
+   }
 }

Modified: webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java?rev=190352&r1=190351&r2=190352&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java (original)
+++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java Sun Jun 12 22:09:30 2005
@@ -1,7 +1,9 @@
+
 package org.apache.axis.tool.codegen.eclipse.ui;
 
 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
 import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
@@ -18,112 +20,169 @@
 import org.eclipse.swt.widgets.Text;
 
 /**
- * The first page of the code generator wizrad. 
- * Asks for the WSDL file Name
+ * The first page of the code generator wizrad. Asks for the WSDL file Name
  */
 
-public class WSDLFileSelectionPage extends WizardPage {
-	
-	private Text fileText;
-	private ISelection selection;
-
-	/**
-	 * 
-	 * @param pageName
-	 */
-	public WSDLFileSelectionPage(ISelection selection) {
-		super(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page1.name"));
-		setTitle(CodegenWizardPlugin.getResourceString("page1.title"));
-		setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page1.desc"));
-		this.selection = selection;
-		setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getWizardImageDescriptor());
-		//set the page complete status to false at initiation 
-		setPageComplete(false);
-	}
-
-	/**
-	 * @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;
-
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		Label label = new Label(container, SWT.NULL);
-		label.setText(CodegenWizardPlugin.getResourceString("page1.fileselection.label"));
-
-		fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
-		fileText.setLayoutData(gd);
-		fileText.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				dialogChanged();
-			}
-		});
-		
-		Button button = new Button(container, SWT.PUSH);
-		button.setText(CodegenWizardPlugin.getResourceString("page1.fileselection.browse"));
-		button.addSelectionListener(new SelectionAdapter() {
-			public void widgetSelected(SelectionEvent e) {
-				handleBrowse();
-			}
-		});
-		setControl(container);
-	}
-	
-	/**
-	 * Handle the dialog change event. Basically evaluates the file name
-	 * and sets the error message accordingly 
-	 */
-	private void dialogChanged() {
-	    
-	    String fileName = getFileName();
-	    
-	    if (fileName.length() == 0) {
-			updateStatus(CodegenWizardPlugin.getResourceString("page1.error.filemissingerror"));
-			return;
-		}
-	    
-		if (!fileName.matches(".*\\.wsdl")){
-				updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page1.error.wrongextension"));
-				return;
-		 }
-		 
-	    updateStatus(null);
-	    
-	}
-	
-	/**
-	 * Pops up the file browse dialog box
-	 *
-	 */
-	private void handleBrowse(){
-	    FileDialog fileDialog = new FileDialog(this.getShell());
-	    fileDialog.setFilterExtensions(new String[]{"*.wsdl"});
-	    String fileName = fileDialog.open();
-	    if (fileName!=null){
-	        fileText.setText(fileName);
-	    }
-	   
-	}
-	
-	/**
-	 * Updates the wizard page messages
-	 * @param message
-	 */
-	private void updateStatus(String message) {
-		setErrorMessage(message);
-		setPageComplete(message == null);
-	}
-
-	/**
-	 * Get the file name
-	 * @return
-	 */
-	public String getFileName() {
-		return fileText.getText();
-	}
+public class WSDLFileSelectionPage extends WizardPage
+{
+
+   /**
+    * The key for storing the WSDL location in the dialog settings of the
+    * WSDLFileSelectionPage
+    */
+   private static final String PREF_WSDL_LOCATION = "PREF_WSDL_LOCATION";
+   private Text fileText;
+   private ISelection selection;
+   
+   /**
+    * The store where the settings are saved to, in the plugin meta folder.
+    */
+   private IDialogSettings settings;
+
+   /**
+    * 
+    * @param pageName
+    */
+   public WSDLFileSelectionPage(ISelection selection)
+   {
+      super(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page1.name"));
+      setTitle(CodegenWizardPlugin.getResourceString("page1.title"));
+      setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page1.desc"));
+      this.selection = selection;
+      setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getWizardImageDescriptor());
+      // set the page complete status to false at initiation
+      setPageComplete(false);
+
+      /*
+       * Get the settings for this page. If there is no section in the Plugin's settings for this OptionsPage, create a
+       * new section
+       */
+      IDialogSettings rootSettings = CodegenWizardPlugin.getDefault().getDialogSettings();
+      IDialogSettings section = rootSettings.getSection(this.getClass().getName());
+      if (section == null)
+      {
+         settings = rootSettings.addNewSection(this.getClass().getName());
+         initializeDefaultSettings();
+      }
+      else
+      {
+         settings = section;
+      }
+
+   }
+
+   /**
+    * Creates a default value for the settings on this page. For WSDLFileSelection, this is not very much.
+    */
+   private void initializeDefaultSettings()
+   {
+      settings.put(PREF_WSDL_LOCATION,"");
+   }
+
+   /**
+    * @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;
+
+      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+      Label label = new Label(container, SWT.NULL);
+      label.setText(CodegenWizardPlugin.getResourceString("page1.fileselection.label"));
+
+      fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+      fileText.setLayoutData(gd);
+      fileText.setText(settings.get(PREF_WSDL_LOCATION));
+      fileText.addModifyListener(new ModifyListener()
+      {
+         public void modifyText(ModifyEvent e)
+         {
+            settings.put(PREF_WSDL_LOCATION,fileText.getText());
+            dialogChanged();
+         }
+      });
+
+      Button button = new Button(container, SWT.PUSH);
+      button.setText(CodegenWizardPlugin.getResourceString("page1.fileselection.browse"));
+      button.addSelectionListener(new SelectionAdapter()
+      {
+         public void widgetSelected(SelectionEvent e)
+         {
+            handleBrowse();
+         }
+      });
+      setControl(container);
+      
+      /*
+       * Validate this dialog, because we could have got valid values from the
+       * settings already.
+       */
+      dialogChanged();
+   }
+
+   /**
+    * Handle the dialog change event. Basically evaluates the file name and sets the error message accordingly
+    */
+   private void dialogChanged()
+   {
+      String fileName = getFileName();
+
+      if (fileName.length() == 0)
+      {
+         updateStatus(CodegenWizardPlugin.getResourceString("page1.error.filemissingerror"));
+         return;
+      }
+
+      if (!fileName.matches(".*\\.wsdl"))
+      {
+         updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
+            .getResourceString("page1.error.wrongextension"));
+         return;
+      }
+
+      updateStatus(null);
+
+   }
+
+   /**
+    * Pops up the file browse dialog box
+    * 
+    */
+   private void handleBrowse()
+   {
+      FileDialog fileDialog = new FileDialog(this.getShell());
+      fileDialog.setFilterExtensions(new String[] {"*.wsdl"});
+      String fileName = fileDialog.open();
+      if (fileName != null)
+      {
+         fileText.setText(fileName);
+      }
+
+   }
+
+   /**
+    * Updates the wizard page messages
+    * 
+    * @param message
+    */
+   private void updateStatus(String message)
+   {
+      setErrorMessage(message);
+      setPageComplete(message == null);
+   }
+
+   /**
+    * Get the file name
+    * 
+    * @return
+    */
+   public String getFileName()
+   {
+      return fileText.getText();
+   }
 }

Modified: webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/resource/Codegen.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/resource/Codegen.properties?rev=190352&r1=190351&r2=190352&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/resource/Codegen.properties (original)
+++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codegen/resource/Codegen.properties Sun Jun 12 22:09:30 2005
@@ -46,5 +46,7 @@
 #
 ##########################################################################
 #Wizard
+generator.generating=Generating code...
+generator.readingWOM=Reading WSDL file...
 #Success message
 wizard.success=Code generation successful!



Mime
View raw message