Page 1 of 1

Adding ask editor variable type

Posted: Tue Jul 20, 2021 7:40 pm
by CheryBen
Hi, i'm working on a custom frameworks and I'm trying to use a ChangeAttributeOperation, and prompt the value to the end user.
The user should be able to change the text size and color of the current element, so this will output a color and size attributes.

This is actually working using
${ask('Color', editable_combobox, ('red':'Red';'blue':'Blue';'green':'Green'), '')}
and
${ask('Size')}

But this is a bit primitive, as the user is able to input whatever he wants.
Is there a way to customize the ask function or can I create a new one, to limit the input to numbers with min and max value for the size, and display a java color picker for the color ?

Thank you.

Re: Adding ask editor variable type

Posted: Wed Jul 21, 2021 10:45 am
by sorin_carbunaru
Hello,

If you would be willing to write some Java code, then you could add an EditorVariablesResolver using the API, and this way you can create your own variables.

If you want to see a simple example, you can take a look at this class from our Git Client Add-on.

All the best wishes,
Sorin Carbunaru
Oxygen XML Editor

Re: Adding ask editor variable type

Posted: Thu Jul 22, 2021 6:10 pm
by CheryBen
Thank you for suggestion, I'm testing a simplier approach using standard configuration, but this is a good option.

What i'm testing for now, is to configure the color list in an external file, such as :

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<properties>
    <entry key="style.colors">"'red':'Red';'blue':'Blue';'green':'Green'"</entry>
</properties>
and below is the value in action configuration, this works pretty well, it is configurable, and cheaper than a cool UI color picker.

Code: Select all

${ask(
    '${i18n(style.choose.color)}',
    editable_combobox,
    (${xpath_eval(
        if (doc-available('file:///${homeDir}/.authorNeo/AESTATWorkspace/AESTATProperties.xml'))
        then string(doc('file:///${homeDir}/.authorNeo/AESTATWorkspace/AESTATProperties.xml')/*:properties/*:entry[@key="style.colors"]/text())
        else "'red':'Red';'blue':'Blue';'green':'Green'"
    )})
)}