if (_addDialog.getReturnCode() == Dialog.OK) {
// check if deployment already exists
if (WGADesignerPlugin.getDefault().getWGADeploymentManager().hasDeployment(_addDialog.getSymbolicName())) {
WorkbenchUtils.showErrorDialog(getShell(), "WGA deployment already exists.", "A WGA deployment with name '" + _addDialog.getSymbolicName() + "' already exists.");
} else {
IRunnableWithProgress runnable = null;
if (_addDialog.isDownloadRequested()) {
runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
TemporaryFile wgaWar = null;
try {
monitor.beginTask("Deploying wga", 100);
SubProgressMonitor downloadMonitor = new SubProgressMonitor(monitor, 90);
boolean isCustomDownloadLocation = false;
if (_addDialog.getLocation() != null && !_addDialog.getLocation().trim().equalsIgnoreCase("")) {
wgaWar = WGADesignerPlugin.getDefault().downloadWGA(downloadMonitor, _addDialog.getLocation());
isCustomDownloadLocation = true;
} else {
wgaWar = WGADesignerPlugin.getDefault().downloadCurrentWGARelease(downloadMonitor);
}
if (!monitor.isCanceled()) {
SubProgressMonitor deployMonitor = new SubProgressMonitor(monitor, 10);
WGADeployment deployment = WGADesignerPlugin.getDefault().getWGADeploymentManager().createDeployment(_addDialog.getSymbolicName(), wgaWar.getFile(), deployMonitor);
if (deployment != null && isCustomDownloadLocation) {
deployment.setUpdateURL(_addDialog.getLocation());
}
}
} catch (Exception e) {
throw new InterruptedException(e.getMessage());
} finally {
if (wgaWar != null) {
wgaWar.delete();
}
monitor.done();
}
}
};
} else {
final File wgaWar = new File(_addDialog.getLocation());
runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
WGADesignerPlugin.getDefault().getWGADeploymentManager().createDeployment(_addDialog.getSymbolicName(), wgaWar, monitor);
} catch (Exception e) {
throw new InterruptedException(e.getMessage());