### Eclipse Workspace Patch 1.0
#P org.jboss.ide.eclipse.as.ui
Index: jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
--- jbossui/org/jboss/ide/eclipse/as/ui/Messages.java	(revision 30277)
+++ jbossui/org/jboss/ide/eclipse/as/ui/Messages.java	(working copy)
@@ -169,6 +169,7 @@
 
 
 	/* Editor Strings */
+	public static String EditorDeployment;
 	public static String EditorUseWorkspaceMetadata;
 	public static String EditorUseServersDeployFolder;
 	public static String EditorUseCustomDeployFolder;
Index: jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
===================================================================
--- jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java	(revision 30277)
+++ jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
- * Copyright (c) 2010 Red Hat, Inc. 
+ * Copyright (c) 2011 Red Hat, Inc. 
  * Distributed under license by Red Hat, Inc. All rights reserved. 
  * This program is made available under the terms of the 
  * Eclipse Public License v1.0 which accompanies this distribution, 
@@ -10,20 +10,15 @@
  ******************************************************************************/ 
 package org.jboss.ide.eclipse.as.ui.editor;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.util.ArrayList;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.IEditorInput;
@@ -44,6 +39,7 @@
 import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
 import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
 import org.jboss.ide.eclipse.as.core.util.ServerUtil;
+import org.jboss.ide.eclipse.as.ui.Messages;
 
 public class ModuleDeploymentPage extends ServerEditorPart {
 	protected ServerResourceCommandManager commandManager;
@@ -115,7 +111,7 @@
 		FormToolkit toolkit = getFormToolkit(parent);
 		ScrolledForm allContent = toolkit.createScrolledForm(parent);
 		toolkit.decorateFormHeading(allContent.getForm());
-		allContent.setText("Deployment");
+		allContent.setText(Messages.EditorDeployment);
 		allContent.getBody().setLayout(new FormLayout());
 		return allContent;
 	}
@@ -148,27 +144,45 @@
 	}
 	
 	public void firePropertyChangeCommand(DeploymentModulePrefs p, String key, String val, String cmdName) {
-		commandManager.execute(new ChangePropertyCommand(p,key,val,cmdName));
+		firePropertyChangeCommand(p, new String[]{key},new String[]{val},cmdName);
 	}
 	
+	public void firePropertyChangeCommand(DeploymentModulePrefs p, String[] keys, String[] vals, String cmdName) {
+		commandManager.execute(new ChangePropertyCommand(p, keys,vals,cmdName));
+	}
+
+	
 	private class ChangePropertyCommand extends ServerCommand {
 		private DeploymentModulePrefs p;
-		private String key;
-		private String oldVal;
-		private String newVal;
+		private String[] keys;
+		private String[] oldVals;
+		private String[] newVals;
 		public ChangePropertyCommand(DeploymentModulePrefs p, String key, String val, String commandName) {
+			this(p, new String[]{key}, new String[]{val}, commandName);
+		}
+		
+		public ChangePropertyCommand(DeploymentModulePrefs p, String[] keys, 
+				String[] vals, String commandName) {
 			super(ModuleDeploymentPage.this.server, commandName);
 			this.p = p;
-			this.key = key;
-			this.newVal = val;
-			this.oldVal = p.getProperty(key);
+			this.keys = keys;
+			this.newVals = vals;
+			this.oldVals = new String[newVals.length];
+			for( int i = 0; i < newVals.length; i++ ) {
+				oldVals[i] = p.getProperty(keys[i]);
+			}
 		}
+		
 		public void execute() {
-			p.setProperty(key, newVal);
+			for( int i = 0; i < keys.length; i++ ) {
+				p.setProperty(keys[i], newVals[i]);
+			}
 			savePreferencesToWorkingCopy();
 		}
 		public void undo() {
-			p.setProperty(key, oldVal);
+			for( int i = 0; i < keys.length; i++) {
+				p.setProperty(keys[i], oldVals[i]);
+			}
 			savePreferencesToWorkingCopy();
 		}
 	}
