Search in sources :

Example 11 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class NewRuntimeComposite method refreshExtension.

public boolean refreshExtension() {
    if (!(serverType instanceof ServerTypeProxy))
        return true;
    final ServerTypeProxy finalServerType = (ServerTypeProxy) serverType;
    try {
        wizard.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                ErrorMessage errorMsg = Discovery.refreshExtension(finalServerType.getExtension(), finalServerType.getURI(), monitor);
                if (errorMsg != null) {
                    final ErrorMessage errorMsgFinal = errorMsg;
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            wizard.setMessage(errorMsgFinal.getErrorTitle(), IMessageProvider.ERROR);
                            WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getRuntimeType().getId());
                            if (fragment2 != null) {
                                TaskModel fragmentTaskModel = fragment2.getTaskModel();
                                fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE, errorMsgFinal.getErrorDescription());
                                fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.ERROR));
                            }
                            wizard.update();
                        }
                    });
                } else {
                    WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getRuntimeType().getId());
                    if (fragment2 != null) {
                        TaskModel fragmentTaskModel = fragment2.getTaskModel();
                        fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE, Discovery.getLicenseText(finalServerType.getExtension()));
                        fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.NONE));
                    }
                }
            }
        });
    } catch (InvocationTargetException e) {
        if (Trace.WARNING) {
            Trace.trace(Trace.STRING_WARNING, "Error refreshing extension", e);
        }
    } catch (InterruptedException e) {
        if (Trace.WARNING) {
            Trace.trace(Trace.STRING_WARNING, "Error refreshing extension", e);
        }
    }
    return true;
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ErrorMessage(org.eclipse.wst.server.discovery.ErrorMessage) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 12 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TaskWizardPage method setMessage.

public void setMessage(String message, int type) {
    if (type == IMessageProvider.ERROR && "".equals(message)) {
        message = null;
    }
    super.setMessage(message, type);
    WizardFragment frag = ((TaskWizard) getWizard()).getCurrentWizardFragment();
    if (!fragment.equals(frag))
        return;
    getContainer().updateButtons();
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment)

Example 13 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class NewServerWizardFragment method createChildFragments.

protected void createChildFragments(List<WizardFragment> list) {
    if (getTaskModel() == null)
        return;
    Byte b = getMode();
    if (b != null && b.byteValue() == MODE_MANUAL) {
        IServerAttributes server = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER);
        Object runtime = getTaskModel().getObject(TaskModel.TASK_RUNTIME);
        if (runtime != null && runtime instanceof IRuntimeWorkingCopy) {
            IServerType st = server == null ? null : server.getServerType();
            // It should be assumed that the optional runtime fragment is added by the adopter later
            if (st != null && st.requiresRuntime()) {
                WizardFragment sub = getWizardFragment(((IRuntime) runtime).getRuntimeType().getId());
                if (sub != null)
                    list.add(sub);
            }
        }
        if (server != null) {
            if (server.getServerType().hasServerConfiguration() && server instanceof ServerWorkingCopy && runtime instanceof IRuntime) {
                ServerWorkingCopy swc = (ServerWorkingCopy) server;
                IRuntime runtime1 = (IRuntime) runtime;
                if (runtime != null && runtime1.getLocation() != null && !runtime1.getLocation().isEmpty()) {
                    if (runtimeLocation == null || !runtimeLocation.equals(runtime1.getLocation()))
                        try {
                            swc.importRuntimeConfiguration(runtime1, null);
                        } catch (CoreException ce) {
                        // ignore
                        }
                    runtimeLocation = runtime1.getLocation();
                } else
                    runtimeLocation = null;
            }
            WizardFragment sub = getWizardFragment(server.getServerType().getId());
            if (sub != null) {
                list.add(sub);
            }
        }
    } else if (b != null && b.byteValue() == MODE_EXISTING) {
    /*if (comp != null) {
				IServer server = comp.getServer();
				if (server != null)
					list.add(new TasksWizardFragment());
			}*/
    }
}
Also used : ServerWorkingCopy(org.eclipse.wst.server.core.internal.ServerWorkingCopy) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) CoreException(org.eclipse.core.runtime.CoreException)

Example 14 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment 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();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) ServerHandler(org.springsource.ide.eclipse.commons.configurator.ServerHandler) IOException(java.io.IOException) InstallableRuntime2(org.eclipse.wst.server.core.internal.InstallableRuntime2) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard) CoreException(org.eclipse.core.runtime.CoreException) LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskModel(org.eclipse.wst.server.core.TaskModel)

Example 15 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment 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();
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) List(java.util.List) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard)

Aggregations

WizardFragment (org.eclipse.wst.server.ui.wizard.WizardFragment)22 WizardDialog (org.eclipse.jface.wizard.WizardDialog)9 TaskWizard (org.eclipse.wst.server.ui.internal.wizard.TaskWizard)9 LicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment)7 DownloadableAdapterLicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 List (java.util.List)5 CoreException (org.eclipse.core.runtime.CoreException)5 ArrayList (java.util.ArrayList)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 TaskModel (org.eclipse.wst.server.core.TaskModel)3 Job (org.eclipse.core.runtime.jobs.Job)2 File (java.io.File)1 IOException (java.io.IOException)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1