[258651] ServersView2: Better CNF adoption
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 1127a86..4dfb1c6 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -70,16 +70,55 @@
       <possibleChildren>
          <or>
             <instanceof
+                  value="java.lang.Object">
+            </instanceof>
+            <instanceof
                   value="org.eclipse.wst.server.core.IServer">
             </instanceof>
             <instanceof
                   value="org.eclipse.wst.server.ui.internal.view.servers.ModuleServer">
             </instanceof>
-         </or></possibleChildren>
+         </or>
+      </possibleChildren>
+	  <actionProvider
+	            class="org.eclipse.wst.server.ui.internal.cnf.ServerActionProvider"
+	            id="org.eclipse.wst.server.ui.ServersView.ServerActionProvider"
+	            priority="highest">
+			<enablement>
+             <or>
+                <instanceof
+                      value="org.eclipse.wst.server.core.IServer">
+                </instanceof>
+                <instanceof
+                      value="org.eclipse.wst.server.ui.internal.view.servers.ModuleServer">
+                </instanceof>
+                <instanceof
+                      value="org.eclipse.core.resources.IWorkspaceRoot">
+                </instanceof>
+               <adapt
+                     type="java.util.Collection">
+                  <count
+                        value="0">
+                  </count>
+               </adapt>
+             </or>
+            </enablement>
+	  </actionProvider>      
+      <dropAssistant
+             class="org.eclipse.wst.server.ui.internal.cnf.ServersViewDropAdapterAssistant"
+             id="org.eclipse.wst.server.ui.ServersView.DropAssistant">
+          <possibleDropTargets>
+             <or>
+                <instanceof
+                      value="java.lang.Object">
+                </instanceof>
+             </or>
+          </possibleDropTargets>
+       </dropAssistant>
    </navigatorContent>
 </extension>
 
-               <extension
+<extension
       point="org.eclipse.ui.navigator.viewer">
    <viewerContentBinding
          viewerId="org.eclipse.wst.server.ui.ServersView">
@@ -585,5 +624,4 @@
       </enablement>
    </decorator>
 </extension>
-
 </plugin>
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java
index ecee321..e7480ae 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java
@@ -1,45 +1,28 @@
 /*******************************************************************************
- * Copyright (c) 2008,2009 IBM Corporation and others.
+ * Copyright (c) 2009 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
+ *     IBM Corporation - Base Code
+ *     Red Hat - Refactor for CNF
  *******************************************************************************/
 package org.eclipse.wst.server.ui.internal.cnf;
 
 import java.util.Iterator;
 
 import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.*;
 import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.*;
 import org.eclipse.swt.dnd.Clipboard;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.*;
 import org.eclipse.ui.actions.ActionFactory;
 import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.navigator.*;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.ServerPort;
@@ -50,13 +33,20 @@
 import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction;
 import org.eclipse.wst.server.ui.internal.view.servers.*;
 
-/**
- * TODO Angel says: Not currently besing used this code was moved up to the ServersView to get similar support
- * to the old view. If we have an action provider when the ServersView firsts open the ActionProvider has not been 
- * initilized yet.
- *
- */
 public class ServerActionProvider extends CommonActionProvider {
+	public static final String NEW_MENU_ID = "org.eclipse.wst.server.ui.internal.cnf.newMenuId";
+	public static final String SHOW_IN_MENU_ID = "org.eclipse.ui.navigate.showInQuickMenu";
+	public static final String TOP_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.topSectionStart";
+	public static final String TOP_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.topSectionEnd";
+	public static final String EDIT_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnfeditSectionStart";
+	public static final String EDIT_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.editSectionEnd";
+	public static final String CONTROL_SERVER_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlServerSectionStart";
+	public static final String CONTROL_SERVER_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlServerSectionEnd";
+	public static final String SERVER_ETC_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.serverEtcSectionStart";
+	public static final String SERVER_ETC_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.serverEtcSectionEnd";
+	public static final String CONTROL_MODULE_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlModuleSectionStart";
+	public static final String CONTROL_MODULE_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlModuleSectionEnd";
+	
 	private ICommonActionExtensionSite actionSite;
 	private Clipboard clipboard;
 	public ServerActionProvider() {
@@ -125,7 +115,7 @@
 		// create the open action
 		openAction = new OpenAction(provider);
 
-//		// create copy, paste, and delete actions
+		// create copy, paste, and delete actions
 		pasteAction = new PasteAction(shell, provider, clipboard);
 		copyAction = new CopyAction(provider, clipboard, pasteAction);
 		deleteAction = new DeleteAction(shell, provider);
@@ -161,13 +151,10 @@
 			cm.add(actions[i]);
 	}
 	
-	private static void fillNewContextMenu(Shell shell, ISelection selection, IMenuManager menu) {
-		IAction newServerAction = new NewServerWizardAction();
-		newServerAction.setText(Messages.actionNewServer);
-		menu.add(newServerAction);
-	}
-
 	public void fillContextMenu(IMenuManager menu) {
+		// This is a temp workaround to clean up the default group that are provided by CNF		
+		menu.removeAll();
+		
 		ICommonViewerSite site = actionSite.getViewSite();
 		IStructuredSelection selection = null;
 		Shell shell = actionSite.getViewSite().getShell();
@@ -193,10 +180,57 @@
 				module = null;
 			}
 		}
