1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-19 06:05:56 +02:00

Bug 466089 - Stop only launches for the active config.

Turns out to be pretty easy, just check the config for each launch
and stop the ones that match the active config.

Change-Id: Ib74a31405382b2d1996b257f7e8ad1d85a23e6c6
This commit is contained in:
Doug Schaefer 2015-05-01 12:07:06 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent f2b778e3c7
commit e8eec12ec4

View file

@ -14,6 +14,7 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@ -22,14 +23,16 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.launchbar.core.internal.LaunchBarManager;
import org.eclipse.launchbar.ui.internal.Activator;
public class StopActiveCommandHandler extends AbstractHandler {
private ILaunchBarManager launchBarManager;
private LaunchBarManager launchBarManager;
public StopActiveCommandHandler() {
launchBarManager = Activator.getService(ILaunchBarManager.class);
launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
}
@Override
@ -48,16 +51,23 @@ public class StopActiveCommandHandler extends AbstractHandler {
if (activeLaunches != null && activeLaunches.length > 0) {
new Job("Stopping launches") {
protected IStatus run(IProgressMonitor monitor) {
// TODO only stop the launches for the active launch descriptor
// Not sure we have the API to map that out yet.
for (ILaunch launch : activeLaunches) {
try {
ILaunchConfiguration activeConfig = launchBarManager.getActiveLaunchConfiguration();
for (ILaunch launch : activeLaunches) {
ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
if (launchConfig.equals(activeConfig)) {
launch.terminate();
} catch (DebugException e) {
return e.getStatus();
} else if (launchConfig instanceof ILaunchConfigurationWorkingCopy) {
// There are evil delegates that use a working copy for scratch storage
if (((ILaunchConfigurationWorkingCopy) launchConfig).getOriginal().equals(activeConfig)) {
launch.terminate();
}
}
}
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
};
}.schedule();
}