Create new Element (EObject) [message #658129] |
Sun, 06 March 2011 20:53 |
No real name Messages: 7 Registered: July 2010 |
Junior Member |
|
|
Hi,
my question is how I can create a new Element e.g. Comment element. I found a snippet where I copy an already exisitng ManagedElement. Also I capture the UMLDiagrammAction2 and then override the the run method.
Snippet for copying an exisitng NamedElement:
NamedElement ne = ((NamedElement)element); ne.getNearestPackage().getPackagedElements().add((Packageabl eElement) EcoreUtil.copy(element));
But I need to create a complete new Element (Comment).
How it os possible?
Thanks for help
[Updated on: Sun, 06 March 2011 20:53] Report message to a moderator
|
|
|
Re: Create new Element (EObject) [message #658157 is a reply to message #658129] |
Mon, 07 March 2011 07:44 |
Eclipse User |
|
|
|
Originally posted by: koen.yskout.cs.kuleuven.be
Sepp,
This is no different from creating other objects in EMF, so probably
your question is more about EMF than about UML2 (or UML2Tools).
You need to use the UMLFactory, i.e.,
Comment newComment = UMLFactory.eINSTANCE.createComment();
Kind regards,
Koen
On 06/03/11 21:53, sepp_forcher@msn.com wrote:
> Hi,
>
> my question is how I can create a new Element e.g. Comment element. I
> found a snippet where I copy an already exisitng ManagedElement. Also I
> capture the UMLDiagrammAction2 and then override the the run method.
> Snippet for copying an exisitng NamedElement:
> NamedElement ne = ((NamedElement)element);
> ne.getNearestPackage().getPackagedElements().add((Packageabl eElement)
> EcoreUtil.copy(element));
>
> But I need to create a complete new Element (Comment).
>
> How it os possible?
>
> Thanks for help
|
|
|
Powered by
FUDForum. Page generated in 0.03623 seconds