-		
-		// new action
-		MenuManager newMenu = new MenuManager(Messages.actionNew);
-		fillNewContextMenu(null, selection, newMenu);
+
+		menu.add(invisibleSeparator(TOP_SECTION_START_SEPARATOR));
+		addTopSection(menu, server, module);
+		menu.add(invisibleSeparator(TOP_SECTION_END_SEPARATOR));
+		menu.add(new Separator());
+
+		if (server != null && module == null) {
+			menu.add(invisibleSeparator(EDIT_SECTION_START_SEPARATOR));
+			menu.add(copyAction);
+			menu.add(pasteAction);
+			menu.add(deleteAction);
+			menu.add(renameAction);
+			menu.add(invisibleSeparator(EDIT_SECTION_END_SEPARATOR));
+
+			menu.add(new Separator());
+			
+			menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_START_SEPARATOR));
+			for (int i = 0; i < actions.length; i++)
+				menu.add(actions[i]);
+			menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_END_SEPARATOR));
+			
+			menu.add(new Separator());
+			
+			menu.add(invisibleSeparator(SERVER_ETC_SECTION_START_SEPARATOR));
+			menu.add(actionModifyModules);
+			addMonitor(server, menu, shell);
+			menu.add(invisibleSeparator(SERVER_ETC_SECTION_END_SEPARATOR));
+			menu.add(new Separator());
+			
+		} else if (server != null && module != null) {
+			
+			menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_START_SEPARATOR));
+			menu.add(new StartModuleAction(server, module));
+			menu.add(new StopModuleAction(server, module));			
+			menu.add(new RestartModuleAction(server, module));
+			if(module.length == 1) {
+				menu.add(new RemoveModuleAction(shell, server, module[0]));
+			}
+			menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_END_SEPARATOR));
+		}
+	
+		menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+		menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));
+		menu.add(propertiesAction);
+	}
+
+	protected void addTopSection(IMenuManager menu, IServer server, IModule[] module) {
+		MenuManager newMenu = new MenuManager(Messages.actionNew, NEW_MENU_ID);
+		IAction newServerAction = new NewServerWizardAction();
+		newServerAction.setText(Messages.actionNewServer);
+		newMenu.add(newServerAction);
 		menu.add(newMenu);
 		
 		// open action
@@ -208,88 +242,58 @@
 			final IBindingService bindingService = (IBindingService) workbench
 					.getAdapter(IBindingService.class);
 			final TriggerSequence[] activeBindings = bindingService
-					.getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
+					.getActiveBindingsFor(SHOW_IN_MENU_ID);
 			if (activeBindings.length > 0) {
 				text += "\t" + activeBindings[0].format();
 			}
 			
-			MenuManager showInMenu = new MenuManager(text);
+			MenuManager showInMenu = new MenuManager(text, SHOW_IN_MENU_ID);
 			showInMenu.add(showInConsoleAction);
 			showInMenu.add(showInDebugAction);
-			//IActionBars actionBars = getViewSite().getActionBars();
-			//actionBars.setGlobalActionHandler("group.show", showInMenu);
 			menu.add(showInMenu);
-			menu.add(new Separator());
-		} else
-			menu.add(new Separator());
-		
-		if (server != null) {
-			if (module == null) {
-				menu.add(copyAction);
-				menu.add(pasteAction);
-				menu.add(deleteAction);
-				menu.add(renameAction);
-			} else if (module.length == 1)
-				menu.add(new RemoveModuleAction(shell, server, module[0]));
-			menu.add(new Separator());
 		}
