Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » deleting child in one class deletes this child in all classes
deleting child in one class deletes this child in all classes [message #425503] Fri, 28 November 2008 10:32 Go to next message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
I have a class called T which has a child(called R) that is a
non-containment reference.

Now I have for example:

T1 with: and T2 with:
R11 R11
R12 R22
R13 R23

and I want to delet R11 just in T2, but when I delete R11 in T2, R11 is
also deleted in T1

What can I do???
Re: deleting child in one class deletes this child in all classes [message #425505 is a reply to message #425503] Fri, 28 November 2008 12:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30886
Registered: July 2009
Senior Member
Summer,

Comments below.


Summer wrote:
> I have a class called T which has a child(called R) that is a
> non-containment reference.
>
> Now I have for example:
>
> T1 with: and T2 with:
> R11 R11 R12 R22
> R13 R23
>
> and I want to delet R11 just in T2, but when I delete R11 in T2, R11
> is also deleted in T1
>
> What can I do???
What happens if you specialize the generated TItemProvider's with an
override of isWrappingNeeded to return true?

Generally when you delete an object, you remove it from the container
and remove all references to it. If you user wrappers then I think only
the one wrapper will be removed, i.e., that one reference will be
removed without deleting the underlying wrapped object.
Re: deleting child in one class deletes this child in all classes [message #425534 is a reply to message #425505] Mon, 01 December 2008 10:14 Go to previous messageGo to next message
Summer is currently offline SummerFriend
Messages: 7
Registered: July 2009
Junior Member
No it doesnŽt work, but I think I got a solution to find out where I am in
my tree and then specialize which object to be deleted.

Something like this:

TreeSelection selectT =
(TreeSelection)this.selectionProvider.getSelection();


int u = selectT.getPaths()[0].getSegmentCount();

.... and so on

but do you know how or where I can ask me key events?? In that way that my
object canŽt be deleted by keyboard,too?

I hope I made myself passably understood.?

Thanks in advance
Re: deleting child in one class deletes this child in all classes [message #425540 is a reply to message #425534] Mon, 01 December 2008 11:19 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30886
Registered: July 2009
Senior Member
Summer,

Comments below.


Summer wrote:
> No it doesnŽt work, but I think I got a solution to find out where I
> am in my tree and then specialize which object to be deleted.
>
> Something like this:
>
> TreeSelection selectT =
> (TreeSelection)this.selectionProvider.getSelection();
>
>
> int u = selectT.getPaths()[0].getSegmentCount();
>
> .... and so on
>
> but do you know how or where I can ask me key events?? In that way
> that my object canŽt be deleted by keyboard,too?
I don't think you should be hooking directly into the key events. If
you create wrappers, it should be possible to specialize the behavior of
the editing domain's creation of the DeleteCommand so if you delete a
wrapper, it doesn't delete the underlying object but simply removes it
from its "parent". Remember that things like getParent on the item
provider should return the proper parent in the tree, so if you set this
up properly, the specialized wrapper item provider will know where in
the tree its located.
>
> I hope I made myself passably understood.?
Yes, but interacting directly with the underlying widgets and key events
if far from ideal.
>
> Thanks in advance
>
>
>
Previous Topic:extending the properties view
Next Topic:Two way references and Dyanmic Feature Delegation
Goto Forum:
  


Current Time: Wed Feb 19 12:37:50 GMT 2020

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

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

Back to the top