InsertConrefOperation on specific location

Post here questions and problems related to oXygen frameworks/document types.
hutz
Posts: 10
Joined: Thu Feb 18, 2016 5:15 pm

InsertConrefOperation on specific location

Post by hutz » Tue Jan 03, 2017 6:03 pm

Hello,

Can I pass an argument to ro.sync.ecss.extensions.dita.conref.InsertConrefOperation in my DITA Map framework to open the wizard with a specific reuse file as "Location"?

Thanks!
François

Radu
Posts: 6329
Joined: Fri Jul 09, 2004 5:18 pm

Re: InsertConrefOperation on specific location

Post by Radu » Wed Jan 04, 2017 10:45 am

Hi François,

You can create your own AuthorOperation custom Java operation which calls directly this static method from the ro.sync.ecss.dita.DITAAccess class:

Code: Select all

  /**
* Shows a dialog that allows inserting a content reference (conref).
*
* @param authorAccess The Author access.
* @param initialReferenceURL The default URL that will be displayed in the URL
* field of the insert reference dialog.
* <br>
* <b>Note: </b> this parameter is not used on Eclipse plugin implementation.
* @param displayReferenceUrl If <code>true</code> the URL input will be
* displayed in the insert reference dialog (the user will have the possibility
* to change the reference URL).
* This parameter can be set to <code>false</code> when an initialReferenceURL
* is provided, and the user must not have the possibility to change it
* (the reference URL must be fixed).
* <br>
* <b>Note: </b> this parameter is not used on Eclipse plugin implementation.
*
* @throws AuthorOperationException
*
* @since 14.2
*/
public static void insertContentReference(
final AuthorAccess authorAccess,
URL initialReferenceURL,
boolean displayReferenceUrl)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Radu
Posts: 6329
Joined: Fri Jul 09, 2004 5:18 pm

Re: InsertConrefOperation on specific location

Post by Radu » Wed Jan 04, 2017 10:49 am

Hi,

Or you can create an Author action based on the predefined JSOperation which invokes a script looking something like this:

Code: Select all

function doOperation(){
Packages.ro.sync.ecss.dita.DITAAccess.insertContentReference(authorAccess, new Packages.java.net.URL("http://www.google.com"), true);
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

hutz
Posts: 10
Joined: Thu Feb 18, 2016 5:15 pm

Re: InsertConrefOperation on specific location

Post by hutz » Wed Jan 04, 2017 3:39 pm

Wonderful. I am going with the JS operation one as I have avoided actual Java until now.

Thanks!

hutz
Posts: 10
Joined: Thu Feb 18, 2016 5:15 pm

Re: InsertConrefOperation on specific location

Post by hutz » Wed Sep 06, 2017 8:25 pm

Hello,

The following snippet works fine as the value of the arg-script parameter for the JSOperation in my .less file:

Code: Select all

oxy_concat(
'function doOperation(){ var url = Packages.ro.sync.ecss.dita.DITAAccess.insertContentReference(authorAccess, new Packages.java.net.URL("',
"${pdu}/reuse/", oxy_xpath("//map/@xml:lang"), "/customConrefFile.dita",
'")',
', true)}'
)
I would like to define the action in the .framework file directly (from the UI), but it seems it doesn't recognize oxy_xpath or oxy_concat ("Could not evaluate script: ReferenceError: "oxy_xpath" is not defined).
I've seen JSOperation-s that embarked oxy_ functions I think, so I must be wrong somewhere.

Current workaround would be to multiply the actions for language (with //map/@xml:lang = 'en',' fr', 'de' etc. as Activation XPath) but not too dynamic.

Thanks,
François

Radu
Posts: 6329
Joined: Fri Jul 09, 2004 5:18 pm

Re: InsertConrefOperation on specific location

Post by Radu » Thu Sep 07, 2017 8:16 am

Hi François,

Inside a JSOperation you can call all the Java-based API we have available. For example we have API which allows you to find nodes based on a certain XPath expression:

https://github.com/oxygenxml/javascript ... keyrefs.js

So even in your original CSS code you did not need to concat the strings so that you could use the CSS oxy_xpath function, you could have searched for the nodes based on XPath directly in the JSOperation code.

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

hutz
Posts: 10
Joined: Thu Feb 18, 2016 5:15 pm

Re: InsertConrefOperation on specific location

Post by hutz » Thu Sep 07, 2017 8:21 am

Thanks Radu. Time to dig the Java API for good :!:

Edit: much better now!

Post Reply