parent
489a6af3b2
commit
1b9ebfc993
|
@ -185,6 +185,7 @@ Modeler.prototype._modelingModules = [
|
||||||
require('diagram-js/lib/features/hand-tool'),
|
require('diagram-js/lib/features/hand-tool'),
|
||||||
require('./features/global-connect'),
|
require('./features/global-connect'),
|
||||||
require('./features/keyboard'),
|
require('./features/keyboard'),
|
||||||
|
require('./features/copy-paste'),
|
||||||
require('./features/snapping'),
|
require('./features/snapping'),
|
||||||
require('./features/modeling'),
|
require('./features/modeling'),
|
||||||
require('./features/context-pad'),
|
require('./features/context-pad'),
|
||||||
|
@ -202,4 +203,4 @@ Modeler.prototype._modelingModules = [
|
||||||
Modeler.prototype._modules = [].concat(
|
Modeler.prototype._modules = [].concat(
|
||||||
Modeler.prototype._modules,
|
Modeler.prototype._modules,
|
||||||
Modeler.prototype._interactionModules,
|
Modeler.prototype._interactionModules,
|
||||||
Modeler.prototype._modelingModules);
|
Modeler.prototype._modelingModules);
|
||||||
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var ModelUtil = require('../../util/ModelUtil'),
|
||||||
|
getBusinessObject = ModelUtil.getBusinessObject,
|
||||||
|
is = ModelUtil.is;
|
||||||
|
|
||||||
|
var map = require('lodash/collection/map'),
|
||||||
|
forEach = require('lodash/collection/forEach');
|
||||||
|
|
||||||
|
|
||||||
|
function setProperties(descriptor, data, properties) {
|
||||||
|
forEach(properties, function(property) {
|
||||||
|
if (data[property]) {
|
||||||
|
descriptor[property] = data[property];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeProperties(element, properties) {
|
||||||
|
forEach(properties, function(prop) {
|
||||||
|
if (element[prop]) {
|
||||||
|
delete element[prop];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canvas, bpmnRules) {
|
||||||
|
|
||||||
|
copyPaste.registerDescriptor(function(element, descriptor) {
|
||||||
|
var businessObject = getBusinessObject(element),
|
||||||
|
conditionExpression,
|
||||||
|
eventDefinitions;
|
||||||
|
|
||||||
|
descriptor.type = element.type;
|
||||||
|
|
||||||
|
if (element.type === 'label') {
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
setProperties(descriptor, businessObject, [
|
||||||
|
'name',
|
||||||
|
'text',
|
||||||
|
'processRef',
|
||||||
|
'isInterrupting',
|
||||||
|
'isForCompensation',
|
||||||
|
'associationDirection'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (businessObject.default) {
|
||||||
|
descriptor.default = businessObject.default.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (businessObject.loopCharacteristics) {
|
||||||
|
|
||||||
|
descriptor.loopCharacteristics = {
|
||||||
|
type: businessObject.loopCharacteristics.$type,
|
||||||
|
isSequential: businessObject.loopCharacteristics.isSequential
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
setProperties(descriptor, businessObject.di, [ 'isExpanded' ]);
|
||||||
|
|
||||||
|
if (is(businessObject, 'bpmn:SequenceFlow')) {
|
||||||
|
conditionExpression = businessObject.get('conditionExpression');
|
||||||
|
|
||||||
|
if (conditionExpression) {
|
||||||
|
descriptor.conditionExpression = {
|
||||||
|
type: conditionExpression.$type,
|
||||||
|
body: conditionExpression.body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eventDefinitions = businessObject.get('eventDefinitions') || [];
|
||||||
|
|
||||||
|
if (eventDefinitions.length) {
|
||||||
|
descriptor.eventDefinitions = map(eventDefinitions, function(defs) {
|
||||||
|
return defs.$type;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return descriptor;
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.on('element.paste', function(context) {
|
||||||
|
var descriptor = context.descriptor,
|
||||||
|
createdElements = context.createdElements,
|
||||||
|
parent = descriptor.parent,
|
||||||
|
businessObject, eventDefinitions, newEventDefinition, rootElement,
|
||||||
|
conditionExpression, loopCharacteristics,
|
||||||
|
source, target, canConnect;
|
||||||
|
|
||||||
|
if (descriptor.type === 'label') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is(parent, 'bpmn:Process')) {
|
||||||
|
rootElement = canvas.getRootElement();
|
||||||
|
|
||||||
|
descriptor.parent = is(rootElement, 'bpmn:Collaboration') ? rootElement : parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor.type === 'bpmn:MessageFlow') {
|
||||||
|
descriptor.parent = canvas.getRootElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure that the correct type of connection is created
|
||||||
|
if (descriptor.waypoints) {
|
||||||
|
source = createdElements[descriptor.source];
|
||||||
|
target = createdElements[descriptor.target];
|
||||||
|
|
||||||
|
if (source && target) {
|
||||||
|
source = source.element;
|
||||||
|
target = target.element;
|
||||||
|
}
|
||||||
|
|
||||||
|
canConnect = bpmnRules.canConnect(source, target);
|
||||||
|
|
||||||
|
if (canConnect) {
|
||||||
|
descriptor.type = canConnect.type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
descriptor.businessObject = businessObject = bpmnFactory.create(descriptor.type);
|
||||||
|
|
||||||
|
setProperties(businessObject, descriptor, [
|
||||||
|
'name',
|
||||||
|
'text',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (descriptor.loopCharacteristics) {
|
||||||
|
loopCharacteristics = descriptor.loopCharacteristics;
|
||||||
|
|
||||||
|
businessObject.loopCharacteristics = moddle.create(loopCharacteristics.type);
|
||||||
|
|
||||||
|
if (loopCharacteristics.isSequential) {
|
||||||
|
businessObject.loopCharacteristics.isSequential = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
businessObject.loopCharacteristics.$parent = businessObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor.conditionExpression) {
|
||||||
|
conditionExpression = descriptor.conditionExpression;
|
||||||
|
|
||||||
|
businessObject.conditionExpression = moddle.create(conditionExpression.type, { body: conditionExpression.body });
|
||||||
|
|
||||||
|
businessObject.conditionExpression.$parent = businessObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor.eventDefinitions) {
|
||||||
|
eventDefinitions = businessObject.eventDefinitions;
|
||||||
|
|
||||||
|
businessObject.eventDefinitions = map(descriptor.eventDefinitions, function(type) {
|
||||||
|
newEventDefinition = moddle.create(type);
|
||||||
|
|
||||||
|
newEventDefinition.$parent = businessObject;
|
||||||
|
|
||||||
|
return newEventDefinition;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeProperties(descriptor, [ 'name', 'text', 'eventDefinitions', 'conditionExpression', 'loopCharacteristics' ]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BpmnCopyPaste.$inject = [
|
||||||
|
'bpmnFactory',
|
||||||
|
'eventBus',
|
||||||
|
'copyPaste',
|
||||||
|
'clipboard',
|
||||||
|
'moddle',
|
||||||
|
'canvas',
|
||||||
|
'bpmnRules'
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = BpmnCopyPaste;
|
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
__depends__: [
|
||||||
|
require('diagram-js/lib/features/copy-paste')
|
||||||
|
],
|
||||||
|
__init__: [ 'bpmnCopyPaste' ],
|
||||||
|
bpmnCopyPaste: [ 'type', require('./BpmnCopyPaste') ]
|
||||||
|
};
|
|
@ -0,0 +1,61 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var inherits = require('inherits');
|
||||||
|
|
||||||
|
var forEach = require('lodash/collection/forEach');
|
||||||
|
|
||||||
|
var is = require('../../../util/ModelUtil').is;
|
||||||
|
|
||||||
|
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
||||||
|
|
||||||
|
|
||||||
|
function CopyPasteBehavior(eventBus, modeling, canvas) {
|
||||||
|
|
||||||
|
CommandInterceptor.call(this, eventBus);
|
||||||
|
|
||||||
|
this.preExecute('elements.paste', 1500, function(context) {
|
||||||
|
var topParent = context.topParent;
|
||||||
|
|
||||||
|
// always grab the latest root
|
||||||
|
if (!topParent.parent) {
|
||||||
|
context.topParent = canvas.getRootElement();
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
this.postExecute('elements.paste', function(context) {
|
||||||
|
|
||||||
|
var tree = context.tree,
|
||||||
|
createdElements = tree.createdElements;
|
||||||
|
|
||||||
|
forEach(createdElements, function(data) {
|
||||||
|
var element = data.element,
|
||||||
|
businessObject = element.businessObject,
|
||||||
|
descriptor = data.descriptor,
|
||||||
|
defaultFlow;
|
||||||
|
|
||||||
|
if ((is(businessObject, 'bpmn:ExclusiveGateway') || is(businessObject, 'bpmn:InclusiveGateway') ||
|
||||||
|
is(businessObject, 'bpmn:Activity')) && descriptor.default) {
|
||||||
|
|
||||||
|
defaultFlow = createdElements[descriptor.default];
|
||||||
|
|
||||||
|
// if the default flow wasn't created, means that it wasn't copied
|
||||||
|
if (defaultFlow) {
|
||||||
|
defaultFlow = defaultFlow.element;
|
||||||
|
} else {
|
||||||
|
defaultFlow = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete element.default;
|
||||||
|
|
||||||
|
modeling.updateProperties(element, { default: defaultFlow });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CopyPasteBehavior.$inject = [ 'eventBus', 'modeling', 'canvas' ];
|
||||||
|
|
||||||
|
inherits(CopyPasteBehavior, CommandInterceptor);
|
||||||
|
|
||||||
|
module.exports = CopyPasteBehavior;
|
|
@ -9,7 +9,7 @@ var is = require('../../../util/ModelUtil').is;
|
||||||
/**
|
/**
|
||||||
* BPMN specific create participant behavior
|
* BPMN specific create participant behavior
|
||||||
*/
|
*/
|
||||||
function CreateParticipantBehavior(eventBus, modeling, elementFactory, bpmnFactory) {
|
function CreateParticipantBehavior(eventBus, modeling, elementFactory, bpmnFactory, canvas) {
|
||||||
|
|
||||||
CommandInterceptor.call(this, eventBus);
|
CommandInterceptor.call(this, eventBus);
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ function CreateParticipantBehavior(eventBus, modeling, elementFactory, bpmnFacto
|
||||||
shape = context.shape,
|
shape = context.shape,
|
||||||
position = context.position;
|
position = context.position;
|
||||||
|
|
||||||
if (is(parent, 'bpmn:Process') && is(shape, 'bpmn:Participant')) {
|
var rootElement = canvas.getRootElement();
|
||||||
|
|
||||||
|
if (is(parent, 'bpmn:Process') && is(shape, 'bpmn:Participant') && !is(rootElement, 'bpmn:Collaboration')) {
|
||||||
|
|
||||||
// this is going to detach the process root
|
// this is going to detach the process root
|
||||||
// and set the returned collaboration element
|
// and set the returned collaboration element
|
||||||
|
@ -82,7 +84,7 @@ function CreateParticipantBehavior(eventBus, modeling, elementFactory, bpmnFacto
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateParticipantBehavior.$inject = [ 'eventBus', 'modeling', 'elementFactory', 'bpmnFactory' ];
|
CreateParticipantBehavior.$inject = [ 'eventBus', 'modeling', 'elementFactory', 'bpmnFactory', 'canvas' ];
|
||||||
|
|
||||||
inherits(CreateParticipantBehavior, CommandInterceptor);
|
inherits(CreateParticipantBehavior, CommandInterceptor);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
__init__: [
|
__init__: [
|
||||||
'appendBehavior',
|
'appendBehavior',
|
||||||
|
'copyPasteBehavior',
|
||||||
'createBoundaryEventBehavior',
|
'createBoundaryEventBehavior',
|
||||||
'createDataObjectBehavior',
|
'createDataObjectBehavior',
|
||||||
'createOnFlowBehavior',
|
'createOnFlowBehavior',
|
||||||
|
@ -19,6 +20,7 @@ module.exports = {
|
||||||
'unclaimIdBehavior'
|
'unclaimIdBehavior'
|
||||||
],
|
],
|
||||||
appendBehavior: [ 'type', require('./AppendBehavior') ],
|
appendBehavior: [ 'type', require('./AppendBehavior') ],
|
||||||
|
copyPasteBehavior: [ 'type', require('./CopyPasteBehavior') ],
|
||||||
createBoundaryEventBehavior: [ 'type', require('./CreateBoundaryEventBehavior') ],
|
createBoundaryEventBehavior: [ 'type', require('./CreateBoundaryEventBehavior') ],
|
||||||
createDataObjectBehavior: [ 'type', require('./CreateDataObjectBehavior') ],
|
createDataObjectBehavior: [ 'type', require('./CreateDataObjectBehavior') ],
|
||||||
createOnFlowBehavior: [ 'type', require('./CreateOnFlowBehavior') ],
|
createOnFlowBehavior: [ 'type', require('./CreateOnFlowBehavior') ],
|
||||||
|
|
|
@ -92,6 +92,33 @@ BpmnRules.prototype.init = function() {
|
||||||
return canAttach([ shape ], target, source, position) || canCreate(shape, target, source, position);
|
return canAttach([ shape ], target, source, position) || canCreate(shape, target, source, position);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addRule('element.copy', function(context) {
|
||||||
|
var collection = context.collection,
|
||||||
|
element = context.element;
|
||||||
|
|
||||||
|
return canCopy(collection, element);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addRule('element.paste', function(context) {
|
||||||
|
var parent = context.parent,
|
||||||
|
element = context.element,
|
||||||
|
position = context.position,
|
||||||
|
source = context.source,
|
||||||
|
target = context.target;
|
||||||
|
|
||||||
|
if (source || target) {
|
||||||
|
return canConnect(source, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return canAttach([ element ], parent, null, position) || canCreate(element, parent, null, position);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addRule('elements.paste', function(context) {
|
||||||
|
var target = context.target;
|
||||||
|
|
||||||
|
return canPaste(target);
|
||||||
|
});
|
||||||
|
|
||||||
this.addRule([ 'elements.delete' ], function(context) {
|
this.addRule([ 'elements.delete' ], function(context) {
|
||||||
|
|
||||||
// do not allow deletion of labels
|
// do not allow deletion of labels
|
||||||
|
@ -125,6 +152,8 @@ BpmnRules.prototype.canConnect = canConnect;
|
||||||
|
|
||||||
BpmnRules.prototype.canResize = canResize;
|
BpmnRules.prototype.canResize = canResize;
|
||||||
|
|
||||||
|
BpmnRules.prototype.canCopy = canCopy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility functions for rule checking
|
* Utility functions for rule checking
|
||||||
*/
|
*/
|
||||||
|
@ -395,6 +424,25 @@ function canDrop(element, target, position) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canPaste(target) {
|
||||||
|
|
||||||
|
// disallow to create elements on collapsed pools
|
||||||
|
if (is(target, 'bpmn:Participant') && !isExpanded(target)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is(target, 'bpmn:FlowElementsContainer')) {
|
||||||
|
return isExpanded(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isAny(target, [
|
||||||
|
'bpmn:Collaboration',
|
||||||
|
'bpmn:Lane',
|
||||||
|
'bpmn:Participant',
|
||||||
|
'bpmn:Process',
|
||||||
|
'bpmn:SubProcess' ]);
|
||||||
|
}
|
||||||
|
|
||||||
function isBoundaryEvent(element) {
|
function isBoundaryEvent(element) {
|
||||||
return !isLabel(element) && is(element, 'bpmn:BoundaryEvent');
|
return !isLabel(element) && is(element, 'bpmn:BoundaryEvent');
|
||||||
}
|
}
|
||||||
|
@ -659,3 +707,19 @@ function canInsert(shape, flow, position) {
|
||||||
!is(shape, 'bpmn:BoundaryEvent') &&
|
!is(shape, 'bpmn:BoundaryEvent') &&
|
||||||
canDrop(shape, flow.parent, position));
|
canDrop(shape, flow.parent, position));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function contains(collection, element) {
|
||||||
|
return (collection && element) && collection.indexOf(element) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function canCopy(collection, element) {
|
||||||
|
if (is(element, 'bpmn:Lane') && !contains(collection, element.parent)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is(element, 'bpmn:BoundaryEvent') && !contains(collection, element.host)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||||
|
<bpmn:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn:laneSet />
|
||||||
|
<bpmn:subProcess id="SubProcess_1kd6ist">
|
||||||
|
<bpmn:subProcess id="SubProcess_0gev7mx">
|
||||||
|
<bpmn:multiInstanceLoopCharacteristics isSequential="true" />
|
||||||
|
<bpmn:startEvent id="StartEvent_1" name="hello">
|
||||||
|
<bpmn:outgoing>SequenceFlow_1rtr33r</bpmn:outgoing>
|
||||||
|
</bpmn:startEvent>
|
||||||
|
<bpmn:endEvent id="EndEvent_0yejuvr" name="world!">
|
||||||
|
<bpmn:incoming>SequenceFlow_0y69l8f</bpmn:incoming>
|
||||||
|
</bpmn:endEvent>
|
||||||
|
<bpmn:task id="Task_1fo63a7" name="wait for it.." default="SequenceFlow_0y69l8f">
|
||||||
|
<bpmn:incoming>SequenceFlow_1rtr33r</bpmn:incoming>
|
||||||
|
<bpmn:outgoing>SequenceFlow_0y69l8f</bpmn:outgoing>
|
||||||
|
<bpmn:outgoing>SequenceFlow_07vo2r8</bpmn:outgoing>
|
||||||
|
</bpmn:task>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_0y69l8f" name="" sourceRef="Task_1fo63a7" targetRef="EndEvent_0yejuvr" />
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_1rtr33r" name="blah" sourceRef="StartEvent_1" targetRef="Task_1fo63a7" />
|
||||||
|
<bpmn:boundaryEvent id="BoundaryEvent_1c94bi9" attachedToRef="Task_1fo63a7">
|
||||||
|
<bpmn:timerEventDefinition />
|
||||||
|
</bpmn:boundaryEvent>
|
||||||
|
<bpmn:boundaryEvent id="BoundaryEvent_1404oxd" attachedToRef="Task_1fo63a7">
|
||||||
|
<bpmn:messageEventDefinition />
|
||||||
|
</bpmn:boundaryEvent>
|
||||||
|
<bpmn:intermediateThrowEvent id="IntermediateThrowEvent_09kpyzx">
|
||||||
|
<bpmn:incoming>SequenceFlow_07vo2r8</bpmn:incoming>
|
||||||
|
</bpmn:intermediateThrowEvent>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_07vo2r8" sourceRef="Task_1fo63a7" targetRef="IntermediateThrowEvent_09kpyzx">
|
||||||
|
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">foo</bpmn:conditionExpression>
|
||||||
|
</bpmn:sequenceFlow>
|
||||||
|
</bpmn:subProcess>
|
||||||
|
<bpmn:textAnnotation id="TextAnnotation_0h1hhgg"> <bpmn:text>foo</bpmn:text>
|
||||||
|
</bpmn:textAnnotation>
|
||||||
|
<bpmn:association id="Association_1f53xbo" sourceRef="SubProcess_0gev7mx" targetRef="TextAnnotation_0h1hhgg" />
|
||||||
|
</bpmn:subProcess>
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||||
|
<bpmndi:BPMNShape id="SubProcess_1kd6ist_di" bpmnElement="SubProcess_1kd6ist" isExpanded="true">
|
||||||
|
<dc:Bounds x="88" y="34" width="613" height="372" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="SubProcess_0gev7mx_di" bpmnElement="SubProcess_0gev7mx" isExpanded="true">
|
||||||
|
<dc:Bounds x="147" y="118" width="461" height="259" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||||
|
<dc:Bounds x="167" y="198" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="140" y="149" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="EndEvent_0yejuvr_di" bpmnElement="EndEvent_0yejuvr">
|
||||||
|
<dc:Bounds x="543" y="198" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="516" y="272" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_1fo63a7_di" bpmnElement="Task_1fo63a7">
|
||||||
|
<dc:Bounds x="293" y="176" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_0y69l8f_di" bpmnElement="SequenceFlow_0y69l8f">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="393" y="216" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="543" y="216" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="421" y="166" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_1rtr33r_di" bpmnElement="SequenceFlow_1rtr33r">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="203" y="216" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="293" y="216" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="202" y="321" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="BoundaryEvent_1c94bi9_di" bpmnElement="BoundaryEvent_1c94bi9">
|
||||||
|
<dc:Bounds x="375" y="238" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="348" y="274" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="TextAnnotation_0h1hhgg_di" bpmnElement="TextAnnotation_0h1hhgg">
|
||||||
|
<dc:Bounds x="564" y="58" width="100" height="30" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="Association_1f53xbo_di" bpmnElement="Association_1f53xbo">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="595" y="118" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="581" y="88" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="BoundaryEvent_1404oxd_di" bpmnElement="BoundaryEvent_1404oxd">
|
||||||
|
<dc:Bounds x="275" y="238" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="248" y="274" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateThrowEvent_09kpyzx_di" bpmnElement="IntermediateThrowEvent_09kpyzx">
|
||||||
|
<dc:Bounds x="458" y="287" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="431" y="323" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_07vo2r8_di" bpmnElement="SequenceFlow_07vo2r8">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="343" y="256" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="343" y="305" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="458" y="305" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="381" y="250.5" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -0,0 +1,102 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||||
|
<bpmn:collaboration id="Collaboration_0xsgb8u">
|
||||||
|
<bpmn:participant id="Participant_0pgdgt4" processRef="Process_1" />
|
||||||
|
<bpmn:participant id="Participant_1id96b4" processRef="Process_08nr0a7" />
|
||||||
|
<bpmn:messageFlow id="MessageFlow_150lriv" sourceRef="IntermediateThrowEvent_0audt6r" targetRef="Task_0n0k2nj" />
|
||||||
|
</bpmn:collaboration>
|
||||||
|
<bpmn:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn:laneSet>
|
||||||
|
<bpmn:lane id="Lane_1gzt96j">
|
||||||
|
<bpmn:flowNodeRef>Task_1pamrp2</bpmn:flowNodeRef>
|
||||||
|
<bpmn:childLaneSet xsi:type="bpmn:tLaneSet">
|
||||||
|
<bpmn:lane id="Lane_1yo0kyz">
|
||||||
|
<bpmn:flowNodeRef>Task_1pamrp2</bpmn:flowNodeRef>
|
||||||
|
</bpmn:lane>
|
||||||
|
<bpmn:lane id="Lane_022an7b" />
|
||||||
|
</bpmn:childLaneSet>
|
||||||
|
</bpmn:lane>
|
||||||
|
<bpmn:lane id="Lane_1kulv9k">
|
||||||
|
<bpmn:flowNodeRef>Task_0n0k2nj</bpmn:flowNodeRef>
|
||||||
|
</bpmn:lane>
|
||||||
|
</bpmn:laneSet>
|
||||||
|
<bpmn:task id="Task_0n0k2nj" />
|
||||||
|
<bpmn:task id="Task_1pamrp2" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmn:process id="Process_08nr0a7" isExecutable="false">
|
||||||
|
<bpmn:laneSet>
|
||||||
|
<bpmn:lane id="Lane_0aws6ii">
|
||||||
|
<bpmn:flowNodeRef>StartEvent_07r1iyh</bpmn:flowNodeRef>
|
||||||
|
</bpmn:lane>
|
||||||
|
<bpmn:lane id="Lane_1sd1zl3">
|
||||||
|
<bpmn:flowNodeRef>IntermediateThrowEvent_0audt6r</bpmn:flowNodeRef>
|
||||||
|
</bpmn:lane>
|
||||||
|
<bpmn:lane id="Lane_16ah5rn" />
|
||||||
|
</bpmn:laneSet>
|
||||||
|
<bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0audt6r" />
|
||||||
|
<bpmn:startEvent id="StartEvent_07r1iyh" />
|
||||||
|
<bpmn:endEvent id="EndEvent_1u50ypf" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0xsgb8u">
|
||||||
|
<bpmndi:BPMNShape id="Participant_0pgdgt4_di" bpmnElement="Participant_0pgdgt4">
|
||||||
|
<dc:Bounds x="93" y="21" width="600" height="323" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Participant_1id96b4_di" bpmnElement="Participant_1id96b4">
|
||||||
|
<dc:Bounds x="93" y="432" width="600" height="250" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_1gzt96j_di" bpmnElement="Lane_1gzt96j">
|
||||||
|
<dc:Bounds x="123" y="21" width="570" height="198" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_1kulv9k_di" bpmnElement="Lane_1kulv9k">
|
||||||
|
<dc:Bounds x="123" y="219" width="570" height="125" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_0aws6ii_di" bpmnElement="Lane_0aws6ii">
|
||||||
|
<dc:Bounds x="123" y="432" width="570" height="83" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_1sd1zl3_di" bpmnElement="Lane_1sd1zl3">
|
||||||
|
<dc:Bounds x="123" y="515" width="570" height="83" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_16ah5rn_di" bpmnElement="Lane_16ah5rn">
|
||||||
|
<dc:Bounds x="123" y="598" width="570" height="84" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="StartEvent_07r1iyh_di" bpmnElement="StartEvent_07r1iyh">
|
||||||
|
<dc:Bounds x="181" y="455" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="154" y="491" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateThrowEvent_0audt6r_di" bpmnElement="IntermediateThrowEvent_0audt6r">
|
||||||
|
<dc:Bounds x="365" y="542" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="338" y="578" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="EndEvent_1u50ypf_di" bpmnElement="EndEvent_1u50ypf">
|
||||||
|
<dc:Bounds x="541" y="636" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="514" y="672" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_1pamrp2_di" bpmnElement="Task_1pamrp2">
|
||||||
|
<dc:Bounds x="341" y="56" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_0n0k2nj_di" bpmnElement="Task_0n0k2nj">
|
||||||
|
<dc:Bounds x="341" y="242" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="MessageFlow_150lriv_di" bpmnElement="MessageFlow_150lriv">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="383" y="542" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="383" y="322" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="338" y="453.5" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="Lane_1yo0kyz_di" bpmnElement="Lane_1yo0kyz">
|
||||||
|
<dc:Bounds x="153" y="21" width="540" height="136" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_022an7b_di" bpmnElement="Lane_022an7b">
|
||||||
|
<dc:Bounds x="153" y="157" width="540" height="62" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||||
|
<bpmn:collaboration id="Collaboration_0whmvae">
|
||||||
|
<bpmn:participant id="Participant_0uu1rvj" processRef="Process_1" />
|
||||||
|
<bpmn:participant id="Participant_145muai" name="colloopsed" />
|
||||||
|
</bpmn:collaboration>
|
||||||
|
<bpmn:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn:laneSet>
|
||||||
|
<bpmn:lane id="Lane_1gl63sa">
|
||||||
|
<bpmn:flowNodeRef>StartEvent_0o6vk5g</bpmn:flowNodeRef>
|
||||||
|
<bpmn:flowNodeRef>Task_13xbgyg</bpmn:flowNodeRef>
|
||||||
|
<bpmn:flowNodeRef>EndEvent_1nef447</bpmn:flowNodeRef>
|
||||||
|
</bpmn:lane>
|
||||||
|
<bpmn:lane id="Lane_13h648l" />
|
||||||
|
</bpmn:laneSet>
|
||||||
|
<bpmn:startEvent id="StartEvent_0o6vk5g">
|
||||||
|
<bpmn:outgoing>SequenceFlow_0v3q8mo</bpmn:outgoing>
|
||||||
|
</bpmn:startEvent>
|
||||||
|
<bpmn:task id="Task_13xbgyg">
|
||||||
|
<bpmn:incoming>SequenceFlow_0v3q8mo</bpmn:incoming>
|
||||||
|
<bpmn:outgoing>SequenceFlow_1yvonen</bpmn:outgoing>
|
||||||
|
</bpmn:task>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_0v3q8mo" sourceRef="StartEvent_0o6vk5g" targetRef="Task_13xbgyg" />
|
||||||
|
<bpmn:endEvent id="EndEvent_1nef447">
|
||||||
|
<bpmn:incoming>SequenceFlow_1yvonen</bpmn:incoming>
|
||||||
|
</bpmn:endEvent>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_1yvonen" sourceRef="Task_13xbgyg" targetRef="EndEvent_1nef447" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0whmvae">
|
||||||
|
<bpmndi:BPMNShape id="Participant_0uu1rvj_di" bpmnElement="Participant_0uu1rvj">
|
||||||
|
<dc:Bounds x="78" y="28" width="600" height="250" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_1gl63sa_di" bpmnElement="Lane_1gl63sa">
|
||||||
|
<dc:Bounds x="108" y="28" width="570" height="125" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Lane_13h648l_di" bpmnElement="Lane_13h648l">
|
||||||
|
<dc:Bounds x="108" y="153" width="570" height="125" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="StartEvent_0o6vk5g_di" bpmnElement="StartEvent_0o6vk5g">
|
||||||
|
<dc:Bounds x="141" y="75" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="114" y="111" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_13xbgyg_di" bpmnElement="Task_13xbgyg">
|
||||||
|
<dc:Bounds x="285" y="53" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_0v3q8mo_di" bpmnElement="SequenceFlow_0v3q8mo">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="177" y="93" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="285" y="93" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="186" y="83" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="EndEvent_1nef447_di" bpmnElement="EndEvent_1nef447">
|
||||||
|
<dc:Bounds x="468" y="75" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="441" y="111" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_1yvonen_di" bpmnElement="SequenceFlow_1yvonen">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="385" y="93" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="468" y="93" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="381.5" y="83" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="Participant_145muai_di" bpmnElement="Participant_145muai">
|
||||||
|
<dc:Bounds x="78" y="330" width="600" height="250" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -0,0 +1,340 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var TestHelper = require('../../../TestHelper');
|
||||||
|
|
||||||
|
/* global bootstrapModeler, inject */
|
||||||
|
|
||||||
|
var bpmnCopyPasteModule = require('../../../../lib/features/copy-paste'),
|
||||||
|
copyPasteModule = require('diagram-js/lib/features/copy-paste'),
|
||||||
|
modelingModule = require('../../../../lib/features/modeling'),
|
||||||
|
coreModule = require('../../../../lib/core');
|
||||||
|
|
||||||
|
var map = require('lodash/collection/map'),
|
||||||
|
forEach = require('lodash/collection/forEach');
|
||||||
|
|
||||||
|
var DescriptorTree = require('./DescriptorTree');
|
||||||
|
|
||||||
|
|
||||||
|
function mapProperty(shapes, prop) {
|
||||||
|
return map(shapes, function(shape) {
|
||||||
|
return shape[prop];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function expectCollection(collA, collB, contains) {
|
||||||
|
expect(collA).to.have.length(collB.length);
|
||||||
|
|
||||||
|
forEach(collB, function(element) {
|
||||||
|
if (!element.parent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contains) {
|
||||||
|
expect(collA).to.contain(element);
|
||||||
|
} else {
|
||||||
|
expect(collA).to.not.contain(element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('features/copy-paste', function() {
|
||||||
|
|
||||||
|
var testModules = [ bpmnCopyPasteModule, copyPasteModule, modelingModule, coreModule ];
|
||||||
|
|
||||||
|
var basicXML = require('../../../fixtures/bpmn/features/copy-paste/basic.bpmn'),
|
||||||
|
collaborationXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration.bpmn'),
|
||||||
|
collaborationMultipleXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn');
|
||||||
|
|
||||||
|
|
||||||
|
var integrationTest = function(ids) {
|
||||||
|
return function(canvas, elementRegistry, modeling, copyPaste, commandStack) {
|
||||||
|
// given
|
||||||
|
var shapes = elementRegistry.getAll(),
|
||||||
|
rootElement;
|
||||||
|
|
||||||
|
var initialContext = {
|
||||||
|
type: mapProperty(shapes, 'type'),
|
||||||
|
ids: mapProperty(shapes, 'id'),
|
||||||
|
length: shapes.length
|
||||||
|
},
|
||||||
|
currentContext;
|
||||||
|
|
||||||
|
var elements = map(ids, function(id) {
|
||||||
|
return elementRegistry.get(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
copyPaste.copy(elements);
|
||||||
|
|
||||||
|
modeling.removeElements(elements);
|
||||||
|
|
||||||
|
rootElement = canvas.getRootElement();
|
||||||
|
|
||||||
|
copyPaste.paste({
|
||||||
|
element: rootElement,
|
||||||
|
point: {
|
||||||
|
x: 1100,
|
||||||
|
y: 250
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
elements = elementRegistry.getAll();
|
||||||
|
|
||||||
|
// remove root
|
||||||
|
elements = elementRegistry.filter(function(element) {
|
||||||
|
return !!element.parent;
|
||||||
|
});
|
||||||
|
|
||||||
|
modeling.moveElements(elements, { x: 50, y: -50 });
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
commandStack.undo();
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
currentContext = {
|
||||||
|
type: mapProperty(shapes, 'type'),
|
||||||
|
ids: mapProperty(shapes, 'id'),
|
||||||
|
length: shapes.length
|
||||||
|
};
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(initialContext).to.have.length(currentContext.length);
|
||||||
|
|
||||||
|
expectCollection(initialContext.ids, currentContext.ids, true);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.redo();
|
||||||
|
commandStack.redo();
|
||||||
|
commandStack.redo();
|
||||||
|
|
||||||
|
currentContext = {
|
||||||
|
type: mapProperty(elementRegistry.getAll(), 'type'),
|
||||||
|
ids: mapProperty(elementRegistry.getAll(), 'id'),
|
||||||
|
length: shapes.length
|
||||||
|
};
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(initialContext).to.have.length(currentContext.length);
|
||||||
|
|
||||||
|
expectCollection(initialContext.type, currentContext.type, true);
|
||||||
|
expectCollection(initialContext.ids, currentContext.ids, false);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('basic diagram', function() {
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(basicXML, { modules: testModules }));
|
||||||
|
|
||||||
|
describe('copy', function() {
|
||||||
|
|
||||||
|
it('selected elements', inject(function(elementRegistry, copyPaste) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcess, startEvent, boundaryEvent, textAnnotation, conditionalFlow, defaultFlow,
|
||||||
|
tree;
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy(elementRegistry.get('SubProcess_1kd6ist'));
|
||||||
|
|
||||||
|
tree = new DescriptorTree(copyPaste._tree);
|
||||||
|
|
||||||
|
startEvent = tree.getElement('StartEvent_1');
|
||||||
|
boundaryEvent = tree.getElement('BoundaryEvent_1c94bi9');
|
||||||
|
subProcess = tree.getElement('SubProcess_1kd6ist');
|
||||||
|
textAnnotation = tree.getElement('TextAnnotation_0h1hhgg');
|
||||||
|
conditionalFlow = tree.getElement('SequenceFlow_07vo2r8');
|
||||||
|
defaultFlow = tree.getElement('Task_1fo63a7');
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(tree.getLength()).to.equal(3);
|
||||||
|
|
||||||
|
expect(tree.getDepthLength(0)).to.equal(1);
|
||||||
|
expect(tree.getDepthLength(1)).to.equal(3);
|
||||||
|
expect(tree.getDepthLength(2)).to.equal(15);
|
||||||
|
|
||||||
|
expect(subProcess.isExpanded).to.be.true;
|
||||||
|
expect(startEvent.name).to.equal('hello');
|
||||||
|
expect(textAnnotation.text).to.equal('foo');
|
||||||
|
expect(boundaryEvent.eventDefinitions).to.contain('bpmn:TimerEventDefinition');
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('integration', function() {
|
||||||
|
|
||||||
|
it('should retain label\'s relative position',
|
||||||
|
inject(function(modeling, copyPaste, canvas, elementRegistry) {
|
||||||
|
// given
|
||||||
|
var startEvent = elementRegistry.get('StartEvent_1'),
|
||||||
|
startEventLabel = startEvent.label,
|
||||||
|
seqFlow = elementRegistry.get('SequenceFlow_1rtr33r'),
|
||||||
|
seqFlowLabel = seqFlow.label,
|
||||||
|
task = elementRegistry.get('Task_1fo63a7'),
|
||||||
|
rootElement = canvas.getRootElement(),
|
||||||
|
newStrtEvt, newSeqFlow;
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy([ startEvent, task ]);
|
||||||
|
|
||||||
|
copyPaste.paste({
|
||||||
|
element: rootElement,
|
||||||
|
point: {
|
||||||
|
x: 1100,
|
||||||
|
y: 250
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newStrtEvt = elementRegistry.filter(function(element) {
|
||||||
|
return element.parent === rootElement && element.type === 'bpmn:StartEvent';
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
newSeqFlow = elementRegistry.filter(function(element) {
|
||||||
|
return element.parent === rootElement && element.type === 'bpmn:SequenceFlow';
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(newStrtEvt.label.x - newStrtEvt.x).to.equal(startEventLabel.x - startEvent.x);
|
||||||
|
expect(newStrtEvt.label.y - newStrtEvt.y).to.equal(startEventLabel.y - startEvent.y);
|
||||||
|
|
||||||
|
expect(newSeqFlow.label.x - newSeqFlow.waypoints[0].x).to.equal(seqFlowLabel.x - seqFlow.waypoints[0].x);
|
||||||
|
expect(newSeqFlow.label.y - newSeqFlow.waypoints[0].y).to.equal(seqFlowLabel.y - seqFlow.waypoints[0].y);
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should retain default & conditional flow property',
|
||||||
|
inject(function(elementRegistry, copyPaste, canvas, modeling) {
|
||||||
|
// given
|
||||||
|
var subProcess = elementRegistry.get('SubProcess_1kd6ist'),
|
||||||
|
rootElement = canvas.getRootElement(),
|
||||||
|
task, defaultFlow, conditionalFlow;
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy(subProcess);
|
||||||
|
|
||||||
|
modeling.removeElements([ subProcess ]);
|
||||||
|
|
||||||
|
copyPaste.paste({
|
||||||
|
element: rootElement,
|
||||||
|
point: {
|
||||||
|
x: 1100,
|
||||||
|
y: 250
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
task = elementRegistry.filter(function(element) {
|
||||||
|
return element.type === 'bpmn:Task';
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
defaultFlow = elementRegistry.filter(function(element) {
|
||||||
|
return !!(element.type === 'bpmn:SequenceFlow' && task.businessObject.default.id === element.id);
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
conditionalFlow = elementRegistry.filter(function(element) {
|
||||||
|
return !!(element.type === 'bpmn:SequenceFlow' && element.businessObject.conditionExpression);
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
expect(defaultFlow).to.exist;
|
||||||
|
expect(conditionalFlow).to.exist;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should retain loop characteristics',
|
||||||
|
inject(function(elementRegistry, copyPaste, canvas, modeling) {
|
||||||
|
// given
|
||||||
|
var subProcess = elementRegistry.get('SubProcess_0gev7mx'),
|
||||||
|
rootElement = canvas.getRootElement(),
|
||||||
|
loopCharacteristics;
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy(subProcess);
|
||||||
|
|
||||||
|
modeling.removeElements([ subProcess ]);
|
||||||
|
|
||||||
|
copyPaste.paste({
|
||||||
|
element: rootElement,
|
||||||
|
point: {
|
||||||
|
x: 1100,
|
||||||
|
y: 250
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
subProcess = elementRegistry.filter(function(element) {
|
||||||
|
return !!(element.id !== 'SubProcess_1kd6ist' && element.type === 'bpmn:SubProcess');
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
loopCharacteristics = subProcess.businessObject.loopCharacteristics;
|
||||||
|
|
||||||
|
expect(loopCharacteristics.$type).to.equal('bpmn:MultiInstanceLoopCharacteristics');
|
||||||
|
expect(loopCharacteristics.isSequential).to.be.true;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('selected elements', inject(integrationTest([ 'SubProcess_1kd6ist' ])));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('rules', function() {
|
||||||
|
|
||||||
|
it('disallow individual boundary events copying', inject(function(copyPaste, elementRegistry, canvas) {
|
||||||
|
|
||||||
|
var boundaryEventA = elementRegistry.get('BoundaryEvent_1404oxd'),
|
||||||
|
boundaryEventB = elementRegistry.get('BoundaryEvent_1c94bi9'),
|
||||||
|
tree;
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy([ boundaryEventA, boundaryEventB ]);
|
||||||
|
|
||||||
|
tree = new DescriptorTree(copyPaste._tree);
|
||||||
|
|
||||||
|
expect(tree.getLength()).to.equal(0);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('basic collaboration', function() {
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(collaborationXML, { modules: testModules }));
|
||||||
|
|
||||||
|
describe('integration', function() {
|
||||||
|
|
||||||
|
it('participant with including lanes + elements', inject(integrationTest([ 'Participant_0uu1rvj' ])));
|
||||||
|
|
||||||
|
it('collapsed pool', inject(integrationTest([ 'Participant_145muai' ])));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('rules', function () {
|
||||||
|
|
||||||
|
it('disallow individual lanes copying', inject(function(copyPaste, elementRegistry, canvas) {
|
||||||
|
|
||||||
|
var laneA = elementRegistry.get('Lane_13h648l'),
|
||||||
|
laneB = elementRegistry.get('Lane_1gl63sa'),
|
||||||
|
tree;
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy([ laneA, laneB ]);
|
||||||
|
|
||||||
|
tree = new DescriptorTree(copyPaste._tree);
|
||||||
|
|
||||||
|
expect(tree.getLength()).to.equal(0);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('complex collaboration', function() {
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(collaborationMultipleXML, { modules: testModules }));
|
||||||
|
|
||||||
|
describe('integration', function() {
|
||||||
|
|
||||||
|
it('multiple participants', inject(integrationTest([ 'Participant_0pgdgt4', 'Participant_1id96b4' ])));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,58 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var forEach = require('lodash/collection/forEach');
|
||||||
|
|
||||||
|
|
||||||
|
function DescriptorTree(tree) {
|
||||||
|
|
||||||
|
this._tree = {};
|
||||||
|
this._length = 0;
|
||||||
|
|
||||||
|
forEach(tree, function(branch, depth) {
|
||||||
|
if (branch.length) {
|
||||||
|
this._length += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
forEach(branch, function(element) {
|
||||||
|
|
||||||
|
element.depth = parseInt(depth, 10);
|
||||||
|
|
||||||
|
this._tree[element.id] = element;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = DescriptorTree;
|
||||||
|
|
||||||
|
DescriptorTree.prototype.getLength = function() {
|
||||||
|
return this._length;
|
||||||
|
};
|
||||||
|
|
||||||
|
DescriptorTree.prototype.getElement = function(id) {
|
||||||
|
return this._tree[id];
|
||||||
|
};
|
||||||
|
|
||||||
|
DescriptorTree.prototype.getDepth = function(depth) {
|
||||||
|
var newTree = {};
|
||||||
|
|
||||||
|
forEach(this._tree, function(element) {
|
||||||
|
if (element.depth === depth) {
|
||||||
|
newTree[element.id] = element;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return newTree;
|
||||||
|
};
|
||||||
|
|
||||||
|
DescriptorTree.prototype.getDepthLength = function(depth) {
|
||||||
|
var length = 0;
|
||||||
|
|
||||||
|
forEach(this._tree, function(element) {
|
||||||
|
if (element.depth === depth) {
|
||||||
|
length += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return length;
|
||||||
|
};
|
|
@ -46,7 +46,7 @@ describe('features - keyboard', function() {
|
||||||
|
|
||||||
it('should include triggers inside editorActions', inject(function(editorActions) {
|
it('should include triggers inside editorActions', inject(function(editorActions) {
|
||||||
// then
|
// then
|
||||||
expect(editorActions.length()).to.equal(13);
|
expect(editorActions.length()).to.equal(15);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue