use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.
the class XMLSourceViewerConfiguration method getXMLScanner.
private XMLScanner getXMLScanner() {
XMLScanner scanner = new XMLScanner(colorManager);
scanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(COLOR_DEFAULT))));
return scanner;
}
use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.
the class XMLSourceViewerConfiguration method getPresentationReconciler.
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getXMLTagScanner());
reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
dr = new DefaultDamagerRepairer(getXMLScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(COLOR_XML_COMMENT)));
reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
return reconciler;
}
use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.
the class JSONSourceViewerConfiguration method getPresentationReconciler.
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
ColorRegistry colorRegistry = UIUtils.getColorRegistry();
PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(jsonScanner);
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorRegistry.get(SQLConstants.CONFIG_COLOR_STRING)));
reconciler.setDamager(ndr, JSONPartitionScanner.JSON_STRING);
reconciler.setRepairer(ndr, JSONPartitionScanner.JSON_STRING);
return reconciler;
}
use of org.eclipse.jface.text.TextAttribute in project hale by halestudio.
the class AbstractJavaScanner method createTextAttribute.
/**
* Create a text attribute based on the given color, bold, italic,
* strikethrough and underline preference keys.
*
* @param colorKey the color preference key
* @param boldKey the bold preference key
* @param italicKey the italic preference key
* @param strikethroughKey the strikethrough preference key
* @param underlineKey the italic preference key
* @return the created text attribute
* @since 3.0
*/
private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
Color color = null;
if (colorKey != null)
color = fColorManager.getColor(colorKey);
int style = fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
if (fPreferenceStore.getBoolean(italicKey))
style |= SWT.ITALIC;
if (fPreferenceStore.getBoolean(strikethroughKey))
style |= TextAttribute.STRIKETHROUGH;
if (fPreferenceStore.getBoolean(underlineKey))
style |= TextAttribute.UNDERLINE;
return new TextAttribute(color, null, style);
}
use of org.eclipse.jface.text.TextAttribute in project hale by halestudio.
the class AbstractJavaScanner 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();
Color color = fColorManager.getColor(property);
Object data = token.getData();
if (data instanceof TextAttribute) {
TextAttribute oldAttr = (TextAttribute) data;
token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
}
}
}
Aggregations