use of org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfiguration in project xtext-xtend by eclipse.
the class XtendThemeManager method handleEvent.
@Override
public void handleEvent(Event event) {
if (!IThemeEngine.Events.THEME_CHANGED.equals(event.getTopic())) {
return;
}
IThemeEngine themeEngine = PlatformUI.getWorkbench().getService(IThemeEngine.class);
ITheme theme = themeEngine.getActiveTheme();
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(ORG_ECLIPSE_XTEND_CORE_XTEND);
if (!theme.getId().contains("dark")) {
// resetting from dark theme does not work the same way
// as a workaround reset the preferences by evaluating the XtendHighlightingConfiguration
IHighlightingConfiguration highlightingConfiguration = new XtendHighlightingConfiguration();
highlightingConfiguration.configure((id, name, style) -> {
setColorPreference(preferences, getSyntaxHightlightingPreferenceKey(id, COLOR_SUFFIX), style.getColor());
setColorPreference(preferences, getSyntaxHightlightingPreferenceKey(id, BACKGROUNDCOLOR_SUFFIX), style.getBackgroundColor());
String styleKey = getSyntaxHightlightingPreferenceKey(id, STYLE_SUFFIX);
int styleMask = style.getStyle();
if (preferences.getInt(styleKey, -1) != -1) {
preferences.remove(styleKey);
}
if (styleMask > 0) {
preferences.putInt(styleKey, styleMask);
}
});
}
themeEngine.applyStyles(preferences, false);
}
Aggregations