Search in sources :

Example 1 with RuntimeWorkingCopy

use of org.eclipse.wst.server.core.internal.RuntimeWorkingCopy 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)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)1 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)1 RuntimeTypeWithServerProxy (org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy)1 RuntimeWorkingCopy (org.eclipse.wst.server.core.internal.RuntimeWorkingCopy)1 ServerWorkingCopy (org.eclipse.wst.server.core.internal.ServerWorkingCopy)1 WizardFragment (org.eclipse.wst.server.ui.wizard.WizardFragment)1