|
Lines 27-50
Link Here
|
| 27 |
import org.eclipse.swt.widgets.DirectoryDialog; |
27 |
import org.eclipse.swt.widgets.DirectoryDialog; |
| 28 |
import org.eclipse.swt.widgets.Label; |
28 |
import org.eclipse.swt.widgets.Label; |
| 29 |
import org.eclipse.swt.widgets.Text; |
29 |
import org.eclipse.swt.widgets.Text; |
| 30 |
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Axis2LicenseDialog; |
30 |
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.ISoapServerDependency; |
| 31 |
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; |
31 |
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; |
| 32 |
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; |
32 |
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; |
|
|
33 |
import org.eclipse.tptp.wsdm.tooling.validation.util.internal.ValidationUtils; |
| 33 |
import org.eclipse.ui.IWorkbench; |
34 |
import org.eclipse.ui.IWorkbench; |
| 34 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
35 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
| 35 |
|
36 |
|
| 36 |
/** |
37 |
/** |
| 37 |
* The class is used to create the Preference page for the MRT Editor. |
38 |
* The class is used to create the Preference page for the Axis jars used in code generation. |
| 38 |
* It is used to set Axis2 Server Location. |
39 |
* It is used to set Axis2 Server Location. |
| 39 |
* |
40 |
* |
| 40 |
*/ |
41 |
*/ |
| 41 |
public class Axis2ServerLocationPreferencePage extends PreferencePage implements IWorkbenchPreferencePage |
42 |
public class Axis2ServerLocationPreferencePage extends PreferencePage implements IWorkbenchPreferencePage |
| 42 |
{ |
43 |
{ |
| 43 |
|
44 |
|
|
|
45 |
private Button _useBuiltInAxis2Button; |
| 46 |
|
| 44 |
private Text _serverLocation; |
47 |
private Text _serverLocation; |
| 45 |
|
48 |
|
| 46 |
private Button _browseButton; |
49 |
private Button _browseButton; |
| 47 |
|
50 |
|
|
|
51 |
private ISoapServerDependency _axisValidator; |
| 52 |
|
| 53 |
public static final String USE_BUILT_IN_AXIS2_PREFERENCE_KEY = "MRT_CODE_GEN.USE_BUILT_IN_AXIS2"; |
| 54 |
|
| 48 |
public static final String SERVER_LOCATION_PREFERENCE_KEY = "MRT_CODE_GEN.AXIS2_SERVER_LOCATION"; |
55 |
public static final String SERVER_LOCATION_PREFERENCE_KEY = "MRT_CODE_GEN.AXIS2_SERVER_LOCATION"; |
| 49 |
|
56 |
|
| 50 |
/** |
57 |
/** |
|
Lines 52-58
Link Here
|
| 52 |
*/ |
59 |
*/ |
| 53 |
public Axis2ServerLocationPreferencePage() |
60 |
public Axis2ServerLocationPreferencePage() |
| 54 |
{ |
61 |
{ |
| 55 |
init(); |
|
|
| 56 |
} |
62 |
} |
| 57 |
|
63 |
|
| 58 |
/** |
64 |
/** |
|
Lines 62-74
Link Here
|
| 62 |
public Axis2ServerLocationPreferencePage(String title) |
68 |
public Axis2ServerLocationPreferencePage(String title) |
| 63 |
{ |
69 |
{ |
| 64 |
super(title); |
70 |
super(title); |
| 65 |
init(); |
|
|
| 66 |
} |
71 |
} |
| 67 |
|
72 |
|
| 68 |
public Axis2ServerLocationPreferencePage(String title, ImageDescriptor image) |
73 |
public Axis2ServerLocationPreferencePage(String title, ImageDescriptor image) |
| 69 |
{ |
74 |
{ |
| 70 |
super(title, image); |
75 |
super(title, image); |
| 71 |
init(); |
|
|
| 72 |
} |
76 |
} |
| 73 |
|
77 |
|
| 74 |
protected Control createContents(Composite parent) |
78 |
protected Control createContents(Composite parent) |
|
Lines 76-107
Link Here
|
| 76 |
Composite composite = new Composite(parent, SWT.NONE); |
80 |
Composite composite = new Composite(parent, SWT.NONE); |
| 77 |
GridLayout layout = new GridLayout(); |
81 |
GridLayout layout = new GridLayout(); |
| 78 |
layout.numColumns = 2; |
82 |
layout.numColumns = 2; |
| 79 |
composite.setLayout(layout); |
83 |
composite.setLayout(layout); |
| 80 |
|
84 |
|
|
|
85 |
_useBuiltInAxis2Button = new Button(composite, SWT.CHECK); |
| 81 |
GridData data = new GridData(); |
86 |
GridData data = new GridData(); |
| 82 |
data.horizontalSpan = 2; |
87 |
data.horizontalSpan = 2; |
| 83 |
data.grabExcessHorizontalSpace = true; |
88 |
data.grabExcessHorizontalSpace = true; |
|
|
89 |
_useBuiltInAxis2Button.setLayoutData(data); |
| 90 |
_useBuiltInAxis2Button.setText(Messages.USE_BUILT_IN_AXIS2_LABEL); |
| 91 |
_useBuiltInAxis2Button.addSelectionListener(new SelectionAdapter() |
| 92 |
{ |
| 93 |
public void widgetSelected(SelectionEvent event) |
| 94 |
{ |
| 95 |
handleUseBuiltInAxis2Button(); |
| 96 |
} |
| 97 |
}); |
| 98 |
|
| 84 |
Label label = new Label(composite, SWT.NONE); |
99 |
Label label = new Label(composite, SWT.NONE); |
|
|
100 |
data = new GridData(); |
| 101 |
data.horizontalSpan = 2; |
| 102 |
data.grabExcessHorizontalSpace = true; |
| 85 |
label.setLayoutData(data); |
103 |
label.setLayoutData(data); |
| 86 |
String labelText = Messages.CODEGEN_PREF_SERVERLOC; |
104 |
String labelText = Messages.CODEGEN_PREF_SERVERLOC; |
| 87 |
label.setText(labelText); |
105 |
label.setText(labelText); |
| 88 |
|
106 |
|
| 89 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
107 |
_serverLocation = new Text(composite, SWT.BORDER); |
| 90 |
String ss = store.getString(SERVER_LOCATION_PREFERENCE_KEY); |
|
|
| 91 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
108 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
| 92 |
data.grabExcessHorizontalSpace = true; |
109 |
data.grabExcessHorizontalSpace = true; |
| 93 |
data.horizontalSpan = 1; |
110 |
data.horizontalSpan = 1; |
| 94 |
data.widthHint = 240; |
111 |
data.widthHint = 240; |
| 95 |
|
|
|
| 96 |
_serverLocation = new Text(composite, SWT.BORDER); |
| 97 |
_serverLocation.setLayoutData(data); |
112 |
_serverLocation.setLayoutData(data); |
| 98 |
|
113 |
|
| 99 |
String runtime = ""; |
|
|
| 100 |
if (runtime != null || runtime.length() > 0) |
| 101 |
_serverLocation.setText(ss); |
| 102 |
else |
| 103 |
_serverLocation.setText(""); |
| 104 |
|
| 105 |
_browseButton = new Button(composite, SWT.PUSH); |
114 |
_browseButton = new Button(composite, SWT.PUSH); |
| 106 |
_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5); |
115 |
_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5); |
| 107 |
_browseButton.addSelectionListener(new SelectionAdapter() |
116 |
_browseButton.addSelectionListener(new SelectionAdapter() |
|
Lines 110-121
Link Here
|
| 110 |
{ |
119 |
{ |
| 111 |
handleLocationBrowseButtonPressed(); |
120 |
handleLocationBrowseButtonPressed(); |
| 112 |
} |
121 |
} |
| 113 |
}); |
122 |
}); |
|
|
123 |
|
| 124 |
initializeControls(); |
| 125 |
|
| 114 |
return composite; |
126 |
return composite; |
| 115 |
} |
127 |
} |
|
|
128 |
|
| 129 |
private void initializeControls() |
| 130 |
{ |
| 131 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
| 132 |
boolean useBuiltInAxis2 = store.getBoolean(USE_BUILT_IN_AXIS2_PREFERENCE_KEY); |
| 133 |
_useBuiltInAxis2Button.setSelection(useBuiltInAxis2); |
| 134 |
_serverLocation.setEnabled(!useBuiltInAxis2); |
| 135 |
_browseButton.setEnabled(!useBuiltInAxis2); |
| 136 |
|
| 137 |
String runtime = store.getString(SERVER_LOCATION_PREFERENCE_KEY); |
| 138 |
if (runtime != null || runtime.length() > 0) |
| 139 |
{ |
| 140 |
_serverLocation.setText(runtime); |
| 141 |
if(!useBuiltInAxis2) |
| 142 |
{ |
| 143 |
String errorMessage = _axisValidator.validateSoapServerHome(runtime); |
| 144 |
setErrorMessage(errorMessage); |
| 145 |
} |
| 146 |
} |
| 147 |
else |
| 148 |
_serverLocation.setText(""); |
| 149 |
} |
| 116 |
|
150 |
|
| 117 |
public void init(IWorkbench workbench) |
151 |
public void init(IWorkbench workbench) |
| 118 |
{ |
152 |
{ |
|
|
153 |
_axisValidator = ValidationUtils.getAllAxisValidators()[0]; |
| 154 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
| 155 |
store.setDefault(SERVER_LOCATION_PREFERENCE_KEY,""); |
| 156 |
store.setDefault(USE_BUILT_IN_AXIS2_PREFERENCE_KEY, true); |
| 157 |
} |
| 158 |
|
| 159 |
private void handleUseBuiltInAxis2Button() |
| 160 |
{ |
| 161 |
boolean useBuiltInAxis2 = _useBuiltInAxis2Button.getSelection(); |
| 162 |
_serverLocation.setEnabled(!useBuiltInAxis2); |
| 163 |
_browseButton.setEnabled(!useBuiltInAxis2); |
| 164 |
if(useBuiltInAxis2) |
| 165 |
setErrorMessage(null); |
| 166 |
else |
| 167 |
setErrorMessage(_axisValidator.validateSoapServerHome(_serverLocation.getText())); |
| 119 |
} |
168 |
} |
| 120 |
|
169 |
|
| 121 |
private void handleLocationBrowseButtonPressed() |
170 |
private void handleLocationBrowseButtonPressed() |
|
Lines 126-174
Link Here
|
| 126 |
selectedDirectory = dialog.open(); |
175 |
selectedDirectory = dialog.open(); |
| 127 |
|
176 |
|
| 128 |
if (selectedDirectory != null) |
177 |
if (selectedDirectory != null) |
| 129 |
_serverLocation.setText(TextProcessor.process(selectedDirectory)); |
178 |
{ |
|
|
179 |
String selectedPath = TextProcessor.process(selectedDirectory); |
| 180 |
_serverLocation.setText(selectedPath); |
| 181 |
setErrorMessage(_axisValidator.validateSoapServerHome(selectedPath)); |
| 182 |
} |
| 183 |
|
| 130 |
} |
184 |
} |
| 131 |
|
185 |
|
| 132 |
protected void performDefaults() |
186 |
protected void performDefaults() |
| 133 |
{ |
187 |
{ |
| 134 |
super.performDefaults(); |
188 |
super.performDefaults(); |
| 135 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
189 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
| 136 |
String defaultValue = store.getDefaultString(SERVER_LOCATION_PREFERENCE_KEY); |
190 |
boolean useBuiltInAxis2 = store.getDefaultBoolean(USE_BUILT_IN_AXIS2_PREFERENCE_KEY); |
| 137 |
_serverLocation.setText(defaultValue); |
191 |
String runtime = store.getDefaultString(SERVER_LOCATION_PREFERENCE_KEY); |
|
|
192 |
_serverLocation.setText(runtime); |
| 193 |
_useBuiltInAxis2Button.setSelection(useBuiltInAxis2); |
| 194 |
_serverLocation.setEnabled(!useBuiltInAxis2); |
| 195 |
_browseButton.setEnabled(!useBuiltInAxis2); |
| 196 |
setErrorMessage(null); |
| 138 |
} |
197 |
} |
| 139 |
|
198 |
|
| 140 |
protected void performApply() |
199 |
protected void performApply() |
| 141 |
{ |
200 |
{ |
| 142 |
popupAxis2LicenseDialog(); |
201 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
|
|
202 |
boolean useBuiltInAxis2 = _useBuiltInAxis2Button.getSelection(); |
| 203 |
if(!useBuiltInAxis2) |
| 204 |
{ |
| 205 |
String errorMessage = validateAxisLocation(); |
| 206 |
setErrorMessage(errorMessage); |
| 207 |
if(errorMessage!=null) |
| 208 |
return; |
| 209 |
} |
| 210 |
|
| 211 |
store.setValue(USE_BUILT_IN_AXIS2_PREFERENCE_KEY, useBuiltInAxis2); |
| 212 |
store.setValue(SERVER_LOCATION_PREFERENCE_KEY, _serverLocation.getText()); |
| 143 |
} |
213 |
} |
| 144 |
|
214 |
|
| 145 |
public boolean performOk() |
215 |
public boolean performOk() |
| 146 |
{ |
216 |
{ |
| 147 |
popupAxis2LicenseDialog(); |
|
|
| 148 |
return true; |
| 149 |
} |
| 150 |
|
| 151 |
private void popupAxis2LicenseDialog() |
| 152 |
{ |
| 153 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
217 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
| 154 |
String oldLocation = store.getString(SERVER_LOCATION_PREFERENCE_KEY); |
218 |
boolean useBuiltInAxis2 = _useBuiltInAxis2Button.getSelection(); |
| 155 |
String newLocation = _serverLocation.getText(); |
219 |
|
| 156 |
if(newLocation == null || newLocation.equals("")) |
220 |
if(!useBuiltInAxis2) |
| 157 |
store.setValue(SERVER_LOCATION_PREFERENCE_KEY,_serverLocation.getText()); |
|
|
| 158 |
else |
| 159 |
{ |
221 |
{ |
| 160 |
if(!newLocation.equals(oldLocation)) |
222 |
String errorMessage = validateAxisLocation(); |
| 161 |
{ |
223 |
setErrorMessage(errorMessage); |
| 162 |
int result = new Axis2LicenseDialog().showWindow(); |
224 |
if(errorMessage!=null) |
| 163 |
if(result == Axis2LicenseDialog.AGREE) |
225 |
return false; |
| 164 |
store.setValue(SERVER_LOCATION_PREFERENCE_KEY,_serverLocation.getText()); |
|
|
| 165 |
} |
| 166 |
} |
226 |
} |
|
|
227 |
store.setValue(USE_BUILT_IN_AXIS2_PREFERENCE_KEY, useBuiltInAxis2); |
| 228 |
store.setValue(SERVER_LOCATION_PREFERENCE_KEY, _serverLocation.getText()); |
| 229 |
return true; |
| 167 |
} |
230 |
} |
| 168 |
|
231 |
|
| 169 |
private void init() |
232 |
private String validateAxisLocation() |
| 170 |
{ |
233 |
{ |
| 171 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
234 |
String newLocation = _serverLocation.getText(); |
| 172 |
store.setDefault(SERVER_LOCATION_PREFERENCE_KEY,""); |
235 |
return _axisValidator.validateSoapServerHome(newLocation); |
| 173 |
} |
236 |
} |
| 174 |
} |
237 |
} |