Skip to content

Commit 02fc196

Browse files
tobias-melchertobiasmelcher
authored andcommitted
Ignore blank color defaults in ColorsAndFontsPreferencePage
Fixes #3559
1 parent 7829422 commit 02fc196

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,12 +1352,16 @@ private RGB getColorTakingPreferenceDefaultValueIntoAccount(ColorDefinition defi
13521352
return valueFromExtension;
13531353
}
13541354
String storeDefault = store.getDefaultString(id);
1355-
if (storeDefault == null) {
1355+
if (storeDefault == null || storeDefault.isBlank()) {
13561356
return valueFromExtension;
13571357
}
13581358
try {
13591359
RGB defaultRGB = ColorUtil.getColorValue(storeDefault);
13601360
if (defaultRGB != null && !defaultRGB.equals(valueFromExtension)) {
1361+
if (getActiveTheme() != null
1362+
&& LightColorFactory.isColorDefinitionIdPartOfLightColorFactory(id)) {
1363+
return valueFromExtension;
1364+
}
13611365
return defaultRGB;
13621366
}
13631367
} catch (DataFormatException e) { // silently ignored

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/LightColorFactory.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.internal.themes;
1616

1717
import java.util.Hashtable;
18-
1918
import org.eclipse.core.runtime.IConfigurationElement;
2019
import org.eclipse.core.runtime.IExecutableExtension;
2120
import org.eclipse.swt.graphics.RGB;
@@ -31,6 +30,10 @@
3130
*/
3231
public class LightColorFactory implements IColorFactory, IExecutableExtension {
3332

33+
private static final String ACTIVE_NOFOCUS_TAB_BG_START = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START"; //$NON-NLS-1$
34+
private static final String ACTIVE_TAB_TEXT_COLOR = "org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR"; //$NON-NLS-1$
35+
private static final String ACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"; //$NON-NLS-1$
36+
private static final String ACTIVE_TAB_BG_START = "org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"; //$NON-NLS-1$
3437
protected static final RGB white = ColorUtil.getColorValue("COLOR_WHITE"); //$NON-NLS-1$
3538
protected static final RGB black = ColorUtil.getColorValue("COLOR_BLACK"); //$NON-NLS-1$
3639

@@ -157,23 +160,30 @@ private RGB getActiveNofocusStartColor() {
157160
return ColorUtil.blend(white, base, 40);
158161
}
159162

163+
static boolean isColorDefinitionIdPartOfLightColorFactory(String id) {
164+
if (ACTIVE_TAB_BG_START.equals(id) || ACTIVE_TAB_BG_END.equals(id) || ACTIVE_TAB_TEXT_COLOR.equals(id)
165+
|| ACTIVE_NOFOCUS_TAB_BG_START.equals(id)) {
166+
return true;
167+
}
168+
return false;
169+
}
170+
160171
@Override
161172
public RGB createColor() {
162173
// should have base, otherwise error in the xml
163174
if (baseColorName == null || definitionId == null) {
164175
return white;
165176
}
166-
167-
if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START")) { //$NON-NLS-1$
177+
if (definitionId.equals(ACTIVE_TAB_BG_START)) {
168178
return getActiveFocusStartColor();
169179
}
170-
if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END")) { //$NON-NLS-1$
180+
if (definitionId.equals(ACTIVE_TAB_BG_END)) {
171181
return getActiveFocusEndColor();
172182
}
173-
if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")) { //$NON-NLS-1$
183+
if (definitionId.equals(ACTIVE_TAB_TEXT_COLOR)) {
174184
return getActiveFocusTextColor();
175185
}
176-
if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START")) { //$NON-NLS-1$
186+
if (definitionId.equals(ACTIVE_NOFOCUS_TAB_BG_START)) {
177187
return getActiveNofocusStartColor();
178188
}
179189

0 commit comments

Comments
 (0)