Search in sources :

Example 61 with TextAttribute

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

Example 62 with TextAttribute

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

Example 63 with TextAttribute

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;
}
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 64 with TextAttribute

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

Example 65 with TextAttribute

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

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