Sparx Systems Forum
Enterprise Architect => Suggestions and Requests => Topic started by: MatthiasVDE on February 29, 2016, 07:19:41 pm
-
Is it possible to add extra attributes types in a class diagram. For example, string, enum, ...
-
You can assign an attribute any type you want.
q.
-
I know, but can I save them so they are reusable?
-
I remember that you can define your own language and introduce datatypes for that. I haven't used that for years...
q.
P.S. See Project/SettingsCode Engineering Datatypes... Add your new language and define some types. Then create a class and make it this new language (Apply change). Then when you edit attributes you see the datatypes you defined.
-
Hi Matthias, and welcome to the forum! :)
Attributes are not quite as simple as they might first appear. There are three ways to set an attribute type.
- Free text: enter whatever type name you want. Not reusable.
- Specify classifier: use the ellipsis button ("...") to pick a class. EA sets the type name, and if you then change the name of the class, the type name is automatically updated.
- Pick from the drop-down list. The contents of this list is defined by the Language property of the class (C, Java, etc) and are thus reusable.
In order to modify the set of attribute types for a language, go to Project -- Settings -- Code Engineering Datatypes. If you want to define your own language, click "Add Product". Note that unless you define at least one attribute type, EA will delete the language / product when you close the dialog.
The same set of languages in a project is the basis for EA's code generation (there is a set of code generation templates for each language), but you don't need to go into that just to create your own set of attribute types.
HTH,
/Uffe
-
In other words, what q said. ;D
-
I just added them to the Java language and it works fine, thanks!