Hi @wildix!
The ElementFactory#createParticipantShape
offers a helper to create bpmn:Participant
elements which an attached bpmn:Process
element. This returns a participant shape which can be added to the canvas. For setting the name you will have to update the shapes
name` property. So something like this
var elementFactory = modeler.get('elementFactory'),
modeling = modeler.get('modeling'),
canvas = modeler.get('canvas');
var parent = canvas.getRootElement(),
participant1 = elementFactory.createParticipantShape(),
participant2 = elementFactory.createParticipantShape();
participant1.businessObject.name = 'A';
participant2.businessObject.name = 'B';
modeling.createShape(participant1, { x: 350, y: 200 }, parent);
// turned into collaboration
parent = canvas.getRootElement();
modeling.createShape(participant2, { x: 350, y: 500 }, parent);
Will lead to this
Note: Creating the first participant in the process will turn the whole diagram to a collaboration for adding another participants