feat(modeling/layout): improve message flow layout on Participants

Closes #574
This commit is contained in:
Ricardo Matias 2016-06-21 11:59:33 +02:00 committed by Nico Rehwaldt
parent e99214bb6a
commit 6549af7aca
3 changed files with 135 additions and 4 deletions

View File

@ -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' ]
@ -150,4 +163,4 @@ function isCompensationAssociation(connection) {
return is(target, 'bpmn:Activity') &&
is(source, 'bpmn:BoundaryEvent') &&
target.businessObject.isForCompensation;
}
}

View File

@ -0,0 +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" id="_pHDz0KojEeOJhIBv1RySdg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.1.0" 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: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:endEvent id="EndEvent_1">
<bpmn2:messageEventDefinition id="MessageEventDefinition_2" />
</bpmn2:endEvent>
<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: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 x="278" y="84" width="599" height="217" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_1" isHorizontal="true">
<dc:Bounds x="222" y="415" width="600" height="100" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_3" bpmnElement="StartEvent_1">
<dc:Bounds x="300" y="448" width="36" height="36" />
<bpmndi:BPMNLabel>
<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 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" y="214" />
<di:waypoint xsi:type="dc:Point" x="590" y="415" />
<bpmndi:BPMNLabel>
<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" y="415" />
<di:waypoint xsi:type="dc:Point" x="506" y="301" />
<bpmndi:BPMNLabel>
<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" 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 x="427" y="321" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">
<dc:Bounds x="653" y="178" width="36" height="36" />
<bpmndi:BPMNLabel>
<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" y="214" />
<di:waypoint xsi:type="dc:Point" x="671" y="415" />
<bpmndi:BPMNLabel>
<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 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>

View File

@ -11,7 +11,7 @@ var modelingModule = require('../../../../../lib/features/modeling'),
describe('features/modeling - layout message flows', function() {
var diagramXML = require('../../../../fixtures/bpmn/collaboration-message-flows.bpmn');
var diagramXML = require('./LayoutMessageFlowSpec.bpmn');
var testModules = [ coreModule, modelingModule ];
@ -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) {
@ -98,4 +123,4 @@ describe('features/modeling - layout message flows', function() {
})
);
});
});