To create a state invariant as an OCL comment:
- On the UML 2.0 Sequence Diagram Tool Palette, choose the State Invariant button.
- Click the target lifeline or execution specification.
Tip: Alternatively, use the Add->State invariant
command on the context menu of a lifeline or an execution specification.
- In the Object Inspector of the state invariant, select the General node.
- In the Invariant kind field, choose OCL expression from the drop-down list. The shape of the state invariant diagram element changes to braces.
- In the OCL invariant node that adds to the Object Inspector, select the language of the comment from the Language drop-down list. The possible options are OCL and plain text.
- Type the text and apply changes.
To connect a state invariant to a state:
- On the diagram Tool Palette, choose the State Invariant button.
- Click the target lifeline or execution specification.
- In the Object Inspector of the state invariant, select the General node.
- In the Invariant kind field, choose States/Regions from the drop-down list.
- In the States/Regions field, click the chooser button.
- In the Choose States and/or Regions dialog box, select the desired states and/or regions from the model, using the Add button.
- Click OK when ready.
Tip: Alternatively, type the state or region name. If the state or region belongs to a different package, specify its fully-qualified name.