Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2004 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jst.ws.internal.axis.consumption.ui.preferences; |
12 |
|
13 |
import org.eclipse.core.runtime.IStatus; |
14 |
import org.eclipse.core.runtime.Status; |
15 |
import org.eclipse.jface.dialogs.DialogPage; |
16 |
import org.eclipse.jface.dialogs.IMessageProvider; |
17 |
import org.eclipse.jface.preference.PreferencePage; |
18 |
import org.eclipse.jst.ws.internal.axis.consumption.core.context.AxisEmitterContext; |
19 |
import org.eclipse.jst.ws.internal.axis.consumption.core.context.AxisEmitterDefaults; |
20 |
import org.eclipse.jst.ws.internal.axis.consumption.core.plugin.WebServiceAxisConsumptionCorePlugin; |
21 |
import org.eclipse.jst.ws.internal.axis.consumption.ui.AxisConsumptionUIMessages; |
22 |
import org.eclipse.jst.ws.internal.axis.consumption.ui.plugin.WebServiceAxisConsumptionUIPlugin; |
23 |
import org.eclipse.jst.ws.internal.ui.common.UIUtils; |
24 |
import org.eclipse.swt.SWT; |
25 |
import org.eclipse.swt.events.ModifyEvent; |
26 |
import org.eclipse.swt.events.ModifyListener; |
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.Combo; |
31 |
import org.eclipse.swt.widgets.Composite; |
32 |
import org.eclipse.swt.widgets.Control; |
33 |
import org.eclipse.swt.widgets.Group; |
34 |
import org.eclipse.swt.widgets.Label; |
35 |
import org.eclipse.swt.widgets.Text; |
36 |
import org.eclipse.ui.IWorkbench; |
37 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
38 |
import org.eclipse.ui.PlatformUI; |
39 |
import org.eclipse.ui.help.IWorkbenchHelpSystem; |
40 |
|
41 |
|
42 |
|
43 |
public class AxisEmitterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage |
44 |
{ |
45 |
/*CONTEXT_ID PPAE0001 for the Axis Emitter Preference Page*/ |
46 |
private String INFOPOP_PPAE_PAGE = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0001"; |
47 |
// |
48 |
private Button allWanted; |
49 |
/*CONTEXT_ID PPAE0002 for the all wanted check box on the Axis Emitter Preference Page*/ |
50 |
private String INFOPOP_PPAE_CHECKBOX_ALL_WANTED = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0002"; |
51 |
// |
52 |
private Button helperWanted; |
53 |
/*CONTEXT_ID PPAE0003 for helper wanted check box on the Axis Emitter Preference Page*/ |
54 |
private String INFOPOP_PPAE_CHECKBOX_HELPER_WANTED = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0003"; |
55 |
// |
56 |
private Button wrapArrays; |
57 |
/*CONTEXT_ID PPAE0004 for the wrap arrays check box on the Axis Emitter Preference Page*/ |
58 |
private String INFOPOP_PPAE_CHECKBOX_WRAP_ARRAYS = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0004"; |
59 |
|
60 |
private Combo deployScopeTypes; |
61 |
//*CONTEXT_ID PPAE0005 for the deploy scope type combo box on the Axis Emitter page*/ |
62 |
private String INFOPOP_PPAE_COMBO_DEPLOY_SCOPE = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0005"; |
63 |
|
64 |
private Text timeOutField; |
65 |
int timeOut; |
66 |
String wsdl2JavaTimeoutProperty = System.getProperty("AxisWsdl2JavaTimeout"); |
67 |
|
68 |
private Label timeOutPropertyLabel; |
69 |
/*CONTEXT_ID PPAE0006 for the time out field on the Axis Emitter Preference page*/ |
70 |
private String INFOPOP_PPAE_FIELD_TIME_OUT = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0006"; |
71 |
|
72 |
private Button useInheritedMethods; |
73 |
/*CONTEXT_ID PPAE0007 for the use inherited methods check box on the Axis Emitter Preference page*/ |
74 |
private String INFOPOP_PPAE_CHECKBOX_USE_INHERITED_METHODS = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0007"; |
75 |
|
76 |
/*CONTEXT_ID PPAE0008 for the wsdl2java group on the Axis Emitter Preference page*/ |
77 |
private String INFOPOP_PPAE_GROUP_WSDL2JAVA = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0008"; |
78 |
/*CONTEXT_ID PPAE0009 for the java2wsdl group on the Axis Emitter Preference page*/ |
79 |
private String INFOPOP_PPAE_GROUP_JAVA2WSDL = WebServiceAxisConsumptionUIPlugin.ID + ".PPAE0009"; |
80 |
|
81 |
|
82 |
/** |
83 |
* Creates preference page controls on demand. |
84 |
* @param parent the parent for the preference page |
85 |
*/ |
86 |
protected Control createContents(Composite superparent) |
87 |
{ |
88 |
UIUtils utils = new UIUtils( WebServiceAxisConsumptionUIPlugin.ID ); |
89 |
IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); |
90 |
|
91 |
Composite parent = new Composite( superparent, SWT.NONE ); |
92 |
GridLayout layout = new GridLayout(); |
93 |
layout.numColumns = 1; |
94 |
parent.setLayout( layout ); |
95 |
parent.setToolTipText(AxisConsumptionUIMessages.TOOLTIP_PPAE_PAGE); |
96 |
helpSystem.setHelp(parent, INFOPOP_PPAE_PAGE); |
97 |
Group wsdl2JavaGroup = utils.createGroup(parent, AxisConsumptionUIMessages.GROUP_WSDL2JAVA_NAME, AxisConsumptionUIMessages.TOOLTIP_PPAE_GROUP_WSDL2JAVA, INFOPOP_PPAE_GROUP_WSDL2JAVA, 2, 10,10); |
98 |
allWanted = createCheckBox(wsdl2JavaGroup, AxisConsumptionUIMessages.BUTTON_ALL_WANTED,AxisConsumptionUIMessages.TOOLTIP_PPAE_CHECKBOX_ALL_WANTED,INFOPOP_PPAE_CHECKBOX_ALL_WANTED); |
99 |
|
100 |
helperWanted = createCheckBox(wsdl2JavaGroup, AxisConsumptionUIMessages.BUTTON_HELPER_WANTED,AxisConsumptionUIMessages.TOOLTIP_PPAE_CHECKBOX_HELPER_WANTED,INFOPOP_PPAE_CHECKBOX_HELPER_WANTED); |
101 |
|
102 |
wrapArrays = createCheckBox(wsdl2JavaGroup, AxisConsumptionUIMessages.BUTTON_WRAP_ARRAYS,AxisConsumptionUIMessages.TOOLTIP_PPAE_CHECKBOX_WRAP_ARRAYS,INFOPOP_PPAE_CHECKBOX_WRAP_ARRAYS); |
103 |
|
104 |
deployScopeTypes = utils.createCombo(wsdl2JavaGroup, AxisConsumptionUIMessages.LABEL_DEPLOY_SCOPE, AxisConsumptionUIMessages.TOOLTIP_PPAE_COMBO_DEPLOY_SCOPE, INFOPOP_PPAE_COMBO_DEPLOY_SCOPE, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); |
105 |
/* |
106 |
* Ensure the order is the same as it in the fields for class |
107 |
* org.eclipse.jst.ws.internal.axis.consumption.core.context.AxisEmitterContext |
108 |
*/ |
109 |
deployScopeTypes.setItems(new String []{AxisConsumptionUIMessages.DEPLOY_SCOPE_APPLICATION, AxisConsumptionUIMessages.DEPLOY_SCOPE_REQUEST,AxisConsumptionUIMessages.DEPLOY_SCOPE_SESSION}); |
110 |
|
111 |
timeOutField = createTextField(wsdl2JavaGroup,AxisConsumptionUIMessages.LABEL_TIME_OUT,AxisConsumptionUIMessages.TOOLTIP_PPAE_FIELD_TIME_OUT,INFOPOP_PPAE_FIELD_TIME_OUT); |
112 |
timeOutPropertyLabel = new Label(wsdl2JavaGroup, SWT.NONE); |
113 |
|
114 |
Group java2WsdlGroup = utils.createGroup(parent, AxisConsumptionUIMessages.GROUP_JAVA2WSDL_NAME, AxisConsumptionUIMessages.TOOLTIP_PPAE_GROUP_JAVA2WSDL, INFOPOP_PPAE_GROUP_JAVA2WSDL, 2, 10,10); |
115 |
useInheritedMethods = createCheckBox(java2WsdlGroup, AxisConsumptionUIMessages.BUTTON_USE_INHERITED_METHODS,AxisConsumptionUIMessages.TOOLTIP_PPAE_CHECKBOX_USE_INHERITED_METHODS,INFOPOP_PPAE_CHECKBOX_USE_INHERITED_METHODS); |
116 |
|
117 |
initializeValues(); |
118 |
org.eclipse.jface.dialogs.Dialog.applyDialogFont(superparent); |
119 |
|
120 |
return parent; |
121 |
} |
122 |
|
123 |
/** |
124 |
* Creates checkbox with horizontalSpan = 2 in its grid data in order to |
125 |
* match the grid layout for combo |
126 |
*/ |
127 |
private Button createCheckBox( Composite parent, String labelName, String tooltip, String infopop ) |
128 |
{ |
129 |
Button button = new Button( parent, SWT.CHECK ); |
130 |
button.setText(labelName); |
131 |
button.setToolTipText( tooltip ); |
132 |
if( infopop != null ) PlatformUI.getWorkbench().getHelpSystem().setHelp( button, WebServiceAxisConsumptionUIPlugin.ID + "." + infopop ); |
133 |
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); |
134 |
gd.horizontalSpan= 2; |
135 |
button.setLayoutData(gd); |
136 |
return button; |
137 |
} |
138 |
|
139 |
private Text createTextField(Composite parent,String labelName, String tooltip, String infopop) |
140 |
{ tooltip = tooltip == null ? labelName : tooltip; |
141 |
if( labelName != null ) |
142 |
{ |
143 |
Label label = new Label( parent, SWT.WRAP); |
144 |
label.setText( labelName ); |
145 |
label.setToolTipText( tooltip ); |
146 |
} |
147 |
Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); |
148 |
GridData data = new GridData(); |
149 |
data.verticalAlignment = GridData.FILL; |
150 |
data.horizontalAlignment = GridData.FILL; |
151 |
data.grabExcessHorizontalSpace = true; |
152 |
text.setLayoutData(data); |
153 |
text.setToolTipText(tooltip); |
154 |
if( infopop != null ) PlatformUI.getWorkbench().getHelpSystem().setHelp( text, WebServiceAxisConsumptionUIPlugin.ID + "." + infopop ); |
155 |
|
156 |
text.addModifyListener( new ModifyListener() { |
157 |
public void modifyText(ModifyEvent e) { |
158 |
numberFieldChanged((Text) e.widget); |
159 |
} |
160 |
} |
161 |
); |
162 |
return text; |
163 |
} |
164 |
|
165 |
/** |
166 |
* Does anything necessary because the default button has been pressed. |
167 |
*/ |
168 |
protected void performDefaults() |
169 |
{ |
170 |
super.performDefaults(); |
171 |
initializeDefaults(); |
172 |
} |
173 |
|
174 |
/** |
175 |
* Do anything necessary because the OK button has been pressed. |
176 |
* @return whether it is okay to close the preference page |
177 |
*/ |
178 |
public boolean performOk() |
179 |
{ |
180 |
if(validateNumber(timeOutField.getText()).isOK()) |
181 |
storeValues(); |
182 |
return true; |
183 |
} |
184 |
|
185 |
protected void performApply() |
186 |
{ |
187 |
performOk(); |
188 |
} |
189 |
|
190 |
/** |
191 |
* @see IWorkbenchPreferencePage |
192 |
*/ |
193 |
public void init(IWorkbench workbench) { } |
194 |
|
195 |
/** |
196 |
* Initializes states of the controls using default values |
197 |
* in the preference store. |
198 |
*/ |
199 |
private void initializeDefaults() |
200 |
{ |
201 |
allWanted.setSelection( AxisEmitterDefaults.getAllWantedDefault()); |
202 |
helperWanted.setSelection( AxisEmitterDefaults.getHelperWantedDefault()); |
203 |
wrapArrays.setSelection( AxisEmitterDefaults.getWrapArraysDefault()); |
204 |
deployScopeTypes.select(AxisEmitterDefaults.getDeployScopeDefault()); |
205 |
timeOutField.setText("" + AxisEmitterDefaults.getTimeOutDefault()); |
206 |
useInheritedMethods.setSelection(AxisEmitterDefaults.getUseInheritedMethodsDefault()); |
207 |
} |
208 |
|
209 |
/** |
210 |
* Initializes states of the controls from the preference store. |
211 |
*/ |
212 |
private void initializeValues() |
213 |
{ |
214 |
// get the persistent context from the plugin |
215 |
AxisEmitterContext context = WebServiceAxisConsumptionCorePlugin.getInstance().getAxisEmitterContext(); |
216 |
allWanted.setSelection( context.isAllWantedEnabled()); |
217 |
helperWanted.setSelection( context.isHelperWantedEnabled()); |
218 |
wrapArrays.setSelection( context.isWrapArraysEnabled()); |
219 |
deployScopeTypes.select(context.getDeployScopeType()); |
220 |
useInheritedMethods.setSelection( context.isUseInheritedMethodsEnabled()); |
221 |
if (wsdl2JavaTimeoutProperty != null) |
222 |
{ |
223 |
long timeOutProperty = new Integer(wsdl2JavaTimeoutProperty).longValue(); |
224 |
timeOut = (int)Math.ceil(timeOutProperty/1000.0); |
225 |
timeOutField.setEnabled(false); |
226 |
timeOutPropertyLabel.setText(AxisConsumptionUIMessages.MSG_USE_JVM_ARGUMENT_FOR_TIME_OUT); |
227 |
} |
228 |
else |
229 |
{ |
230 |
timeOut = context.getTimeOut(); |
231 |
} |
232 |
timeOutField.setText(""+ timeOut); |
233 |
} |
234 |
|
235 |
/** |
236 |
* Stores the values of the controls back to the preference store. |
237 |
*/ |
238 |
private void storeValues() |
239 |
{ |
240 |
// get the persistent context from the plugin |
241 |
AxisEmitterContext context = WebServiceAxisConsumptionCorePlugin.getInstance().getAxisEmitterContext(); |
242 |
context.setAllWantedEnabled( allWanted.getSelection() ); |
243 |
context.setHelperWantedEnabled( helperWanted.getSelection() ); |
244 |
context.setWrapArraysEnabled( wrapArrays.getSelection() ); |
245 |
context.selectDeployScopeType(deployScopeTypes.getSelectionIndex()); |
246 |
timeOut = Integer.parseInt(timeOutField.getText().trim()); |
247 |
context.setTimeOut(timeOut); |
248 |
context.setUseInheritedMethodsEnabled( useInheritedMethods.getSelection() ); |
249 |
} |
250 |
|
251 |
private void numberFieldChanged(Text textControl) { |
252 |
IStatus status = validateNumber(textControl.getText()); |
253 |
setValid(!status.matches(IStatus.ERROR)); |
254 |
applyToStatusLine(this,status); |
255 |
} |
256 |
|
257 |
private IStatus validateNumber(String numberString) |
258 |
{ |
259 |
IStatus status; |
260 |
try |
261 |
{ |
262 |
int number = Integer.parseInt(numberString); |
263 |
if (number <= 0 && number != -1) |
264 |
{ |
265 |
status = new Status(IStatus.ERROR, WebServiceAxisConsumptionUIPlugin.ID, IStatus.ERROR, |
266 |
AxisConsumptionUIMessages.MSG_ERROR_INVALID_TIME_OUT, null); |
267 |
} |
268 |
else |
269 |
{ timeOut = number; |
270 |
status = Status.OK_STATUS; |
271 |
//we set param:message="" here, Later in |
272 |
//applyToStatusLine(), we do page.setMessage(null,type) |
273 |
status = new Status(IStatus.OK, WebServiceAxisConsumptionUIPlugin.ID, IStatus.OK, "",null); |
274 |
} |
275 |
} |
276 |
catch |
277 |
(NumberFormatException e) |
278 |
{ |
279 |
status = new Status(IStatus.ERROR, WebServiceAxisConsumptionUIPlugin.ID, IStatus.ERROR, |
280 |
AxisConsumptionUIMessages.MSG_ERROR_INVALID_TIME_OUT, null); |
281 |
} |
282 |
return status; |
283 |
} |
284 |
|
285 |
private void applyToStatusLine(DialogPage page, IStatus status) { |
286 |
String message= status.getMessage(); |
287 |
switch (status.getSeverity()) { |
288 |
case IStatus.OK: |
289 |
page.setMessage(null, IMessageProvider.NONE); |
290 |
page.setErrorMessage(null); |
291 |
break; |
292 |
case IStatus.WARNING: |
293 |
page.setMessage(message, IMessageProvider.WARNING); |
294 |
page.setErrorMessage(null); |
295 |
break; |
296 |
case IStatus.INFO: |
297 |
page.setMessage(message, IMessageProvider.INFORMATION); |
298 |
page.setErrorMessage(null); |
299 |
break; |
300 |
default: |
301 |
if (message.length() == 0) { |
302 |
message= null; |
303 |
} |
304 |
page.setMessage(null); |
305 |
page.setErrorMessage(message); |
306 |
break; |
307 |
} |
308 |
} |
309 |
} |