Catching new XREF node in Java code

Post here questions and problems related to oXygen frameworks/document types.
efren
Posts: 4
Joined: Tue Nov 15, 2016 9:32 pm

Catching new XREF node in Java code

Post by efren »

I'm working in a DITA customized framework, we are creating our own Image Map Editor. We want to reuse Oxygen's Insert Crossreference dialogue (DITAAccess.insertHref), but this function is inserting the new xref node directly into the AuthorDocument.

I need an option that returns a new ElementNode that I can manipulate and insert in a DOM tree, before saving the whole Image Map into the AuthorDocument.

What's the best approach to catch the new xref ElementNode created by DITAAccess.insertHref, or any other function?

Thanks for your assistance.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Catching new XREF node in Java code

Post by Radu »

Hi,

I'm afraid that's the API we have right now.
I see two possible solutions:
1) Implement a reference insertion dialog yourself. You can use the API "ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace.createEditorComponentProvider(String[], String)" to create the preview area where you would show a preview for each element.
2) (More of a hack) Before calling DITAAccess.insertHref create your own class which implements the "AuthorAccess" interface and delegates to our AuthorAccess, so create some kind of wrapper class over our AuthorAccess.
On the callback "ro.sync.ecss.extensions.api.AuthorAccess.getDocumentController()" return your own wrapper class over the AuthorDocumentController API which delegates to ours.
Oxygen's code will probably call the method "ro.sync.ecss.ue.AuthorDocumentController.insertXMLFragmentSchemaAware(String, int)" to insert the composed XML fragment in the editor and you could bypass and intercept it in your wrapper class.

REgards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
efren
Posts: 4
Joined: Tue Nov 15, 2016 9:32 pm

Re: Catching new XREF node in Java code

Post by efren »

Hola Radu:

I'm trying your option 2, using a custom DocumentController, but I'm getting a ClassCastException: CustomDocumentController cannot be cast to ro.sync.ecss.extensions.o.

Any idea for a work around?

Thanks for your help.
— Efrén
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Catching new XREF node in Java code

Post by Radu »

Hi Efrén,

I'm afraid I did not test the second solution I proposed to you, somewhere in our code Oxygen probably casts the AuthorDocumentController interface to its implementation and of course the implementation is not what it expects anymore. So you will probably need to re-implement the dialog.
Other than that let the dialog insert the content in the document and then copy what was inserted in the document, post process it, delete the original insertion from the document and then insert the post processed version.

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