Properties of a choice type
You can assign certain properties to a choice type.
The following table lists the properties that you can assign to a choice type:
| Property | Values | Meaning | Default |
|---|---|---|---|
| text | String | The text used to display the complex type. It must reference the <...> placeholder (see Properties of a sequence type). | The name of the element itself between brackets: <choice1> |
| default (guided editor only) |
String | The initial choice for text, for example <choice1>. | none |
| emptyText (guided editor only) |
String | The text displayed until the user makes a choice. | <select a choice> |
| meta (guided editor only) |
true, false, or choice | Use this property to specify metatokens that are not displayed in read-only mode. The choice value specifies that the choice is meta, but not the tokens that follow. Only the ChoiceToken is meta, and not the rest of the switch. |
|
| fixedText (guided editor only) |
String | Use this property to specify that the text displayed once a choice has been made is fixed, no matter what choice is selected, and it is the text given as value of the property. For example: <choice>.fixedText = : |
none |
| merge (guided editor only) |
Boolean | True if the subchoices must be merged into the same menu. | false |
Here is an example of a choice emptyText property definition. This is the text that is displayed in the empty token before the user has made a choice:
<condition>.emptyText = <select a condition>
The merge property specifies that if an element in the choice is itself a choice, the subchoices must be merged into the same menu in the editor.
For example, if you have the abstract syntax:
<complexType name="test">
<choice>
<element name="comparison" type="comparison">
<element name="instanceof" type="instanceof">
</choice>
</complexType>
<complexType name="comparison">
<choice>
<element name="equality" type="equality">
<element name="greaterThan" type="greaterThan">
<element name="lowerThan" type="lowerThan">
</choice>
</complexType>
with the following properties in the concrete syntax:
<instanceof>.text = instance of
<equality>.text = is equal to
<greaterThan>.text = is greater than
<lowerThan>.text = is lower than
<test>.merge = true
you get the following menu when using the <test> type:
instance of | is equal to | is greater than | is lower than
This definition also works when the subchoice is a sequence and the first element of that sequence is a choice. For more information about the properties of an element of a choice type, see Properties of a terminal type.