Skip to content

Commit

Permalink
feat(modeling): modify how to layout straight message flows
Browse files Browse the repository at this point in the history
Closes #574
  • Loading branch information
Ricardo Matias authored and nikku committed Jun 21, 2016
1 parent e99214b commit c5b9880
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 39 deletions.
17 changes: 15 additions & 2 deletions lib/features/modeling/BpmnLayouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,22 @@ BpmnLayouter.prototype.layoutConnection = function(connection, layoutHints) {
// manhattan layout sequence / message flows
if (is(connection, 'bpmn:MessageFlow')) {
manhattanOptions = {
preferredLayouts: [ 'straight', 'v:v' ]
preferredLayouts: [ 'v:v' ]
};

if (is(target, 'bpmn:Participant')) {
manhattanOptions = {
preferredLayouts: [ 'straight', 'v:v' ]
};
}

if (is(source, 'bpmn:Participant') && is(target, 'bpmn:FlowNode')) {
manhattanOptions = {
preferredLayouts: [ 'straight', 'v:v' ],
moveSource: true
};
}

if (is(target, 'bpmn:Event')) {
manhattanOptions = {
preferredLayouts: [ 'v:v' ]
Expand Down Expand Up @@ -150,4 +163,4 @@ function isCompensationAssociation(connection) {
return is(target, 'bpmn:Activity') &&
is(source, 'bpmn:BoundaryEvent') &&
target.businessObject.isForCompensation;
}
}
82 changes: 46 additions & 36 deletions test/fixtures/bpmn/collaboration-message-flows.bpmn
Original file line number Diff line number Diff line change
@@ -1,83 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_pHDz0KojEeOJhIBv1RySdg" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_pHDz0KojEeOJhIBv1RySdg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.2.0-dev" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="_Collaboration_2">
<bpmn2:participant id="Participant_2" name="Pool" processRef="Process_1"/>
<bpmn2:participant id="Participant_1" name="Pool" processRef="Process_2"/>
<bpmn2:messageFlow id="MessageFlow_1" name="" sourceRef="Task_2" targetRef="Participant_1"/>
<bpmn2:messageFlow id="MessageFlow_2" name="" sourceRef="Participant_1" targetRef="Participant_2"/>
<bpmn2:messageFlow id="MessageFlow_4" name="" sourceRef="Task_1" targetRef="StartEvent_1"/>
<bpmn2:messageFlow id="MessageFlow_5" name="" sourceRef="EndEvent_1" targetRef="Participant_1"/>
<bpmn2:participant id="Participant_2" name="Pool" processRef="Process_1" />
<bpmn2:participant id="Participant_1" name="Pool" processRef="Process_2" />
<bpmn2:messageFlow id="MessageFlow_1" name="" sourceRef="Task_2" targetRef="Participant_1" />
<bpmn2:messageFlow id="MessageFlow_2" name="" sourceRef="Participant_1" targetRef="Participant_2" />
<bpmn2:messageFlow id="MessageFlow_4" name="" sourceRef="Task_1" targetRef="StartEvent_1" />
<bpmn2:messageFlow id="MessageFlow_5" name="" sourceRef="EndEvent_1" targetRef="Participant_1" />
<bpmn2:messageFlow id="MessageFlow_6" sourceRef="Participant_1" targetRef="Task_3" />
</bpmn2:collaboration>
<bpmn2:process id="Process_1" isExecutable="false">
<bpmn2:task id="Task_1"/>
<bpmn2:task id="Task_1" />
<bpmn2:endEvent id="EndEvent_1">
<bpmn2:messageEventDefinition id="MessageEventDefinition_2"/>
<bpmn2:messageEventDefinition id="MessageEventDefinition_2" />
</bpmn2:endEvent>
<bpmn2:task id="Task_2"/>
<bpmn2:task id="Task_2" />
<bpmn2:task id="Task_3" />
</bpmn2:process>
<bpmn2:process id="Process_2" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:messageEventDefinition id="MessageEventDefinition_1"/>
<bpmn2:messageEventDefinition id="MessageEventDefinition_1" />
</bpmn2:startEvent>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_2" isHorizontal="true">
<dc:Bounds height="217.0" width="456.0" x="278.0" y="84.0"/>
<dc:Bounds x="278" y="84" width="599" height="217" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_1" isHorizontal="true">
<dc:Bounds height="100.0" width="600.0" x="222.0" y="415.0"/>
<dc:Bounds x="222" y="415" width="600" height="100" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_3" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="300.0" y="448.0"/>
<dc:Bounds x="300" y="448" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="318.0" y="489.0"/>
<dc:Bounds x="273" y="489" width="90" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task_1">
<dc:Bounds height="80.0" width="100.0" x="360.0" y="134.0"/>
<dc:Bounds x="360" y="134" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_1" bpmnElement="MessageFlow_1" sourceElement="_BPMNShape_Task_4" targetElement="_BPMNShape_Participant_3">
<di:waypoint xsi:type="dc:Point" x="590.0" y="214.0"/>
<di:waypoint xsi:type="dc:Point" x="590.0" y="415.0"/>
<di:waypoint xsi:type="dc:Point" x="590" y="214" />
<di:waypoint xsi:type="dc:Point" x="590" y="415" />
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="522.0" y="314.0"/>
<dc:Bounds x="522" y="314" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_2" bpmnElement="MessageFlow_2" sourceElement="_BPMNShape_Participant_3" targetElement="_BPMNShape_Participant_2">
<di:waypoint xsi:type="dc:Point" x="506.0" y="415.0"/>
<di:waypoint xsi:type="dc:Point" x="506.0" y="386.0"/>
<di:waypoint xsi:type="dc:Point" x="506.0" y="386.0"/>
<di:waypoint xsi:type="dc:Point" x="506.0" y="300.0"/>
<di:waypoint xsi:type="dc:Point" x="506" y="415" />
<di:waypoint xsi:type="dc:Point" x="506" y="301" />
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="504.0" y="386.0"/>
<dc:Bounds x="504" y="386" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_4" bpmnElement="MessageFlow_4" sourceElement="_BPMNShape_Task_3" targetElement="_BPMNShape_StartEvent_3">
<di:waypoint xsi:type="dc:Point" x="390.0" y="214.0"/>
<di:waypoint xsi:type="dc:Point" x="390.0" y="387.0"/>
<di:waypoint xsi:type="dc:Point" x="318.0" y="387.0"/>
<di:waypoint xsi:type="dc:Point" x="318.0" y="448.0"/>
<di:waypoint xsi:type="dc:Point" x="390" y="214" />
<di:waypoint xsi:type="dc:Point" x="390" y="387" />
<di:waypoint xsi:type="dc:Point" x="318" y="387" />
<di:waypoint xsi:type="dc:Point" x="318" y="448" />
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="427.0" y="321.0"/>
<dc:Bounds x="427" y="321" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="653.0" y="178.0"/>
<dc:Bounds x="653" y="178" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="671.0" y="219.0"/>
<dc:Bounds x="671" y="219" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_5" bpmnElement="MessageFlow_5" sourceElement="_BPMNShape_EndEvent_2" targetElement="_BPMNShape_Participant_3">
<di:waypoint xsi:type="dc:Point" x="671.0" y="214.0"/>
<di:waypoint xsi:type="dc:Point" x="671.0" y="415.0"/>
<di:waypoint xsi:type="dc:Point" x="671" y="214" />
<di:waypoint xsi:type="dc:Point" x="671" y="415" />
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="630.0" y="332.0"/>
<dc:Bounds x="630" y="332" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_Task_4" bpmnElement="Task_2">
<dc:Bounds height="80.0" width="100.0" x="516.0" y="134.0"/>
<dc:Bounds x="516" y="134" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_01g27j8_di" bpmnElement="Task_3">
<dc:Bounds x="723" y="134" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="MessageFlow_0dz36ij_di" bpmnElement="MessageFlow_6">
<di:waypoint xsi:type="dc:Point" x="773" y="415" />
<di:waypoint xsi:type="dc:Point" x="773" y="214" />
<bpmndi:BPMNLabel>
<dc:Bounds x="743" y="304.5" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn2:definitions>
27 changes: 26 additions & 1 deletion test/spec/features/modeling/layout/LayoutMessageFlowSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ describe('features/modeling - layout message flows', function() {
}));


it('should layout straight after Participant move, without moving Task\'s docking point',
inject(function(elementRegistry, modeling) {

// given
var participantShape = elementRegistry.get('Participant_1'),
messageFlow1 = elementRegistry.get('MessageFlow_1'),
messageFlow6 = elementRegistry.get('MessageFlow_6');

// when
modeling.moveElements([ participantShape ], { x: 300, y: 50 });
// then

// expect cropped, repaired manhattan connection
expect(messageFlow1.waypoints).eql([
{ original: { x: 590, y: 214 }, x: 590, y: 214 },
{ original: { x: 590, y: 465 }, x: 590, y: 465 }
]);

expect(messageFlow6.waypoints).eql([
{ original: { x: 773, y: 465 }, x: 773, y: 465 },
{ original: { x: 773, y: 214 }, x: 773, y: 214 }
]);
}));


it('should layout manhattan after Participant move beyond EndEvent bounds',
inject(function(elementRegistry, modeling) {

Expand All @@ -98,4 +123,4 @@ describe('features/modeling - layout message flows', function() {
})
);

});
});

0 comments on commit c5b9880

Please sign in to comment.