Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Using visual annotations with JDT text editor
Using visual annotations with JDT text editor [message #635715] Wed, 27 October 2010 15:39 Go to next message
Eclipse UserFriend
Hello,

I'd like to highlight certain regions of a JDT text editior (e.g. variables). I think this can be done with annotations and markers and I've started by adding code:

IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
	    			
Annotation annotation = new Annotation("type", true, "text");
annotationModel.addAnnotation(annotation, new Position(textSelected.getOffset(), textSelected.getLength()));


I'm not sure what "type" and "text" should be. Also, how Markers fit. I guess I could use a standard marker and associate that with those areas of text I would like to highlight but it would be better if I could highlight with squiggly colored lines or similar.

Any pointers to a tutorial or cookbook code to do this would be helpful

Chris
Re: Using visual annotations with JDT text editor [message #636107 is a reply to message #635715] Fri, 29 October 2010 06:23 Go to previous message
Eclipse UserFriend
Chris wrote:
> Hello,
>
> I'd like to highlight certain regions of a JDT text editior (e.g.
> variables). I think this can be done with annotations and markers and
> I've started by adding code:
>
>
> IAnnotationModel annotationModel =
> editor.getDocumentProvider().getAnnotationModel(editor.getEd itorInput());
>
> Annotation annotation = new Annotation("type", true, "text");
> annotationModel.addAnnotation(annotation, new
> Position(textSelected.getOffset(), textSelected.getLength()));
>
>
> I'm not sure what "type" and "text" should be. Also, how Markers fit.
> I guess I could use a standard marker and associate that with those
> areas of text I would like to highlight but it would be better if I
> could highlight with squiggly colored lines or similar.
>
> Any pointers to a tutorial or cookbook code to do this would be helpful
http://www.eclipse.org/eclipse/platform-text/eclipseCon/2006 /texteditorrecipes.zip

Dani
>
> Chris
>
Previous Topic:Build Path Order (possiblya bug?)
Next Topic:eclipse crashes at startup with jvm failure
Goto Forum:
  


Current Time: Wed Jul 02 18:05:19 EDT 2025

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

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

Back to the top