Search in sources :

Example 1 with BulletDrawingStrategy

use of org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.BulletDrawingStrategy 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)

Aggregations

ColorRegistry (org.eclipse.jface.resource.ColorRegistry)1 Annotation (org.eclipse.jface.text.source.Annotation)1 AnnotationPainter (org.eclipse.jface.text.source.AnnotationPainter)1 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)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