use of org.eclipse.jface.text.TextAttribute in project soot by Sable.
the class JimpleConfiguration method getJimpleScanner.
protected JimpleScanner getJimpleScanner() {
if (scanner == null) {
scanner = new JimpleScanner(colorManager);
scanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(IJimpleColorConstants.JIMPLE_DEFAULT))));
}
return scanner;
}
use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.
the class AbstractLineStyleProvider method prepareTextRegion.
/**
* @param region
* @param start
* @param length
* @param holdResults
* @return
*/
private 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();
int nRegions = regions.size();
StyleRange styleRange = null;
for (int i = 0; i < nRegions; 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;
// regions correctly
if ((styleRange != null) && (previousAttr != null) && (previousAttr.equals(attr))) {
styleRange.length += region.getLength();
} else {
styleRange = createStyleRange(blockedRegion, region, attr, partitionStartOffset, partitionLength);
holdResults.add(styleRange);
// technically speaking, we don't need to update
// previousAttr
// in the other case, because the other case is when
// it hasn't changed
previousAttr = attr;
}
} else {
previousAttr = null;
}
}
}
return handled;
}
use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.
the class StyledTextColorPicker method getAttribute.
protected TextAttribute getAttribute(String namedStyle) {
TextAttribute ta = new TextAttribute(getDefaultForeground(), getDefaultBackground(), SWT.NORMAL);
if (namedStyle != null && getPreferenceStore() != null) {
String prefString = getPreferenceStore().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;
boolean bold = Boolean.valueOf(stylePrefs[2]).booleanValue();
if (bold)
fontModifier = fontModifier | SWT.BOLD;
if (showItalic) {
boolean italic = Boolean.valueOf(stylePrefs[3]).booleanValue();
if (italic)
fontModifier = fontModifier | SWT.ITALIC;
}
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 StyledTextColorPicker method applyStyles.
protected void applyStyles() {
if (fText == null || fText.isDisposed() || fInput == null || fInput.length() == 0)
return;
// List regions = fParser.getRegions();
IStructuredDocumentRegion node = fNodes;
while (node != null) {
ITextRegionList regions = node.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion currentRegion = regions.get(i);
// lookup the local coloring type and apply it
String namedStyle = (String) getContextStyleMap().get(currentRegion.getType());
if (namedStyle == null)
continue;
TextAttribute attribute = getAttribute(namedStyle);
if (attribute == null)
continue;
StyleRange style = new StyleRange(node.getStartOffset(currentRegion), currentRegion.getLength(), attribute.getForeground(), attribute.getBackground(), attribute.getStyle());
fText.setStyleRange(style);
}
node = node.getNext();
}
}
use of org.eclipse.jface.text.TextAttribute in project webtools.sourceediting by eclipse.
the class HTMLSyntaxColoringPage 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;
}
Aggregations