[296731] New extension point to control behaviour of UI controls in the server editor
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.properties b/plugins/org.eclipse.wst.server.ui/plugin.properties
index 9c47881..a808474 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.properties
+++ b/plugins/org.eclipse.wst.server.ui/plugin.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2004, 2009 IBM Corporation and others.
+# Copyright (c) 2004, 2010 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
@@ -19,6 +19,7 @@
 extensionPointInitialSelectionProvider=Initial Selection Provider
 extensionPointAudio=Audio
 extensionPointServerCreationWizardPageExtension=Server Creation Wizard Page Extension
+extensionPointServerEditorOverviewPageExtension=Server Editor Overview Page Modifier
 
 # --------------- Wizards and Views ---------------
 
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index b4ca617..230db97 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -11,6 +11,7 @@
   <extension-point id="audio" name="%extensionPointAudio" schema="schema/audio.exsd"/>
   <extension-point id="serverToolTip" name="%extensionPointServerToolTip" schema="schema/serverToolTip.exsd"/>
   <extension-point id="serverCreationWizardPageExtension" name="%extensionPointServerCreationWizardPageExtension" schema="schema/serverCreationWizardPageExtension.exsd"/>
+  <extension-point id="serverEditorOverviewPageModifier" name="%extensionPointServerEditorOverviewPageExtension" schema="schema/serverEditorOverviewPageModifier.exsd"/>
 
 <extension point="org.eclipse.ui.newWizards">
   <category
diff --git a/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd b/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd
new file mode 100644
index 0000000..9bf999f
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd
@@ -0,0 +1,132 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.server.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.wst.server.ui" id="serverEditorOverviewPageModifier" name="Server Editor Overview Page Modifier"/>
+      </appInfo>
+      <documentation>
+         This extension point provides a way for adopters to modify controls on the server editor Overview page.  It provides a mechanism to allow modify the display of some existing UI on the Overview page.
+
+This extension point is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="serverEditorOverviewPageModifier"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a fully qualified identifier of the target extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  an optional identifier of the extension instance
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  an optional name of the extension instance
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="serverEditorOverviewPageModifier">
+      <annotation>
+         <appInfo>
+            <meta.element labelAttribute="name"/>
+         </appInfo>
+      </annotation>
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  specifies a unique identifier for this extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  specifies the fully qualified name of the Java class that extends &lt;samp&gt;org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier&lt;/samp&gt;. The class must have a public 0-arg constructor.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         3.2
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         The following is an example of the extension point:
+
+&lt;pre&gt;
+   &lt;extension
+         point=&quot;org.eclipse.wst.server.ui.serverEditorPageExtension&quot;&gt;
+      &lt;serverEditorOverviewPageModifier
+            id=&quot;org.eclipse.wst.server.ui.test.serverEditorOverviewModifier&quot;
+                        class=&quot;org.eclipse.wst.server.ui.test.internal.serverEditorPageExtension.ServerEditorOverviewPageModifierTest&quot;/&gt;
+   &lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2010 IBM Corporation and others.&lt;br&gt;
+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 
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         Value of the attribute &lt;b&gt;class&lt;/b&gt; must be a fully qualified name of a Java class that extends &lt;code&gt;org.eclipse.wst.server.ui.editor.ServerEditorPageExtension&lt;/code&gt;.
+
+This extension point currently only supports the control on the following fields on the implementation of org.eclipse.wst.server.ui.AbstractUIControl.IUIControlListener.handleUIControlMapChanged(Map&lt;String, UIControlEntry&gt;):
+Server&apos;s host name
+
+This extension point currently only issue property change event on the following property change:
+Server type selection change
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorOverviewPageModifier.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorOverviewPageModifier.java
new file mode 100644
index 0000000..fe9488a
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorOverviewPageModifier.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.editor;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.AbstractUIControl;
+
+/**
+ * A modifier class that allows adopter to modify the behaviour of a UI control on the
+ * server editor page(s).
+ * 
+ * ServerEditorOverviewPageModifier
+ */
+public abstract class ServerEditorOverviewPageModifier extends AbstractUIControl {
+	protected IServerWorkingCopy serverWc = null;
+
+	
+	/**
+	 * The list of editor sections on the server editors that allow inserting custom GUI.
+	 * UI_POSITION
+	 */
+	public enum UI_LOCATION { OVERVIEW, OTHER }
+
+
+	/**
+	 * Create the customer UI on the specified server editor part, either general or other.
+	 * @param position the position on the server creation wizard page that allows inserting custom GUI.
+	 * @param parent parent composite.
+	 * @param location
+	 */
+	public abstract void createControl(UI_LOCATION location, Composite parent);
+	
+	
+	/**
+	* Set the server working copy to the control to allow extension to store the extension values.
+	* @param curServerWc
+	*/
+	public void setServerWorkingCopy(IServerWorkingCopy curServerWc) {
+		serverWc = curServerWc;
+	}
+}
\ No newline at end of file
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 3170c8c..f664829 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2010 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
@@ -31,6 +31,7 @@
 import org.eclipse.wst.server.core.internal.Trace;
 import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
 import org.eclipse.wst.server.core.util.PublishAdapter;
+import org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier;
 import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate;
 import org.eclipse.wst.server.ui.internal.editor.IServerEditorInput;
 import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore;
@@ -91,6 +92,9 @@
 	
 	// Cached copy of all server wizard UI modifier
 	private static List<ServerCreationWizardPageExtension> serverCreationWizardPageExtensions;
+	
+	// Cached copy of all server editor UI modifiers
+	private static List<ServerEditorOverviewPageModifier> serverEditorOverviewPageModifier;
 
 	// cached initial selection provider
 	private static InitialSelectionProvider selectionProvider;
@@ -725,12 +729,23 @@
 	 * @return the list of server creation wizard modifier, or an empty list if none could be found
 	 */
 	public static List<ServerCreationWizardPageExtension> getServerCreationWizardPageExtensions() {
-		if (serverCreationWizardPageExtensions == null) {
+		if (serverCreationWizardPageExtensions == null)
 			loadServerCreationWizardPageExtensions();
-		}
+
 		return serverCreationWizardPageExtensions;
 	}
 
+ 	/**
+	 * Returns the list of server editor modifiers.
+	 *
+	 * @return the list of server editor modifiers, or an empty list if none could be found
+	 */
+	public static List<ServerEditorOverviewPageModifier> getServerEditorOverviewPageModifiers() {
+		if (serverEditorOverviewPageModifier == null)
+			loadServerEditorOverviewPageModifiers();
+		return serverEditorOverviewPageModifier;
+	}
+	
 	/**
 	 * Load the Server creation wizard page modifiers.
 	 */
@@ -748,12 +763,12 @@
 				// Create the class here already since the usage of the server wizard page will need to use all the extensions
 				// in all the calls.  Therefore, there is no need for lazy loading here.
 				ServerCreationWizardPageExtension curExtension = (ServerCreationWizardPageExtension)curConfigElement.createExecutableExtension("class");
-				Trace.trace(Trace.CONFIG, "  Loaded serverCreationWizardPageExtension: " + cf[0].getAttribute("id") + ", loaded class=" + curExtension);
+				Trace.trace(Trace.CONFIG, "  Loaded .serverCreationWizardPageExtension: " + cf[0].getAttribute("id") + ", loaded class=" + curExtension);
 				if (curExtension != null)
 					serverCreationWizardPageExtensions.add(curExtension);
 
 			} catch (Throwable t) {
-				Trace.trace(Trace.SEVERE, "  Could not load serverCreationWizardPageExtension: " + cf[0].getAttribute("id"), t);
+				Trace.trace(Trace.SEVERE, "  Could not load .serverCreationWizardPageExtension: " + cf[0].getAttribute("id"), t);
 			}
 		}
 		
