Home » Modeling » EMF » Delete elements in the model(changing default funcionality)
|
Re: Delete elements in the model [message #493526 is a reply to message #493436] |
Mon, 26 October 2009 15:49 |
Ed Merks 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 |
Carlos 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 |
Ed Merks 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 #494105 is a reply to message #493991] |
Thu, 29 October 2009 08:58 |
Carlos 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 |
Ed Merks 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/
|
|
| | |
Goto Forum:
Current Time: Fri Apr 26 11:11:42 GMT 2024
Powered by FUDForum. Page generated in 0.04466 seconds
|