Skip to content

Commit 20a1b95

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. The indicator is shown only when the corresponding preference is enabled.
1 parent a877760 commit 20a1b95

7 files changed

Lines changed: 60 additions & 10 deletions

File tree

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void initializeDefaultPreferences() {
168168
prefs.setDefault(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED, true);
169169
prefs.setDefault(IInternalDebugUIConstants.PREF_FILTER_WORKING_SETS, false);
170170
prefs.setDefault(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES, false);
171-
171+
prefs.setDefault(IInternalDebugUIConstants.PREF_LAUNCHED_INDICATOR, false);
172172
/**
173173
* Debug view mode default
174174
*

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,10 @@ public interface IInternalDebugUIConstants {
483483
*/
484484
String EXPRESSION_PASTE_AS_MULTI = "org.eclipse.debug.ui.expression.paste.multi"; //$NON-NLS-1$
485485

486+
/**
487+
* Boolean preference for showing active launch indicator in launch history
488+
*
489+
*/
490+
String PREF_LAUNCHED_INDICATOR = IDebugUIConstants.PLUGIN_ID + ".PREF_LAUNCHED_INDICATOR"; //$NON-NLS-1$
491+
486492
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,6 @@ public class DebugPreferencesMessages extends NLS {
240240
public static String ConsoleFontSettingsLink;
241241
public static String DebugPreferencePage_PromptMultiExpressions;
242242

243+
public static String LaunchIndicatorPreference;
244+
243245
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@ DefaultLaunchConfigurationsPropertiesPage_9=Delete selected launch configuration
185185
DefaultLaunchConfigurationsPropertiesPage_11=Select Configuration Type
186186
DefaultLaunchConfigurationsPropertiesPage_12=&Select the type of configuration to create:
187187
RunDebugPropertiesPage_0=There was a problem trying to edit {0}
188+
LaunchIndicatorPreference=Show active launch indicator in launch history menu
188189

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
159159
*/
160160
private Table fTable;
161161

162+
/**
163+
* Boolean editor for showing active launch indicator
164+
*/
165+
private FieldEditor launchIndicator;
166+
162167
/**
163168
* Constructor
164169
*/
@@ -188,10 +193,10 @@ protected Control createContents(Composite parent) {
188193
edit = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_FILTER_WORKING_SETS, DebugPreferencesMessages.LaunchConfigurationsPreferencePage_3, SWT.NONE, spacer);
189194
fFieldEditors.add(edit);
190195
fDeleteConfigs = SWTFactory.createCheckButton(comp, DebugPreferencesMessages.LaunchConfigurationsPreferencePage_2, null, false, 3);
191-
192196
//add table options
193197
createTypeFiltering(group);
194-
198+
launchIndicator = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_LAUNCHED_INDICATOR,
199+
DebugPreferencesMessages.LaunchIndicatorPreference, SWT.NONE, comp);
195200
//migration
196201
group = SWTFactory.createGroup(comp, DebugPreferencesMessages.LaunchingPreferencePage_35, 1, 1, GridData.FILL_HORIZONTAL);
197202
Label label = new Label(group, SWT.LEFT | SWT.WRAP);
@@ -334,6 +339,9 @@ private void initFieldEditors() {
334339
}
335340
}
336341
}
342+
launchIndicator.setPreferenceStore(getPreferenceStore());
343+
launchIndicator.load();
344+
337345
}
338346

339347
@Override
@@ -345,6 +353,7 @@ protected void performDefaults() {
345353
fTable.setEnabled(((BooleanFieldEditor2)editor).getBooleanValue());
346354
}
347355
}
356+
launchIndicator.loadDefault();
348357
}
349358