-		
-		if (server != null && module == null) {
-			// server actions
-			for (int i = 0; i < actions.length; i++)
-				menu.add(actions[i]);
+	}
+	
+	protected void addMonitor(IServer server, IMenuManager menu, Shell shell) {
+
+		if (server.getServerType() != null) {
+			final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
 			
-			menu.add(new Separator());
-			menu.add(actionModifyModules);
-			
-			// monitor
-			if (server.getServerType() != null) {
-				final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
-				
-				final IServer server2 = server;
-				final Shell shell2 = shell;
-				menuManager.addMenuListener(new IMenuListener() {
-					public void menuAboutToShow(IMenuManager manager) {
-						menuManager.removeAll();
-						if (server2.getAdapter(ServerDelegate.class) != null) {
-							ServerPort[] ports = server2.getServerPorts(null);
-							if (ports != null) {
-								int size = ports.length;
-								for (int i = 0; i < size; i++) {
-									if (!ports[i].isAdvanced())
-										menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
-								}
+			final IServer server2 = server;
+			final Shell shell2 = shell;
+			menuManager.addMenuListener(new IMenuListener() {
+				public void menuAboutToShow(IMenuManager manager) {
+					menuManager.removeAll();
+					if (server2.getAdapter(ServerDelegate.class) != null) {
+						ServerPort[] ports = server2.getServerPorts(null);
+						if (ports != null) {
+							int size = ports.length;
+							for (int i = 0; i < size; i++) {
+								if (!ports[i].isAdvanced())
+									menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
 							}
 						}
-						
-						if (menuManager.isEmpty())
-							menuManager.add(noneAction);
-						
-						menuManager.add(new Separator());
-						menuManager.add(monitorPropertiesAction);
 					}
-				});
-				
-				// add an initial menu item so that the menu appears correctly
-				noneAction.setEnabled(false);
-				menuManager.add(noneAction);
-				menu.add(menuManager);
-			}
+					
+					if (menuManager.isEmpty())
+						menuManager.add(noneAction);
+					
+					menuManager.add(new Separator());
+					menuManager.add(monitorPropertiesAction);
+				}
+			});
+			
+			// add an initial menu item so that the menu appears correctly
+			noneAction.setEnabled(false);
+			menuManager.add(noneAction);
+			menu.add(menuManager);
 		}
-		
-		if (server != null && module != null) {
-			menu.add(new Separator());
-			menu.add(new StartModuleAction(server, module));
-			menu.add(new StopModuleAction(server, module));			
-			menu.add(new RestartModuleAction(server, module));
-		}
-		
-		menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
-		menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));
-		
-		if (server != null) {
-			menu.add(new Separator());
-			menu.add(propertiesAction);
-		}
+	}
+	
+	
+	private Separator invisibleSeparator(String s) {
+		Separator sep = new Separator(s);
+		sep.setVisible(false);
+		return sep;
 	}
 }
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java
index 112fed8..be923da 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java
@@ -11,34 +11,32 @@
 package org.eclipse.wst.server.ui.internal.cnf;
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IDecoratorManager;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.navigator.CommonNavigator;
 import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.IPublishListener;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerEvent;
 import org.eclipse.wst.server.core.internal.Server;
 import org.eclipse.wst.server.core.internal.UpdateServerJob;
-import org.eclipse.wst.server.core.model.ServerDelegate;
 import org.eclipse.wst.server.core.util.PublishAdapter;
-import org.eclipse.wst.server.ui.internal.*;
-import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction;
-import org.eclipse.wst.server.ui.internal.view.servers.*;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerToolTip;
+import org.eclipse.wst.server.ui.internal.Trace;
 /**
  * A view of servers, their modules, and status.
  */
@@ -46,12 +44,6 @@
 	
 	protected CommonViewer tableViewer;
 	
-	protected Clipboard clipboard;
-	
-	protected Action noneAction = new Action(Messages.dialogMonitorNone) {
-		// dummy action
-	};
-	
 	protected IServerLifecycleListener serverResourceListener;
 	protected IPublishListener publishListener;
 	protected IServerListener serverListener;
@@ -61,13 +53,6 @@
 	protected static Set<String> starting = new HashSet<String>(4);
 	protected boolean animationActive = false;
 	protected boolean stopAnimation = false;
