[145834] Implement settable deploy directory that defaults to something other than "webapps".  This avoids problems with default web applications.
Minor updates to clean work directory.
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF
index c1e8727..b25d0fe 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF
@@ -17,11 +17,11 @@
  org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
  org.eclipse.jdt.debug.ui;bundle-version="[3.2.0,4.0.0)",
  org.eclipse.jdt.launching;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.wst.server.core;bundle-version="[1.0.103,1.1.0)",
- org.eclipse.wst.server.ui;bundle-version="[1.0.103,1.1.0)",
+ org.eclipse.wst.server.core;bundle-version="[1.0.204,1.1.0)",
+ org.eclipse.wst.server.ui;bundle-version="[1.0.204,1.1.0)",
  org.eclipse.jst.server.core;bundle-version="[1.0.103,1.1.0)",
  org.eclipse.jst.server.ui;bundle-version="[1.0.103,1.1.0)",
- org.eclipse.jst.server.tomcat.core;bundle-version="[1.0.103,1.1.0)",
+ org.eclipse.jst.server.tomcat.core;bundle-version="[1.1.0,1.2.0)",
  org.eclipse.wst.common.project.facet.ui;bundle-version="[1.1.0,1.2.0)"
 Eclipse-LazyStart: true
 Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java
index d3fa4d2..1febe9c 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java
@@ -32,10 +32,11 @@
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
 import org.eclipse.wst.server.core.IServer.IOperationListener;
-import org.eclipse.wst.server.core.internal.ServerSchedulingRule;
 
 /**
  * Dialog to confirm deletion of the work directory for a module on a
@@ -98,6 +99,8 @@
 
 		// create a composite with standard margins and spacing
 		Composite composite = (Composite)super.createDialogArea(parent);
+		// Since there are only label widgets on this page, set the help on the parent
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ContextIds.SERVER_CLEAN_WORK_DIR);
 
 		Label label = new Label(composite, SWT.WRAP);
 		if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING || state == IServer.STATE_UNKNOWN) {
@@ -142,7 +145,7 @@
 	protected void okPressed() {
 		// Create job to perform the deletion
 		DeleteWorkDirJob job = new DeleteWorkDirJob(Messages.cleanServerTask);
-		job.setRule(new ServerSchedulingRule(server));
+		job.setRule(ServerUtil.getServerSchedulingRule(server));
 		
 		job.addJobChangeListener(new JobChangeAdapter() {
 			public void done(IJobChangeEvent event) {
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.java
index 7957cc1..28b8237 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.java
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.java
@@ -45,4 +45,6 @@
 	public static final String CONFIGURATION_EDITOR_PORTS_LIST = TomcatUIPlugin.PLUGIN_ID + ".tecp0002";
 		
 	public static final String RUNTIME_COMPOSITE = TomcatUIPlugin.PLUGIN_ID + ".twnr0000";
+
+	public static final String SERVER_CLEAN_WORK_DIR = TomcatUIPlugin.PLUGIN_ID + ".tvcp0000";
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java
index d296b17..4271bec 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java
@@ -51,11 +51,17 @@
 	public static String configurationEditorMimeMapppingDialogTitleAdd;
 	public static String configurationEditorMimeMapppingDialogMimeType;
 	public static String configurationEditorMimeMapppingDialogMimeExtension;
+	public static String configurationEditorBrowseDeploy;
+	public static String configurationEditorBrowseDeployMessage;
 	public static String serverEditorGeneralSection;
 	public static String serverEditorGeneralDescription;
 	public static String serverEditorTestEnvironment;
 	public static String serverEditorSecure;
 	public static String serverEditorDebugMode;
+	public static String serverEditorDeployDir;
+	public static String serverEditorBrowse;
+	public static String serverEditorSpecialFieldsLabel;
+	public static String errorDeployDirNotSpecified;
 	public static String configurationEditorWebModuleDialogTitleEdit;
 	public static String configurationEditorWebModuleDialogTitleAdd;
 	public static String configurationEditorWebModuleDialogProjects;
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties
index d9763c3..65fe7b5 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties
@@ -69,6 +69,10 @@
 configurationEditorWebModuleDialogSelectDirectory=Select the Web module directory.
 errorMissingWebModule=The Web module at the following location cannot be found: {0}.
 
+# Browse for Deploy dialog
+configurationEditorBrowseDeploy=Browse
+configurationEditorBrowseDeployMessage=Select a deploy directory.
+
 # --- Server Editor ---
 serverEditorGeneralSection=Server
 serverEditorGeneralDescription=Enter settings for the server.
@@ -77,6 +81,9 @@
 serverEditorSecure=Enable security
 serverEditorDebugMode=Enable Tomcat debug mode (v4.x and above only)
 serverEditorTestEnvironment=Run modules directly from the workspace (do not modify the Tomcat installation)
+serverEditorDeployDir=Deploy directory:
+serverEditorSpecialFieldsLabel=The field above may be changed only when the server is synchronized with no modules added.
+errorDeployDirNotSpecified=A Deploy directory must be specified.
 
 # --- Clean Work Directory ---
 confirmCleanWorkDirTitle=Confirm Clean
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java
index 32ab13c..03fa7fe 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java
@@ -13,20 +13,29 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jst.server.tomcat.core.internal.ITomcatServer;
 import org.eclipse.jst.server.tomcat.core.internal.TomcatServer;
 import org.eclipse.jst.server.tomcat.core.internal.command.SetDebugModeCommand;
+import org.eclipse.jst.server.tomcat.core.internal.command.SetDeployDirectoryCommand;
 import org.eclipse.jst.server.tomcat.core.internal.command.SetSecureCommand;
 import org.eclipse.jst.server.tomcat.core.internal.command.SetTestEnvironmentCommand;
 import org.eclipse.jst.server.tomcat.ui.internal.ContextIds;
 import org.eclipse.jst.server.tomcat.ui.internal.Messages;
+import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
 import org.eclipse.ui.PlatformUI;
@@ -34,8 +43,10 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
-
-import org.eclipse.wst.server.ui.editor.*;
+import org.eclipse.wst.server.core.IPublishListener;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.util.PublishAdapter;
+import org.eclipse.wst.server.ui.editor.ServerEditorSection;
 /**
  * Tomcat server general editor page.
  */
