Page 1 of 1

No AuthorCaretListener in the Text View of the XML Editor

Posted: Fri Mar 23, 2012 1:59 pm
by SSC
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

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

Posted: Fri Mar 23, 2012 2:34 pm
by Radu
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

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

Posted: Fri Mar 23, 2012 3:17 pm
by SSC
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