Search in sources :

Example 16 with WizardFragment

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

the class TaskWizard method performCancel.

/**
 * Cancel the client selection.
 *
 * @return boolean
 */
public boolean performCancel() {
    final List list = getAllWizardFragments();
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                Iterator iterator = list.iterator();
                while (iterator.hasNext()) executeTask((WizardFragment) iterator.next(), CANCEL, monitor);
            } catch (CoreException ce) {
                throw new InvocationTargetException(ce);
            }
        }
    };
    Throwable t = null;
    try {
        if (getContainer() != null)
            getContainer().run(true, true, runnable);
        else
            runnable.run(new NullProgressMonitor());
        return true;
    } catch (InvocationTargetException te) {
        t = te.getCause();
    } catch (Exception e) {
        t = e;
    }
    if (Trace.SEVERE) {
        Trace.trace(Trace.STRING_SEVERE, "Error cancelling task wizard", t);
    }
    if (t instanceof CoreException) {
        EclipseUtil.openError(t.getLocalizedMessage(), ((CoreException) t).getStatus());
    } else
        EclipseUtil.openError(t.getLocalizedMessage());
    return false;
}
Also used : DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 17 with WizardFragment

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

the class NewRuntimeWizardFragment method createChildFragments.

protected void createChildFragments(List<WizardFragment> list) {
    if (getTaskModel() == null)
        return;
    Object runtime = getTaskModel().getObject(TaskModel.TASK_RUNTIME);
    if (runtime == null)
        return;
    WizardFragment sub = null;
    if (runtime instanceof IRuntimeWorkingCopy)
        sub = getWizardFragment(((RuntimeWorkingCopy) runtime).getRuntimeType().getId());
    else if (runtime instanceof RuntimeTypeWithServerProxy)
        sub = getWizardFragment(((RuntimeTypeWithServerProxy) runtime).getId());
    if (sub != null)
        list.add(sub);
    Object serverObj = getTaskModel().getObject(TaskModel.TASK_SERVER);
    if (serverObj != null && serverObj instanceof IServerWorkingCopy) {
        IServerWorkingCopy server = (IServerWorkingCopy) serverObj;
        if (server.getServerType().hasServerConfiguration() && server instanceof ServerWorkingCopy) {
            ServerWorkingCopy swc = (ServerWorkingCopy) server;
            try {
                if (runtime instanceof IRuntimeWorkingCopy) {
                    RuntimeWorkingCopy runtimeWorkingCopy = (RuntimeWorkingCopy) runtime;
                    if (runtimeWorkingCopy.getLocation() != null && !runtimeWorkingCopy.getLocation().isEmpty())
                        swc.importRuntimeConfiguration(runtimeWorkingCopy, null);
                }
            } catch (CoreException ce) {
            // ignore
            }
        }
        list.add(new WizardFragment() {

            public void enter() {
                IRuntimeWorkingCopy runtime2 = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
                IServerWorkingCopy server2 = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
                server2.setRuntime(runtime2);
            }
        });
        sub = getWizardFragment(server.getServerType().getId());
        if (sub != null)
            list.add(sub);
        list.add(WizardTaskUtil.SaveServerFragment);
    }
}
Also used : RuntimeTypeWithServerProxy(org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy) ServerWorkingCopy(org.eclipse.wst.server.core.internal.ServerWorkingCopy) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) CoreException(org.eclipse.core.runtime.CoreException) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) RuntimeWorkingCopy(org.eclipse.wst.server.core.internal.RuntimeWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 18 with WizardFragment

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

the class NewManualServerComposite method refreshExtension.

public boolean refreshExtension() {
    if (!(oldServerType instanceof ServerTypeProxy))
        return true;
    final ServerTypeProxy finalServerType = (ServerTypeProxy) oldServerType;
    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() {
                            canProceed = false;
                            wizard.setMessage(errorMsgFinal.getErrorTitle(), IMessageProvider.ERROR);
                            WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getId());
                            if (fragment2 != null) {
                                TaskModel taskModel = fragment2.getTaskModel();
                                taskModel.putObject(LicenseWizardFragment.LICENSE, errorMsgFinal.getErrorDescription());
                                taskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.ERROR));
                            }
                            wizard.update();
                        }
                    });
                } else {
                    WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getId());
                    if (fragment2 != null) {
                        TaskModel taskModel = fragment2.getTaskModel();
                        taskModel.putObject(LicenseWizardFragment.LICENSE, Discovery.getLicenseText(finalServerType.getExtension()));
                        taskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.NONE));
                    }
                }
            }
        });
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return true;
}
Also used : LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) 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 19 with WizardFragment

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

the class NewManualServerComposite method showDownloadableServerWizard.

protected boolean showDownloadableServerWizard(ServerTypeProxy serverType, IProgressMonitor monitor) {
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            wizard.setMessage(Messages.downLoadableAdapterDescription, IMessageProvider.INFORMATION);
        }
    });
    WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(serverType.getId());
    if (fragment2 == null)
        return false;
    TaskModel taskModel = fragment2.getTaskModel();
    if (taskModel == null)
        taskModel = new TaskModel();
    taskModel.putObject(TaskModel.TASK_EXTENSION, serverType.getExtension());
    taskModel.putObject(TaskModel.TASK_RUNTIME, serverType.getRuntimeType());
    taskModel.putObject(TaskModel.TASK_SERVER, serverType);
    fragment2.setTaskModel(taskModel);
    return true;
}
Also used : LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment)

Example 20 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment 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;
}
Also used : LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) CoreException(org.eclipse.core.runtime.CoreException) 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