1 16 package org.apache.axis.tool.codegen.eclipse.ui; 17 18 import java.io.File ; 19 20 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin; 21 import org.eclipse.swt.SWT; 22 import org.eclipse.swt.events.ModifyEvent; 23 import org.eclipse.swt.events.ModifyListener; 24 import org.eclipse.swt.events.SelectionEvent; 25 import org.eclipse.swt.events.SelectionListener; 26 import org.eclipse.swt.layout.GridData; 27 import org.eclipse.swt.layout.GridLayout; 28 import org.eclipse.swt.widgets.Button; 29 import org.eclipse.swt.widgets.Composite; 30 import org.eclipse.swt.widgets.DirectoryDialog; 31 import org.eclipse.swt.widgets.Label; 32 import org.eclipse.swt.widgets.Text; 33 34 40 public class JavaWSDLOutputLocationPage extends AbstractWizardPage { 41 42 private Text outputFolderTextBox; 43 private Text outputFileNameTextBox; 44 45 48 public JavaWSDLOutputLocationPage() { 49 super("page6"); 50 } 51 54 protected void initializeDefaultSettings() { 55 settings.put(PREF_JAVA_OUTPUT_WSDL_LOCATION,System.getProperty("user.dir")); 56 settings.put(JAVA_OUTPUT_WSDL_NAME,"service.wsdl"); 57 58 } 59 60 63 public int getPageType() { 64 return JAVA_2_WSDL_TYPE; 65 } 66 67 70 public void createControl(Composite parent) { 71 Composite container = new Composite(parent, SWT.NULL); 72 GridLayout layout = new GridLayout(); 73 container.setLayout(layout); 74 layout.numColumns = 3; 75 layout.verticalSpacing = 9; 76 77 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 78 Label label = new Label(container, SWT.NULL); 79 label.setText(CodegenWizardPlugin 80 .getResourceString("page6.output.label")); 81 82 outputFolderTextBox = new Text(container,SWT.BORDER); 83 outputFolderTextBox.setLayoutData(gd); 84 outputFolderTextBox.setText(settings.get(PREF_JAVA_OUTPUT_WSDL_LOCATION)); 85 outputFolderTextBox.addModifyListener(new ModifyListener(){ 86 public void modifyText(ModifyEvent e){ 87 handleFolderTextChange(); 88 } 89 }); 90 91 Button browseButton = new Button(container,SWT.PUSH); 92 browseButton.setText(CodegenWizardPlugin 93 .getResourceString("general.browse")); 94 browseButton.addSelectionListener(new SelectionListener(){ 95 public void widgetSelected(SelectionEvent e){ 96 handleBrowse(); 97 } 98 public void widgetDefaultSelected(SelectionEvent e){} 99 }); 100 101 label = new Label(container, SWT.NULL); 102 label.setText(CodegenWizardPlugin 103 .getResourceString("page6.outputname.label")); 104 105 gd = new GridData(GridData.FILL_HORIZONTAL); 106 outputFileNameTextBox = new Text(container,SWT.BORDER); 107 outputFileNameTextBox.setLayoutData(gd); 108 outputFileNameTextBox.setText(settings.get(JAVA_OUTPUT_WSDL_NAME)); 109 outputFileNameTextBox.addModifyListener(new ModifyListener(){ 110 public void modifyText(ModifyEvent e){ 111 handleFileNameTextChange(); 112 } 113 }); 114 115 if(restoredFromPreviousSettings){ 116 handleFolderTextChange(); 117 handleFolderTextChange(); 118 } 119 120 setControl(container); 121 122 } 123 124 private void handleFolderTextChange(){ 125 String outputFolder = outputFolderTextBox.getText(); 126 settings.put(PREF_JAVA_OUTPUT_WSDL_LOCATION,outputFolder); 127 if ("".equals(outputFolder.trim())){ 128 updateStatus("Input a proper location for the output"); 129 }else{ 130 updateStatus(null); 131 } 132 } 133 134 private void handleFileNameTextChange(){ 135 String outFileName = outputFileNameTextBox .getText(); 136 settings.put(JAVA_OUTPUT_WSDL_NAME,outFileName); 137 if ("".equals(outFileName.trim())){ 138 updateStatus("Input a file name"); 139 }else if (outFileName.matches("\\W")){ 140 updateStatus("Input a valid file name"); 141 }else{ 142 updateStatus(null); 143 } 144 } 145 146 private void handleBrowse(){ 147 DirectoryDialog fileDialog = new DirectoryDialog(this.getShell()); 148 String dirName = fileDialog.open(); 149 if (dirName != null) { 150 outputFolderTextBox.setText(dirName); 151 } 152 153 } 154 155 public String getFullFileName(){ 156 String folder =this.outputFolderTextBox.getText(); 157 String fileName = this.outputFileNameTextBox.getText(); 158 if (!fileName.endsWith(".wsdl")){ 159 fileName = fileName + ".wsdl"; 160 } 161 return folder + File.separator +fileName; 162 } 163 164 public String getOutputWSDLName(){ 165 return this.outputFileNameTextBox.getText(); 166 } 167 168 public String getOutputLocation(){ 169 return this.outputFolderTextBox.getText(); 170 } 171 172 } 173 | Popular Tags |