1 16 package org.apache.axis.tool.service.eclipse.ui; 17 18 19 import org.apache.axis.tool.service.bean.Page1Bean; 20 import org.apache.axis.tool.service.eclipse.plugin.ServiceArchiver; 21 import org.eclipse.jface.wizard.WizardPage; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.events.ModifyEvent; 24 import org.eclipse.swt.events.ModifyListener; 25 import org.eclipse.swt.events.MouseAdapter; 26 import org.eclipse.swt.events.MouseEvent; 27 import org.eclipse.swt.layout.GridData; 28 import org.eclipse.swt.layout.GridLayout; 29 import org.eclipse.swt.widgets.Button; 30 import org.eclipse.swt.widgets.Composite; 31 import org.eclipse.swt.widgets.DirectoryDialog; 32 import org.eclipse.swt.widgets.Label; 33 import org.eclipse.swt.widgets.Text; 34 35 36 public class WizardPane1 extends WizardPage { 37 38 private Text classFileLocationText; 39 private Button browseButton; 40 41 private boolean pageComplete; 42 43 public WizardPane1(){ 44 super("page1"); 45 this.setTitle(ServiceArchiver.getResourceString("page1.title")); 46 this.setDescription(ServiceArchiver.getResourceString("page1.welcometext")); 47 this.setImageDescriptor(ServiceArchiver.getWizardImageDescriptor()); 48 } 49 50 51 54 public void createControl(Composite parent) { 55 Composite container = new Composite(parent, SWT.NULL); 56 GridLayout layout = new GridLayout(); 57 layout.numColumns=3; 58 container.setLayout(layout); 59 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 60 Label lable = new Label(container,SWT.NULL); 61 lable.setText(ServiceArchiver.getResourceString("page1.fileLocationLabel")); 62 63 classFileLocationText = new Text(container,SWT.BORDER); 64 classFileLocationText.setLayoutData(gd); 65 classFileLocationText.addModifyListener(new ModifyListener(){ 66 public void modifyText(ModifyEvent e){ 67 handleModify(); 68 } 69 }); 70 71 browseButton = new Button(container,SWT.PUSH); 72 browseButton.setText(ServiceArchiver.getResourceString("general.browse")); 73 browseButton.addMouseListener(new MouseAdapter(){ 74 public void mouseUp(MouseEvent e) { 75 handleBrowse(); 76 } 77 }); 78 79 setControl(container); 80 setPageComplete(false); 81 } 82 83 84 private void handleBrowse(){ 85 DirectoryDialog dirDialog = new DirectoryDialog(this.getShell()); 86 dirDialog.setMessage(ServiceArchiver.getResourceString("page1.filedialogTitle")); 87 String returnText = dirDialog.open(); 88 if (returnText!=null){ 89 this.classFileLocationText.setText(returnText); 90 } 91 } 92 93 private void handleModify(){ 94 String classLocationText = this.classFileLocationText.getText().trim(); 95 if (classLocationText.equals("")){ 96 updateMessage("Filename should not be empty"); 97 return; 98 }else{ 99 updateMessage(null); 100 } 101 } 102 103 private void updateMessage(String str){ 104 this.setErrorMessage(str); 105 setPageComplete(str==null); 106 } 107 108 public Page1Bean getBean(){ 109 Page1Bean pageBean = new Page1Bean(); 110 pageBean.setFileLocation(this.classFileLocationText.getText()); 111 return pageBean; 112 } 113 } 114 | Popular Tags |