Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
Expand Down Expand Up @@ -347,8 +348,12 @@ protected void fillMenu(Menu menu) {

// Add favorites
int accelerator = 1;
ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
for (ILaunchConfiguration launch : favoriteList) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please guard the new code, including fetching of the launch configs by first check if launchPref is set? Same below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a length check for launches

LaunchAction action= new LaunchAction(launch, getMode());
if (launches.length > 0 && checkIfLaunched(launch, launches)) {
action.setText(action.getText() + " \u2699"); //$NON-NLS-1$
}
addToMenu(menu, action, accelerator);
accelerator++;
}
Expand All @@ -361,6 +366,9 @@ protected void fillMenu(Menu menu) {
// Add history launches next
for (ILaunchConfiguration launch : historyList) {
LaunchAction action= new LaunchAction(launch, getMode());
if (launches.length > 0 && checkIfLaunched(launch, launches)) {
action.setText(action.getText() + " \u2699"); //$NON-NLS-1$
}
addToMenu(menu, action, accelerator);
accelerator++;
}
Expand All @@ -373,6 +381,22 @@ protected void fillMenu(Menu menu) {
}
}

/**
* Returns whether the given launch configuration has been launched.
*
* @param launchConfiguration the launch configuration
* @param launches the current active launches
* @return {@code true} if a matching launch exists, {@code false} otherwise
*/
private boolean checkIfLaunched(ILaunchConfiguration launchConfiguration, ILaunch[] launches) {
for (ILaunch launch : launches) {
if (launch.getLaunchConfiguration().equals(launchConfiguration) && !launch.isTerminated()) {
return true;
}
}
return false;
}

/**
* Adds a separator to the given menu
*
Expand Down
Loading