350359
@Override
@@ -364,6 +373,7 @@ public boolean performOk() {
364373
}
365374
}
366375
getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST, types);
376+
launchIndicator.store();
367377
return super.performOk();
368378
}
369379
}

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

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -23,12 +23,14 @@
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;
2930
import org.eclipse.debug.core.ILaunchManager;
3031
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
3132
import org.eclipse.debug.internal.ui.DebugUIPlugin;
33+
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
3234
import org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener;
3335
import org.eclipse.debug.internal.ui.ILaunchLabelChangedListener;
3436
import org.eclipse.debug.internal.ui.actions.ActionMessages;
@@ -46,6 +48,7 @@
4648
import org.eclipse.jface.action.ActionContributionItem;
4749
import org.eclipse.jface.action.IAction;
4850
import org.eclipse.jface.dialogs.IDialogConstants;
51+
import org.eclipse.jface.preference.IPreferenceStore;
4952
import org.eclipse.jface.viewers.ISelection;
5053
import org.eclipse.jface.viewers.IStructuredSelection;
5154
import org.eclipse.jface.viewers.StructuredSelection;
@@ -342,13 +345,20 @@ private void setMenu(Menu menu) {
342345
* @param menu the menu to fill
343346
*/
344347
protected void fillMenu(Menu menu) {
345-
ILaunchConfiguration[] historyList= getHistory();
348+
ILaunchConfiguration[] historyList = getHistory();
346349
ILaunchConfiguration[] favoriteList = getFavorites();
347350

348351
// Add favorites
349352
int accelerator = 1;
353+
ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
354+
IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
355+
boolean launchPref = store.getBoolean(IInternalDebugUIConstants.PREF_LAUNCHED_INDICATOR);
350356
for (ILaunchConfiguration launch : favoriteList) {
351-
LaunchAction action= new LaunchAction(launch, getMode());
357+
358+
LaunchAction action = new LaunchAction(launch, getMode());
359+
if (launchPref && checkIfLaunched(launch, launches)) {
360+
action.setText(action.getText() + " \u25CF"); //$NON-NLS-1$
361+
}
352362
addToMenu(menu, action, accelerator);
353363
accelerator++;
354364
}
@@ -360,19 +370,39 @@ protected void fillMenu(Menu menu) {
360370

361371
// Add history launches next
362372
for (ILaunchConfiguration launch : historyList) {
363-
LaunchAction action= new LaunchAction(launch, getMode());
373+
LaunchAction action = new LaunchAction(launch, getMode());
374+
if (launchPref && checkIfLaunched(launch, launches)) {
375+
action.setText(action.getText() + " \u25CF"); //$NON-NLS-1$
376+
}
364377
addToMenu(menu, action, accelerator);
365378
accelerator++;
366379
}
367380

368-
if(accelerator == 1) {
369-
IAction action = new Action(ActionMessages.AbstractLaunchHistoryAction_6) {};
381+
if (accelerator == 1) {
382+
IAction action = new Action(ActionMessages.AbstractLaunchHistoryAction_6) {
383+
};
370384
action.setEnabled(false);
371-
ActionContributionItem item= new ActionContributionItem(action);
385+
ActionContributionItem item = new ActionContributionItem(action);
372386
item.fill(menu, -1);
373387
}
374388
}
375389

390+
/**
391+
* Returns whether the given launch configuration has been launched.
392+
*
393+
* @param launchConfiguration the launch configuration
394+
* @param launches the current active launches
395+
* @return {@code true} if a matching launch exists, {@code false} otherwise
396+
*/
397+
private boolean checkIfLaunched(ILaunchConfiguration launchConfiguration, ILaunch[] launches) {
398+
for (ILaunch launch : launches) {
399+
if (launch.getLaunchConfiguration().equals(launchConfiguration) && !launch.isTerminated()) {
400+
return true;
401+
}
402+
}
403+
return false;
404+
}
405+
376406
/**
377407
* Adds a separator to the given menu
378408
*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,5 @@ private ILaunchGroup[] getAllGroupsForConfiguration(ILaunchConfiguration config)
179179
catch(CoreException ce) {}
180180
return list.toArray(new ILaunchGroup[list.size()]);
181181
}
182+
182183
}

0 commit comments

Comments
 (0)