| [news.eclipse.platform] Re: How to access an editor's SourceViewer and AnnotationModel |
TextEditor activeEd = (TextEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
TextFileDocumentProvider tfdp = (TextFileDocumentProvider)activeEd.getDocumentProvider();
Document doc = (Document)tfdp.getDocument(Object obj);
AnnotationModel am = (AnnotationModel)tfdp.getAnnotationModel(Object obj);
The problem I have is I don't know what Object it wants and the documentation is not helpful in this area.
Once you have the TextEditor just call getSourceViewer() to get ISourceViewer, since the method is from AbstractTextEditor, which is extended by TextEditor. From there just get the AnnotationModel.