Merge branch 'master' into develop

This commit is contained in:
Philipp Fromme 2019-10-11 16:38:08 +02:00
commit 59de7598b1
5 changed files with 138 additions and 26 deletions

View File

@ -84,6 +84,11 @@ export default function AdaptiveLabelPositioningBehavior(eventBus, modeling) {
label = element.label,
labelMid = getMid(label);
// ignore labels that are being created
if (!label.parent) {
return;
}
var elementTrbl = asTRBL(element);
var newLabelMid;
@ -125,7 +130,6 @@ export default function AdaptiveLabelPositioningBehavior(eventBus, modeling) {
break;
}
var delta = substract(newLabelMid, labelMid);
modeling.moveShape(label, delta);

View File

@ -34,7 +34,7 @@ UpdateFlowNodeRefsHandler.$inject = [
UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, laneShapes) {
var handledNodes = {};
var handledNodes = [];
var updates = [];
@ -58,9 +58,9 @@ UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, la
}
function addFlowNodeShape(flowNodeShape) {
if (!handledNodes[flowNodeShape.id]) {
if (handledNodes.indexOf(flowNodeShape) === -1) {
allFlowNodeShapes.push(flowNodeShape);
handledNodes[flowNodeShape.id] = flowNodeShape;
handledNodes.push(flowNodeShape);
}
}
@ -92,7 +92,7 @@ UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, la
laneShapes.forEach(function(laneShape) {
var root = getLanesRoot(laneShape);
if (!root || handledNodes[root.id]) {
if (!root || handledNodes.indexOf(root) !== -1) {
return;
}
@ -102,7 +102,7 @@ UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, la
children.forEach(addFlowNodeShape);
handledNodes[root.id] = root;
handledNodes.push(root);
});
flowNodeShapes.forEach(addFlowNodeShape);
@ -190,4 +190,4 @@ UpdateFlowNodeRefsHandler.prototype.revert = function(context) {
// TODO(nikku): return changed elements
// return [ ... ];
};
};

View File

@ -3,13 +3,16 @@ import {
inject
} from 'test/TestHelper';
import {
getOrientation
} from 'diagram-js/lib/layout/LayoutUtil';
import { getOrientation } from 'diagram-js/lib/layout/LayoutUtil';
import modelingModule from 'lib/features/modeling';
import coreModule from 'lib/core';
import {
DEFAULT_LABEL_SIZE,
getExternalLabelMid
} from 'lib/util/LabelUtil';
var testModules = [
modelingModule,
coreModule
@ -281,6 +284,45 @@ describe('modeling/behavior - AdaptiveLabelPositioningBehavior', function() {
}
));
it('should not adjust position', inject(function(bpmnFactory, elementFactory, elementRegistry, modeling, textRenderer) {
// given
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var intermediateThrowEvent = elementFactory.createShape({
businessObject: bpmnFactory.create('bpmn:IntermediateThrowEvent', {
name: 'Foo'
}),
type: 'bpmn:IntermediateThrowEvent',
x: 0,
y: 0
});
var externalLabelMid = getExternalLabelMid(intermediateThrowEvent);
var externalLabelBounds = textRenderer.getExternalLabelBounds(DEFAULT_LABEL_SIZE, 'Foo');
var label = elementFactory.createLabel({
labelTarget: intermediateThrowEvent,
x: externalLabelMid.x - externalLabelBounds.width / 2,
y: externalLabelMid.y - externalLabelBounds.height / 2,
width: externalLabelBounds.width,
height: externalLabelBounds.height
});
var sequenceFlowMid = getConnectionMid(sequenceFlow.waypoints[0], sequenceFlow.waypoints[1]);
// when
modeling.createElements([ intermediateThrowEvent, label ], sequenceFlowMid, sequenceFlow);
// then
expect(label.x).to.be.closeTo(325, 1);
expect(label.y).to.be.closeTo(335, 1);
expect(label.width).to.be.closeTo(19, 1);
expect(label.height).to.be.closeTo(14, 1);
}));
});
});
@ -407,3 +449,12 @@ describe('modeling/behavior - AdaptiveLabelPositioningBehavior', function() {
});
});
// helpers //////////
function getConnectionMid(a, b) {
return {
x: (a.x + b.x) / 2,
y: (a.y + b.y) / 2
};
}

View File

@ -266,4 +266,28 @@ describe('features/modeling - lanes - flowNodeRefs', function() {
expect(sourceLane.flowNodeRef).not.to.contain(event);
}));
it('should not create duplicate refs on attaching / detaching', inject(function(elementRegistry, modeling) {
// given
var eventID = 'IntermediateThrowEvent',
throwEvent = elementRegistry.get(eventID),
task1 = elementRegistry.get('Task_1'),
task2 = elementRegistry.get('Task_2'),
lane1 = elementRegistry.get('Participant_C_Lane_1').businessObject,
lane2 = elementRegistry.get('Participant_C_Lane_2').businessObject;
// when
modeling.moveElements([ throwEvent ], { x: -280, y: 30 }, task1, { attach: true });
var boundaryEvent = elementRegistry.get(eventID);
modeling.moveElements([ boundaryEvent ], { x: 0, y: 150 }, task2, { attach: true });
// then
expect(lane1.flowNodeRef).not.to.contain(boundaryEvent.businessObject);
expect(lane2.flowNodeRef).to.contain(boundaryEvent.businessObject);
expect(lane1.flowNodeRef).to.have.length(1);
expect(lane2.flowNodeRef).to.have.length(2);
}));
});

