1 16 package org.apache.axis.tool.service.eclipse.ui; 17 18 import org.apache.axis.tool.service.bean.Page2Bean; 19 import org.apache.axis.tool.service.eclipse.plugin.ServiceArchiver; 20 import org.eclipse.jface.wizard.WizardPage; 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.MouseAdapter; 25 import org.eclipse.swt.events.MouseEvent; 26 import org.eclipse.swt.events.SelectionEvent; 27 import org.eclipse.swt.events.SelectionListener; 28 import org.eclipse.swt.layout.GridData; 29 import org.eclipse.swt.layout.GridLayout; 30 import org.eclipse.swt.widgets.Button; 31 import org.eclipse.swt.widgets.Composite; 32 import org.eclipse.swt.widgets.FileDialog; 33 import org.eclipse.swt.widgets.Label; 34 import org.eclipse.swt.widgets.Text; 35 36 public class WizardPane2 extends WizardPage { 37 38 private Text serviceXMLText; 39 private Label manualSelectionLabel; 40 private Button browseButton; 41 private Button selectAutoFileGenerationCheckBox; 42 43 private boolean skipNextPage=true; 44 private boolean pageComplete; 45 46 public WizardPane2(){ 47 super("page2"); 48 this.setTitle(ServiceArchiver.getResourceString("page2.title")); 49 this.setDescription(ServiceArchiver.getResourceString("page2.welcometext")); 50 this.setImageDescriptor(ServiceArchiver.getWizardImageDescriptor()); 51 } 52 53 56 public void createControl(Composite parent) { 57 Composite container = new Composite(parent, SWT.NULL); 58 GridLayout layout = new GridLayout(); 59 layout.numColumns=3; 60 container.setLayout(layout); 61 62 manualSelectionLabel = new Label(container,SWT.NULL); 63 manualSelectionLabel.setText(ServiceArchiver.getResourceString("page2.selectservicexml.caption")); 64 65 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 66 serviceXMLText = new Text(container,SWT.BORDER); 67 serviceXMLText.setLayoutData(gd); 68 serviceXMLText.addModifyListener(new ModifyListener(){ 69 public void modifyText(ModifyEvent e){ 70 handleModify(); 71 } 72 }); 73 74 browseButton = new Button(container,SWT.PUSH); 75 browseButton.setText(ServiceArchiver.getResourceString("general.browse")); 76 browseButton.addMouseListener(new MouseAdapter(){ 77 public void mouseUp(MouseEvent e) { 78 handleBrowse(); 79 } 80 }); 81 82 gd = new GridData(); 83 gd.horizontalSpan = 2; 84 selectAutoFileGenerationCheckBox = new Button(container,SWT.CHECK); 85 selectAutoFileGenerationCheckBox.setLayoutData(gd); 86 selectAutoFileGenerationCheckBox.setText(ServiceArchiver.getResourceString("page2.generateauto.caption")); 87 selectAutoFileGenerationCheckBox.addSelectionListener(new SelectionListener(){ 88 public void widgetSelected(SelectionEvent e){ 89 handleSelection(); 90 } 91 public void widgetDefaultSelected(SelectionEvent e){} 92 }); 93 selectAutoFileGenerationCheckBox.setEnabled(false); 96 selectAutoFileGenerationCheckBox.setToolTipText(ServiceArchiver.getResourceString("page2.autogen.tooltip")); 97 setControl(container); 99 setPageComplete(false); 100 } 101 102 private void handleBrowse(){ 103 FileDialog fileDialog = new FileDialog(this.getShell()); 104 fileDialog.setFilterExtensions(new String []{"service.xml"}); 105 String returnFileName = fileDialog.open() ; 106 if (returnFileName!=null){ 107 this.serviceXMLText.setText(returnFileName); 108 } 109 } 110 111 private void handleSelection(){ 112 if (this.selectAutoFileGenerationCheckBox.getSelection()){ 113 changeManualSelectionStatus(false); 114 this.skipNextPage = false; 115 updateMessage(null); 116 }else{ 117 changeManualSelectionStatus(true); 118 this.skipNextPage = true; 119 handleModify(); 120 121 } 122 } 123 124 private void changeManualSelectionStatus(boolean state){ 125 this.serviceXMLText.setEnabled(state); 126 this.browseButton.setEnabled(state); 127 this.manualSelectionLabel.setEnabled(state); 128 } 129 130 private void handleModify(){ 131 String serviceXMLString =serviceXMLText.getText().trim().toLowerCase(); 132 if (serviceXMLString.equals("")){ 133 this.updateMessage(ServiceArchiver.getResourceString("page2.error.servicenameempty")); 134 }else if(!serviceXMLString.endsWith("service.xml")){ 135 this.updateMessage(ServiceArchiver.getResourceString("page2.error.servicenamewrong")); 136 }else{ 137 this.updateMessage(null); 138 } 139 } 140 141 private void updateMessage(String str){ 142 this.setErrorMessage(str); 143 setPageComplete(str==null); 144 } 145 146 149 public boolean isSkipNextPage() { 150 return skipNextPage; 151 } 152 153 public Page2Bean getBean(){ 154 Page2Bean pageBean = new Page2Bean(); 155 pageBean.setManual(true); 156 pageBean.setManualFileName(this.serviceXMLText.getText()); 157 return pageBean; 158 } 159 } 160 | Popular Tags |