How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post here questions and problems related to oXygen frameworks/document types.
serioadamo97
Posts: 22
Joined: Tue Oct 17, 2017 5:05 pm

How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post by serioadamo97 »

For example, in XSLT we have following code:

Code: Select all


    <xsl:template match="/">
<xsl:call-template name="foo"/>
</xsl:template>

<xsl:template name="foo">
<foo></foo>
</xsl:template>
When we place the cursor inside "foo" , we can click "Show Definition" button (or use Quick Assist) and then the cursor will jump to definition.

My question is how to customize "Show Definition" (or Quick Assist) feature for my own framework?

I know that using ID/IDREF(https://www.oxygenxml.com/doc/versions/ ... odes2.html) can implement this feature. But ID/IDREF has a lot of restrictions.(eg: D/IDREF must be unique globally and it does not support scoping-based symbol find.)

Thanks.
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post by adrian »

Hi,
My question is how to customize "Show Definition" (or Quick Assist) feature for my own framework?
In short you can't, it's not customizable, there's no API to redefine its behavior.
The implementation is completely different for each specialized editor. For XML files "Show Definition" will go to the schema and show you where that element or attribute is declared. For XSL it's implemented differently and shows the definition of the respective variable, template or function.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
serioadamo97
Posts: 22
Joined: Tue Oct 17, 2017 5:05 pm

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post by serioadamo97 »

adrian wrote:Hi,
My question is how to customize "Show Definition" (or Quick Assist) feature for my own framework?
In short you can't, it's not customizable, there's no API to redefine its behavior.
The implementation is completely different for each specialized editor. For XML files "Show Definition" will go to the schema and show you where that element or attribute is declared. For XSL it's implemented differently and shows the definition of the respective variable, template or function.

Regards,
Adrian
Hi Adrian,
Thanks for your answer.

I found some document on oxygenxml website:
https://www.oxygenxml.com/doc/versions/ ... inder.html

It says that :
The link target reference finder represents the support for finding references from links that indicate specific elements inside an XML document.

Is this can implement this feature? (Or I understand what it meant?)
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post by Radu »

Hi,

Adrian asked me to help you with this.
So if you implement a workspace access plugin for Oxygen:

https://www.oxygenxml.com/doc/versions/ ... lugin.html

You can add a menus and toolbars customizer:

Code: Select all

ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace.addMenusAndToolbarsContributorCustomizer(MenusAndToolbarsContributorCustomizer)
https://www.oxygenxml.com/InstData/Edit ... mizer.html

which allows you to customize the popup menu for the text page:

customizeTextPopUpMenu(javax.swing.JPopupMenu popUp, WSTextEditorPage textPage)

If the opened document is XML, the "textPage" can actually be cast to ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextEditorPage which gives you access to more API (for example execute XPath expressions).
You also have access to the caret offset WSTextBasedEditorPage.getCaretOffset() and even to the Swing JTextArea "WSTextEditorPage.getTextComponent()".
So you could try to add a contextual menu action which when pressed could look in the current document and then try to open another document at another location using an API like "ro.sync.exml.workspace.api.Workspace.open(URL)".
If that URL contains a custom anchor inside it like:

"file:/.../test.xml#myCustomAnchor"

then the job of finding the place in the opened XML document is then delegated to the link target element finder for which you already found a resource:

https://www.oxygenxml.com/doc/versions/ ... inder.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
serioadamo97
Posts: 22
Joined: Tue Oct 17, 2017 5:05 pm

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post by serioadamo97 »

Thanks, it works.
But finally, I used the XPath expression instead of developing extra plug-ins to implement the feature of Show Definition.
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to customize "Show Definition" (or Quick Assist) feature for my own framework?

Post by Radu »

Hi,

Sure, however it suits you better.

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