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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations