Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Delete elements in the model(changing default funcionality)
Delete elements in the model [message #493436] Mon, 26 October 2009 09:31 Go to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Hi.

I want to check deletion of elements on my model. To do that, I have modified the listener for the menu option "Delete" and if the element is a element by reference, the option for deleting is disabled, and if the element has not any reference, the option changes to "true", and the users can delete that element. I use "ECrossReferencer" for checking the element references.

My problem is that the key "Supr" or "Delete", throws the command of action for deleting, althought the menu option is disabled. I have not found the key listener for editingDomain in which I could make the same checking like in the menu option.

Other way may be changing DeleteCommand for EditingDomainActionBarContributor... but I don't know....

Have you got any suggestion about this issue?

Thanks in advance.
Carlos.
Re: Delete elements in the model [message #493526 is a reply to message #493436] Mon, 26 October 2009 15:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Carlos,

Comments below.

Carlos wrote:
> Hi.
>
> I want to check deletion of elements on my model. To do that, I have
> modified the listener for the menu option "Delete" and if the element
> is a element by reference, the option for deleting is disabled, and if
> the element has not any reference, the option changes to "true", and
> the users can delete that element. I use "ECrossReferencer" for
> checking the element references.
>
> My problem is that the key "Supr" or "Delete", throws the command of
> action for deleting, althought the menu option is disabled. I have not
> found the key listener for editingDomain in which I could make the
> same checking like in the menu option.
>
> Other way may be changing DeleteCommand for
> EditingDomainActionBarContributor... but I don't know....
Generally I'd expect you to specialize the DeleteCommand that the
editing domain creates. I wonder if
https://bugs.eclipse.org/bugs/show_bug.cgi?id=292887 is related to your
issue? When showing children for non-containment references, you should
be able to make use of wrappers so that it just work without all the
stuff you're doing, i.e., only the reference will be removed..
>
> Have you got any suggestion about this issue?
>
> Thanks in advance.
> Carlos.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete elements in the model [message #493616 is a reply to message #493526] Tue, 27 October 2009 09:19 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

that bug has some relation with my problem. The bug description indicate that:
"DeleteCommand removes all references to an object. It make sense when an object needs to be deleted from its parent container. However, when just one of the references needs to be deleted, it cannot be used (it removes all of them)"

I think that it's a good idea don't let the user deleting references, removing the source from that references it.
However, the bug example shows a case with leaf nodes. If the element by reference is a subtree, with other relations, and the user wants to delete a children of that subtree, I don't know if the fix of the bug resolves the problem.

In that case, I suppose that the user could remove the full subtree related by reference, but couldn't remove one of the children, because that children are only a representation in the tree, which are in other place of the model...
What would be the behavior in that case?

The other way: wrapper. I don't mind me leaving the implementation that I have made to handle the menu option, but I wanted to know where can I get an example of that wrapper, and what would be the functionality in the case I have indicated above.

Thank you very much.
Regards.
Carlos.
Re: Delete elements in the model [message #493622 is a reply to message #493616] Tue, 27 October 2009 09:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Carlos,

Comments below.

Carlos wrote:
> Ed,
> that bug has some relation with my problem. The bug description
> indicate that:
> "DeleteCommand removes all references to an object. It make sense when
> an object needs to be deleted from its parent container. However, when
> just one of the references needs to be deleted, it cannot be used (it
> removes all of them)"
>
> I think that it's a good idea don't let the user deleting references,
> removing the source from that references it. However, the bug example
> shows a case with leaf nodes. If the element by reference is a
> subtree, with other relations, and the user wants to delete a children
> of that subtree, I don't know if the fix of the bug resolves the problem.
The bug fix checks if the deleted object becomes a dangling reference,
i.e., eResource is null, so it should work well even for non-leaf nodes.
>
> In that case, I suppose that the user could remove the full subtree
> related by reference, but couldn't remove one of the children, because
> that children are only a representation in the tree, which are in
> other place of the model...
> What would be the behavior in that case?
Try it. :-P
>
> The other way: wrapper. I don't mind me leaving the implementation
> that I have made to handle the menu option, but I wanted to know where
> can I get an example of that wrapper, and what would be the
> functionality in the case I have indicated above.
The attached example in the bug shows how isWrappingNeeded is
specialized to return always true on the generated item provider that
has non-containment children.
>
> Thank you very much.
> Regards.
> Carlos.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete elements in the model [message #493889 is a reply to message #493622] Wed, 28 October 2009 11:43 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

for testing that changes, do I have to download the source code from "dev.eclipse.org" and compile it?
Or is there any site for which could I get the binaries?

Thanks.
Re: Delete elements in the model [message #493896 is a reply to message #493889] Wed, 28 October 2009 12:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Carlos,

That's one way. Or, if you have the SDK installed, you can use PDE to
import the source that plugin with source into your workspace and then
modify that.



Carlos wrote:
> Ed,
> for testing that changes, do I have to download the source code from
> "dev.eclipse.org" and compile it? Or is there any site for which could
> I get the binaries?
>
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete elements in the model [message #493984 is a reply to message #493896] Wed, 28 October 2009 16:25 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

I have imported "org.eclipse.emf.edit.source" project using PDE tools.
I have modified "DeleteCommand" following the attached file at the indicated bug: https://bugs.eclipse.org/bugs/attachment.cgi?id=150109

When I execute the new code, I get the same result... If I delete a referenced element, editor removes all the referenced elements, besides "source" or "physical" element.
What can be happening?
(I have checked by log that the new code is executing now).

Probably, I have misunderstood something about the functionality for this issue...

Thanks.
Re: Delete elements in the model [message #493991 is a reply to message #493984] Wed, 28 October 2009 16:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Carlos,

And you did the wrapper thing? I.e., overrode isWrappingNeeded to
return true for the parent of these non-containment children? How is
your example different from the one in the bugzilla?


Carlos wrote:
> Ed,
> I have imported "org.eclipse.emf.edit.source" project using PDE tools.
> I have modified "DeleteCommand" following the attached file at the
> indicated bug: https://bugs.eclipse.org/bugs/attachment.cgi?id=150109
>
> When I execute the new code, I get the same result... If I delete a
> referenced element, editor removes all the referenced elements,
> besides "source" or "physical" element.
> What can be happening?
> (I have checked by log that the new code is executing now).
>
> Probably, I have misunderstood something about the functionality for
> this issue...
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete elements in the model [message #494105 is a reply to message #493991] Thu, 29 October 2009 08:58 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

I have changed the method "isWrappingNeeded" in the class "org.eclipse.emf.edit.provider.ItemProviderAdapter" for returning always "true" value.
I have checked that if I delete a referenced element, editor only removes that reference, and not the source element.
However, if that referenced element has children at the tree, if I delete one of that children, the editor removes all the element appearances.

I can not attach an example image. But is something like next:

+ Entity 1
+++ Entity A
++++++ Entity B

+ Entity 2
+++ Entity 4
++++++ Entity A
+++++++++ Entity B

+ Entity 3
+++ Entity 5
++++++ Entity A
++++++++++ Entity B
<- If I delete this, the editor removes all entities B

In that image, there is a "Physical" element called "Entity A" that has one child called "Entity B" (green). That simple subtree is contained by reference under two other entities: Entities 4 and 5 (red color).
If I delete Entity A in green color, it will be disappeared all, but if I delete an Entity A in red color, only disappear that element (and its child). This is OK.
But if I delete an Entity B of red color, it will be removed all appearences of entity B, when I would hope that only was removed that element. (The "physical" element in this case, is entity B in green color...)

On the other hand, I have got customized viewers in my editor and when I have changed the ItemProviderAdapter, now, there are elements at the tree with type "org.eclipse.emf.edit.provider.DelegatingWrapperItemProvider " when before, they were EObjects...

Probably, my mistake is the change I have made in isWrappingNeeded...
In short, I would like to extend the behaviour of deleting to the children of the elements by reference.

Thanks in advance.
Re: Delete elements in the model [message #494113 is a reply to message #494105] Thu, 29 October 2009 09:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Carlos,

It seems likely that the children of non-contained children will need
wrappers as well. Can you give that a try?


Carlos wrote:
> Ed,
>
> I have changed the method "isWrappingNeeded" in the class
> "org.eclipse.emf.edit.provider.ItemProviderAdapter" for returning
> always "true" value.
> I have checked that if I delete a referenced element, editor only
> removes that reference, and not the source element.
> However, if that referenced element has children at the tree, if I
> delete one of that children, the editor removes all the element
> appearances.
>
> I can not attach an example image. But is something like next:
>
> + Entity 1
> +++ Entity A
> ++++++ Entity B
> + Entity 2
> +++ Entity 4
> ++++++ Entity A
> +++++++++ Entity B
> + Entity 3
> +++ Entity 5
> ++++++ Entity A
> ++++++++++ Entity B <- If I delete this, the editor removes all
> entities B
>
> In that image, there is a "Physical" element called "Entity A" that
> has one child called "Entity B" (green). That simple subtree is
> contained by reference under two other entities: Entities 4 and 5 (red
> color).
> If I delete Entity A in green color, it will be disappeared all, but
> if I delete an Entity A in red color, only disappear that element (and
> its child). This is OK.
> But if I delete an Entity B of red color, it will be removed all
> appearences of entity B, when I would hope that only was removed that
> element. (The "physical" element in this case, is entity B in green
> color...)
>
> On the other hand, I have got customized viewers in my editor and when
> I have changed the ItemProviderAdapter, now, there are elements at the
> tree with type
> "org.eclipse.emf.edit.provider.DelegatingWrapperItemProvider " when
> before, they were EObjects...
>
> Probably, my mistake is the change I have made in isWrappingNeeded...
> In short, I would like to extend the behaviour of deleting to the
> children of the elements by reference.
>
> Thanks in advance.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete elements in the model [message #494118 is a reply to message #494113] Thu, 29 October 2009 09:36 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

how can I get it? I. e. I have changed the method "isWrappingNeeded" for returning always true, but I don't know where could I make more changes in this way...

I don't know enough the implementation of "org.eclipse.emf.edit", so please, have you got ant clue?

Thanks.
Re: Delete elements in the model [message #494127 is a reply to message #494118] Thu, 29 October 2009 10:12 Go to previous message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

excuse me for the last post.
I have been thinking in the issue, and I was mistaken... A child of a referenced element is not a reference. In that case, that element is the child of the referenced element, but is containment in the source element ... so, if I delete it, the editor will delete all appearences. That's right.

Sorry for the wasted time.
Once again, thank you very much for your attention.

Carlos.
Previous Topic:EMF and String ID
Next Topic:Team revert causing undoing of EMF model changes
Goto Forum:
  


Current Time: Fri Apr 26 11:11:42 GMT 2024

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

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

Back to the top