KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > codegen > eclipse > ui > JavaWSDLOutputLocationPage


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis.tool.codegen.eclipse.ui;
17
18 import java.io.File JavaDoc;
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 /**
35  * @author Ajith
36  *
37  * TODO To change the template for this generated type comment go to
38  * Window - Preferences - Java - Code Style - Code Templates
39  */

40 public class JavaWSDLOutputLocationPage extends AbstractWizardPage {
41     
42     private Text outputFolderTextBox;
43     private Text outputFileNameTextBox;
44
45     /**
46      * @param pageName
47      */

48     public JavaWSDLOutputLocationPage() {
49         super("page6");
50     }
51     /* (non-Javadoc)
52      * @see org.apache.axis.tool.codegen.eclipse.ui.AbstractWizardPage#initializeDefaultSettings()
53      */

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     /* (non-Javadoc)
61      * @see org.apache.axis.tool.codegen.eclipse.ui.AbstractWizardPage#getPageType()
62      */

63     public int getPageType() {
64          return JAVA_2_WSDL_TYPE;
65     }
66
67     /* (non-Javadoc)
68      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
69      */

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 JavaDoc 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 JavaDoc 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 JavaDoc dirName = fileDialog.open();
149         if (dirName != null) {
150             outputFolderTextBox.setText(dirName);
151         }
152
153     }
154     
155     public String JavaDoc getFullFileName(){
156         String JavaDoc folder =this.outputFolderTextBox.getText();
157         String JavaDoc 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 JavaDoc getOutputWSDLName(){
165         return this.outputFileNameTextBox.getText();
166     }
167     
168     public String JavaDoc getOutputLocation(){
169         return this.outputFolderTextBox.getText();
170     }
171
172 }
173
Popular Tags