|How to add a stereotype to an element in an UML diagram [message #685399]
||Fri, 17 June 2011 08:55
Registered: June 2011
how do I add a stereotype to a class or an action in an UML diagram.
I select a diagram element, click "Profile" tab then click the "Plus" button and can see the list "Applicable stereotypes" - but it is always empty and it seems like there is no way to add an element to this list. Is it possible somehow to add values to this list so I could use them with my classes or actions?
I've spent few hours searching an answer this this naive question but could not find it in forums nor documentations. Other UML tools like OMONDO allow simply to type stereotype in an appropiate field.
|Re: How to add a stereotype to an element in an UML diagram [message #685408 is a reply to message #685399]
||Fri, 17 June 2011 09:14
| Yann Tanguy
Registered: July 2009
In UML, stereotypes are declared in profiles.|
In your model, you have to "apply" a profile before you can use ("apply stereotype") the stereotypes it contains.
To do that:
- select a package (say the root of your model) in the model explorer
- open the profile tab in the property view
- in the profile application area use the buttons on the right to select and apply the profile you want (some profile are pre-registered in papyrus and can be applied with the third button "Apply registered profile")
- Once this is done you should be able to apply stereotype on your UML elements (doing the same action you previously tried).
To make a trial :
- try to apply the registered profile "Standard" (the Standard UML2 profile is described in UML Specification document)
- create a Class and try to apply a stereotype, the list of "Applicable stereotypes" is no longer empty as some Stereotypes defined in Standard profile are applicable on Class (ex. Focus, Auxiliary, Metaclass...).
Creating your own Profile:
1. Create a Profile
2. Save / Define / Close the profile
3. Use your profile (described above)
To create a profile:
- use Papyrus wizard (File / New / Papyrus / Papyrus Model), and select "Profile" on the second page.
- create a profile diagram
- add the metaclass you want your stereotype to relates to using "Import Metaclass" button in the palette (ex. Select "Class" and your stereotype will be applicable on any "Class" element)
- create a new "Stereotype" with your desired name
- create an "Extension" link going from your stereotype to the meta class
You can now save the profile but you'll not be able to use it unless it is "defined", so make sure you answer "yes" when Papyrus ask if you want to define the profile during save.
Always close the profile before using it.
In case you make some changes in the profile, you'll have to re-define it and to re-apply it in your models.
[Updated on: Fri, 17 June 2011 09:32]
Report message to a moderator
|Re: How to add a stereotype to an element in an UML diagram [message #685922 is a reply to message #685417]
||Mon, 20 June 2011 14:53
| Steve Blackwell
Registered: May 2011
(Sorry but this ended up being quite long and detailed)
I, too, have been struggling with applying stereotypes and I tried to follow your example above but without success.
Here's what I'm trying to do. I created a deployment diagram with some devices in it. I want to make one of them look like a truck instead of the normal box. I am assuming that this is possible as I have seen examples even though they were not from Papyrus.
I created a profile, added an imported metaclass, and set it to Device so now I have a box with <<metaclass>> on one line and Device on the next line in the box.
Next I added a Stereotype and named it Truck. With the stereotype selected, I clicked on the UML tab in the Properties view, clicked on the green '+' "Add elements" icon next to the icon box which then popped up the "Create a new Element" dialog and I selected the UML tab there. From the Kind dropdown menu I selected Shape and then clicked on the green '+' "Content" icon and selected my graphic. When I clicked OK, image0 is now displayed in the icon box in the Properties view.
Next I selected the Extension link and drew a line between the stereotype and the metaclass with the arrow at the metaclass end.
I saved the profile and answered "Yes" when asked if I wanted to define the profile. Finally, I closed the profile.
Now back in my deployment diagram, I clicked on the background to deselect everything, and clicked on the Profile tab in the Properties view which displays 3 boxes; ProfileApplication, Applied Stereotypes and Property Values all of which are empty.
I clicked on the green '+' Apply Profile button next to the ProfileApplication box, selected my saved profile, clicked OK and then checked the checkbox next to profile. 'profile' is now displayed in the ProfileApplication box.
Now in my deployment diagram, I select the device I want to apply the stereotype to which causes the ProfileApplication box to disappear from the Properties view Profie tab. I clicked the green '+' "Add a new Element" button next to the Applied Stereotypes box in the Profile tab, selected my Truck stereotype and pushed it over to the Applied Sterotypes side and clicked OK. This caused "Truck (from profile)" stereotype to be displayed in the Applied Stereotypes box and the Property Values box to disappear from the Property View Profile tab.
However it did not make the jpg I selected for the stereotype display.
Did I miss a step or do something wrong?
Powered by FUDForum
. Page generated in 0.01612 seconds