@@ -761,6 +776,34 @@
 	}
 
 	/**
+	 * Load the Server editor page modifiers.
+	 */
+	private static synchronized void loadServerEditorOverviewPageModifiers() {
+		if (serverEditorOverviewPageModifier != null)
+			return;
+		
+		Trace.trace(Trace.CONFIG, "->- Loading .serverEditorOverviewPageModifier extension point ->-");
+		serverEditorOverviewPageModifier = new ArrayList<ServerEditorOverviewPageModifier>();
+		IExtensionRegistry registry = Platform.getExtensionRegistry();
+		IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "serverEditorOverviewPageModifier");
+		
+		for (IConfigurationElement curConfigElement: cf) {
+			try {
+				ServerEditorOverviewPageModifier curExtension = (ServerEditorOverviewPageModifier)curConfigElement.createExecutableExtension("class");
+				Trace.trace(Trace.CONFIG, "  Loaded .serverEditorOverviewPageModifier: " + cf[0].getAttribute("id") + ", loaded class=" + curExtension);
+				if (curExtension != null)
+					serverEditorOverviewPageModifier.add(curExtension);
+
+			} catch (Throwable t) {
+				Trace.trace(Trace.SEVERE, "  Could not load .serverEditorOverviewPageModifier: " + cf[0].getAttribute("id"), t);
+			}
+		}
+		
+		Trace.trace(Trace.CONFIG, "-<- Done loading .serverEditorOverviewPageModifier extension point -<-");
+	}
+	
+	
+	/**
 	 * Load the initial selection provider.
 	 */
 	private static synchronized void loadInitialSelectionProvider() {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java
index db47e6b..8f4a579 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2010 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
@@ -15,6 +15,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
@@ -70,7 +71,10 @@
 import org.eclipse.wst.server.core.internal.ServerPlugin;
 import org.eclipse.wst.server.core.internal.ServerType;
 import org.eclipse.wst.server.core.util.SocketUtil;
+import org.eclipse.wst.server.ui.AbstractUIControl;
+import org.eclipse.wst.server.ui.AbstractUIControl.UIControlEntry;
 import org.eclipse.wst.server.ui.editor.*;
+import org.eclipse.wst.server.ui.AbstractUIControl.IUIControlListener;
 import org.eclipse.wst.server.ui.internal.ContextIds;
 import org.eclipse.wst.server.ui.internal.ImageResource;
 import org.eclipse.wst.server.ui.internal.Messages;
@@ -83,13 +87,17 @@
 import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
 import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
 import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+
 /**
  * Server general editor page.
  */
-public class OverviewEditorPart extends ServerEditorPart {
+public class OverviewEditorPart extends ServerEditorPart implements IUIControlListener {
 	protected Text serverName;
 	protected Text serverConfiguration;
 	protected Text hostname;
+	protected Label hostnameLabel;
+	protected ControlDecoration hostnameDecoration;
 	protected Combo runtimeCombo;
 	protected Button browse;
 	protected Button autoPublishDisable;
@@ -109,6 +117,8 @@
 
 	protected IRuntimeLifecycleListener runtimeListener;
 
+	private IServerType oldServerType;
+	
 	class PublisherContentProvider extends BaseContentProvider {
 		protected Publisher[] pubs;
 		public PublisherContentProvider(Publisher[] pubs) {
@@ -350,10 +360,10 @@
 			whs.setHelp(serverName, ContextIds.EDITOR_SERVER);
 			
 			// hostname
-			createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname);
+			hostnameLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname);
 			
 			hostname = toolkit.createText(composite, server.getHost());
-			final ControlDecoration hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
+			hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
 			data = new GridData(GridData.FILL_HORIZONTAL);
 			data.horizontalSpan = 2;
 			data.horizontalIndent = decorationWidth;
@@ -584,6 +594,16 @@
 				}
 			}
 		}
+		
+		// Insertion of extension widgets. If the page modifier createControl is not implemented still 
+		// add the modifier to the listeners list.
+		List<ServerEditorOverviewPageModifier> pageModifiersLst = ServerUIPlugin.getServerEditorOverviewPageModifiers();
+		for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
+			if(server != null && server.getServerType() != null){
+				curPageModifier.createControl(ServerEditorOverviewPageModifier.UI_LOCATION.OVERVIEW, composite);
+				curPageModifier.setUIControlListener(this);
+			}
+		}
 	}
 
 	protected void createPublishSection(Composite rightColumnComp, FormToolkit toolkit) {
@@ -964,6 +984,12 @@
 				autoPublishEnable.setEnabled(true);
 				autoPublishTime.setEnabled(publishSetting == Server.AUTO_PUBLISH_ENABLE);
 			}
+			
+			List<ServerEditorOverviewPageModifier> pageModifiersLst = ServerUIPlugin.getServerEditorOverviewPageModifiers();
+			for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
+				if(server != null && server.getServerType() != null)
+					curPageModifier.handlePropertyChanged(new PropertyChangeEvent(this, AbstractUIControl.PROP_SERVER_TYPE, oldServerType, server.getServerType()));
+			}
 		}
 		
 		updating = false;
@@ -1034,4 +1060,44 @@
 		else if (serverConfiguration != null)
 			serverConfiguration.setFocus();
 	}
+
+	public String getControlStringValue(String controlId) {
+		if (controlId != null && AbstractUIControl.PROP_HOSTNAME.equals(controlId))
+			return hostname.getText();
+		return null;
+	}
+
+	public void handleUIControlMapChanged(Map<String, UIControlEntry> controlMap) {
+		if (controlMap == null)
+			return;
+		
+		for (String curControlId : controlMap.keySet()) {
+			if (AbstractUIControl.PROP_HOSTNAME.equals(curControlId)) {
+				UIControlEntry curControlEntry = controlMap.get(curControlId);
+				if (hostnameLabel != null)
+					hostnameLabel.setEnabled(curControlEntry.isEnabled());
+				
+				if (hostname != null){
+					if (curControlEntry.getNewTextValue() != null)
+						hostname.setText(curControlEntry.getNewTextValue());
+					
+					hostname.setEnabled(curControlEntry.isEnabled());
+				}
+				
+				if (hostnameDecoration != null){
+					if(curControlEntry.isEnabled())
+						hostnameDecoration.show();
+					else
+						hostnameDecoration.hide();
+				}
+			}
+		}
+	}
+	
+	protected void fireServerWorkingCopyChanged() {
+		List<ServerEditorOverviewPageModifier> pageModifiersLst = ServerUIPlugin.getServerEditorOverviewPageModifiers();
+		for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
+			curPageModifier.setServerWorkingCopy(getServer());
+		}
+	}
 }
\ No newline at end of file