Page 1 of 1

System variables in actions

Posted: Thu Apr 16, 2015 5:26 pm
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

Re: System variables in actions

Posted: Fri Apr 17, 2015 9:33 am
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

Re: System variables in actions

Posted: Fri Apr 17, 2015 10:17 am
by xephon
Awesome, thanks Alex!

Have a nice weekend

Re: System variables in actions

Posted: Mon May 18, 2015 3:06 pm
by Radu
Hi,

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

Regards,
Radu