@@ -195,7 +209,7 @@
 	public static String makeRelative(String path, IRuntime runtime) {
 		IJBossServerRuntime rt = getRuntime(runtime);
 		if (rt == null)
-			return path;
+			return path; 
 		return ServerUtil.makeRelative(rt, new Path(path)).toString();
 	}
 
Index: jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
===================================================================
--- jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java	(revision 30277)
+++ jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
- * Copyright (c) 2011 Red Hat, Inc. 
+* Copyright (c) 2011 Red Hat, Inc. 
  * Distributed under license by Red Hat, Inc. All rights reserved. 
  * This program is made available under the terms of the 
  * Eclipse Public License v1.0 which accompanies this distribution, 
@@ -59,6 +59,7 @@
 import org.jboss.ide.eclipse.as.core.ExtensionManager;
 import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
 import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
 import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
 import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
 import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
@@ -115,32 +116,21 @@
 	private ModuleDeploymentPage page;
 	private DeploymentPreferences preferences;
 	private TreeViewer viewer;
-	protected String COLUMN_NAME;
-	protected String COLUMN_LOC;
-	protected String COLUMN_TEMP_LOC;
-	protected String currentDeployType;
+	protected static final String COLUMN_NAME = IJBossToolingConstants.LOCAL_DEPLOYMENT_NAME;
+	protected static final String COLUMN_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC;
+	protected static final String COLUMN_TEMP_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC;
+	protected static final String OUTPUT_NAME = IJBossToolingConstants.LOCAL_DEPLOYMENT_OUTPUT_NAME;
+	protected String currentDeployType = LocalPublishMethod.LOCAL_PUBLISH_METHOD;
 	
 	private IServerWorkingCopy lastWC;
 	
 	public DeploymentModuleOptionCompositeAssistant() {
-		COLUMN_NAME = IJBossToolingConstants.LOCAL_DEPLOYMENT_NAME;
-		COLUMN_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC;
-		COLUMN_TEMP_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC;
-		currentDeployType = LocalPublishMethod.LOCAL_PUBLISH_METHOD;
 	}
 
 	public ModuleDeploymentPage getPage() {
 		return page;
 	}
 	
-	public String getCurrentDeployType() {
-		return currentDeployType;
-	}
-	
-	public void setCurrentDeployType(String type) {
-		this.currentDeployType = type;
-	}
-	
 	public void setDeploymentPage(ModuleDeploymentPage page) {
 		this.page = page;
 	}
