[143021] Integrate Select Client wizard into Run on Server
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
index 53351b7..bdeed0a 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
@@ -779,4 +779,78 @@
 		list.toArray(s);
 		return s;
 	}
+
+	/**
+	 * Returns the launchable clients for the given server and launchable
+	 * object.
+	 * 
+	 * @param server org.eclipse.wst.server.core.IServer
+	 * @param launchable
+	 * @param launchMode String
+	 * @return an array of clients
+	 */
+	public static IClient[] getClients(IServer server, Object launchable, String launchMode) {
+		if (server == null || launchable == null)
+			return new IClient[0];
+		
+		ArrayList list = new ArrayList(5);
+		IClient[] clients = ServerPlugin.getClients();
+		if (clients != null) {
+			int size = clients.length;
+			for (int i = 0; i < size; i++) {
+				Trace.trace(Trace.FINEST, "client= " + clients[i]);
+				if (clients[i].supports(server, launchable, launchMode))
+					list.add(clients[i]);
+			}
+		}
+		
+		IClient[] clients2 = new IClient[list.size()];
+		list.toArray(clients2);
+		return clients2;
+	}
+
+	public static Object[] getLaunchableAdapter(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
+		ILaunchableAdapter launchableAdapter = null;
+		Object launchable = null;
+		
+		ILaunchableAdapter[] adapters = ServerPlugin.getLaunchableAdapters();
+		if (adapters != null) {
+			int size2 = adapters.length;
+			IStatus lastStatus = null;
+			for (int j = 0; j < size2; j++) {
+				ILaunchableAdapter adapter = adapters[j];
+				try {
+					Object launchable2 = adapter.getLaunchable(server, moduleArtifact);
+					Trace.trace(Trace.FINEST, "adapter= " + adapter + ", launchable= " + launchable2);
+					if (launchable2 != null) {
+						launchableAdapter = adapter;
+						launchable = launchable2;
+					}
+				} catch (CoreException ce) {
+					lastStatus = ce.getStatus();
+				} catch (Exception e) {
+					Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
+				}
+			}
+			if (launchable == null && lastStatus != null)
+				throw new CoreException(lastStatus);
+		}
+		if (launchable == null) {
+			launchableAdapter = new ILaunchableAdapter() {
+				public String getId() {
+					return "org.eclipse.wst.server.ui.launchable.adapter.default";
+				}
+
+				public Object getLaunchable(IServer server3, IModuleArtifact moduleArtifact2) throws CoreException {
+					return "launchable";
+				}
+			};
+			try {
+				launchable = launchableAdapter.getLaunchable(server, moduleArtifact);
+			} catch (CoreException ce) {
+				// ignore
+			}
+		}
+		return new Object[] { launchableAdapter, launchable };
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
index 7ab2373..b824bcd 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
@@ -10,7 +10,6 @@
  **********************************************************************/
 package org.eclipse.wst.server.ui.internal.actions;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -57,7 +56,10 @@
 
 	protected static Map globalLaunchMode;
 
-	protected boolean tasksRun;
+	protected boolean tasksAndClientShown;
+
+	public ILaunchableAdapter launchableAdapter;
+	public IClient client;
 
 	/**
 	 * RunOnServerActionDelegate constructor comment.
@@ -125,7 +127,9 @@
 			}
 			server = wizard.getServer();
 			boolean preferred = wizard.isPreferredServer();
-			tasksRun = true;
+			tasksAndClientShown = true;
+			client = wizard.getSelectedClient();
+			launchableAdapter = wizard.getLaunchableAdapter();
 			
 			// set preferred server if requested
 			if (server != null && preferred) {
@@ -222,8 +226,10 @@
 		if (!ServerUIPlugin.saveEditors())
 			return;
 		
-		tasksRun = false;
+		tasksAndClientShown = false;
 		IServer server2 = null;
+		client = null;
+		launchableAdapter = null;
 		try {
 			IProgressMonitor monitor = new NullProgressMonitor();
 			server2 = getServer(module, launchMode2, moduleArtifact, monitor);
@@ -254,70 +260,23 @@
 		if (!ServerUIPlugin.promptIfDirty(shell, server))
 			return;
 		
-		if (!tasksRun) {
-			SelectTasksWizard wizard = new SelectTasksWizard(server);
-			wizard.addPages();
-			if (wizard.hasTasks() && wizard.hasOptionalTasks()) {
+		if (!tasksAndClientShown) {
+			RunOnServerWizard wizard = new RunOnServerWizard(server, launchMode2, moduleArtifact);
+			if (wizard.shouldAppear()) {
 				WizardDialog dialog = new WizardDialog(shell, wizard);
 				if (dialog.open() == Window.CANCEL)
 					return;
 			} else
 				wizard.performFinish();
+			client = wizard.getSelectedClient();
+			launchableAdapter = wizard.getLaunchableAdapter();
 		}
 		
 		Thread thread = new Thread("Run on Server") {
 			public void run() {
 				String launchMode = launchMode2;
 				
-				// get the launchable adapter and module object
-				ILaunchableAdapter launchableAdapter = null;
-				Object launchable = null;
-				ILaunchableAdapter[] adapters = ServerPlugin.getLaunchableAdapters();
-				if (adapters != null) {
-					int size2 = adapters.length;
-					IStatus lastStatus = null;
-					for (int j = 0; j < size2; j++) {
-						ILaunchableAdapter adapter = adapters[j];
-						try {
-							Object launchable2 = adapter.getLaunchable(server, moduleArtifact);
-							Trace.trace(Trace.FINEST, "adapter= " + adapter + ", launchable= " + launchable2);
-							if (launchable2 != null) {
-								launchableAdapter = adapter;
-								launchable = launchable2;
-							}
-						} catch (CoreException ce) {
-							lastStatus = ce.getStatus();
-						} catch (Exception e) {
-							Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
-						}
-					}
-					if (launchable == null && lastStatus != null) {
-						EclipseUtil.openError(null, lastStatus);
-						return;
-					}
-				}
-				if (launchable == null) {
-					launchableAdapter = new ILaunchableAdapter() {
-						public String getId() {
-							return "org.eclipse.wst.server.ui.launchable.adapter.default";
-						}
-
-						public Object getLaunchable(IServer server3, IModuleArtifact moduleArtifact2) throws CoreException {
-							return "launchable";
-						}
-					};
-					try {
-						launchable = launchableAdapter.getLaunchable(server, moduleArtifact);
-					} catch (CoreException ce) {
-						// ignore
-					}
-				}
-				
-				IClient[] clients = getClients(server, launchable, launchMode);
-				Trace.trace(Trace.FINEST, "Launchable clients: " + clients.length);
-				
-				IClient client = null;
-				if (clients == null || clients.length == 0) {
+				if (client == null) {
 					// if there is no client, use a dummy
 					client = new IClient() {
 						public String getDescription() {
@@ -340,19 +299,6 @@
 							return true;
 						}
 					};
-				} else if (clients.length == 1) {
-					client = clients[0];
-				} else {
-					SelectClientWizard wizard = new SelectClientWizard(clients);
-					final ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard);
-					shell.getDisplay().syncExec(new Runnable() {
-						public void run() {
-							dialog.open();
-						}
-					});
-					client = wizard.getSelectedClient();
-					if (client == null)
-						return;
 				}
 				
 				Trace.trace(Trace.FINEST, "Ready to launch");
@@ -464,32 +410,6 @@
 	}
 
 	/**
-	 * Returns the launchable clients for the given server and launchable
-	 * object.
-	 * 
-	 * @param server org.eclipse.wst.server.core.IServer
-	 * @param launchable
-	 * @param launchMode String
-	 * @return an array of clients
-	 */
-	public static IClient[] getClients(IServer server, Object launchable, String launchMode) {
-		ArrayList list = new ArrayList(5);
-		IClient[] clients = ServerPlugin.getClients();
-		if (clients != null) {
-			int size = clients.length;
-			for (int i = 0; i < size; i++) {
-				Trace.trace(Trace.FINEST, "client= " + clients[i]);
-				if (clients[i].supports(server, launchable, launchMode))
-					list.add(clients[i]);
-			}
-		}
-		
-		IClient[] clients2 = new IClient[list.size()];
-		list.toArray(clients2);
-		return clients2;
-	}
-
-	/**
 	 * Open an options dialog.
 	 * 
 	 * @param shell
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java
index 08b930f..258f863 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java
@@ -26,10 +26,10 @@
 	static class ModifyModulesWizard2 extends WizardFragment {
 		protected void createChildFragments(List list) {
 			list.add(new ModifyModulesWizardFragment());
+			list.add(WizardTaskUtil.SaveServerFragment);
+			
 			list.add(new WizardFragment() {
 				public void performFinish(IProgressMonitor monitor) throws CoreException {
-					WizardTaskUtil.saveServer(getTaskModel(), monitor);
-					
 					IServerAttributes svr = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER);
 					if (svr instanceof IServer) {
 						IServer server = (IServer) svr;
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java
index 04a2249..7e5da64 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -12,8 +12,6 @@
 
 import java.util.List;
 
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.wst.server.ui.internal.Messages;
 import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment;
@@ -31,11 +29,7 @@
 		super(Messages.wizNewRuntimeWizardTitle, new WizardFragment() {
 			protected void createChildFragments(List list) {
 				list.add(new NewRuntimeWizardFragment());
-				list.add(new WizardFragment() {
-					public void performFinish(IProgressMonitor monitor) throws CoreException {
-						WizardTaskUtil.saveRuntime(getTaskModel(), monitor);
-					}
-				});
+				list.add(WizardTaskUtil.SaveRuntimeFragment);
 			}
 		});
 
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java
index ce8be44..59c833c 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -12,14 +12,10 @@
 
 import java.util.List;
 
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
-import org.eclipse.wst.server.core.IServerAttributes;
 import org.eclipse.wst.server.core.TaskModel;
 import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
 import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment;
 import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment;
 import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment;
@@ -41,26 +37,16 @@
 		super(Messages.wizNewServerWizardTitle, new WizardFragment() {
 			protected void createChildFragments(List list) {
 				list.add(new NewServerWizardFragment());
-				list.add(new WizardFragment() {
-					public void performFinish(IProgressMonitor monitor) throws CoreException {
-						WizardTaskUtil.tempSaveRuntime(getTaskModel(), monitor);
-						WizardTaskUtil.tempSaveServer(getTaskModel(), monitor);
-					}
-				});
+
+				list.add(WizardTaskUtil.TempSaveRuntimeFragment);
+				list.add(WizardTaskUtil.TempSaveServerFragment);
+				
 				list.add(new ModifyModulesWizardFragment());
 				list.add(new TasksWizardFragment());
-				list.add(new WizardFragment() {
-					public void performFinish(IProgressMonitor monitor) throws CoreException {
-						WizardTaskUtil.saveRuntime(getTaskModel(), monitor);
-						WizardTaskUtil.saveServer(getTaskModel(), monitor);
-						try {
-							IServerAttributes server = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER);
-							ServerUIPlugin.getPreferences().addHostname(server.getHost());
-						} catch (Exception e) {
-							// ignore
-						}
-					}
-				});
+				
+				list.add(WizardTaskUtil.SaveRuntimeFragment);
+				list.add(WizardTaskUtil.SaveServerFragment);
+				list.add(WizardTaskUtil.SaveHostnameFragment);
 			}
 		});
 		
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java
index 8557d3e..7801f41 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java
@@ -10,35 +10,19 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.wizard;
 
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IModuleArtifact;
 import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerAttributes;
 import org.eclipse.wst.server.core.TaskModel;
 import org.eclipse.wst.server.core.internal.IClient;
+import org.eclipse.wst.server.core.internal.ILaunchableAdapter;
 import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.OptionalClientWizardFragment;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.RunOnServerWizardFragment;
 /**
- * A wizard used to select a server from various lists.
+ * A wizard used for Run on Server.
  */
 public class RunOnServerWizard extends TaskWizard {
-	protected static NewServerWizardFragment task;
-	protected static OptionalClientWizardFragment fragment;
-
-	public RunOnServerWizard(IModule module, String launchMode) {
-		this(module, launchMode, null);
-	}
-
 	/**
 	 * RunOnServerWizard constructor comment.
 	 * 
@@ -46,66 +30,128 @@
 	 * @param launchMode a launch mode
 	 * @param moduleArtifact a module artifact
 	 */
-	public RunOnServerWizard(final IModule module, final String launchMode, final IModuleArtifact moduleArtifact) {
-		super(Messages.wizRunOnServerTitle, new WizardFragment() {
-			protected void createChildFragments(List list) {
-				task = new NewServerWizardFragment(module, launchMode);
-				list.add(task);
-				list.add(new WizardFragment() {
-					public void performFinish(IProgressMonitor monitor) throws CoreException {
-						WizardTaskUtil.tempSaveRuntime(getTaskModel(), monitor);
-						WizardTaskUtil.tempSaveServer(getTaskModel(), monitor);
-					}
-				});
-				list.add(new ModifyModulesWizardFragment(module));
-				list.add(new TasksWizardFragment());
-				list.add(new WizardFragment() {
-					public void performFinish(IProgressMonitor monitor) throws CoreException {
-						WizardTaskUtil.saveRuntime(getTaskModel(), monitor);
-						WizardTaskUtil.saveServer(getTaskModel(), monitor);
-						try {
-							IServerAttributes server = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER);
-							ServerUIPlugin.getPreferences().addHostname(server.getHost());
-						} catch (Exception e) {
-							// ignore
-						}
-					}
-				});
-				//fragment = new OptionalClientWizardFragment(moduleArtifact, launchMode);
-				//list.add(fragment);
-			}
-		});
+	public RunOnServerWizard(IModule module, String launchMode, IModuleArtifact moduleArtifact) {
+		super(Messages.wizRunOnServerTitle, new RunOnServerWizardFragment(module, launchMode, moduleArtifact));
 		
 		setNeedsProgressMonitor(true);
 		if (ILaunchManager.DEBUG_MODE.equals(launchMode))
 			setWindowTitle(Messages.wizDebugOnServerTitle);
 		else if (ILaunchManager.PROFILE_MODE.equals(launchMode))
 			setWindowTitle(Messages.wizProfileOnServerTitle);
+		getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode);
+	}
+
+	/**
+	 * RunOnServerWizard constructor comment.
+	 * 
+	 * @param server a server
+	 * @param launchMode a launch mode
+	 * @param moduleArtifact a module artifact
+	 */
+	public RunOnServerWizard(IServer server, String launchMode, IModuleArtifact moduleArtifact) {
+		super(Messages.wizRunOnServerTitle, new RunOnServerWizardFragment(server, launchMode, moduleArtifact));
+		
+		setNeedsProgressMonitor(true);
+		if (ILaunchManager.DEBUG_MODE.equals(launchMode))
+			setWindowTitle(Messages.wizDebugOnServerTitle);
+		else if (ILaunchManager.PROFILE_MODE.equals(launchMode))
+			setWindowTitle(Messages.wizProfileOnServerTitle);
+		
+		getTaskModel().putObject(TaskModel.TASK_SERVER, server);
+		getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode);
+		addPages();
 	}
 
 	/**
 	 * Return the server.
+	 * 
 	 * @return the server
 	 */
 	public IServer getServer() {
 		try {
-			return (IServer) getRootFragment().getTaskModel().getObject(TaskModel.TASK_SERVER);
+			return (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
 		} catch (Exception e) {
 			return null;
 		}
 	}
 
+	/**
+	 * Return if the user wants to use the server as a default.
+	 * 
+	 * @return true if the server should be the default
+	 */
 	public boolean isPreferredServer() {
-		if (task == null)
+		try {
+			Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_DEFAULT_SERVER);
+			return b.booleanValue();
+		} catch (Exception e) {
 			return false;
-		return task.isPreferredServer();
+		}
 	}
 
 	/**
 	 * Return the selected client.
+	 * 
 	 * @return the client
 	 */
 	public IClient getSelectedClient() {
-		return fragment.getSelectedClient();
+		try {
+			return (IClient) getTaskModel().getObject(WizardTaskUtil.TASK_CLIENT);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	/**
+	 * Return the launchable adapter.
+	 * 
+	 * @return the adapter
+	 */
+	public ILaunchableAdapter getLaunchableAdapter() {
+		try {
+			return (ILaunchableAdapter) getTaskModel().getObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	/**
+	 * Returns true if this wizard should be shown to the user.
+	 * 
+	 * @return <code>true</code> if this wizard should be shown, and <code>false</code>
+	 *    otherwise
+	 */
+	public boolean shouldAppear() {
+		return getServer() == null || hasTasks() || hasClients();
+	}
+
+	/**
+	 * Return <code>true</code> if this wizard has tasks.
+	 * 
+	 * @return <code>true</code> if this wizard has tasks, and <code>false</code>
+	 *    otherwise
+	 */
+	protected boolean hasTasks() {
+		try {
+			Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_HAS_TASKS);
+			return b.booleanValue();
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+	/**
+	 * Return <code>true</code> if this wizard has multiple clients to show.
+	 * 
+	 * @return <code>true</code> if this wizard has multiple clients, and <code>false</code>
+	 *    otherwise
+	 */
+	protected boolean hasClients() {
+		try {
+			Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_HAS_CLIENTS);
+			return b.booleanValue();
+		} catch (Exception e) {
+			return false;
+		}
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/SelectClientWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/SelectClientWizard.java
deleted file mode 100644
index 4a2fb74..0000000
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/SelectClientWizard.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.wst.server.ui.internal.wizard;
-
-import java.util.List;
-
-import org.eclipse.wst.server.core.internal.IClient;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.SelectClientWizardFragment;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-/**
- * A wizard used to select a client from a list.
- */
-public class SelectClientWizard extends TaskWizard {
-	protected static SelectClientWizardFragment fragment;
-
-	/**
-	 * SelectClientWizard constructor comment.
-	 * 
-	 * @param clients an array of clients
-	 */
-	public SelectClientWizard(final IClient[] clients) {
-		super(Messages.wizSelectClientWizardTitle, new WizardFragment() {
-			protected void createChildFragments(List list) {
-				fragment = new SelectClientWizardFragment(clients);
-				list.add(fragment);
-			}
-		});
-		
-		setForcePreviousAndNextButtons(true);
-	}
-
-	/**
-	 * Return the selected client.
-	 * @return the client
-	 */
-	public IClient getSelectedClient() {
-		return fragment.getSelectedClient();
-	}
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/SelectTasksWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/SelectTasksWizard.java
deleted file mode 100644
index 47e0e85..0000000
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/SelectTasksWizard.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.server.ui.internal.wizard;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.TaskModel;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-/**
- * A wizard used to select server and module tasks.
- */
-public class SelectTasksWizard extends TaskWizard {
-	protected static TasksWizardFragment fragment;
-
-	/**
-	 * SelectTasksWizard constructor.
-	 * 
-	 * @param server a server
-	 */
-	public SelectTasksWizard(final IServer server) {
-		super(Messages.wizTaskWizardTitle, new WizardFragment() {
-			protected void createChildFragments(List list) {
-				fragment = new TasksWizardFragment();
-				list.add(fragment);
-				list.add(new WizardFragment() {
-					public void performFinish(IProgressMonitor monitor) throws CoreException {
-						WizardTaskUtil.saveServer(getTaskModel(), monitor);
-					}
-				});
-			}
-		});
-		getTaskModel().putObject(TaskModel.TASK_SERVER, server);
-		addPages();
-	}
-
-	/**
-	 * Return <code>true</code> if this wizard has tasks.
-	 * 
-	 * @return <code>true</code> if this wizard has tasks, and <code>false</code>
-	 *    otherwise
-	 */
-	public boolean hasTasks() {
-		return fragment.hasTasks();
-	}
-
-	/**
-	 * Return <code>true</code> if this wizard has optional tasks.
-	 * 
-	 * @return <code>true</code> if this wizard has optional tasks, and
-	 *    <code>false</code> otherwise
-	 */
-	public boolean hasOptionalTasks() {
-		return fragment.hasOptionalTasks();
-	}
-
-	/**
-	 * Return <code>true</code> if this wizard has preferred tasks.
-	 * 
-	 * @return <code>true</code> if this wizard has preferred tasks, and
-	 *    <code>false</code> otherwise
-	 */
-	public boolean hasPreferredTasks() {
-		return fragment.hasPreferredTasks();
-	}
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java
index dc29ca9..3a67199 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java
@@ -340,7 +340,7 @@
 						fragmentData.put(fragment, page2);
 						addPage(page2);
 					}
-				}	
+				}
 			}
 		} catch (Exception e) {
 			Trace.trace(Trace.SEVERE, "Error adding fragments to wizard", e);
@@ -348,7 +348,7 @@
 			addingPages = false;
 		}
 	}
-	
+
 	/*private static void updateWizardPages() {
 		try {
 			current.updatePages();
@@ -357,7 +357,7 @@
 			Trace.trace(Trace.SEVERE, "Error updating wizard pages", e);
 		}
 	}*/
-	
+
 	private TaskWizardPage getFragmentData(WizardFragment fragment) {
 		try {
 			TaskWizardPage page = (TaskWizardPage) fragmentData.get(fragment);
@@ -369,7 +369,7 @@
 		
 		return null;
 	}
-	
+
 	protected void updatePages() {
 		addPages();
 	}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java
index a794693..51cc1db 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java
@@ -31,6 +31,7 @@
 	protected WizardFragment fragment;
 	
 	protected boolean isEmptyError = false;
+	protected boolean isCreated = false;
 
 	public TaskWizardPage(WizardFragment fragment) {
 		super(fragment.toString());
@@ -55,6 +56,9 @@
 		//data.heightHint = convertVerticalDLUsToPixels(350);
 		comp.setLayoutData(data);
 		setControl(comp);
+		
+		isCreated = true;
+		update();
 	}
 
 	public boolean isPageComplete() {
@@ -115,6 +119,9 @@
 	}
 
 	public void update() {
+		if (!isCreated)
+			return;
+		
 		fragment.updateChildFragments();
 		((TaskWizard) getWizard()).updatePages();
 		
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java
index daf4955..6c74d59 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -21,15 +21,65 @@
 import org.eclipse.wst.server.core.internal.ServerPlugin;
 import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
 import org.eclipse.wst.server.ui.internal.EclipseUtil;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
 import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
 /**
  * 
  */
 public class WizardTaskUtil {
+	public static final String TASK_LAUNCHABLE_ADAPTER = "launchableAdapter";
+	public static final String TASK_LAUNCHABLE = "launchable";
+	public static final String TASK_CLIENT = "client";
+	public static final String TASK_CLIENTS = "clients";
+	public static final String TASK_DEFAULT_SERVER = "defaultServer";
+	public static final String TASK_MODE = "mode";
+	public static final String TASK_HAS_TASKS = "hasTasks";
+	public static final String TASK_HAS_CLIENTS = "hasClients";
+
+	public static final byte MODE_EXISTING = 0;
+	public static final byte MODE_DETECT = 1;
+	public static final byte MODE_MANUAL = 2;
+
+	public static final WizardFragment SaveRuntimeFragment = new WizardFragment() {
+		public void performFinish(IProgressMonitor monitor) throws CoreException {
+			WizardTaskUtil.saveRuntime(getTaskModel(), monitor);
+		}
+	};
+
+	public static final WizardFragment SaveServerFragment = new WizardFragment() {
+		public void performFinish(IProgressMonitor monitor) throws CoreException {
+			WizardTaskUtil.saveServer(getTaskModel(), monitor);
+		}
+	};
+
+	public static final WizardFragment TempSaveRuntimeFragment = new WizardFragment() {
+		public void performFinish(IProgressMonitor monitor) throws CoreException {
+			WizardTaskUtil.tempSaveRuntime(getTaskModel(), monitor);
+		}
+	};
+
+	public static final WizardFragment TempSaveServerFragment = new WizardFragment() {
+		public void performFinish(IProgressMonitor monitor) throws CoreException {
+			WizardTaskUtil.tempSaveServer(getTaskModel(), monitor);
+		}
+	};
+
+	public static final WizardFragment SaveHostnameFragment = new WizardFragment() {
+		public void performFinish(IProgressMonitor monitor) throws CoreException {
+			try {
+				IServerAttributes server2 = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER);
+				ServerUIPlugin.getPreferences().addHostname(server2.getHost());
+			} catch (Exception e) {
+				// ignore
+			}
+		}
+	};
+
 	private WizardTaskUtil() {
 		// do nothing
 	}
-	
+
 	public static void saveRuntime(TaskModel taskModel, IProgressMonitor monitor) throws CoreException {
 		IRuntime runtime = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME);
 		if (runtime != null && runtime instanceof IRuntimeWorkingCopy) {
@@ -62,7 +112,7 @@
 			}
 		}
 	}
-	
+
 	public static void tempSaveRuntime(TaskModel taskModel, IProgressMonitor monitor) throws CoreException {
 		IRuntime runtime = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME);
 		if (runtime != null && runtime instanceof IRuntimeWorkingCopy) {
@@ -74,7 +124,7 @@
 			taskModel.putObject(TaskModel.TASK_RUNTIME, runtime.createWorkingCopy());
 		}
 	}
