use of org.eclipse.wst.server.ui.internal.wizard.TaskWizard in project eclipse-integration-commons by spring-projects.
the class ServerConfigurator method installServer.
public ServerHandler installServer(final ServerDescriptor descriptor, File installLocation, IOverwriteQuery query, IProgressMonitor monitor) throws CoreException {
try {
SubMonitor progress = SubMonitor.convert(monitor);
progress.beginTask(NLS.bind("Installing Runtime {0}", descriptor.getRuntimeName()), 100);
File serverLocation = getLocation(descriptor);
if (serverLocation == null) {
final boolean[] response = new boolean[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
response[0] = MessageDialog.openQuestion(UiUtil.getShell(), "Install Runtime", NLS.bind("No local installation of {0} found. Proceed with download?", descriptor.getServerName()));
}
});
if (!response[0]) {
throw new OperationCanceledException();
}
InstallableRuntime2 ir = new ServerDescriptorInstaller(descriptor);
// prompt license if necessary
if (ir.getLicenseURL() != null) {
progress.subTask("Downloading license");
try {
final boolean[] result = new boolean[1];
final String license = ir.getLicense(progress.newChild(20));
Display.getDefault().syncExec(new Runnable() {
public void run() {
TaskModel taskModel = new TaskModel();
taskModel.putObject(LicenseWizardFragment.LICENSE, license);
TaskWizard wizard2 = new TaskWizard("License", new WizardFragment() {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void createChildFragments(List list) {
list.add(new LicenseWizardFragment());
}
}, taskModel);
WizardDialog dialog2 = new WizardDialog(UiUtil.getShell(), wizard2);
result[0] = (dialog2.open() == Window.OK);
}
});
if (!result[0]) {
// user did not agree to license
throw new OperationCanceledException();
}
} catch (CoreException e) {
StatusHandler.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error getting license", e));
}
}
progress.setWorkRemaining(80);
// schedule download job
serverLocation = new File(installLocation, descriptor.getInstallPath());
monitor.subTask(NLS.bind("Downloading runtime to {0}", serverLocation.getAbsolutePath()));
File archiveFile = File.createTempFile("runtime", null);
archiveFile.deleteOnExit();
HttpUtil.download(descriptor.getArchiveUrl(), archiveFile, serverLocation, descriptor.getArchivePath(), progress.newChild(70));
// Path path = new Path(location.getAbsolutePath());
// ir.install(path, new SubProgressMonitor(monitor, 70));
}
// create wtp runtime
progress.setWorkRemaining(10);
monitor.subTask(NLS.bind("Creating server {0}", descriptor.getServerName()));
ServerHandler serverHandler = new ServerHandler(descriptor, serverLocation);
serverHandler.createServer(progress.newChild(10), query, descriptor.getCallback());
return serverHandler;
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Installing runtime failed", e));
} finally {
monitor.done();
}
}
use of org.eclipse.wst.server.ui.internal.wizard.TaskWizard in project webtools.servertools by eclipse.
the class TaskWizardTestCase method getTaskWizard.
protected TaskWizard getTaskWizard() {
if (wizard == null) {
wizard = new TaskWizard("title", null);
// Ensure pages are not null
wizard.addPages();
}
return wizard;
}
use of org.eclipse.wst.server.ui.internal.wizard.TaskWizard in project webtools.servertools by eclipse.
the class OverviewEditorPart method showWizard.
protected int showWizard(final IRuntimeWorkingCopy runtimeWorkingCopy) {
String title = Messages.wizEditRuntimeWizardTitle;
final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId());
if (fragment2 == null)
return Window.CANCEL;
TaskModel taskModel = new TaskModel();
taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
WizardFragment fragment = new WizardFragment() {
protected void createChildFragments(List<WizardFragment> list) {
list.add(fragment2);
list.add(WizardTaskUtil.SaveRuntimeFragment);
}
};
TaskWizard wizard = new TaskWizard(title, fragment, taskModel);
wizard.setForcePreviousAndNextButtons(true);
WizardDialog dialog = new WizardDialog(getEditorSite().getShell(), wizard);
return dialog.open();
}
use of org.eclipse.wst.server.ui.internal.wizard.TaskWizard in project webtools.servertools by eclipse.
the class NewManualServerComposite method showRuntimeWizard.
protected int showRuntimeWizard(IServerType serverType) {
WizardFragment fragment = null;
TaskModel taskModel = new TaskModel();
IRuntimeType runtimeType = serverType.getRuntimeType();
final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeType.getId());
if (fragment2 == null)
return Window.CANCEL;
try {
IRuntimeWorkingCopy runtimeWorkingCopy = runtimeType.createRuntime(null, null);
taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
} catch (CoreException ce) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error creating runtime", ce);
}
return Window.CANCEL;
}
fragment = new WizardFragment() {
protected void createChildFragments(List<WizardFragment> list) {
list.add(fragment2);
list.add(WizardTaskUtil.SaveRuntimeFragment);
}
};
TaskWizard wizard2 = new TaskWizard(Messages.wizNewRuntimeWizardTitle, fragment, taskModel);
wizard2.setForcePreviousAndNextButtons(true);
WizardDialog dialog = new WizardDialog(getShell(), wizard2);
int returnValue = dialog.open();
if (returnValue != Window.CANCEL) {
updateRuntimeCombo(serverType);
IRuntime rt = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME);
if (rt != null && rt.getName() != null && runtimeCombo.indexOf(rt.getName()) != -1) {
setRuntime(rt);
runtimeCombo.select(runtimeCombo.indexOf(rt.getName()));
}
}
return returnValue;
}
use of org.eclipse.wst.server.ui.internal.wizard.TaskWizard in project jbosstools-openshift by jbosstools.
the class LaunchCDKServerHandler method showNewServerWizard.
/**
* Open the new server wizard.
*
* @param shell a shell
* @param serverTypeId a server runtime type, or null for any type
* @return <code>true</code> if a server was created, or
* <code>false</code> otherwise
*/
public static IServer showNewServerWizard(Shell shell, final String serverTypeId) {
WizardFragment fragment = new WizardFragment() {
@Override
protected void createChildFragments(List<WizardFragment> list) {
list.add(new NewServerWizardFragment(null, serverTypeId));
list.add(WizardTaskUtil.TempSaveRuntimeFragment);
list.add(WizardTaskUtil.TempSaveServerFragment);
list.add(new ModifyModulesWizardFragment());
list.add(new TasksWizardFragment());
list.add(WizardTaskUtil.SaveRuntimeFragment);
list.add(WizardTaskUtil.SaveServerFragment);
list.add(WizardTaskUtil.SaveHostnameFragment);
}
};
TaskWizard wizard = new TaskWizard(Messages.wizNewServerWizardTitle, fragment);
wizard.setForcePreviousAndNextButtons(true);
WizardDialog dialog = new WizardDialog(shell, wizard);
int ret = (dialog.open());
if (ret == IDialogConstants.OK_ID) {
IServer server = (IServer) wizard.getTaskModel().getObject(TaskModel.TASK_SERVER);
return server;
}
return null;
}
Aggregations