Best way to connect multiple nodes to a single node


I’m looking for an user flow which will enable user to select some nodes and connect all selected nodes into target node.
Any idea appreciated and if I missed something in samples/introductions page please let me know and share the link :)


How would the user declare which node is to be the target node? Could you use a context menu command?

Or how would your code choose the appropriate target node, based on location or some other criteria?

The general answer is to commit a transaction that iterates over the Diagram.selection. For each qualified node it would add a link from that node to the target node.

Actually I’m looking for UX solution/ user flow for this functionality. I’m thinking about context menu action, but not sure this is something I want.
I have an idea an I want an confirmation that it make sense and will work

  1. On user select multiple nodes of special category, another category nodes are “highlighted” in some sort
  2. user clicks on highlighted node, nodes which was selected connects into highlighted node user just clicked
  3. de-highlight node, unselect everything (optional)


OK, so you aren’t really asking about how to add some links – you already know how to do that.

So, do you want there to be a separate “mode” to enable this behavior?

If so, whenever a node of that special category is selected or de-selected, you could highlight potential target nodes that have a different category. You could implement this highlighting in a “ChangedSelection” DiagramEvent. In this special linking mode, I assume you would ignore selection of links and nodes of that were not of that special category.

Then there would need to be a way for the user to indicate which node(s) they would want to connect with new links. Is more than one target node permitted? I suppose clicking on a highlighted target node could be deemed sufficient to say “yes, connect the selected nodes to this node”. Or maybe you would anticipate that they would want to scroll and zoom around first while they are deciding, so you would want to require something more deliberate than just a click on a valid target node.

There would also need to be a way to cancel the mode, in case the user changes their mind. They could explicitly change modes. Or maybe you would let them hit the Escape key, in which case you’d have to implement a CommandHandler.stopCommand to maybe change the mode or else call the super method.

Thanks @walter for sharing. A lot of things to think about.