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

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

Wed Feb 14, 2018 11:40 am

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/19.1/ug-editor/topics/xml-id-idrefs-quick-assist-x-modes2.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: 2460

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

Thu Feb 15, 2018 5:51 pm

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

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

Thu Feb 15, 2018 8:50 pm

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: 5866

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

Fri Feb 16, 2018 12:29 pm

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/19.1/ug-editor/topics/workspace-access-plugin.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/Editor/SDK/javadoc/ro/sync/exml/workspace/api/standalone/actions/MenusAndToolbarsContributorCustomizer.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/19.1/ug-editor/topics/dg-author-link-target-reference-finder.html

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

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

Sun Mar 04, 2018 4:19 pm

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: 5866

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

Mon Mar 05, 2018 9:50 am

Hi,

Sure, however it suits you better.

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests