Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2011-09-06 21:16:45 +0000
committerPawel Piech2011-09-06 21:16:45 +0000
commit7a5ccc300f97a6f23b4d515091009df10d385a5b (patch)
treecb4c3ab19c443249839caa98a1f470c455befbaa
parent8dfa641ff497d7f205952186bf5a49fb0c04f7bd (diff)
downloadeclipse.platform.debug-7a5ccc300f97a6f23b4d515091009df10d385a5b.tar.gz
eclipse.platform.debug-7a5ccc300f97a6f23b4d515091009df10d385a5b.tar.xz
eclipse.platform.debug-7a5ccc300f97a6f23b4d515091009df10d385a5b.zip
Bug 324959 - Terminate and Remove doesn't always terminate (but always removes)
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java43
1 files changed, 32 insertions, 11 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java
index 2c85d09b4..3155711c3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java
@@ -22,6 +22,7 @@ import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
import org.eclipse.debug.ui.actions.DebugCommandAction;
+import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
@@ -81,6 +82,37 @@ public class TerminateAndRemoveAction extends DebugCommandAction {
return ITerminateHandler.class;
}
+ public void debugContextChanged(DebugContextEvent event) {
+ boolean isAllTerminated = true;
+ ISelection context = event.getContext();
+ if (context instanceof IStructuredSelection) {
+ Object[] elements = ((IStructuredSelection)context).toArray();
+ for (int i = 0; i < elements.length; i++) {
+ if (!isTerminated(elements[i])) {
+ isAllTerminated = false;
+ break;
+ }
+ }
+ }
+ // IF all elements are terminated, we don't need to query the terminate handler, just
+ // enable the action, which whill just remove the terminated launches (bug 324959).
+ fCanTerminate = !isAllTerminated;
+ if (isAllTerminated) {
+ setEnabled(true);
+ } else {
+ super.debugContextChanged(event);
+ }
+ }
+
+ protected boolean isTerminated(Object element) {
+ ILaunch launch = DebugUIPlugin.getLaunch(element);
+ if (launch != null) {
+ return launch.isTerminated();
+ }
+ return false;
+ }
+
+
protected void postExecute(IRequest request, Object[] targets) {
IStatus status = request.getStatus();
if(status == null || status.isOK()) {
@@ -93,17 +125,6 @@ public class TerminateAndRemoveAction extends DebugCommandAction {
}
/* (non-Javadoc)
- * @see org.eclipse.debug.ui.actions.DebugCommandAction#setEnabled(boolean)
- */
- public void setEnabled(boolean enabled) {
- synchronized (this) {
- fCanTerminate = enabled;
- }
- // action is always enabled... just depends whether terminate is required first.
- super.setEnabled(true);
- }
-
- /* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.DebugCommandAction#runWithEvent(org.eclipse.swt.widgets.Event)
*/
public void runWithEvent(Event event) {

Back to the top