Search in sources :

Example 11 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method showCursorLine.

/**
 * Shows the cursor line.
 */
private void showCursorLine() {
    if (fCursorLinePainter == null) {
        if (fSourceViewer instanceof ITextViewerExtension2) {
            fCursorLinePainter = new CursorLinePainter(fSourceViewer);
            fCursorLinePainter.setHighlightColor(getColor(fCursorLinePainterColorKey));
            ITextViewerExtension2 extension = (ITextViewerExtension2) fSourceViewer;
            extension.addPainter(fCursorLinePainter);
        }
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) CursorLinePainter(org.eclipse.jface.text.CursorLinePainter)

Example 12 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method hideCursorLine.

/**
 * Hides the cursor line.
 */
private void hideCursorLine() {
    if (fCursorLinePainter != null) {
        if (fSourceViewer instanceof ITextViewerExtension2) {
            ITextViewerExtension2 extension = (ITextViewerExtension2) fSourceViewer;
            extension.removePainter(fCursorLinePainter);
            fCursorLinePainter.deactivate(true);
            fCursorLinePainter.dispose();
            fCursorLinePainter = null;
        }
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2)

Example 13 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class CodeMiningDemo method addAnnotationPainter.

private static void addAnnotationPainter(ISourceViewer viewer) {
    IAnnotationAccess annotationAccess = new IAnnotationAccess() {

        @Override
        public Object getType(Annotation annotation) {
            return annotation.getType();
        }

        @Override
        public boolean isMultiLine(Annotation annotation) {
            return true;
        }

        @Override
        public boolean isTemporary(Annotation annotation) {
            return true;
        }
    };
    AnnotationPainter painter = new AnnotationPainter(viewer, annotationAccess);
    ((ITextViewerExtension2) viewer).addPainter(painter);
    // Register this annotation painter as CodeMining annotation painter.
    ((ISourceViewerExtension5) viewer).setCodeMiningAnnotationPainter(painter);
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) ISourceViewerExtension5(org.eclipse.jface.text.source.ISourceViewerExtension5) AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter) Annotation(org.eclipse.jface.text.source.Annotation)

Example 14 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class InlinedAnnotationDemo method createAnnotationPainter.

/**
 * Create annotation painter.
 *
 * @param viewer
 *            the viewer.
 * @return annotation painter.
 */
private static AnnotationPainter createAnnotationPainter(ISourceViewer viewer) {
    IAnnotationAccess annotationAccess = new IAnnotationAccess() {

        @Override
        public Object getType(Annotation annotation) {
            return annotation.getType();
        }

        @Override
        public boolean isMultiLine(Annotation annotation) {
            return true;
        }

        @Override
        public boolean isTemporary(Annotation annotation) {
            return true;
        }
    };
    AnnotationPainter painter = new AnnotationPainter(viewer, annotationAccess);
    ((ITextViewerExtension2) viewer).addPainter(painter);
    return painter;
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter) LineContentAnnotation(org.eclipse.jface.text.source.inlined.LineContentAnnotation) Annotation(org.eclipse.jface.text.source.Annotation) AbstractInlinedAnnotation(org.eclipse.jface.text.source.inlined.AbstractInlinedAnnotation) LineHeaderAnnotation(org.eclipse.jface.text.source.inlined.LineHeaderAnnotation)

Aggregations

ITextViewerExtension2 (org.eclipse.jface.text.ITextViewerExtension2)14 ITextViewer (org.eclipse.jface.text.ITextViewer)2 ITextViewerExtension4 (org.eclipse.jface.text.ITextViewerExtension4)2 Annotation (org.eclipse.jface.text.source.Annotation)2 AnnotationPainter (org.eclipse.jface.text.source.AnnotationPainter)2 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)2 ISourceViewerExtension5 (org.eclipse.jface.text.source.ISourceViewerExtension5)2 MatchingCharacterPainter (org.eclipse.jface.text.source.MatchingCharacterPainter)2 CursorLinePainter (org.eclipse.jface.text.CursorLinePainter)1 MarginPainter (org.eclipse.jface.text.MarginPainter)1 WhitespaceCharacterPainter (org.eclipse.jface.text.WhitespaceCharacterPainter)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 AbstractInlinedAnnotation (org.eclipse.jface.text.source.inlined.AbstractInlinedAnnotation)1 LineContentAnnotation (org.eclipse.jface.text.source.inlined.LineContentAnnotation)1 LineHeaderAnnotation (org.eclipse.jface.text.source.inlined.LineHeaderAnnotation)1 StyledText (org.eclipse.swt.custom.StyledText)1 Color (org.eclipse.swt.graphics.Color)1