|
Re: Applying stereotype to a model which is not contained in a resource yet? [message #487549 is a reply to message #487375] |
Wed, 23 September 2009 14:59 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi,
The result of applyStereotype() is the stereotype application so you can do
what you like with it at that point.
In addition, you can simply override the getContainmentList() method and
return what you like by specializing the stereotype application helper.
You can have the UML2 infrastructure load your special helper by using the
org.eclipse.uml2.uml.util$SterotypeApplicationHelper.INSTANC E system
property.
The method is trying to locate a place to put the stereotype applications.
Typically they are placed in the same resource as the element to which the
stereotype is applied, however you can put them anywhere you like.
The result of calling applyStereotype() (with no resource being set) is the
application of the stereotype. The stereotype application is cached and the
base element is set. The in-memory representation of the application
should be fine. I don't see why an exception should be thrown.
- James.
<skobilke@gmx.de> wrote in message news:h9bkqc$8mu$1@build.eclipse.org...
> Hi,
>
> if I want to apply a stereotype to a model programmaticly I do this:
> element.applyStereotype(this.arrayStereotype);
> Unfortunatly, that does not work, if the model is not yet contained in a
> resource (because I am just constructing it).
>
> That is because of these methods in org.eclipse.uml2.uml.util.UMLUtil:
>
> protected EList<EObject> getContainmentList(Element element,
> EClass definition) {
>
> if (element.eResource() != null) {
> return element.eResource().getContents();
> }
> return null;
> }
>
> public EObject applyStereotype(Element element, EClass definition) {
> EObject stereotypeApplication = EcoreUtil.create(definition);
>
> CacheAdapter.INSTANCE.adapt(stereotypeApplication);
>
> EList<EObject> containmentList = getContainmentList(element,
> definition);
> if (containmentList != null) {
> containmentList.add(stereotypeApplication);
> }
> setBaseElement(stereotypeApplication, element);
>
> return stereotypeApplication;
> }
>
> So my code for applying a stereotype does not do anything and no exception
> is thrown (which is bad in my oppinnion: If something does not do what it
> is supposed to do there should be an exception).
>
> Why is it compulsory for the model to be in a resource just for applying a
> stereotype? And is there a way to get around this?
>
> Thank you
|
|
|
Re: Applying stereotype to a model which is not contained in a resource yet? [message #497095 is a reply to message #487549] |
Thu, 12 November 2009 14:04 |
|
Hi All;
I have the same problem as mentioned by previous post.
No exception occurs during code execution of profile creation, applying it on model & Stereotype creation/applying etc. But when I opened the model file, no Stereotype was there even Eclipse shows some errors while opening that file.
Pls tell the answer, if you something
Thanks in advance
Kishore
Regards,
Kishore
|
|
|
Re: Applying stereotype to a model which is not contained in a resource yet? [message #628048 is a reply to message #487549] |
Thu, 12 November 2009 14:04 |
|
Hi All;
I have the same problem as mentioned by previous post.
No exception occurs during code execution of profile creation, applying it on model & Stereotype creation/applying etc. But when I opened the model file, no Stereotype was there even Eclipse shows some errors while opening that file.
Pls tell the answer, if you something
Thanks in advance
Kishore
Regards,
Kishore
|
|
|
Powered by
FUDForum. Page generated in 0.03318 seconds