3535import org .eclipse .core .runtime .IStatus ;
3636import org .eclipse .e4 .core .services .events .IEventBroker ;
3737import org .eclipse .e4 .ui .css .swt .theme .IThemeEngine ;
38+ import org .eclipse .jface .preference .IPreferenceStore ;
3839import org .eclipse .jface .preference .PreferenceConverter ;
3940import org .eclipse .jface .preference .PreferencePage ;
41+ import org .eclipse .jface .resource .DataFormatException ;
4042import org .eclipse .jface .resource .JFaceResources ;
4143import org .eclipse .jface .resource .StringConverter ;
4244import org .eclipse .jface .util .IPropertyChangeListener ;
8789import org .eclipse .ui .internal .WorkbenchPlugin ;
8890import org .eclipse .ui .internal .misc .StatusUtil ;
8991import org .eclipse .ui .internal .util .PrefUtil ;
92+ import org .eclipse .ui .themes .ColorUtil ;
9093import org .eclipse .ui .themes .ITheme ;
9194import org .eclipse .ui .themes .IThemeManager ;
9295import org .eclipse .ui .themes .IThemePreview ;
@@ -331,9 +334,22 @@ private class PresentationLabelProvider extends LabelProvider implements IFontPr
331334
332335 private int usableImageSize = -1 ;
333336
337+ private final Runnable updateControlsAndRefreshTreeRunnable = new Runnable () {
338+
339+ @ Override
340+ public void run () {
341+ if (fontChangeButton == null || fontChangeButton .isDisposed ()) {
342+ return ;
343+ }
344+ updateControls ();
345+ tree .getViewer ().refresh ();
346+ }
347+ };
348+
334349 private IPropertyChangeListener listener = event -> {
335350 if (event .getNewValue () != null ) {
336351 fireLabelProviderChanged (new LabelProviderChangedEvent (PresentationLabelProvider .this ));
352+ Display .getDefault ().timerExec (300 , updateControlsAndRefreshTreeRunnable );
337353 } else {
338354 // Some theme definition element has been modified and we
339355 // need to refresh the viewer
@@ -1304,6 +1320,27 @@ private void updateThemeInfo(IThemeManager manager) {
13041320 labelProvider .hookListeners (); // rehook the listeners
13051321 }
13061322
1323+ private RGB getColorTakingOverriddenCssValueIntoAccount (ColorDefinition definition ) {
1324+ RGB value = definition .getValue ();
1325+ IPreferenceStore store = getPreferenceStore ();
1326+ if (store != null ) {
1327+ String id = definition .getId ();
1328+ if (id != null && id .length () > 0 ) {
1329+ String storeDefault = store .getDefaultString (id );
1330+ if (storeDefault != null ) {
1331+ try {
1332+ RGB defaultRGB = ColorUtil .getColorValue (storeDefault );
1333+ if (defaultRGB != null && !defaultRGB .equals (value )) {
1334+ value = defaultRGB ;
1335+ }
1336+ } catch (DataFormatException e ) { // silently ignored
1337+ }
1338+ }
1339+ }
1340+ }
1341+ return value ;
1342+ }
1343+
13071344 /**
13081345 * Answers whether the definition is currently set to the default value.
13091346 *
@@ -1314,23 +1351,34 @@ private void updateThemeInfo(IThemeManager manager) {
13141351 */
13151352 private boolean isDefault (ColorDefinition definition ) {
13161353 String id = definition .getId ();
1317-
13181354 if (colorPreferencesToSet .containsKey (definition )) {
13191355 if (definition .getValue () != null ) { // value-based color
1320- if (colorPreferencesToSet .get (definition ).equals (definition .getValue ()))
1356+ if (colorPreferencesToSet .get (definition )
1357+ .equals (getColorTakingOverriddenCssValueIntoAccount (definition )))
13211358 return true ;
13221359 } else if (colorPreferencesToSet .get (definition ).equals (getColorAncestorValue (definition )))
13231360 return true ;
13241361 } else if (colorValuesToSet .containsKey (id )) {
13251362 if (definition .getValue () != null ) { // value-based color
1326- if (colorValuesToSet .get (id ).equals (definition . getValue ( )))
1363+ if (colorValuesToSet .get (id ).equals (getColorTakingOverriddenCssValueIntoAccount ( definition )))
13271364 return true ;
13281365 } else {
13291366 if (colorValuesToSet .get (id ).equals (getColorAncestorValue (definition )))
13301367 return true ;
13311368 }
13321369 } else if (definition .getValue () != null ) { // value-based color
1333- if (getPreferenceStore ().isDefault (createPreferenceKey (definition )))
1370+ IPreferenceStore store = getPreferenceStore ();
1371+ String defaultString = store .getDefaultString (id );
1372+ String string = store .getString (id );
1373+ if (defaultString != null && string != null && defaultString .equals (string )) {
1374+ return true ;
1375+ }
1376+ // String overriddenByCss = store.getString(EclipsePreferencesHelper.PROPS_OVERRIDDEN_BY_CSS_PROP);
1377+ // if (overriddenByCss != null && overriddenByCss.contains(EclipsePreferencesHelper.SEPARATOR
1378+ // + id + EclipsePreferencesHelper.SEPARATOR)) {
1379+ // return true;
1380+ // }
1381+ if (store .isDefault (createPreferenceKey (definition )))
13341382 return true ;
13351383 } else {
13361384 // a descendant is default if it's the same value as its ancestor
@@ -1516,8 +1564,9 @@ private void refreshCategory() {
15161564 private boolean resetColor (ColorDefinition definition , boolean force ) {
15171565 if (force || !isDefault (definition )) {
15181566 RGB newRGB ;
1519- if (definition .getValue () != null )
1520- newRGB = definition .getValue ();
1567+ if (definition .getValue () != null ) {
1568+ newRGB = getColorTakingOverriddenCssValueIntoAccount (definition );
1569+ }
15211570 else
15221571 newRGB = getColorAncestorValue (definition );
15231572
0 commit comments