Create containers [message #1756101] |
Sat, 11 March 2017 04:13  |
Eclipse User |
|
|
|
Hi,
This might be a stupid question but I wasn't able to find the answer online.
I try to create a DSL that needs to have elements that contain other elements. Take for a example a Zoo DSL where elements stereotyped as "Zoo" should containt elements stereotyped as "Animals". I suppose I can create an aggregation association to denote this notation, however is it possible to use "Zoo" instances as containers for "Animal" instances to denote this relation by grouping the latter inside the former? Just to make it clear, creating a "large" Zoo element and place the Animal elements on top of it is not what I am looking. I would like to have zoo and animals bound, so when I move the Zoo node the contained animal elements will follow.
|
|
|
Re: Create containers [message #1756111 is a reply to message #1756101] |
Sat, 11 March 2017 09:10   |
Eclipse User |
|
|
|
Hi,
Stereotype instances can't (Or "shouldn't?" I'm not 100% sure) contain each other. So, aggregation associations between two Stereotypes are not allowed (Or discouraged; once again, I'm not sure).
Instead, your Stereotypes should extend 2 UML Metaclasses which already define a containment relationship to each other. For example, "Zoo" extends Package, and "Animal" extends Class.
The Package - Class relationship is quite limited, so usually I would recommend using "Class" and "Property" instead (i.e. similar to what is done for Component or Composite structures, or Blocks/Internal Blocks in SysML...). The benefit of Class/Property is that a property can be typed by a Class, allowing deeper recursion of ownership. It probably isn't necessary for such a simple example, but on real world applications, it's often required.
HTH,
Camille
|
|
|
|
|
|
|
Re: Create containers [message #1756349 is a reply to message #1756165] |
Wed, 15 March 2017 13:10  |
Eclipse User |
|
|
|
I followed your suggestions and now my container element extends the Profile metaclass and the contents extend the Class metaclass. I can place the latter inside the former. However, when it comes to custom shapes there's a slight problem. More specifically, if I create a custom SVG symbol for my package (let's say a simple rectangle SVG) this is placed in a compartment which is beneath the compartment that acts as the container in the package. So, visually the contained classes are not inside but above the SVG symbol that supposedly represents the container.
First of all, could you please tell me if my understanding is correct, i.e., the symbol compartment and the contents compartment are two different things one beneath the other?
Secondly, if this is the case, I know that it is possible to set "placeholders" in the SVG shape to dictate Papyrus where to place the labels (if I recall correctly this is done via an invisible shape inside the symbol that has the id "PapyrusLabel"). Is there any way to say to Papyrus where to place the contained elements in the SVG so they're are moved to the symbol compartment and not the default one?
[Updated on: Wed, 15 March 2017 13:19] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.08076 seconds