Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Split connection between two nodes when placing a new node on the connection
Split connection between two nodes when placing a new node on the connection [message #771523] Tue, 27 December 2011 14:06 Go to next message
Peter Hayduk is currently offline Peter HaydukFriend
Messages: 3
Registered: December 2011
Junior Member
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 23:25 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
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

Re: Split connection between two nodes when placing a new node on the connection [message #986504 is a reply to message #771523] Tue, 20 November 2012 16:44 Go to previous messageGo to next message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
Hi!
I wanted to ask if there are any updates or examples on this requirement.

Thank you!
Re: Split connection between two nodes when placing a new node on the connection [message #986614 is a reply to message #986504] Wed, 21 November 2012 08:21 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi Daniel,

actually there is an update on this. You can find a how to and sample code here http://wiki.eclipse.org/Graphical_Modeling_Framework/Tips#Implicit_node_in_the_middle_creation. To stay up to date you should also put yourself on CC of this bugzilla item https://bugs.eclipse.org/bugs/show_bug.cgi?id=331868

Ralph
Re: Split connection between two nodes when placing a new node on the connection [message #986999 is a reply to message #771523] Thu, 22 November 2012 18:13 Go to previous messageGo to next message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
Thank you for your answer Ralph! Smile

Do you know if it's also possible to add such a "node in the middle" after a connection has been made (i.e. add a node to an existing connection)?
This would be exactly what I am looking for. Smile

Thank you again,
Daniel
Re: Split connection between two nodes when placing a new node on the connection [message #987068 is a reply to message #986999] Fri, 23 November 2012 09:38 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

how shall this look on the UI (how shall the user invoke this action)?

Ralph
Re: Split connection between two nodes when placing a new node on the connection [message #987071 is a reply to message #987068] Fri, 23 November 2012 09:52 Go to previous messageGo to next message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
Hi Ralph!

Currently I have simple connection between my nodes (the triangles).
I have an use-case, where the user should be able to split an existing connection into two connections and have a node in the middle which should also be a (triangle) node again.

The behaviour would be exactly the same as if the user inserts a "routing point" (I don't know the name of these but I think you know what I mean Wink) to a connection.

Example:
index.php/fa/12483/0/

So it's similar to the node in the middle example you mentioned with the difference, that the node should be added to an existing connection.

Do you (know if)/(think) that is possible?


Thank you,
Daniel
  • Attachment: example.png
    (Size: 6.58KB, Downloaded 586 times)

[Updated on: Fri, 23 November 2012 09:54]

Report message to a moderator

Re: Split connection between two nodes when placing a new node on the connection [message #987099 is a reply to message #987071] Fri, 23 November 2012 13:15 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

to create the triangle you would need to use a CreateUnspecifiedTypeRequest and hand an ElementType to it (e.g. xxxElementTypes.MyTriangleType1234). To redirect the connection lines try to use emf's SetCommand (e.g. Command cmd = SetCommand.create(domain <- you can use TransactionUtil.getDomain on the owner of the feature, owner, feature <- xxxPackage.eInstance.getFeatureXY(), value <- The new connection)). This should do the trick.

Ralph
Re: Split connection between two nodes when placing a new node on the connection [message #1007518 is a reply to message #771523] Wed, 06 February 2013 10:10 Go to previous messageGo to next message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
Do you know if and how I can add a node to a connection? (EditPolicies, Tools, whatever)

The best way would be to create such a "Middle Node" with a tool from the palette, but this seems to not be supported as I can't add "Child References" to a Link in the gmfmap.


Thanks to everybody who (can / tries to) help in advance!
Daniel
Re: Split connection between two nodes when placing a new node on the connection [message #1007713 is a reply to message #1007518] Thu, 07 February 2013 09:17 Go to previous message
Daniel König is currently offline Daniel KönigFriend
Messages: 24
Registered: November 2012
Junior Member
It tried using the BendpointEditPolicy to react to new bendpoints and split the connection instead of the default behaviour (set a bendpoint).
Unfortunately it seems that the methods of that EditPolicy are never called and therefore it didn't work...
Previous Topic:Wizard for creating a model file
Next Topic:Creating elements in the diagram statically
Goto Forum:
  


Current Time: Thu Apr 18 14:57:10 GMT 2024

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

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

Back to the top