How to programmatically delete/remove elements [message #104866] |
Sun, 18 February 2007 18:39  |
Eclipse User |
|
|
|
Originally posted by: ellerhold.web.de
Hi,
I have read this post from the Q&A concerning adding an element
programmatically:
http://wiki.eclipse.org/index.php/GMF_Newsgroup_Q&A#How_ can_I_programmatically_add_a_note_to_created_elements.3F
I guess, that I have to add something like that in the
ItemSemanticEditPolicy. I tried to use the idea from the "create element"
idea above
but couldn't get it to work. The goal is to delete all elements of a type
with a certain index in a compartment when one of them is deleted.
I get the target ModelElements over the compartmentEditPart (=parent) and I
understand that I have to do the internal process of
sending a DeleteRequest, creating and executing the ElementToDestroyCommand
for each one of these elements.
I also want to do the same for a "ResizeRequest" ( when one element with a
certain index is resized, all other elements with this index have
to be resized as well) but I think that this should work in a very similar
way.
Thank you for your help.
Chris
|
|
|
Re: How to programmatically delete/remove elements [message #104959 is a reply to message #104866] |
Mon, 19 February 2007 10:15  |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
AbstractEditHelper has a getDeteleDependentsCommand or similar designed
for this purpose.
Essentially, in the edit helper corresponding to the element type being
deleted, return an ICommand that does the work. You can either subclass
AbstractTransactionalCommand or IElementType.getEditCommand() if I
remember correctly. Note that the latter will invoke EditHelper commands
on the elements you delete so this might lead to loops.
vlad
On Mon, 19 Feb 2007 00:39:12 +0100, Christian E. wrote:
> Hi,
>
> I have read this post from the Q&A concerning adding an element
> programmatically:
>
> http://wiki.eclipse.org/index.php/GMF_Newsgroup_Q&A#How_ can_I_programmatically_add_a_note_to_created_elements.3F
>
> I guess, that I have to add something like that in the
> ItemSemanticEditPolicy. I tried to use the idea from the "create element"
> idea above
> but couldn't get it to work. The goal is to delete all elements of a type
> with a certain index in a compartment when one of them is deleted.
>
> I get the target ModelElements over the compartmentEditPart (=parent) and I
> understand that I have to do the internal process of
> sending a DeleteRequest, creating and executing the ElementToDestroyCommand
> for each one of these elements.
>
> I also want to do the same for a "ResizeRequest" ( when one element with a
> certain index is resized, all other elements with this index have
> to be resized as well) but I think that this should work in a very similar
> way.
>
> Thank you for your help.
> Chris
|
|
|
Powered by
FUDForum. Page generated in 0.02360 seconds