@@ -673,8 +663,7 @@
 			DeploymentModulePrefs p = preferences.getOrCreatePreferences(currentDeployType)
 					.getOrCreateModulePrefs((IModule) element);
 			if (property == COLUMN_LOC) {
-				String ret = p.getProperty(COLUMN_LOC);
-				return ret == null ? "" : ret;
+				return getOutputFolderAndName(p, (IModule)element);
 			}
 			if (property == COLUMN_TEMP_LOC) {
 				String ret = p.getProperty(COLUMN_TEMP_LOC);
@@ -690,8 +679,12 @@
 			DeploymentModulePrefs p = preferences.getOrCreatePreferences(currentDeployType)
 					.getOrCreateModulePrefs(module);
 			if (property == COLUMN_LOC) {
-				page.firePropertyChangeCommand(p, COLUMN_LOC,
-						(String) value, Messages.EditorEditDeployLocCommand);
+				String outputName = new Path(((String)value)).lastSegment();
+				String outPath = ((String)value).substring(0, ((String)value).length()-outputName.length());
+				page.firePropertyChangeCommand(p, 
+						new String[]{COLUMN_LOC, OUTPUT_NAME},
+						new String[]{outPath,outputName},
+						Messages.EditorEditDeployLocCommand);
 				viewer.refresh();
 			} else if (property == COLUMN_TEMP_LOC) {
 				page.firePropertyChangeCommand(p, COLUMN_TEMP_LOC,
@@ -745,11 +738,7 @@
 					DeploymentModulePrefs modPref = preferences
 							.getOrCreatePreferences(currentDeployType)
 							.getOrCreateModulePrefs(m);
-					String result = modPref.getProperty(COLUMN_LOC);
-					if (result != null)
-						return result;
-					modPref.setProperty(COLUMN_LOC, "");
-					return "";
+					return getOutputFolderAndName(modPref, m);
 				}
 				if (columnIndex == 2) {
 					DeploymentModulePrefs modPref = preferences
@@ -802,4 +791,19 @@
 		
 	}
 	
+	
+	public static String getDefaultOutputName(IModule module) {
+		return module.getName() + PublishUtil.getSuffix(module.getModuleType().getId());
+	}
+	
+	protected static String getOutputFolderAndName(DeploymentModulePrefs modPref, IModule m) {
+		String folder = modPref.getProperty(COLUMN_LOC);
+		String outputName = modPref.getProperty(OUTPUT_NAME);
+		outputName = outputName == null || outputName.equals("") 
+			? getDefaultOutputName(m) : outputName;
+			
+		if (folder != null)
+			return new Path(folder).append(outputName).toPortableString();
+		return outputName;
+	}
 }
Index: jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
--- jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties	(revision 30277)
+++ jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties	(working copy)
@@ -144,10 +144,11 @@
 DescriptorXPathMatch=Match
 
 #Editor
+EditorDeployment=Deployment
 EditorUseWorkspaceMetadata=Use workspace metadata (does not modify JBoss deploy folder)
 EditorUseServersDeployFolder=Use the JBoss deploy folder
 EditorUseCustomDeployFolder=Use a custom deploy folder
-EditorSetDeployLabel=Deploy Directory
+EditorSetDeployLabel=Deployment Location
 EditorSetTempDeployLabel=Temporary Deploy Directory
 EditorEditDeployLocCommand=Edit Deployment Location
 EditorModule=Module
#P org.jboss.ide.eclipse.archives.webtools
Index: src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
===================================================================
--- src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java	(revision 30277)
+++ src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
- * Copyright (c) 2010 Red Hat, Inc. 
+ * Copyright (c) 2011 Red Hat, Inc. 
  * Distributed under license by Red Hat, Inc. All rights reserved. 
  * This program is made available under the terms of the 
  * Eclipse Public License v1.0 which accompanies this distribution, 
@@ -43,6 +43,7 @@
 import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
 import org.jboss.ide.eclipse.as.core.util.FileUtil;
 import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
 import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
 
 import de.schlichtherle.io.ArchiveDetector;
@@ -52,7 +53,7 @@
 	private String deployRoot;
 	private boolean hasBeenChanged = false;
 	private IModule[] module;
-	
+	private IServer server;
 	public IStatus publishModule(IServer server, String deployRoot, IModule[] module,
 			int publishType, IModuleResourceDelta[] delta,
 			IProgressMonitor monitor) throws CoreException {
@@ -61,6 +62,7 @@
 		monitor.setTaskName(name);
 		this.deployRoot = deployRoot;
 		this.module = module;
+		this.server = server;
 		IStatus[] returnStatus;
 		
 		
@@ -325,7 +327,8 @@
 	}
 	
 	public IPath getOutputFilePath(IModule[] module) {
-		return getDeployPath(module, deployRoot);
+		IDeployableServer ds = ServerConverter.getDeployableServer(server);
+		return getDeployPath(module, deployRoot, ds);
 	}
 	
 	public boolean hasBeenChanged() {
#P org.jboss.ide.eclipse.as.core
Index: jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
===================================================================
--- jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java	(revision 30277)
+++ jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java	(working copy)
@@ -100,5 +100,5 @@
 	public static final String LOCAL_DEPLOYMENT_NAME = "name";  //$NON-NLS-1$
 	public static final String LOCAL_DEPLOYMENT_LOC = "location";  //$NON-NLS-1$
 	public static final String LOCAL_DEPLOYMENT_TEMP_LOC = "tempLocation";  //$NON-NLS-1$
-
+	public static final String LOCAL_DEPLOYMENT_OUTPUT_NAME = "outputName"; //$NON-NLS-1$
 }
Index: jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
--- jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java	(revision 30277)
+++ jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
- * Copyright (c) 2007 Red Hat, Inc. 
+ * Copyright (c) 2011 Red Hat, Inc. 
  * Distributed under license by Red Hat, Inc. All rights reserved. 
  * This program is made available under the terms of the 
  * Eclipse Public License v1.0 which accompanies this distribution, 
@@ -125,7 +125,7 @@
 				moduleTree, server, 
 				server.getDeployFolder(), 
 				IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
-		return getDeployPath(moduleTree, folder);
+		return getDeployPath(moduleTree, folder, server);
 	}
 
 	public static IPath getDeployRootFolder(IModule[] moduleTree, IDeployableServer server) {
@@ -144,6 +144,47 @@
 		return new Path(folder);
 	}
 	
