use of org.eclipse.jface.text.source.IAnnotationAccess 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.IAnnotationAccess in project egit by eclipse.
the class SpellcheckableMessageArea method configureAnnotationPreferences.
private SourceViewerDecorationSupport configureAnnotationPreferences() {
ISharedTextColors textColors = EditorsUI.getSharedTextColors();
IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(sourceViewer, null, annotationAccess, textColors);
List annotationPreferences = new MarkerAnnotationPreferences().getAnnotationPreferences();
Iterator e = annotationPreferences.iterator();
while (e.hasNext()) support.setAnnotationPreference((AnnotationPreference) e.next());
support.install(EditorsUI.getPreferenceStore());
return support;
}
use of org.eclipse.jface.text.source.IAnnotationAccess in project eclipse-integration-commons by spring-projects.
the class EditorToolkit method createTextEditor.
public TextViewer createTextEditor(Composite composite, String text, boolean spellCheck, int style) {
AnnotationModel annotationModel = new AnnotationModel();
final SourceViewer textViewer = new SourceViewer(composite, null, null, true, style);
textViewer.showAnnotations(false);
textViewer.showAnnotationsOverview(false);
IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(textViewer, null, annotationAccess, EditorsUI.getSharedTextColors());
@SuppressWarnings("unchecked") Iterator e = new MarkerAnnotationPreferences().getAnnotationPreferences().iterator();
while (e.hasNext()) {
support.setAnnotationPreference((AnnotationPreference) e.next());
}
support.install(EditorsUI.getPreferenceStore());
textViewer.getTextWidget().setIndent(2);
textViewer.getTextWidget().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
support.uninstall();
}
});
IThemeManager themeManager = editorSite.getWorkbenchWindow().getWorkbench().getThemeManager();
textViewer.getTextWidget().setFont(themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT));
final ActionContributorProxy actionContributor = getContributor();
if (actionContributor.getSelectionChangedListener() != null) {
textViewer.addSelectionChangedListener(actionContributor.getSelectionChangedListener());
}
textViewer.getTextWidget().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
actionContributor.updateSelectableActions(textViewer.getSelection());
}
public void focusLost(FocusEvent e) {
StyledText st = (StyledText) e.widget;
st.setSelectionRange(st.getCaretOffset(), 0);
actionContributor.forceActionsEnabled();
}
});
textViewer.addTextListener(new ITextListener() {
public void textChanged(TextEvent event) {
actionContributor.updateSelectableActions(textViewer.getSelection());
}
});
Document document = new Document(text);
StsTextViewerConfiguration viewerConfig = new StsTextViewerConfiguration(spellCheck, false);
textViewer.configure(viewerConfig);
textViewer.setDocument(document, annotationModel);
EditorUtil.setTextViewer(textViewer.getControl(), textViewer);
configureContextMenuManager(textViewer.getControl());
return textViewer;
}
use of org.eclipse.jface.text.source.IAnnotationAccess in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method initializeViewer.
private static ReconcilerViewer initializeViewer(Composite composite, int styles, boolean checkCode, IDocument document, int visibleOffset) {
IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
ISharedTextColors sharedColors = JavaPlugin.getDefault().getJavaTextTools().getColorManager();
IOverviewRuler overviewRuler = null;
IVerticalRuler verticalRuler = null;
if (checkCode) {
overviewRuler = new OverviewRuler(annotationAccess, 12, sharedColors);
Iterator e = EditorsPlugin.getDefault().getMarkerAnnotationPreferences().getAnnotationPreferences().iterator();
while (e.hasNext()) {
AnnotationPreference preference = (AnnotationPreference) e.next();
if (preference.contributesToHeader()) {
overviewRuler.addHeaderAnnotationType(preference.getAnnotationType());
}
}
}
verticalRuler = new CompositeRuler(12);
ReconcilerViewer viewer = new TalendJavaSourceViewer(composite, verticalRuler, overviewRuler, checkCode, styles, annotationAccess, sharedColors, checkCode, document);
if (visibleOffset != -1) {
viewer.setVisibleRegion(visibleOffset, 0);
}
return viewer;
}
use of org.eclipse.jface.text.source.IAnnotationAccess 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);
}
Aggregations