protected TextAttribute createTextAttribute(String id, TextStyle defaultTextStyle) { TextStyle textStyle = new TextStyle(); preferencesAccessor.populateTextStyle(id, textStyle, defaultTextStyle); int style = textStyle.getStyle(); Font fontFromFontData = EditorUtils.fontFromFontData(textStyle.getFontData()); return new TextAttribute( EditorUtils.colorFromRGB(textStyle.getColor()), EditorUtils.colorFromRGB(textStyle.getBackgroundColor()), style, fontFromFontData); }
@Override public void applyStyles(TextStyle textStyle) { textStyle.strikeout = (xtextTextStyle.getStyle() & TextAttribute.STRIKETHROUGH) != 0; textStyle.underline = (xtextTextStyle.getStyle() & TextAttribute.UNDERLINE) != 0; if (xtextTextStyle.getFontData() == null && xtextTextStyle.getStyle() != org.eclipse.xtext.ui.editor.utils.TextStyle.DEFAULT_FONT_STYLE) { FontData fontData = new FontData(); fontData.setStyle(xtextTextStyle.getStyle()); xtextTextStyle.setFontData(fontData); } textStyle.font = fontFromFontData(xtextTextStyle.getFontData()); if (xtextTextStyle.getBackgroundColor() != null) textStyle.background = colorFromRGB(xtextTextStyle.getBackgroundColor()); textStyle.foreground = colorFromRGB(xtextTextStyle.getColor()); } }
if (defaults.getColor() != null) PreferenceConverter.setDefault(preferenceStore, colorKey, defaults.getColor()); else { PreferenceConverter.setDefault(preferenceStore, colorKey, fontColorDefaultDefault); if (defaults.getBackgroundColor() != null) PreferenceConverter.setDefault(preferenceStore, backgroundKey, defaults.getBackgroundColor()); else { PreferenceConverter.setDefault(preferenceStore, backgroundKey, backgrounColorDefaultDefault); if (defaults.getFontData() != null) PreferenceConverter.setDefault(preferenceStore, fontKey, defaults.getFontData()); else { PreferenceConverter.setDefault(preferenceStore, fontKey, fontDataDefaultDefault); preferenceStore.setDefault(styleKey, defaults.getStyle()); style.setColor(color); RGB background = PreferenceConverter.getColor(preferenceStore, backgroundKey); if (!background.equals(backgrounColorDefaultDefault)) style.setBackgroundColor(background); FontData[] fontDataArray = PreferenceConverter.getFontDataArray(preferenceStore, fontKey); if (!Arrays.equals(fontDataArray, fontDataDefaultDefault)) { style.setFontData(fontDataArray); style.setStyle(preferenceStore.getInt(styleKey));
/** * creates a new {@link TextStyle} instance and copies all the source fields */ public TextStyle copy() { return new TextStyle(this); }
public TextStyle punctuationTextStyle() { TextStyle textStyle = defaultTextStyle().copy(); return textStyle; }
protected void refreshAttributes() { Collections.sort(highlightings, this); for (Triple<String, String, TextStyle> highlighting : highlightings) { preferenceStoreAccessor.populateTextStyle(highlighting.getFirst(), new TextStyle(), highlighting.getThird()); } }
public TextStyle errorTextStyle() { TextStyle textStyle = defaultTextStyle().copy(); // textStyle.setColor(new RGB(255, 0, 0)); return textStyle; }