From b9f7871e66900f60bbec4b203b36ea4122e108f0 Mon Sep 17 00:00:00 2001 From: Tobias Melcher Date: Fri, 28 Nov 2025 13:43:17 +0100 Subject: [PATCH] Ignore blank color defaults in ColorsAndFontsPreferencePage Fixes https://github.com/eclipse-platform/eclipse.platform.ui/issues/3559 --- .../themes/ColorsAndFontsPreferencePage.java | 6 ++++- .../ui/internal/themes/LightColorFactory.java | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java index 93dd53bf64b..ce48e843223 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java @@ -1352,12 +1352,16 @@ private RGB getColorTakingPreferenceDefaultValueIntoAccount(ColorDefinition defi return valueFromExtension; } String storeDefault = store.getDefaultString(id); - if (storeDefault == null) { + if (storeDefault == null || storeDefault.isBlank()) { return valueFromExtension; } try { RGB defaultRGB = ColorUtil.getColorValue(storeDefault); if (defaultRGB != null && !defaultRGB.equals(valueFromExtension)) { + if (getActiveTheme() != null + && LightColorFactory.isColorDefinitionIdPartOfLightColorFactory(id)) { + return valueFromExtension; + } return defaultRGB; } } catch (DataFormatException e) { // silently ignored diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/LightColorFactory.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/LightColorFactory.java index c739134ac76..4721dee731f 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/LightColorFactory.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/LightColorFactory.java @@ -15,7 +15,6 @@ package org.eclipse.ui.internal.themes; import java.util.Hashtable; - import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.swt.graphics.RGB; @@ -31,6 +30,10 @@ */ public class LightColorFactory implements IColorFactory, IExecutableExtension { + private static final String ACTIVE_NOFOCUS_TAB_BG_START = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START"; //$NON-NLS-1$ + private static final String ACTIVE_TAB_TEXT_COLOR = "org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR"; //$NON-NLS-1$ + private static final String ACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"; //$NON-NLS-1$ + private static final String ACTIVE_TAB_BG_START = "org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"; //$NON-NLS-1$ protected static final RGB white = ColorUtil.getColorValue("COLOR_WHITE"); //$NON-NLS-1$ protected static final RGB black = ColorUtil.getColorValue("COLOR_BLACK"); //$NON-NLS-1$ @@ -157,23 +160,30 @@ private RGB getActiveNofocusStartColor() { return ColorUtil.blend(white, base, 40); } + static boolean isColorDefinitionIdPartOfLightColorFactory(String id) { + if (ACTIVE_TAB_BG_START.equals(id) || ACTIVE_TAB_BG_END.equals(id) || ACTIVE_TAB_TEXT_COLOR.equals(id) + || ACTIVE_NOFOCUS_TAB_BG_START.equals(id)) { + return true; + } + return false; + } + @Override public RGB createColor() { // should have base, otherwise error in the xml if (baseColorName == null || definitionId == null) { return white; } - - if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START")) { //$NON-NLS-1$ + if (definitionId.equals(ACTIVE_TAB_BG_START)) { return getActiveFocusStartColor(); } - if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END")) { //$NON-NLS-1$ + if (definitionId.equals(ACTIVE_TAB_BG_END)) { return getActiveFocusEndColor(); } - if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")) { //$NON-NLS-1$ + if (definitionId.equals(ACTIVE_TAB_TEXT_COLOR)) { return getActiveFocusTextColor(); } - if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START")) { //$NON-NLS-1$ + if (definitionId.equals(ACTIVE_NOFOCUS_TAB_BG_START)) { return getActiveNofocusStartColor(); }