Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 19:39 Go to next message
Chris  is currently offline Chris Friend
Messages: 5
Registered: October 2010
Junior Member
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 10:23 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
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: Thu Apr 25 03:31:30 GMT 2024

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

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

Back to the top