file Option to disable automatic role generation for Association

10 years 7 months ago #268 by dimfa
Currently when association is created on a Class diagram, the Role is automatically
populated based on the association class name.
This clutters the diagram. I have to remove it for every single association created.
It would be nice to have an ability to disable automatic role generation in the settings.

Please Log in or Create an account to join the conversation.

10 years 7 months ago #274 by fpo
This feature is already available actually. As you said, it is possible (through the style options available in the "Symbol" view) to show or hide these labels (role and cardinality) for each Association individually.
There are several ways to do it for all Associations (with slightly different effects), but all imply to use named styles, so here are basic information concerning named styles:
1) Named styles are created and edited in the Style Editor, that you can open in the "Configuration" menu, by clicking on "Diagram Styles". They use "cascading", meaning any value not explicitly defined in a named style is actually taken from the "parent" style it is derived of. Change said value in the parent style, and it is changed in all derived styles (if they didn't have they're own values).
2) All elements in a diagram (including the diagram itself) use a named style to get default values for its options. To set the named style to be used by an element in a diagram, select this element (click in the diagram background for the diagram itself) and use the combo in the toolbar of the "Symbol" view to select the named style to use. All elements EXCEPT diagrams have a special value "diagram settings" in this combo that is used to say "this element should use the same named style as the diagram" and this is the default value when you create or unmask an element in a diagram, allowing to quickly change the look of a whole diagram by simply changing the named style of the diagram itself (rather than element by element).
3) Any element can have local values, that are always given priorities over the values from its named style (these are the lines in bold in the "Symbol" view), even when its named style changes. If you want your element to start using the default values from the named style again, you can delete the local values by using the "Cancel the local changes" button right next to the named style combo, in the toolbar of the "Symbol" view.

Now here is a way (but not the only one) to do what you asked for:
Open the style editor and create a new named style derived from any already existing style (in your case, a style derived from "default" should do fine). Now edit the values for Association in your style so that neither Role nor Cardinality are shown and save your style. You can now use your style on any of your diagrams so that both Associations already in the diagram AND Association that you will create won't show these labels. If you need to actually show it in a particular case, you can still override the default value (from your named style) in the "Symbol" view for a particular Association.

Of course, you could also directly edit the values for the "default" style, but I would recommend against it, as this will "modify" all existing diagrams in your projects and so is probably a bad habit. I think it is worth creating your own style and applying it to all your diagrams one by one (not that much work, more so in regards of changing the values for all you Associations...), making sure there are no unwanted side effects (namely: cases where you'd actually want the labels to show).

Hope that helps!

Please Log in or Create an account to join the conversation.

Moderators: cde
Time to create page: 0.038 seconds
^ Back to Top