Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EMF.Edit: Deleting non-containment tree items deletes all references
EMF.Edit: Deleting non-containment tree items deletes all references [message #735672] Wed, 12 October 2011 14:14 Go to next message
pro.kyon is currently offline pro.kyonFriend
Messages: 6
Registered: October 2011
Junior Member
Hi all,

I've generated the basic tree editor that comes with EMF.
The problem is, that deleting element references from the referencing model (via the context menu delete action) also deletes the elements from the referenced model.

Here's what the tree editor looks like:
Model A:

- Node
    - Elem1 (non-containment ref)
    - Elem2 (non-containment ref)
    - Elem3 (non-containment ref)

Model B:

- ElemContainer1
    - Elem1 (actual referenced element, containment)
    - Elem2 (actual referenced element, containment)
- ElemContainer2
    - Elem3 (actual referenced element, containment)


As you can see, Model A references Model B. Elem1-3 are modeled as a reference feature, with the "Containment" flag set to true, but the "Children"-flag in the genmodel is set to "True", in order to display those as individual tree items.
If I delete the nodes in Model A, they are also deleted in Model B. What I actually intend is to remove them only from the corresponding feature of "Node" in Model A.

I have already come across the EditingDomainActionBarContributor and its "removeAllReferencesOnDelete()". Unfortunately returning "false" in that method only deletes the elements from the referenced model, which is exactly the opposite of what I need.

Did anyone else ever run into that problem? Any help is greatly appreciated.

Edit: Thinking about it now, there might be another solution. I could create a new Type "ElemRef" with a 0..1 reference-feature and make the original feature a containment.
Anyways, I'd still like to now if the described behavior is intended and if my solution is indeed the best way to go.

Regards

[Updated on: Wed, 12 October 2011 14:16]

Report message to a moderator

Re: EMF.Edit: Deleting non-containment tree items deletes all references [message #735736 is a reply to message #735672] Wed, 12 October 2011 15:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31556
Registered: July 2009
Senior Member
Comments below.

On 12/10/2011 4:14 PM, pro.kyon wrote:
> Hi all,
>
> I've generated the basic tree editor that comes with EMF.
> The problem is, that deleting element references from the referencing
> model (via the context menu delete action) also deletes the elements
> from the referenced model.
>
> Here's what the tree editor look like:
>
> Model A:
>
> - Node
You need to ensure you're using wrappers if you have non-containment
references as children and show these nodes elsewhere. Specialize
isWrappingNeeded to return true for NodeItemProviderAdapter.
> - Elem1 (non-containment ref)
> - Elem2 (non-containment ref)
> - Elem3 (non-containment ref)
>
> Model B:
>
> - ElemContainer1
> - Elem1 (actual referenced element, containment)
> - Elem2 (actual referenced element, containment)
> - ElemContainer2
> - Elem3 (actual referenced element, containment)
>
>
> As you can see, Model A references Model B. Elem1-3 are modeled as a
> reference feature, with the "Containment" flag set to true, but the
> "Children"-flag in the genmodel is set to "True", in order to display
> those as individual tree items.
> If I delete the nodes in Model A, they are also deleted in Model B.
> What I actually intend is to remove them only from the corresponding
> feature of "Node" in Model A.
>
> I have already come across the EditingDomainActionBarContributor and
> its "removeAllReferencesOnDelete()". Unfortunately returning "false"
> in that method only deletes the elements from the referenced model,
> which is exactly the opposite of what I need.
>
> Did anyone else ever run into that problem. Any help is greatly
> appreciated.
>
> Edit: Thinking about it now, there might be another solution. I could
> create a new Type "ElemRef" with a 0..1 reference-feature and make
> the original feature a containment.
> Anyways, I'd still like to now if the described behavior is intended
> and if my solution is indeed the best way to go.
>
> Regards
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF.Edit: Deleting non-containment tree items deletes all references [message #736884 is a reply to message #735736] Fri, 14 October 2011 12:36 Go to previous message
pro.kyon is currently offline pro.kyonFriend
Messages: 6
Registered: October 2011
Junior Member
Thanks, Ed! Exactly the bit of information I was looking for. Smile
Previous Topic:[EEF] leverage EEF to generate a INewWizard
Next Topic:[EEF] Use EEF to generate property sheet editor for Graphiti
Goto Forum:
  


Current Time: Wed Oct 28 00:50:41 GMT 2020

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

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

Back to the top