Split connection between two nodes when placing a new node on the connection [message #771523] |
Tue, 27 December 2011 09:06  |
Eclipse User |
|
|
|
Hello I have a graphical editor with only one kind of connection and a dozen of different nodes. I need to implement the following feature. I have a connection between two nodes and I want to place a new node on the existing connection. Now the connection should be split.
e.g.
Node_A ---- Node_B --> Node_A ---- Node_C ---- Node_B
My idea is to remove the existing connection and create two new connections but how to get the existing connection where I dropped the new node on it? Can anybody give me a hint how to solve this. Thanks.
|
|
|
Re: Split connection between two nodes when placing a new node on the connection [message #780673 is a reply to message #771523] |
Wed, 18 January 2012 18:25   |
Eclipse User |
|
|
|
Hello,
Interesting requirement, probably quite common one to be generalized for a generation support.
Right now I can only suggest the solution that uses the 100% hand-written tool for splitting the link, separate from the UnspecifiedTypeCreationTool that creates NodeC at the diagram canvas.
If this is acceptable for you, I would
- created the new type of MySplitRequest extends CreateRequest
- created the new editpolicy that understands new request to be attached to the link editpart
- in this new SplitLinkPolicy you would be able to access
-- the link model (edge) by getHostImpl().getNotationView()
-- the source/target nodes by getHostImpl().getTarget().getNotationView()
-- all 3 semantic elements as a correspondingView.getElement()
-- location of the user click via MySplitRequest#getLocation()
-- view and semantic element for the diagram via getHostImpl().getNotationView().getDiagram()[.getElement()]
With access to all the above, from the getCommand() I would return the new ICommandProxy(new AbstractTransactionalCommand(...)), that does the following:
(semantic part)
-- (1.1) creation of the new semantic element (look for existing CreateNodeCCommand for hints)
-- (1.2) creation of the semantic link from new NodeC to NodeB -- depends only on your model
-- (1.3) semantic rerouting of the existing link from NodeA to the new NodeC instead of old NodeB -- depends only on your model
(notation part)
-- (2.1) creation of the new notation node for just created NodeC -- simply call the ViewService.createNode(...) for results of (1.1)
-- (2.2) creation of the new notation edge for just created link B->C -- simply call the ViewService.createEdge(...) for results of (1.2)
-- (2.3) some magic code around anchors and bendpoints for (2.2) that I never understood completely -- look at the SetConnectionAnchorsCommand / SetConnectionBendpointsCommand
-- (2.4) rerouting of the old notation edge from the old nodeB to the results of (2.1) -- just call oldEdge.setTarget(...) directly
-- (2.5) positioning of the (2.1) according to the request location
Quite a lot of work, that's why we probably would be better automate this, so please submit bugzilla for a generation support for that.
Regards,
Michael "Borlander" Golubev
at Montages Think Tank, Prague, Czech Republic
Montages AG, Zürich, Switzerland
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.72671 seconds