-	
+
 	public static void tempSaveServer(TaskModel taskModel, IProgressMonitor monitor) throws CoreException {
 		IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER);
 		if (server != null && server instanceof IServerWorkingCopy) {
@@ -105,7 +155,7 @@
 			taskModel.putObject(TaskModel.TASK_SERVER, workingCopy);
 		}
 	}
-	
+
 	public static void addModule(IModule module, TaskModel taskModel, IProgressMonitor monitor) throws CoreException {
 		if (module == null)
 			return;
@@ -136,7 +186,7 @@
 		workingCopy.modifyModules(new IModule[] { parentModule }, new IModule[0], monitor);
 		taskModel.putObject(TaskModel.TASK_SERVER, workingCopy.save(false, monitor));
 	}
-	
+
 	public static void modifyModules(List add, List remove, TaskModel taskModel, IProgressMonitor monitor) throws CoreException {
 		if ((add == null || add.isEmpty()) && (remove == null || remove.isEmpty()))
 			return;
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
index 741d96f..c898f2b 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
@@ -24,19 +24,17 @@
  * 
  */
 public class NewRuntimeWizardFragment extends WizardFragment {
-	protected NewRuntimeComposite page;
-	
 	// filter by type/version
 	protected String type;
 	protected String version;
-	
+
 	// filter by partial runtime type id
 	protected String runtimeTypeId;
-	
+
 	public NewRuntimeWizardFragment() {
 		// do nothing
 	}
-	
+
 	public NewRuntimeWizardFragment(String type, String version, String runtimeTypeId) {
 		this.type = type;
 		this.version = version;
@@ -51,8 +49,7 @@
 	 * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage()
 	 */
 	public Composite createComposite(Composite parent, IWizardHandle wizard) {
-		page = new NewRuntimeComposite(parent, wizard, getTaskModel(), type, version, runtimeTypeId);
-		return page;
+		return new NewRuntimeComposite(parent, wizard, getTaskModel(), type, version, runtimeTypeId);
 	}
 
 	protected void createChildFragments(List list) {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java
index b56e557..63bfdc9 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java
@@ -20,6 +20,7 @@
 import org.eclipse.wst.server.core.*;
 import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
 import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.internal.wizard.page.NewServerComposite;
 import org.eclipse.wst.server.ui.wizard.WizardFragment;
 import org.eclipse.wst.server.ui.wizard.IWizardHandle;
@@ -27,14 +28,11 @@
  * 
  */
 public class NewServerWizardFragment extends WizardFragment {
-	public static final String MODE = "mode";
-	public static final byte MODE_EXISTING = 0;
-	public static final byte MODE_DETECT = 1;
-	public static final byte MODE_MANUAL= 2;
+	public static final byte MODE_EXISTING = WizardTaskUtil.MODE_EXISTING;
+	public static final byte MODE_DETECT = WizardTaskUtil.MODE_DETECT;
+	public static final byte MODE_MANUAL= WizardTaskUtil.MODE_MANUAL;
 
-	protected NewServerComposite comp;
 	protected IModule module;
-	protected String launchMode;
 
 	protected Map fragmentMap = new HashMap();
 	protected Map configMap = new HashMap();
@@ -43,9 +41,8 @@
 		// do nothing
 	}
 
-	public NewServerWizardFragment(IModule module, String launchMode) {
+	public NewServerWizardFragment(IModule module) {
 		this.module = module;
-		this.launchMode = launchMode;
 	}
 
 	public boolean hasComposite() {
@@ -54,14 +51,14 @@
 
 	public void enter() {
 		super.enter();
-		getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage()
 	 */
 	public Composite createComposite(Composite parent, IWizardHandle wizard) {
-		comp = new NewServerComposite(parent, wizard, module, launchMode);
+		String launchMode = (String) getTaskModel().getObject(TaskModel.TASK_LAUNCH_MODE);
+		NewServerComposite comp = new NewServerComposite(parent, wizard, module, launchMode);
 		if (getTaskModel() != null)
 			comp.setTaskModel(getTaskModel());
 		return comp;
@@ -92,7 +89,7 @@
 		if (getTaskModel() == null)
 			return;
 		
-		Byte b = (Byte) getTaskModel().getObject(MODE);
+		Byte b = (Byte) getTaskModel().getObject(WizardTaskUtil.TASK_MODE);
 		if (b != null && b.byteValue() == MODE_MANUAL) {
 			IRuntime runtime = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
 			if (runtime != null && runtime instanceof IRuntimeWorkingCopy) {
@@ -126,20 +123,14 @@
 	}
 
 	public boolean isComplete() {
-		if (comp == null)
-			return false;
-		return comp.getServer() != null; 
+		return getServer() != null; 
 	}
 
-	public IServerWorkingCopy getServer() {
-		if (comp == null)
+	private IServerWorkingCopy getServer() {
+		try {
+			return (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
+		} catch (Exception e) {
 			return null;
-		return comp.getServer();
-	}
-
-	public boolean isPreferredServer() {
-		if (comp == null)
-			return false;
-		return comp.isPreferredServer();
+		}
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java
index 53a1cfe..4f71c8a 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java
@@ -10,45 +10,40 @@
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.wizard.fragment;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.wst.server.core.IModuleArtifact;
 import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.TaskModel;
 import org.eclipse.wst.server.core.internal.IClient;
-import org.eclipse.wst.server.core.internal.ILaunchableAdapter;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
 import org.eclipse.wst.server.ui.internal.EclipseUtil;
-import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.wizard.WizardFragment;
 /**
  * A fragment used to select a client.
  */
 public class OptionalClientWizardFragment extends WizardFragment {
-	protected SelectClientWizardFragment fragment;
 	protected IClient[] clients;
-	protected String launchMode;
+
 	protected IModuleArtifact moduleArtifact;
 	protected IServer lastServer;
 
-	public OptionalClientWizardFragment(IModuleArtifact moduleArtifact, String launchMode) {
+	public OptionalClientWizardFragment(IModuleArtifact moduleArtifact) {
 		super();
-		this.launchMode = launchMode;
 		this.moduleArtifact = moduleArtifact;
 	}
 
 	protected void createChildFragments(List list) {
-		if (clients != null && clients.length > 1) {
-			fragment = new SelectClientWizardFragment(clients);
-			list.add(fragment);
-		} else
-			fragment = null;
+		if (clients != null && clients.length > 1)
+			list.add(new SelectClientWizardFragment());
 	}
 
 	protected void updateClients() {
+		if (getTaskModel() == null)
+			return;
+		
 		try {
 			IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
 			if (lastServer == null && server == null)
@@ -58,51 +53,33 @@
 			
 			lastServer = server;
 			
+			getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
+			getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
+			
 			// get the launchable adapter and module object
-			ILaunchableAdapter launchableAdapter = null;
 			Object launchable = null;
-			ILaunchableAdapter[] adapters = ServerPlugin.getLaunchableAdapters();
-			if (adapters != null) {
-				int size2 = adapters.length;
-				IStatus lastStatus = null;
-				for (int j = 0; j < size2; j++) {
-					ILaunchableAdapter adapter = adapters[j];
-					try {
-						Object launchable2 = adapter.getLaunchable(server, moduleArtifact);
-						Trace.trace(Trace.FINEST, "adapter= " + adapter + ", launchable= " + launchable2);
-						if (launchable2 != null) {
-							launchableAdapter = adapter;
-							launchable = launchable2;
-						}
-					} catch (CoreException ce) {
-						lastStatus = ce.getStatus();
-					} catch (Exception e) {
-						Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
-					}
-				}
-				if (launchable == null && lastStatus != null) {
-					EclipseUtil.openError(null, lastStatus);
-					return; // TODO
-				}
-			}
-			if (launchable == null) {
-				launchableAdapter = new ILaunchableAdapter() {
-					public String getId() {
-						return "org.eclipse.wst.server.ui.launchable.adapter.default";
-					}
-
-					public Object getLaunchable(IServer server3, IModuleArtifact moduleArtifact2) throws CoreException {
-						return "launchable";
-					}
-				};
-				try {
-					launchable = launchableAdapter.getLaunchable(server, moduleArtifact);
-				} catch (CoreException ce) {
-					// ignore
-				}
+			try {
+				Object[] obj = ServerUIPlugin.getLaunchableAdapter(server, moduleArtifact);
+				getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, obj[0]);
+				getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, obj[1]);
+				launchable = obj[1];
+			} catch (CoreException ce) {
+				getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null);
+				getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null);
+				EclipseUtil.openError(null, ce.getStatus());
 			}
 			
-			clients = getClients(server, launchable, launchMode);
+			String launchMode = (String) getTaskModel().getObject(TaskModel.TASK_LAUNCH_MODE);
+			clients = ServerUIPlugin.getClients(server, launchable, launchMode);
+			
+			if (clients != null) {
+				if (clients.length > 1) {
+					getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, clients);
+					getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(true));
+				} else
+					getTaskModel().putObject(WizardTaskUtil.TASK_CLIENT, clients[0]);
+			}
+			
 			updateChildFragments();
 		} catch (Exception e) {
 			// ignore
@@ -122,41 +99,4 @@
 		super.setTaskModel(taskModel);
 		updateClients();
 	}
-
-	/**
-	 * Returns the launchable clients for the given server and launchable
-	 * object.
-	 * 
-	 * @param server org.eclipse.wst.server.core.IServer
-	 * @param launchable
-	 * @param launchMode String
-	 * @return an array of clients
-	 */
-	public static IClient[] getClients(IServer server, Object launchable, String launchMode) {
-		ArrayList list = new ArrayList(5);
-		IClient[] clients = ServerPlugin.getClients();
-		if (clients != null) {
-			int size = clients.length;
-			for (int i = 0; i < size; i++) {
-				Trace.trace(Trace.FINEST, "client= " + clients[i]);
-				if (clients[i].supports(server, launchable, launchMode))
-					list.add(clients[i]);
-			}
-		}
-		
-		IClient[] clients2 = new IClient[list.size()];
-		list.toArray(clients2);
-		return clients2;
-	}
-
-	/**
-	 * Return the selected client.
-	 * 
-	 * @return the client
-	 */
-	public IClient getSelectedClient() {
-		if (fragment == null)
-			return null;
-		return fragment.getSelectedClient();
-	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/RunOnServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/RunOnServerWizardFragment.java
new file mode 100644
index 0000000..d766839
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/RunOnServerWizardFragment.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal.wizard.fragment;
+
+import java.util.List;
+
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+/**
+ * A fragment used for the Run on Server wizard.
+ */
+public class RunOnServerWizardFragment extends WizardFragment {
+	protected IServer server;
+	protected IModule module;
+	protected IModuleArtifact moduleArtifact;
+
+	/**
+	 * Create the Run on Server wizard with all pages.
+	 * 
+	 * @param module
+	 * @param launchMode
+	 * @param moduleArtifact
+	 */
+	public RunOnServerWizardFragment(IModule module, String launchMode, IModuleArtifact moduleArtifact) {
+		super();
+		this.module = module;
+		this.moduleArtifact = moduleArtifact;
+	}
+
+	/**
+	 * Create the Run on Server wizard with a default server.
+	 * 
+	 * @param server a server
+	 * @param launchMode
+	 * @param moduleArtifact
+	 */
+	public RunOnServerWizardFragment(IServer server, String launchMode, IModuleArtifact moduleArtifact) {
+		super();
+		this.server = server;
+		this.moduleArtifact = moduleArtifact;
+	}
+
+	protected void createChildFragments(List list) {
+		if (server == null) {
+			list.add(new NewServerWizardFragment(module));
+			
+			list.add(WizardTaskUtil.TempSaveRuntimeFragment);
+			list.add(WizardTaskUtil.TempSaveServerFragment);
+			
+			list.add(new ModifyModulesWizardFragment(module));
+		}
+		
+		list.add(new TasksWizardFragment());
+		
+		list.add(WizardTaskUtil.SaveRuntimeFragment);
+		list.add(WizardTaskUtil.SaveServerFragment);
+		if (server == null)
+			list.add(WizardTaskUtil.SaveHostnameFragment);
+		
+		list.add(new OptionalClientWizardFragment(moduleArtifact));
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java
index f5e0803..f27eb75 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java
@@ -12,6 +12,7 @@
 
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.wst.server.core.internal.IClient;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.internal.wizard.page.SelectClientComposite;
 import org.eclipse.wst.server.ui.wizard.WizardFragment;
 import org.eclipse.wst.server.ui.wizard.IWizardHandle;
@@ -19,32 +20,27 @@
  * A fragment used to select a client.
  */
 public class SelectClientWizardFragment extends WizardFragment {
-	protected IClient[] clients;
-	protected SelectClientComposite comp;
-
-	public SelectClientWizardFragment(IClient[] clients) {
+	public SelectClientWizardFragment() {
 		super();
-		this.clients = clients;
 	}
 
 	public boolean hasComposite() {
 		return true;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage()
-	 */
 	public Composite createComposite(Composite parent, IWizardHandle wizard) {
-		comp = new SelectClientComposite(parent, wizard, clients);
-		return comp;
+		return new SelectClientComposite(parent, wizard, getTaskModel());
 	}
 
-	/**
-	 * Return the selected client.
-	 * 
-	 * @return the client
-	 */
-	public IClient getSelectedClient() {
-		return comp.getSelectedClient();
+	public boolean isComplete() {
+		try {
+			IClient[] clients = (IClient[]) getTaskModel().getObject(WizardTaskUtil.TASK_CLIENTS);
+			if (clients == null || clients.length < 2)
+				return true;
+		} catch (Exception e) {
+			return true;
+		}
+		
+		return getTaskModel().getObject(WizardTaskUtil.TASK_CLIENT) != null;
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java
index 077911f..aaed110 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java
@@ -22,6 +22,7 @@
 import org.eclipse.wst.server.core.internal.*;
 import org.eclipse.wst.server.core.model.PublishOperation;
 import org.eclipse.wst.server.ui.internal.editor.IOrdered;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.wizard.WizardFragment;
 /**
  * 
@@ -163,12 +164,19 @@
 		}
 		
 		if (server != null && modules != null) {
-			List taskList = new ArrayList();
+			hasOptionalTasks = false;
+			hasPreferredTasks = false;
+			List taskList = new ArrayList(5);
 			createTasks(taskList, server, modules);
 			
 			if (tasks == null || !tasks.equals(taskList)) {
 				tasks = taskList;
 				updateChildFragments();
+				
+				boolean b = tasks == null || !tasks.isEmpty();
+				if (hasOptionalTasks)
+					b = true;
+				getTaskModel().putObject(WizardTaskUtil.TASK_HAS_TASKS, new Boolean(b));
 			}
 		}
 	}
@@ -256,34 +264,4 @@
 			wc.save(true, monitor);
 		monitor.done();
 	}
-
-	/**
-	 * Return <code>true</code> if this wizard has tasks.
-	 * 
-	 * @return <code>true</code> if this wizard has tasks, and <code>false</code>
-	 *    otherwise
-	 */
-	public boolean hasTasks() {
-		return tasks == null || !tasks.isEmpty();
-	}
-	
-	/**
-	 * Return <code>true</code> if this wizard has optional tasks.
-	 * 
-	 * @return <code>true</code> if this wizard has optional tasks, and
-	 *    <code>false</code> otherwise
-	 */
-	public boolean hasOptionalTasks() {
-		return hasOptionalTasks;
-	}
-
-	/**
-	 * Return <code>true</code> if this wizard has preferred tasks.
-	 * 
-	 * @return <code>true</code> if this wizard has preferred tasks, and
-	 *    <code>false</code> otherwise
-	 */
-	public boolean hasPreferredTasks() {
-		return hasPreferredTasks;
-	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java
index 79523b2..cf87078 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java
@@ -44,7 +44,7 @@
 import org.eclipse.wst.server.core.ServerUtil;
 import org.eclipse.wst.server.ui.internal.*;
 import org.eclipse.wst.server.ui.internal.viewers.ServerComposite;
-import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.wizard.IWizardHandle;
 /**
  * A wizard page used to select a server.
@@ -55,9 +55,9 @@
 	protected IModule module;
 	protected String launchMode;
 	
-	protected static final byte MODE_EXISTING = 0;
-	protected static final byte MODE_DETECT = 1;
-	protected static final byte MODE_MANUAL= 2;
+	protected static final byte MODE_EXISTING = WizardTaskUtil.MODE_EXISTING;
+	protected static final byte MODE_DETECT = WizardTaskUtil.MODE_DETECT;
+	protected static final byte MODE_MANUAL = WizardTaskUtil.MODE_MANUAL;
 	protected byte mode;
 
 	protected Composite detectComp2;
@@ -73,9 +73,6 @@
 	
 	protected String lastHostname;
 	
-	protected Button pref;
-	protected boolean preferred;
-	
 	protected IServerWorkingCopy existingWC;
 
 	/**
@@ -219,16 +216,13 @@
 		
 		if (module != null) {
 			// preferred server button
-			pref = new Button(this, SWT.CHECK | SWT.WRAP);
+			final Button pref = new Button(this, SWT.CHECK | SWT.WRAP);
 			pref.setText(Messages.wizSelectServerPreferred);
 			data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_END);
-			//pref.setSelection(true);
-			//preferred = true;
-			data.horizontalSpan = 1;
 			pref.setLayoutData(data);
 			pref.addSelectionListener(new SelectionAdapter() {
 				public void widgetSelected(SelectionEvent e) {
-					preferred = pref.getSelection();
+					taskModel.putObject(WizardTaskUtil.TASK_DEFAULT_SERVER, new Boolean(pref.getSelection()));
 				}
 			});
 			PlatformUI.getWorkbench().getHelpSystem().setHelp(pref, ContextIds.SELECT_SERVER_PREFERENCE);
@@ -259,7 +253,7 @@
 		}
 		stack.layout();
 		if (taskModel != null) {
-			taskModel.putObject(NewServerWizardFragment.MODE, new Byte(mode));
+			taskModel.putObject(WizardTaskUtil.TASK_MODE, new Byte(mode));
 			updateTaskModel();
 		}
 	}
@@ -474,7 +468,7 @@
 
 	public void setTaskModel(TaskModel model) {
 		taskModel = model;
-		taskModel.putObject(NewServerWizardFragment.MODE, new Byte(mode));
+		taskModel.putObject(WizardTaskUtil.TASK_MODE, new Byte(mode));
 		updateTaskModel();
 	}
 
@@ -498,16 +492,7 @@
 		else
 			return manualComp.getRuntime();
 	}
-	
-	/**
-	 * Returns true if this server should become the preferred server.
-	 * 
-	 * @return boolean
-	 */
-	public boolean isPreferredServer() {
-		return preferred;
-	}
-	
+
 	public void setVisible(boolean visible) {
 		super.setVisible(visible);
 		
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java
index 6a182ce..3384a48 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java
@@ -13,9 +13,11 @@
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.wst.server.core.TaskModel;
 import org.eclipse.wst.server.core.internal.IClient;
 import org.eclipse.wst.server.ui.ServerUICore;
 import org.eclipse.wst.server.ui.internal.*;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.wizard.IWizardHandle;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
@@ -33,6 +35,7 @@
  */
 public class SelectClientComposite extends Composite {
 	protected IWizardHandle wizard;
+	protected TaskModel taskModel;
 
 	// the list of elements to select from
 	protected IClient[] clients;
@@ -51,12 +54,17 @@
 	 * 
 	 * @param parent a parent composite
 	 * @param wizard a wizard handle
-	 * @param clients an array of clients
+	 * @param taskModel a task model
 	 */
-	public SelectClientComposite(Composite parent, IWizardHandle wizard, IClient[] clients) {
+	public SelectClientComposite(Composite parent, IWizardHandle wizard, TaskModel taskModel) {
 		super(parent, SWT.NONE);
 		this.wizard = wizard;
-		this.clients = clients;
+		this.taskModel = taskModel;
+		try {
+			clients = (IClient[]) taskModel.getObject(WizardTaskUtil.TASK_CLIENTS);
+		} catch (Exception e) {
+			// ignore
+		}
 	
 		wizard.setTitle(Messages.wizSelectClientTitle);
 		wizard.setDescription(Messages.wizSelectClientDescription);
@@ -66,13 +74,6 @@
 	}
 
 	/**
-	 * Clears the selected client.
-	 */
-	public void clearSelectedClient() {
-		selectedClient = null;
-	}
-
-	/**
 	 * Creates the UI of the page.
 	 */
 	protected void createControl() {
@@ -127,15 +128,6 @@
 	}
 
 	/**
-	 * Return the selected client.
-	 *
-	 * @return org.eclipse.wst.server.core.IClient
-	 */
-	public IClient getSelectedClient() {
-		return selectedClient;
-	}
-
-	/**
 	 * Handle the selection of a client.
 	 */
 	protected void handleSelection() {
@@ -145,18 +137,19 @@
 		else
 			selectedClient = clients[index];
 		
+		taskModel.putObject(WizardTaskUtil.TASK_CLIENT, selectedClient);
 		if (selectedClient != null)
 			wizard.setMessage(null, IMessageProvider.NONE);
 		else
 			wizard.setMessage("", IMessageProvider.ERROR);
-	
+		
 		String desc = null;
 		if (selectedClient != null)
 			desc = selectedClient.getDescription();
 		if (desc == null)
 			desc = "";
 		description.setText(desc);
-	
+		
 		wizard.update();
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java
index d6e4d7b..800b824 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java
@@ -183,7 +183,7 @@
 	 * state and the flow of the wizard will be incorrect. 
 	 * 
 	 * @param list a list to add the child fragments to
-	 */	
+	 */
 	protected void createChildFragments(List list) {
 		// do nothing
 	}