Share via


Defining Decorators on Shapes and Connectors

Decorators are labels, icons, or expand/collapse chevrons that you can add to a shape or connector to customize its appearance on the diagram. You can add multiple decorators to a shape.

Adding a Decorator

Add a decorator to a shape or connector on the diagram by right-clicking the element, pointing to Add, and then clicking one of these decorator types: Expand Collapse Decorator, Icon Decorator, or Text Decorator. You cannot add expand/collapse decorators to connectors.

Defining a Display Property on a Text Decorator

Text decorators can be used to display text from a domain property value. You can use any value that can be displayed as a string and can be reached from the domain class or relationship that is mapped to the shape or connector.

The following procedure shows how to add a text decorator to a shape and then map the text decorator on a domain property that belongs to a related domain class.

To define a display property on a decorator

  1. Create a Domain-Specific Language Tools solution that is based on the MinimalLanguage solution template.

  2. Add a domain class and name it Comment.

  3. Add a domain property to the Comment domain class and name it DecoratorProperty. By default, the type of the domain property is String.

  4. Add an embedding relationship from ExampleElement to Comment.

  5. Set the multiplicity on the role with property name Comments to 0..1. The role property name should become Comment, and the relationship name should become ExampleElementHasComment.

  6. Add a text decorator to the ExampleShape geometry shape.

  7. Select ExampleShape and view the DSL Details window.

  8. Click the Mapping Details icon at the left of the window, and then click the Decorator Maps tab.

  9. In the Decorators box, select the decorator you want to map. The TextDecorator1 item must be checked and selected.

  10. Click in the Path to display property box to display a tree view of the path of the display property.

  11. Click ExampleElement, click ExampleElementHasComment, and then click Comment. The resulting path should resemble ExampleElementHasComment.Comments/!Comment.

  12. In the Display property list, select DecoratorProperty.

  13. You must add toolbox items for the domain classes before a user of your domain-specific language designer can add them to the diagram. For information about how to add toolbox items, see Customizing Tools and the Toolbox.

Setting Visibility Filtering

Decorators do not have to be visible. You can use visibility filtering to specify the conditions under which a decorator is displayed. The following procedure shows how to define an icon decorator for the ExampleShape that you defined in the earlier procedure, and how to set the icon to be displayed only when Comment.IconIsVisible is True.

To apply visibility filtering

  1. Open the model that you created in the earlier procedure.

  2. Add a domain property to Comment and name it IconIsVisible. Set its type to Boolean.

  3. Add an icon decorator to ExampleShape and name it ToolIcon.

  4. In the DSL Explorer, select ToolIcon. In the Properties window, set the Default Icon property to Resources\ExampleShapeToolBitmap.bmp.

  5. Select ExampleShape and view the DSL Details window.

  6. Click the Mapping Details icon at the left of the window, and then click the Decorator Maps tab.

  7. Select ToolIcon.

  8. Select Visibility Filter.

  9. In the Path to filter property box, click ExampleElementHasComment and then click Comment.

  10. In the Filter property list, select IconIsVisible.

  11. In the Visibility entries list, select True.

  12. You must add toolbox items for the domain classes before a user of your domain-specific language designer can add them to the diagram. For information about how to add toolbox items, see Customizing Tools and the Toolbox.

See Also

Other Resources

Domain-Specific Language Tools Glossary

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.