MDK User's Guide: 3 Create Enumerated Values

One of the more sophisticated features of View Editor is the option to have values be enumerated values. This means that a user will only be allowed to set an element's value to a specific set of choices. In View Editor, this is shown as a drop down list. This can be extremely useful for elements that are similar in makeup but have different properties and different values.The following instructions demonstrate how to create enumerated values so that they may be seen as drop down lists on View Editor.

 

Creating the Enumeration

  1. Create an "Enumeration" element

    • Right click on a package that will contain the enumeration > create element > ennumeration

    • Name the enumeration

  1. Create enumeration literals. Enumeration literals represent the values that the enumeration may hold 

    • Right click on the newly created enumeration > create element > enumeration literal 

    • Name the enumeration literal

    • Create multiple enumeration literals for each enumeration

  1. For each component that will utilize the enumeration, create a property

    • Right click component > create element > Property

      • Optional Note: Once the property has been typed by the enumeration, the part may be refactored as a value property and maintains the same functionality

    • Name the property (preferably the name of the enumeration)

  1. Set the "Type" of the property as the enumeration

    • Open the specification of the value property by either double clicking or right click > specification

    • Drag the enumeration from the containment tree to the "Type" field in the specification or browse for the enumeration 

 

  1. Under specification, default value may now be specified as any of the enumeration literals

Implementation in the context of a table in View Editor

The following instructions demonstrate how to create enumerated values so that they may be seen as drop down lists in the column of a Rapid Table ([cf:Create and Generate a Rapid Table.vlink]) on View Editor

  1. Create a View diagram, document, view, and view point method diagram as described in [cf:Create A Document With A View.vlink] and [cf:Insert Diagram as Image.vlink]

  1. In the viewpoint method diagram, include the following elements:

    • Initial node

    • CollectOwnedElements

    • FilterByStereotypes with stereotypes field set to the element type containing properties with enumerations (ex. block)

    • Table Structure

    • Activity Final node

  2. Within the Table structure, include the following elements:

    • Initial node

    • TableAttributeColumn with desired attribute (ex. name)

    • TableAttributeColumn with desired attribute set to "value"

    • Activity Final node 

  3. Within the TableAttributeColumn with the attribute set to "value", include the following elements:

    • Initial node

    • CollectOwnedElements

    • FilterByNames with the NameChoosable field set to the name of the part property with enumerated values

    • Activity Final node

  4. Define control flow between all elements on the diagram. 

 

  1. Save changes

  2. Generate document

    • Right click document > MMS > Generate View Contents Recursively

  3. See that table is generated in View Editor that includes the name of the element and its value (one of the enumeration literals). When the value is edited, the list of enumeration literals is displayed as a dropdown menu. 

Â