Skip to main content



      Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Eclipse custom texteditor - marker annotation presentation issue
Eclipse custom texteditor - marker annotation presentation issue [message #1041040] Sun, 14 April 2013 10:22
Eclipse UserFriend
I want to write an eclipse plugin for my computer science lecturer. It's a custom editor with an xml based file format.
I've implemented syntax highlighting and other stuff. But I stuck when it comes to the usage of annotations/marker to show invalid content.

This is how it looks like, if the content is valid:
image-upload.de/image/aPcsaa/6c799a671c.png

This is how it looks like, if the content is invalid:
image-upload.de/image/4TdooQ/04d662f397.png


NOTE: would like to use direct images here, but I'm not allowed to... (thanks to this great restriction)


As you can see, invalid attributes will get marked, but the problem is, the whole formatting seems to be lost between these annotations.


I use
org.eclipse.jface.text.reconciler.Reconciler
for delayed parsing of the content to create the document model. The model is used to format the text and display annotations. All this happens in the void
void process(DirtyRegion dirtyRegion)
method of the
Reconciler
.

For text formatting I use
<ITextViewer>.changeTextPresentation(textAttributes, false)
and for annotation handling I use


IAnnotationModel annotationModel = <ISourceViewer>.getAnnotationModel();
IAnnotationModelExtension annotationModelExtension = (IAnnotationModelExtension) annotationModel;
annotationModelExtension.replaceAnnotations(oldAnnotations, newAnnotations);



Since the
Reconciler
does not use the swt thread I have to use this construct to avoid exceptions:

<ITextViewer>.getTextWidget().getDisplay().asyncExec(new Runnable() {
  @Override
  public void run() {

    <ITextViewer>.changeTextPresentation(textAttributes, false);
    updateAnnotations(nodes);
  }
});


By the way
ITextViewer
and
ISourceViewer
are meant as the same viewer object.

As annotation type I've testet:
org.eclipse.ui.workbench.texteditor.spelling
and some others, also custom types, but all with the same result.


I'm not quite sure, what I'm doing wrong, could it be because it is all in a single call?


I hope someone can help me with this problem.

Thank you in advance.

[Updated on: Sun, 14 April 2013 10:24] by Moderator

Previous Topic:Require custom messages while editing a read-only file in the workbench
Next Topic:Missing templates in exported Eclipse
Goto Forum:
  


Current Time: Mon Jul 07 16:42:30 EDT 2025

Powered by FUDForum. Page generated in 0.06676 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top