Merge branch 'master' of ssh://shung@git.eclipse.org/gitroot/servertools/webtools.servertools.git
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/publishers/AntPublisher.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/publishers/AntPublisher.java
index 67ced10..3e34add 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/publishers/AntPublisher.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/publishers/AntPublisher.java
@@ -1,5 +1,5 @@
 /***************************************************************************************************
- * Copyright (c) 2005, 2009 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the
+ * Copyright (c) 2005, 2013 Eteration A.S. and Gorkem Ercan. 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
@@ -20,6 +20,7 @@
 import java.util.Map;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+
 import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -52,6 +53,7 @@
 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.ServerUtil;
 import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
 import org.osgi.framework.Bundle;
 
@@ -319,16 +321,16 @@
 	}
 
 	private String guessModuleName(IModule module) {
-		String moduleName = module.getName();
+		String deployName = ServerUtil.getModuleDisplayName(module); 
 		if ("jst.web".equals(getModuleTypeId())) { //$NON-NLS-1$
 			IWebModule webModule = (IWebModule) getModule()[0].loadAdapter(IWebModule.class, null);
 			if (webModule == null) {
-				return module.getName();
+				return deployName;
 			}
 			String contextRoot = webModule.getURI(module);
-			moduleName = contextRoot.substring(0, contextRoot.lastIndexOf('.'));
+			deployName = contextRoot.substring(0, contextRoot.lastIndexOf('.'));
 		}
-		return moduleName;
+		return deployName;
 	}
 
 	private String guessContextRoot(IModule module) {
diff --git a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
index 2d43153..43406a8 100644
--- a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.server.core; singleton:=true
-Bundle-Version: 1.4.100.qualifier
+Bundle-Version: 1.5.0.qualifier
 Bundle-Activator: org.eclipse.wst.server.core.internal.ServerPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule2.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule2.java
new file mode 100644
index 0000000..a52bf21
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule2.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. 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:
+ *     Red Hat Inc. - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.core;
+
+/**
+ * A module that provides additional properties.
+ * Variable constants that starts with "PROP_" are reserved for further purpose. Classes
+ * that implements this class should not use variables with this naming convention.
+ *
+ * @see org.eclipse.wst.server.core.IModule
+ * @since 1.5
+ */
+public interface IModule2 extends IModule {
+	
+	/**
+	 * A property key to store a value for the module name to
+	 * be displayed in servertools UI workflows
+	 */
+	public static final String PROP_DISPLAY_NAME = "org.eclipse.wst.server.core.displayName";
+
+	/**
+	 * A property key to store a value for the preferred name of the module 
+	 * to be used by publishers when deploying.  
+	 */
+	public static final String PROP_DEPLOY_NAME = "org.eclipse.wst.server.core.deployName";
+
+	/**
+	 * Access a property of the module. 
+	 * 
+	 * @param key
+	 * @see #PROP_DISPLAY_NAME
+	 * @see #PROP_DEPLOY_NAME
+	 * @return value of the property with the given key,
+	 *   or <code>null</code> if the value is not available on this module.
+	 */
+	public String getProperty(String key);
+}
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java
index 75ba379..b977e68 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2012 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 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
@@ -137,6 +137,21 @@
 	}
 
 	/**
+	 * Get the display name of a given module
+	 * @return the display name
+	 * @since 1.5
+	 */
+	public static String getModuleDisplayName(IModule curModule) {
+		if (curModule instanceof IModule2) {
+			String displayProp = ((IModule2)curModule).getProperty(IModule2.PROP_DISPLAY_NAME);
+			if (displayProp != null) {
+				return displayProp;
+			}
+		}
+		return curModule.getName();
+	}
+
+	/**
 	 * Return all the available modules from all factories whose
 	 * type matches the given module types.
 	 * <p>
@@ -796,4 +811,5 @@
 	public static ISchedulingRule getServerSchedulingRule(IServer server) {
 		return server;
 	}
+
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java
index 8f648e8..9ff0ce6 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 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
@@ -10,16 +10,20 @@
  *******************************************************************************/
 package org.eclipse.wst.server.core.internal;
 
+import java.util.Map;
+
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.IModule2;
 import org.eclipse.wst.server.core.model.ModuleDelegate;
 /**
  * 
  */
