|
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 23:25 |
Michael Golubev Messages: 383 Registered: July 2009 |
Senior Member |
|
|
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.04021 seconds