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;
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations