Skip to content

Commit f0e08f5

Browse files
Reset in colors preference page now respects theme-specific defaults
1 parent 68e6337 commit f0e08f5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,13 +1317,13 @@ private boolean isDefault(ColorDefinition definition) {
13171317

13181318
if (colorPreferencesToSet.containsKey(definition)) {
13191319
if (definition.getValue() != null) { // value-based color
1320-
if (colorPreferencesToSet.get(definition).equals(definition.getValue()))
1320+
if (colorPreferencesToSet.get(definition).equals(getColorRGB(definition)))
13211321
return true;
13221322
} else if (colorPreferencesToSet.get(definition).equals(getColorAncestorValue(definition)))
13231323
return true;
13241324
} else if (colorValuesToSet.containsKey(id)) {
13251325
if (definition.getValue() != null) { // value-based color
1326-
if (colorValuesToSet.get(id).equals(definition.getValue()))
1326+
if (colorValuesToSet.get(id).equals(getColorRGB(definition)))
13271327
return true;
13281328
} else {
13291329
if (colorValuesToSet.get(id).equals(getColorAncestorValue(definition)))
@@ -1517,7 +1517,7 @@ private boolean resetColor(ColorDefinition definition, boolean force) {
15171517
if (force || !isDefault(definition)) {
15181518
RGB newRGB;
15191519
if (definition.getValue() != null)
1520-
newRGB = definition.getValue();
1520+
newRGB = getColorRGB(definition);
15211521
else
15221522
newRGB = getColorAncestorValue(definition);
15231523

@@ -1531,6 +1531,18 @@ private boolean resetColor(ColorDefinition definition, boolean force) {
15311531
return false;
15321532
}
15331533

1534+
private RGB getColorRGB(ColorDefinition definition) {
1535+
RGB rgb = definition.getValue();
1536+
if (currentTheme != null && currentTheme.getColorRegistry() != null && definition.getId() != null) {
1537+
String colorKey = ThemeElementHelper.createPreferenceKey(currentTheme, definition.getId());
1538+
RGB themeRgb = currentTheme.getColorRegistry().getRGB(colorKey);
1539+
if (themeRgb != null) {
1540+
rgb = themeRgb;
1541+
}
1542+
}
1543+
return rgb;
1544+
}
1545+
15341546
protected boolean resetFont(FontDefinition definition, boolean force) {
15351547
if (force || !isDefault(definition)) {
15361548
FontData[] newFD;

0 commit comments

Comments
 (0)