Gettinng the currently selected XML Element (Oxygen Plugin)

Oxygen general issues.
fwn
Posts: 3
Joined: Tue May 11, 2010 1:20 pm

Gettinng the currently selected XML Element (Oxygen Plugin)

Post by fwn »

Hi,

an application I'm working on will have XML documents with references to other documents or images in them. When the user left clicks on an element that has such a reference I would like to have an option in the contextmenu that allows him to open the referenced object.

In eclipses wst xml Editor I can do this rather easily by listening for SelectionEvents and processing the IStructuredSelections thrown, however this won't work with the Oxygen Plugin since its Editor seems to throw TextSelections.

The Outline uses StructuredSelections, so I tried to work with those, but since the contained elements are internal classes of the plugin (Package ro.sync.outline.xml) I couldn't get it to work that way either.

Is there any way to get the Element that is selected in the Editor from outside of the Plugin?
Alternatively, is there a way to get the Editors DocumentProvider so that I can use the TextSelections to get the element from the document?
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: Gettinng the currently selected XML Element (Oxygen Plugin)

Post by Mircea »

Hi Florian,

The text page of our multi-page XML editor is based on Eclipse's TextEditor, and there is no DOM model behind it.

The multipage editor is derived from the org.eclipse.ui.part.MultiPageEditorPart so casting to it and requesting getSelectedPage() shoud give you the XML text editor, which at its turn is derived from the Eclipse's org.eclipse.ui.editors.text.TextEditor.

This should help,
Mircea
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
fwn
Posts: 3
Joined: Tue May 11, 2010 1:20 pm

Re: Gettinng the currently selected XML Element (Oxygen Plugin)

Post by fwn »

Thank you very much, that helped me solve my problem :D
Post Reply