[394273] Delete dialog invoked by Del key is not located correctly
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 e7b9253..290fbd2 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,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 IBM Corporation and others.
+ * Copyright (c) 2009, 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
@@ -122,7 +122,7 @@
// create copy, paste, and delete actions
pasteAction = new PasteAction(shell, provider, clipboard);
copyAction = new CopyAction(provider, clipboard, pasteAction);
- globalDeleteAction = new GlobalDeleteAction(shell, provider);
+ globalDeleteAction = new GlobalDeleteAction(tableViewer, provider);
renameAction = new RenameAction(shell, tableViewer, provider);
// create the other actions
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
index 2a98d98..a639c91 100644
--- 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
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -32,11 +33,11 @@
* This global delete action handles both the server and module deletion.
*/
public class GlobalDeleteAction extends SelectionProviderAction {
- private Shell shell;
+ private TreeViewer viewer;
- public GlobalDeleteAction(Shell shell, ISelectionProvider selectionProvider) {
+ public GlobalDeleteAction(TreeViewer viewer, ISelectionProvider selectionProvider) {
super(selectionProvider, Messages.actionDelete);
- this.shell = shell;
+ this.viewer = viewer;
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
@@ -101,12 +102,19 @@
if( moduleList != null ) {
IServer s = ((ModuleServer)sel.getFirstElement()).getServer();
IModule[] asArray = moduleList.toArray(new IModule[moduleList.size()]);
- new RemoveModuleAction(shell, s, asArray).run();
+ new RemoveModuleAction(getShell(), s, asArray).run();
}
}
}
}
+ private Shell getShell() {
+ if (viewer != null && !viewer.getControl().isDisposed()) {
+ return viewer.getTree().getShell();
+ }
+ return null;
+ }
+
private IFolder[] getConfigurationsFor(IServer[] serverArr) {
List<IFolder> list = new ArrayList<IFolder>();
for( int i = 0; i < serverArr.length; i++ ) {
@@ -196,7 +204,7 @@
// No check is made for valid parameters at this point, since if there is a failure, it
// should be output to the error log instead of failing silently.
- DeleteServerDialog dsd = new DeleteServerDialog(shell, servers, getConfigurationsFor(servers));
+ DeleteServerDialog dsd = new DeleteServerDialog(getShell(), servers, getConfigurationsFor(servers));
dsd.open();
}
}
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 7dd16ac..bfc3b50 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, 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
@@ -286,7 +286,7 @@
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);
+ globalDeleteAction = new GlobalDeleteAction(tableViewer, provider);
renameAction = new RenameAction(shell, tableViewer, provider);
actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);