[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.uml2] Re: Composite attributes

Ricardo,

As you've discovered, stereotype applications are not UML elements, since 
when you are defining a profile, you're effectively defining your own 
(domain-specific) metamodel as an extension to the UML metamodel. It's 
expected, however, that every stereotype application (e.g. instance of 
Container or Widget in your scenario) has a base element, which represents 
the UML element to which the corresponding stereotype is applied. The base 
element can be obtained from a given stereotype application using the 
UMLUtil#getBaseElement(EObject) utility method.

Creating an instance of Widget directly (via the 'Children Widget' option in 
the 'New Child' menu) would result in a stereotype application that does not 
have a base element, and there's currently no way to specify/change the base 
element for a stereotype application in the UML editor (the property is 
read-only - feel free to open a Bugzilla report to have this changed). This 
must have been what I was referring to when I said it was "invalid" for a 
stereotype to have a composition to another stereotype (note that nothing in 
the UML specification implies this restriction), i.e. support for it in UML2 
is limited.

It is possible, however, for a stereotype application to be referenced or 
contained by another stereotype application; to do this, you would apply the 
stereotype to the UML element first and then make reference to it from the 
other stereotype application. In your scenario you would apply the Widget 
stereotype to some element before attempting to reference it from the 
Container instance (stereotype application), which you would do via the 
(advanced) 'children' property in the Properties view.

Kenn

"Ricardo Giacomin" <giacomin@xxxxxxxxxxxxx> wrote in message 
news:ehbiog$amo$1@xxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I have an stereotype Container with a property 'children: Widget[0..*]' 
> (iow, a list of widgets, where Widget is another stereotype and 
> aggregation type is Composite). When I create a model and apply stereotype 
> container to a given class, New Child menu options include a 'Children 
> Widget' option. Perfect, that is what I expected.
>
> My question is: I have a method that traverses the model and transform 
> each Element on it. However, the child of type Widget is not an Element 
> but an EObject (more precisely, a DynamicEObjectImpl). Isn't the widget I 
> added as child of my container an Element of the model? Is it possible to 
> obtain the Element from the EObject?
>
> By the way, I've read in a message on this group that it is not possible 
> to have an stereotype with a composition to another stereotype 
> (http://dev.eclipse.org/newslists/news.eclipse.tools.uml2/msg03179.html). 
> Does that mean what I did is not correct?
> Thanks a lot,
>
> -- 
> Ricardo Giacomin
>
>
>