Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » Create new Element (EObject)
Create new Element (EObject) [message #658129] Sun, 06 March 2011 20:53 Go to next message
No real name is currently offline No real nameFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:classDiagram.gmfmap
Next Topic:Extension Point for catching "Add Note"
Goto Forum:
  


Current Time: Sun Dec 21 15:53:32 GMT 2014

Powered by FUDForum. Page generated in 0.03856 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software