System variables in actions

Oxygen general issues.
xephon
Posts: 160
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

System variables in actions

Post by xephon »

Hi,

I'd like to open a file via a framework action. This works well with:

Code: Select all

ro.sync.ecss.extensions.commons.operations.OpenInSystemAppOperation


Unfortunately I could not figure out, how to open a file in a user dir. System variables like %HOMEPATH% do not work and Oxygen Editor Variables do not work either. Any chance?

Best regards,
Stefan
stefan-jung.org – Your DITA/DITA-OT XML consultant
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: System variables in actions

Post by alex_jitianu »

Hello Stefan,

Indeed, this operation doesn't expand editor variables although I believe it should. Hopefully I'll be able to fix this for version 17.0 (there's not much time left till the release). Luckily this operation is public API so you can make the necessary change yourself, like this:
1. create the sample SDK project
2. focus on the sub-module oxygen-sample-framework
3. run a mvn generate-resources. A folder named samples will appear and in it you will find the source code for OpenInSystemAppOperation.
4. Copy it inside the project's Java source folder and expand the variables like this:

Code: Select all

toOpenVal = EditorVariables.expandEditorVariables(toOpenVal, authorAccess.getEditorAccess().getEditorLocation().toExternalForm());
If the operation receives this parameter it will now expand the variable (the start and end quote are important because the parameter is interpreted as an XPath expresssion so you mark it as a literal):

Code: Select all

"${env(HOMEPATH)}/a.html"
5. Run a mvn install. Look inside the target folder for a file named oxygen-sample-framework-0.0.1-SNAPSHOT.jar. This JAR must be added in the Classpath tab of the document type edit dialog and afterwards you can use your new action.

Best regards,
Alex
xephon
Posts: 160
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: System variables in actions

Post by xephon »

Awesome, thanks Alex!

Have a nice weekend
stefan-jung.org – Your DITA/DITA-OT XML consultant
Radu
Posts: 9437
Joined: Fri Jul 09, 2004 5:18 pm

Re: System variables in actions

Post by Radu »

Hi,

Just to update this thread, in Oxygen 17 the OpenInSystemAppOperation operation should expand editor variables by default.

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