[286960] Cannot delete a module using the delete key button on servers view.
diff --git a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
index 08f5c3d..92e4079 100644
--- a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wst.server.ui; singleton:=true
-Bundle-Version: 1.1.5.qualifier
+Bundle-Version: 1.1.6.qualifier
Bundle-Activator: org.eclipse.wst.server.ui.internal.ServerUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/GlobalDeleteAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/GlobalDeleteAction.java
new file mode 100644
index 0000000..4666249
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/GlobalDeleteAction.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal.view.servers;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.SelectionProviderAction;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.Messages;
+/**
+ * This global delete action handles both the server and module deletion.
+ */
+public class GlobalDeleteAction extends SelectionProviderAction {
+ protected Shell shell;
+ private DeleteAction serverDeleteAction = null;
+ private boolean isRemoveServer = false;
+
+ public GlobalDeleteAction(Shell shell, ISelectionProvider selectionProvider) {
+ super(selectionProvider, Messages.actionDelete);
+ this.shell = shell;
+ setEnabled(false);
+ serverDeleteAction = new DeleteAction(shell, selectionProvider);
+ }
+
+ private boolean isRemoveModuleActionEnabled(IStructuredSelection sel) {
+ if (sel == null || sel.isEmpty())
+ return false;
+
+ // get selection but avoid no selection or multiple selection
+ IModule[] moduleArray = null;
+ Iterator iterator = sel.iterator();
+ Object obj = iterator.next();
+ if (obj instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) obj;
+ moduleArray = ms.module;
+ }
+
+ if (iterator.hasNext()) {
+ moduleArray = null;
+ }
+
+ return (moduleArray == null || moduleArray.length == 1);
+ }
+
+ /**
+ * Update the enabled state.
+ *
+ * @param sel a selection
+ */
+ public void selectionChanged(IStructuredSelection sel) {
+ if (sel.isEmpty()) {
+ setEnabled(false);
+ return;
+ }
+
+ // Check if the delete action is enabled or not.
+ serverDeleteAction.selectionChanged(sel);
+
+ if (serverDeleteAction.isEnabled()) {
+ // The server deletion action is already enabled.
+ isRemoveServer = true;
+ setEnabled(true);
+ return;
+ }
+
+ // Check the remove module action.
+ if (isRemoveModuleActionEnabled(sel)) {
+ isRemoveServer = false;
+ setEnabled(true);
+ } else {
+ setEnabled(false);
+ }
+ }
+
+ public void run() {
+ if (isRemoveServer) {
+ // Run the server delete action;
+ serverDeleteAction.run();
+ return;
+ }
+ // get selection but avoid no selection or multiple selection
+ IServer server = null;
+ IModule[] moduleArray = null;
+ IStructuredSelection sel = getStructuredSelection();
+ if (!sel.isEmpty()) {
+ Iterator iterator = sel.iterator();
+ Object obj = iterator.next();
+
+ // and the method calls serverDeleteAction, then returns
+ if (obj instanceof IServer)
+ server = (IServer) obj;
+ if (obj instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) obj;
+ server = ms.server; // even though ms.server is public, let's stick to the getServer call
+ moduleArray = ms.module;
+ }
+
+ if (iterator.hasNext()) {
+ server = null;
+ moduleArray = null;
+ }
+ }
+
+ if (moduleArray != null && moduleArray.length == 1) {
+ new RemoveModuleAction(shell, server, moduleArray[0]).run();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java
index 5d754ad..21a1fa9 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -68,7 +68,7 @@
// actions on a server
protected Action[] actions;
protected Action actionModifyModules;
- protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction, monitorPropertiesAction;
+ protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction, monitorPropertiesAction, globalDeleteAction;
protected Action copyAction, pasteAction, deleteAction, renameAction;
/**
@@ -289,10 +289,13 @@
pasteAction = new PasteAction(shell, provider, tableViewer.clipboard);
copyAction = new CopyAction(provider, tableViewer.clipboard, pasteAction);
deleteAction = new DeleteAction(shell, provider);
+ // Create a second delete action that can act in modules, when the delete key is pressed
+ // the old DeleteAction only works for servers see bug# 286960
+ globalDeleteAction = new GlobalDeleteAction(shell, provider);
renameAction = new RenameAction(shell, tableViewer, provider);
actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
- actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), globalDeleteAction);
actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
// create the other actions