@@ -45,9 +56,14 @@
 	protected Button secure;
 	protected Button debug;
 	protected Button testEnvironment;
+	protected Text deployDir;
+	protected Button deployDirBrowse;
 	protected boolean updating;
 
 	protected PropertyChangeListener listener;
+	protected IPublishListener publishListener;
+	
+	boolean allowRestrictedEditing;
 
 	/**
 	 * ServerGeneralEditorPart constructor comment.
@@ -59,7 +75,7 @@
 	/**
 	 * 
 	 */
-	protected void addChangeListener() {
+	protected void addChangeListeners() {
 		listener = new PropertyChangeListener() {
 			public void propertyChange(PropertyChangeEvent event) {
 				if (updating)
@@ -74,11 +90,36 @@
 				} else if (ITomcatServer.PROPERTY_TEST_ENVIRONMENT.equals(event.getPropertyName())) {
 					Boolean b = (Boolean) event.getNewValue();
 					ServerGeneralEditorSection.this.testEnvironment.setSelection(b.booleanValue());
+				} else if (ITomcatServer.PROPERTY_DEPLOYDIR.equals(event.getPropertyName())) {
+					String s = (String) event.getNewValue();
+					ServerGeneralEditorSection.this.deployDir.setText(s);
+					validate();
 				}
 				updating = false;
 			}
 		};
 		server.addPropertyChangeListener(listener);
+		
+		publishListener = new PublishAdapter() {
+			public void publishFinished(IServer server2, IStatus status) {
+				boolean flag = false;
+				if (status.isOK() && server2.getModules().length == 0)
+					flag = true;
+				if (flag != allowRestrictedEditing) {
+					allowRestrictedEditing = flag;
+					// Update the state of the fields
+					PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+						public void run() {
+							if (!ServerGeneralEditorSection.this.deployDir.isDisposed())
+								ServerGeneralEditorSection.this.deployDir.setEnabled(allowRestrictedEditing);
+							if (!ServerGeneralEditorSection.this.deployDirBrowse.isDisposed())
+								ServerGeneralEditorSection.this.deployDirBrowse.setEnabled(allowRestrictedEditing);
+						}
+					});
+				}
+			}
+		};
+		server.getOriginal().addPublishListener(publishListener);
 	}
 	
 	/**
@@ -110,9 +151,55 @@
 		toolkit.paintBordersFor(composite);
 		section.setClient(composite);
 		
+		// deployment directory
+		Label label = toolkit.createLabel(composite, Messages.serverEditorDeployDir);
+		GridData data = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
+		label.setLayoutData(data);
+		
+		deployDir = toolkit.createText(composite, null);
+		data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		deployDir.setLayoutData(data);
+		deployDir.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				if (updating)
+					return;
+				updating = true;
+				execute(new SetDeployDirectoryCommand(tomcatServer, deployDir.getText()));
+				updating = false;
+				validate();
+			}
+		});
+		
+		deployDirBrowse = toolkit.createButton(composite, Messages.configurationEditorBrowseDeploy, SWT.PUSH);
+		deployDirBrowse.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent se) {
+				DirectoryDialog dialog = new DirectoryDialog(deployDir.getShell());
+				dialog.setMessage(Messages.configurationEditorBrowseDeployMessage);
+				dialog.setFilterPath(deployDir.getText());
+				String selectedDirectory = dialog.open();
+				if (selectedDirectory != null && !selectedDirectory.equals(deployDir.getText())) {
+					updating = true;
+					execute(new SetDeployDirectoryCommand(tomcatServer, selectedDirectory));
+					updating = false;
+					validate();
+				}
+			}
+		});
+		deployDirBrowse.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+		
+		label = toolkit.createLabel(composite, Messages.serverEditorSpecialFieldsLabel);
+		data = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
+		data.horizontalSpan = 3;
+		label.setLayoutData(data);
+
+		Label separator = toolkit.createSeparator(composite, SWT.HORIZONTAL);
+		data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		data.horizontalSpan = 3;
+		separator.setLayoutData(data);
+		
 		// test environment
 		testEnvironment = toolkit.createButton(composite, Messages.serverEditorTestEnvironment, SWT.CHECK);
-		GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+		data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 		data.horizontalSpan = 3;
 		testEnvironment.setLayoutData(data);
 		testEnvironment.addSelectionListener(new SelectionAdapter() {
@@ -160,18 +247,27 @@
 	
 		initialize();
 	}
-
+	
+	/**
+	 * @see ServerEditorSection#dispose()
+	 */
 	public void dispose() {
-		if (server != null)
+		if (server != null) {
 			server.removePropertyChangeListener(listener);
+			if (server.getOriginal() != null)
+				server.getOriginal().removePublishListener(publishListener);
+		}
 	}
 
