From 72ffa77e3f8a4555ca2c3aec6ced697644546044 Mon Sep 17 00:00:00 2001 From: Sarika Sinha Date: Fri, 12 Aug 2016 13:07:07 +0530 Subject: Bug 492182 - Add Terminate and Relaunch from Configurations, Relaunch actions and Context based launch Change-Id: Ie4828a93ec219dd9a5f1298451e42f1b6a765ecb --- .../ui/org/eclipse/debug/ui/DebugUITools.java | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/ui') diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java index df2c46e61..e0474df51 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java @@ -13,6 +13,7 @@ package org.eclipse.debug.ui; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Set; import org.eclipse.core.commands.ExecutionEvent; @@ -898,14 +899,22 @@ public class DebugUITools { ILaunch[] launches = launchManager.getLaunches(); for (ILaunch iLaunch : launches) { if (configuration.contentsEqual(iLaunch.getLaunchConfiguration())) { - try { - iLaunch.terminate(); - } catch (DebugException e) { - DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), NLS.bind(ActionMessages.TerminateAndLaunchFailure, iLaunch.getLaunchConfiguration().getName()), e)); + synchronized (fgLaunchList) { + fgLaunchList.add(iLaunch); } } } } + if (!fgLaunchList.isEmpty()) { + Thread t = new Thread(fgLaunchTerminate); + t.start(); + try { + t.join(); + } catch (InterruptedException e1) { + DebugUIPlugin.log(e1); + return; + } + } boolean launchInBackground = true; try { launchInBackground = configuration.getAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); @@ -919,6 +928,29 @@ public class DebugUITools { } } + + private static Set fgLaunchList = new LinkedHashSet<>(); + private static Runnable fgLaunchTerminate = new Runnable() { + @Override + public void run() { + String launchConfigName = null; + Set launchList; + try { + synchronized (fgLaunchList) { + launchList = new LinkedHashSet<>(fgLaunchList); + fgLaunchList.clear(); + } + for (ILaunch iLaunch : launchList) { + launchConfigName = iLaunch.getLaunchConfiguration().getName(); + iLaunch.terminate(); + } + + } catch (DebugException e) { + DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), NLS.bind(ActionMessages.TerminateAndLaunchFailure, launchConfigName), e)); + } + } + }; + /** * Builds the workspace according to current preference settings, and launches -- cgit v1.2.3