Question

I have a GEF Editor with a Command to create a new node. I want to pass the current selection of nodes in the editor to this command, in order to let the command create a new node and create connections from the new node to the selected nodes in the editor.

How can I achieve this?

Was it helpful?

Solution

In the edit policy you can call getHost().getViewer().getSelectedEditParts() to get the selected edit parts, and then pass their model to the Command used to create the new node.

IMO, instead of one single command to do this you should have different commands for node creation and link creation and create a compound command in your edit policy that first creates the node and then creates the link. This gives you better modularity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top