Skip to content

Commit a6e754c

Browse files
committed
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
1 parent 56e8969 commit a6e754c

6 files changed

Lines changed: 34 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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.eclipse.jface.action.IToolBarManager;
2929
import org.eclipse.jface.action.Separator;
3030
import org.eclipse.jface.action.ToolBarManager;
31+
import org.eclipse.jface.preference.IPreferenceStore;
3132
import org.eclipse.jface.resource.ImageDescriptor;
3233
import org.eclipse.jface.resource.JFaceResources;
3334
import org.eclipse.jface.resource.LocalResourceManager;
@@ -141,6 +142,9 @@ public void propertyChange(PropertyChangeEvent event) {
141142
updateTitle();
142143
}
143144
}
145+
if (IConsoleConstants.UPDATE_CONSOLE_ICON.equals(event.getProperty())) {
146+
updateIcon();
147+
}
144148

145149
}
146150

@@ -277,6 +281,14 @@ protected void updateHelp() {
277281
}
278282

279283
protected void updateIcon() {
284+
IPreferenceStore store = ConsolePlugin.getDefault().getPreferenceStore();
285+
if (!store.getBoolean(IConsoleConstants.UPDATE_CONSOLE_ICON)) {
286+
if (currentIcon != defaultIcon) {
287+
currentIcon = defaultIcon;
288+
setTitleImage(currentIcon);
289+
}
290+
return;
291+
}
280292
IConsole console = getConsole();
281293
if (console == null) {
282294
// Check and restore default console icon if last page is closed
@@ -412,6 +424,7 @@ public void dispose() {
412424
localResManager.dispose();
413425
localResManager = null;
414426
}
427+
ConsolePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
415428
}
416429

417430
/**
@@ -614,6 +627,7 @@ public void createPartControl(Composite parent) {
614627
localResManager = new LocalResourceManager(JFaceResources.getResources(), parent);
615628
defaultIcon = ConsolePluginImages.getImage(IConsoleConstants.IMG_VIEW_CONSOLE);
616629
currentIcon = defaultIcon;
630+
ConsolePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
617631
}
618632

619633
/**

0 commit comments

Comments
 (0)