Run JSOperation on multiple topics

Post here questions and problems related to oXygen frameworks/document types.
Bruno.Ballarin
Posts: 25
Joined: Thu Aug 07, 2014 3:40 pm

Run JSOperation on multiple topics

Post by Bruno.Ballarin »

Hi,

I am seeking guidance as per which direction to go for running a JSOperation to multiple topics at a time, without having to select each topic one after the other and click my JSOperation action button for each one.

Should I think into creating a transformation scenario? Can I call a JSOperation from a transformation scenario and how?

Should I develop my JSOperation so that it is able to invoke other opened topics (than the one where the carret is currently positioned)? Does the WSEditorBase interface useful? An example would help showing how to run a simple JSOperation let says:
  • on all currently opened topics?
  • on all open topics of the currently Active map in DitaMap manager?
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Run JSOperation on multiple topics

Post by Radu »

Hi Bruno,

An Oxygen plugin can add actions to the Project view or to the DITA Maps Manager view. And an action provided by the plugin can for example programmatically open XML documents in the main editing area and change them.
There is a sample Javascript-based plugin created by my colleague Cosmin which invokes a certain Author action (specified by ID) on all XML documents selected in the Project view:

https://github.com/oxygenxml/wsaccess-j ... tResources

The API used by the plugin "pluginWorkspaceAccess.createEditorComponentProvider" creates a visual editor in-memory, without opening the XML in the main editing area.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Bruno.Ballarin
Posts: 25
Joined: Thu Aug 07, 2014 3:40 pm

Re: Run JSOperation on multiple topics

Post by Bruno.Ballarin »

Thanks Radu, seems promising,

I have been able to install the performAuthorActionOnProjectResources plugin and to edit the config.xml file in order to point to my own Dita Author action ID.

I built a project where I added the batch of Dita xml topics I need to be processed. In the project window I select all the topics, then right click, and run the new menu item made available in the Project contextual Menu thanks to the above plugin :D .

I got a " 'mymenuItemName' finished " message in Oxygen so I know the process has been completed and I can see that the "Date modified" properties of my topics are updated in windows explorer, however when I open the topics, I don't see the modifications I would have expected.

I tried again with a more simple Dita Autor action (without js operation, just using standard InsertFragmentOperation) but same observation that the topics, despite being edited and saved, do not seem to have been processed with the invoked Author Action.

I also tried to put a pop-up in my Author Action, the pop-up appears when I run the Action from the Author toolbar but I have no pop-up if I run the Author Action through the new Menu Item from the Project contextual menu.

I put a trace within the plugin wsAccess.js file in order to retrieve the replaceReferenceContentAction variable and it returns what seems to be a valid Action ID = ro.sync.ecss.extensions.fb@6d11c (I say valid ID because I also tried altering on purpose the Action ID in the plugin config.xml file and it this case I got an empty replaceReferenceContentAction variable)
Cosmin Duna
Site Admin
Posts: 120
Joined: Wed Dec 12, 2018 5:33 pm

Re: Run JSOperation on multiple topics

Post by Cosmin Duna »

Hello Bruno,

The plugin detect your action as disable.
For fix this you should complete with 'true()' the 'Activation XPath' field from the dialog where you edit or create the action.

Regards,
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
Bruno.Ballarin
Posts: 25
Joined: Thu Aug 07, 2014 3:40 pm

Re: Run JSOperation on multiple topics

Post by Bruno.Ballarin »

Oh that's it! Thank you very much to you both :D .

I lost the habit to put the true() when no particular activation Xpath was needed because I did not see the difference :? .

Cheers,

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

Re: Run JSOperation on multiple topics

Post by Radu »

Hi Bruno,

An empty xpath expression is considered by Oxygen to be equivalent to (self::*), meaning that if the cursor is not inside an XML element (maybe the cursor is at the start of the document before the root element) the action is not enabled. So indeed if you always want to force an action to be enabled use true().

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