Skip to main content



      Home
Home » Modeling » UML2 Tools » Create new Element (EObject)
Create new Element (EObject) [message #658129] Sun, 06 March 2011 15:53 Go to next message
Eclipse UserFriend
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 15:53] by Moderator

Re: Create new Element (EObject) [message #658157 is a reply to message #658129] Mon, 07 March 2011 02: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: Tue Jul 22 18:26:43 EDT 2025

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

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

Back to the top