1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-20 06:35:50 +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.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -22,21 +23,23 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; 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; import org.eclipse.launchbar.ui.internal.Activator;
public class StopActiveCommandHandler extends AbstractHandler { public class StopActiveCommandHandler extends AbstractHandler {
private ILaunchBarManager launchBarManager; private LaunchBarManager launchBarManager;
public StopActiveCommandHandler() { public StopActiveCommandHandler() {
launchBarManager = Activator.getService(ILaunchBarManager.class); launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
} }
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
stop(); stop();
return null; return null;
} }
public void stop() { public void stop() {
stopBuild(); stopBuild();
@ -48,16 +51,23 @@ public class StopActiveCommandHandler extends AbstractHandler {
if (activeLaunches != null && activeLaunches.length > 0) { if (activeLaunches != null && activeLaunches.length > 0) {
new Job("Stopping launches") { new Job("Stopping launches") {
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
// TODO only stop the launches for the active launch descriptor try {
// Not sure we have the API to map that out yet. ILaunchConfiguration activeConfig = launchBarManager.getActiveLaunchConfiguration();
for (ILaunch launch : activeLaunches) { for (ILaunch launch : activeLaunches) {
try { ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
launch.terminate(); if (launchConfig.equals(activeConfig)) {
} catch (DebugException e) { launch.terminate();
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();
} }
return Status.OK_STATUS;
}; };
}.schedule(); }.schedule();
} }