use of org.eclipse.jface.text.TextAttribute in project usbdm-eclipse-plugins by podonoghue.
the class ViewConfiguration method getCodeScanner.
protected RuleBasedScanner getCodeScanner() {
if (codeScanner == null) {
codeScanner = new CodeScanner(colorManager);
codeScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(ColorConstants.DEFAULT))));
}
return codeScanner;
}
use of org.eclipse.jface.text.TextAttribute in project egit by eclipse.
the class DiffViewer method refreshDiffStyles.
private void refreshDiffStyles() {
ColorRegistry col = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
FontRegistry reg = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
// We do the foreground via syntax coloring and the background via a
// line background listener. If we did the background also via the
// TextAttributes, this would take precedence over the line background
// resulting in strange display if the current line is highlighted:
// that highlighting would appear only beyond the end of the actual
// text content (i.e., beyond the end-of-line), while actual text
// would still get the background from the attribute.
tokens.put(IDocument.DEFAULT_CONTENT_TYPE, new Token(null));
tokens.put(DiffDocument.HEADLINE_CONTENT_TYPE, new Token(new TextAttribute(col.get(THEME_DiffHeadlineForegroundColor), null, SWT.NORMAL, reg.get(THEME_DiffHeadlineFont))));
tokens.put(DiffDocument.HUNK_CONTENT_TYPE, new Token(new TextAttribute(col.get(THEME_DiffHunkForegroundColor))));
tokens.put(DiffDocument.ADDED_CONTENT_TYPE, new Token(new TextAttribute(col.get(THEME_DiffAddForegroundColor))));
tokens.put(DiffDocument.REMOVED_CONTENT_TYPE, new Token(new TextAttribute(col.get(THEME_DiffRemoveForegroundColor))));
backgroundColors.put(DiffDocument.HEADLINE_CONTENT_TYPE, col.get(THEME_DiffHeadlineBackgroundColor));
backgroundColors.put(DiffDocument.HUNK_CONTENT_TYPE, col.get(THEME_DiffHunkBackgroundColor));
backgroundColors.put(DiffDocument.ADDED_CONTENT_TYPE, col.get(THEME_DiffAddBackgroundColor));
backgroundColors.put(DiffDocument.REMOVED_CONTENT_TYPE, col.get(THEME_DiffRemoveBackgroundColor));
}
use of org.eclipse.jface.text.TextAttribute in project statecharts by Yakindu.
the class StyleRanges method getRanges.
public List<StyleRange> getRanges(String expression) {
final List<StyleRange> ranges = Lists.newArrayList();
DocumentEvent event = new DocumentEvent();
event.fDocument = new DummyDocument(expression);
DocumentTokenSource tokenSource = tokenSourceProvider.get();
tokenSource.updateStructure(event);
Iterator<ILexerTokenRegion> iterator = tokenSource.getTokenInfos().iterator();
while (iterator.hasNext()) {
ILexerTokenRegion next = iterator.next();
TextAttribute attribute = attributeProvider.getAttribute(tokenTypeMapper.getId(next.getLexerTokenType()));
StyleRange range = new StyleRange(next.getOffset(), next.getLength(), attribute.getForeground(), attribute.getBackground());
range.font = attribute.getFont();
range.fontStyle = attribute.getStyle();
ranges.add(range);
}
return ranges;
}
use of org.eclipse.jface.text.TextAttribute in project tdq-studio-se by Talend.
the class AbstractSQLScanner method adaptToColorChange.
private void adaptToColorChange(Token token, PropertyChangeEvent event) {
RGB rgb = null;
Object value = event.getNewValue();
if (value instanceof RGB)
rgb = (RGB) value;
else if (value instanceof String)
rgb = StringConverter.asRGB((String) value);
if (rgb != null) {
String property = event.getProperty();
if (fColorManager instanceof IColorManagerExtension) {
IColorManagerExtension ext = (IColorManagerExtension) fColorManager;
ext.unbindColor(property);
ext.bindColor(property, rgb);
}
Object data = token.getData();
if (data instanceof TextAttribute) {
TextAttribute oldAttr = (TextAttribute) data;
token.setData(new TextAttribute(fColorManager.getColor(property), oldAttr.getBackground(), oldAttr.getStyle()));
}
}
}
use of org.eclipse.jface.text.TextAttribute in project titan.EclipsePlug-ins by eclipse.
the class ColorManager method createAttributeFromPreference.
/**
* Creates a TextAttribute out of a 'preference group' 's name.
* <p>
* Actually 3 preference names are use which are postfixed to get the
* actual ones needed.
*
* @see #getBackgroundColor(String)
* @see #getForegroundColor(String)
* @see #createTokenFromPreference(String)
* @see PreferenceConstants
*
* @param key
* The 'preference group' 's name.
* @return The TextAttribute created.
*/
public TextAttribute createAttributeFromPreference(final String key) {
Color foregroundColor = getForegroundColor(key + PreferenceConstants.FOREGROUND);
Color backgroundColor;
if (Activator.getDefault().getPreferenceStore().getBoolean(key + PreferenceConstants.USEBACKGROUNDCOLOR)) {
backgroundColor = getBackgroundColor(key + PreferenceConstants.BACKGROUND);
} else {
backgroundColor = null;
}
boolean isBold = Activator.getDefault().getPreferenceStore().getBoolean(key + PreferenceConstants.BOLD);
return new TextAttribute(foregroundColor, backgroundColor, isBold ? SWT.BOLD : SWT.NORMAL);
}
Aggregations