Skip to main content



      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 10:14 Go to next message
Eclipse UserFriend
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 10:16] by Moderator

Re: EMF.Edit: Deleting non-containment tree items deletes all references [message #735736 is a reply to message #735672] Wed, 12 October 2011 11:49 Go to previous messageGo to next message
Eclipse UserFriend
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
>
Re: EMF.Edit: Deleting non-containment tree items deletes all references [message #736884 is a reply to message #735736] Fri, 14 October 2011 08:36 Go to previous message
Eclipse UserFriend
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 Jul 23 21:50:12 EDT 2025

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

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

Back to the top