Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Recursive Deleting all children of a ModelObject
Recursive Deleting all children of a ModelObject [message #231488] Fri, 09 March 2007 10:42 Go to next message
Eclipse UserFriend
Originally posted by: news.madlener.online.de

Hello everyone,

another question to the audience. How is it possible to run a delete
command in a recursive order?
For example, a node in a tree is deleted. But all children that come
after that node have to be deleted too.
I thought that the commands would work like this automatically, but
somehow it does not show in the editor (if it is not once again the
problem using the directgraph layouter...)
Thanks for helping out.

cheers

Oliver
Re: Recursive Deleting all children of a ModelObject [message #231504 is a reply to message #231488] Fri, 09 March 2007 11:45 Go to previous message
Eclipse UserFriend
Originally posted by: news.madlener.online.de

Hi again,

here is a first try on how to get it working, well it does work. I just
wonder if there is a better place to put it, it seems a little crude to
produce a deleteCommand inside a deleteCommand.

This Code-Snippet is part of the DeleteCommand, the class that is
extending Command :

public void execute() {
if(child instanceof ParentModelElement &&
(ParentModelElement)child).getChildren()!=Collections.EMPTY_ LIST)
{ for(int i = 0; i <((ParentModelElement)child).getChildren().size(); i++)
{
VisualEditorModelElement vEME =
(VisualEditorModelElement)((ParentModelElement)child).getChi ldren().get(i);

DeleteCommand cmd = new DeleteCommand((ParentModelElement)child, vEME);
cmd.execute();
}
}
sourceConnections = child.getSourceConnections();
targetConnections = child.getTargetConnections();
parent.removeChild(child);
deleteConnections(sourceConnections);
deleteConnections(targetConnections);
}

cheers

Oliver
Previous Topic:jUnit Testing GEF
Next Topic:recursive call of fillShape methode
Goto Forum:
  


Current Time: Tue Oct 19 00:32:05 GMT 2021

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

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

Back to the top