Skip to content

Commit bcda9df

Browse files
Add preference page for console icon update
This commit adds a preference option in console preference for enable/disable dynamic console update based on active console page Fixes: #2434 Co-authored-by: Andrey Loskutov <loskutov@gmx.de>
1 parent 56e8969 commit bcda9df

6 files changed

Lines changed: 40 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 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
@@ -181,6 +181,10 @@ public void widgetSelected(SelectionEvent e) {
181181
DebugPreferencesMessages.ConsolePreferencePage_ConsoleAutoPinEnable, SWT.NONE, getFieldEditorParent());
182182
autoPinEditor.setPreferenceStore(ConsolePlugin.getDefault().getPreferenceStore());
183183
addField(autoPinEditor);
184+
BooleanFieldEditor consoleIconUpdate = new BooleanFieldEditor(IConsoleConstants.UPDATE_CONSOLE_ICON,
185+
DebugPreferencesMessages.ConsolePreferencePage_ConsoleIconUpdate, SWT.NONE, getFieldEditorParent());
186+
consoleIconUpdate.setPreferenceStore(ConsolePlugin.getDefault().getPreferenceStore());
187+
addField(consoleIconUpdate);
184188
Label comboLabel = new Label(getFieldEditorParent(), SWT.NONE);
185189
comboLabel.setText(DebugPreferencesMessages.ConsoleElapsedTimeLabel);
186190
fElapsedFormat = new ComboViewer(getFieldEditorParent(), SWT.DROP_DOWN | SWT.BORDER);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 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
@@ -230,4 +230,6 @@ public class DebugPreferencesMessages extends NLS {
230230

231231
public static Object ConsoleDisableElapsedTime;
232232

233+
public static String ConsolePreferencePage_ConsoleIconUpdate;
234+
233235
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2000, 2025 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
@@ -36,6 +36,7 @@ ConsoleElapsedTimeLabel=Elapsed Time Format (Choose 'None' to disable)
3636
ConsoleDefaultElapsedTimeFormat=%d:%02d:%02d
3737
ConsoleElapsedTimeToolTip=Supports formats like: 'H:MM:SS.mmm', 'MMm SSs', 'H:MM:SS' \nYou can also use positional parameters \n%1$ = (H)hours\n%2$ = (M)minutes\n%3$ = (S)seconds\n%4$ = (mmm)milliseconds
3838
ConsoleDisableElapsedTime=None
39+
ConsolePreferencePage_ConsoleIconUpdate=Update Console icon based on currently active page
3940

4041
DebugPreferencePage_1=General Settings for Running and Debugging.
4142
DebugPreferencePage_2=Re&use editor when displaying source code

debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 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
@@ -197,4 +197,11 @@ public interface IConsoleConstants {
197197
*/
198198
String COMMAND_ID_CLEAR_CONSOLE = "org.eclipse.debug.ui.commands.console.clear"; //$NON-NLS-1$
199199

200+
/**
201+
* The preference for updating console icon based on active console page
202+
*
203+
* @since 3.16
204+
*/
205+
String UPDATE_CONSOLE_ICON = ConsolePlugin.getUniqueIdentifier() + ".PREF_DYNAMIC_CONSOLE_ICON"; //$NON-NLS-1$
206+
200207
}

debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleUIPreferenceInitializer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018, 2020 Andrey Loskutov <loskutov@gmx.de> and others.
2+
* Copyright (c) 2018, 2026 Andrey Loskutov <loskutov@gmx.de> and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -31,6 +31,7 @@ public void initializeDefaultPreferences() {
3131
prefs.setDefault(IConsoleConstants.P_CONSOLE_WORD_WRAP, false);
3232
prefs.setDefault(IConsoleConstants.AUTO_PIN_ENABLED_PREF_NAME, true);
3333
prefs.setDefault(IConsoleConstants.REMEMBER_AUTO_PIN_DECISION_PREF_NAME, false);
34+
prefs.setDefault(IConsoleConstants.UPDATE_CONSOLE_ICON, true);
3435
}
3536

3637
}

debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
129129
private Image currentIcon, defaultIcon;
130130
private LocalResourceManager localResManager;
131131

132+
private boolean updateConsoleIcon;
133+
132134
private boolean isAvailable() {
133135
return getPageBook() != null && !getPageBook().isDisposed();
134136
}
@@ -141,9 +143,17 @@ public void propertyChange(PropertyChangeEvent event) {
141143
updateTitle();
142144
}
143145
}
146+
if (IConsoleConstants.UPDATE_CONSOLE_ICON.equals(event.getProperty())) {
147+
updateConsoleIcon = shouldUpdateConsoleIcon();
148+
updateIcon();
149+
}
144150

145151
}
146152

153+
private boolean shouldUpdateConsoleIcon() {
154+
return ConsolePlugin.getDefault().getPreferenceStore().getBoolean(IConsoleConstants.UPDATE_CONSOLE_ICON);
155+
}
156+
147157
@Override
148158
public void partClosed(IWorkbenchPart part) {
149159
super.partClosed(part);
@@ -277,6 +287,13 @@ protected void updateHelp() {
277287
}
278288

279289
protected void updateIcon() {
290+
if (!updateConsoleIcon) {
291+
if (currentIcon != defaultIcon) {
292+
currentIcon = defaultIcon;
293+
setTitleImage(currentIcon);
294+
}
295+
return;
296+
}
280297
IConsole console = getConsole();
281298
if (console == null) {
282299
// Check and restore default console icon if last page is closed
@@ -412,6 +429,7 @@ public void dispose() {
412429
localResManager.dispose();
413430
localResManager = null;
414431
}
432+
ConsolePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
415433
}
416434

417435
/**
@@ -612,8 +630,10 @@ public void createPartControl(Composite parent) {
612630
getViewSite().getPage().addPartListener((IPartListener2)this);
613631
initPageSwitcher();
614632
localResManager = new LocalResourceManager(JFaceResources.getResources(), parent);
633+
updateConsoleIcon = shouldUpdateConsoleIcon();
615634
defaultIcon = ConsolePluginImages.getImage(IConsoleConstants.IMG_VIEW_CONSOLE);
616635
currentIcon = defaultIcon;
636+
ConsolePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
617637
}
618638

619639
/**

0 commit comments

Comments
 (0)