Search in sources :

Example 51 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.

the class DTDSyntaxColoringPage method getAttributeFor.

private TextAttribute getAttributeFor(String namedStyle) {
    TextAttribute ta = new TextAttribute(fDefaultForeground, fDefaultBackground, SWT.NORMAL);
    if (namedStyle != null && fOverlayStore != null) {
        // note: "namedStyle" *is* the preference key
        String prefString = getOverlayStore().getString(namedStyle);
        String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
        if (stylePrefs != null) {
            RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
            RGB background = ColorHelper.toRGB(stylePrefs[1]);
            int fontModifier = SWT.NORMAL;
            if (stylePrefs.length > 2) {
                boolean on = Boolean.valueOf(stylePrefs[2]).booleanValue();
                if (on)
                    fontModifier = fontModifier | SWT.BOLD;
            }
            if (stylePrefs.length > 3) {
                boolean on = Boolean.valueOf(stylePrefs[3]).booleanValue();
                if (on)
                    fontModifier = fontModifier | SWT.ITALIC;
            }
            if (stylePrefs.length > 4) {
                boolean on = Boolean.valueOf(stylePrefs[4]).booleanValue();
                if (on)
                    fontModifier = fontModifier | TextAttribute.STRIKETHROUGH;
            }
            if (stylePrefs.length > 5) {
                boolean on = Boolean.valueOf(stylePrefs[5]).booleanValue();
                if (on)
                    fontModifier = fontModifier | TextAttribute.UNDERLINE;
            }
            ta = new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, fontModifier);
        }
    }
    return ta;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) RGB(org.eclipse.swt.graphics.RGB)

Example 52 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.

the class XSLSyntaxColoringPage method getAttributeFor.

private TextAttribute getAttributeFor(String namedStyle) {
    TextAttribute ta = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
    if (namedStyle != null && overlayStore != null) {
        // note: "namedStyle" *is* the preference key
        String prefString = getOverlayStore().getString(namedStyle);
        String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
        if (stylePrefs != null) {
            RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
            RGB background = ColorHelper.toRGB(stylePrefs[1]);
            int fontModifier = SWT.NORMAL;
            if (stylePrefs.length > 2) {
                boolean on = Boolean.valueOf(stylePrefs[2]).booleanValue();
                if (on)
                    fontModifier = fontModifier | SWT.BOLD;
            }
            if (stylePrefs.length > 3) {
                boolean on = Boolean.valueOf(stylePrefs[3]).booleanValue();
                if (on)
                    fontModifier = fontModifier | SWT.ITALIC;
            }
            if (stylePrefs.length > 4) {
                boolean on = Boolean.valueOf(stylePrefs[4]).booleanValue();
                if (on)
                    fontModifier = fontModifier | TextAttribute.STRIKETHROUGH;
            }
            if (stylePrefs.length > 5) {
                boolean on = Boolean.valueOf(stylePrefs[5]).booleanValue();
                if (on)
                    fontModifier = fontModifier | TextAttribute.UNDERLINE;
            }
            ta = new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, fontModifier);
        }
    }
    return ta;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) RGB(org.eclipse.swt.graphics.RGB)

Example 53 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.

the class LineStyleProviderForXSL method prepareTextRegion.

/**
 * @param region
 * @param start
 * @param length
 * @param holdResults
 * @return
 */
protected boolean prepareTextRegion(ITextRegionCollection blockedRegion, int partitionStartOffset, int partitionLength, Collection holdResults) {
    boolean handled = false;
    final int partitionEndOffset = partitionStartOffset + partitionLength - 1;
    ITextRegion region = null;
    ITextRegionList regions = blockedRegion.getRegions();
    StyleRange styleRange = null;
    for (int i = 0; i < regions.size(); i++) {
        region = regions.get(i);
        TextAttribute attr = null;
        TextAttribute previousAttr = null;
        if (blockedRegion.getStartOffset(region) > partitionEndOffset)
            break;
        if (blockedRegion.getEndOffset(region) <= partitionStartOffset)
            continue;
        if (region instanceof ITextRegionCollection) {
            handled = prepareTextRegion((ITextRegionCollection) region, partitionStartOffset, partitionLength, holdResults);
        } else {
            attr = getAttributeFor(blockedRegion, region);
            if (attr != null) {
                handled = true;
                styleRange = applyStyleRange(blockedRegion, partitionStartOffset, partitionLength, holdResults, region, styleRange, attr, previousAttr);
            } else {
                previousAttr = null;
            }
        }
    }
    return handled;
}
Also used : ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) TextAttribute(org.eclipse.jface.text.TextAttribute) StyleRange(org.eclipse.swt.custom.StyleRange) ITextRegionCollection(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)

Example 54 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.

the class LineStyleProviderForXSL method updateTextAttribute.

private void updateTextAttribute(String colorKey, RGB foreground, RGB background, int style) {
    TextAttribute createTextAttribute = createTextAttribute(foreground, background, style);
    TextAttribute textAttribute = XSLTextAttributeMap.getInstance().getTextAttributeMap().get(colorKey);
    if (textAttribute != null) {
        XSLTextAttributeMap.getInstance().getTextAttributeMap().put(colorKey, createTextAttribute);
        return;
    }
    textAttribute = XMLTextAttributeMap.getInstance().getTextAttributeMap().get(colorKey);
    if (textAttribute != null) {
        XMLTextAttributeMap.getInstance().getTextAttributeMap().put(colorKey, createTextAttribute);
    }
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute)

Example 55 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.

the class XMLSourceViewerConfiguration method getXMLTagScanner.

private XMLTagScanner getXMLTagScanner() {
    XMLTagScanner tagScanner = new XMLTagScanner(colorManager);
    tagScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(COLOR_TAG))));
    return tagScanner;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Token(org.eclipse.jface.text.rules.Token)

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