Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-11-04 19:29:21 +0000
committerDarin Wright2009-11-04 19:29:21 +0000
commit7f796b755f58d4614db2ff3938811245e06177f5 (patch)
treed8df51b182a2d3632b981d66b3db537a43b4a9ad
parentdb03260337a0c8fe44d7c115ab8c6e2496078fe1 (diff)
downloadeclipse.platform.debug-7f796b755f58d4614db2ff3938811245e06177f5.tar.gz
eclipse.platform.debug-7f796b755f58d4614db2ff3938811245e06177f5.tar.xz
eclipse.platform.debug-7f796b755f58d4614db2ff3938811245e06177f5.zip
Bug 294218 - "Relaunch" option launches too many instances
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractDebugActionDelegate.java18
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java40
2 files changed, 44 insertions, 14 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractDebugActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractDebugActionDelegate.java
index 84d2e9ebd..68b582c3d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractDebugActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractDebugActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -146,7 +146,7 @@ public abstract class AbstractDebugActionDelegate implements IViewActionDelegate
*/
protected void update(IAction action, ISelection s) {
if (s instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection)s;
+ IStructuredSelection ss = getTargetSelection((IStructuredSelection)s);
action.setEnabled(getEnableStateForSelection(ss));
setSelection(ss);
} else {
@@ -156,6 +156,20 @@ public abstract class AbstractDebugActionDelegate implements IViewActionDelegate
}
/**
+ * Returns a selection this operation should act on based on the given selection.
+ * Provides an opportunity for actions to translate the selection/targets of the
+ * operation.
+ * <p>
+ * By default, the original selection is returned. Subclasses may override.
+ * </p>
+ * @param s selection
+ * @return selection to operate on
+ */
+ protected IStructuredSelection getTargetSelection(IStructuredSelection s) {
+ return s;
+ }
+
+ /**
* Performs the specific action on this element.
*/
protected abstract void doAction(Object element) throws DebugException;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java
index bae103538..ca18fc06b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RelaunchActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -11,13 +11,17 @@
package org.eclipse.debug.internal.ui.actions;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
public class RelaunchActionDelegate extends AbstractDebugActionDelegate {
@@ -42,17 +46,29 @@ public class RelaunchActionDelegate extends AbstractDebugActionDelegate {
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
- ILaunch launch= null;
- if (element instanceof ILaunch) {
- launch= (ILaunch)element;
- } else if (element instanceof IDebugElement) {
- launch= ((IDebugElement)element).getLaunch();
- } else if (element instanceof IProcess) {
- launch= ((IProcess)element).getLaunch();
- }
-
+ ILaunch launch= DebugUIPlugin.getLaunch(element);
return launch != null && launch.getLaunchConfiguration() != null && LaunchConfigurationManager.isVisible(launch.getLaunchConfiguration());
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#getTargetSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected IStructuredSelection getTargetSelection(IStructuredSelection s) {
+ if (s.isEmpty()) {
+ return s;
+ }
+ Set dups = new LinkedHashSet();
+ Iterator iterator = s.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ ILaunch launch = DebugUIPlugin.getLaunch(object);
+ if (launch == null) {
+ return s;
+ }
+ dups.add(launch);
+ }
+ return new StructuredSelection(dups.toArray());
+ }
/**
* @see AbstractDebugActionDelegate#getErrorDialogMessage()

Back to the top