Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » JDT Java editor drawing box around text area
JDT Java editor drawing box around text area [message #230841] Wed, 07 June 2006 10:49 Go to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------010002090601030908060804
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

How does the JDT draw the box (the blue box in the attached image)
around the text area? I would greatly appreciate it if someone points
me the JDT code that does this.

please see attached image.

Thanks

--------------010002090601030908060804
Content-Type: image/gif;
name="jdtbox.gif"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="jdtbox.gif"

R0lGODlhVgGNAPcCAP///38AVQAAAOjy/kZkpf9L/xcNAQAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAABLW4AAAAMgAAHyRBRYE8NesAFEAEnyR BRUTeAVtAAB8
kQAAAJEEPQAAfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIoAAAAAAAA AAAAAAAAAAAA
AAAAAAAAAAAAAM4AAHyRMwDefdT8AAAAEgAVABLYeO4YAMB8kHyRQP///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n4Rl5G8aNSLOkbL3lGQGrx lB6FpTljylKD
DhGiEc2pMAUoxFLm0JQ83CAQ0flQnRo1l/5bqVF/mjylulOoBe3p7th51Kpa tYAStGBW14nT
q3r1q//TnljHSlaycq+rxMudWtfK1ra69a1wfc/s4nqdudIVOna962/yqlff 8LWvovkrYEMj
2ME+prCGtVBiF8vYxjr2sZCNrGQnS9nKWrZEiL3sTTKrWZpwtrMy+SxoYyLa 0baktKZlCWpT
q5LVsnZcr40SrWxnS9va2va2uM2tbneboYAAACH+ADs=
--------------010002090601030908060804--
Re: JDT Java editor drawing box around text area [message #230854 is a reply to message #230841] Wed, 07 June 2006 10:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tom_eicher.ch.ibm.com

AL wrote:
> How does the JDT draw the box (the blue box in the attached image)
> around the text area? I would greatly appreciate it if someone points
> me the JDT code that does this.

Hi AL,

the Java editor uses a linked mode setup to display the boxes, to manage
navigation between them, and to link multiple occurrences of the same
variable.

@see org.eclipse.jface.text.link.LinkedModeUI
@see org.eclipse.jface.text.link.LinkedModeModel

Alternatively, if you just want to draw boxes, but not have any special
editing behavior, you can do it using annotations.

@see org.eclipse.jface.text.source.Annotation
@see org.eclipse.ui.texteditor.MarkerAnnotationPreferences

-tom
Re: JDT Java editor drawing box around text area [message #230883 is a reply to message #230854] Wed, 07 June 2006 14:25 Go to previous messageGo to next message
Eclipse UserFriend
Tom Eicher wrote:

> AL wrote:
>
>> How does the JDT draw the box (the blue box in the attached image)
>> around the text area? I would greatly appreciate it if someone points
>> me the JDT code that does this.
>
>
> Hi AL,
>
> the Java editor uses a linked mode setup to display the boxes, to manage
> navigation between them, and to link multiple occurrences of the same
> variable.
>
> @see org.eclipse.jface.text.link.LinkedModeUI
> @see org.eclipse.jface.text.link.LinkedModeModel
>
> Alternatively, if you just want to draw boxes, but not have any special
> editing behavior, you can do it using annotations.
>
> @see org.eclipse.jface.text.source.Annotation
> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>
> -tom


Thanks very much, Tom, for the tips! I would prefer to use the jface
text framework because my editor is already using ISourceViewer, etc.
Re: JDT Java editor drawing box around text area [message #230890 is a reply to message #230854] Wed, 07 June 2006 14:48 Go to previous messageGo to next message
Eclipse UserFriend
Tom Eicher wrote:

> AL wrote:
>
>> How does the JDT draw the box (the blue box in the attached image)
>> around the text area? I would greatly appreciate it if someone points
>> me the JDT code that does this.
>
>
> Hi AL,
>
> the Java editor uses a linked mode setup to display the boxes, to manage
> navigation between them, and to link multiple occurrences of the same
> variable.
>
> @see org.eclipse.jface.text.link.LinkedModeUI
> @see org.eclipse.jface.text.link.LinkedModeModel
>
> Alternatively, if you just want to draw boxes, but not have any special
> editing behavior, you can do it using annotations.
>
> @see org.eclipse.jface.text.source.Annotation
> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>
> -tom

Sorry...One more question...I look at the documentation, and it says to
use SourceViewerDecorationSupport class which has all kinds of
strategies, including drawing the box around the text, the squiggly
line, etc.

my question is: How and/or under what conditions I kick start these
strategies? That is, what do I have to do to cause the drawing to start
and to reset the drawing?
Re: JDT Java editor drawing box around text area [message #230940 is a reply to message #230890] Thu, 08 June 2006 03:17 Go to previous messageGo to next message
Eclipse UserFriend
AL wrote:

> Tom Eicher wrote:
>
>> AL wrote:
>>
>>> How does the JDT draw the box (the blue box in the attached image)
>>> around the text area? I would greatly appreciate it if someone
>>> points me the JDT code that does this.
>>
>>
>>
>> Hi AL,
>>
>> the Java editor uses a linked mode setup to display the boxes, to
>> manage navigation between them, and to link multiple occurrences of
>> the same variable.
>>
>> @see org.eclipse.jface.text.link.LinkedModeUI
>> @see org.eclipse.jface.text.link.LinkedModeModel
>>
>> Alternatively, if you just want to draw boxes, but not have any
>> special editing behavior, you can do it using annotations.
>>
>> @see org.eclipse.jface.text.source.Annotation
>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>
>> -tom
>
>
> Sorry...One more question...I look at the documentation, and it says
> to use SourceViewerDecorationSupport class which has all kinds of
> strategies, including drawing the box around the text, the squiggly
> line, etc.
>
> my question is: How and/or under what conditions I kick start these
> strategies? That is, what do I have to do to cause the drawing to
> start and to reset the drawing?

This is automatically done if you add or remove your annotations.

Dani
Re: JDT Java editor drawing box around text area [message #231032 is a reply to message #230940] Thu, 08 June 2006 15:05 Go to previous messageGo to next message
Eclipse UserFriend
Daniel Megert wrote:

> AL wrote:
>
>> Tom Eicher wrote:
>>
>>> AL wrote:
>>>
>>>> How does the JDT draw the box (the blue box in the attached image)
>>>> around the text area? I would greatly appreciate it if someone
>>>> points me the JDT code that does this.
>>>
>>>
>>>
>>>
>>> Hi AL,
>>>
>>> the Java editor uses a linked mode setup to display the boxes, to
>>> manage navigation between them, and to link multiple occurrences of
>>> the same variable.
>>>
>>> @see org.eclipse.jface.text.link.LinkedModeUI
>>> @see org.eclipse.jface.text.link.LinkedModeModel
>>>
>>> Alternatively, if you just want to draw boxes, but not have any
>>> special editing behavior, you can do it using annotations.
>>>
>>> @see org.eclipse.jface.text.source.Annotation
>>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>>
>>> -tom
>>
>>
>>
>> Sorry...One more question...I look at the documentation, and it says
>> to use SourceViewerDecorationSupport class which has all kinds of
>> strategies, including drawing the box around the text, the squiggly
>> line, etc.
>>
>> my question is: How and/or under what conditions I kick start these
>> strategies? That is, what do I have to do to cause the drawing to
>> start and to reset the drawing?
>
>
> This is automatically done if you add or remove your annotations.
>
> Dani

So, got it...Just like markers. Thanks!
Re: JDT Java editor drawing box around text area [message #231074 is a reply to message #230940] Fri, 09 June 2006 02:30 Go to previous messageGo to next message
Eclipse UserFriend
Daniel Megert wrote:

> AL wrote:
>
>> Tom Eicher wrote:
>>
>>> AL wrote:
>>>
>>>> How does the JDT draw the box (the blue box in the attached image)
>>>> around the text area? I would greatly appreciate it if someone
>>>> points me the JDT code that does this.
>>>
>>>
>>>
>>>
>>> Hi AL,
>>>
>>> the Java editor uses a linked mode setup to display the boxes, to
>>> manage navigation between them, and to link multiple occurrences of
>>> the same variable.
>>>
>>> @see org.eclipse.jface.text.link.LinkedModeUI
>>> @see org.eclipse.jface.text.link.LinkedModeModel
>>>
>>> Alternatively, if you just want to draw boxes, but not have any
>>> special editing behavior, you can do it using annotations.
>>>
>>> @see org.eclipse.jface.text.source.Annotation
>>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>>
>>> -tom
>>
>>
>>
>> Sorry...One more question...I look at the documentation, and it says
>> to use SourceViewerDecorationSupport class which has all kinds of
>> strategies, including drawing the box around the text, the squiggly
>> line, etc.
>>
>> my question is: How and/or under what conditions I kick start these
>> strategies? That is, what do I have to do to cause the drawing to
>> start and to reset the drawing?
>
>
> This is automatically done if you add or remove your annotations.
>
> Dani

Oh, boy...I am still quite lost. I've been reading documentation and
that I can create a SourceViewerDecorationSupport and associate it to my
source viewer.

All I want to do is to draw a red box around a text range. I see that
SourceViewerDecorationSupport has the box strategy to draw the box
around a text range.

(1) How do I create the box annotation? I look at the Annotation class
and I can't find the annotation type id (a string) that represents the
box drawing strategy. Do I have to define extension points?

(2) where to I add and remove the annotation?

Thanks.
Re: JDT Java editor drawing box around text area [message #231091 is a reply to message #231074] Fri, 09 June 2006 04:00 Go to previous messageGo to next message
Eclipse UserFriend
AL wrote:

> Daniel Megert wrote:
>
>> AL wrote:
>>
>>> Tom Eicher wrote:
>>>
>>>> AL wrote:
>>>>
>>>>> How does the JDT draw the box (the blue box in the attached image)
>>>>> around the text area? I would greatly appreciate it if someone
>>>>> points me the JDT code that does this.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Hi AL,
>>>>
>>>> the Java editor uses a linked mode setup to display the boxes, to
>>>> manage navigation between them, and to link multiple occurrences of
>>>> the same variable.
>>>>
>>>> @see org.eclipse.jface.text.link.LinkedModeUI
>>>> @see org.eclipse.jface.text.link.LinkedModeModel
>>>>
>>>> Alternatively, if you just want to draw boxes, but not have any
>>>> special editing behavior, you can do it using annotations.
>>>>
>>>> @see org.eclipse.jface.text.source.Annotation
>>>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>>>
>>>> -tom
>>>
>>>
>>>
>>>
>>> Sorry...One more question...I look at the documentation, and it says
>>> to use SourceViewerDecorationSupport class which has all kinds of
>>> strategies, including drawing the box around the text, the squiggly
>>> line, etc.
>>>
>>> my question is: How and/or under what conditions I kick start these
>>> strategies? That is, what do I have to do to cause the drawing to
>>> start and to reset the drawing?
>>
>>
>>
>> This is automatically done if you add or remove your annotations.
>>
>> Dani
>
>
> Oh, boy...I am still quite lost. I've been reading documentation and
> that I can create a SourceViewerDecorationSupport and associate it to
> my source viewer.
>
> All I want to do is to draw a red box around a text range. I see that
> SourceViewerDecorationSupport has the box strategy to draw the box
> around a text range.
>
> (1) How do I create the box annotation? I look at the Annotation
> class and I can't find the annotation type id (a string) that
> represents the box drawing strategy. Do I have to define extension
> points?

Yep, see org.eclipse.ui.editors.annotationTypes and
org.eclipse.ui.editors.markerAnnotationSpecification extension points.
There you can specify BOX text style.

>
> (2) where to I add and remove the annotation?

On the annotation model (which you get from your document provider).

Dani

>
> Thanks.
Re: JDT Java editor drawing box around text area [message #231123 is a reply to message #231091] Fri, 09 June 2006 13:43 Go to previous messageGo to next message
Eclipse UserFriend
Daniel Megert wrote:

> AL wrote:
>
>> Daniel Megert wrote:
>>
>>> AL wrote:
>>>
>>>> Tom Eicher wrote:
>>>>
>>>>> AL wrote:
>>>>>
>>>>>> How does the JDT draw the box (the blue box in the attached image)
>>>>>> around the text area? I would greatly appreciate it if someone
>>>>>> points me the JDT code that does this.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Hi AL,
>>>>>
>>>>> the Java editor uses a linked mode setup to display the boxes, to
>>>>> manage navigation between them, and to link multiple occurrences of
>>>>> the same variable.
>>>>>
>>>>> @see org.eclipse.jface.text.link.LinkedModeUI
>>>>> @see org.eclipse.jface.text.link.LinkedModeModel
>>>>>
>>>>> Alternatively, if you just want to draw boxes, but not have any
>>>>> special editing behavior, you can do it using annotations.
>>>>>
>>>>> @see org.eclipse.jface.text.source.Annotation
>>>>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>>>>
>>>>> -tom
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Sorry...One more question...I look at the documentation, and it says
>>>> to use SourceViewerDecorationSupport class which has all kinds of
>>>> strategies, including drawing the box around the text, the squiggly
>>>> line, etc.
>>>>
>>>> my question is: How and/or under what conditions I kick start these
>>>> strategies? That is, what do I have to do to cause the drawing to
>>>> start and to reset the drawing?
>>>
>>>
>>>
>>>
>>> This is automatically done if you add or remove your annotations.
>>>
>>> Dani
>>
>>
>>
>> Oh, boy...I am still quite lost. I've been reading documentation and
>> that I can create a SourceViewerDecorationSupport and associate it to
>> my source viewer.
>>
>> All I want to do is to draw a red box around a text range. I see that
>> SourceViewerDecorationSupport has the box strategy to draw the box
>> around a text range.
>>
>> (1) How do I create the box annotation? I look at the Annotation
>> class and I can't find the annotation type id (a string) that
>> represents the box drawing strategy. Do I have to define extension
>> points?
>
>
> Yep, see org.eclipse.ui.editors.annotationTypes and
> org.eclipse.ui.editors.markerAnnotationSpecification extension points.
> There you can specify BOX text style.
>
>>
>> (2) where to I add and remove the annotation?
>
>
> On the annotation model (which you get from your document provider).
>
> Dani
>
>>
>> Thanks.

thanks again for the response...My scenerio is that I don't use the
documentation provider at all. I "embed" my source viewer (editable) in
a layout, just like how the JDT shows when you do
"Preferences->Java-Editor->Syntax Coloring".

Can I simply create the IAnnotationModel (that is, AnnotationModel
class) and connect it to my IDocument? But the question is: What is
the relationship with the annotation model and the source view and/or
the source viewer configuration? When I do
IAnnotationModel.addAnnotation(...), how would the source viewer to told
to do the box?

Thanks so much for your help so far.
Re: JDT Java editor drawing box around text area [message #231130 is a reply to message #231123] Fri, 09 June 2006 14:22 Go to previous messageGo to next message
Eclipse UserFriend
AL wrote:

> Daniel Megert wrote:
>
>> AL wrote:
>>
>>> Daniel Megert wrote:
>>>
>>>> AL wrote:
>>>>
>>>>> Tom Eicher wrote:
>>>>>
>>>>>> AL wrote:
>>>>>>
>>>>>>> How does the JDT draw the box (the blue box in the attached
>>>>>>> image) around the text area? I would greatly appreciate it if
>>>>>>> someone points me the JDT code that does this.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi AL,
>>>>>>
>>>>>> the Java editor uses a linked mode setup to display the boxes, to
>>>>>> manage navigation between them, and to link multiple occurrences
>>>>>> of the same variable.
>>>>>>
>>>>>> @see org.eclipse.jface.text.link.LinkedModeUI
>>>>>> @see org.eclipse.jface.text.link.LinkedModeModel
>>>>>>
>>>>>> Alternatively, if you just want to draw boxes, but not have any
>>>>>> special editing behavior, you can do it using annotations.
>>>>>>
>>>>>> @see org.eclipse.jface.text.source.Annotation
>>>>>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>>>>>
>>>>>> -tom
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Sorry...One more question...I look at the documentation, and it
>>>>> says to use SourceViewerDecorationSupport class which has all kinds
>>>>> of strategies, including drawing the box around the text, the
>>>>> squiggly line, etc.
>>>>>
>>>>> my question is: How and/or under what conditions I kick start these
>>>>> strategies? That is, what do I have to do to cause the drawing to
>>>>> start and to reset the drawing?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> This is automatically done if you add or remove your annotations.
>>>>
>>>> Dani
>>>
>>>
>>>
>>>
>>> Oh, boy...I am still quite lost. I've been reading documentation and
>>> that I can create a SourceViewerDecorationSupport and associate it to
>>> my source viewer.
>>>
>>> All I want to do is to draw a red box around a text range. I see
>>> that SourceViewerDecorationSupport has the box strategy to draw the
>>> box around a text range.
>>>
>>> (1) How do I create the box annotation? I look at the Annotation
>>> class and I can't find the annotation type id (a string) that
>>> represents the box drawing strategy. Do I have to define extension
>>> points?
>>
>>
>>
>> Yep, see org.eclipse.ui.editors.annotationTypes and
>> org.eclipse.ui.editors.markerAnnotationSpecification extension points.
>> There you can specify BOX text style.
>>
>>>
>>> (2) where to I add and remove the annotation?
>>
>>
>>
>> On the annotation model (which you get from your document provider).
>>
>> Dani
>>
>>>
>>> Thanks.
>
>
> thanks again for the response...My scenerio is that I don't use the
> documentation provider at all. I "embed" my source viewer (editable) in
> a layout, just like how the JDT shows when you do
> "Preferences->Java-Editor->Syntax Coloring".
>
> Can I simply create the IAnnotationModel (that is, AnnotationModel
> class) and connect it to my IDocument? But the question is: What is
> the relationship with the annotation model and the source view and/or
> the source viewer configuration? When I do
> IAnnotationModel.addAnnotation(...), how would the source viewer to told
> to do the box?
>
> Thanks so much for your help so far.

I see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int).
I can set my own annotation model, even though the annotation model
in the org.eclipse.jface.text.source.SourceViewer, which my source
viewer derives off, says that it is for the ruler annotation. Sounds
like the right usage?

thanks.
Re: JDT Java editor drawing box around text area [message #231246 is a reply to message #231130] Mon, 12 June 2006 09:58 Go to previous message
Eclipse UserFriend
AL wrote:

> AL wrote:
>
>> Daniel Megert wrote:
>>
>>> AL wrote:
>>>
>>>> Daniel Megert wrote:
>>>>
>>>>> AL wrote:
>>>>>
>>>>>> Tom Eicher wrote:
>>>>>>
>>>>>>> AL wrote:
>>>>>>>
>>>>>>>> How does the JDT draw the box (the blue box in the attached
>>>>>>>> image) around the text area? I would greatly appreciate it if
>>>>>>>> someone points me the JDT code that does this.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Hi AL,
>>>>>>>
>>>>>>> the Java editor uses a linked mode setup to display the boxes,
>>>>>>> to manage navigation between them, and to link multiple
>>>>>>> occurrences of the same variable.
>>>>>>>
>>>>>>> @see org.eclipse.jface.text.link.LinkedModeUI
>>>>>>> @see org.eclipse.jface.text.link.LinkedModeModel
>>>>>>>
>>>>>>> Alternatively, if you just want to draw boxes, but not have any
>>>>>>> special editing behavior, you can do it using annotations.
>>>>>>>
>>>>>>> @see org.eclipse.jface.text.source.Annotation
>>>>>>> @see org.eclipse.ui.texteditor.MarkerAnnotationPreferences
>>>>>>>
>>>>>>> -tom
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Sorry...One more question...I look at the documentation, and it
>>>>>> says to use SourceViewerDecorationSupport class which has all
>>>>>> kinds of strategies, including drawing the box around the text,
>>>>>> the squiggly line, etc.
>>>>>>
>>>>>> my question is: How and/or under what conditions I kick start
>>>>>> these strategies? That is, what do I have to do to cause the
>>>>>> drawing to start and to reset the drawing?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> This is automatically done if you add or remove your annotations.
>>>>>
>>>>> Dani
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Oh, boy...I am still quite lost. I've been reading documentation
>>>> and that I can create a SourceViewerDecorationSupport and associate
>>>> it to my source viewer.
>>>>
>>>> All I want to do is to draw a red box around a text range. I see
>>>> that SourceViewerDecorationSupport has the box strategy to draw the
>>>> box around a text range.
>>>>
>>>> (1) How do I create the box annotation? I look at the Annotation
>>>> class and I can't find the annotation type id (a string) that
>>>> represents the box drawing strategy. Do I have to define extension
>>>> points?
>>>
>>>
>>>
>>>
>>> Yep, see org.eclipse.ui.editors.annotationTypes and
>>> org.eclipse.ui.editors.markerAnnotationSpecification extension
>>> points. There you can specify BOX text style.
>>>
>>>>
>>>> (2) where to I add and remove the annotation?
>>>
>>>
>>>
>>>
>>> On the annotation model (which you get from your document provider).
>>>
>>> Dani
>>>
>>>>
>>>> Thanks.
>>>
>>
>>
>> thanks again for the response...My scenerio is that I don't use the
>> documentation provider at all. I "embed" my source viewer (editable)
>> in a layout, just like how the JDT shows when you do
>> "Preferences->Java-Editor->Syntax Coloring".
>>
>> Can I simply create the IAnnotationModel (that is, AnnotationModel
>> class) and connect it to my IDocument? But the question is: What is
>> the relationship with the annotation model and the source view and/or
>> the source viewer configuration? When I do
>> IAnnotationModel.addAnnotation(...), how would the source viewer to
>> told to do the box?
>>
>> Thanks so much for your help so far.
>
>
> I see ISourceViewer#setDocument(IDocument, IAnnotationModel, int,
> int). I can set my own annotation model, even though the annotation
> model in the org.eclipse.jface.text.source.SourceViewer, which my
> source viewer derives off, says that it is for the ruler annotation.
> Sounds like the right usage?

And you must setup the source viewer decoration support. See
AbstractDecoratedTextEditor for a template how to do this.

Dani

>
> thanks.
Previous Topic:AST walking of large sources
Next Topic:Eclipse Editor Environment
Goto Forum:
  


Current Time: Mon Nov 10 08:27:57 EST 2025

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

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

Back to the top