-public class Module implements IModule {
+public class Module implements IModule2 {
 	protected String id;
 	protected String name;
 	protected ModuleFactory factory;
@@ -28,6 +32,8 @@
 	protected ModuleDelegate delegate;
 	protected String id2;
 
+	protected Map<String, String> properties;
+	
 	/**
 	 * Module constructor.
 	 * 
@@ -39,6 +45,20 @@
 	 * @param project
 	 */
 	public Module(ModuleFactory factory, String id, String name, String type, String version, IProject project) {
+		this(factory, id, name, type, version, project, null);
+	}
+	
+	/**
+	 * Module constructor with properties
+	 * 
+	 * @param factory
+	 * @param id
+	 * @param name
+	 * @param type
+	 * @param version
+	 * @param project
+	 */
+	public Module(ModuleFactory factory, String id, String name, String type, String version, IProject project, Map<String, String> properties) {
 		super();
 		this.factory = factory;
 		this.project = project;
@@ -50,6 +70,7 @@
 		else
 			id2 = ":";
 		id2 += id;
+		this.properties = properties;
 	}
 
 	/**
@@ -268,4 +289,12 @@
 	public String toString() {
 		return "Module[" + name + "," + id2 + "]";
 	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.wst.server.core.IModule2#getProperty(java.lang.String)
+	 */
+	public String getProperty(String key) {
+		return properties == null || key == null ? null : properties.get(key);
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java
index fe57cc5..50ff7cc 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 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,6 +12,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -123,6 +124,25 @@
 	}
 
 	/**
+	 * Creates a module instance with the given static information,
+	 * including a map of properties. 
+	 * 
+	 * This method is used by module factory delegates to create module instances.
+	 * 
+	 * @param id the module id
+	 * @param name the module name
+	 * @param type the module type id
+	 * @param version the module version id
+	 * @param project the project that the module is contained in
+	 * @param properties a map of key/value pairs for additional information
+	 * @return a module instance
+	 * @since 1.4
+	 */
+	protected final IModule createModule(String id, String name, String type, String version, IProject project, Map<String, String> properties) {
+		return new Module(factory, id, name, type, version, project, properties);
+	}
+
+	/**
 	 * Creates the module delegate for a module with the given information.
 	 * This method is called when a client needs to access the module delegate
 	 * associated with the given module.
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java
index e295e81..d781cf8 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 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
@@ -251,8 +251,7 @@
 			return decorate(module.getName(), modules);
 		} else if (element instanceof ModuleServer) {
 			ModuleServer ms = (ModuleServer) element;
-			IModule module = ms.module[ms.module.length - 1];
-			return decorate(module.getName(), ms);
+			return decorate(ms.getModuleDisplayName(), ms);
 		} else if (element instanceof IWorkbenchAdapter) {
 			return ((IWorkbenchAdapter) element).getLabel(null);
 		}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
index d3a1ecd..88b7ee5 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
@@ -190,7 +190,7 @@
 		if (module != null) {
 			IModule[] modules = module.getModule();
 			IModule m = modules[modules.length - 1];
-			sText.setText("<b>" + m.getName() + "</b>");
+			sText.setText("<b>" + ServerUtil.getModuleDisplayName(m) + "</b>");
 			//sText.setText("<b>" + m.getName() + "</b></p>" + m.getModuleType().getName());
 			
 			StyledText sText2 = new StyledText(parent, SWT.NONE);
@@ -329,4 +329,4 @@
 //			// Auto-generated method stub
 //		}
 //	}	
-}
\ No newline at end of file
+}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java
index 76f8228..5e37583 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java
@@ -140,8 +140,19 @@
 		IModule[] modules = new IModule[] { module }; // TODO: get parent hierarchy correct
 		int state = server.getServerState();
 		if (state == IServer.STATE_STARTING) {
-			LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client);
-			clientJob.schedule();
+			final LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client);
+			final IServer server2 = server;
+			if (server2.shouldPublish()) {
+				server2.publish(IServer.PUBLISH_INCREMENTAL, null, info, new IServer.IOperationListener() {
+					public void done(IStatus result) {
+						if (result.isOK()){
+							clientJob.schedule();
+						}
+					}
+				});
+			} else {
+				clientJob.schedule();
+			}
 		} else if (state == IServer.STATE_STARTED) {
 			boolean restart = false;
 			String mode = server.getMode();
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java
index 5a355c8..5d14c08 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008,2010 IBM Corporation and others.
+ * Copyright (c) 2008,2013 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
@@ -44,9 +44,7 @@
 			ModuleServer ms = (ModuleServer) element;
 			if (ms.module == null)
 				return "";
-			int size = ms.module.length;
-			String name = ms.module[size - 1].getName();
-			return name;
+			return ms.getModuleDisplayName();
 		}
 		
 		if( element instanceof IServer ) {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java
index bdffa04..d26fb88 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 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,6 +12,7 @@
 
 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.ui.IServerModule;
 /**
  * A utility class for referencing a server and a module at the same time.
@@ -57,7 +58,19 @@
 	public IModule[] getModule() {
 		return module;
 	}
-
+	
+	/**
+	 * Get the display name of the module of this module server.
+	 * @return the display name
+	 */
+	public String getModuleDisplayName() {
+		int size = module.length;
+		if (size == 0) {
+			return null;
+		}
+		return ServerUtil.getModuleDisplayName(module[size - 1]);
+	}
+	
 	/**
 	 * @see Object#equals(Object)
 	 */
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java
index 415bf50..793aa6b 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 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
@@ -77,6 +77,7 @@
 				if (part != null) {
 					IDebugView view = (IDebugView)part.getAdapter(IDebugView.class);
 					if (view != null) {
+						page.activate(part);
 						view.setFocus();
 						Viewer viewer = view.getViewer();
 						if (viewer != null) {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java
index 94a1145..1e487d3 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2012 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 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
@@ -510,7 +510,7 @@
 				if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) {
 					ModuleServer s1 = (ModuleServer) e1;
 					ModuleServer s2 = (ModuleServer) e2;
-					return (s1.module[s1.module.length - 1].getName().compareToIgnoreCase(s2.module[s2.module.length - 1].getName()));
+					return (s1.getModuleDisplayName().compareToIgnoreCase(s2.getModuleDisplayName()));
 				}
 				
 				return super.compare(viewer, e1, e2);