You can apply properties to elements through script expressions
so that the property values change based on the output data contained
in them. This task provides general instructions for applying a background
color using a script and includes an example using a Rational® DOORS® data
source schema.
Procedure
- From the Palette view, select an element and drag it into
the template content editor, such as a Text element.
- Drag an attribute from the data source schema to an element.
- Select the element.
- In the Properties view, select a property that allows a
script, such as Text background color for a text
element.
- Click the ellipsis.
- Select the Script expression tab.
- Enter a script.
- Click OK.
- Generate the output to test your changes.
Adding a background color to a Rational DOORS attribute
by using a script
This example uses a Rational DOORS schema with a custom color attribute
to apply background color to cells that contain color data in the
output.
- Drag a table element into the template content editor.
- Enter 2 rows and 3 columns.
- Drag a query into the table. Example: module
- Enter column headings in the first row. Examples: Object
Heading, Object Text, and Color
- Drag a query into the second row. Example: module/object
- In the second row, drag attributes into the first two cells. Examples: module/object/Object_Heading and module/object/Object_Text
- In the third cell of the second row, drag the module/object/color attribute
in.
- Select the third cell in the second row.
- In the Properties view, select the Color tab.
- For the Cell background, click the ellipsis.
- Select the Script expression tab.
- Select the attribute that you are applying the script to. Example: module/object/color
- Enter the script. Example:
if (color == "green")
{
"00FF00"
}
else if (color == "yellow")
{
"FFFF00"
}
else if (color == "green,yellow" || color == "yellow,green" )
{
"6B7D02"
}
- Click OK.
- Generate the output.