Adding ask editor variable type

Post here questions and problems related to oXygen frameworks/document types.
CheryBen
Posts: 24
Joined: Tue Jun 05, 2012 10:34 am

Adding ask editor variable type

Post 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.
sorin_carbunaru
Posts: 397
Joined: Mon May 09, 2016 9:37 am

Re: Adding ask editor variable type

Post 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
CheryBen
Posts: 24
Joined: Tue Jun 05, 2012 10:34 am

Re: Adding ask editor variable type

Post 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'"
    )})
)}
Post Reply