|Re: Changing focus/cursor position with hyperlink in an XML Editor [message #227692 is a reply to message #227651]
||Thu, 12 February 2009 01:46
| Nitin Dahyabhai
Registered: July 2009
Xavier Coulon wrote:|
> I'm trying to provide custom hyperlinks in an XML Editor. These
> hyperlinks should bring the user (focus and/or cursor position) on
> another XMLeElement of the current document in the current editor (ie,
> just move within the current xml document).
> How should I implement the open() method brought by the IHyperlink
> interface in my custom Hyperlink class ? Do you have any example ?
For the same file, all you should need to do is set the text
viewer's selection to the new Element as an ITextSelection with its
start offset and a length, and possibly call
ITextViewer.revealRange() to make sure it's scrolled to. You should
already have access to the viewer from your implementation of
IHyperlinkDetector.detectHyperlinks(ITextViewer, IRegion, boolean),
so just have your hyperlink object ask it for its ISelectionProvider
and set your new selection through it.
Once you have the basics working, be sure to go back and revisit
ITextViewerExtension5, as you will need to use it to properly work
in situations where the source has been folded.
Eclipse WTP Source Editing
Eclipse WTP, IBM
Powered by FUDForum
. Page generated in 0.01614 seconds