+	/**
+	 * @see ServerEditorSection#init(IEditorSite, IEditorInput)
+	 */
 	public void init(IEditorSite site, IEditorInput input) {
 		super.init(site, input);
 		
 		if (server != null) {
 			tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, null);
-			addChangeListener();
+			addChangeListeners();
 		}
 		initialize();
 	}
@@ -183,6 +279,17 @@
 		if (secure == null || tomcatServer == null)
 			return;
 		updating = true;
+		
+		allowRestrictedEditing = false;
+		if (server.getOriginal().getServerPublishState() == IServer.PUBLISH_STATE_NONE
+				&& server.getOriginal().getModules().length == 0) {
+			allowRestrictedEditing = true;
+		}
+		
+		deployDir.setText(tomcatServer.getDeployDirectory());
+		deployDir.setEnabled(allowRestrictedEditing);
+		
+		deployDirBrowse.setEnabled(allowRestrictedEditing);
 
 		testEnvironment.setSelection(tomcatServer.isTestEnvironment());
 		secure.setSelection(tomcatServer.isSecure());
@@ -199,5 +306,32 @@
 			secure.setEnabled(true);
 		
 		updating = false;
+		validate();
+	}
+	
+	/**
+	 * @see ServerEditorSection#getSaveStatus()
+	 */
+	public IStatus[] getSaveStatus() {
+		if (tomcatServer != null) {
+			String dir = tomcatServer.getDeployDirectory();
+			if (dir == null || dir.length() == 0) {
+				return new IStatus [] {
+						new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, Messages.errorDeployDirNotSpecified)};
+			}
+		}
+		// use default implementation to return success
+		return super.getSaveStatus();
+	}
+	
+	protected void validate() {
+		if (tomcatServer != null) {
+			String dir = tomcatServer.getDeployDirectory();
+			if (dir == null || dir.length() == 0) {
+				setErrorMessage(Messages.errorDeployDirNotSpecified);
+				return;
+			}
+		}
+		setErrorMessage(null);
 	}
 }
\ No newline at end of file