KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package org.apache.axis.tool.codegen.eclipse.ui;
17
18 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
19 import org.apache.axis.tool.codegen.eclipse.util.UIConstants;
20 import org.apache.axis.wsdl.util.URLProcessor;
21 import org.eclipse.jface.wizard.WizardPage;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.SelectionEvent;
24 import org.eclipse.swt.events.SelectionListener;
25 import org.eclipse.swt.layout.GridData;
26 import org.eclipse.swt.layout.GridLayout;
27 import org.eclipse.swt.widgets.Button;
28 import org.eclipse.swt.widgets.Combo;
29 import org.eclipse.swt.widgets.Composite;
30 import org.eclipse.swt.widgets.Label;
31 import org.eclipse.swt.widgets.Text;
32
33 public class OptionsPage extends WizardPage implements UIConstants {
34
35     private Combo languageSelectionComboBox;
36
37     private Button syncAndAsyncRadioButton;
38
39     private Button syncOnlyRadioButton;
40
41     private Button asyncOnlyRadioButton;
42
43     private Text packageText;
44
45     private Button serverSideCheckBoxButton;
46     
47     private Button testCaseCheckBoxButton;
48
49     private Button serverXMLCheckBoxButton;
50
51     /**
52      * @param pageName
53      */

54     public OptionsPage() {
55         super(CodegenWizardPlugin.getResourceString("page2.name"));
56         setTitle(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page2.title"));
57         setDescription(CodegenWizardPlugin.getResourceString("page2.desc"));
58         setImageDescriptor(CodegenWizardPlugin.getWizardImageDescriptor());
59
60     }
61
62     /*
63      * (non-Javadoc)
64      *
65      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
66      */

67     public void createControl(Composite parent) {
68
69         Composite container = new Composite(parent, SWT.NULL);
70         GridLayout layout = new GridLayout();
71         container.setLayout(layout);
72         layout.numColumns = 3;
73         layout.verticalSpacing = 9;
74
75         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
76         gd.horizontalSpan = 2;
77
78         Label label = new Label(container, SWT.NULL);
79         label.setText(CodegenWizardPlugin
80                 .getResourceString("page2.language.caption"));
81
82         languageSelectionComboBox = new Combo(container, SWT.DROP_DOWN
83                 | SWT.BORDER | SWT.READ_ONLY);
84         //fill the combo
85
this.fillLanguageCombo();
86         languageSelectionComboBox.setLayoutData(gd);
87
88         syncAndAsyncRadioButton = new Button(container, SWT.RADIO);
89         syncAndAsyncRadioButton.setText(CodegenWizardPlugin
90                 .getResourceString("page2.syncAsync.caption"));
91         syncAndAsyncRadioButton.setSelection(true);
92
93         syncOnlyRadioButton = new Button(container, SWT.RADIO);
94         syncOnlyRadioButton.setText(CodegenWizardPlugin
95                 .getResourceString("page2.sync.caption"));
96
97         asyncOnlyRadioButton = new Button(container, SWT.RADIO);
98         asyncOnlyRadioButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
99                 .getResourceString("page2.async.caption"));
100
101         label = new Label(container, SWT.NULL);
102         label.setText(CodegenWizardPlugin
103                 .getResourceString("page2.package.caption"));
104
105         packageText = new Text(container, SWT.BORDER);
106         gd = new GridData(GridData.FILL_HORIZONTAL);
107         gd.horizontalSpan = 2;
108
109         packageText.setLayoutData(gd);
110         packageText.setText(URLProcessor.getNameSpaceFromURL(""));//get this text from the URLProcessor
111

112         
113         gd = new GridData(GridData.FILL_HORIZONTAL);
114         gd.horizontalSpan = 3;
115         testCaseCheckBoxButton = new Button(container, SWT.CHECK);
116         testCaseCheckBoxButton.setLayoutData(gd);
117         testCaseCheckBoxButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
118                 .getResourceString("page2.testcase.caption"));
119         
120         
121         
122         
123         serverSideCheckBoxButton = new Button(container, SWT.CHECK);
124         serverSideCheckBoxButton.setText(CodegenWizardPlugin
125                 .getResourceString("page2.serverside.caption"));
126         serverSideCheckBoxButton.addSelectionListener(new SelectionListener() {
127             public void widgetSelected(SelectionEvent e) {
128                 handleServersideSelection();
129             }
130
131             public void widgetDefaultSelected(SelectionEvent e) {
132             }
133         });
134
135         serverXMLCheckBoxButton = new Button(container, SWT.CHECK);
136         serverXMLCheckBoxButton.setText(CodegenWizardPlugin
137                 .getResourceString("page2.serviceXML.caption"));
138         serverXMLCheckBoxButton.setEnabled(false);
139
140         setControl(container);
141         setPageComplete(true);
142
143     }
144
145     /**
146      * Fill the combo with proper language names
147      *
148      */

149     private void fillLanguageCombo() {
150
151         languageSelectionComboBox.add(JAVA);
152         languageSelectionComboBox.add(C_SHARP);
153         languageSelectionComboBox.add(C_PLUS_PLUS);
154
155         languageSelectionComboBox.setText(languageSelectionComboBox.getItem(0));
156     }
157
158     private void handleServersideSelection() {
159         if (this.serverSideCheckBoxButton.getSelection()) {
160             this.serverXMLCheckBoxButton.setEnabled(true);
161         } else {
162             this.serverXMLCheckBoxButton.setEnabled(false);
163         }
164     }
165
166     /**
167      * Get the selected language
168      *
169      * @return
170      */

171     public String JavaDoc getSelectedLanguage() {
172         return languageSelectionComboBox.getItem(languageSelectionComboBox
173                 .getSelectionIndex());
174     }
175
176     /**
177      * the async only status
178      *
179      * @return
180      */

181     public boolean isAsyncOnlyOn() {
182         return asyncOnlyRadioButton.getSelection();
183     }
184
185     /**
186      * the sync only status
187      *
188      * @return
189      */

190     public boolean isSyncOnlyOn() {
191         return syncOnlyRadioButton.getSelection();
192     }
193
194     /**
195      * return the package name
196      *
197      * @return
198      */

199     public String JavaDoc getPackageName() {
200         return this.packageText.getText();
201     }
202
203     /**
204      * The serverside status
205      * @return
206      */

207     public boolean isServerside() {
208         return this.serverSideCheckBoxButton.getSelection();
209     }
210
211     public boolean isServerXML() {
212         if (this.serverXMLCheckBoxButton.isEnabled())
213             return this.serverXMLCheckBoxButton.getSelection();
214         else
215             return false;
216     }
217     public boolean isGenerateTestCase(){
218         return this.testCaseCheckBoxButton.getSelection();
219     }
220 }
221
Popular Tags