-	
-	
-	// actions on a server
-	protected Action[] actions;
-	protected Action actionModifyModules;
-	protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction, monitorPropertiesAction;
-	protected Action copyAction, pasteAction, deleteAction, renameAction;
 
 	/**
 	 * ServersView constructor comment.
@@ -78,7 +63,6 @@
 
 	@Override
 	public void createPartControl(Composite parent) {
-		clipboard = new Clipboard(Display.getCurrent());
 		super.createPartControl(parent);
 		deferInitialization();
 	}
@@ -117,26 +101,9 @@
 	
 	protected void deferredInitialize() {
 		addListener();
-		
-		// TODO Angel says: is this the best place for this? 
 		tableViewer = getCommonViewer();
-		
-		MenuManager menuManager = new MenuManager("#PopupMenu");
-		menuManager.setRemoveAllWhenShown(true);
-		final Shell shell = tableViewer.getTree().getShell();
-		menuManager.addMenuListener(new IMenuListener() {
-			public void menuAboutToShow(IMenuManager mgr) {
-				fillContextMenu(shell, mgr);
-			}
-		});
-		Menu menu = menuManager.createContextMenu(tableViewer.getTree());
-		tableViewer.getTree().setMenu(menu);
-		getSite().registerContextMenu(menuManager, tableViewer);
 		getSite().setSelectionProvider(tableViewer);
 		
-		//TODO Angel: What to do here?
-		//initDragAndDrop();
-		
 		// init the tooltip
 		ServerToolTip toolTip = new ServerToolTip(tableViewer.getTree());
 		toolTip.setShift(new Point(10, 3));
@@ -306,202 +273,6 @@
 		}
 	}
 	
-	protected void fillContextMenu(Shell shell, IMenuManager menu) {
-		// get selection but avoid no selection or multiple selection
-		IServer server = null;
-		IModule[] module = null;
-		IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
-		if (!selection.isEmpty()) {
-			Iterator iterator = selection.iterator();
-			Object obj = iterator.next();
-			if (obj instanceof IServer)
-				server = (IServer) obj;
-			if (obj instanceof ModuleServer) {
-				ModuleServer ms = (ModuleServer) obj;
-				server = ms.server;
-				module = ms.module;
-			}
-			if (iterator.hasNext()) {
-				server = null;
-				module = null;
-			}
-		}
-		
-		// new action
-		MenuManager newMenu = new MenuManager(Messages.actionNew);
-		fillNewContextMenu(null, selection, newMenu);
-		menu.add(newMenu);
-		
-		// open action
-		if (server != null && module == null) {
-			menu.add(openAction);
-			
-			String text = Messages.actionShowIn;
-			final IWorkbench workbench = PlatformUI.getWorkbench();
-			final IBindingService bindingService = (IBindingService) workbench
-					.getAdapter(IBindingService.class);
-			final TriggerSequence[] activeBindings = bindingService
-					.getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
-			if (activeBindings.length > 0) {
-				text += "\t" + activeBindings[0].format();
-			}
-			
-			MenuManager showInMenu = new MenuManager(text);
-			showInMenu.add(showInConsoleAction);
-			showInMenu.add(showInDebugAction);
-			
-			menu.add(showInMenu);
-			menu.add(new Separator());
-		} else
-			menu.add(new Separator());
-		
-		if (server != null) {
-			if (module == null) {
-				menu.add(copyAction);
-				menu.add(pasteAction);
-				menu.add(deleteAction);
-				menu.add(renameAction);
-			} else if (module.length == 1)
-				menu.add(new RemoveModuleAction(shell, server, module[0]));
-			menu.add(new Separator());
-		}
-		
-		if (server != null && module == null) {
-			// server actions
-			for (int i = 0; i < actions.length; i++)
-				menu.add(actions[i]);
-			
-			menu.add(new Separator());
-			menu.add(actionModifyModules);
-			
-			// monitor
-			if (server.getServerType() != null) {
-				final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
-				
-				final IServer server2 = server;
-				final Shell shell2 = shell;
-				menuManager.addMenuListener(new IMenuListener() {
-					public void menuAboutToShow(IMenuManager manager) {
-						menuManager.removeAll();
-						if (server2.getAdapter(ServerDelegate.class) != null) {
-							ServerPort[] ports = server2.getServerPorts(null);
-							if (ports != null) {
-								int size = ports.length;
-								for (int i = 0; i < size; i++) {
-									if (!ports[i].isAdvanced())
-										menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
-								}
-							}
-						}
-						
-						if (menuManager.isEmpty())
-							menuManager.add(noneAction);
-						
-						menuManager.add(new Separator());
-						menuManager.add(monitorPropertiesAction);
-					}
-				});
-				
-				// add an initial menu item so that the menu appears correctly
-				noneAction.setEnabled(false);
-				menuManager.add(noneAction);
-				menu.add(menuManager);
-			}
-		}
-		
-		if (server != null && module != null) {
-			menu.add(new Separator());
-			menu.add(new StartModuleAction(server, module));
-			menu.add(new StopModuleAction(server, module));			
-			menu.add(new RestartModuleAction(server, module));
-		}
-		
-		menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
-		menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));
-		
-		if (server != null) {
-			menu.add(new Separator());
-			menu.add(propertiesAction);
-		}
-	}
-
-	
-	private static void fillNewContextMenu(Shell shell, ISelection selection, IMenuManager menu) {
-		IAction newServerAction = new NewServerWizardAction();
-		newServerAction.setText(Messages.actionNewServer);
-		menu.add(newServerAction);
-	}
-	
-	@Override
-	protected ActionGroup createCommonActionGroup() {
-		CommonViewer provider = getCommonViewer();
-		Shell shell = getSite().getShell();
-		IActionBars actionBars = getViewSite().getActionBars();
-		
-		actions = new Action[6];
-		// create the start actions
-		actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE);
-		actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug", actions[0]);
-		actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE);
-		actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]);
-		actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE);
-		
-		// create the stop action
-		actions[3] = new StopAction(shell, provider);
-		actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop", actions[3]);
-		
-		// create the publish actions
-		actions[4] = new PublishAction(shell, provider);
-		actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish", actions[4]);
-		actions[5] = new PublishCleanAction(shell, provider);
-		
-		// create the open action
-		openAction = new OpenAction(provider);
-		actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open", openAction);
-		
-		// create copy, paste, and delete actions
-		pasteAction = new PasteAction(shell, provider,  clipboard);
-		copyAction = new CopyAction(provider, clipboard, pasteAction);
-		deleteAction = new DeleteAction(shell, provider);
-		renameAction = new RenameAction(shell, getCommonViewer(), provider);
-		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
-		actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
-		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
-		actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
-		
-		// create the other actions
-		actionModifyModules = new ModuleSloshAction(shell, provider);
-		showInConsoleAction = new ShowInConsoleAction(provider);
-		showInDebugAction = new ShowInDebugAction(provider);
-		
-		// create the properties action
-		propertiesAction = new PropertiesAction(shell, provider);
-		actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction);
-		monitorPropertiesAction = new PropertiesAction(shell, "org.eclipse.wst.server.ui.properties.monitor", provider);
-		
-		// add toolbar buttons
-		IContributionManager cm = actionBars.getToolBarManager();
-		for (int i = 0; i < actions.length - 1; i++)
-			cm.add(actions[i]);
-		
-		cm.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
-		return super.createCommonActionGroup();
-	}
-
-	@Override
-	protected void handleDoubleClick(DoubleClickEvent anEvent) {
-		try {
-			IStructuredSelection sel = (IStructuredSelection) anEvent.getSelection();
-			Object data = sel.getFirstElement();
-			if (!(data instanceof IServer))
-				return;
-			IServer server = (IServer) data;
-			ServerUIPlugin.editServer(server);
-		} catch (Exception e) {
-			Trace.trace(Trace.SEVERE, "Could not open server", e);
-		}
-	}
-	
 	protected void addServer(final IServer server) {
 		Display.getDefault().asyncExec(new Runnable() {
 			public void run() {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersViewDropAdapterAssistant.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersViewDropAdapterAssistant.java
new file mode 100644
index 0000000..80c905a
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersViewDropAdapterAssistant.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2009 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 - Base Code
+ *     Red Hat - Refactor for CNF
+ */
+
+package org.eclipse.wst.server.ui.internal.cnf;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.ui.internal.EclipseUtil;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate;
+
+public class ServersViewDropAdapterAssistant extends CommonDropAdapterAssistant {
+
+	private List dndElementList;
+
+	public IStatus validatePluginTransferDrop(
+			IStructuredSelection aDragSelection, Object aDropTarget) {
+		initializeSelection(aDragSelection);
+		return internalValidate(aDropTarget, dndElementList);
+	}
+
+	public IStatus validateDrop(Object target, int operation,
+			TransferData transferType) {
+		if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
+			ISelection s = LocalSelectionTransfer.getTransfer().getSelection();
+			initializeSelection(s);
+			return internalValidate(target, dndElementList);
+		}
+		return Status.CANCEL_STATUS;
+	}
+
+	protected void initializeSelection(ISelection s) {
+		if (dndElementList != null)
+			return;
+		if (!(s instanceof IStructuredSelection)) {
+			dndElementList = Collections.EMPTY_LIST;
+			return;
+		}
+		dndElementList = ((IStructuredSelection) s).toList();
+	}
+
+	protected IStatus internalValidate(Object target, List elements) {
+		if (target instanceof IServer) {
+			IServer server = (IServer) target;
+			Object next;
+			if (elements != null) {
+				Iterator i = elements.iterator();
+				while (i.hasNext()) {
+					next = i.next();
+					IModuleArtifact[] moduleArtifacts = ServerPlugin
+							.getModuleArtifacts(next);
+					if (moduleArtifacts != null && moduleArtifacts.length > 0) {
+						for (int j = 0; j < moduleArtifacts.length; j++) {
+							if (moduleArtifacts[j] != null
+									&& moduleArtifacts[j].getModule() != null) {
+								IModuleType[] moduleTypes = server
+										.getServerType().getRuntimeType()
+										.getModuleTypes();
+								if (ServerUtil.isSupportedModule(moduleTypes,
+										moduleArtifacts[j].getModule()
+												.getModuleType())) {
+									return Status.OK_STATUS;
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		clear();
+		return Status.CANCEL_STATUS;
+	}
+
+	public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent dropTargetEvent, Object target) {
+		IStatus status = internalHandleDrop(target, dndElementList);
+		if (status.isOK())
+			dropTargetEvent.detail = DND.DROP_NONE;
+		return status;
+	}
+
+	public IStatus handlePluginTransferDrop(IStructuredSelection aDragSelection, Object aDropTarget) {
+		return internalHandleDrop(aDropTarget, dndElementList);
+	}
+
+	protected IStatus internalHandleDrop(Object target, List elements) {
+		boolean b = false;
+		if (target instanceof IServer) {
+			b = true;
+			if (dndElementList != null) {
+				Iterator iterator = elements.iterator();
+				while (iterator.hasNext()) {
+					Object data2 = iterator.next();
+					if (!doRunOnServerAction((IServer) target, data2))
+						b = false;
+				}
+			}
+		}
+		clear();
+		return b ? Status.OK_STATUS : Status.CANCEL_STATUS;
+	}
+
+	private void clear() {
+		dndElementList = null;
+	}
+
+	protected boolean doRunOnServerAction(IServer server, Object data) {
+		// check if the selection is a project (module) that we can add to the server
+		IProject project = (IProject) Platform.getAdapterManager().getAdapter(
+				data, IProject.class);
+		if (project != null) {
+			IModule[] modules = ServerUtil.getModules(project);
+			if (modules != null && modules.length == 1) {
+				try {
+					IServerWorkingCopy wc = server.createWorkingCopy();
+					IModule[] parents = wc.getRootModules(modules[0], null);
+					if (parents == null || parents.length == 0)
+						return false;
+
+					if (ServerUtil.containsModule(server, parents[0], null))
+						return false;
+
+					IModule[] add = new IModule[] { parents[0] };
+					if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) {
+						wc.modifyModules(modules, null, null);
+						wc.save(false, null);
+						return true;
+					}
+				} catch (final CoreException ce) {
+					final Shell shell = getShell();
+					shell.getDisplay().asyncExec(new Runnable() {
+						public void run() {
+							EclipseUtil.openError(shell, ce
+									.getLocalizedMessage());
+						}
+					});
+					return true;
+				}
+			}
+		}
+
+		// otherwise, try Run on Server
+		final IServer finalServer = server;
+		RunOnServerActionDelegate ros = new RunOnServerActionDelegate() {
+			public IServer getServer(IModule module,
+					IModuleArtifact moduleArtifact, IProgressMonitor monitor)
+					throws CoreException {
+				if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer,
+						launchMode))
+					return null;
+
+				if (!ServerUtil.containsModule(finalServer, module, monitor)) {
+					IServerWorkingCopy wc = finalServer.createWorkingCopy();
+					try {
+						ServerUtil.modifyModules(wc, new IModule[] { module },
+								new IModule[0], monitor);
+						wc.save(false, monitor);
+					} catch (CoreException ce) {
+						throw ce;
+					}
+				}
+
+				return finalServer;
+			}
+		};
+		Action action = new Action() {
+			// dummy action
+		};
+		ros.selectionChanged(action, new StructuredSelection(data));
+
+		ros.run(action);
+		return true;
+	}
+}