Skip to content

Commit 46a02a6

Browse files
committed
Add active launch indicator to launch history menu
Adds a visual indicator to launch configurations that are currently active in the launch history menu.
1 parent 77bec00 commit 46a02a6

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.eclipse.core.resources.IResource;
2424
import org.eclipse.core.runtime.CoreException;
2525
import org.eclipse.debug.core.DebugPlugin;
26+
import org.eclipse.debug.core.ILaunch;
2627
import org.eclipse.debug.core.ILaunchConfiguration;
2728
import org.eclipse.debug.core.ILaunchConfigurationType;
2829
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -347,8 +348,12 @@ protected void fillMenu(Menu menu) {
347348

348349
// Add favorites
349350
int accelerator = 1;
351+
ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
350352
for (ILaunchConfiguration launch : favoriteList) {
351353
LaunchAction action= new LaunchAction(launch, getMode());
354+
if (checkIfLaunchActive(launch, launches)) {
355+
action.setText(action.getText() + " \u2699"); //$NON-NLS-1$
356+
}
352357
addToMenu(menu, action, accelerator);
353358
accelerator++;
354359
}
@@ -361,6 +366,9 @@ protected void fillMenu(Menu menu) {
361366
// Add history launches next
362367
for (ILaunchConfiguration launch : historyList) {
363368
LaunchAction action= new LaunchAction(launch, getMode());
369+
if (checkIfLaunchActive(launch, launches)) {
370+
action.setText(action.getText() + " \u2699"); //$NON-NLS-1$
371+
}
364372
addToMenu(menu, action, accelerator);
365373
accelerator++;
366374
}
@@ -373,6 +381,24 @@ protected void fillMenu(Menu menu) {
373381
}
374382
}
375383

384+
/**
385+
* Returns whether the given launch configuration has been launched and active
386+
* now.
387+
*
388+
* @param launchConfiguration the launch configuration
389+
* @param launches the current active launches
390+
* @return {@code true} if a matching launch exists, {@code false} otherwise
391+
*/
392+
private boolean checkIfLaunchActive(ILaunchConfiguration launchConfiguration, ILaunch[] launches) {
393+
for (ILaunch launch : launches) {
394+
ILaunchConfiguration activeLaunch = launch.getLaunchConfiguration();
395+
if (activeLaunch != null && activeLaunch.equals(launchConfiguration) && !launch.isTerminated()) {
396+
return true;
397+
}
398+
}
399+
return false;
400+
}
401+
376402
/**
377403
* Adds a separator to the given menu
378404
*

0 commit comments

Comments
 (0)