Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Adding Squiggle lines to text
Adding Squiggle lines to text [message #147511] Tue, 21 October 2003 23:35 Go to next message
Eclipse UserFriend
Originally posted by: btcoxx.cs.wm.edu

Hi,

I'm trying to write a plugin that will put squiggle lines under certain
Positions of text and am having difficulty deciphering the documentation. I
gather that I need to get the AnnotationModel from the document provider. I
then need to call addAnnotation(Annotation annotation,Position position).

If I'm on the right track so far, I'm having trouble figuring out which
annotation I should put as the parameter to addAnnotation. If I need to
create a new instance of one of its subclasses, which one and how do I
configure it. If I need to pass in an annotation that already exists
somewhere, where is it?

If I'm talking gibberish, I apologize. Please point me in the right
direction.

Thanks in Advance

-Ben
Re: Adding Squiggle lines to text [message #147626 is a reply to message #147511] Wed, 22 October 2003 07:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.tkilla.ch

Ben Cox wrote:
> I'm trying to write a plugin that will put squiggle lines under
> certain Positions of text and am having difficulty deciphering the
> documentation. I gather that I need to get the AnnotationModel from
> the document provider. I then need to call addAnnotation(Annotation
> annotation,Position position).
>
> If I'm on the right track so far,

You are.

> I'm having trouble figuring out which annotation I should put as the
> parameter to addAnnotation. If I need to create a new instance of
> one of its subclasses, which one and how do I configure it. If I
> need to pass in an annotation that already exists somewhere, where is
> it?

You pass in a new annotation you created. You probably want to define
your own concrete subclass of Annotation (which is abstract).

Use the
org.eclipse.ui.workbench.texteditor.markerAnnotationSpecific ation
extension point if you want your annotation type to show up in the
preferences, so the user can configure whether and how it should show up
in the editor.

-tom
Re: Adding Squiggle lines to text [message #148864 is a reply to message #147626] Thu, 23 October 2003 23:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jmyron.ioconcepts.com

I've been watching this thread for several days in hopes that more
information would be added. I've implemented an editor extended from
TextEditor and have succeded in providing problem markers / annotations when
syntax errors are detected when running my parser/compiler. The problem
markers appear in the left margin sidebar and in the tasklist. I was hoping
I would also get little red squigglies underlining the first character of
the errant text and possibly a problem marker indicator on the tab of the
file. This is not the case. To get the functionality I've gotten thus far, I
didn't have to implement my own markers or anntotations. The snippet of code
that creates my markers and annotations during a syntax check:

IMarker parseError =
((IFileEditorInput)getEditorInput()).getFile().createMarker( "org.eclipse.cor
e.resources.problemmarker");
parseError.setAttribute(IMarker.MESSAGE, msg);
parseError.setAttribute(IMarker.LINE_NUMBER, parseE.getLine());
parseError.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
MarkerAnnotation markerAnot = new MarkerAnnotation(parseError);
IRegion info =
getDocumentProvider().getDocument(getEditorInput()).getLineI nformation(parse
E.getLine());
Position pos = new Position( info.getOffset() + parseE.getColumn(), 1);
IAnnotationModel am =
getDocumentProvider().getAnnotationModel(getEditorInput());
am.addAnnotation(markerAnot, pos);

Anyone reading this thread who knows how to do the following I'd appreciate
it if you'd clue me in:
1) what do I need to do to get the squiggly underline to appear in the
text area?
2) what do I need to do to get a problem indicator to appear on the
filename tab?
3) what is required to add popup characteristics to the annotations /
markers to display a text popup when the mouse cursor is passed over them?
Re: Adding Squiggle lines to text [message #149127 is a reply to message #148864] Fri, 24 October 2003 16:26 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse.tkilla.ch

J Myron Smith wrote:
> I've been watching this thread for several days in hopes that more
> information would be added. I've implemented an editor extended from
> TextEditor and have succeded in providing problem markers / annotations when
> syntax errors are detected when running my parser/compiler. The problem
> markers appear in the left margin sidebar and in the tasklist. I was hoping
> I would also get little red squigglies underlining the first character of
> the errant text and possibly a problem marker indicator on the tab of the
> file. This is not the case. To get the functionality I've gotten thus far, I
> didn't have to implement my own markers or anntotations.

Markers (something you can attach to a IResource) are shown as
annotations in the UI. If you want persistence, then Markers are what
you want. If you want just some temporary Annotation, you're better off
defining your own.

Note that the Marker / Annotation dependency is not always so clear and
will likely undergo some changes in the future.

> 1) what do I need to do to get the squiggly underline to appear in the
> text area?

Only marker types / annotations configured for display (see the
markerAnnotationSpecification extension point) are displayed. Use one of
the types defined or add your own extension.

> 2) what do I need to do to get a problem indicator to appear on the
> filename tab?

This is quite independent. See JavaEditorErrorTickUpdater for an example.

> 3) what is required to add popup characteristics to the annotations /
> markers to display a text popup when the mouse cursor is passed over them?

Yet another story. For example, see how TextViewerHoverManager fires up
text hovers (when hovering over the concerned text in the editor) or
AnnotationBarHoverManager for hovers over the vertical ruler (left hand
margin).

Hope this gives you some starting points, Tom
Previous Topic:Anonymous CVS to sourceforge accounts doesn't work here
Next Topic:How to lunch Eclipse programmatically (from Java app.)
Goto Forum:
  


Current Time: Thu May 09 19:36:03 GMT 2024

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

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

Back to the top