Page 1 of 1

Catching new XREF node in Java code

Posted: Tue Dec 14, 2021 9:14 pm
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.

Re: Catching new XREF node in Java code

Posted: Wed Dec 15, 2021 1:40 pm
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

Re: Catching new XREF node in Java code

Posted: Thu Dec 16, 2021 7:29 pm
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

Re: Catching new XREF node in Java code

Posted: Fri Dec 17, 2021 10:04 am
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