Page 1 of 1
Resolve editor variables in string parameter default values of refactoring operations
Posted: Wed Dec 21, 2022 7:30 pm
by chrispitude
In an XSLT refactoring operation, I would like the default value of a string parameter to default to the current user ID by using an
Oxygen editor variable:
Code: Select all
<parameter type="TEXT" name="my-string-user" label="my-string-user">
<description>my-string-user, defaults to ${author.name}</description>
<possibleValues>
<value name="string-default" default="true">${author.name}</value>
</possibleValues>
</parameter>
However, currently editor variables are not resolved:
image.png
It would be great if this were supported. (It would be nice if they also resolved in the descriptions, but this is not necessary as the default value will make itself obvious.)
A testcase is included:
oxygen_refactoring_string_default_vars.zip
Re: Resolve editor variables in string parameter default values of refactoring operations
Posted: Thu Dec 22, 2022 11:50 am
by Radu
Hi Chris,
I added your comment on an already opened internal issue:
EXM-33203 XML Refactoring operations should be able to use and expand editor variables
So ideally we should expand editor variables in parameter values before they are passed to the XML refactoring stylesheets.
But you do have an uglier workaround, call a static Java method we provide directly in the XSLT code to expand editor variables:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="3.0"
xmlns:edVars="java:ro.sync.util.editorvars.EditorVariables">
<xsl:template match="node() | @*">
<xsl:message><xsl:value-of select="edVars:expandEditorVariables('${author.name}', '')"/></xsl:message>
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
So if for example the end user leaves the author name parameter empty, you could expand in the XSLT stylesheet the ${author.name} editor variable and use that instead.
Regards,
Radu
Re: Resolve editor variables in string parameter default values of refactoring operations
Posted: Fri Dec 23, 2022 6:43 pm
by chrispitude
Thanks Radu!
In my testcase, TEXT parameters do not accept empty values; the Next and Finish buttons are disabled until text is present in every TEXT field.
Some TEXT parameters might require values while others are optional and can be blank. Is there a way to specify this in the descriptor file?
Re: Resolve editor variables in string parameter default values of refactoring operations
Posted: Mon Jan 02, 2023 9:00 am
by Radu
Hi Chris,
I think specifying optional=true on it should work:
Code: Select all
<parameter type="TEXT" name="my-string-user" label="my-string-user" optional="true">
Regards,
Radu