33.2 Customizing the Dialog Output
Because the id of a widget can be any string, you can construct a wide variety of output formats simply by changing the form of the id. Some common use-cases are:
id=" -name " => -name value
id=" +incdir+" => +incdir+value
id=" name=" => name=value
The dvt:Container widget
This widget acts just like a
Composite (i.e. you can surround sets of widgets or composites with it), but also takes some configuration
parameters that are applied for all the widgets it contains.
XML
<dvt:Container layout="layout:grid;" parameters="checkboxOnValue: -cov 1;checkboxOffValue: -cov 0">
<Button id=" " style="CHECK" text="Collect coverage" selection="true" />
</dvt:Container>
<dvt:Container layout="layout:grid;" parameters="checkboxOnValue: -wave 1;checkboxOffValue: -wave 0">
<Button id=" " style="CHECK" text="Dump wave" />
</dvt:Container>
Output:
XML
<dvt:Container parameters="listSeparator: -f ">
<dvt:DirectoryFilesListing id=" -f " rootDirectory="/tmp/files"/>
</dvt:Container>
Output:
-f file_1 -f file_3 -f file_5 -f file_7
XML
<dvt:Container parameters="noIdForEmptyValues:true">
<Text id=" -text "></Text>
</dvt:Container>
XML
<dvt:Container layout="layout:grid;numColumns:2;" parameters="quoteWith:'">
<Label text="Text:"></Label>
<Text id=" -text " style="BORDER" text="text with whitespace that needs to be quoted" />
</dvt:Container>
Output:
-text 'text with whitespace that needs to be quoted'
Note: If you wish to quote a string with double quotes you should escape the double quote character from XML syntax as follows:
<dvt:Container parameters="quoteWith:"">
XML
<dvt:Container parameters="showInTitle:true">
<Label text="Seed:"></Label>
<Text id=" -seed " style="BORDER" text="42223" />
</dvt:Container>
Output
To disable a set of widgets based on the selection state of a radio button, checkbox or the value of a combobox or text widget, wrap the set of widgets you want to disable in a <dvt:Container> and specify which widget dictates its enablement using the
enabler attribute. You can refer to a widget with its
standard XML XPath within the dialog xml:
XML
<Group text="Radio buttons" layout="layout:fill;type:VERTICAL;">
<Button id=" -test random" style="RADIO" text="Run a random test" selection="true" />
<Button style="RADIO" text="Run a specific test" />
</Group>
<dvt:Container enabler="/Composite/Composite[1]/Group[1]/Button[2]" layout="layout:fill;type:HORIZONTAL;">
<sv:ClassSelector id=" -test " question="Pick test" baseClassName="uvm_test" />
</dvt:Container>
Output
XML
<Combo items="run_random_test;run_specific_test" layoutData="horizontalAlignment:CENTER;">
</Combo>
<dvt:Container enabler="/Composite/Composite[1]/Combo == run_specific_test" layout="layout:fill;type:HORIZONTAL;">
<sv:ClassSelector id=" -test " question="Pick test" baseClassName="uvm_test" />
</dvt:Container>
Output
You can combine the states of multiple buttons or comboboxes/text widgets using logical operators, and you can refer the same widget from multiple <dvt:Container> widgets:
XML
<Group text="Resolution" layout="layout:row;type:VERTICAL;">
<Button style="RADIO" text="800x600" selection="true" />
<Button style="RADIO" text="1024x768" />
<Button style="RADIO" text="1280x1024" />
<Button style="RADIO" text="1600x1200" />
</Group>
<Group text="Refresh Rate (Hz)" layout="layout:row;type:VERTICAL;">
<Button style="RADIO" text="70" />
<dvt:Container
enabler="/Composite/Composite[1]/Group[1]/Button[1] ||
/Composite/Composite[1]/Group[1]/Button[2] ||
/Composite/Composite[1]/Group[1]/Button[3]">
<Button style="RADIO" text="80" />
</dvt:Container>
<dvt:Container
enabler="!/Composite/Composite[1]/Group[1]/Button[3] &&
!/Composite/Composite[1]/Group[1]/Button[4]">
<Button style="RADIO" text="90" />
</dvt:Container>
<dvt:Container enabler="/Composite/Composite[1]/Group[1]/Button[1]">
<Button style="RADIO" text="100" />
</dvt:Container>
</Group>
<Group text="Color depth (bpp)" layout="layout:row;type:VERTICAL;">
<dvt:Container
enabler="/Composite/Composite[1]/Group[1]/Button[1] ||
/Composite/Composite[1]/Group[1]/Button[2]">
<Button style="RADIO" text="16" />
</dvt:Container>
<dvt:Container
enabler="/Composite/Composite[1]/Group[1]/Button[3] ||
/Composite/Composite[1]/Group[1]/Button[4]">
<Button style="RADIO" text="32" />
</dvt:Container>
</Group>
Output
NOTE: To easily obtain the XPath to a specific widget run the dialog once, and identify the widget(s) inside the <dialog_name>.snapshots.xml file which is automatically generated/updated by DVT after each run.
Further customization can easily be achieved by using a simple script for processing arguments. E.g. with the following bash snippet you can convert any argument to any desired form:
#!/bin/bash
#
# bash_arg_converter.sh
#
while [ $# -gt 0 ]; do
case $1 in
-custom_*)
argname="$1"
shift
argval="$1"
## Customize here to desired format ##
echo -n " $argname $argval "
;;
*)
echo -n " $1 "
;;
esac
shift
done
In the configuration command box use the following instead of ${dvt_dialog_prompt}:
`./bash_arg_converter.sh ${dvt_dialog_prompt:customdialog.swtxml}`
How to avoid quoting problems: in the .swtxml file it is recommended to use
\" for nested quotes and for the
Launch Command (Run Configurations > Launch Command) the variable
${dvt_dialog_prompt:customdialog.swtxml} should be surrounded by quotes, like in the image below: