|
Re: Cloning with Stereotypes [message #478193 is a reply to message #478191] |
Fri, 13 February 2009 21:58 |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, Peter,
The Copier can copy a collection of EObjects in one operation, which
results in also copying the cross-references between them.
So, if you retrieve the stereotypes instances applied to your element
(using Element::getStereotypeApplications()) and add those to a
collection along with the base element, then copy the lot, you'll get
what you expect.
The only trick, then, is to find a place to store the new stereotype
applications (usually they are attached directly to the resource that
contains the base element).
HTH,
Christian
Peter wrote:
> Hello,
> i uses oAW to make some M2M Transformations and need to clone UML
> Elements. They uses a Java Extension with this Code to clone Elements.
>
> public static Object clone(Object original) {
> EObject context = (EObject) original;
> EcoreUtil.Copier copier = new EcoreUtil.Copier();
> EObject copy = copier.copy(context);
> copier.copyReferences();
> return copy;
> }
>
> Unfortunately the Stereotypes get lost.
> Is it possible to clone UML Elements with Stereotypes and the
> corresponding Tagged Values?
> Thank you
> Peter
|
|
|
Re: Cloning with Stereotypes [message #627393 is a reply to message #478191] |
Fri, 13 February 2009 21:58 |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, Peter,
The Copier can copy a collection of EObjects in one operation, which
results in also copying the cross-references between them.
So, if you retrieve the stereotypes instances applied to your element
(using Element::getStereotypeApplications()) and add those to a
collection along with the base element, then copy the lot, you'll get
what you expect.
The only trick, then, is to find a place to store the new stereotype
applications (usually they are attached directly to the resource that
contains the base element).
HTH,
Christian
Peter wrote:
> Hello,
> i uses oAW to make some M2M Transformations and need to clone UML
> Elements. They uses a Java Extension with this Code to clone Elements.
>
> public static Object clone(Object original) {
> EObject context = (EObject) original;
> EcoreUtil.Copier copier = new EcoreUtil.Copier();
> EObject copy = copier.copy(context);
> copier.copyReferences();
> return copy;
> }
>
> Unfortunately the Stereotypes get lost.
> Is it possible to clone UML Elements with Stereotypes and the
> corresponding Tagged Values?
> Thank you
> Peter
|
|
|
Powered by
FUDForum. Page generated in 0.03067 seconds