|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007 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 |
* Balan Subramanian (bsubram@us.ibm.com) |
| 10 |
* IBM Corporation - initial API and implementation |
| 11 |
*******************************************************************************/ |
| 12 |
|
| 13 |
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; |
| 14 |
|
| 15 |
import java.util.HashMap; |
| 16 |
import java.util.Iterator; |
| 17 |
import java.util.Map; |
| 18 |
import java.util.prefs.Preferences; |
| 19 |
|
| 20 |
import org.apache.muse.tools.generator.analyzer.Analyzer; |
| 21 |
import org.apache.muse.tools.generator.projectizer.Projectizer; |
| 22 |
import org.apache.muse.tools.generator.synthesizer.Synthesizer; |
| 23 |
import org.eclipse.core.filesystem.URIUtil; |
| 24 |
import org.eclipse.core.resources.IProject; |
| 25 |
import org.eclipse.core.resources.IWorkspace; |
| 26 |
import org.eclipse.core.resources.IWorkspaceRoot; |
| 27 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 28 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 29 |
import org.eclipse.core.runtime.IExtension; |
| 30 |
import org.eclipse.core.runtime.IExtensionPoint; |
| 31 |
import org.eclipse.core.runtime.IExtensionRegistry; |
| 32 |
import org.eclipse.core.runtime.IPath; |
| 33 |
import org.eclipse.core.runtime.IStatus; |
| 34 |
import org.eclipse.core.runtime.Path; |
| 35 |
import org.eclipse.core.runtime.Platform; |
| 36 |
import org.eclipse.jface.dialogs.DialogPage; |
| 37 |
import org.eclipse.jface.preference.IPreferenceStore; |
| 38 |
import org.eclipse.jface.util.Util; |
| 39 |
import org.eclipse.jface.wizard.WizardPage; |
| 40 |
import org.eclipse.osgi.util.TextProcessor; |
| 41 |
import org.eclipse.swt.SWT; |
| 42 |
import org.eclipse.swt.events.ModifyEvent; |
| 43 |
import org.eclipse.swt.events.ModifyListener; |
| 44 |
import org.eclipse.swt.events.SelectionAdapter; |
| 45 |
import org.eclipse.swt.events.SelectionEvent; |
| 46 |
import org.eclipse.swt.layout.GridData; |
| 47 |
import org.eclipse.swt.layout.GridLayout; |
| 48 |
import org.eclipse.swt.widgets.Button; |
| 49 |
import org.eclipse.swt.widgets.Combo; |
| 50 |
import org.eclipse.swt.widgets.Composite; |
| 51 |
import org.eclipse.swt.widgets.DirectoryDialog; |
| 52 |
import org.eclipse.swt.widgets.Event; |
| 53 |
import org.eclipse.swt.widgets.Group; |
| 54 |
import org.eclipse.swt.widgets.Label; |
| 55 |
import org.eclipse.swt.widgets.Listener; |
| 56 |
import org.eclipse.swt.widgets.Text; |
| 57 |
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; |
| 58 |
import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.dialog.internal.MemoryComboBox; |
| 59 |
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; |
| 60 |
import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage; |
| 61 |
import org.eclipse.tptp.wsdm.tooling.util.internal.Validation; |
| 62 |
import org.eclipse.tptp.wsdm.tooling.validation.util.internal.ValidationUtils; |
| 63 |
|
| 64 |
/** |
| 65 |
* This wizard enables the use to specify the projectizer options and also the |
| 66 |
* runtime environment and general options |
| 67 |
*/ |
| 68 |
public class GenerationOptionsPage extends WizardPage |
| 69 |
{ |
| 70 |
private static final String PROJECT_MEMORY_COMBO_ID = "project_memory_combo"; |
| 71 |
|
| 72 |
private static final String EXT_PT = "codeGeneration"; |
| 73 |
|
| 74 |
private Button _overwriteButton; |
| 75 |
|
| 76 |
private Combo _projectNameField; |
| 77 |
|
| 78 |
private String _userPath = Util.ZERO_LENGTH_STRING;// IDEResourceInfoUtils.EMPTY_STRING; |
| 79 |
|
| 80 |
private Button _useDefaultsButton; |
| 81 |
|
| 82 |
private Label _locationLabel; |
| 83 |
|
| 84 |
private Text _locationPathField; |
| 85 |
|
| 86 |
private Button _browseButton; |
| 87 |
|
| 88 |
private IProject _existingProject; |
| 89 |
|
| 90 |
private Combo _projectizerCombo; |
| 91 |
|
| 92 |
private Button _persistExtraArtifactsButton; |
| 93 |
|
| 94 |
private Map _platformContainerMap = new HashMap(); |
| 95 |
|
| 96 |
private Combo _containerCombo; |
| 97 |
|
| 98 |
private Label _containerLabel; |
| 99 |
|
| 100 |
private Listener _containerComboListener = new Listener() { |
| 101 |
|
| 102 |
public void handleEvent(Event event) { |
| 103 |
dialogChanged(); |
| 104 |
} |
| 105 |
|
| 106 |
}; |
| 107 |
|
| 108 |
public GenerationOptionsPage() { |
| 109 |
super("wizardPage"); |
| 110 |
setTitle(Messages.HOOKUP_WIZARD_TXT1); |
| 111 |
setDescription(Messages.HOOKUP_WIZARD_TXT2); |
| 112 |
|
| 113 |
loadExtensionData(); |
| 114 |
setPageComplete(false); |
| 115 |
} |
| 116 |
|
| 117 |
private void loadExtensionData() { |
| 118 |
IExtensionRegistry er = Platform.getExtensionRegistry(); |
| 119 |
IExtensionPoint ep = er.getExtensionPoint(Activator.PLUGIN_ID, EXT_PT); |
| 120 |
IExtension[] extensions = ep.getExtensions(); |
| 121 |
|
| 122 |
for (int i = 0; i < extensions.length; i++) { |
| 123 |
IConfigurationElement[] elements = extensions[i].getConfigurationElements(); |
| 124 |
CodeGenerationData codeGenData = new CodeGenerationData(elements); |
| 125 |
updatePlatformContainerMap(codeGenData); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
private void updatePlatformContainerMap(CodeGenerationData codeGenData) { |
| 130 |
Map containerCodeGenDataMap = (Map) _platformContainerMap.get(codeGenData.getPlatform()); |
| 131 |
if(containerCodeGenDataMap == null) { |
| 132 |
// |
| 133 |
// handles the case of proxy which doesn't have a container |
| 134 |
// |
| 135 |
if(codeGenData.getContainer() == null) { |
| 136 |
containerCodeGenDataMap = new SingleValueMap(); |
| 137 |
} else { |
| 138 |
containerCodeGenDataMap = new HashMap(); |
| 139 |
} |
| 140 |
|
| 141 |
_platformContainerMap.put(codeGenData.getPlatform(), containerCodeGenDataMap); |
| 142 |
} |
| 143 |
|
| 144 |
// |
| 145 |
// if the platform was null then it means we're using a |
| 146 |
// singlevaluemap which doesn't look at the key ever |
| 147 |
// |
| 148 |
containerCodeGenDataMap.put(codeGenData.getContainer(), codeGenData); |
| 149 |
} |
| 150 |
|
| 151 |
public void createControl(Composite parent) { |
| 152 |
setControl(doLayout(parent)); |
| 153 |
} |
| 154 |
|
| 155 |
private Composite doLayout(Composite parent) { |
| 156 |
Composite container = new Composite(parent, SWT.NULL); |
| 157 |
container.setLayout(new GridLayout(2, false)); |
| 158 |
|
| 159 |
GridData data = new GridData(); |
| 160 |
data.horizontalAlignment = SWT.FILL; |
| 161 |
data.grabExcessHorizontalSpace = true; |
| 162 |
container.setLayoutData(data); |
| 163 |
|
| 164 |
createProjectInput(container); |
| 165 |
|
| 166 |
Composite composite = createProjectTypeGroup(container); |
| 167 |
|
| 168 |
data = new GridData(); |
| 169 |
data.grabExcessHorizontalSpace = true; |
| 170 |
data.horizontalAlignment = SWT.FILL; |
| 171 |
data.horizontalSpan = 2; |
| 172 |
composite.setLayoutData(data); |
| 173 |
|
| 174 |
composite = createProjectOptionsGroup(container); |
| 175 |
|
| 176 |
data = new GridData(); |
| 177 |
data.grabExcessHorizontalSpace = true; |
| 178 |
data.horizontalAlignment = SWT.FILL; |
| 179 |
data.horizontalSpan = 2; |
| 180 |
composite.setLayoutData(data); |
| 181 |
return container; |
| 182 |
} |
| 183 |
|
| 184 |
private void createProjectInput(Composite parent) { |
| 185 |
Label projectNameLabel = new Label(parent, SWT.NONE); |
| 186 |
projectNameLabel.setText(Messages.HOOKUP_WIZARD_TXT4); |
| 187 |
|
| 188 |
GridData data = new GridData(); |
| 189 |
data.horizontalAlignment = SWT.FILL; |
| 190 |
data.grabExcessHorizontalSpace = false; |
| 191 |
projectNameLabel.setLayoutData(data); |
| 192 |
|
| 193 |
_projectNameField = MemoryComboBox.createMemoryComboBox(parent, Preferences.userNodeForPackage(GenerationOptionsPage.class), PROJECT_MEMORY_COMBO_ID); |
| 194 |
|
| 195 |
data = new GridData(); |
| 196 |
data.horizontalAlignment = SWT.FILL; |
| 197 |
data.grabExcessHorizontalSpace = true; |
| 198 |
_projectNameField.setLayoutData(data); |
| 199 |
|
| 200 |
_projectNameField.addListener(SWT.Modify, nameModifyListener); |
| 201 |
} |
| 202 |
|
| 203 |
private Group createProjectTypeGroup(Composite parent) { |
| 204 |
Group page = new Group(parent, SWT.SHADOW_IN); |
| 205 |
page.setText("Code Generation Options"); |
| 206 |
page.setLayout(new GridLayout(2, false)); |
| 207 |
|
| 208 |
Label platformLabel = new Label(page, SWT.NONE); |
| 209 |
platformLabel.setText("Platform:");//TODO AME |
| 210 |
_projectizerCombo = makePlatformCombo(page); |
| 211 |
|
| 212 |
_containerLabel = new Label(page, SWT.NONE); |
| 213 |
_containerLabel.setText("Container:");//TODO AME |
| 214 |
_containerLabel.setEnabled(false); |
| 215 |
|
| 216 |
_containerCombo = makeContainerCombo(page); |
| 217 |
|
| 218 |
return page; |
| 219 |
} |
| 220 |
|
| 221 |
private Group createProjectOptionsGroup(Composite parent) { |
| 222 |
Group group = new Group(parent, SWT.SHADOW_IN); |
| 223 |
group.setText("Project Options"); |
| 224 |
group.setLayout(new GridLayout(3, false)); |
| 225 |
|
| 226 |
_useDefaultsButton = createDefaultsButton(group); |
| 227 |
|
| 228 |
GridData buttonData = new GridData(); |
| 229 |
buttonData.horizontalSpan = 3; |
| 230 |
_useDefaultsButton.setLayoutData(buttonData); |
| 231 |
|
| 232 |
createUserEntryArea(group, true); |
| 233 |
createCheckboxes(group); |
| 234 |
|
| 235 |
return group; |
| 236 |
} |
| 237 |
|
| 238 |
private Button createDefaultsButton(Composite parent) { |
| 239 |
Button button = new Button(parent, SWT.CHECK | SWT.RIGHT); |
| 240 |
button.setText(Messages.CODE_GEN_DEFAULT_LOCATION);// IDEWorkbenchMessages.ProjectLocationSelectionDialog_useDefaultLabel); |
| 241 |
button.setSelection(true); |
| 242 |
|
| 243 |
button.addSelectionListener(new SelectionAdapter() |
| 244 |
{ |
| 245 |
public void widgetSelected(SelectionEvent e) |
| 246 |
{ |
| 247 |
boolean useDefaults = _useDefaultsButton.getSelection(); |
| 248 |
|
| 249 |
if (!useDefaults) |
| 250 |
{ |
| 251 |
_userPath = _locationPathField.getText(); |
| 252 |
_locationPathField.setText(TextProcessor |
| 253 |
.process(getDefaultPathDisplayString())); |
| 254 |
} |
| 255 |
else |
| 256 |
{ |
| 257 |
_locationPathField |
| 258 |
.setText(TextProcessor.process(_userPath)); |
| 259 |
} |
| 260 |
setUserAreaEnabled(!useDefaults); |
| 261 |
} |
| 262 |
}); |
| 263 |
|
| 264 |
return button; |
| 265 |
} |
| 266 |
|
| 267 |
private void createCheckboxes(Composite parent) { |
| 268 |
GridData data = null; |
| 269 |
|
| 270 |
_overwriteButton = makeButton(parent, Messages.HOOKUP_WIZARD_TXT3, SWT.CHECK); |
| 271 |
|
| 272 |
data = new GridData(); |
| 273 |
data.horizontalSpan = 2; |
| 274 |
_overwriteButton.setLayoutData(data); |
| 275 |
|
| 276 |
_persistExtraArtifactsButton = makeButton(parent, Messages.HOOKUP_WIZARD_PERSIST, SWT.CHECK); |
| 277 |
|
| 278 |
data = new GridData(); |
| 279 |
data.horizontalSpan = 2; |
| 280 |
_persistExtraArtifactsButton.setLayoutData(data); |
| 281 |
} |
| 282 |
|
| 283 |
private Combo makeContainerCombo(Group page) { |
| 284 |
Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY); |
| 285 |
combo.setEnabled(false); |
| 286 |
|
| 287 |
combo.addListener(SWT.Modify, _containerComboListener); |
| 288 |
return combo; |
| 289 |
} |
| 290 |
|
| 291 |
private Combo makePlatformCombo(Group page) |
| 292 |
{ |
| 293 |
Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY); |
| 294 |
for(Iterator i=_platformContainerMap.keySet().iterator(); i.hasNext();) { |
| 295 |
combo.add(i.next().toString()); |
| 296 |
} |
| 297 |
combo.select(0); |
| 298 |
combo.addListener(SWT.Modify, comboChangeListener); |
| 299 |
|
| 300 |
return combo; |
| 301 |
} |
| 302 |
|
| 303 |
private void setUserAreaEnabled(boolean enabled) |
| 304 |
{ |
| 305 |
_locationLabel.setEnabled(enabled); |
| 306 |
_locationPathField.setEnabled(enabled); |
| 307 |
_browseButton.setEnabled(enabled); |
| 308 |
} |
| 309 |
|
| 310 |
private void createUserEntryArea(Composite composite, boolean defaultEnabled) |
| 311 |
{ |
| 312 |
GridData data = null; |
| 313 |
|
| 314 |
// location label |
| 315 |
_locationLabel = new Label(composite, SWT.NONE); |
| 316 |
_locationLabel.setText(Messages.HOOKUP_WIZARD_TXT6); |
| 317 |
|
| 318 |
// project location entry field |
| 319 |
_locationPathField = new Text(composite, SWT.BORDER); |
| 320 |
data = new GridData(GridData.FILL_HORIZONTAL); |
| 321 |
_locationPathField.setLayoutData(data); |
| 322 |
|
| 323 |
// browse button |
| 324 |
_browseButton = new Button(composite, SWT.PUSH); |
| 325 |
_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5); |
| 326 |
_browseButton.addSelectionListener(new SelectionAdapter() |
| 327 |
{ |
| 328 |
public void widgetSelected(SelectionEvent event) |
| 329 |
{ |
| 330 |
handleLocationBrowseButtonPressed(); |
| 331 |
} |
| 332 |
}); |
| 333 |
|
| 334 |
if (defaultEnabled) |
| 335 |
{ |
| 336 |
_locationPathField.setText(TextProcessor |
| 337 |
.process(getDefaultPathDisplayString())); |
| 338 |
} |
| 339 |
else |
| 340 |
{ |
| 341 |
if (_existingProject == null) |
| 342 |
{ |
| 343 |
_locationPathField.setText(Util.ZERO_LENGTH_STRING);// IDEResourceInfoUtils.EMPTY_STRING); |
| 344 |
} |
| 345 |
else |
| 346 |
{ |
| 347 |
_locationPathField.setText(TextProcessor |
| 348 |
.process(_existingProject.getLocation().toString())); |
| 349 |
} |
| 350 |
} |
| 351 |
|
| 352 |
_locationPathField.addModifyListener(new ModifyListener() |
| 353 |
{ |
| 354 |
public void modifyText(ModifyEvent e) |
| 355 |
{ |
| 356 |
setErrorMessage(checkValidLocation()); |
| 357 |
} |
| 358 |
}); |
| 359 |
|
| 360 |
setUserAreaEnabled(false); |
| 361 |
} |
| 362 |
|
| 363 |
public boolean isDefault() |
| 364 |
{ |
| 365 |
return _useDefaultsButton.getSelection(); |
| 366 |
} |
| 367 |
|
| 368 |
public String getProjectLocation() |
| 369 |
{ |
| 370 |
if(isDefault()) { |
| 371 |
return null; |
| 372 |
} |
| 373 |
|
| 374 |
String projectLocation = _locationPathField.getText(); |
| 375 |
return projectLocation.length() == 0?null:projectLocation; |
| 376 |
} |
| 377 |
|
| 378 |
public String checkValidLocation() |
| 379 |
{ |
| 380 |
|
| 381 |
if (isDefault()) |
| 382 |
{ |
| 383 |
return null; |
| 384 |
} |
| 385 |
|
| 386 |
String newPath = getProjectLocation(); |
| 387 |
if (newPath == null) |
| 388 |
{ |
| 389 |
return Messages.CODE_GEN_LOCATION_ERROR_; |
| 390 |
} |
| 391 |
|
| 392 |
if (_existingProject == null) |
| 393 |
{ |
| 394 |
IPath projectPath = new Path(newPath); |
| 395 |
if (Platform.getLocation().isPrefixOf(projectPath)) |
| 396 |
{ |
| 397 |
return Messages.NEW_PROJECT_CREATION_PAGE_DEFAULT_LOCATION_ERROR_; |
| 398 |
} |
| 399 |
|
| 400 |
} |
| 401 |
else |
| 402 |
{ |
| 403 |
|
| 404 |
IStatus locationStatus = _existingProject.getWorkspace() |
| 405 |
.validateProjectLocationURI(_existingProject, URIUtil.toURI(newPath)); |
| 406 |
|
| 407 |
if (!locationStatus.isOK()) |
| 408 |
{ |
| 409 |
return locationStatus.getMessage(); |
| 410 |
} |
| 411 |
|
| 412 |
java.net.URI projectPath = _existingProject.getLocationURI(); |
| 413 |
if (projectPath != null && URIUtil.equals(projectPath, URIUtil.toURI(newPath))) |
| 414 |
{ |
| 415 |
return Messages.CODE_GEN_LOCATION_ERROR_; |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
return null; |
| 420 |
} |
| 421 |
|
| 422 |
private String getDefaultPathDisplayString() |
| 423 |
{ |
| 424 |
|
| 425 |
java.net.URI defaultURI = null; |
| 426 |
if (_existingProject != null) |
| 427 |
{ |
| 428 |
defaultURI = _existingProject.getLocationURI(); |
| 429 |
} |
| 430 |
|
| 431 |
// Handle files specially. Assume a file if there is no project to query |
| 432 |
if (defaultURI == null || defaultURI.getScheme().equals("file")) |
| 433 |
{ |
| 434 |
return Platform.getLocation().append(_projectNameField.getText()) |
| 435 |
.toString(); |
| 436 |
} |
| 437 |
return defaultURI.toString(); |
| 438 |
|
| 439 |
} |
| 440 |
|
| 441 |
private String getPathFromLocationField() |
| 442 |
{ |
| 443 |
java.net.URI fieldURI; |
| 444 |
try |
| 445 |
{ |
| 446 |
fieldURI = new java.net.URI(_locationPathField.getText()); |
| 447 |
} |
| 448 |
catch (java.net.URISyntaxException e) |
| 449 |
{ |
| 450 |
return _locationPathField.getText(); |
| 451 |
} |
| 452 |
return fieldURI.getPath(); |
| 453 |
} |
| 454 |
|
| 455 |
private void updateLocationField(String selectedPath) |
| 456 |
{ |
| 457 |
_locationPathField.setText(TextProcessor.process(selectedPath)); |
| 458 |
} |
| 459 |
|
| 460 |
private void handleLocationBrowseButtonPressed() |
| 461 |
{ |
| 462 |
|
| 463 |
String selectedDirectory = null; |
| 464 |
String dirName = getPathFromLocationField(); |
| 465 |
|
| 466 |
DirectoryDialog dialog = new DirectoryDialog(_locationPathField |
| 467 |
.getShell()); |
| 468 |
dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);// IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel); |
| 469 |
dialog.setFilterPath(dirName); |
| 470 |
selectedDirectory = dialog.open(); |
| 471 |
|
| 472 |
if (selectedDirectory != null) |
| 473 |
updateLocationField(selectedDirectory); |
| 474 |
} |
| 475 |
|
| 476 |
private Listener nameModifyListener = new Listener() |
| 477 |
{ |
| 478 |
public void handleEvent(Event e) |
| 479 |
{ |
| 480 |
dialogChanged(); |
| 481 |
} |
| 482 |
}; |
| 483 |
|
| 484 |
private Listener comboChangeListener = new Listener() { |
| 485 |
public void handleEvent(Event e) { |
| 486 |
String platform = _projectizerCombo.getText(); |
| 487 |
|
| 488 |
Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform); |
| 489 |
_containerCombo.removeListener(SWT.Modify, _containerComboListener); |
| 490 |
_containerCombo.removeAll(); |
| 491 |
|
| 492 |
boolean hasContainers = containerCodeGenDataMap.size() != 0; |
| 493 |
|
| 494 |
if(hasContainers) { |
| 495 |
for(Iterator i=containerCodeGenDataMap.keySet().iterator(); i.hasNext();) { |
| 496 |
_containerCombo.add(i.next().toString()); |
| 497 |
} |
| 498 |
_containerCombo.select(0); |
| 499 |
} |
| 500 |
|
| 501 |
_containerCombo.addListener(SWT.Modify, _containerComboListener); |
| 502 |
_containerCombo.setEnabled(hasContainers); |
| 503 |
_containerLabel.setEnabled(hasContainers); |
| 504 |
|
| 505 |
dialogChanged(); |
| 506 |
} |
| 507 |
}; |
| 508 |
|
| 509 |
private TargetedFileList[] _filesToCopy; |
| 510 |
|
| 511 |
protected void dialogChanged() |
| 512 |
{ |
| 513 |
String prjName = getProjectName(); |
| 514 |
|
| 515 |
if (prjName.length() == 0) |
| 516 |
{ |
| 517 |
updateStatus(Messages.HOOKUP_WIZARD_ERROR_1); |
| 518 |
return; |
| 519 |
} |
| 520 |
|
| 521 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
| 522 |
IWorkspaceRoot root = workspace.getRoot(); |
| 523 |
|
| 524 |
IProject project = root.getProject(prjName); |
| 525 |
|
| 526 |
if (project != null && project.exists()) |
| 527 |
{ |
| 528 |
updateStatus(Messages.PROJECT_EXISTS_WARN_, DialogPage.WARNING); |
| 529 |
return; |
| 530 |
} |
| 531 |
|
| 532 |
if (!Validation.isQName(prjName)) |
| 533 |
{ |
| 534 |
updateStatus(Messages.HOOKUP_WIZARD_ERROR_2); |
| 535 |
return; |
| 536 |
} |
| 537 |
|
| 538 |
updateStatus(null, DialogPage.NONE); |
| 539 |
} |
| 540 |
|
| 541 |
private void updateStatus(String message) |
| 542 |
{ |
| 543 |
updateStatus(message, DialogPage.ERROR); |
| 544 |
} |
| 545 |
|
| 546 |
private void updateStatus(String message, int type) |
| 547 |
{ |
| 548 |
setMessage(message, type); |
| 549 |
setPageComplete(type != DialogPage.ERROR); |
| 550 |
} |
| 551 |
|
| 552 |
private Button makeButton(Composite parent, String title, int style) |
| 553 |
{ |
| 554 |
Button b = new Button(parent, style); |
| 555 |
b.setText(title); |
| 556 |
return b; |
| 557 |
} |
| 558 |
|
| 559 |
public boolean shouldPersistArtifacts() |
| 560 |
{ |
| 561 |
return _persistExtraArtifactsButton.getSelection(); |
| 562 |
} |
| 563 |
|
| 564 |
/** |
| 565 |
* Return the value of the output project |
| 566 |
* @return String |
| 567 |
*/ |
| 568 |
public String getProjectName() |
| 569 |
{ |
| 570 |
return _projectNameField.getText(); |
| 571 |
} |
| 572 |
|
| 573 |
/** |
| 574 |
* Returns if Overwrite button is enabled |
| 575 |
* @return boolean |
| 576 |
*/ |
| 577 |
public boolean canOverwrite() |
| 578 |
{ |
| 579 |
return _overwriteButton.getSelection(); |
| 580 |
} |
| 581 |
|
| 582 |
public CodeGenerationData getSelectedData() { |
| 583 |
String platform = _projectizerCombo.getText(); |
| 584 |
Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform); |
| 585 |
String container = _containerCombo.getText(); |
| 586 |
return (CodeGenerationData) containerCodeGenDataMap.get(container); |
| 587 |
} |
| 588 |
|
| 589 |
/** |
| 590 |
* Return the projectizer |
| 591 |
* @return {@link Projectizer} |
| 592 |
*/ |
| 593 |
public Projectizer getProjectizer() |
| 594 |
{ |
| 595 |
return getSelectedData().getProjectizer(); |
| 596 |
} |
| 597 |
|
| 598 |
/** |
| 599 |
* Return the synthesizer |
| 600 |
* @return {@link Synthesizer} |
| 601 |
*/ |
| 602 |
public Synthesizer getSynthesizer() |
| 603 |
{ |
| 604 |
return getSelectedData().getSynthesizer(); |
| 605 |
} |
| 606 |
|
| 607 |
/** |
| 608 |
* Return the analyzer |
| 609 |
* @return {@link Analyzer} |
| 610 |
*/ |
| 611 |
public Analyzer getAnalyzer() |
| 612 |
{ |
| 613 |
return getSelectedData().getAnalyzer(); |
| 614 |
} |
| 615 |
|
| 616 |
/** |
| 617 |
* Returns the base address |
| 618 |
* |
| 619 |
* @return String |
| 620 |
*/ |
| 621 |
public String getBaseAddress() |
| 622 |
{ |
| 623 |
String baseAddress = "http://localhost"; |
| 624 |
|
| 625 |
int port = getSelectedData().getServicePort(); |
| 626 |
if (port != 0) |
| 627 |
{ |
| 628 |
baseAddress += ":" + port; |
| 629 |
} |
| 630 |
|
| 631 |
baseAddress += "/" + getProjectName(); |
| 632 |
|
| 633 |
String servicePath = getSelectedData().getServicePath(); |
| 634 |
|
| 635 |
if (servicePath != null) |
| 636 |
{ |
| 637 |
baseAddress += servicePath; |
| 638 |
} |
| 639 |
|
| 640 |
return baseAddress; |
| 641 |
} |
| 642 |
|
| 643 |
public boolean canFlipToNextPage() { |
| 644 |
return isPageComplete() && isAxis2Project(); |
| 645 |
} |
| 646 |
public boolean isAxis2Project(){ |
| 647 |
String container = getSelectedData().getContainer(); |
| 648 |
return container != null && container.equals("Axis2"); |
| 649 |
} |
| 650 |
|
| 651 |
public void saveCombo() { |
| 652 |
MemoryComboBox.save(_projectNameField, PROJECT_MEMORY_COMBO_ID, Preferences.userNodeForPackage(GenerationOptionsPage.class)); |
| 653 |
} |
| 654 |
|
| 655 |
private String validateLocation() |
| 656 |
{ |
| 657 |
String serverHome = getPreferenceServerLocation(); |
| 658 |
|
| 659 |
ISoapServerDependency axisValidators[] = ValidationUtils.getAllAxisValidators(); |
| 660 |
for(int i = 0 ; i < axisValidators.length ; i++){ |
| 661 |
|
| 662 |
ISoapServerDependency axis2Dependency = (Axis2ServerDependency)axisValidators[i]; |
| 663 |
String errorMessage = axis2Dependency.validateSoapServerHome(serverHome); |
| 664 |
if(errorMessage!=null) |
| 665 |
return errorMessage; |
| 666 |
_filesToCopy = axis2Dependency.getFilesToCopy(); |
| 667 |
if(_filesToCopy == null) |
| 668 |
_filesToCopy = new TargetedFileList[0]; |
| 669 |
} |
| 670 |
return null; |
| 671 |
} |
| 672 |
|
| 673 |
/** |
| 674 |
* Returns the Axis2 files to copied to generated code |
| 675 |
* @return |
| 676 |
*/ |
| 677 |
public TargetedFileList[] getAxis2FilesToCopy() |
| 678 |
{ |
| 679 |
validateLocation(); |
| 680 |
return _filesToCopy; |
| 681 |
} |
| 682 |
|
| 683 |
protected String getPreferenceServerLocation() |
| 684 |
{ |
| 685 |
IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); |
| 686 |
String location = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY).trim(); |
| 687 |
if(location != null && !location.equals("")) |
| 688 |
return location; |
| 689 |
return ""; |
| 690 |
} |
| 691 |
} |