1 package org.apache.axis.tool.codegen.eclipse.ui; 2 3 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin; 4 import org.eclipse.jface.dialogs.IDialogPage; 5 import org.eclipse.jface.viewers.ISelection; 6 import org.eclipse.swt.SWT; 7 import org.eclipse.swt.events.ModifyEvent; 8 import org.eclipse.swt.events.ModifyListener; 9 import org.eclipse.swt.events.SelectionAdapter; 10 import org.eclipse.swt.events.SelectionEvent; 11 import org.eclipse.swt.layout.GridData; 12 import org.eclipse.swt.layout.GridLayout; 13 import org.eclipse.swt.widgets.Button; 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.swt.widgets.FileDialog; 16 import org.eclipse.swt.widgets.Label; 17 import org.eclipse.swt.widgets.Text; 18 19 22 23 public class WSDLFileSelectionPage extends AbstractWizardPage { 24 25 private Text fileText; 26 27 private ISelection selection; 28 29 30 34 public WSDLFileSelectionPage() { 35 super("page1"); 36 37 38 } 39 40 44 protected void initializeDefaultSettings() { 45 settings.put(PREF_WSDL_LOCATION, ""); 46 } 47 48 51 public void createControl(Composite parent) { 52 53 Composite container = new Composite(parent, SWT.NULL); 54 GridLayout layout = new GridLayout(); 55 container.setLayout(layout); 56 layout.numColumns = 3; 57 layout.verticalSpacing = 9; 58 59 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 60 Label label = new Label(container, SWT.NULL); 61 label.setText(CodegenWizardPlugin 62 .getResourceString("page1.fileselection.label")); 63 64 fileText = new Text(container, SWT.BORDER | SWT.SINGLE); 65 fileText.setLayoutData(gd); 66 fileText.setText(settings.get(PREF_WSDL_LOCATION)); 67 fileText.addModifyListener(new ModifyListener() { 68 public void modifyText(ModifyEvent e) { 69 settings.put(PREF_WSDL_LOCATION, fileText.getText()); 70 dialogChanged(); 71 } 72 }); 73 74 Button button = new Button(container, SWT.PUSH); 75 button.setText(CodegenWizardPlugin 76 .getResourceString("page1.fileselection.browse")); 77 button.addSelectionListener(new SelectionAdapter() { 78 public void widgetSelected(SelectionEvent e) { 79 handleBrowse(); 80 } 81 }); 82 83 setPageComplete(false); 84 setControl(container); 85 86 90 if (restoredFromPreviousSettings){ 91 dialogChanged(); 92 } 93 } 94 95 99 private void dialogChanged() { 100 String fileName = getFileName(); 101 102 if (fileName.length() == 0) { 103 updateStatus(CodegenWizardPlugin 104 .getResourceString("page1.error.filemissingerror")); 105 return; 106 } 107 108 if (!fileName.matches(".*\\.wsdl")) { 109 updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin 110 .getResourceString("page1.error.wrongextension")); 111 return; 112 } 113 114 updateStatus(null); 115 116 } 117 118 122 private void handleBrowse() { 123 FileDialog fileDialog = new FileDialog(this.getShell()); 124 fileDialog.setFilterExtensions(new String [] { "*.wsdl" }); 125 String fileName = fileDialog.open(); 126 if (fileName != null) { 127 fileText.setText(fileName); 128 } 129 130 } 131 132 133 138 public String getFileName() { 139 return fileText.getText(); 140 } 141 142 147 public int getPageType() { 148 return WSDL_2_JAVA_TYPE; 149 } 150 } | Popular Tags |