Visual OCL

TU-Berlin | Faculty IV | Institute ISTI | Research group TFS

User Guide for the Eclipse VOCL-Plugin
goup 1

small logo
section: < previous | next >
| |
chapter: << previous | next >>


3.6 Conditions

As already mentioned a condition belongs to a constraint, and makes statements on variables, like those defined for attributes of classifiers, for return values of methods or for set operations. Statements are made by comparing these variables to constants or even to other variables.

a) Creating a condition

When having a constraint, the creation of a condition is done as follows:
  1. Open the context-menu from inside of a constraint, but not over another element inside of it. Then, select the item Condition, what will open a dialog, as displayed in fig. 3.6.1.
  2. This dialog contains a list (initially empty) of conditions, and the usual buttons to add, edit or remove them. Click the Add-Button.
  3. A new dialog appears, where the condition can be specified. It has a drop-down list, where the comparison can be selected, which is one of greater, greater equal, less, less equal and equal. Among that, the dialog is splitted into two parts. On the left side, a variable must be selected, on right side either a variable or a constant can be set (see fig. 3.6.2) The resulting condition then will be something like [left-side] compared to [right side] by selected comparison. Enter for example on the left a variable of type Integer and name x.
  4. On the right side, select a constant by leaving the check-box is value selected, and entering 2000 into the text-field (see fig. 3.6.2).
  5. Then, choose any operation, for example '='. Click the Apply-Button, to close this dialog. The new condition is overtaken to the list (fig. 3.6.3).
  6. By closing this dialog, the condition will be applied to the constraint. The result is displayed in fig. 3.6.4.
The condition is displayed at the bottom of the constraint-figure, separated by a black line from the drawing area. The displayed string forms the condition itself, so it is easy to see what is meant. The type of the variable(s) used in the condition are annoted behind. Note, that the operations less or greater make only sense when using on an ordered datatype, like Integer. Comparing strings for example with > has no defined meaning.

Fig. 3.6.1 - Dialog for managing conditions


Fig. 3.6.2 - Dialog for creating conditions


Fig. 3.6.3 - Dialog with a condition added


Fig. 3.6.4 - Resulting figure with conditions

b) Editing the conditions

Editing the conditions is done via the same dialog. To change a conditions properties, select it from the list (fig. 3.6.3), and click the Edit-Button. A dialog similar to the one displayed in fig. 3.6.2 appears, with the conditions properties already set. Changing and applying these properties will alter the condition. Removing a condition is simply done by clicking the Remove-Button when a condition is selected.


  section: < previous | next >
| |
chapter: << previous | next >>
©2005 TFS