1 16 package org.apache.axis.tool.codegen.eclipse.ui; 17 18 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin; 19 import org.eclipse.core.resources.ResourcesPlugin; 20 import org.eclipse.core.runtime.Path; 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.SelectionAdapter; 26 import org.eclipse.swt.events.SelectionEvent; 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 import org.eclipse.ui.dialogs.ContainerSelectionDialog; 35 36 public class OutputPage extends WizardPage { 37 private Text outputLocation; 38 private Button browseButton; 39 private Button locationSelectCheckBox; 40 41 44 public OutputPage() { 45 super(CodegenWizardPlugin.getResourceString("page3.name")); 46 setTitle(CodegenWizardPlugin.getResourceString("page3.title")); 47 setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.desc")); 48 setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getWizardImageDescriptor()); 49 setPageComplete(false); 51 52 } 53 54 58 public void createControl(Composite parent) { 59 Composite container = new Composite(parent, SWT.NULL); 60 GridLayout layout = new GridLayout(); 61 container.setLayout(layout); 62 layout.numColumns = 3; 63 layout.verticalSpacing = 9; 64 65 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 66 Label label = new Label(container, SWT.NULL); 67 label.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin 68 .getResourceString("page3.output.caption")); 69 70 outputLocation = new Text(container, SWT.BORDER); 71 outputLocation.setLayoutData(gd); 72 outputLocation.addModifyListener(new ModifyListener() { 73 public void modifyText(ModifyEvent e) { 74 handleModifyEvent(); 75 } 76 }); 77 78 browseButton = new Button(container, SWT.PUSH); 79 browseButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin 80 .getResourceString("page3.outselection.browse")); 81 browseButton.addSelectionListener(new SelectionAdapter() { 82 public void widgetSelected(SelectionEvent e) { 83 handleBrowse(); 84 } 85 }); 86 87 90 setControl(container); 91 92 93 } 94 95 99 public String getOutputLocation() { 100 return outputLocation.getText(); 101 } 102 103 108 private void handleModifyEvent() { 109 String text = this.outputLocation.getText(); 110 if ((text == null) || (text.trim().equals(""))) { 111 updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin 112 .getResourceString("page3.error.nolocation")); 113 return; 114 } 115 updateStatus(null); 116 } 117 118 122 private void updateStatus(String message) { 123 setErrorMessage(message); 124 setPageComplete(message == null); 125 } 126 127 131 private void handleBrowse() { 132 boolean location = false; if (!location) { 134 DirectoryDialog dialog = new DirectoryDialog(this.getShell()); 135 String returnString = dialog.open(); 136 if (returnString != null) { 137 outputLocation.setText(returnString); 138 } 139 } else { 140 ContainerSelectionDialog dialog = 141 new ContainerSelectionDialog( 142 getShell(), 143 ResourcesPlugin.getWorkspace().getRoot(), 144 false, 145 org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.containerbox.title")); 146 if (dialog.open() == ContainerSelectionDialog.OK) { 147 Object [] result = dialog.getResult(); 148 if (result.length == 1) { 149 outputLocation.setText(((Path)result[0]).toOSString()); 150 } 151 } 152 } 153 } 154 } 155 | Popular Tags |