View File

@ -1,8 +1,9 @@
<?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="_2_FUoE-xEeWT0c1N_GlSWA" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/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="_2_FUoE-xEeWT0c1N_GlSWA" targetNamespace="http://activiti.org/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.0-dev" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="_Collaboration_2">
<bpmn2:participant id="Participant_A" name="Participant_A" processRef="Process_A"/>
<bpmn2:participant id="Participant_B" name="Participant_B" processRef="Process_B"/>
<bpmn2:participant id="Participant_A" name="Participant_A" processRef="Process_A" />
<bpmn2:participant id="Participant_B" name="Participant_B" processRef="Process_B" />
<bpmn2:participant id="Participant_0emukbw" name="Participant_C" processRef="Process_1gjk6nk" />
</bpmn2:collaboration>
<bpmn2:process id="Process_A" isExecutable="false">
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
@ -14,44 +15,76 @@
<bpmn2:task id="Task_A" name="Task_A">
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Task_A" targetRef="Event"/>
<bpmn2:intermediateCatchEvent id="Event" name="Event">
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
</bpmn2:intermediateCatchEvent>
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Task_A" targetRef="Event" />
</bpmn2:process>
<bpmn2:process id="Process_B" isExecutable="false">
<bpmn2:task id="Task_B" name="Task_B"/>
<bpmn2:task id="Task_B" name="Task_B" />
</bpmn2:process>
<bpmn2:process id="Process_1gjk6nk" isExecutable="false">
<bpmn2:laneSet id="LaneSet_06y7y48">
<bpmn2:lane id="Participant_C_Lane_1">
<bpmn2:flowNodeRef>Task_1</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>IntermediateThrowEvent</bpmn2:flowNodeRef>
</bpmn2:lane>
<bpmn2:lane id="Participant_C_Lane_2">
<bpmn2:flowNodeRef>Task_2</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:task id="Task_1" />
<bpmn2:task id="Task_2" />
<bpmn2:intermediateThrowEvent id="IntermediateThrowEvent" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_A" isHorizontal="true">
<dc:Bounds height="145.0" width="540.0" x="84.0" y="96.0"/>
<dc:Bounds x="154" y="96" width="540" height="145" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_B" isHorizontal="true">
<dc:Bounds height="133.0" width="540.0" x="84.0" y="312.0"/>
<dc:Bounds x="154" y="312" width="540" height="133" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_A">
<dc:Bounds height="80.0" width="100.0" x="168.0" y="129.0"/>
<dc:Bounds x="238" y="129" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Lane_2" bpmnElement="Lane" isHorizontal="true">
<dc:Bounds height="145.0" width="510.0" x="114.0" y="96.0"/>
<dc:Bounds x="184" y="96" width="510" height="145" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_2" bpmnElement="Event">
<dc:Bounds height="36.0" width="36.0" x="384.0" y="151.0"/>
<dc:Bounds x="454" y="151" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds height="21.0" width="112.0" x="346.0" y="192.0"/>
<dc:Bounds x="458" y="192" width="29" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_IntermediateCatchEvent_2">
<di:waypoint xsi:type="dc:Point" x="268.0" y="169.0"/>
<di:waypoint xsi:type="dc:Point" x="384.0" y="169.0"/>
<di:waypoint x="338" y="169" />
<di:waypoint x="454" y="169" />
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="290.0" y="169.0"/>
<dc:Bounds x="290" y="169" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task_B">
<dc:Bounds height="80.0" width="100.0" x="492.0" y="339.0"/>
<dc:Bounds x="562" y="339" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0emukbw_di" bpmnElement="Participant_0emukbw" isHorizontal="true">
<dc:Bounds x="154" y="475" width="540" height="285" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0lsm3hs_di" bpmnElement="Participant_C_Lane_1" isHorizontal="true">
<dc:Bounds x="184" y="475" width="510" height="150" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_16dmnot_di" bpmnElement="Participant_C_Lane_2" isHorizontal="true">
<dc:Bounds x="184" y="625" width="510" height="135" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1abs8bh_di" bpmnElement="Task_1">
<dc:Bounds x="230" y="510" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="IntermediateThrowEvent_0oto7vx_di" bpmnElement="IntermediateThrowEvent">
<dc:Bounds x="592" y="532" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0j7a294_di" bpmnElement="Task_2">
<dc:Bounds x="230" y="650" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn2:definitions>