use of org.eclipse.jface.text.TextAttribute in project dbeaver by dbeaver.
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 dbeaver.
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;
}
use of org.eclipse.jface.text.TextAttribute in project dbeaver by dbeaver.
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 xtext-eclipse by eclipse.
the class HighlightingReconciler method addPosition.
/**
* Add a position with the given range and highlighting if it does not exist already.
* @param offset The range offset
* @param length The range length
* @param ids The highlighting attribute ids
*/
@Override
public void addPosition(int offset, int length, String... ids) {
TextAttribute highlighting = ids.length == 1 ? attributeProvider.getAttribute(ids[0]) : attributeProvider.getMergedAttributes(ids);
if (highlighting == null)
return;
boolean isExisting = false;
PositionHandle handle = new PositionHandle(offset, length, highlighting);
Integer index = handleToListIndex.remove(handle);
if (index != null) {
AttributedPosition position = removedPositions.get(index);
if (position == null) {
throw new IllegalStateException("Position may not be null if the handle is still present.");
}
isExisting = true;
removedPositions.set(index, null);
removedPositionCount--;
}
if (!isExisting && presenter != null) {
// in case we have been uninstalled due to exceptions
AttributedPosition position = presenter.createHighlightedPosition(offset, length, highlighting);
addedPositions.add(position);
}
}
use of org.eclipse.jface.text.TextAttribute in project xtext-eclipse by eclipse.
the class AttributedPosition method createStyleRange.
/**
* @return Returns a corresponding style range.
*/
public StyleRange createStyleRange() {
int len = getLength();
TextAttribute textAttribute = attribute;
int style = textAttribute.getStyle();
int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
StyleRange styleRange = new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle);
styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
styleRange.font = textAttribute.getFont();
return styleRange;
}
Aggregations