Page 1 of 1

InsertConrefOperation on specific location

Posted: Tue Jan 03, 2017 6:03 pm
by hutz
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

Re: InsertConrefOperation on specific location

Posted: Wed Jan 04, 2017 10:45 am
by Radu
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

Re: InsertConrefOperation on specific location

Posted: Wed Jan 04, 2017 10:49 am
by Radu
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

Re: InsertConrefOperation on specific location

Posted: Wed Jan 04, 2017 3:39 pm
by hutz
Wonderful. I am going with the JS operation one as I have avoided actual Java until now.

Thanks!

Re: InsertConrefOperation on specific location

Posted: Wed Sep 06, 2017 8:25 pm
by hutz
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

Re: InsertConrefOperation on specific location

Posted: Thu Sep 07, 2017 8:16 am
by Radu
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

Re: InsertConrefOperation on specific location

Posted: Thu Sep 07, 2017 8:21 am
by hutz
Thanks Radu. Time to dig the Java API for good :!:

Edit: much better now!