+	public static IPath getDeployPath(IModule[] moduleTree, String deployFolder, IDeployableServer server) {
+		IPath root = new Path( deployFolder );
+		String type, modName, name, uri, suffixedName;
+		for( int i = 0; i < moduleTree.length; i++ ) {	
+			boolean found = false;
+			if( i == 0 ) {
+				// If this is the root module, we can customize the output name
+				DeploymentPreferences prefs = DeploymentPreferenceLoader.loadPreferencesFromServer(server.getServer());
+				DeploymentTypePrefs typePrefs = prefs.getOrCreatePreferences(LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+				DeploymentModulePrefs modPrefs = typePrefs.getModulePrefs(moduleTree[0]);
+				if( modPrefs != null ) {
+					String outName = modPrefs.getProperty(IJBossToolingConstants.LOCAL_DEPLOYMENT_OUTPUT_NAME);
+					if( outName != null && !outName.equals("")) { //$NON-NLS-1$
+						found = true;
+						root = root.append(outName);
+					}
+				}
+			} 
+			
+			// If it's a child module, or the property is not set,
+			// we must respect the deployment model... 
+			if( !found ) {
+				type = moduleTree[i].getModuleType().getId();
+				modName = moduleTree[i].getName();
+				name = new Path(modName).lastSegment();
+				suffixedName = name + getSuffix(type);
+				uri = getParentRelativeURI(moduleTree, i, suffixedName);
+				root = root.append(uri);
+			}
+		}
+		return root;
+	}
+	
+	/**
+	 * This method is deprecated. Please use the following:
+	 * @see getDeployPath(IModule[] module, String folder, IDeployableServer server)
+	 * @param moduleTree
+	 * @param deployFolder
+	 * @return
+	 */
+	@Deprecated
 	public static IPath getDeployPath(IModule[] moduleTree, String deployFolder) {
 		IPath root = new Path( deployFolder );
 		String type, modName, name, uri, suffixedName;
@@ -197,10 +238,10 @@
 		String folder = PublishUtil.getDeployRootFolder(
 				moduleTree, server, defaultFolder,
 				IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
-		return PublishUtil.getDeployPath(moduleTree, folder);
+		return PublishUtil.getDeployPath(moduleTree, folder, server);
 	}
 
-	private static String getSuffix(String type) {
+	public static String getSuffix(String type) {
 		// TODO
 		// VirtualReferenceUtilities.INSTANCE. has utility methods to help!!
 
#P org.jboss.ide.eclipse.as.rse.core
Index: src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java
===================================================================
--- src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java	(revision 30277)
+++ src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
- * Copyright (c) 2010 Red Hat, Inc. 
+ * Copyright (c) 2011 Red Hat, Inc. 
  * Distributed under license by Red Hat, Inc. All rights reserved. 
  * This program is made available under the terms of the 
  * Eclipse Public License v1.0 which accompanies this distribution, 
@@ -93,7 +93,7 @@
 		// set up needed vars
 		IDeployableServer server2 = ServerConverter.getDeployableServer(server);
 		String remoteTempDeployRoot = getDeployRoot(module, ServerConverter.getDeployableServer(server));
-		IPath sourcePath = PublishUtil.getDeployPath(module, remoteTempDeployRoot);
+		IPath sourcePath = PublishUtil.getDeployPath(module, remoteTempDeployRoot, server2);
 		IPath destFolder = PublishUtil.getDeployPath(method, module, server2);
 		String name = sourcePath.lastSegment();
 		IStatus result = null;
