Search in sources :

Example 56 with TextAttribute

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;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Token(org.eclipse.jface.text.rules.Token)

Example 57 with TextAttribute

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;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) DefaultDamagerRepairer(org.eclipse.jface.text.rules.DefaultDamagerRepairer) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler) PresentationReconciler(org.eclipse.jface.text.presentation.PresentationReconciler) NonRuleBasedDamagerRepairer(org.jkiss.dbeaver.ui.editors.text.NonRuleBasedDamagerRepairer)

Example 58 with TextAttribute

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;
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry) TextAttribute(org.eclipse.jface.text.TextAttribute) DefaultDamagerRepairer(org.eclipse.jface.text.rules.DefaultDamagerRepairer) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler) PresentationReconciler(org.eclipse.jface.text.presentation.PresentationReconciler) NonRuleBasedDamagerRepairer(org.jkiss.dbeaver.ui.editors.text.NonRuleBasedDamagerRepairer)

Example 59 with TextAttribute

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);
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Color(org.eclipse.swt.graphics.Color)

Example 60 with TextAttribute

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()));
        }
    }
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Color(org.eclipse.swt.graphics.Color) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

TextAttribute (org.eclipse.jface.text.TextAttribute)142 Token (org.eclipse.jface.text.rules.Token)45 RGB (org.eclipse.swt.graphics.RGB)37 Color (org.eclipse.swt.graphics.Color)36 IToken (org.eclipse.jface.text.rules.IToken)23 StyleRange (org.eclipse.swt.custom.StyleRange)20 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)16 PresentationReconciler (org.eclipse.jface.text.presentation.PresentationReconciler)16 DefaultDamagerRepairer (org.eclipse.jface.text.rules.DefaultDamagerRepairer)14 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)12 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)12 IRule (org.eclipse.jface.text.rules.IRule)10 RuleBasedScanner (org.eclipse.jface.text.rules.RuleBasedScanner)9 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)8 ArrayList (java.util.ArrayList)7 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)6 ColorRegistry (org.eclipse.jface.resource.ColorRegistry)5 Document (org.eclipse.jface.text.Document)4 IDocument (org.eclipse.jface.text.IDocument)4 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)4