Search in sources :

Example 1 with AnnotationPainter

use of org.eclipse.jface.text.source.AnnotationPainter in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method createAnnotationPainter.

/**
 * Creates and configures the annotation painter and configures.
 * @return an annotation painter
 * @since 3.0
 */
protected AnnotationPainter createAnnotationPainter() {
    AnnotationPainter painter = new AnnotationPainter(fSourceViewer, fAnnotationAccess);
    /*
		 * XXX:
		 * Could provide an extension point for drawing strategies,
		 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51498
		 */
    painter.addDrawingStrategy(AnnotationPreference.STYLE_NONE, fgNullStrategy);
    painter.addDrawingStrategy(AnnotationPreference.STYLE_IBEAM, fgIBeamStrategy);
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_SQUIGGLES, fgSquigglesStrategy);
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_PROBLEM_UNDERLINE, fgProblemUnderlineStrategy);
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_BOX, fgBoxStrategy);
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_DASHED_BOX, fgDashedBoxStrategy);
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_UNDERLINE, fgUnderlineStrategy);
    return painter;
}
Also used : AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter)

Example 2 with AnnotationPainter

use of org.eclipse.jface.text.source.AnnotationPainter in project mylyn.docs by eclipse.

the class HtmlViewer method initPainter.

@SuppressWarnings("deprecation")
private void initPainter() {
    if (haveInit) {
        return;
    }
    haveInit = true;
    // bug# 245759: must work outside of an Eclipse runtime
    ColorRegistry colorRegistry = WikiTextUiResources.getColors();
    IAnnotationAccess annotationAccess = new IAnnotationAccess() {

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

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

        public boolean isTemporary(Annotation annotation) {
            return true;
        }
    };
    AnnotationPainter painter = new AnnotationPainter(this, annotationAccess);
    // paint bullets
    painter.addDrawingStrategy(BulletAnnotation.TYPE, new BulletDrawingStrategy());
    painter.addAnnotationType(BulletAnnotation.TYPE, BulletAnnotation.TYPE);
    painter.setAnnotationTypeColor(BulletAnnotation.TYPE, getTextWidget().getForeground());
    // paint HR
    painter.addDrawingStrategy(HorizontalRuleAnnotation.TYPE, new HorizontalRuleDrawingStrategy());
    painter.addAnnotationType(HorizontalRuleAnnotation.TYPE, HorizontalRuleAnnotation.TYPE);
    painter.setAnnotationTypeColor(HorizontalRuleAnnotation.TYPE, colorRegistry.get(WikiTextUiResources.COLOR_HR));
    if (displayImages) {
        // paint images
        painter.addDrawingStrategy(ImageAnnotation.TYPE, new ImageDrawingStrategy(this));
        painter.addAnnotationType(ImageAnnotation.TYPE, ImageAnnotation.TYPE);
        painter.setAnnotationTypeColor(ImageAnnotation.TYPE, getTextWidget().getForeground());
    }
    addTextPresentationListener(painter);
    addPainter(painter);
    getTextWidget().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            imageCache.dispose();
        }
    });
    if (displayImages) {
        new ImageManager(this, imageCache, painter);
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) HorizontalRuleDrawingStrategy(org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.HorizontalRuleDrawingStrategy) ImageDrawingStrategy(org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.ImageDrawingStrategy) BulletDrawingStrategy(org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.BulletDrawingStrategy) DisposeEvent(org.eclipse.swt.events.DisposeEvent) AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter) Annotation(org.eclipse.jface.text.source.Annotation) HorizontalRuleAnnotation(org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.HorizontalRuleAnnotation) ImageAnnotation(org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.ImageAnnotation) BulletAnnotation(org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.BulletAnnotation) ImageManager(org.eclipse.mylyn.internal.wikitext.ui.viewer.ImageManager)

Example 3 with AnnotationPainter

use of org.eclipse.jface.text.source.AnnotationPainter in project webtools.sourceediting by eclipse.

the class StructuredSourceViewerDecorationSupport method createAnnotationPainter.

protected AnnotationPainter createAnnotationPainter() {
    /*
		 * The new squiggly drawer depends on the presentation reconciler to
		 * draw its squiggles. Unfortunately, StructuredTextEditors cannot use
		 * the presentation reconciler because it conflicts with its
		 * highlighter. Overriding createAnnotationPainter so that it is
		 * forced to use the old squiggly painter instead of the new one. See
		 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=201928
		 */
    AnnotationPainter painter = super.createAnnotationPainter();
    // dont use new squiggly painter
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_SQUIGGLES, null);
    // use old one
    painter.addDrawingStrategy(AnnotationPreference.STYLE_SQUIGGLES, new AnnotationPainter.SquigglesStrategy());
    // dont use new problem underline painter
    painter.addTextStyleStrategy(AnnotationPreference.STYLE_PROBLEM_UNDERLINE, null);
    // use old one
    painter.addDrawingStrategy(AnnotationPreference.STYLE_PROBLEM_UNDERLINE, new AnnotationPainter.SquigglesStrategy());
    return painter;
}
Also used : AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter)

Example 4 with AnnotationPainter

use of org.eclipse.jface.text.source.AnnotationPainter 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 5 with AnnotationPainter

use of org.eclipse.jface.text.source.AnnotationPainter 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

AnnotationPainter (org.eclipse.jface.text.source.AnnotationPainter)6 Annotation (org.eclipse.jface.text.source.Annotation)3 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)3 ITextViewerExtension2 (org.eclipse.jface.text.ITextViewerExtension2)2 ColorRegistry (org.eclipse.jface.resource.ColorRegistry)1 ISourceViewerExtension5 (org.eclipse.jface.text.source.ISourceViewerExtension5)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 ImageManager (org.eclipse.mylyn.internal.wikitext.ui.viewer.ImageManager)1 BulletAnnotation (org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.BulletAnnotation)1 BulletDrawingStrategy (org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.BulletDrawingStrategy)1 HorizontalRuleAnnotation (org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.HorizontalRuleAnnotation)1 HorizontalRuleDrawingStrategy (org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.HorizontalRuleDrawingStrategy)1 ImageAnnotation (org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.ImageAnnotation)1 ImageDrawingStrategy (org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.ImageDrawingStrategy)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1