No AuthorCaretListener in the Text View of the XML Editor

<oXygen/> general issues.
SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

No AuthorCaretListener in the Text View of the XML Editor

Post by SSC » Fri Mar 23, 2012 1:59 pm

Hello,

I just realized that the Text View of the XML Editor is just an instance of the ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage and therefore I cannot add an AuthorCaretListener to it.
Even thought your Attributes View is able to show the attributes of a XML Node, which is selected on the ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.
May I ask how do you achieve that, while not having an AuthorCaretListener, which informs you about the selected AuthorNode?

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Radu
Posts: 6806
Joined: Fri Jul 09, 2004 5:18 pm

Re: No AuthorCaretListener in the Text View of the XML Editor

Post by Radu » Fri Mar 23, 2012 2:34 pm

Hi Simon,

There is a method called:

Code: Select all

/**
* Get the internal text component which is currently used for editing.
*
* @return for the stand alone version, a javax.swing.JTextArea and for the eclipse implementation a org.eclipse.swt.custom.StyledText.
*
* @since 12
*/
Object ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.getTextComponent();
which can be used to obtain the org.eclipse.swt.custom.StyledText which is used in the text page.

Eclipse 3.5 added the possibility to add a caret listener to a StyledText, if you want to be compatible with older versions of Eclipse you can add both a mouse and a key listener in order to fire caret move events (we do this in order to be backward compatible with Eclipse 3.3 and 3.4).

But the Text view does not share a common internal node structure with the Author page.

In our internal implementation of the Text page we have access to a structure which resembles a hierarchy of nodes but this structure is not exposed in the API.

But even in the Text page you have access to this API method:

Code: Select all

/**
* Get the schema manager used to ask useful information about allowed elements and the context of the current offset.
* @return the XML Schema Manager used to ask useful information about allowed elements and the context of the current offset.
* Only available for opened XML files.
*
* @since 12.1
*/
WSTextXMLSchemaManager ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.getXMLSchemaManager();
which should give you an indication about the context in which the caret is placed but there is no API to precisely alter elements, set attributes like there is in the Author page.

For Oxygen 14 we also plan to add API to find the range of certain XML elements in the text page by running an XPath 2.0 expression.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: No AuthorCaretListener in the Text View of the XML Editor

Post by SSC » Fri Mar 23, 2012 3:17 pm

Ok thanks for your replay.

For now we decided to leave out the support for the text view, because you could actually edit the attributes directly in the text view of the XML Editor.

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Post Reply