Last Updated:

Providing a Combo Box Selector for String Tags

Andy Lapping Tip

Overview

When you define a stereotype that has tags on it and those tags are typed by String then by default your users can type anything they want into the tag value. Whist this provides the most freedom, sometimes it is helpful to provide users with a selectable list. Of course you could type the tag by an enum but this constrains the user to only those values. How then to give the user the freedom of text but also provide a suggested list of values ? 

This can be achieved using a hidden feature !

Add a new property (either on the stereotype directly or in a prp file). The property should be Model.Stereotype.tagNameProposedStringValues (replace tagName with the exact name of the tag - mu;tiple properties may be added if you have multiple tags). Set that property to a comma separated list of string values and hey presto - a selectable list of strings (users may still choose to type in a value - they are not constrained to the list as they would be is you used an enum as the type)

The stereotype can be a new term - or not - the feature works either way.

Example

Profile

Stereotype with a String Tag Called 'make'
Model.Stereotype.makeProposedStringValues

Model

New Model Element - Selecting from the List of Proposed Strings