Return-Path: Delivered-To: apmail-ws-axis-cvs-archive@www.apache.org Received: (qmail 85332 invoked from network); 13 Jun 2005 05:09:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2005 05:09:50 -0000 Received: (qmail 50430 invoked by uid 500); 13 Jun 2005 05:09:47 -0000 Delivered-To: apmail-ws-axis-cvs-archive@ws.apache.org Received: (qmail 50348 invoked by uid 500); 13 Jun 2005 05:09:47 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 50335 invoked by uid 99); 13 Jun 2005 05:09:46 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 12 Jun 2005 22:09:41 -0700 Received: (qmail 85281 invoked by uid 65534); 13 Jun 2005 05:09:31 -0000 Message-ID: <20050613050931.85280.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 -0000 To: axis-cvs@ws.apache.org From: ajith@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ajith Date: Sun Jun 12 22:09:30 2005 New Revision: 190352 URL: http://svn.apache.org/viewcvs?rev=3D190352&view=3Drev Log: Checking in the following changes by courtesy of Mike Haller 1=2ECommented the code 2=2EAdded persistent support for the wizard 3=2EFixed some minor bugs Modified: webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/CodeGenWizard.java webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/OptionsPage.java webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/OutputPage.java webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/WSDLFileSelectionPage.java webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/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=3D190352&r= 1=3D190351&r2=3D190352&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/CodeGenWizard.java (original) +++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/CodeGenWizard.java Sun Jun 12 22:09:30 2005 @@ -1,9 +1,11 @@ + package org.apache.axis.tool.codegen.eclipse; =20 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 @@ -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; =20 /** * The main wizard for the codegen wizard */ =20 -public class CodeGenWizard extends Wizard implements INewWizard { - private WSDLFileSelectionPage page1; - - private OptionsPage page2; - - private OutputPage page3; - - private ISelection selection; - - private boolean canFinish =3D false; - - /** - * Constructor for CodeGenWizard. - */ - public CodeGenWizard() { - super(); - setNeedsProgressMonitor(true); - this.setWindowTitle(org.apache.axis.tool.codegen.eclipse.plugin.Co= degenWizardPlugin - .getResourceString("general.name")); - } - - /** - * Adding the page to the wizard. - */ - - public void addPages() { - page1 =3D new WSDLFileSelectionPage(selection); - addPage(page1); - page2 =3D new OptionsPage(); - addPage(page2); - page3 =3D 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 conte= xt. - */ - 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() { - =20 - try { - WSDLDescription wom =3D this.getWOM(page1.getFileName()); - Map optionsMap =3D fillOptionMap(); - CodeGenConfiguration codegenConfig =3D new CodeGenConfiguratio= n(wom, - optionsMap); - new CodeGenerationEngine(codegenConfig).generate(); - } catch (Exception e) { - throw new RuntimeException(e); - } - - } - - /** - * =20 - */ - private Map fillOptionMap() { - Map optionMap =3D new HashMap(); - - optionMap.put(CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, - new CommandLineOption( - CommandLineOptionConstants.WSDL_LOCATION_URI_OPTIO= N, - getStringArray(page1.getFileName()))); - - if (page2.isAsyncOnlyOn()) { - optionMap - .put( - CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_= OPTION, - new CommandLineOption( - CommandLineOptionConstants.CODEGEN_ASY= NC_ONLY_OPTION, - new String[0])); - } - if (page2.isSyncOnlyOn()) { - optionMap - .put( - CommandLineOptionConstants.CODEGEN_SYNC_ONLY_O= PTION, - new CommandLineOption( - CommandLineOptionConstants.CODEGEN_SYN= C_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_OPTI= ON, - new CommandLineOption( - CommandLineOptionConstants.SERVER_SIDE_CODE_OP= TION, - new String[0])); - - if (page2.isServerXML()) { - optionMap - .put( - CommandLineOptionConstants.GENERATE_SERVIC= E_DESCRIPTION_OPTION, - new CommandLineOption( - CommandLineOptionConstants.GENERAT= E_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 =3D false; + + /** + * Constructor for CodeGenWizard. + */ + public CodeGenWizard() + { + super(); + setNeedsProgressMonitor(true); + this.setWindowTitle(org.apache.axis.tool.codegen.eclipse.plugin.Code= genWizardPlugin + .getResourceString("general.name")); + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() + { + page1 =3D new WSDLFileSelectionPage(selection); + addPage(page1); + page2 =3D new OptionsPage(); + addPage(page2); + page3 =3D 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.getResour= ceString("general.Error"), e.getMessage()); + return false; + } + MessageDialog.openInformation(this.getShell(), CodegenWizardPlugin.g= etResourceString("general.name"), + CodegenWizardPlugin.getResourceString("wizard.success")); + return true; + } + + /** + * The worker method, generates the code itself. + */ + private void doFinish() + { + + WorkspaceModifyOperation op =3D new WorkspaceModifyOperation() + { + protected void execute(IProgressMonitor monitor) + { + if (monitor =3D=3D null) + monitor =3D new NullProgressMonitor(); + + /* + * "3" is the total amount of steps, see below monitor.worked(= amount) + */ + monitor.beginTask(CodegenWizardPlugin.getResourceString("gener= ator.generating"), 3); + + try + { + /* + * TODO: Introduce a progress monitor interface for CodeGen= erationEngine. + * Since this monitor here doesn't make much sense, we + * should either remove the progress monitor from the CodeG= enWizard, + * or give a (custom) progress monitor to the generate() me= thod, so + * we will be informed by Axis2 about the progress of code = generation. =20 + */ + monitor.subTask(CodegenWizardPlugin.getResourceString("gene= rator.readingWOM")); + WSDLDescription wom =3D getWOM(page1.getFileName()); + monitor.worked(1); + Map optionsMap =3D fillOptionMap(); + CodeGenConfiguration codegenConfig =3D new CodeGenConfigura= tion(wom, optionsMap); + monitor.worked(1); + monitor.subTask(CodegenWizardPlugin.getResourceString("gene= rator.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]));=20 - } - //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 init= ialize - * from it. - *=20 - * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) - */ - public void init(IWorkbench workbench, IStructuredSelection selection)= { - this.selection =3D selection; - } - - private WSDLDescription getWOM(String wsdlLocation) throws WSDLExcepti= on, - IOException { - InputStream in =3D new FileInputStream(new File(wsdlLocation)); - return WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).buil= d(in); - } - - private String[] getStringArray(String value) { - String[] values =3D new String[1]; - values[0] =3D 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 dec= isions made by the user on the OptionsPage + * (page2). For each setting, there is a Command-Line option for the Ax= is2 code generator. + *=20 + * @return a Map with keys from CommandLineOptionConstants with the val= ues entered by the user on the Options Page. + */ + private Map fillOptionMap() + { + Map optionMap =3D new HashMap(); + + optionMap.put(CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, n= ew CommandLineOption( + CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, getStringArr= ay(page1.getFileName()))); + + if (page2.isAsyncOnlyOn()) + { + optionMap.put(CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTIO= N, new CommandLineOption( + CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION, new Stri= ng[0])); + } + if (page2.isSyncOnlyOn()) + { + optionMap.put(CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION= , new CommandLineOption( + CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION, new Strin= g[0])); + } + optionMap.put(CommandLineOptionConstants.PACKAGE_OPTION, new Command= LineOption( + CommandLineOptionConstants.PACKAGE_OPTION, getStringArray(page2.g= etPackageName()))); + optionMap.put(CommandLineOptionConstants.STUB_LANGUAGE_OPTION, new C= ommandLineOption( + CommandLineOptionConstants.STUB_LANGUAGE_OPTION, getStringArray(m= apLanguagesWithCombo(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_DESC= RIPTION_OPTION, new CommandLineOption( + CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPT= ION, new String[0])); + } + } + if (page2.isGenerateTestCase()) + { + optionMap.put(CommandLineOptionConstants.GENERATE_TEST_CASE_OPTIO= N, new CommandLineOption( + CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION, new Stri= ng[0])); + } + // System.out.println(page3.getOutputLocation()); + return optionMap; + } + + /** + * Maps a string containing the name of a language to a constant define= d in CommandLineOptionConstants.LanguageNames + *=20 + * @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 initi= alize from it. + *=20 + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.selection =3D selection; + } + + /** + * Reads the WSDL Object Model from the given location. + *=20 + * @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 WSDLExceptio= n, IOException + { + InputStream in =3D new FileInputStream(new File(wsdlLocation)); + return WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(= in); + } + + /** + * Converts a single String into a String Array + *=20 + * @param value a single string + * @return an array containing only one element + */ + private String[] getStringArray(String value) + { + String[] values =3D new String[1]; + values[0] =3D 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=3D190352&= r1=3D190351&r2=3D190352&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/OptionsPage.java (original) +++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/OptionsPage.java Sun Jun 12 22:09:30 2005 @@ -1,25 +1,26 @@ /* * Copyright 2004,2005 The Apache Software Foundation. *=20 - * 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 c= opy 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 *=20 * http://www.apache.org/licenses/LICENSE-2.0 *=20 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHO= UT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See th= e - * License for the specific language governing permissions and limitations= under - * the License. + * Unless required by applicable law or agreed to in writing, software dis= tributed 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 Licen= se. */ + package org.apache.axis.tool.codegen.eclipse.ui; =20 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; =20 -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; - =20 - private Button testCaseCheckBoxButton; - - private Button serverXMLCheckBoxButton; - - /** - * @param pageName - */ - public OptionsPage() { - super(CodegenWizardPlugin.getResourceString("page2.name")); - setTitle(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizard= Plugin.getResourceString("page2.title")); - setDescription(CodegenWizardPlugin.getResourceString("page2.desc")= ); - setImageDescriptor(CodegenWizardPlugin.getWizardImageDescriptor())= ; - - } - - /* - * (non-Javadoc) - *=20 - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclips= e=2Eswt.widgets.Composite) - */ - public void createControl(Composite parent) { - - Composite container =3D new Composite(parent, SWT.NULL); - GridLayout layout =3D new GridLayout(); - container.setLayout(layout); - layout.numColumns =3D 3; - layout.verticalSpacing =3D 9; - - GridData gd =3D new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan =3D 2; - - Label label =3D new Label(container, SWT.NULL); - label.setText(CodegenWizardPlugin - .getResourceString("page2.language.caption")); - - languageSelectionComboBox =3D new Combo(container, SWT.DROP_DOWN - | SWT.BORDER | SWT.READ_ONLY); - //fill the combo - this.fillLanguageCombo(); - languageSelectionComboBox.setLayoutData(gd); - - syncAndAsyncRadioButton =3D new Button(container, SWT.RADIO); - syncAndAsyncRadioButton.setText(CodegenWizardPlugin - .getResourceString("page2.syncAsync.caption")); - syncAndAsyncRadioButton.setSelection(true); - - syncOnlyRadioButton =3D new Button(container, SWT.RADIO); - syncOnlyRadioButton.setText(CodegenWizardPlugin - .getResourceString("page2.sync.caption")); - - asyncOnlyRadioButton =3D new Button(container, SWT.RADIO); - asyncOnlyRadioButton.setText(org.apache.axis.tool.codegen.eclipse.= plugin.CodegenWizardPlugin - .getResourceString("page2.async.caption")); - - label =3D new Label(container, SWT.NULL); - label.setText(CodegenWizardPlugin - .getResourceString("page2.package.caption")); - - packageText =3D new Text(container, SWT.BORDER); - gd =3D new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan =3D 2; - - packageText.setLayoutData(gd); - packageText.setText(URLProcessor.getNameSpaceFromURL(""));//get th= is text from the URLProcessor - =20 - =20 - gd =3D new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan =3D 3; - testCaseCheckBoxButton =3D new Button(container, SWT.CHECK); - testCaseCheckBoxButton.setLayoutData(gd); - testCaseCheckBoxButton.setText(org.apache.axis.tool.codegen.eclips= e=2Eplugin.CodegenWizardPlugin - .getResourceString("page2.testcase.caption")); - =20 - =20 - =20 - =20 - serverSideCheckBoxButton =3D new Button(container, SWT.CHECK); - serverSideCheckBoxButton.setText(CodegenWizardPlugin - .getResourceString("page2.serverside.caption")); - serverSideCheckBoxButton.addSelectionListener(new SelectionListene= r() { - public void widgetSelected(SelectionEvent e) { - handleServersideSelection(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - serverXMLCheckBoxButton =3D 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 - * =20 - */ - private void fillLanguageCombo() { - - languageSelectionComboBox.add(JAVA); - languageSelectionComboBox.add(C_SHARP); - languageSelectionComboBox.add(C_PLUS_PLUS); - - languageSelectionComboBox.setText(languageSelectionComboBox.getIte= m(0)); - } - - private void handleServersideSelection() { - if (this.serverSideCheckBoxButton.getSelection()) { - this.serverXMLCheckBoxButton.setEnabled(true); - } else { - this.serverXMLCheckBoxButton.setEnabled(false); - } - } - - /** - * Get the selected language - *=20 - * @return - */ - public String getSelectedLanguage() { - return languageSelectionComboBox.getItem(languageSelectionComboBox - .getSelectionIndex()); - } - - /** - * the async only status - *=20 - * @return - */ - public boolean isAsyncOnlyOn() { - return asyncOnlyRadioButton.getSelection(); - } - - /** - * the sync only status - *=20 - * @return - */ - public boolean isSyncOnlyOn() { - return syncOnlyRadioButton.getSelection(); - } - - /** - * return the package name - *=20 - * @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 generati= on. It is used in the CodegenWizardPlugin, + * CodeGenWizard. + *=20 + */ +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 =3D "PREF_LANGUAGE_INDE= X"; + + /** + * Three radio buttons: Generate Code for Sync calls, Async and Both. B= oth is default. + */ + private static final String PREF_RADIO_SYNC_AND_ASYNC =3D "PREF_RADIO_S= YNC_AND_ASYNC"; + + /** + * Three radio buttons: Generate Code for Sync calls, Async and Both. B= oth is default. + */ + private static final String PREF_RADIO_SYNC_ONLY =3D "PREF_RADIO_SYNC_O= NLY"; + + /** + * Three radio buttons: Generate Code for Sync calls, Async and Both. B= oth is default. + */ + private static final String PREF_RADIO_ASYNC_ONLY =3D "PREF_RADIO_ASYNC= _ONLY"; + + /** + * Specifies the full qualified package name for the generated source c= ode. + */ + private static final String PREF_PACKAGE_NAME =3D "PREF_PACKAGE_NAME"; + + /** + * A boolean value whether JUnit test classes are generated or not. + */ + private static final String PREF_CHECK_GENERATE_TESTCASE =3D "PREF_CHEC= K_GENERATE_TESTCASE"; + + /** + * A boolean value whether the server-side skeletons are generated or n= ot + */ + private static final String PREF_CHECK_GENERATE_SERVERSIDE =3D "PREF_CH= ECK_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 =3D "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 gener= ated implementation of the webservice. + */ + private Button testCaseCheckBoxButton; + + /** + * Checkbox to enable the generation of a default server.xml configurat= ion 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.CodegenWizardPl= ugin.getResourceString("page2.title")); + setDescription(CodegenWizardPlugin.getResourceString("page2.desc")); + setImageDescriptor(CodegenWizardPlugin.getWizardImageDescriptor()); + + /* + * Get the settings for this page. If there is no section in the Plu= gin's settings for this OptionsPage, create a + * new section + */ + IDialogSettings rootSettings =3D CodegenWizardPlugin.getDefault().ge= tDialogSettings(); + IDialogSettings section =3D rootSettings.getSection(this.getClass().= getName()); + if (section =3D=3D null) + { + settings =3D rootSettings.addNewSection(this.getClass().getName()= ); + initializeDefaultSettings(); + } + else + { + settings =3D section; + } + } + + /** + * Sets the default values for the Options page + *=20 + * @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) + *=20 + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse= .swt.widgets.Composite) + */ + public void createControl(Composite parent) + { + + Composite container =3D new Composite(parent, SWT.NULL); + GridLayout layout =3D new GridLayout(); + container.setLayout(layout); + layout.numColumns =3D 3; + layout.verticalSpacing =3D 9; + + GridData gd =3D new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan =3D 2; + + Label label =3D new Label(container, SWT.NULL); + label.setText(CodegenWizardPlugin.getResourceString("page2.language.= caption")); + + languageSelectionComboBox =3D new Combo(container, SWT.DROP_DOWN | S= WT.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.ge= tSelectionIndex()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + syncAndAsyncRadioButton =3D new Button(container, SWT.RADIO); + syncAndAsyncRadioButton.setText(CodegenWizardPlugin.getResourceStrin= g("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, syncAndAsyncRadioButto= n=2EgetSelection()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + syncOnlyRadioButton =3D new Button(container, SWT.RADIO); + syncOnlyRadioButton.setText(CodegenWizardPlugin.getResourceString("p= age2.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.getSele= ction()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + asyncOnlyRadioButton =3D new Button(container, SWT.RADIO); + asyncOnlyRadioButton.setText(org.apache.axis.tool.codegen.eclipse.pl= ugin.CodegenWizardPlugin + .getResourceString("page2.async.caption")); + asyncOnlyRadioButton.setSelection(settings.getBoolean(PREF_RADIO_ASY= NC_ONLY)); + asyncOnlyRadioButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent e) + { + settings.put(PREF_RADIO_ASYNC_ONLY, asyncOnlyRadioButton.getSe= lection()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + label =3D new Label(container, SWT.NULL); + label.setText(CodegenWizardPlugin.getResourceString("page2.package.c= aption")); + + packageText =3D new Text(container, SWT.BORDER); + gd =3D new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan =3D 2; + + packageText.setLayoutData(gd); + String packageName; + String storedPackageName =3D settings.get(PREF_PACKAGE_NAME); + if (storedPackageName.equals("")) + { + packageName =3D URLProcessor.getNameSpaceFromURL(""); + } + else + { + packageName =3D storedPackageName; + } + packageText.setText(packageName); // get this text from the URLProce= ssor + packageText.addModifyListener(new ModifyListener() + { + public void modifyText(ModifyEvent e) + { + settings.put(PREF_PACKAGE_NAME, packageText.getText()); + } + }); + + + gd =3D new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan =3D 3; + testCaseCheckBoxButton =3D 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_G= ENERATE_TESTCASE)); + testCaseCheckBoxButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent e) + { + settings.put(PREF_CHECK_GENERATE_TESTCASE, testCaseCheckBoxBut= ton.getEnabled()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + serverSideCheckBoxButton =3D new Button(container, SWT.CHECK); + serverSideCheckBoxButton.setText(CodegenWizardPlugin.getResourceStri= ng("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, serverSideCheckBo= xButton.getEnabled()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + serverXMLCheckBoxButton =3D new Button(container, SWT.CHECK); + serverXMLCheckBoxButton.setSelection(settings.getBoolean(PREF_CHECK_= GENERATE_SERVERCONFIG)); + serverXMLCheckBoxButton.setText(CodegenWizardPlugin.getResourceStrin= g("page2.serviceXML.caption")); + serverXMLCheckBoxButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent e) + { + settings.put(PREF_CHECK_GENERATE_SERVERCONFIG, serverXMLCheckB= oxButton.getEnabled()); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + } + }); + + /* + * Check the state of server-side selection, so we can enable/disabl= e + * the serverXML checkbox button. + */ + handleServersideSelection(); + + =20 + setControl(container); + setPageComplete(true); + + } + + /** + * Fill the combo with proper language names + *=20 + */ + 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/disabl= es + * 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 + *=20 + * @return a string containing the name of the target language + */ + public String getSelectedLanguage() + { + return languageSelectionComboBox.getItem(languageSelectionComboBox.g= etSelectionIndex()); + } + + /** + * the async only status + *=20 + * @return true if "Generate asynchronous code only" is checked + */ + public boolean isAsyncOnlyOn() + { + return asyncOnlyRadioButton.getSelection(); + } + + /** + * the sync only status + *=20 + * @return true if "Generate synchronous code only" is checked + */ + public boolean isSyncOnlyOn() + { + return syncOnlyRadioButton.getSelection(); + } + + /** + * return the package name + *=20 + * @return a string containing the package name to use for code generat= ion + */ + public String getPackageName() + { + return this.packageText.getText(); + } + + /** + * The serverside status + *=20 + * @return true if "Generate Server-Side" is checked + */ + public boolean isServerside() + { + return this.serverSideCheckBoxButton.getSelection(); + } + + /** + *=20 + * @return true if "Generate XML configuration file" is checked + */ + public boolean isServerXML() + { + if (this.serverXMLCheckBoxButton.isEnabled()) + return this.serverXMLCheckBoxButton.getSelection(); + else + return false; + } + + /** + *=20 + * @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=3D190352&r= 1=3D190351&r2=3D190352&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/OutputPage.java (original) +++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/OutputPage.java Sun Jun 12 22:09:30 2005 @@ -1,23 +1,22 @@ /* * Copyright 2004,2005 The Apache Software Foundation. *=20 - * 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 c= opy 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 *=20 * http://www.apache.org/licenses/LICENSE-2.0 *=20 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHO= UT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See th= e - * License for the specific language governing permissions and limitations= under - * the License. + * Unless required by applicable law or agreed to in writing, software dis= tributed 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 Licen= se. */ + package org.apache.axis.tool.codegen.eclipse.ui; =20 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; =20 -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.Codegen= WizardPlugin.getResourceString("page3.desc")); - setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.Cod= egenWizardPlugin.getWizardImageDescriptor()); - //set the page complete status to false at initilaization - setPageComplete(false); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclips= e=2Eswt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite container =3D new Composite(parent, SWT.NULL); - GridLayout layout =3D new GridLayout(); - container.setLayout(layout); - layout.numColumns =3D 3; - layout.verticalSpacing =3D 9; - - GridData gd =3D new GridData(GridData.FILL_HORIZONTAL); - Label label =3D new Label(container, SWT.NULL); - label.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenW= izardPlugin - .getResourceString("page3.output.caption")); - - outputLocation =3D new Text(container, SWT.BORDER); - outputLocation.setLayoutData(gd); - outputLocation.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - handleModifyEvent(); - } - }); - - browseButton =3D new Button(container, SWT.PUSH); - browseButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.C= odegenWizardPlugin - .getResourceString("page3.outselection.browse")); - browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleBrowse(); - } - }); - -// locationSelectCheckBox =3D new Button(container, SWT.CHECK); -// locationSelectCheckBox.setText("Workspace projects only"); - - setControl(container); - =20 - - } - =20 - /** - * get the output location - * @return - */ - public String getOutputLocation() { - return outputLocation.getText(); - } - - /** - * Worker method for handling modifications to the=20 - * textbox - * - */ - private void handleModifyEvent() { - String text =3D this.outputLocation.getText(); - if ((text =3D=3D null) || (text.trim().equals(""))) { - updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.Codeg= enWizardPlugin - .getResourceString("page3.error.nolocation")); - return; - } - updateStatus(null); - } - - /** - * Updates the wizard page error messages - * @param message - */ - private void updateStatus(String message) { - setErrorMessage(message); - setPageComplete(message =3D=3D null); - } - - /** - * Handle the browse button events - * - */ - private void handleBrowse() { - boolean location =3D false;//locationSelectCheckBox.getSelection()= ; - if (!location) { - DirectoryDialog dialog =3D new DirectoryDialog(this.getShell()= ); - String returnString =3D dialog.open(); - if (returnString !=3D null) { - outputLocation.setText(returnString); +public class OutputPage extends WizardPage +{ + /** + * The key to store the output location in the settings + *=20 + */ + private static final String PREF_OUTPUT_LOCATION =3D "PREF_OUTPUT_LOCAT= ION"; + private Text outputLocation; + private Button browseButton; + private Button locationSelectCheckBox; + =20 + /** + * The dialog settings of this page, which are stored in the plugin's m= eta + * folder. + */ + private IDialogSettings settings; + + /** + *=20 + */ + public OutputPage() + { + super(CodegenWizardPlugin.getResourceString("page3.name")); + setTitle(CodegenWizardPlugin.getResourceString("page3.title")); + setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWi= zardPlugin.getResourceString("page3.desc")); + setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.Codeg= enWizardPlugin.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 Plu= gin's settings for this OptionsPage, create a + * new section + */ + IDialogSettings rootSettings =3D CodegenWizardPlugin.getDefault().ge= tDialogSettings(); + IDialogSettings section =3D rootSettings.getSection(this.getClass().= getName()); + if (section =3D=3D null) + { + settings =3D rootSettings.addNewSection(this.getClass().getName()= ); + initializeDefaultSettings(); + } + else + { + settings =3D section; + } + + + } + + + /** + * Creates some initial values for the settings. On the output page, th= is + * is not very much. + */ + private void initializeDefaultSettings() + { + settings.put(PREF_OUTPUT_LOCATION,""); + } + + /* + * (non-Javadoc) + *=20 + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse= .swt.widgets.Composite) + */ + public void createControl(Composite parent) + { + Composite container =3D new Composite(parent, SWT.NULL); + GridLayout layout =3D new GridLayout(); + container.setLayout(layout); + layout.numColumns =3D 3; + layout.verticalSpacing =3D 9; + =20 + GridData gd =3D new GridData(GridData.FILL_HORIZONTAL); + Label label =3D new Label(container, SWT.NULL); + label.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWiz= ardPlugin + .getResourceString("page3.output.caption")); + + outputLocation =3D 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 =3D new Button(container, SWT.PUSH); + browseButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.Cod= egenWizardPlugin + .getResourceString("page3.outselection.browse")); + browseButton.addSelectionListener(new SelectionAdapter() + { + public void widgetSelected(SelectionEvent e) + { + handleBrowse(); + } + }); + + // locationSelectCheckBox =3D new Button(container, SWT.CHECK); + // locationSelectCheckBox.setText("Workspace projects only"); + + setControl(container); + =20 + /* + * Update the buttons, because we could have get a valid path from + * the settings store. + */ + handleModifyEvent(); + } + + /** + * get the output location + *=20 + * @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 + *=20 + */ + private void handleModifyEvent() + { + String text =3D this.outputLocation.getText(); + if ((text =3D=3D null) || (text.trim().equals(""))) + { + updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenW= izardPlugin + .getResourceString("page3.error.nolocation")); + return; + } + updateStatus(null); + } + + /** + * Updates the wizard page error messages + *=20 + * @param message an error message to display in the dialog + */ + private void updateStatus(String message) + { + setErrorMessage(message); + setPageComplete(message =3D=3D null); + } + + /** + * Handle the browse button events: opens a dialog where the user + * can choose an external directory location + *=20 + */ + private void handleBrowse() + { + boolean location =3D false;// locationSelectCheckBox.getSelection(); + if (!location) + { + DirectoryDialog dialog =3D new DirectoryDialog(this.getShell()); + String returnString =3D dialog.open(); + if (returnString !=3D null) + { + outputLocation.setText(returnString); + } + } + else + { + ContainerSelectionDialog dialog =3D new ContainerSelectionDialog(= getShell(), ResourcesPlugin.getWorkspace() + .getRoot(), false, org.apache.axis.tool.codegen.eclipse.plugin= .CodegenWizardPlugin + .getResourceString("page3.containerbox.title")); + if (dialog.open() =3D=3D ContainerSelectionDialog.OK) + { + Object[] result =3D dialog.getResult(); + if (result.length =3D=3D 1) + { + outputLocation.setText(((Path) result[0]).toOSString()); } - } else { - ContainerSelectionDialog dialog =3D - new ContainerSelectionDialog( - getShell(), - ResourcesPlugin.getWorkspace().getRoot(), - false, - org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.ge= tResourceString("page3.containerbox.title")); - if (dialog.open() =3D=3D ContainerSelectionDialog.OK) { - Object[] result =3D dialog.getResult(); - if (result.length =3D=3D 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= =3D190352&r1=3D190351&r2=3D190352&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/WSDLFileSelectionPage.java (original) +++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/eclipse/ui/WSDLFileSelectionPage.java Sun Jun 12 22:09:30 2005 @@ -1,7 +1,9 @@ + package org.apache.axis.tool.codegen.eclipse.ui; =20 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; =20 /** - * The first page of the code generator wizrad.=20 - * Asks for the WSDL file Name + * The first page of the code generator wizrad. Asks for the WSDL file Name */ =20 -public class WSDLFileSelectionPage extends WizardPage { -=09 - private Text fileText; - private ISelection selection; - - /** - *=20 - * @param pageName - */ - public WSDLFileSelectionPage(ISelection selection) { - super(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.ge= tResourceString("page1.name")); - setTitle(CodegenWizardPlugin.getResourceString("page1.title")); - setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizard= Plugin.getResourceString("page1.desc")); - this.selection =3D selection; - setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWi= zardPlugin.getWizardImageDescriptor()); - //set the page complete status to false at initiation=20 - setPageComplete(false); - } - - /** - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - =20 - Composite container =3D new Composite(parent, SWT.NULL); - GridLayout layout =3D new GridLayout(); - container.setLayout(layout); - layout.numColumns =3D 3; - layout.verticalSpacing =3D 9; - - GridData gd =3D new GridData(GridData.FILL_HORIZONTAL); - Label label =3D new Label(container, SWT.NULL); - label.setText(CodegenWizardPlugin.getResourceString("page1.fileselection= .label")); - - fileText =3D new Text(container, SWT.BORDER | SWT.SINGLE); - fileText.setLayoutData(gd); - fileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - dialogChanged(); - } - }); - =09 - Button button =3D new Button(container, SWT.PUSH); - button.setText(CodegenWizardPlugin.getResourceString("page1.fileselectio= n=2Ebrowse")); - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleBrowse(); - } - }); - setControl(container); - } -=09 - /** - * Handle the dialog change event. Basically evaluates the file name - * and sets the error message accordingly=20 - */ - private void dialogChanged() { - =20 - String fileName =3D getFileName(); - =20 - if (fileName.length() =3D=3D 0) { - updateStatus(CodegenWizardPlugin.getResourceString("page1.error.filemis= singerror")); - return; - } - =20 - if (!fileName.matches(".*\\.wsdl")){ - updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizard= Plugin.getResourceString("page1.error.wrongextension")); - return; - } - =20 - updateStatus(null); - =20 - } -=09 - /** - * Pops up the file browse dialog box - * - */ - private void handleBrowse(){ - FileDialog fileDialog =3D new FileDialog(this.getShell()); - fileDialog.setFilterExtensions(new String[]{"*.wsdl"}); - String fileName =3D fileDialog.open(); - if (fileName!=3Dnull){ - fileText.setText(fileName); - } - =20 - } -=09 - /** - * Updates the wizard page messages - * @param message - */ - private void updateStatus(String message) { - setErrorMessage(message); - setPageComplete(message =3D=3D 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 =3D "PREF_WSDL_LOCATION"; + private Text fileText; + private ISelection selection; + =20 + /** + * The store where the settings are saved to, in the plugin meta folder. + */ + private IDialogSettings settings; + + /** + *=20 + * @param pageName + */ + public WSDLFileSelectionPage(ISelection selection) + { + super(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugi= n=2EgetResourceString("page1.name")); + setTitle(CodegenWizardPlugin.getResourceString("page1.title")); + setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWi= zardPlugin.getResourceString("page1.desc")); + this.selection =3D selection; + setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.Codeg= enWizardPlugin.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 Plu= gin's settings for this OptionsPage, create a + * new section + */ + IDialogSettings rootSettings =3D CodegenWizardPlugin.getDefault().ge= tDialogSettings(); + IDialogSettings section =3D rootSettings.getSection(this.getClass().= getName()); + if (section =3D=3D null) + { + settings =3D rootSettings.addNewSection(this.getClass().getName()= ); + initializeDefaultSettings(); + } + else + { + settings =3D section; + } + + } + + /** + * Creates a default value for the settings on this page. For WSDLFileS= election, this is not very much. + */ + private void initializeDefaultSettings() + { + settings.put(PREF_WSDL_LOCATION,""); + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) + { + + Composite container =3D new Composite(parent, SWT.NULL); + GridLayout layout =3D new GridLayout(); + container.setLayout(layout); + layout.numColumns =3D 3; + layout.verticalSpacing =3D 9; + + GridData gd =3D new GridData(GridData.FILL_HORIZONTAL); + Label label =3D new Label(container, SWT.NULL); + label.setText(CodegenWizardPlugin.getResourceString("page1.fileselec= tion.label")); + + fileText =3D 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 =3D new Button(container, SWT.PUSH); + button.setText(CodegenWizardPlugin.getResourceString("page1.filesele= ction.browse")); + button.addSelectionListener(new SelectionAdapter() + { + public void widgetSelected(SelectionEvent e) + { + handleBrowse(); + } + }); + setControl(container); + =20 + /* + * 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 an= d sets the error message accordingly + */ + private void dialogChanged() + { + String fileName =3D getFileName(); + + if (fileName.length() =3D=3D 0) + { + updateStatus(CodegenWizardPlugin.getResourceString("page1.error.f= ilemissingerror")); + return; + } + + if (!fileName.matches(".*\\.wsdl")) + { + updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenW= izardPlugin + .getResourceString("page1.error.wrongextension")); + return; + } + + updateStatus(null); + + } + + /** + * Pops up the file browse dialog box + *=20 + */ + private void handleBrowse() + { + FileDialog fileDialog =3D new FileDialog(this.getShell()); + fileDialog.setFilterExtensions(new String[] {"*.wsdl"}); + String fileName =3D fileDialog.open(); + if (fileName !=3D null) + { + fileText.setText(fileName); + } + + } + + /** + * Updates the wizard page messages + *=20 + * @param message + */ + private void updateStatus(String message) + { + setErrorMessage(message); + setPageComplete(message =3D=3D null); + } + + /** + * Get the file name + *=20 + * @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=3D190352&= r1=3D190351&r2=3D190352&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/resource/Codegen.properties (original) +++ webservices/axis/trunk/java/modules/tool/src/org/apache/axis/tool/codeg= en/resource/Codegen.properties Sun Jun 12 22:09:30 2005 @@ -46,5 +46,7 @@ # ########################################################################## #Wizard +generator.generating=3DGenerating code... +generator.readingWOM=3DReading WSDL file... #Success message wizard.success=3DCode generation successful!