Use case is to scale the content of elements (event, gateways) based
* on the element bounding box's size.
*
*
Why not transform
*
Scaling a path with transform() will also scale the stroke and IE does not support
* the option 'non-scaling-stroke' to prevent this.
* Also there are use cases where only some parts of a path should be
* scaled.
*
* @param {string} pathId The ID of the path.
* @param {Object} param
* Example param object scales the path to 60% size of the container (data.width, data.height).
*
Position is used to set the starting coordinate of the path. M is computed:
*
*
position.x * containerWidth
*
position.y * containerHeight
*
* Center of the container
position: {
* mx: 0.5,
* my: 0.5,
* }
* Upper left corner of the container
*
position: {
* mx: 0.0,
* my: 0.0,
* }
*
*
*
*
*/
this.getScaledPath = function getScaledPath(pathId, param) {
var rawPath = this.pathMap[pathId]; // positioning
// compute the start point of the path
var mx, my;
if (param.abspos) {
mx = param.abspos.x;
my = param.abspos.y;
} else {
mx = param.containerWidth * param.position.mx;
my = param.containerHeight * param.position.my;
}
var coordinates = {}; // map for the scaled coordinates
if (param.position) {
// path
var heightRatio = param.containerHeight / rawPath.height * param.yScaleFactor;
var widthRatio = param.containerWidth / rawPath.width * param.xScaleFactor; // Apply height ratio
for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
} // Apply width ratio
for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
}
} // Apply value to raw path
var path = format(rawPath.d, {
mx: mx,
my: my,
e: coordinates
});
return path;
};
} // helpers //////////////////////
// copied from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
var tokenRegex = /\{([^}]+)\}/g,
objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties
function replacer(all, key, obj) {
var res = obj;
key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
name = name || quotedName;
if (res) {
if (name in res) {
res = res[name];
}
typeof res == 'function' && isFunc && (res = res());
}
});
res = (res == null || res == obj ? all : res) + '';
return res;
}
function format(str, obj) {
return String(str).replace(tokenRegex, function (all, key) {
return replacer(all, key, obj);
});
}
},{}],22:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = TextRenderer;
var _minDash = require("min-dash");
var _Text = _interopRequireDefault(require("diagram-js/lib/util/Text"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var DEFAULT_FONT_SIZE = 12;
var LINE_HEIGHT_RATIO = 1.2;
var MIN_TEXT_ANNOTATION_HEIGHT = 30;
function TextRenderer(config) {
var defaultStyle = (0, _minDash.assign)({
fontFamily: 'Arial, sans-serif',
fontSize: DEFAULT_FONT_SIZE,
fontWeight: 'normal',
lineHeight: LINE_HEIGHT_RATIO
}, config && config.defaultStyle || {});
var fontSize = parseInt(defaultStyle.fontSize, 10) - 1;
var externalStyle = (0, _minDash.assign)({}, defaultStyle, {
fontSize: fontSize
}, config && config.externalStyle || {});
var textUtil = new _Text.default({
style: defaultStyle
});
/**
* Get the new bounds of an externally rendered,
* layouted label.
*
* @param {Bounds} bounds
* @param {string} text
*
* @return {Bounds}
*/
this.getExternalLabelBounds = function (bounds, text) {
var layoutedDimensions = textUtil.getDimensions(text, {
box: {
width: 90,
height: 30,
x: bounds.width / 2 + bounds.x,
y: bounds.height / 2 + bounds.y
},
style: externalStyle
}); // resize label shape to fit label text
return {
x: Math.round(bounds.x + bounds.width / 2 - layoutedDimensions.width / 2),
y: Math.round(bounds.y),
width: Math.ceil(layoutedDimensions.width),
height: Math.ceil(layoutedDimensions.height)
};
};
/**
* Get the new bounds of text annotation.
*
* @param {Bounds} bounds
* @param {string} text
*
* @return {Bounds}
*/
this.getTextAnnotationBounds = function (bounds, text) {
var layoutedDimensions = textUtil.getDimensions(text, {
box: bounds,
style: defaultStyle,
align: 'left-top',
padding: 5
});
return {
x: bounds.x,
y: bounds.y,
width: bounds.width,
height: Math.max(MIN_TEXT_ANNOTATION_HEIGHT, Math.round(layoutedDimensions.height))
};
};
/**
* Create a layouted text element.
*
* @param {string} text
* @param {Object} [options]
*
* @return {SVGElement} rendered text
*/
this.createText = function (text, options) {
return textUtil.createText(text, options || {});
};
/**
* Get default text style.
*/
this.getDefaultStyle = function () {
return defaultStyle;
};
/**
* Get the external text style.
*/
this.getExternalStyle = function () {
return externalStyle;
};
}
TextRenderer.$inject = ['config.textRenderer'];
},{"diagram-js/lib/util/Text":331,"min-dash":559}],23:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BpmnRenderer = _interopRequireDefault(require("./BpmnRenderer"));
var _TextRenderer = _interopRequireDefault(require("./TextRenderer"));
var _PathMap = _interopRequireDefault(require("./PathMap"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['bpmnRenderer'],
bpmnRenderer: ['type', _BpmnRenderer.default],
textRenderer: ['type', _TextRenderer.default],
pathMap: ['type', _PathMap.default]
};
exports.default = _default;
},{"./BpmnRenderer":20,"./PathMap":21,"./TextRenderer":22}],24:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AutoPlace;
var _BpmnAutoPlaceUtil = require("./BpmnAutoPlaceUtil");
/**
* BPMN auto-place behavior.
*
* @param {EventBus} eventBus
*/
function AutoPlace(eventBus) {
eventBus.on('autoPlace', function (context) {
var shape = context.shape,
source = context.source;
return (0, _BpmnAutoPlaceUtil.getNewShapePosition)(source, shape);
});
}
AutoPlace.$inject = ['eventBus'];
},{"./BpmnAutoPlaceUtil":25}],25:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getDataElementPosition = getDataElementPosition;
exports.getFlowNodePosition = getFlowNodePosition;
exports.getNewShapePosition = getNewShapePosition;
exports.getTextAnnotationPosition = getTextAnnotationPosition;
var _ModelUtil = require("../../util/ModelUtil");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _AutoPlaceUtil = require("diagram-js/lib/features/auto-place/AutoPlaceUtil");
/**
* Find the new position for the target element to
* connect to source.
*
* @param {djs.model.Shape} source
* @param {djs.model.Shape} element
*
* @return {Point}
*/
function getNewShapePosition(source, element) {
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
return getTextAnnotationPosition(source, element);
}
if ((0, _ModelingUtil.isAny)(element, ['bpmn:DataObjectReference', 'bpmn:DataStoreReference'])) {
return getDataElementPosition(source, element);
}
if ((0, _ModelUtil.is)(element, 'bpmn:FlowNode')) {
return getFlowNodePosition(source, element);
}
}
/**
* Always try to place element right of source;
* compute actual distance from previous nodes in flow.
*/
function getFlowNodePosition(source, element) {
var sourceTrbl = (0, _LayoutUtil.asTRBL)(source);
var sourceMid = (0, _LayoutUtil.getMid)(source);
var horizontalDistance = (0, _AutoPlaceUtil.getConnectedDistance)(source, {
filter: function (connection) {
return (0, _ModelUtil.is)(connection, 'bpmn:SequenceFlow');
}
});
var margin = 30,
minDistance = 80,
orientation = 'left';
if ((0, _ModelUtil.is)(source, 'bpmn:BoundaryEvent')) {
orientation = (0, _LayoutUtil.getOrientation)(source, source.host, -25);
if (orientation.indexOf('top') !== -1) {
margin *= -1;
}
}
var position = {
x: sourceTrbl.right + horizontalDistance + element.width / 2,
y: sourceMid.y + getVerticalDistance(orientation, minDistance)
};
var nextPositionDirection = {
y: {
margin: margin,
minDistance: minDistance
}
};
return (0, _AutoPlaceUtil.findFreePosition)(source, element, position, (0, _AutoPlaceUtil.generateGetNextPosition)(nextPositionDirection));
}
function getVerticalDistance(orientation, minDistance) {
if (orientation.indexOf('top') != -1) {
return -1 * minDistance;
} else if (orientation.indexOf('bottom') != -1) {
return minDistance;
} else {
return 0;
}
}
/**
* Always try to place text annotations top right of source.
*/
function getTextAnnotationPosition(source, element) {
var sourceTrbl = (0, _LayoutUtil.asTRBL)(source);
var position = {
x: sourceTrbl.right + element.width / 2,
y: sourceTrbl.top - 50 - element.height / 2
};
var nextPositionDirection = {
y: {
margin: -30,
minDistance: 20
}
};
return (0, _AutoPlaceUtil.findFreePosition)(source, element, position, (0, _AutoPlaceUtil.generateGetNextPosition)(nextPositionDirection));
}
/**
* Always put element bottom right of source.
*/
function getDataElementPosition(source, element) {
var sourceTrbl = (0, _LayoutUtil.asTRBL)(source);
var position = {
x: sourceTrbl.right - 10 + element.width / 2,
y: sourceTrbl.bottom + 40 + element.width / 2
};
var nextPositionDirection = {
x: {
margin: 30,
minDistance: 30
}
};
return (0, _AutoPlaceUtil.findFreePosition)(source, element, position, (0, _AutoPlaceUtil.generateGetNextPosition)(nextPositionDirection));
}
},{"../../util/ModelUtil":142,"../modeling/util/ModelingUtil":113,"diagram-js/lib/features/auto-place/AutoPlaceUtil":165,"diagram-js/lib/layout/LayoutUtil":302}],26:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _autoPlace = _interopRequireDefault(require("diagram-js/lib/features/auto-place"));
var _BpmnAutoPlace = _interopRequireDefault(require("./BpmnAutoPlace"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_autoPlace.default],
__init__: ['bpmnAutoPlace'],
bpmnAutoPlace: ['type', _BpmnAutoPlace.default]
};
exports.default = _default;
},{"./BpmnAutoPlace":24,"diagram-js/lib/features/auto-place":166}],27:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnAutoResize;
var _AutoResize = _interopRequireDefault(require("diagram-js/lib/features/auto-resize/AutoResize"));
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Sub class of the AutoResize module which implements a BPMN
* specific resize function.
*/
function BpmnAutoResize(injector) {
injector.invoke(_AutoResize.default, this);
}
BpmnAutoResize.$inject = ['injector'];
(0, _inherits.default)(BpmnAutoResize, _AutoResize.default);
/**
* Resize shapes and lanes.
*
* @param {djs.model.Shape} target
* @param {Bounds} newBounds
* @param {Object} hints
*/
BpmnAutoResize.prototype.resize = function (target, newBounds, hints) {
if ((0, _ModelUtil.is)(target, 'bpmn:Participant')) {
this._modeling.resizeLane(target, newBounds, null, hints);
} else {
this._modeling.resizeShape(target, newBounds, null, hints);
}
};
},{"../../util/ModelUtil":142,"diagram-js/lib/features/auto-resize/AutoResize":167,"inherits":349}],28:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnAutoResizeProvider;
var _ModelUtil = require("../../util/ModelUtil");
var _inherits = _interopRequireDefault(require("inherits"));
var _minDash = require("min-dash");
var _AutoResizeProvider = _interopRequireDefault(require("diagram-js/lib/features/auto-resize/AutoResizeProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* This module is a provider for automatically resizing parent BPMN elements
*/
function BpmnAutoResizeProvider(eventBus, modeling) {
_AutoResizeProvider.default.call(this, eventBus);
this._modeling = modeling;
}
(0, _inherits.default)(BpmnAutoResizeProvider, _AutoResizeProvider.default);
BpmnAutoResizeProvider.$inject = ['eventBus', 'modeling'];
/**
* Check if the given target can be expanded
*
* @param {djs.model.Shape} target
*
* @return {boolean}
*/
BpmnAutoResizeProvider.prototype.canResize = function (elements, target) {
if (!(0, _ModelUtil.is)(target, 'bpmn:Participant') && !(0, _ModelUtil.is)(target, 'bpmn:Lane') && !(0, _ModelUtil.is)(target, 'bpmn:SubProcess')) {
return false;
}
var canResize = true;
(0, _minDash.forEach)(elements, function (element) {
if ((0, _ModelUtil.is)(element, 'bpmn:Lane') || element.labelTarget) {
canResize = false;
return;
}
});
return canResize;
};
},{"../../util/ModelUtil":142,"diagram-js/lib/features/auto-resize/AutoResizeProvider":168,"inherits":349,"min-dash":559}],29:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BpmnAutoResize = _interopRequireDefault(require("./BpmnAutoResize"));
var _BpmnAutoResizeProvider = _interopRequireDefault(require("./BpmnAutoResizeProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['bpmnAutoResize', 'bpmnAutoResizeProvider'],
bpmnAutoResize: ['type', _BpmnAutoResize.default],
bpmnAutoResizeProvider: ['type', _BpmnAutoResizeProvider.default]
};
exports.default = _default;
},{"./BpmnAutoResize":27,"./BpmnAutoResizeProvider":28}],30:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ContextPadProvider;
var _minDash = require("min-dash");
var _ModelUtil = require("../../util/ModelUtil");
var _DiUtil = require("../../util/DiUtil");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _LaneUtil = require("../modeling/util/LaneUtil");
var _Mouse = require("diagram-js/lib/util/Mouse");
/**
* A provider for BPMN 2.0 elements context pad
*/
function ContextPadProvider(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate) {
config = config || {};
contextPad.registerProvider(this);
this._contextPad = contextPad;
this._modeling = modeling;
this._elementFactory = elementFactory;
this._connect = connect;
this._create = create;
this._popupMenu = popupMenu;
this._canvas = canvas;
this._rules = rules;
this._translate = translate;
if (config.autoPlace !== false) {
this._autoPlace = injector.get('autoPlace', false);
}
eventBus.on('create.end', 250, function (event) {
var context = event.context,
shape = context.shape;
if (!(0, _Mouse.hasPrimaryModifier)(event) || !contextPad.isOpen(shape)) {
return;
}
var entries = contextPad.getEntries(shape);
if (entries.replace) {
entries.replace.action.click(event, shape);
}
});
}
ContextPadProvider.$inject = ['config.contextPad', 'injector', 'eventBus', 'contextPad', 'modeling', 'elementFactory', 'connect', 'create', 'popupMenu', 'canvas', 'rules', 'translate'];
ContextPadProvider.prototype.getContextPadEntries = function (element) {
var contextPad = this._contextPad,
modeling = this._modeling,
elementFactory = this._elementFactory,
connect = this._connect,
create = this._create,
popupMenu = this._popupMenu,
canvas = this._canvas,
rules = this._rules,
autoPlace = this._autoPlace,
translate = this._translate;
var actions = {};
if (element.type === 'label') {
return actions;
}
var businessObject = element.businessObject;
function startConnect(event, element) {
connect.start(event, element);
}
function removeElement(e) {
modeling.removeElements([element]);
}
function getReplaceMenuPosition(element) {
var Y_OFFSET = 5;
var diagramContainer = canvas.getContainer(),
pad = contextPad.getPad(element).html;
var diagramRect = diagramContainer.getBoundingClientRect(),
padRect = pad.getBoundingClientRect();
var top = padRect.top - diagramRect.top;
var left = padRect.left - diagramRect.left;
var pos = {
x: left,
y: top + padRect.height + Y_OFFSET
};
return pos;
}
/**
* Create an append action
*
* @param {string} type
* @param {string} className
* @param {string} [title]
* @param {Object} [options]
*
* @return {Object} descriptor
*/
function appendAction(type, className, title, options) {
if (typeof title !== 'string') {
options = title;
title = translate('Append {type}', {
type: type.replace(/^bpmn:/, '')
});
}
function appendStart(event, element) {
var shape = elementFactory.createShape((0, _minDash.assign)({
type: type
}, options));
create.start(event, shape, {
source: element
});
}
var append = autoPlace ? function (event, element) {
var shape = elementFactory.createShape((0, _minDash.assign)({
type: type
}, options));
autoPlace.append(element, shape);
} : appendStart;
return {
group: 'model',
className: className,
title: title,
action: {
dragstart: appendStart,
click: append
}
};
}
function splitLaneHandler(count) {
return function (event, element) {
// actual split
modeling.splitLane(element, count); // refresh context pad after split to
// get rid of split icons
contextPad.open(element, true);
};
}
if ((0, _ModelingUtil.isAny)(businessObject, ['bpmn:Lane', 'bpmn:Participant']) && (0, _DiUtil.isExpanded)(businessObject)) {
var childLanes = (0, _LaneUtil.getChildLanes)(element);
(0, _minDash.assign)(actions, {
'lane-insert-above': {
group: 'lane-insert-above',
className: 'bpmn-icon-lane-insert-above',
title: translate('Add Lane above'),
action: {
click: function (event, element) {
modeling.addLane(element, 'top');
}
}
}
});
if (childLanes.length < 2) {
if (element.height >= 120) {
(0, _minDash.assign)(actions, {
'lane-divide-two': {
group: 'lane-divide',
className: 'bpmn-icon-lane-divide-two',
title: translate('Divide into two Lanes'),
action: {
click: splitLaneHandler(2)
}
}
});
}
if (element.height >= 180) {
(0, _minDash.assign)(actions, {
'lane-divide-three': {
group: 'lane-divide',
className: 'bpmn-icon-lane-divide-three',
title: translate('Divide into three Lanes'),
action: {
click: splitLaneHandler(3)
}
}
});
}
}
(0, _minDash.assign)(actions, {
'lane-insert-below': {
group: 'lane-insert-below',
className: 'bpmn-icon-lane-insert-below',
title: translate('Add Lane below'),
action: {
click: function (event, element) {
modeling.addLane(element, 'bottom');
}
}
}
});
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:FlowNode')) {
if ((0, _ModelUtil.is)(businessObject, 'bpmn:EventBasedGateway')) {
(0, _minDash.assign)(actions, {
'append.receive-task': appendAction('bpmn:ReceiveTask', 'bpmn-icon-receive-task', translate('Append ReceiveTask')),
'append.message-intermediate-event': appendAction('bpmn:IntermediateCatchEvent', 'bpmn-icon-intermediate-event-catch-message', translate('Append MessageIntermediateCatchEvent'), {
eventDefinitionType: 'bpmn:MessageEventDefinition'
}),
'append.timer-intermediate-event': appendAction('bpmn:IntermediateCatchEvent', 'bpmn-icon-intermediate-event-catch-timer', translate('Append TimerIntermediateCatchEvent'), {
eventDefinitionType: 'bpmn:TimerEventDefinition'
}),
'append.condition-intermediate-event': appendAction('bpmn:IntermediateCatchEvent', 'bpmn-icon-intermediate-event-catch-condition', translate('Append ConditionIntermediateCatchEvent'), {
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
}),
'append.signal-intermediate-event': appendAction('bpmn:IntermediateCatchEvent', 'bpmn-icon-intermediate-event-catch-signal', translate('Append SignalIntermediateCatchEvent'), {
eventDefinitionType: 'bpmn:SignalEventDefinition'
})
});
} else if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
(0, _minDash.assign)(actions, {
'append.compensation-activity': appendAction('bpmn:Task', 'bpmn-icon-task', translate('Append compensation activity'), {
isForCompensation: true
})
});
} else if (!(0, _ModelUtil.is)(businessObject, 'bpmn:EndEvent') && !businessObject.isForCompensation && !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') && !(0, _DiUtil.isEventSubProcess)(businessObject)) {
(0, _minDash.assign)(actions, {
'append.end-event': appendAction('bpmn:EndEvent', 'bpmn-icon-end-event-none', translate('Append EndEvent')),
'append.gateway': appendAction('bpmn:ExclusiveGateway', 'bpmn-icon-gateway-none', translate('Append Gateway')),
'append.append-task': appendAction('bpmn:Task', 'bpmn-icon-task', translate('Append Task')),
'append.intermediate-event': appendAction('bpmn:IntermediateThrowEvent', 'bpmn-icon-intermediate-event-none', translate('Append Intermediate/Boundary Event'))
});
}
}
if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
// Replace menu entry
(0, _minDash.assign)(actions, {
'replace': {
group: 'edit',
className: 'bpmn-icon-screw-wrench',
title: translate('Change type'),
action: {
click: function (event, element) {
var position = (0, _minDash.assign)(getReplaceMenuPosition(element), {
cursor: {
x: event.x,
y: event.y
}
});
popupMenu.open(element, 'bpmn-replace', position);
}
}
}
});
}
if ((0, _ModelingUtil.isAny)(businessObject, ['bpmn:FlowNode', 'bpmn:InteractionNode', 'bpmn:DataObjectReference', 'bpmn:DataStoreReference'])) {
(0, _minDash.assign)(actions, {
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation'),
'connect': {
group: 'connect',
className: 'bpmn-icon-connection-multi',
title: translate('Connect using ' + (businessObject.isForCompensation ? '' : 'Sequence/MessageFlow or ') + 'Association'),
action: {
click: startConnect,
dragstart: startConnect
}
}
});
}
if ((0, _ModelingUtil.isAny)(businessObject, ['bpmn:DataObjectReference', 'bpmn:DataStoreReference'])) {
(0, _minDash.assign)(actions, {
'connect': {
group: 'connect',
className: 'bpmn-icon-connection-multi',
title: translate('Connect using DataInputAssociation'),
action: {
click: startConnect,
dragstart: startConnect
}
}
});
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Group')) {
(0, _minDash.assign)(actions, {
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation')
});
} // delete element entry, only show if allowed by rules
var deleteAllowed = rules.allowed('elements.delete', {
elements: [element]
});
if ((0, _minDash.isArray)(deleteAllowed)) {
// was the element returned as a deletion candidate?
deleteAllowed = deleteAllowed[0] === element;
}
if (deleteAllowed) {
(0, _minDash.assign)(actions, {
'delete': {
group: 'edit',
className: 'bpmn-icon-trash',
title: translate('Remove'),
action: {
click: removeElement
}
}
});
}
return actions;
}; // helpers /////////
function isEventType(eventBo, type, definition) {
var isType = eventBo.$instanceOf(type);
var isDefinition = false;
var definitions = eventBo.eventDefinitions || [];
(0, _minDash.forEach)(definitions, function (def) {
if (def.$type === definition) {
isDefinition = true;
}
});
return isType && isDefinition;
}
},{"../../util/DiUtil":140,"../../util/ModelUtil":142,"../modeling/util/LaneUtil":112,"../modeling/util/ModelingUtil":113,"diagram-js/lib/util/Mouse":325,"min-dash":559}],31:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _diagramJsDirectEditing = _interopRequireDefault(require("diagram-js-direct-editing"));
var _contextPad = _interopRequireDefault(require("diagram-js/lib/features/context-pad"));
var _selection = _interopRequireDefault(require("diagram-js/lib/features/selection"));
var _connect = _interopRequireDefault(require("diagram-js/lib/features/connect"));
var _create = _interopRequireDefault(require("diagram-js/lib/features/create"));
var _popupMenu = _interopRequireDefault(require("../popup-menu"));
var _ContextPadProvider = _interopRequireDefault(require("./ContextPadProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_diagramJsDirectEditing.default, _contextPad.default, _selection.default, _connect.default, _create.default, _popupMenu.default],
__init__: ['contextPadProvider'],
contextPadProvider: ['type', _ContextPadProvider.default]
};
exports.default = _default;
},{"../popup-menu":119,"./ContextPadProvider":30,"diagram-js-direct-editing":334,"diagram-js/lib/features/connect":184,"diagram-js/lib/features/context-pad":188,"diagram-js/lib/features/create":193,"diagram-js/lib/features/selection":280}],32:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnCopyPaste;
var _ModelUtil = require("../../util/ModelUtil");
var _minDash = require("min-dash");
function copyProperties(source, target, properties) {
if (!(0, _minDash.isArray)(properties)) {
properties = [properties];
}
(0, _minDash.forEach)(properties, function (property) {
if (!(0, _minDash.isUndefined)(source[property])) {
target[property] = source[property];
}
});
}
function removeProperties(element, properties) {
if (!(0, _minDash.isArray)(properties)) {
properties = [properties];
}
(0, _minDash.forEach)(properties, function (property) {
if (element[property]) {
delete element[property];
}
});
}
var LOW_PRIORITY = 750;
function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
eventBus.on('copyPaste.copyElement', LOW_PRIORITY, function (context) {
var descriptor = context.descriptor,
element = context.element;
var businessObject = descriptor.oldBusinessObject = (0, _ModelUtil.getBusinessObject)(element);
descriptor.type = element.type;
copyProperties(businessObject, descriptor, 'name');
descriptor.di = {}; // fill and stroke will be set to DI
copyProperties(businessObject.di, descriptor.di, ['fill', 'stroke']);
copyProperties(businessObject.di, descriptor, 'isExpanded');
if (isLabel(descriptor)) {
return descriptor;
} // default sequence flow
if (businessObject.default) {
descriptor.default = businessObject.default.id;
}
});
eventBus.on('moddleCopy.canCopyProperty', function (context) {
var parent = context.parent,
property = context.property,
propertyName = context.propertyName,
bpmnProcess;
if (propertyName === 'processRef' && (0, _ModelUtil.is)(parent, 'bpmn:Participant') && (0, _ModelUtil.is)(property, 'bpmn:Process')) {
bpmnProcess = bpmnFactory.create('bpmn:Process'); // return copy of process
return moddleCopy.copyElement(property, bpmnProcess);
}
});
var references;
function resolveReferences(descriptor, cache) {
var businessObject = (0, _ModelUtil.getBusinessObject)(descriptor); // default sequence flows
if (descriptor.default) {
// relationship cannot be resolved immediately
references[descriptor.default] = {
element: businessObject,
property: 'default'
};
} // boundary events
if (descriptor.host) {
// relationship can be resolved immediately
(0, _ModelUtil.getBusinessObject)(descriptor).attachedToRef = (0, _ModelUtil.getBusinessObject)(cache[descriptor.host]);
}
references = (0, _minDash.omit)(references, (0, _minDash.reduce)(references, function (array, reference, key) {
var element = reference.element,
property = reference.property;
if (key === descriptor.id) {
element[property] = businessObject;
array.push(descriptor.id);
}
return array;
}, []));
}
eventBus.on('copyPaste.pasteElements', function () {
references = {};
});
eventBus.on('copyPaste.pasteElement', function (context) {
var cache = context.cache,
descriptor = context.descriptor,
oldBusinessObject = descriptor.oldBusinessObject,
newBusinessObject; // do NOT copy business object if external label
if (isLabel(descriptor)) {
descriptor.businessObject = (0, _ModelUtil.getBusinessObject)(cache[descriptor.labelTarget]);
return;
}
newBusinessObject = bpmnFactory.create(oldBusinessObject.$type);
descriptor.businessObject = moddleCopy.copyElement(oldBusinessObject, newBusinessObject); // resolve references e.g. default sequence flow
resolveReferences(descriptor, cache);
copyProperties(descriptor, newBusinessObject, ['isExpanded', 'name']);
removeProperties(descriptor, 'oldBusinessObject');
});
}
BpmnCopyPaste.$inject = ['bpmnFactory', 'eventBus', 'moddleCopy']; // helpers //////////
function isLabel(element) {
return !!element.labelTarget;
}
},{"../../util/ModelUtil":142,"min-dash":559}],33:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ModdleCopy;
exports.getPropertyNames = getPropertyNames;
var _minDash = require("min-dash");
var DISALLOWED_PROPERTIES = ['artifacts', 'dataInputAssociations', 'dataOutputAssociations', 'default', 'flowElements', 'lanes', 'incoming', 'outgoing'];
/**
* @typedef {Function} listener
*
* @param {Object} context
* @param {Array} context.propertyNames
* @param {ModdleElement} context.sourceElement
* @param {ModdleElement} context.targetElement
*
* @returns {Array|boolean} - Return properties to be copied or false to disallow
* copying.
*/
/**
* @typedef {Function} listener
*
* @param {Object} context
* @param {ModdleElement} context.parent
* @param {*} context.property
* @param {string} context.propertyName
*
* @returns {*|boolean} - Return copied property or false to disallow
* copying.
*/
/**
* @typedef {Function} listener
*
* @param {Object} context
* @param {ModdleElement} context.parent
* @param {*} context.property
* @param {string} context.propertyName
*
* @returns {boolean} - Return false to disallow
* setting copied property.
*/
/**
* Utility for copying model properties from source element to target element.
*
* @param {EventBus} eventBus
* @param {BpmnFactory} bpmnFactory
* @param {BpmnModdle} moddle
*/
function ModdleCopy(eventBus, bpmnFactory, moddle) {
this._bpmnFactory = bpmnFactory;
this._eventBus = eventBus;
this._moddle = moddle; // copy extension elements last
eventBus.on('moddleCopy.canCopyProperties', function (context) {
var propertyNames = context.propertyNames;
if (!propertyNames || !propertyNames.length) {
return;
}
return (0, _minDash.sortBy)(propertyNames, function (propertyName) {
return propertyName === 'extensionElements';
});
}); // default check whether property can be copied
eventBus.on('moddleCopy.canCopyProperty', function (context) {
var parent = context.parent,
parentDescriptor = (0, _minDash.isObject)(parent) && parent.$descriptor,
propertyName = context.propertyName;
if (propertyName && DISALLOWED_PROPERTIES.indexOf(propertyName) !== -1) {
// disallow copying property
return false;
}
if (propertyName && parentDescriptor && !(0, _minDash.find)(parentDescriptor.properties, (0, _minDash.matchPattern)({
name: propertyName
}))) {
// disallow copying property
return false;
}
}); // do NOT allow to copy empty extension elements
eventBus.on('moddleCopy.canSetCopiedProperty', function (context) {
var property = context.property;
if (is(property, 'bpmn:ExtensionElements') && (!property.values || !property.values.length)) {
// disallow setting copied property
return false;
}
});
}
ModdleCopy.$inject = ['eventBus', 'bpmnFactory', 'moddle'];
/**
* Copy model properties of source element to target element.
*
* @param {ModdleElement} sourceElement
* @param {ModdleElement} targetElement
* @param {Array} [propertyNames]
*
* @param {ModdleElement}
*/
ModdleCopy.prototype.copyElement = function (sourceElement, targetElement, propertyNames) {
var self = this;
if (propertyNames && !(0, _minDash.isArray)(propertyNames)) {
propertyNames = [propertyNames];
}
propertyNames = propertyNames || getPropertyNames(sourceElement.$descriptor);
var canCopyProperties = this._eventBus.fire('moddleCopy.canCopyProperties', {
propertyNames: propertyNames,
sourceElement: sourceElement,
targetElement: targetElement
});
if (canCopyProperties === false) {
return targetElement;
}
if ((0, _minDash.isArray)(canCopyProperties)) {
propertyNames = canCopyProperties;
} // copy properties
(0, _minDash.forEach)(propertyNames, function (propertyName) {
var sourceProperty;
if ((0, _minDash.has)(sourceElement, propertyName)) {
sourceProperty = sourceElement.get(propertyName);
}
var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName);
var canSetProperty = self._eventBus.fire('moddleCopy.canSetCopiedProperty', {
parent: targetElement,
property: copiedProperty,
propertyName: propertyName
});
if (canSetProperty === false) {
return;
}
if ((0, _minDash.isDefined)(copiedProperty)) {
targetElement.set(propertyName, copiedProperty);
}
});
return targetElement;
};
/**
* Copy model property.
*
* @param {*} property
* @param {ModdleElement} parent
* @param {string} propertyName
*
* @returns {*}
*/
ModdleCopy.prototype.copyProperty = function (property, parent, propertyName) {
var self = this; // allow others to copy property
var copiedProperty = this._eventBus.fire('moddleCopy.canCopyProperty', {
parent: parent,
property: property,
propertyName: propertyName
}); // return if copying is NOT allowed
if (copiedProperty === false) {
return;
}
if (copiedProperty) {
if ((0, _minDash.isObject)(copiedProperty) && copiedProperty.$type && !copiedProperty.$parent) {
copiedProperty.$parent = parent;
}
return copiedProperty;
}
var propertyDescriptor = this._moddle.getPropertyDescriptor(parent, propertyName); // do NOT copy Ids and references
if (propertyDescriptor.isId || propertyDescriptor.isReference) {
return;
} // copy arrays
if ((0, _minDash.isArray)(property)) {
return (0, _minDash.reduce)(property, function (childProperties, childProperty) {
// recursion
copiedProperty = self.copyProperty(childProperty, parent, propertyName); // copying might NOT be allowed
if (copiedProperty) {
copiedProperty.$parent = parent;
return childProperties.concat(copiedProperty);
}
return childProperties;
}, []);
} // copy model elements
if ((0, _minDash.isObject)(property) && property.$type) {
if (this._moddle.getElementDescriptor(property).isGeneric) {
return;
}
copiedProperty = self._bpmnFactory.create(property.$type);
copiedProperty.$parent = parent; // recursion
copiedProperty = self.copyElement(property, copiedProperty);
return copiedProperty;
} // copy primitive properties
return property;
}; // helpers //////////
function getPropertyNames(descriptor, keepDefaultProperties) {
return (0, _minDash.reduce)(descriptor.properties, function (properties, property) {
if (keepDefaultProperties && property.default) {
return properties;
}
return properties.concat(property.name);
}, []);
}
function is(element, type) {
return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type);
}
},{"min-dash":559}],34:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _copyPaste = _interopRequireDefault(require("diagram-js/lib/features/copy-paste"));
var _BpmnCopyPaste = _interopRequireDefault(require("./BpmnCopyPaste"));
var _ModdleCopy = _interopRequireDefault(require("./ModdleCopy"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_copyPaste.default],
__init__: ['bpmnCopyPaste', 'moddleCopy'],
bpmnCopyPaste: ['type', _BpmnCopyPaste.default],
moddleCopy: ['type', _ModdleCopy.default]
};
exports.default = _default;
},{"./BpmnCopyPaste":32,"./ModdleCopy":33,"diagram-js/lib/features/copy-paste":190}],35:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnDiOrdering;
var _BpmnRenderUtil = require("../../draw/BpmnRenderUtil");
var _ModelUtil = require("../../util/ModelUtil");
var _minDash = require("min-dash");
var _Elements = require("diagram-js/lib/util/Elements");
var HIGH_PRIORITY = 2000;
function BpmnDiOrdering(eventBus, canvas) {
eventBus.on('saveXML.start', HIGH_PRIORITY, orderDi);
function orderDi() {
var root = canvas.getRootElement(),
rootDi = (0, _ModelUtil.getBusinessObject)(root).di,
elements,
diElements;
elements = (0, _Elements.selfAndAllChildren)([root], false); // only bpmndi:Shape and bpmndi:Edge can be direct children of bpmndi:Plane
elements = (0, _minDash.filter)(elements, function (element) {
return element !== root && !element.labelTarget;
});
diElements = (0, _minDash.map)(elements, _BpmnRenderUtil.getDi);
rootDi.set('planeElement', diElements);
}
}
BpmnDiOrdering.$inject = ['eventBus', 'canvas'];
},{"../../draw/BpmnRenderUtil":19,"../../util/ModelUtil":142,"diagram-js/lib/util/Elements":317,"min-dash":559}],36:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BpmnDiOrdering = _interopRequireDefault(require("../di-ordering/BpmnDiOrdering"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['bpmnDiOrdering'],
bpmnDiOrdering: ['type', _BpmnDiOrdering.default]
};
exports.default = _default;
},{"../di-ordering/BpmnDiOrdering":35}],37:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnDistributeElements;
var _minDash = require("min-dash");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
/**
* Registers element exclude filters for elements that
* currently do not support distribution.
*/
function BpmnDistributeElements(distributeElements) {
distributeElements.registerFilter(function (elements) {
return (0, _minDash.filter)(elements, function (element) {
var cannotDistribute = (0, _ModelingUtil.isAny)(element, ['bpmn:Association', 'bpmn:BoundaryEvent', 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation', 'bpmn:Lane', 'bpmn:MessageFlow', 'bpmn:Participant', 'bpmn:SequenceFlow', 'bpmn:TextAnnotation']);
return !(element.labelTarget || cannotDistribute);
});
});
}
BpmnDistributeElements.$inject = ['distributeElements'];
},{"../modeling/util/ModelingUtil":113,"min-dash":559}],38:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _distributeElements = _interopRequireDefault(require("diagram-js/lib/features/distribute-elements"));
var _BpmnDistributeElements = _interopRequireDefault(require("./BpmnDistributeElements"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_distributeElements.default],
__init__: ['bpmnDistributeElements'],
bpmnDistributeElements: ['type', _BpmnDistributeElements.default]
};
exports.default = _default;
},{"./BpmnDistributeElements":37,"diagram-js/lib/features/distribute-elements":195}],39:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnEditorActions;
var _inherits = _interopRequireDefault(require("inherits"));
var _EditorActions = _interopRequireDefault(require("diagram-js/lib/features/editor-actions/EditorActions"));
var _minDash = require("min-dash");
var _ModelUtil = require("../../util/ModelUtil");
var _Elements = require("diagram-js/lib/util/Elements");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Registers and executes BPMN specific editor actions.
*
* @param {Injector} injector
*/
function BpmnEditorActions(injector) {
injector.invoke(_EditorActions.default, this);
}
(0, _inherits.default)(BpmnEditorActions, _EditorActions.default);
BpmnEditorActions.$inject = ['injector'];
/**
* Register default actions.
*
* @param {Injector} injector
*/
BpmnEditorActions.prototype._registerDefaultActions = function (injector) {
// (0) invoke super method
_EditorActions.default.prototype._registerDefaultActions.call(this, injector); // (1) retrieve optional components to integrate with
var canvas = injector.get('canvas', false);
var elementRegistry = injector.get('elementRegistry', false);
var selection = injector.get('selection', false);
var spaceTool = injector.get('spaceTool', false);
var lassoTool = injector.get('lassoTool', false);
var handTool = injector.get('handTool', false);
var globalConnect = injector.get('globalConnect', false);
var distributeElements = injector.get('distributeElements', false);
var alignElements = injector.get('alignElements', false);
var directEditing = injector.get('directEditing', false);
var searchPad = injector.get('searchPad', false);
var modeling = injector.get('modeling', false); // (2) check components and register actions
if (canvas && elementRegistry && selection) {
this._registerAction('selectElements', function () {
// select all elements except for the invisible
// root element
var rootElement = canvas.getRootElement();
var elements = elementRegistry.filter(function (element) {
return element !== rootElement;
});
selection.select(elements);
return elements;
});
}
if (spaceTool) {
this._registerAction('spaceTool', function () {
spaceTool.toggle();
});
}
if (lassoTool) {
this._registerAction('lassoTool', function () {
lassoTool.toggle();
});
}
if (handTool) {
this._registerAction('handTool', function () {
handTool.toggle();
});
}
if (globalConnect) {
this._registerAction('globalConnectTool', function () {
globalConnect.toggle();
});
}
if (selection && distributeElements) {
this._registerAction('distributeElements', function (opts) {
var currentSelection = selection.get(),
type = opts.type;
if (currentSelection.length) {
distributeElements.trigger(currentSelection, type);
}
});
}
if (selection && alignElements) {
this._registerAction('alignElements', function (opts) {
var currentSelection = selection.get(),
aligneableElements = [],
type = opts.type;
if (currentSelection.length) {
aligneableElements = (0, _minDash.filter)(currentSelection, function (element) {
return !(0, _ModelUtil.is)(element, 'bpmn:Lane');
});
alignElements.trigger(aligneableElements, type);
}
});
}
if (selection && modeling) {
this._registerAction('setColor', function (opts) {
var currentSelection = selection.get();
if (currentSelection.length) {
modeling.setColor(currentSelection, opts);
}
});
}
if (selection && directEditing) {
this._registerAction('directEditing', function () {
var currentSelection = selection.get();
if (currentSelection.length) {
directEditing.activate(currentSelection[0]);
}
});
}
if (searchPad) {
this._registerAction('find', function () {
searchPad.toggle();
});
}
if (canvas && modeling) {
this._registerAction('moveToOrigin', function () {
var rootElement = canvas.getRootElement(),
boundingBox,
elements;
if ((0, _ModelUtil.is)(rootElement, 'bpmn:Collaboration')) {
elements = elementRegistry.filter(function (element) {
return (0, _ModelUtil.is)(element.parent, 'bpmn:Collaboration');
});
} else {
elements = elementRegistry.filter(function (element) {
return element !== rootElement && !(0, _ModelUtil.is)(element.parent, 'bpmn:SubProcess');
});
}
boundingBox = (0, _Elements.getBBox)(elements);
modeling.moveElements(elements, {
x: -boundingBox.x,
y: -boundingBox.y
}, rootElement);
});
}
};
},{"../../util/ModelUtil":142,"diagram-js/lib/features/editor-actions/EditorActions":198,"diagram-js/lib/util/Elements":317,"inherits":349,"min-dash":559}],40:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _editorActions = _interopRequireDefault(require("diagram-js/lib/features/editor-actions"));
var _BpmnEditorActions = _interopRequireDefault(require("./BpmnEditorActions"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_editorActions.default],
editorActions: ['type', _BpmnEditorActions.default]
};
exports.default = _default;
},{"./BpmnEditorActions":39,"diagram-js/lib/features/editor-actions":199}],41:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnGridSnapping;
var _ModelingUtil = require("../modeling/util/ModelingUtil");
function BpmnGridSnapping(eventBus) {
eventBus.on(['create.init', 'shape.move.init'], function (event) {
var context = event.context,
shape = event.shape;
if ((0, _ModelingUtil.isAny)(shape, ['bpmn:Participant', 'bpmn:SubProcess', 'bpmn:TextAnnotation'])) {
if (!context.gridSnappingContext) {
context.gridSnappingContext = {};
}
context.gridSnappingContext.snapLocation = 'top-left';
}
});
}
BpmnGridSnapping.$inject = ['eventBus'];
},{"../modeling/util/ModelingUtil":113}],42:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AutoPlaceBehavior;
var _BpmnAutoPlaceUtil = require("../../auto-place/BpmnAutoPlaceUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _ModelUtil = require("../../../util/ModelUtil");
var HIGH_PRIORITY = 2000;
function AutoPlaceBehavior(eventBus, gridSnapping) {
eventBus.on('autoPlace', HIGH_PRIORITY, function (context) {
var source = context.source,
sourceMid = (0, _LayoutUtil.getMid)(source),
shape = context.shape;
var position = (0, _BpmnAutoPlaceUtil.getNewShapePosition)(source, shape);
['x', 'y'].forEach(function (axis) {
var options = {}; // do not snap if x/y equal
if (position[axis] === sourceMid[axis]) {
return;
}
if (position[axis] > sourceMid[axis]) {
options.min = position[axis];
} else {
options.max = position[axis];
}
if ((0, _ModelUtil.is)(shape, 'bpmn:TextAnnotation')) {
if (isHorizontal(axis)) {
options.offset = -shape.width / 2;
} else {
options.offset = -shape.height / 2;
}
}
position[axis] = gridSnapping.snapValue(position[axis], options);
}); // must be returned to be considered by auto place
return position;
});
}
AutoPlaceBehavior.$inject = ['eventBus', 'gridSnapping']; // helpers //////////
function isHorizontal(axis) {
return axis === 'x';
}
},{"../../../util/ModelUtil":142,"../../auto-place/BpmnAutoPlaceUtil":25,"diagram-js/lib/layout/LayoutUtil":302}],43:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CreateParticipantBehavior;
var _ModelUtil = require("../../../util/ModelUtil");
var HIGHER_PRIORITY = 1750;
function CreateParticipantBehavior(canvas, eventBus, gridSnapping) {
eventBus.on(['create.start', 'shape.move.start'], HIGHER_PRIORITY, function (event) {
var context = event.context,
shape = context.shape,
rootElement = canvas.getRootElement();
if (!(0, _ModelUtil.is)(shape, 'bpmn:Participant') || !(0, _ModelUtil.is)(rootElement, 'bpmn:Process') || !rootElement.children.length) {
return;
}
var createConstraints = context.createConstraints;
if (!createConstraints) {
return;
}
shape.width = gridSnapping.snapValue(shape.width, {
min: shape.width
});
shape.height = gridSnapping.snapValue(shape.height, {
min: shape.height
});
});
}
CreateParticipantBehavior.$inject = ['canvas', 'eventBus', 'gridSnapping'];
},{"../../../util/ModelUtil":142}],44:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = LayoutConnectionBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _Geometry = require("diagram-js/lib/util/Geometry");
var _minDash = require("min-dash");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var HIGH_PRIORITY = 3000;
/**
* Snaps connections with Manhattan layout.
*/
function LayoutConnectionBehavior(eventBus, gridSnapping, modeling) {
_CommandInterceptor.default.call(this, eventBus);
this._gridSnapping = gridSnapping;
var self = this;
this.postExecuted(['connection.create', 'connection.layout'], HIGH_PRIORITY, function (event) {
var context = event.context,
connection = context.connection,
hints = context.hints || {},
waypoints = connection.waypoints;
if (hints.connectionStart || hints.connectionEnd || hints.createElementsBehavior === false) {
return;
}
if (!hasMiddleSegments(waypoints)) {
return;
}
modeling.updateWaypoints(connection, self.snapMiddleSegments(waypoints));
});
}
LayoutConnectionBehavior.$inject = ['eventBus', 'gridSnapping', 'modeling'];
(0, _inherits.default)(LayoutConnectionBehavior, _CommandInterceptor.default);
/**
* Snap middle segments of a given connection.
*
* @param {Array} waypoints
*
* @returns {Array}
*/
LayoutConnectionBehavior.prototype.snapMiddleSegments = function (waypoints) {
var gridSnapping = this._gridSnapping,
snapped;
waypoints = waypoints.slice();
for (var i = 1; i < waypoints.length - 2; i++) {
snapped = snapSegment(gridSnapping, waypoints[i], waypoints[i + 1]);
waypoints[i] = snapped[0];
waypoints[i + 1] = snapped[1];
}
return waypoints;
}; // helpers //////////
/**
* Check whether a connection has a middle segments.
*
* @param {Array} waypoints
*
* @returns {boolean}
*/
function hasMiddleSegments(waypoints) {
return waypoints.length > 3;
}
/**
* Check whether an alignment is horizontal.
*
* @param {string} aligned
*
* @returns {boolean}
*/
function horizontallyAligned(aligned) {
return aligned === 'h';
}
/**
* Check whether an alignment is vertical.
*
* @param {string} aligned
*
* @returns {boolean}
*/
function verticallyAligned(aligned) {
return aligned === 'v';
}
/**
* Get middle segments from a given connection.
*
* @param {Array} waypoints
*
* @returns {Array}
*/
function snapSegment(gridSnapping, segmentStart, segmentEnd) {
var aligned = (0, _Geometry.pointsAligned)(segmentStart, segmentEnd);
var snapped = {};
if (horizontallyAligned(aligned)) {
// snap horizontally
snapped.y = gridSnapping.snapValue(segmentStart.y);
}
if (verticallyAligned(aligned)) {
// snap vertically
snapped.x = gridSnapping.snapValue(segmentStart.x);
}
if ('x' in snapped || 'y' in snapped) {
segmentStart = (0, _minDash.assign)({}, segmentStart, snapped);
segmentEnd = (0, _minDash.assign)({}, segmentEnd, snapped);
}
return [segmentStart, segmentEnd];
}
},{"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/util/Geometry":320,"inherits":349,"min-dash":559}],45:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _AutoPlaceBehavior = _interopRequireDefault(require("./AutoPlaceBehavior"));
var _CreateParticipantBehavior = _interopRequireDefault(require("./CreateParticipantBehavior"));
var _LayoutConnectionBehavior = _interopRequireDefault(require("./LayoutConnectionBehavior"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['gridSnappingAutoPlaceBehavior', 'gridSnappingCreateParticipantBehavior', 'gridSnappingLayoutConnectionBehavior'],
gridSnappingAutoPlaceBehavior: ['type', _AutoPlaceBehavior.default],
gridSnappingCreateParticipantBehavior: ['type', _CreateParticipantBehavior.default],
gridSnappingLayoutConnectionBehavior: ['type', _LayoutConnectionBehavior.default]
};
exports.default = _default;
},{"./AutoPlaceBehavior":42,"./CreateParticipantBehavior":43,"./LayoutConnectionBehavior":44}],46:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BpmnGridSnapping = _interopRequireDefault(require("./BpmnGridSnapping"));
var _gridSnapping = _interopRequireDefault(require("diagram-js/lib/features/grid-snapping"));
var _behavior = _interopRequireDefault(require("./behavior"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_gridSnapping.default, _behavior.default],
__init__: ['bpmnGridSnapping'],
bpmnGridSnapping: ['type', _BpmnGridSnapping.default]
};
exports.default = _default;
},{"./BpmnGridSnapping":41,"./behavior":45,"diagram-js/lib/features/grid-snapping":207}],47:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnInteractionEvents;
var _ModelUtil = require("../../util/ModelUtil");
var _DiUtil = require("../../util/DiUtil");
var LABEL_WIDTH = 30,
LABEL_HEIGHT = 30;
/**
* BPMN-specific hit zones and interaction fixes.
*
* @param {EventBus} eventBus
* @param {InteractionEvents} interactionEvents
*/
function BpmnInteractionEvents(eventBus, interactionEvents) {
this._interactionEvents = interactionEvents;
var self = this;
eventBus.on(['interactionEvents.createHit', 'interactionEvents.updateHit'], function (context) {
var element = context.element,
gfx = context.gfx;
if ((0, _ModelUtil.is)(element, 'bpmn:Lane')) {
return self.createParticipantHit(element, gfx);
} else if ((0, _ModelUtil.is)(element, 'bpmn:Participant')) {
if ((0, _DiUtil.isExpanded)(element)) {
return self.createParticipantHit(element, gfx);
} else {
return self.createDefaultHit(element, gfx);
}
} else if ((0, _ModelUtil.is)(element, 'bpmn:SubProcess')) {
if ((0, _DiUtil.isExpanded)(element)) {
return self.createSubProcessHit(element, gfx);
} else {
return self.createDefaultHit(element, gfx);
}
}
});
}
BpmnInteractionEvents.$inject = ['eventBus', 'interactionEvents'];
BpmnInteractionEvents.prototype.createDefaultHit = function (element, gfx) {
this._interactionEvents.removeHits(gfx);
this._interactionEvents.createDefaultHit(element, gfx); // indicate that we created a hit
return true;
};
BpmnInteractionEvents.prototype.createParticipantHit = function (element, gfx) {
// remove existing hits
this._interactionEvents.removeHits(gfx); // add outline hit
this._interactionEvents.createBoxHit(gfx, 'click-stroke', {
width: element.width,
height: element.height
}); // add label hit
this._interactionEvents.createBoxHit(gfx, 'all', {
width: LABEL_WIDTH,
height: element.height
}); // indicate that we created a hit
return true;
};
BpmnInteractionEvents.prototype.createSubProcessHit = function (element, gfx) {
// remove existing hits
this._interactionEvents.removeHits(gfx); // add outline hit
this._interactionEvents.createBoxHit(gfx, 'click-stroke', {
width: element.width,
height: element.height
}); // add label hit
this._interactionEvents.createBoxHit(gfx, 'all', {
width: element.width,
height: LABEL_HEIGHT
}); // indicate that we created a hit
return true;
};
},{"../../util/DiUtil":140,"../../util/ModelUtil":142}],48:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BpmnInteractionEvents = _interopRequireDefault(require("./BpmnInteractionEvents"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['bpmnInteractionEvents'],
bpmnInteractionEvents: ['type', _BpmnInteractionEvents.default]
};
exports.default = _default;
},{"./BpmnInteractionEvents":47}],49:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnKeyboardBindings;
var _inherits = _interopRequireDefault(require("inherits"));
var _KeyboardBindings = _interopRequireDefault(require("diagram-js/lib/features/keyboard/KeyboardBindings"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN 2.0 specific keyboard bindings.
*
* @param {Injector} injector
*/
function BpmnKeyboardBindings(injector) {
injector.invoke(_KeyboardBindings.default, this);
}
(0, _inherits.default)(BpmnKeyboardBindings, _KeyboardBindings.default);
BpmnKeyboardBindings.$inject = ['injector'];
/**
* Register available keyboard bindings.
*
* @param {Keyboard} keyboard
* @param {EditorActions} editorActions
*/
BpmnKeyboardBindings.prototype.registerBindings = function (keyboard, editorActions) {
// inherit default bindings
_KeyboardBindings.default.prototype.registerBindings.call(this, keyboard, editorActions);
/**
* Add keyboard binding if respective editor action
* is registered.
*
* @param {string} action name
* @param {Function} fn that implements the key binding
*/
function addListener(action, fn) {
if (editorActions.isRegistered(action)) {
keyboard.addListener(fn);
}
} // select all elements
// CTRL + A
addListener('selectElements', function (context) {
var event = context.keyEvent;
if (keyboard.isKey(['a', 'A'], event) && keyboard.isCmd(event)) {
editorActions.trigger('selectElements');
return true;
}
}); // search labels
// CTRL + F
addListener('find', function (context) {
var event = context.keyEvent;
if (keyboard.isKey(['f', 'F'], event) && keyboard.isCmd(event)) {
editorActions.trigger('find');
return true;
}
}); // activate space tool
// S
addListener('spaceTool', function (context) {
var event = context.keyEvent;
if (keyboard.hasModifier(event)) {
return;
}
if (keyboard.isKey(['s', 'S'], event)) {
editorActions.trigger('spaceTool');
return true;
}
}); // activate lasso tool
// L
addListener('lassoTool', function (context) {
var event = context.keyEvent;
if (keyboard.hasModifier(event)) {
return;
}
if (keyboard.isKey(['l', 'L'], event)) {
editorActions.trigger('lassoTool');
return true;
}
}); // activate hand tool
// H
addListener('handTool', function (context) {
var event = context.keyEvent;
if (keyboard.hasModifier(event)) {
return;
}
if (keyboard.isKey(['h', 'H'], event)) {
editorActions.trigger('handTool');
return true;
}
}); // activate global connect tool
// C
addListener('globalConnectTool', function (context) {
var event = context.keyEvent;
if (keyboard.hasModifier(event)) {
return;
}
if (keyboard.isKey(['c', 'C'], event)) {
editorActions.trigger('globalConnectTool');
return true;
}
}); // activate direct editing
// E
addListener('directEditing', function (context) {
var event = context.keyEvent;
if (keyboard.hasModifier(event)) {
return;
}
if (keyboard.isKey(['e', 'E'], event)) {
editorActions.trigger('directEditing');
return true;
}
});
};
},{"diagram-js/lib/features/keyboard/KeyboardBindings":217,"inherits":349}],50:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _keyboard = _interopRequireDefault(require("diagram-js/lib/features/keyboard"));
var _BpmnKeyboardBindings = _interopRequireDefault(require("./BpmnKeyboardBindings"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_keyboard.default],
__init__: ['keyboardBindings'],
keyboardBindings: ['type', _BpmnKeyboardBindings.default]
};
exports.default = _default;
},{"./BpmnKeyboardBindings":49,"diagram-js/lib/features/keyboard":219}],51:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = LabelEditingPreview;
var _tinySvg = require("tiny-svg");
var _ModelUtil = require("../../util/ModelUtil");
var _SvgTransformUtil = require("diagram-js/lib/util/SvgTransformUtil");
var MARKER_HIDDEN = 'djs-element-hidden',
MARKER_LABEL_HIDDEN = 'djs-label-hidden';
function LabelEditingPreview(eventBus, canvas, elementRegistry, pathMap) {
var self = this;
var defaultLayer = canvas.getDefaultLayer();
var element, absoluteElementBBox, gfx;
eventBus.on('directEditing.activate', function (context) {
var activeProvider = context.active;
element = activeProvider.element.label || activeProvider.element; // text annotation
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
absoluteElementBBox = canvas.getAbsoluteBBox(element);
gfx = (0, _tinySvg.create)('g');
var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
xScaleFactor: 1,
yScaleFactor: 1,
containerWidth: element.width,
containerHeight: element.height,
position: {
mx: 0.0,
my: 0.0
}
});
var path = self.path = (0, _tinySvg.create)('path');
(0, _tinySvg.attr)(path, {
d: textPathData,
strokeWidth: 2,
stroke: getStrokeColor(element)
});
(0, _tinySvg.append)(gfx, path);
(0, _tinySvg.append)(defaultLayer, gfx);
(0, _SvgTransformUtil.translate)(gfx, element.x, element.y);
}
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation') || element.labelTarget) {
canvas.addMarker(element, MARKER_HIDDEN);
} else if ((0, _ModelUtil.is)(element, 'bpmn:Task') || (0, _ModelUtil.is)(element, 'bpmn:CallActivity') || (0, _ModelUtil.is)(element, 'bpmn:SubProcess') || (0, _ModelUtil.is)(element, 'bpmn:Participant')) {
canvas.addMarker(element, MARKER_LABEL_HIDDEN);
}
});
eventBus.on('directEditing.resize', function (context) {
// text annotation
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
var height = context.height,
dy = context.dy;
var newElementHeight = Math.max(element.height / absoluteElementBBox.height * (height + dy), 0);
var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
xScaleFactor: 1,
yScaleFactor: 1,
containerWidth: element.width,
containerHeight: newElementHeight,
position: {
mx: 0.0,
my: 0.0
}
});
(0, _tinySvg.attr)(self.path, {
d: textPathData
});
}
});
eventBus.on(['directEditing.complete', 'directEditing.cancel'], function (context) {
var activeProvider = context.active;
if (activeProvider) {
canvas.removeMarker(activeProvider.element.label || activeProvider.element, MARKER_HIDDEN);
canvas.removeMarker(element, MARKER_LABEL_HIDDEN);
}
element = undefined;
absoluteElementBBox = undefined;
if (gfx) {
(0, _tinySvg.remove)(gfx);
gfx = undefined;
}
});
}
LabelEditingPreview.$inject = ['eventBus', 'canvas', 'elementRegistry', 'pathMap']; // helpers ///////////////////
function getStrokeColor(element, defaultColor) {
var bo = (0, _ModelUtil.getBusinessObject)(element);
return bo.di.get('stroke') || defaultColor || 'black';
}
},{"../../util/ModelUtil":142,"diagram-js/lib/util/SvgTransformUtil":330,"tiny-svg":571}],52:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = LabelEditingProvider;
var _minDash = require("min-dash");
var _LabelUtil = require("./LabelUtil");
var _ModelUtil = require("../../util/ModelUtil");
var _CategoryUtil = require("../modeling/behavior/util/CategoryUtil");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _DiUtil = require("../../util/DiUtil");
var _LabelUtil2 = require("../../util/LabelUtil");
function LabelEditingProvider(eventBus, bpmnFactory, canvas, directEditing, modeling, resizeHandles, textRenderer) {
this._bpmnFactory = bpmnFactory;
this._canvas = canvas;
this._modeling = modeling;
this._textRenderer = textRenderer;
directEditing.registerProvider(this); // listen to dblclick on non-root elements
eventBus.on('element.dblclick', function (event) {
activateDirectEdit(event.element, true);
}); // complete on followup canvas operation
eventBus.on(['autoPlace.start', 'canvas.viewbox.changing', 'drag.init', 'element.mousedown', 'popupMenu.open'], function (event) {
if (directEditing.isActive()) {
directEditing.complete();
}
}); // cancel on command stack changes
eventBus.on(['commandStack.changed'], function (e) {
if (directEditing.isActive()) {
directEditing.cancel();
}
});
eventBus.on('directEditing.activate', function (event) {
resizeHandles.removeResizers();
});
eventBus.on('create.end', 500, function (event) {
var context = event.context,
element = context.shape,
canExecute = event.context.canExecute,
isTouch = event.isTouch; // TODO(nikku): we need to find a way to support the
// direct editing on mobile devices; right now this will
// break for desworkflowediting on mobile devices
// as it breaks the user interaction workflow
// TODO(nre): we should temporarily focus the edited element
// here and release the focused viewport after the direct edit
// operation is finished
if (isTouch) {
return;
}
if (!canExecute) {
return;
}
if (context.hints && context.hints.createElementsBehavior === false) {
return;
}
activateDirectEdit(element);
});
eventBus.on('autoPlace.end', 500, function (event) {
activateDirectEdit(event.shape);
});
function activateDirectEdit(element, force) {
if (force || (0, _ModelingUtil.isAny)(element, ['bpmn:Task', 'bpmn:TextAnnotation', 'bpmn:Group']) || isCollapsedSubProcess(element)) {
directEditing.activate(element);
}
}
}
LabelEditingProvider.$inject = ['eventBus', 'bpmnFactory', 'canvas', 'directEditing', 'modeling', 'resizeHandles', 'textRenderer'];
/**
* Activate direct editing for activities and text annotations.
*
* @param {djs.model.Base} element
*
* @return {Object} an object with properties bounds (position and size), text and options
*/
LabelEditingProvider.prototype.activate = function (element) {
// text
var text = (0, _LabelUtil.getLabel)(element);
if (text === undefined) {
return;
}
var context = {
text: text
}; // bounds
var bounds = this.getEditingBBox(element);
(0, _minDash.assign)(context, bounds);
var options = {}; // tasks
if ((0, _ModelingUtil.isAny)(element, ['bpmn:Task', 'bpmn:Participant', 'bpmn:Lane', 'bpmn:CallActivity']) || isCollapsedSubProcess(element)) {
(0, _minDash.assign)(options, {
centerVertically: true
});
} // external labels
if ((0, _LabelUtil2.isLabelExternal)(element)) {
(0, _minDash.assign)(options, {
autoResize: true
});
} // text annotations
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
(0, _minDash.assign)(options, {
resizable: true,
autoResize: true
});
}
(0, _minDash.assign)(context, {
options: options
});
return context;
};
/**
* Get the editing bounding box based on the element's size and position
*
* @param {djs.model.Base} element
*
* @return {Object} an object containing information about position
* and size (fixed or minimum and/or maximum)
*/
LabelEditingProvider.prototype.getEditingBBox = function (element) {
var canvas = this._canvas;
var target = element.label || element;
var bbox = canvas.getAbsoluteBBox(target);
var mid = {
x: bbox.x + bbox.width / 2,
y: bbox.y + bbox.height / 2
}; // default position
var bounds = {
x: bbox.x,
y: bbox.y
};
var zoom = canvas.zoom();
var defaultStyle = this._textRenderer.getDefaultStyle(),
externalStyle = this._textRenderer.getExternalStyle(); // take zoom into account
var externalFontSize = externalStyle.fontSize * zoom,
externalLineHeight = externalStyle.lineHeight,
defaultFontSize = defaultStyle.fontSize * zoom,
defaultLineHeight = defaultStyle.lineHeight;
var style = {
fontFamily: this._textRenderer.getDefaultStyle().fontFamily,
fontWeight: this._textRenderer.getDefaultStyle().fontWeight
}; // adjust for expanded pools AND lanes
if ((0, _ModelUtil.is)(element, 'bpmn:Lane') || isExpandedPool(element)) {
(0, _minDash.assign)(bounds, {
width: bbox.height,
height: 30 * zoom,
x: bbox.x - bbox.height / 2 + 15 * zoom,
y: mid.y - 30 * zoom / 2
});
(0, _minDash.assign)(style, {
fontSize: defaultFontSize + 'px',
lineHeight: defaultLineHeight,
paddingTop: 7 * zoom + 'px',
paddingBottom: 7 * zoom + 'px',
paddingLeft: 5 * zoom + 'px',
paddingRight: 5 * zoom + 'px',
transform: 'rotate(-90deg)'
});
} // internal labels for tasks and collapsed call activities,
// sub processes and participants
if ((0, _ModelingUtil.isAny)(element, ['bpmn:Task', 'bpmn:CallActivity']) || isCollapsedPool(element) || isCollapsedSubProcess(element)) {
(0, _minDash.assign)(bounds, {
width: bbox.width,
height: bbox.height
});
(0, _minDash.assign)(style, {
fontSize: defaultFontSize + 'px',
lineHeight: defaultLineHeight,
paddingTop: 7 * zoom + 'px',
paddingBottom: 7 * zoom + 'px',
paddingLeft: 5 * zoom + 'px',
paddingRight: 5 * zoom + 'px'
});
} // internal labels for expanded sub processes
if (isExpandedSubProcess(element)) {
(0, _minDash.assign)(bounds, {
width: bbox.width,
x: bbox.x
});
(0, _minDash.assign)(style, {
fontSize: defaultFontSize + 'px',
lineHeight: defaultLineHeight,
paddingTop: 7 * zoom + 'px',
paddingBottom: 7 * zoom + 'px',
paddingLeft: 5 * zoom + 'px',
paddingRight: 5 * zoom + 'px'
});
}
var width = 90 * zoom,
paddingTop = 7 * zoom,
paddingBottom = 4 * zoom; // external labels for events, data elements, gateways, groups and connections
if (target.labelTarget) {
(0, _minDash.assign)(bounds, {
width: width,
height: bbox.height + paddingTop + paddingBottom,
x: mid.x - width / 2,
y: bbox.y - paddingTop
});
(0, _minDash.assign)(style, {
fontSize: externalFontSize + 'px',
lineHeight: externalLineHeight,
paddingTop: paddingTop + 'px',
paddingBottom: paddingBottom + 'px'
});
} // external label not yet created
if ((0, _LabelUtil2.isLabelExternal)(target) && !(0, _LabelUtil2.hasExternalLabel)(target) && !(0, _LabelUtil2.isLabel)(target)) {
var externalLabelMid = (0, _LabelUtil2.getExternalLabelMid)(element);
var absoluteBBox = canvas.getAbsoluteBBox({
x: externalLabelMid.x,
y: externalLabelMid.y,
width: 0,
height: 0
});
var height = externalFontSize + paddingTop + paddingBottom;
(0, _minDash.assign)(bounds, {
width: width,
height: height,
x: absoluteBBox.x - width / 2,
y: absoluteBBox.y - height / 2
});
(0, _minDash.assign)(style, {
fontSize: externalFontSize + 'px',
lineHeight: externalLineHeight,
paddingTop: paddingTop + 'px',
paddingBottom: paddingBottom + 'px'
});
} // text annotations
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
(0, _minDash.assign)(bounds, {
width: bbox.width,
height: bbox.height,
minWidth: 30 * zoom,
minHeight: 10 * zoom
});
(0, _minDash.assign)(style, {
textAlign: 'left',
paddingTop: 5 * zoom + 'px',
paddingBottom: 7 * zoom + 'px',
paddingLeft: 7 * zoom + 'px',
paddingRight: 5 * zoom + 'px',
fontSize: defaultFontSize + 'px',
lineHeight: defaultLineHeight
});
}
return {
bounds: bounds,
style: style
};
};
LabelEditingProvider.prototype.update = function (element, newLabel, activeContextText, bounds) {
var newBounds, bbox;
if ((0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
bbox = this._canvas.getAbsoluteBBox(element);
newBounds = {
x: element.x,
y: element.y,
width: element.width / bbox.width * bounds.width,
height: element.height / bbox.height * bounds.height
};
}
if ((0, _ModelUtil.is)(element, 'bpmn:Group')) {
var businessObject = (0, _ModelUtil.getBusinessObject)(element); // initialize categoryValue if not existing
if (!businessObject.categoryValueRef) {
var rootElement = this._canvas.getRootElement(),
definitions = (0, _ModelUtil.getBusinessObject)(rootElement).$parent;
var categoryValue = (0, _CategoryUtil.createCategoryValue)(definitions, this._bpmnFactory);
(0, _ModelUtil.getBusinessObject)(element).categoryValueRef = categoryValue;
}
}
if (isEmptyText(newLabel)) {
newLabel = null;
}
this._modeling.updateLabel(element, newLabel, newBounds);
}; // helpers //////////////////////
function isCollapsedSubProcess(element) {
return (0, _ModelUtil.is)(element, 'bpmn:SubProcess') && !(0, _DiUtil.isExpanded)(element);
}
function isExpandedSubProcess(element) {
return (0, _ModelUtil.is)(element, 'bpmn:SubProcess') && (0, _DiUtil.isExpanded)(element);
}
function isCollapsedPool(element) {
return (0, _ModelUtil.is)(element, 'bpmn:Participant') && !(0, _DiUtil.isExpanded)(element);
}
function isExpandedPool(element) {
return (0, _ModelUtil.is)(element, 'bpmn:Participant') && (0, _DiUtil.isExpanded)(element);
}
function isEmptyText(label) {
return !label || !label.trim();
}
},{"../../util/DiUtil":140,"../../util/LabelUtil":141,"../../util/ModelUtil":142,"../modeling/behavior/util/CategoryUtil":95,"../modeling/util/ModelingUtil":113,"./LabelUtil":53,"min-dash":559}],53:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getLabel = getLabel;
exports.setLabel = setLabel;
var _ModelUtil = require("../../util/ModelUtil");
function getLabelAttr(semantic) {
if ((0, _ModelUtil.is)(semantic, 'bpmn:FlowElement') || (0, _ModelUtil.is)(semantic, 'bpmn:Participant') || (0, _ModelUtil.is)(semantic, 'bpmn:Lane') || (0, _ModelUtil.is)(semantic, 'bpmn:SequenceFlow') || (0, _ModelUtil.is)(semantic, 'bpmn:MessageFlow') || (0, _ModelUtil.is)(semantic, 'bpmn:DataInput') || (0, _ModelUtil.is)(semantic, 'bpmn:DataOutput')) {
return 'name';
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:TextAnnotation')) {
return 'text';
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Group')) {
return 'categoryValueRef';
}
}
function getCategoryValue(semantic) {
var categoryValueRef = semantic['categoryValueRef'];
if (!categoryValueRef) {
return '';
}
return categoryValueRef.value || '';
}
function getLabel(element) {
var semantic = element.businessObject,
attr = getLabelAttr(semantic);
if (attr) {
if (attr === 'categoryValueRef') {
return getCategoryValue(semantic);
}
return semantic[attr] || '';
}
}
function setLabel(element, text, isExternal) {
var semantic = element.businessObject,
attr = getLabelAttr(semantic);
if (attr) {
if (attr === 'categoryValueRef') {
semantic['categoryValueRef'].value = text;
} else {
semantic[attr] = text;
}
}
return element;
}
},{"../../util/ModelUtil":142}],54:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UpdateLabelHandler;
var _LabelUtil = require("../LabelUtil");
var _LabelUtil2 = require("../../../util/LabelUtil");
var _ModelUtil = require("../../../util/ModelUtil");
var NULL_DIMENSIONS = {
width: 0,
height: 0
};
/**
* A handler that updates the text of a BPMN element.
*/
function UpdateLabelHandler(modeling, textRenderer) {
/**
* Set the label and return the changed elements.
*
* Element parameter can be label itself or connection (i.e. sequence flow).
*
* @param {djs.model.Base} element
* @param {string} text
*/
function setText(element, text) {
// external label if present
var label = element.label || element;
var labelTarget = element.labelTarget || element;
(0, _LabelUtil.setLabel)(label, text, labelTarget !== label);
return [label, labelTarget];
}
function preExecute(ctx) {
var element = ctx.element,
businessObject = element.businessObject,
newLabel = ctx.newLabel;
if (!(0, _LabelUtil2.isLabel)(element) && (0, _LabelUtil2.isLabelExternal)(element) && !(0, _LabelUtil2.hasExternalLabel)(element) && !isEmptyText(newLabel)) {
// create label
var paddingTop = 7;
var labelCenter = (0, _LabelUtil2.getExternalLabelMid)(element);
labelCenter = {
x: labelCenter.x,
y: labelCenter.y + paddingTop
};
modeling.createLabel(element, labelCenter, {
id: businessObject.id + '_label',
businessObject: businessObject
});
}
}
function execute(ctx) {
ctx.oldLabel = (0, _LabelUtil.getLabel)(ctx.element);
return setText(ctx.element, ctx.newLabel);
}
function revert(ctx) {
return setText(ctx.element, ctx.oldLabel);
}
function postExecute(ctx) {
var element = ctx.element,
label = element.label || element,
newLabel = ctx.newLabel,
newBounds = ctx.newBounds,
hints = ctx.hints || {}; // ignore internal labels for elements except text annotations
if (!(0, _LabelUtil2.isLabel)(label) && !(0, _ModelUtil.is)(label, 'bpmn:TextAnnotation')) {
return;
}
if ((0, _LabelUtil2.isLabel)(label) && isEmptyText(newLabel)) {
if (hints.removeShape !== false) {
modeling.removeShape(label, {
unsetLabel: false
});
}
return;
}
var text = (0, _LabelUtil.getLabel)(label); // resize element based on label _or_ pre-defined bounds
if (typeof newBounds === 'undefined') {
newBounds = textRenderer.getExternalLabelBounds(label, text);
} // setting newBounds to false or _null_ will
// disable the postExecute resize operation
if (newBounds) {
modeling.resizeShape(label, newBounds, NULL_DIMENSIONS);
}
} // API
this.preExecute = preExecute;
this.execute = execute;
this.revert = revert;
this.postExecute = postExecute;
}
UpdateLabelHandler.$inject = ['modeling', 'textRenderer']; // helpers ///////////////////////
function isEmptyText(label) {
return !label || !label.trim();
}
},{"../../../util/LabelUtil":141,"../../../util/ModelUtil":142,"../LabelUtil":53}],55:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _changeSupport = _interopRequireDefault(require("diagram-js/lib/features/change-support"));
var _resize = _interopRequireDefault(require("diagram-js/lib/features/resize"));
var _diagramJsDirectEditing = _interopRequireDefault(require("diagram-js-direct-editing"));
var _LabelEditingProvider = _interopRequireDefault(require("./LabelEditingProvider"));
var _LabelEditingPreview = _interopRequireDefault(require("./LabelEditingPreview"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_changeSupport.default, _resize.default, _diagramJsDirectEditing.default],
__init__: ['labelEditingProvider', 'labelEditingPreview'],
labelEditingProvider: ['type', _LabelEditingProvider.default],
labelEditingPreview: ['type', _LabelEditingPreview.default]
};
exports.default = _default;
},{"./LabelEditingPreview":51,"./LabelEditingProvider":52,"diagram-js-direct-editing":334,"diagram-js/lib/features/change-support":179,"diagram-js/lib/features/resize":271}],56:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnFactory;
var _minDash = require("min-dash");
var _ModelingUtil = require("./util/ModelingUtil");
var _ModelUtil = require("../../util/ModelUtil");
function BpmnFactory(moddle) {
this._model = moddle;
}
BpmnFactory.$inject = ['moddle'];
BpmnFactory.prototype._needsId = function (element) {
return (0, _ModelingUtil.isAny)(element, ['bpmn:RootElement', 'bpmn:FlowElement', 'bpmn:MessageFlow', 'bpmn:DataAssociation', 'bpmn:Artifact', 'bpmn:Participant', 'bpmn:Lane', 'bpmn:LaneSet', 'bpmn:Process', 'bpmn:Collaboration', 'bpmndi:BPMNShape', 'bpmndi:BPMNEdge', 'bpmndi:BPMNDiagram', 'bpmndi:BPMNPlane', 'bpmn:Property', 'bpmn:CategoryValue']);
};
BpmnFactory.prototype._ensureId = function (element) {
// generate semantic ids for elements
// bpmn:SequenceFlow -> SequenceFlow_ID
var prefix;
if ((0, _ModelUtil.is)(element, 'bpmn:Activity')) {
prefix = 'Activity';
} else if ((0, _ModelUtil.is)(element, 'bpmn:Event')) {
prefix = 'Event';
} else if ((0, _ModelUtil.is)(element, 'bpmn:Gateway')) {
prefix = 'Gateway';
} else if ((0, _ModelingUtil.isAny)(element, ['bpmn:SequenceFlow', 'bpmn:MessageFlow'])) {
prefix = 'Flow';
} else {
prefix = (element.$type || '').replace(/^[^:]*:/g, '');
}
prefix += '_';
if (!element.id && this._needsId(element)) {
element.id = this._model.ids.nextPrefixed(prefix, element);
}
};
BpmnFactory.prototype.create = function (type, attrs) {
var element = this._model.create(type, attrs || {});
this._ensureId(element);
return element;
};
BpmnFactory.prototype.createDiLabel = function () {
return this.create('bpmndi:BPMNLabel', {
bounds: this.createDiBounds()
});
};
BpmnFactory.prototype.createDiShape = function (semantic, bounds, attrs) {
return this.create('bpmndi:BPMNShape', (0, _minDash.assign)({
bpmnElement: semantic,
bounds: this.createDiBounds(bounds)
}, attrs));
};
BpmnFactory.prototype.createDiBounds = function (bounds) {
return this.create('dc:Bounds', bounds);
};
BpmnFactory.prototype.createDiWaypoints = function (waypoints) {
var self = this;
return (0, _minDash.map)(waypoints, function (pos) {
return self.createDiWaypoint(pos);
});
};
BpmnFactory.prototype.createDiWaypoint = function (point) {
return this.create('dc:Point', (0, _minDash.pick)(point, ['x', 'y']));
};
BpmnFactory.prototype.createDiEdge = function (semantic, waypoints, attrs) {
return this.create('bpmndi:BPMNEdge', (0, _minDash.assign)({
bpmnElement: semantic
}, attrs));
};
BpmnFactory.prototype.createDiPlane = function (semantic) {
return this.create('bpmndi:BPMNPlane', {
bpmnElement: semantic
});
};
},{"../../util/ModelUtil":142,"./util/ModelingUtil":113,"min-dash":559}],57:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnLayouter;
var _inherits = _interopRequireDefault(require("inherits"));
var _minDash = require("min-dash");
var _BaseLayouter = _interopRequireDefault(require("diagram-js/lib/layout/BaseLayouter"));
var _ManhattanLayout = require("diagram-js/lib/layout/ManhattanLayout");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _DiUtil = require("../../util/DiUtil");
var _ModelUtil = require("../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ATTACH_ORIENTATION_PADDING = -10,
BOUNDARY_TO_HOST_THRESHOLD = 40;
var oppositeOrientationMapping = {
'top': 'bottom',
'top-right': 'bottom-left',
'top-left': 'bottom-right',
'right': 'left',
'bottom': 'top',
'bottom-right': 'top-left',
'bottom-left': 'top-right',
'left': 'right'
};
var orientationDirectionMapping = {
top: 't',
right: 'r',
bottom: 'b',
left: 'l'
};
function BpmnLayouter() {}
(0, _inherits.default)(BpmnLayouter, _BaseLayouter.default);
BpmnLayouter.prototype.layoutConnection = function (connection, hints) {
if (!hints) {
hints = {};
}
var source = hints.source || connection.source,
target = hints.target || connection.target,
waypoints = hints.waypoints || connection.waypoints,
connectionStart = hints.connectionStart,
connectionEnd = hints.connectionEnd;
var manhattanOptions, updatedWaypoints;
if (!connectionStart) {
connectionStart = getConnectionDocking(waypoints && waypoints[0], source);
}
if (!connectionEnd) {
connectionEnd = getConnectionDocking(waypoints && waypoints[waypoints.length - 1], target);
} // TODO(nikku): support vertical modeling
// and invert preferredLayouts accordingly
if ((0, _ModelUtil.is)(connection, 'bpmn:Association') || (0, _ModelUtil.is)(connection, 'bpmn:DataAssociation')) {
if (waypoints && !isCompensationAssociation(source, target)) {
return [].concat([connectionStart], waypoints.slice(1, -1), [connectionEnd]);
}
}
if ((0, _ModelUtil.is)(connection, 'bpmn:MessageFlow')) {
manhattanOptions = getMessageFlowManhattanOptions(source, target);
} else if ((0, _ModelUtil.is)(connection, 'bpmn:SequenceFlow') || isCompensationAssociation(source, target)) {
// layout all connection between flow elements h:h, except for
// (1) outgoing of boundary events -> layout based on attach orientation and target orientation
// (2) incoming/outgoing of gateways -> v:h for outgoing, h:v for incoming
// (3) loops
if (source === target) {
manhattanOptions = {
preferredLayouts: getLoopPreferredLayout(source, connection)
};
} else if ((0, _ModelUtil.is)(source, 'bpmn:BoundaryEvent')) {
manhattanOptions = {
preferredLayouts: getBoundaryEventPreferredLayouts(source, target, connectionEnd)
};
} else if (isExpandedSubProcess(source) || isExpandedSubProcess(target)) {
manhattanOptions = getSubProcessManhattanOptions(source);
} else if ((0, _ModelUtil.is)(source, 'bpmn:Gateway')) {
manhattanOptions = {
preferredLayouts: ['v:h']
};
} else if ((0, _ModelUtil.is)(target, 'bpmn:Gateway')) {
manhattanOptions = {
preferredLayouts: ['h:v']
};
} else {
manhattanOptions = {
preferredLayouts: ['h:h']
};
}
}
if (manhattanOptions) {
manhattanOptions = (0, _minDash.assign)(manhattanOptions, hints);
updatedWaypoints = (0, _ManhattanLayout.withoutRedundantPoints)((0, _ManhattanLayout.repairConnection)(source, target, connectionStart, connectionEnd, waypoints, manhattanOptions));
}
return updatedWaypoints || [connectionStart, connectionEnd];
}; // helpers //////////
function getAttachOrientation(attachedElement) {
var hostElement = attachedElement.host;
return (0, _LayoutUtil.getOrientation)((0, _LayoutUtil.getMid)(attachedElement), hostElement, ATTACH_ORIENTATION_PADDING);
}
function getMessageFlowManhattanOptions(source, target) {
return {
preferredLayouts: ['straight', 'v:v'],
preserveDocking: getMessageFlowPreserveDocking(source, target)
};
}
function getMessageFlowPreserveDocking(source, target) {
// (1) docking element connected to participant has precedence
if ((0, _ModelUtil.is)(target, 'bpmn:Participant')) {
return 'source';
}
if ((0, _ModelUtil.is)(source, 'bpmn:Participant')) {
return 'target';
} // (2) docking element connected to expanded sub-process has precedence
if (isExpandedSubProcess(target)) {
return 'source';
}
if (isExpandedSubProcess(source)) {
return 'target';
} // (3) docking event has precedence
if ((0, _ModelUtil.is)(target, 'bpmn:Event')) {
return 'target';
}
if ((0, _ModelUtil.is)(source, 'bpmn:Event')) {
return 'source';
}
return null;
}
function getSubProcessManhattanOptions(source) {
return {
preferredLayouts: ['straight', 'h:h'],
preserveDocking: getSubProcessPreserveDocking(source)
};
}
function getSubProcessPreserveDocking(source) {
return isExpandedSubProcess(source) ? 'target' : 'source';
}
function getConnectionDocking(point, shape) {
return point ? point.original || point : (0, _LayoutUtil.getMid)(shape);
}
function isCompensationAssociation(source, target) {
return (0, _ModelUtil.is)(target, 'bpmn:Activity') && (0, _ModelUtil.is)(source, 'bpmn:BoundaryEvent') && target.businessObject.isForCompensation;
}
function isExpandedSubProcess(element) {
return (0, _ModelUtil.is)(element, 'bpmn:SubProcess') && (0, _DiUtil.isExpanded)(element);
}
function isSame(a, b) {
return a === b;
}
function isAnyOrientation(orientation, orientations) {
return orientations.indexOf(orientation) !== -1;
}
function getHorizontalOrientation(orientation) {
var matches = /right|left/.exec(orientation);
return matches && matches[0];
}
function getVerticalOrientation(orientation) {
var matches = /top|bottom/.exec(orientation);
return matches && matches[0];
}
function isOppositeOrientation(a, b) {
return oppositeOrientationMapping[a] === b;
}
function isOppositeHorizontalOrientation(a, b) {
var horizontalOrientation = getHorizontalOrientation(a);
var oppositeHorizontalOrientation = oppositeOrientationMapping[horizontalOrientation];
return b.indexOf(oppositeHorizontalOrientation) !== -1;
}
function isOppositeVerticalOrientation(a, b) {
var verticalOrientation = getVerticalOrientation(a);
var oppositeVerticalOrientation = oppositeOrientationMapping[verticalOrientation];
return b.indexOf(oppositeVerticalOrientation) !== -1;
}
function isHorizontalOrientation(orientation) {
return orientation === 'right' || orientation === 'left';
}
function getLoopPreferredLayout(source, connection) {
var waypoints = connection.waypoints;
var orientation = waypoints && waypoints.length && (0, _LayoutUtil.getOrientation)(waypoints[0], source);
if (orientation === 'top') {
return ['t:r'];
} else if (orientation === 'right') {
return ['r:b'];
} else if (orientation === 'left') {
return ['l:t'];
}
return ['b:l'];
}
function getBoundaryEventPreferredLayouts(source, target, end) {
var sourceMid = (0, _LayoutUtil.getMid)(source),
targetMid = (0, _LayoutUtil.getMid)(target),
attachOrientation = getAttachOrientation(source),
sourceLayout,
targetLayout;
var isLoop = isSame(source.host, target);
var attachedToSide = isAnyOrientation(attachOrientation, ['top', 'right', 'bottom', 'left']);
var targetOrientation = (0, _LayoutUtil.getOrientation)(targetMid, sourceMid, {
x: source.width / 2 + target.width / 2,
y: source.height / 2 + target.height / 2
});
if (isLoop) {
return getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, target, end);
} // source layout
sourceLayout = getBoundaryEventSourceLayout(attachOrientation, targetOrientation, attachedToSide); // target layout
targetLayout = getBoundaryEventTargetLayout(attachOrientation, targetOrientation, attachedToSide);
return [sourceLayout + ':' + targetLayout];
}
function getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, target, end) {
var orientation = attachedToSide ? attachOrientation : getVerticalOrientation(attachOrientation),
sourceLayout = orientationDirectionMapping[orientation],
targetLayout;
if (attachedToSide) {
if (isHorizontalOrientation(attachOrientation)) {
targetLayout = shouldConnectToSameSide('y', source, target, end) ? 'h' : 'b';
} else {
targetLayout = shouldConnectToSameSide('x', source, target, end) ? 'v' : 'l';
}
} else {
targetLayout = 'v';
}
return [sourceLayout + ':' + targetLayout];
}
function shouldConnectToSameSide(axis, source, target, end) {
var threshold = BOUNDARY_TO_HOST_THRESHOLD;
return !(areCloseOnAxis(axis, end, target, threshold) || areCloseOnAxis(axis, end, {
x: target.x + target.width,
y: target.y + target.height
}, threshold) || areCloseOnAxis(axis, end, (0, _LayoutUtil.getMid)(source), threshold));
}
function areCloseOnAxis(axis, a, b, threshold) {
return Math.abs(a[axis] - b[axis]) < threshold;
}
function getBoundaryEventSourceLayout(attachOrientation, targetOrientation, attachedToSide) {
// attached to either top, right, bottom or left side
if (attachedToSide) {
return orientationDirectionMapping[attachOrientation];
} // attached to either top-right, top-left, bottom-right or bottom-left corner
// same vertical or opposite horizontal orientation
if (isSame(getVerticalOrientation(attachOrientation), getVerticalOrientation(targetOrientation)) || isOppositeOrientation(getHorizontalOrientation(attachOrientation), getHorizontalOrientation(targetOrientation))) {
return orientationDirectionMapping[getVerticalOrientation(attachOrientation)];
} // fallback
return orientationDirectionMapping[getHorizontalOrientation(attachOrientation)];
}
function getBoundaryEventTargetLayout(attachOrientation, targetOrientation, attachedToSide) {
// attached to either top, right, bottom or left side
if (attachedToSide) {
if (isHorizontalOrientation(attachOrientation)) {
// orientation is right or left
// opposite horizontal orientation or same orientation
if (isOppositeHorizontalOrientation(attachOrientation, targetOrientation) || isSame(attachOrientation, targetOrientation)) {
return 'h';
} // fallback
return 'v';
} else {
// orientation is top or bottom
// opposite vertical orientation or same orientation
if (isOppositeVerticalOrientation(attachOrientation, targetOrientation) || isSame(attachOrientation, targetOrientation)) {
return 'v';
} // fallback
return 'h';
}
} // attached to either top-right, top-left, bottom-right or bottom-left corner
// orientation is right, left
// or same vertical orientation but also right or left
if (isHorizontalOrientation(targetOrientation) || isSame(getVerticalOrientation(attachOrientation), getVerticalOrientation(targetOrientation)) && getHorizontalOrientation(targetOrientation)) {
return 'h';
} else {
return 'v';
}
}
},{"../../util/DiUtil":140,"../../util/ModelUtil":142,"diagram-js/lib/layout/BaseLayouter":300,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/layout/ManhattanLayout":303,"inherits":349,"min-dash":559}],58:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnUpdater;
var _minDash = require("min-dash");
var _inherits = _interopRequireDefault(require("inherits"));
var _Collections = require("diagram-js/lib/util/Collections");
var _model = require("diagram-js/lib/model");
var _ModelUtil = require("../../util/ModelUtil");
var _ModelingUtil = require("./util/ModelingUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* A handler responsible for updating the underlying BPMN 2.0 XML + DI
* once changes on the diagram happen
*/
function BpmnUpdater(eventBus, bpmnFactory, connectionDocking, translate) {
_CommandInterceptor.default.call(this, eventBus);
this._bpmnFactory = bpmnFactory;
this._translate = translate;
var self = this; // connection cropping //////////////////////
// crop connection ends during create/update
function cropConnection(e) {
var context = e.context,
hints = context.hints || {},
connection;
if (!context.cropped && hints.createElementsBehavior !== false) {
connection = context.connection;
connection.waypoints = connectionDocking.getCroppedWaypoints(connection);
context.cropped = true;
}
}
this.executed(['connection.layout', 'connection.create'], cropConnection);
this.reverted(['connection.layout'], function (e) {
delete e.context.cropped;
}); // BPMN + DI update //////////////////////
// update parent
function updateParent(e) {
var context = e.context;
self.updateParent(context.shape || context.connection, context.oldParent);
}
function reverseUpdateParent(e) {
var context = e.context;
var element = context.shape || context.connection,
// oldParent is the (old) new parent, because we are undoing
oldParent = context.parent || context.newParent;
self.updateParent(element, oldParent);
}
this.executed(['shape.move', 'shape.create', 'shape.delete', 'connection.create', 'connection.move', 'connection.delete'], ifBpmn(updateParent));
this.reverted(['shape.move', 'shape.create', 'shape.delete', 'connection.create', 'connection.move', 'connection.delete'], ifBpmn(reverseUpdateParent));
/*
* ## Updating Parent
*
* When morphing a Process into a Collaboration or vice-versa,
* make sure that both the *semantic* and *di* parent of each element
* is updated.
*
*/
function updateRoot(event) {
var context = event.context,
oldRoot = context.oldRoot,
children = oldRoot.children;
(0, _minDash.forEach)(children, function (child) {
if ((0, _ModelUtil.is)(child, 'bpmn:BaseElement')) {
self.updateParent(child);
}
});
}
this.executed(['canvas.updateRoot'], updateRoot);
this.reverted(['canvas.updateRoot'], updateRoot); // update bounds
function updateBounds(e) {
var shape = e.context.shape;
if (!(0, _ModelUtil.is)(shape, 'bpmn:BaseElement')) {
return;
}
self.updateBounds(shape);
}
this.executed(['shape.move', 'shape.create', 'shape.resize'], ifBpmn(function (event) {
// exclude labels because they're handled separately during shape.changed
if (event.context.shape.type === 'label') {
return;
}
updateBounds(event);
}));
this.reverted(['shape.move', 'shape.create', 'shape.resize'], ifBpmn(function (event) {
// exclude labels because they're handled separately during shape.changed
if (event.context.shape.type === 'label') {
return;
}
updateBounds(event);
})); // Handle labels separately. This is necessary, because the label bounds have to be updated
// every time its shape changes, not only on move, create and resize.
eventBus.on('shape.changed', function (event) {
if (event.element.type === 'label') {
updateBounds({
context: {
shape: event.element
}
});
}
}); // attach / detach connection
function updateConnection(e) {
self.updateConnection(e.context);
}
this.executed(['connection.create', 'connection.move', 'connection.delete', 'connection.reconnect'], ifBpmn(updateConnection));
this.reverted(['connection.create', 'connection.move', 'connection.delete', 'connection.reconnect'], ifBpmn(updateConnection)); // update waypoints
function updateConnectionWaypoints(e) {
self.updateConnectionWaypoints(e.context.connection);
}
this.executed(['connection.layout', 'connection.move', 'connection.updateWaypoints'], ifBpmn(updateConnectionWaypoints));
this.reverted(['connection.layout', 'connection.move', 'connection.updateWaypoints'], ifBpmn(updateConnectionWaypoints)); // update conditional/default flows
this.executed('connection.reconnect', ifBpmn(function (event) {
var context = event.context,
connection = context.connection,
oldSource = context.oldSource,
newSource = context.newSource,
connectionBo = (0, _ModelUtil.getBusinessObject)(connection),
oldSourceBo = (0, _ModelUtil.getBusinessObject)(oldSource),
newSourceBo = (0, _ModelUtil.getBusinessObject)(newSource); // remove condition from connection on reconnect to new source
// if new source can NOT have condional sequence flow
if (connectionBo.conditionExpression && !(0, _ModelingUtil.isAny)(newSourceBo, ['bpmn:Activity', 'bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway'])) {
context.oldConditionExpression = connectionBo.conditionExpression;
delete connectionBo.conditionExpression;
} // remove default from old source flow on reconnect to new source
// if source changed
if (oldSource !== newSource && oldSourceBo.default === connectionBo) {
context.oldDefault = oldSourceBo.default;
delete oldSourceBo.default;
}
}));
this.reverted('connection.reconnect', ifBpmn(function (event) {
var context = event.context,
connection = context.connection,
oldSource = context.oldSource,
newSource = context.newSource,
connectionBo = (0, _ModelUtil.getBusinessObject)(connection),
oldSourceBo = (0, _ModelUtil.getBusinessObject)(oldSource),
newSourceBo = (0, _ModelUtil.getBusinessObject)(newSource); // add condition to connection on revert reconnect to new source
if (context.oldConditionExpression) {
connectionBo.conditionExpression = context.oldConditionExpression;
} // add default to old source on revert reconnect to new source
if (context.oldDefault) {
oldSourceBo.default = context.oldDefault;
delete newSourceBo.default;
}
})); // update attachments
function updateAttachment(e) {
self.updateAttachment(e.context);
}
this.executed(['element.updateAttachment'], ifBpmn(updateAttachment));
this.reverted(['element.updateAttachment'], ifBpmn(updateAttachment));
}
(0, _inherits.default)(BpmnUpdater, _CommandInterceptor.default);
BpmnUpdater.$inject = ['eventBus', 'bpmnFactory', 'connectionDocking', 'translate']; // implementation //////////////////////
BpmnUpdater.prototype.updateAttachment = function (context) {
var shape = context.shape,
businessObject = shape.businessObject,
host = shape.host;
businessObject.attachedToRef = host && host.businessObject;
};
BpmnUpdater.prototype.updateParent = function (element, oldParent) {
// do not update BPMN 2.0 label parent
if (element instanceof _model.Label) {
return;
} // data stores in collaborations are handled separately by DataStoreBehavior
if ((0, _ModelUtil.is)(element, 'bpmn:DataStoreReference') && element.parent && (0, _ModelUtil.is)(element.parent, 'bpmn:Collaboration')) {
return;
}
var parentShape = element.parent;
var businessObject = element.businessObject,
parentBusinessObject = parentShape && parentShape.businessObject,
parentDi = parentBusinessObject && parentBusinessObject.di;
if ((0, _ModelUtil.is)(element, 'bpmn:FlowNode')) {
this.updateFlowNodeRefs(businessObject, parentBusinessObject, oldParent && oldParent.businessObject);
}
if ((0, _ModelUtil.is)(element, 'bpmn:DataOutputAssociation')) {
if (element.source) {
parentBusinessObject = element.source.businessObject;
} else {
parentBusinessObject = null;
}
}
if ((0, _ModelUtil.is)(element, 'bpmn:DataInputAssociation')) {
if (element.target) {
parentBusinessObject = element.target.businessObject;
} else {
parentBusinessObject = null;
}
}
this.updateSemanticParent(businessObject, parentBusinessObject);
if ((0, _ModelUtil.is)(element, 'bpmn:DataObjectReference') && businessObject.dataObjectRef) {
this.updateSemanticParent(businessObject.dataObjectRef, parentBusinessObject);
}
this.updateDiParent(businessObject.di, parentDi);
};
BpmnUpdater.prototype.updateBounds = function (shape) {
var di = shape.businessObject.di;
var target = shape instanceof _model.Label ? this._getLabel(di) : di;
var bounds = target.bounds;
if (!bounds) {
bounds = this._bpmnFactory.createDiBounds();
target.set('bounds', bounds);
}
(0, _minDash.assign)(bounds, {
x: shape.x,
y: shape.y,
width: shape.width,
height: shape.height
});
};
BpmnUpdater.prototype.updateFlowNodeRefs = function (businessObject, newContainment, oldContainment) {
if (oldContainment === newContainment) {
return;
}
var oldRefs, newRefs;
if ((0, _ModelUtil.is)(oldContainment, 'bpmn:Lane')) {
oldRefs = oldContainment.get('flowNodeRef');
(0, _Collections.remove)(oldRefs, businessObject);
}
if ((0, _ModelUtil.is)(newContainment, 'bpmn:Lane')) {
newRefs = newContainment.get('flowNodeRef');
(0, _Collections.add)(newRefs, businessObject);
}
}; // update existing sourceElement and targetElement di information
BpmnUpdater.prototype.updateDiConnection = function (di, newSource, newTarget) {
if (di.sourceElement && di.sourceElement.bpmnElement !== newSource) {
di.sourceElement = newSource && newSource.di;
}
if (di.targetElement && di.targetElement.bpmnElement !== newTarget) {
di.targetElement = newTarget && newTarget.di;
}
};
BpmnUpdater.prototype.updateDiParent = function (di, parentDi) {
if (parentDi && !(0, _ModelUtil.is)(parentDi, 'bpmndi:BPMNPlane')) {
parentDi = parentDi.$parent;
}
if (di.$parent === parentDi) {
return;
}
var planeElements = (parentDi || di.$parent).get('planeElement');
if (parentDi) {
planeElements.push(di);
di.$parent = parentDi;
} else {
(0, _Collections.remove)(planeElements, di);
di.$parent = null;
}
};
function getDefinitions(element) {
while (element && !(0, _ModelUtil.is)(element, 'bpmn:Definitions')) {
element = element.$parent;
}
return element;
}
BpmnUpdater.prototype.getLaneSet = function (container) {
var laneSet, laneSets; // bpmn:Lane
if ((0, _ModelUtil.is)(container, 'bpmn:Lane')) {
laneSet = container.childLaneSet;
if (!laneSet) {
laneSet = this._bpmnFactory.create('bpmn:LaneSet');
container.childLaneSet = laneSet;
laneSet.$parent = container;
}
return laneSet;
} // bpmn:Participant
if ((0, _ModelUtil.is)(container, 'bpmn:Participant')) {
container = container.processRef;
} // bpmn:FlowElementsContainer
laneSets = container.get('laneSets');
laneSet = laneSets[0];
if (!laneSet) {
laneSet = this._bpmnFactory.create('bpmn:LaneSet');
laneSet.$parent = container;
laneSets.push(laneSet);
}
return laneSet;
};
BpmnUpdater.prototype.updateSemanticParent = function (businessObject, newParent, visualParent) {
var containment,
translate = this._translate;
if (businessObject.$parent === newParent) {
return;
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataInput') || (0, _ModelUtil.is)(businessObject, 'bpmn:DataOutput')) {
if ((0, _ModelUtil.is)(newParent, 'bpmn:Participant') && 'processRef' in newParent) {
newParent = newParent.processRef;
} // already in correct ioSpecification
if ('ioSpecification' in newParent && newParent.ioSpecification === businessObject.$parent) {
return;
}
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Lane')) {
if (newParent) {
newParent = this.getLaneSet(newParent);
}
containment = 'lanes';
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:FlowElement')) {
if (newParent) {
if ((0, _ModelUtil.is)(newParent, 'bpmn:Participant')) {
newParent = newParent.processRef;
} else if ((0, _ModelUtil.is)(newParent, 'bpmn:Lane')) {
do {
// unwrap Lane -> LaneSet -> (Lane | FlowElementsContainer)
newParent = newParent.$parent.$parent;
} while ((0, _ModelUtil.is)(newParent, 'bpmn:Lane'));
}
}
containment = 'flowElements';
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:Artifact')) {
while (newParent && !(0, _ModelUtil.is)(newParent, 'bpmn:Process') && !(0, _ModelUtil.is)(newParent, 'bpmn:SubProcess') && !(0, _ModelUtil.is)(newParent, 'bpmn:Collaboration')) {
if ((0, _ModelUtil.is)(newParent, 'bpmn:Participant')) {
newParent = newParent.processRef;
break;
} else {
newParent = newParent.$parent;
}
}
containment = 'artifacts';
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:MessageFlow')) {
containment = 'messageFlows';
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:Participant')) {
containment = 'participants'; // make sure the participants process is properly attached / detached
// from the XML document
var process = businessObject.processRef,
definitions;
if (process) {
definitions = getDefinitions(businessObject.$parent || newParent);
if (businessObject.$parent) {
(0, _Collections.remove)(definitions.get('rootElements'), process);
process.$parent = null;
}
if (newParent) {
(0, _Collections.add)(definitions.get('rootElements'), process);
process.$parent = definitions;
}
}
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataOutputAssociation')) {
containment = 'dataOutputAssociations';
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataInputAssociation')) {
containment = 'dataInputAssociations';
}
if (!containment) {
throw new Error(translate('no parent for {element} in {parent}', {
element: businessObject.id,
parent: newParent.id
}));
}
var children;
if (businessObject.$parent) {
// remove from old parent
children = businessObject.$parent.get(containment);
(0, _Collections.remove)(children, businessObject);
}
if (!newParent) {
businessObject.$parent = null;
} else {
// add to new parent
children = newParent.get(containment);
children.push(businessObject);
businessObject.$parent = newParent;
}
if (visualParent) {
var diChildren = visualParent.get(containment);
(0, _Collections.remove)(children, businessObject);
if (newParent) {
if (!diChildren) {
diChildren = [];
newParent.set(containment, diChildren);
}
diChildren.push(businessObject);
}
}
};
BpmnUpdater.prototype.updateConnectionWaypoints = function (connection) {
connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
};
BpmnUpdater.prototype.updateConnection = function (context) {
var connection = context.connection,
businessObject = (0, _ModelUtil.getBusinessObject)(connection),
newSource = (0, _ModelUtil.getBusinessObject)(connection.source),
newTarget = (0, _ModelUtil.getBusinessObject)(connection.target),
visualParent;
if (!(0, _ModelUtil.is)(businessObject, 'bpmn:DataAssociation')) {
var inverseSet = (0, _ModelUtil.is)(businessObject, 'bpmn:SequenceFlow');
if (businessObject.sourceRef !== newSource) {
if (inverseSet) {
(0, _Collections.remove)(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject);
if (newSource && newSource.get('outgoing')) {
newSource.get('outgoing').push(businessObject);
}
}
businessObject.sourceRef = newSource;
}
if (businessObject.targetRef !== newTarget) {
if (inverseSet) {
(0, _Collections.remove)(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject);
if (newTarget && newTarget.get('incoming')) {
newTarget.get('incoming').push(businessObject);
}
}
businessObject.targetRef = newTarget;
}
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataInputAssociation')) {
// handle obnoxious isMsome sourceRef
businessObject.get('sourceRef')[0] = newSource;
visualParent = context.parent || context.newParent || newTarget;
this.updateSemanticParent(businessObject, newTarget, visualParent);
} else if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataOutputAssociation')) {
visualParent = context.parent || context.newParent || newSource;
this.updateSemanticParent(businessObject, newSource, visualParent); // targetRef = new target
businessObject.targetRef = newTarget;
}
this.updateConnectionWaypoints(connection);
this.updateDiConnection(businessObject.di, newSource, newTarget);
}; // helpers //////////////////////
BpmnUpdater.prototype._getLabel = function (di) {
if (!di.label) {
di.label = this._bpmnFactory.createDiLabel();
}
return di.label;
};
/**
* Make sure the event listener is only called
* if the touched element is a BPMN element.
*
* @param {Function} fn
* @return {Function} guarded function
*/
function ifBpmn(fn) {
return function (event) {
var context = event.context,
element = context.shape || context.connection;
if ((0, _ModelUtil.is)(element, 'bpmn:BaseElement')) {
fn(event);
}
};
}
},{"../../util/ModelUtil":142,"./util/ModelingUtil":113,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/model":304,"diagram-js/lib/util/Collections":315,"inherits":349,"min-dash":559}],59:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ElementFactory;
var _minDash = require("min-dash");
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../util/ModelUtil");
var _DiUtil = require("../../util/DiUtil");
var _ElementFactory = _interopRequireDefault(require("diagram-js/lib/core/ElementFactory"));
var _LabelUtil = require("../../util/LabelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* A bpmn-aware factory for diagram-js shapes
*/
function ElementFactory(bpmnFactory, moddle, translate) {
_ElementFactory.default.call(this);
this._bpmnFactory = bpmnFactory;
this._moddle = moddle;
this._translate = translate;
}
(0, _inherits.default)(ElementFactory, _ElementFactory.default);
ElementFactory.$inject = ['bpmnFactory', 'moddle', 'translate'];
ElementFactory.prototype.baseCreate = _ElementFactory.default.prototype.create;
ElementFactory.prototype.create = function (elementType, attrs) {
// no special magic for labels,
// we assume their businessObjects have already been created
// and wired via attrs
if (elementType === 'label') {
return this.baseCreate(elementType, (0, _minDash.assign)({
type: 'label'
}, _LabelUtil.DEFAULT_LABEL_SIZE, attrs));
}
return this.createBpmnElement(elementType, attrs);
};
ElementFactory.prototype.createBpmnElement = function (elementType, attrs) {
var size,
translate = this._translate;
attrs = attrs || {};
var businessObject = attrs.businessObject;
if (!businessObject) {
if (!attrs.type) {
throw new Error(translate('no shape type specified'));
}
businessObject = this._bpmnFactory.create(attrs.type);
}
if (!businessObject.di) {
if (elementType === 'root') {
businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], {
id: businessObject.id + '_di'
});
} else if (elementType === 'connection') {
businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], {
id: businessObject.id + '_di'
});
} else {
businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, {
id: businessObject.id + '_di'
});
}
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Group')) {
attrs = (0, _minDash.assign)({
isFrame: true
}, attrs);
}
if (attrs.di) {
(0, _minDash.assign)(businessObject.di, attrs.di);
delete attrs.di;
}
applyAttributes(businessObject, attrs, ['processRef', 'isInterrupting', 'associationDirection', 'isForCompensation']);
if (attrs.isExpanded) {
applyAttribute(businessObject.di, attrs, 'isExpanded');
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:ExclusiveGateway')) {
businessObject.di.isMarkerVisible = true;
}
var eventDefinitions, newEventDefinition;
if (attrs.eventDefinitionType) {
eventDefinitions = businessObject.get('eventDefinitions') || [];
newEventDefinition = this._bpmnFactory.create(attrs.eventDefinitionType, attrs.eventDefinitionAttrs);
if (attrs.eventDefinitionType === 'bpmn:ConditionalEventDefinition') {
newEventDefinition.condition = this._bpmnFactory.create('bpmn:FormalExpression');
}
eventDefinitions.push(newEventDefinition);
newEventDefinition.$parent = businessObject;
businessObject.eventDefinitions = eventDefinitions;
delete attrs.eventDefinitionType;
}
size = this._getDefaultSize(businessObject);
attrs = (0, _minDash.assign)({
businessObject: businessObject,
id: businessObject.id
}, size, attrs);
return this.baseCreate(elementType, attrs);
};
ElementFactory.prototype._getDefaultSize = function (semantic) {
if ((0, _ModelUtil.is)(semantic, 'bpmn:SubProcess')) {
if ((0, _DiUtil.isExpanded)(semantic)) {
return {
width: 350,
height: 200
};
} else {
return {
width: 100,
height: 80
};
}
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Task')) {
return {
width: 100,
height: 80
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Gateway')) {
return {
width: 50,
height: 50
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Event')) {
return {
width: 36,
height: 36
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Participant')) {
if ((0, _DiUtil.isExpanded)(semantic)) {
return {
width: 600,
height: 250
};
} else {
return {
width: 400,
height: 60
};
}
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Lane')) {
return {
width: 400,
height: 100
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:DataObjectReference')) {
return {
width: 36,
height: 50
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:DataStoreReference')) {
return {
width: 50,
height: 50
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:TextAnnotation')) {
return {
width: 100,
height: 30
};
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:Group')) {
return {
width: 300,
height: 300
};
}
return {
width: 100,
height: 80
};
};
/**
* Create participant.
*
* @param {boolean|Object} [attrs] attrs
*
* @returns {djs.model.Shape}
*/
ElementFactory.prototype.createParticipantShape = function (attrs) {
if (!(0, _minDash.isObject)(attrs)) {
attrs = {
isExpanded: attrs
};
}
attrs = (0, _minDash.assign)({
type: 'bpmn:Participant'
}, attrs || {}); // participants are expanded by default
if (attrs.isExpanded !== false) {
attrs.processRef = this._bpmnFactory.create('bpmn:Process');
}
return this.createShape(attrs);
}; // helpers //////////////////////
/**
* Apply attributes from a map to the given element,
* remove attribute from the map on application.
*
* @param {Base} element
* @param {Object} attrs (in/out map of attributes)
* @param {Array} attributeNames name of attributes to apply
*/
function applyAttributes(element, attrs, attributeNames) {
(0, _minDash.forEach)(attributeNames, function (property) {
if (attrs[property] !== undefined) {
applyAttribute(element, attrs, property);
}
});
}
/**
* Apply named property to element and drain it from the attrs
* collection.
*
* @param {Base} element
* @param {Object} attrs (in/out map of attributes)
* @param {string} attributeName to apply
*/
function applyAttribute(element, attrs, attributeName) {
element[attributeName] = attrs[attributeName];
delete attrs[attributeName];
}
},{"../../util/DiUtil":140,"../../util/LabelUtil":141,"../../util/ModelUtil":142,"diagram-js/lib/core/ElementFactory":150,"inherits":349,"min-dash":559}],60:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Modeling;
var _inherits = _interopRequireDefault(require("inherits"));
var _Modeling = _interopRequireDefault(require("diagram-js/lib/features/modeling/Modeling"));
var _UpdateModdlePropertiesHandler = _interopRequireDefault(require("./cmd/UpdateModdlePropertiesHandler"));
var _UpdatePropertiesHandler = _interopRequireDefault(require("./cmd/UpdatePropertiesHandler"));
var _UpdateCanvasRootHandler = _interopRequireDefault(require("./cmd/UpdateCanvasRootHandler"));
var _AddLaneHandler = _interopRequireDefault(require("./cmd/AddLaneHandler"));
var _SplitLaneHandler = _interopRequireDefault(require("./cmd/SplitLaneHandler"));
var _ResizeLaneHandler = _interopRequireDefault(require("./cmd/ResizeLaneHandler"));
var _UpdateFlowNodeRefsHandler = _interopRequireDefault(require("./cmd/UpdateFlowNodeRefsHandler"));
var _IdClaimHandler = _interopRequireDefault(require("./cmd/IdClaimHandler"));
var _SetColorHandler = _interopRequireDefault(require("./cmd/SetColorHandler"));
var _UpdateLabelHandler = _interopRequireDefault(require("../label-editing/cmd/UpdateLabelHandler"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN 2.0 modeling features activator
*
* @param {EventBus} eventBus
* @param {ElementFactory} elementFactory
* @param {CommandStack} commandStack
* @param {BpmnRules} bpmnRules
*/
function Modeling(eventBus, elementFactory, commandStack, bpmnRules) {
_Modeling.default.call(this, eventBus, elementFactory, commandStack);
this._bpmnRules = bpmnRules;
}
(0, _inherits.default)(Modeling, _Modeling.default);
Modeling.$inject = ['eventBus', 'elementFactory', 'commandStack', 'bpmnRules'];
Modeling.prototype.getHandlers = function () {
var handlers = _Modeling.default.prototype.getHandlers.call(this);
handlers['element.updateModdleProperties'] = _UpdateModdlePropertiesHandler.default;
handlers['element.updateProperties'] = _UpdatePropertiesHandler.default;
handlers['canvas.updateRoot'] = _UpdateCanvasRootHandler.default;
handlers['lane.add'] = _AddLaneHandler.default;
handlers['lane.resize'] = _ResizeLaneHandler.default;
handlers['lane.split'] = _SplitLaneHandler.default;
handlers['lane.updateRefs'] = _UpdateFlowNodeRefsHandler.default;
handlers['id.updateClaim'] = _IdClaimHandler.default;
handlers['element.setColor'] = _SetColorHandler.default;
handlers['element.updateLabel'] = _UpdateLabelHandler.default;
return handlers;
};
Modeling.prototype.updateLabel = function (element, newLabel, newBounds, hints) {
this._commandStack.execute('element.updateLabel', {
element: element,
newLabel: newLabel,
newBounds: newBounds,
hints: hints || {}
});
};
Modeling.prototype.connect = function (source, target, attrs, hints) {
var bpmnRules = this._bpmnRules;
if (!attrs) {
attrs = bpmnRules.canConnect(source, target);
}
if (!attrs) {
return;
}
return this.createConnection(source, target, attrs, source.parent, hints);
};
Modeling.prototype.updateModdleProperties = function (element, moddleElement, properties) {
this._commandStack.execute('element.updateModdleProperties', {
element: element,
moddleElement: moddleElement,
properties: properties
});
};
Modeling.prototype.updateProperties = function (element, properties) {
this._commandStack.execute('element.updateProperties', {
element: element,
properties: properties
});
};
Modeling.prototype.resizeLane = function (laneShape, newBounds, balanced) {
this._commandStack.execute('lane.resize', {
shape: laneShape,
newBounds: newBounds,
balanced: balanced
});
};
Modeling.prototype.addLane = function (targetLaneShape, location) {
var context = {
shape: targetLaneShape,
location: location
};
this._commandStack.execute('lane.add', context);
return context.newLane;
};
Modeling.prototype.splitLane = function (targetLane, count) {
this._commandStack.execute('lane.split', {
shape: targetLane,
count: count
});
};
/**
* Transform the current diagram into a collaboration.
*
* @return {djs.model.Root} the new root element
*/
Modeling.prototype.makeCollaboration = function () {
var collaborationElement = this._create('root', {
type: 'bpmn:Collaboration'
});
var context = {
newRoot: collaborationElement
};
this._commandStack.execute('canvas.updateRoot', context);
return collaborationElement;
};
Modeling.prototype.updateLaneRefs = function (flowNodeShapes, laneShapes) {
this._commandStack.execute('lane.updateRefs', {
flowNodeShapes: flowNodeShapes,
laneShapes: laneShapes
});
};
/**
* Transform the current diagram into a process.
*
* @return {djs.model.Root} the new root element
*/
Modeling.prototype.makeProcess = function () {
var processElement = this._create('root', {
type: 'bpmn:Process'
});
var context = {
newRoot: processElement
};
this._commandStack.execute('canvas.updateRoot', context);
};
Modeling.prototype.claimId = function (id, moddleElement) {
this._commandStack.execute('id.updateClaim', {
id: id,
element: moddleElement,
claiming: true
});
};
Modeling.prototype.unclaimId = function (id, moddleElement) {
this._commandStack.execute('id.updateClaim', {
id: id,
element: moddleElement
});
};
Modeling.prototype.setColor = function (elements, colors) {
if (!elements.length) {
elements = [elements];
}
this._commandStack.execute('element.setColor', {
elements: elements,
colors: colors
});
};
},{"../label-editing/cmd/UpdateLabelHandler":54,"./cmd/AddLaneHandler":101,"./cmd/IdClaimHandler":102,"./cmd/ResizeLaneHandler":103,"./cmd/SetColorHandler":104,"./cmd/SplitLaneHandler":105,"./cmd/UpdateCanvasRootHandler":106,"./cmd/UpdateFlowNodeRefsHandler":107,"./cmd/UpdateModdlePropertiesHandler":108,"./cmd/UpdatePropertiesHandler":109,"diagram-js/lib/features/modeling/Modeling":224,"inherits":349}],61:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AdaptiveLabelPositioningBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _Math = require("diagram-js/lib/util/Math");
var _LabelUtil = require("../../../util/LabelUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ALIGNMENTS = ['top', 'bottom', 'left', 'right'];
var ELEMENT_LABEL_DISTANCE = 10;
/**
* A component that makes sure that external labels are added
* together with respective elements and properly updated (DI wise)
* during move.
*
* @param {EventBus} eventBus
* @param {Modeling} modeling
*/
function AdaptiveLabelPositioningBehavior(eventBus, modeling) {
_CommandInterceptor.default.call(this, eventBus);
this.postExecuted(['connection.create', 'connection.layout', 'connection.updateWaypoints'], function (event) {
var context = event.context,
connection = context.connection,
source = connection.source,
target = connection.target,
hints = context.hints || {};
if (hints.createElementsBehavior !== false) {
checkLabelAdjustment(source);
checkLabelAdjustment(target);
}
});
this.postExecuted(['label.create'], function (event) {
var context = event.context,
shape = context.shape,
hints = context.hints || {};
if (hints.createElementsBehavior !== false) {
checkLabelAdjustment(shape.labelTarget);
}
});
this.postExecuted(['elements.create'], function (event) {
var context = event.context,
elements = context.elements,
hints = context.hints || {};
if (hints.createElementsBehavior !== false) {
elements.forEach(function (element) {
checkLabelAdjustment(element);
});
}
});
function checkLabelAdjustment(element) {
// skip non-existing labels
if (!(0, _LabelUtil.hasExternalLabel)(element)) {
return;
}
var optimalPosition = getOptimalPosition(element); // no optimal position found
if (!optimalPosition) {
return;
}
adjustLabelPosition(element, optimalPosition);
}
function adjustLabelPosition(element, orientation) {
var elementMid = (0, _LayoutUtil.getMid)(element),
label = element.label,
labelMid = (0, _LayoutUtil.getMid)(label); // ignore labels that are being created
if (!label.parent) {
return;
}
var elementTrbl = (0, _LayoutUtil.asTRBL)(element);
var newLabelMid;
switch (orientation) {
case 'top':
newLabelMid = {
x: elementMid.x,
y: elementTrbl.top - ELEMENT_LABEL_DISTANCE - label.height / 2
};
break;
case 'left':
newLabelMid = {
x: elementTrbl.left - ELEMENT_LABEL_DISTANCE - label.width / 2,
y: elementMid.y
};
break;
case 'bottom':
newLabelMid = {
x: elementMid.x,
y: elementTrbl.bottom + ELEMENT_LABEL_DISTANCE + label.height / 2
};
break;
case 'right':
newLabelMid = {
x: elementTrbl.right + ELEMENT_LABEL_DISTANCE + label.width / 2,
y: elementMid.y
};
break;
}
var delta = (0, _Math.substract)(newLabelMid, labelMid);
modeling.moveShape(label, delta);
}
}
(0, _inherits.default)(AdaptiveLabelPositioningBehavior, _CommandInterceptor.default);
AdaptiveLabelPositioningBehavior.$inject = ['eventBus', 'modeling']; // helpers //////////////////////
/**
* Return alignments which are taken by a boundary's host element
*
* @param {Shape} element
*
* @return {Array}
*/
function getTakenHostAlignments(element) {
var hostElement = element.host,
elementMid = (0, _LayoutUtil.getMid)(element),
hostOrientation = (0, _LayoutUtil.getOrientation)(elementMid, hostElement);
var freeAlignments; // check whether there is a multi-orientation, e.g. 'top-left'
if (hostOrientation.indexOf('-') >= 0) {
freeAlignments = hostOrientation.split('-');
} else {
freeAlignments = [hostOrientation];
}
var takenAlignments = ALIGNMENTS.filter(function (alignment) {
return freeAlignments.indexOf(alignment) === -1;
});
return takenAlignments;
}
/**
* Return alignments which are taken by related connections
*
* @param {Shape} element
*
* @return {Array}
*/
function getTakenConnectionAlignments(element) {
var elementMid = (0, _LayoutUtil.getMid)(element);
var takenAlignments = [].concat(element.incoming.map(function (c) {
return c.waypoints[c.waypoints.length - 2];
}), element.outgoing.map(function (c) {
return c.waypoints[1];
})).map(function (point) {
return getApproximateOrientation(elementMid, point);
});
return takenAlignments;
}
/**
* Return the optimal label position around an element
* or _undefined_, if none was found.
*
* @param {Shape} element
*
* @return {string} positioning identifier
*/
function getOptimalPosition(element) {
var labelMid = (0, _LayoutUtil.getMid)(element.label);
var elementMid = (0, _LayoutUtil.getMid)(element);
var labelOrientation = getApproximateOrientation(elementMid, labelMid);
if (!isAligned(labelOrientation)) {
return;
}
var takenAlignments = getTakenConnectionAlignments(element);
if (element.host) {
var takenHostAlignments = getTakenHostAlignments(element);
takenAlignments = takenAlignments.concat(takenHostAlignments);
}
var freeAlignments = ALIGNMENTS.filter(function (alignment) {
return takenAlignments.indexOf(alignment) === -1;
}); // NOTHING TO DO; label already aligned a.O.K.
if (freeAlignments.indexOf(labelOrientation) !== -1) {
return;
}
return freeAlignments[0];
}
function getApproximateOrientation(p0, p1) {
return (0, _LayoutUtil.getOrientation)(p1, p0, 5);
}
function isAligned(orientation) {
return ALIGNMENTS.indexOf(orientation) !== -1;
}
},{"../../../util/LabelUtil":141,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/Math":324,"inherits":349}],62:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AppendBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../../util/ModelUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function AppendBehavior(eventBus, elementFactory, bpmnRules) {
_CommandInterceptor.default.call(this, eventBus); // assign correct shape position unless already set
this.preExecute('shape.append', function (context) {
var source = context.source,
shape = context.shape;
if (!context.position) {
if ((0, _ModelUtil.is)(shape, 'bpmn:TextAnnotation')) {
context.position = {
x: source.x + source.width / 2 + 75,
y: source.y - 50 - shape.height / 2
};
} else {
context.position = {
x: source.x + source.width + 80 + shape.width / 2,
y: source.y + source.height / 2
};
}
}
}, true);
}
(0, _inherits.default)(AppendBehavior, _CommandInterceptor.default);
AppendBehavior.$inject = ['eventBus', 'elementFactory', 'bpmnRules'];
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],63:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AssociationBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../../util/ModelUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _minDash = require("min-dash");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function AssociationBehavior(injector, modeling) {
injector.invoke(_CommandInterceptor.default, this);
this.postExecute('shape.move', function (context) {
var newParent = context.newParent,
shape = context.shape;
var associations = (0, _minDash.filter)(shape.incoming.concat(shape.outgoing), function (connection) {
return (0, _ModelUtil.is)(connection, 'bpmn:Association');
});
(0, _minDash.forEach)(associations, function (association) {
modeling.moveConnection(association, {
x: 0,
y: 0
}, newParent);
});
}, true);
}
(0, _inherits.default)(AssociationBehavior, _CommandInterceptor.default);
AssociationBehavior.$inject = ['injector', 'modeling'];
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349,"min-dash":559}],64:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AttachEventBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _ModelingUtil = require("../util/ModelingUtil");
var _LabelUtil = require("../../../util/LabelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 500;
/**
* Replace intermediate event with boundary event when creating or moving results in attached event.
*/
function AttachEventBehavior(bpmnReplace, injector) {
injector.invoke(_CommandInterceptor.default, this);
this._bpmnReplace = bpmnReplace;
var self = this;
this.postExecuted('elements.create', LOW_PRIORITY, function (context) {
var elements = context.elements;
elements = elements.filter(function (shape) {
var host = shape.host;
return shouldReplace(shape, host);
});
if (elements.length !== 1) {
return;
}
elements.map(function (element) {
return elements.indexOf(element);
}).forEach(function (index) {
var host = elements[index];
context.elements[index] = self.replaceShape(elements[index], host);
});
}, true);
this.preExecute('elements.move', LOW_PRIORITY, function (context) {
var shapes = context.shapes,
host = context.newHost;
if (shapes.length !== 1) {
return;
}
var shape = shapes[0];
if (shouldReplace(shape, host)) {
context.shapes = [self.replaceShape(shape, host)];
}
}, true);
}
AttachEventBehavior.$inject = ['bpmnReplace', 'injector'];
(0, _inherits.default)(AttachEventBehavior, _CommandInterceptor.default);
AttachEventBehavior.prototype.replaceShape = function (shape, host) {
var eventDefinition = getEventDefinition(shape);
var boundaryEvent = {
type: 'bpmn:BoundaryEvent',
host: host
};
if (eventDefinition) {
boundaryEvent.eventDefinitionType = eventDefinition.$type;
}
return this._bpmnReplace.replaceElement(shape, boundaryEvent, {
layoutConnection: false
});
}; // helpers //////////
function getEventDefinition(element) {
var businessObject = (0, _ModelUtil.getBusinessObject)(element),
eventDefinitions = businessObject.eventDefinitions;
return eventDefinitions && eventDefinitions[0];
}
function shouldReplace(shape, host) {
return !(0, _LabelUtil.isLabel)(shape) && (0, _ModelingUtil.isAny)(shape, ['bpmn:IntermediateThrowEvent', 'bpmn:IntermediateCatchEvent']) && !!host;
}
},{"../../../util/LabelUtil":141,"../../../util/ModelUtil":142,"../util/ModelingUtil":113,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],65:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BoundaryEventBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _minDash = require("min-dash");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN specific boundary event behavior
*/
function BoundaryEventBehavior(eventBus, modeling) {
_CommandInterceptor.default.call(this, eventBus);
function getBoundaryEvents(element) {
return (0, _minDash.filter)(element.attachers, function (attacher) {
return (0, _ModelUtil.is)(attacher, 'bpmn:BoundaryEvent');
});
} // remove after connecting to event-based gateway
this.postExecute('connection.create', function (event) {
var source = event.context.source,
target = event.context.target,
boundaryEvents = getBoundaryEvents(target);
if ((0, _ModelUtil.is)(source, 'bpmn:EventBasedGateway') && (0, _ModelUtil.is)(target, 'bpmn:ReceiveTask') && boundaryEvents.length > 0) {
modeling.removeElements(boundaryEvents);
}
}); // remove after replacing connected gateway with event-based gateway
this.postExecute('connection.reconnect', function (event) {
var oldSource = event.context.oldSource,
newSource = event.context.newSource;
if ((0, _ModelUtil.is)(oldSource, 'bpmn:Gateway') && (0, _ModelUtil.is)(newSource, 'bpmn:EventBasedGateway')) {
(0, _minDash.forEach)(newSource.outgoing, function (connection) {
var target = connection.target,
attachedboundaryEvents = getBoundaryEvents(target);
if ((0, _ModelUtil.is)(target, 'bpmn:ReceiveTask') && attachedboundaryEvents.length > 0) {
modeling.removeElements(attachedboundaryEvents);
}
});
}
});
}
BoundaryEventBehavior.$inject = ['eventBus', 'modeling'];
(0, _inherits.default)(BoundaryEventBehavior, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349,"min-dash":559}],66:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CreateBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../../util/ModelUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelingUtil = require("../util/ModelingUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function CreateBehavior(injector) {
injector.invoke(_CommandInterceptor.default, this);
this.preExecute('shape.create', 1500, function (event) {
var context = event.context,
parent = context.parent,
shape = context.shape;
if ((0, _ModelUtil.is)(parent, 'bpmn:Lane') && !(0, _ModelUtil.is)(shape, 'bpmn:Lane')) {
context.parent = (0, _ModelingUtil.getParent)(parent, 'bpmn:Participant');
}
});
}
CreateBehavior.$inject = ['injector'];
(0, _inherits.default)(CreateBehavior, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"../util/ModelingUtil":113,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],67:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CreateDataObjectBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN specific create data object behavior
*/
function CreateDataObjectBehavior(eventBus, bpmnFactory, moddle) {
_CommandInterceptor.default.call(this, eventBus);
this.preExecute('shape.create', function (event) {
var context = event.context,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:DataObjectReference') && shape.type !== 'label') {
// create a DataObject every time a DataObjectReference is created
var dataObject = bpmnFactory.create('bpmn:DataObject'); // set the reference to the DataObject
shape.businessObject.dataObjectRef = dataObject;
}
});
}
CreateDataObjectBehavior.$inject = ['eventBus', 'bpmnFactory', 'moddle'];
(0, _inherits.default)(CreateDataObjectBehavior, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],68:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PARTICIPANT_BORDER_WIDTH = void 0;
exports.default = CreateParticipantBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _LabelUtil = require("../../../util/LabelUtil");
var _Elements = require("diagram-js/lib/util/Elements");
var _minDash = require("min-dash");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var HORIZONTAL_PARTICIPANT_PADDING = 20,
VERTICAL_PARTICIPANT_PADDING = 20;
var PARTICIPANT_BORDER_WIDTH = 30;
exports.PARTICIPANT_BORDER_WIDTH = PARTICIPANT_BORDER_WIDTH;
var HIGH_PRIORITY = 2000;
/**
* BPMN-specific behavior for creating participants.
*/
function CreateParticipantBehavior(canvas, eventBus, modeling) {
_CommandInterceptor.default.call(this, eventBus); // fit participant
eventBus.on(['create.start', 'shape.move.start'], HIGH_PRIORITY, function (event) {
var context = event.context,
shape = context.shape,
rootElement = canvas.getRootElement();
if (!(0, _ModelUtil.is)(shape, 'bpmn:Participant') || !(0, _ModelUtil.is)(rootElement, 'bpmn:Process') || !rootElement.children.length) {
return;
} // ignore connections, groups and labels
var children = rootElement.children.filter(function (element) {
return !(0, _ModelUtil.is)(element, 'bpmn:Group') && !(0, _LabelUtil.isLabel)(element) && !isConnection(element);
}); // ensure for available children to calculate bounds
if (!children.length) {
return;
}
var childrenBBox = (0, _Elements.getBBox)(children);
var participantBounds = getParticipantBounds(shape, childrenBBox); // assign width and height
(0, _minDash.assign)(shape, participantBounds); // assign create constraints
context.createConstraints = getParticipantCreateConstraints(shape, childrenBBox);
}); // force hovering process when creating first participant
eventBus.on('create.start', HIGH_PRIORITY, function (event) {
var context = event.context,
shape = context.shape,
rootElement = canvas.getRootElement(),
rootElementGfx = canvas.getGraphics(rootElement);
function ensureHoveringProcess(event) {
event.element = rootElement;
event.gfx = rootElementGfx;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant') && (0, _ModelUtil.is)(rootElement, 'bpmn:Process')) {
eventBus.on('element.hover', HIGH_PRIORITY, ensureHoveringProcess);
eventBus.once('create.cleanup', function () {
eventBus.off('element.hover', ensureHoveringProcess);
});
}
});
function ensureCollaboration(context) {
var parent = context.parent,
collaboration;
var rootElement = canvas.getRootElement();
if ((0, _ModelUtil.is)(rootElement, 'bpmn:Collaboration')) {
collaboration = rootElement;
} else {
// update root element by making collaboration
collaboration = modeling.makeCollaboration(); // re-use process when creating first participant
context.process = parent;
}
context.parent = collaboration;
} // turn process into collaboration before adding participant
this.preExecute('shape.create', function (context) {
var parent = context.parent,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant') && (0, _ModelUtil.is)(parent, 'bpmn:Process')) {
ensureCollaboration(context);
}
}, true);
this.execute('shape.create', function (context) {
var process = context.process,
shape = context.shape;
if (process) {
context.oldProcessRef = shape.businessObject.processRef; // re-use process when creating first participant
shape.businessObject.processRef = process.businessObject;
}
}, true);
this.revert('shape.create', function (context) {
var process = context.process,
shape = context.shape;
if (process) {
// re-use process when creating first participant
shape.businessObject.processRef = context.oldProcessRef;
}
}, true);
this.postExecute('shape.create', function (context) {
var process = context.process,
shape = context.shape;
if (process) {
// move children from process to participant
var processChildren = process.children.slice();
modeling.moveElements(processChildren, {
x: 0,
y: 0
}, shape);
}
}, true); // turn process into collaboration when creating participants
this.preExecute('elements.create', HIGH_PRIORITY, function (context) {
var elements = context.elements,
parent = context.parent,
participant;
var hasParticipants = findParticipant(elements);
if (hasParticipants && (0, _ModelUtil.is)(parent, 'bpmn:Process')) {
ensureCollaboration(context);
participant = findParticipant(elements);
context.oldProcessRef = participant.businessObject.processRef; // re-use process when creating first participant
participant.businessObject.processRef = parent.businessObject;
}
}, true);
this.revert('elements.create', function (context) {
var elements = context.elements,
process = context.process,
participant;
if (process) {
participant = findParticipant(elements); // re-use process when creating first participant
participant.businessObject.processRef = context.oldProcessRef;
}
}, true);
this.postExecute('elements.create', function (context) {
var elements = context.elements,
process = context.process,
participant;
if (process) {
participant = findParticipant(elements); // move children from process to first participant
var processChildren = process.children.slice();
modeling.moveElements(processChildren, {
x: 0,
y: 0
}, participant);
}
}, true);
}
CreateParticipantBehavior.$inject = ['canvas', 'eventBus', 'modeling'];
(0, _inherits.default)(CreateParticipantBehavior, _CommandInterceptor.default); // helpers //////////
function getParticipantBounds(shape, childrenBBox) {
childrenBBox = {
width: childrenBBox.width + HORIZONTAL_PARTICIPANT_PADDING * 2 + PARTICIPANT_BORDER_WIDTH,
height: childrenBBox.height + VERTICAL_PARTICIPANT_PADDING * 2
};
var width = Math.max(shape.width, childrenBBox.width),
height = Math.max(shape.height, childrenBBox.height);
return {
x: -width / 2,
y: -height / 2,
width: width,
height: height
};
}
function getParticipantCreateConstraints(shape, childrenBBox) {
childrenBBox = (0, _LayoutUtil.asTRBL)(childrenBBox);
return {
bottom: childrenBBox.top + shape.height / 2 - VERTICAL_PARTICIPANT_PADDING,
left: childrenBBox.right - shape.width / 2 + HORIZONTAL_PARTICIPANT_PADDING,
top: childrenBBox.bottom - shape.height / 2 + VERTICAL_PARTICIPANT_PADDING,
right: childrenBBox.left + shape.width / 2 - HORIZONTAL_PARTICIPANT_PADDING - PARTICIPANT_BORDER_WIDTH
};
}
function isConnection(element) {
return !!element.waypoints;
}
function findParticipant(elements) {
return (0, _minDash.find)(elements, function (element) {
return (0, _ModelUtil.is)(element, 'bpmn:Participant');
});
}
},{"../../../util/LabelUtil":141,"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/Elements":317,"inherits":349,"min-dash":559}],69:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DataInputAssociationBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _Collections = require("diagram-js/lib/util/Collections");
var _minDash = require("min-dash");
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var TARGET_REF_PLACEHOLDER_NAME = '__targetRef_placeholder';
/**
* This behavior makes sure we always set a fake
* DataInputAssociation#targetRef as demanded by the BPMN 2.0
* XSD schema.
*
* The reference is set to a bpmn:Property{ name: '__targetRef_placeholder' }
* which is created on the fly and cleaned up afterwards if not needed
* anymore.
*
* @param {EventBus} eventBus
* @param {BpmnFactory} bpmnFactory
*/
function DataInputAssociationBehavior(eventBus, bpmnFactory) {
_CommandInterceptor.default.call(this, eventBus);
this.executed(['connection.create', 'connection.delete', 'connection.move', 'connection.reconnect'], ifDataInputAssociation(fixTargetRef));
this.reverted(['connection.create', 'connection.delete', 'connection.move', 'connection.reconnect'], ifDataInputAssociation(fixTargetRef));
function usesTargetRef(element, targetRef, removedConnection) {
var inputAssociations = element.get('dataInputAssociations');
return (0, _minDash.find)(inputAssociations, function (association) {
return association !== removedConnection && association.targetRef === targetRef;
});
}
function getTargetRef(element, create) {
var properties = element.get('properties');
var targetRefProp = (0, _minDash.find)(properties, function (p) {
return p.name === TARGET_REF_PLACEHOLDER_NAME;
});
if (!targetRefProp && create) {
targetRefProp = bpmnFactory.create('bpmn:Property', {
name: TARGET_REF_PLACEHOLDER_NAME
});
(0, _Collections.add)(properties, targetRefProp);
}
return targetRefProp;
}
function cleanupTargetRef(element, connection) {
var targetRefProp = getTargetRef(element);
if (!targetRefProp) {
return;
}
if (!usesTargetRef(element, targetRefProp, connection)) {
(0, _Collections.remove)(element.get('properties'), targetRefProp);
}
}
/**
* Make sure targetRef is set to a valid property or
* `null` if the connection is detached.
*
* @param {Event} event
*/
function fixTargetRef(event) {
var context = event.context,
connection = context.connection,
connectionBo = connection.businessObject,
target = connection.target,
targetBo = target && target.businessObject,
newTarget = context.newTarget,
newTargetBo = newTarget && newTarget.businessObject,
oldTarget = context.oldTarget || context.target,
oldTargetBo = oldTarget && oldTarget.businessObject;
var dataAssociation = connection.businessObject,
targetRefProp;
if (oldTargetBo && oldTargetBo !== targetBo) {
cleanupTargetRef(oldTargetBo, connectionBo);
}
if (newTargetBo && newTargetBo !== targetBo) {
cleanupTargetRef(newTargetBo, connectionBo);
}
if (targetBo) {
targetRefProp = getTargetRef(targetBo, true);
dataAssociation.targetRef = targetRefProp;
} else {
dataAssociation.targetRef = null;
}
}
}
DataInputAssociationBehavior.$inject = ['eventBus', 'bpmnFactory'];
(0, _inherits.default)(DataInputAssociationBehavior, _CommandInterceptor.default);
/**
* Only call the given function when the event
* touches a bpmn:DataInputAssociation.
*
* @param {Function} fn
* @return {Function}
*/
function ifDataInputAssociation(fn) {
return function (event) {
var context = event.context,
connection = context.connection;
if ((0, _ModelUtil.is)(connection, 'bpmn:DataInputAssociation')) {
return fn(event);
}
};
}
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/util/Collections":315,"inherits":349,"min-dash":559}],70:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DataStoreBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _ModelingUtil = require("../util/ModelingUtil");
var _UpdateSemanticParentHandler = _interopRequireDefault(require("../cmd/UpdateSemanticParentHandler"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN specific data store behavior
*/
function DataStoreBehavior(canvas, commandStack, elementRegistry, eventBus) {
_CommandInterceptor.default.call(this, eventBus);
commandStack.registerHandler('dataStore.updateContainment', _UpdateSemanticParentHandler.default);
function getFirstParticipant() {
return elementRegistry.filter(function (element) {
return (0, _ModelUtil.is)(element, 'bpmn:Participant');
})[0];
}
function getDataStores(element) {
return element.children.filter(function (child) {
return (0, _ModelUtil.is)(child, 'bpmn:DataStoreReference') && !child.labelTarget;
});
}
function updateDataStoreParent(dataStore, newDataStoreParent) {
var dataStoreBo = dataStore.businessObject || dataStore;
newDataStoreParent = newDataStoreParent || getFirstParticipant();
if (newDataStoreParent) {
var newDataStoreParentBo = newDataStoreParent.businessObject || newDataStoreParent;
commandStack.execute('dataStore.updateContainment', {
dataStoreBo: dataStoreBo,
newSemanticParent: newDataStoreParentBo.processRef || newDataStoreParentBo,
newDiParent: newDataStoreParentBo.di
});
}
} // disable auto-resize for data stores
this.preExecute('shape.create', function (event) {
var context = event.context,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:DataStoreReference') && shape.type !== 'label') {
if (!context.hints) {
context.hints = {};
} // prevent auto resizing
context.hints.autoResize = false;
}
}); // disable auto-resize for data stores
this.preExecute('elements.move', function (event) {
var context = event.context,
shapes = context.shapes;
var dataStoreReferences = shapes.filter(function (shape) {
return (0, _ModelUtil.is)(shape, 'bpmn:DataStoreReference');
});
if (dataStoreReferences.length) {
if (!context.hints) {
context.hints = {};
} // prevent auto resizing for data store references
context.hints.autoResize = shapes.filter(function (shape) {
return !(0, _ModelUtil.is)(shape, 'bpmn:DataStoreReference');
});
}
}); // update parent on data store created
this.postExecute('shape.create', function (event) {
var context = event.context,
shape = context.shape,
parent = shape.parent;
if ((0, _ModelUtil.is)(shape, 'bpmn:DataStoreReference') && shape.type !== 'label' && (0, _ModelUtil.is)(parent, 'bpmn:Collaboration')) {
updateDataStoreParent(shape);
}
}); // update parent on data store moved
this.postExecute('shape.move', function (event) {
var context = event.context,
shape = context.shape,
oldParent = context.oldParent,
parent = shape.parent;
if ((0, _ModelUtil.is)(oldParent, 'bpmn:Collaboration')) {
// do nothing if not necessary
return;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:DataStoreReference') && shape.type !== 'label' && (0, _ModelUtil.is)(parent, 'bpmn:Collaboration')) {
var participant = (0, _ModelUtil.is)(oldParent, 'bpmn:Participant') ? oldParent : getAncestor(oldParent, 'bpmn:Participant');
updateDataStoreParent(shape, participant);
}
}); // update data store parents on participant or subprocess deleted
this.postExecute('shape.delete', function (event) {
var context = event.context,
shape = context.shape,
rootElement = canvas.getRootElement();
if ((0, _ModelingUtil.isAny)(shape, ['bpmn:Participant', 'bpmn:SubProcess']) && (0, _ModelUtil.is)(rootElement, 'bpmn:Collaboration')) {
getDataStores(rootElement).filter(function (dataStore) {
return isDescendant(dataStore, shape);
}).forEach(function (dataStore) {
updateDataStoreParent(dataStore);
});
}
}); // update data store parents on collaboration -> process
this.postExecute('canvas.updateRoot', function (event) {
var context = event.context,
oldRoot = context.oldRoot,
newRoot = context.newRoot;
var dataStores = getDataStores(oldRoot);
dataStores.forEach(function (dataStore) {
if ((0, _ModelUtil.is)(newRoot, 'bpmn:Process')) {
updateDataStoreParent(dataStore, newRoot);
}
});
});
}
DataStoreBehavior.$inject = ['canvas', 'commandStack', 'elementRegistry', 'eventBus'];
(0, _inherits.default)(DataStoreBehavior, _CommandInterceptor.default); // helpers //////////
function isDescendant(descendant, ancestor) {
var descendantBo = descendant.businessObject || descendant,
ancestorBo = ancestor.businessObject || ancestor;
while (descendantBo.$parent) {
if (descendantBo.$parent === ancestorBo.processRef || ancestorBo) {
return true;
}
descendantBo = descendantBo.$parent;
}
return false;
}
function getAncestor(element, type) {
while (element.parent) {
if ((0, _ModelUtil.is)(element.parent, type)) {
return element.parent;
}
element = element.parent;
}
}
},{"../../../util/ModelUtil":142,"../cmd/UpdateSemanticParentHandler":110,"../util/ModelingUtil":113,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],71:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DeleteLaneBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _LaneUtil = require("../util/LaneUtil");
var _Elements = require("diagram-js/lib/util/Elements");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 500;
/**
* BPMN specific delete lane behavior
*/
function DeleteLaneBehavior(eventBus, modeling, spaceTool) {
_CommandInterceptor.default.call(this, eventBus);
function compensateLaneDelete(shape, oldParent) {
var siblings = (0, _LaneUtil.getChildLanes)(oldParent);
var topAffected = [];
var bottomAffected = [];
(0, _Elements.eachElement)(siblings, function (element) {
if (element.y > shape.y) {
bottomAffected.push(element);
} else {
topAffected.push(element);
}
return element.children;
});
if (!siblings.length) {
return;
}
var offset;
if (bottomAffected.length && topAffected.length) {
offset = shape.height / 2;
} else {
offset = shape.height;
}
var topAdjustments, bottomAdjustments;
if (topAffected.length) {
topAdjustments = spaceTool.calculateAdjustments(topAffected, 'y', offset, shape.y - 10);
spaceTool.makeSpace(topAdjustments.movingShapes, topAdjustments.resizingShapes, {
x: 0,
y: offset
}, 's');
}
if (bottomAffected.length) {
bottomAdjustments = spaceTool.calculateAdjustments(bottomAffected, 'y', -offset, shape.y + shape.height + 10);
spaceTool.makeSpace(bottomAdjustments.movingShapes, bottomAdjustments.resizingShapes, {
x: 0,
y: -offset
}, 'n');
}
}
/**
* Adjust sizes of other lanes after lane deletion
*/
this.postExecuted('shape.delete', LOW_PRIORITY, function (event) {
var context = event.context,
hints = context.hints,
shape = context.shape,
oldParent = context.oldParent; // only compensate lane deletes
if (!(0, _ModelUtil.is)(shape, 'bpmn:Lane')) {
return;
} // compensate root deletes only
if (hints && hints.nested) {
return;
}
compensateLaneDelete(shape, oldParent);
});
}
DeleteLaneBehavior.$inject = ['eventBus', 'modeling', 'spaceTool'];
(0, _inherits.default)(DeleteLaneBehavior, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"../util/LaneUtil":112,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/util/Elements":317,"inherits":349}],72:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DetachEventBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _LabelUtil = require("../../../util/LabelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 500;
/**
* Replace boundary event with intermediate event when creating or moving results in detached event.
*/
function DetachEventBehavior(bpmnReplace, injector) {
injector.invoke(_CommandInterceptor.default, this);
this._bpmnReplace = bpmnReplace;
var self = this;
this.postExecuted('elements.create', LOW_PRIORITY, function (context) {
var elements = context.elements;
elements.filter(function (shape) {
var host = shape.host;
return shouldReplace(shape, host);
}).map(function (shape) {
return elements.indexOf(shape);
}).forEach(function (index) {
context.elements[index] = self.replaceShape(elements[index]);
});
}, true);
this.preExecute('elements.move', LOW_PRIORITY, function (context) {
var shapes = context.shapes,
newHost = context.newHost;
shapes.forEach(function (shape, index) {
var host = shape.host;
if (shouldReplace(shape, includes(shapes, host) ? host : newHost)) {
shapes[index] = self.replaceShape(shape);
}
});
}, true);
}
DetachEventBehavior.$inject = ['bpmnReplace', 'injector'];
(0, _inherits.default)(DetachEventBehavior, _CommandInterceptor.default);
DetachEventBehavior.prototype.replaceShape = function (shape) {
var eventDefinition = getEventDefinition(shape),
intermediateEvent;
if (eventDefinition) {
intermediateEvent = {
type: 'bpmn:IntermediateCatchEvent',
eventDefinitionType: eventDefinition.$type
};
} else {
intermediateEvent = {
type: 'bpmn:IntermediateThrowEvent'
};
}
return this._bpmnReplace.replaceElement(shape, intermediateEvent, {
layoutConnection: false
});
}; // helpers //////////
function getEventDefinition(element) {
var businessObject = (0, _ModelUtil.getBusinessObject)(element),
eventDefinitions = businessObject.eventDefinitions;
return eventDefinitions && eventDefinitions[0];
}
function shouldReplace(shape, host) {
return !(0, _LabelUtil.isLabel)(shape) && (0, _ModelUtil.is)(shape, 'bpmn:BoundaryEvent') && !host;
}
function includes(array, item) {
return array.indexOf(item) !== -1;
}
},{"../../../util/LabelUtil":141,"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],73:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DropOnFlowBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _minDash = require("min-dash");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _LineIntersection = require("diagram-js/lib/util/LineIntersection");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function DropOnFlowBehavior(eventBus, bpmnRules, modeling) {
_CommandInterceptor.default.call(this, eventBus);
/**
* Reconnect start / end of a connection after
* dropping an element on a flow.
*/
function insertShape(shape, targetFlow, positionOrBounds) {
var waypoints = targetFlow.waypoints,
waypointsBefore,
waypointsAfter,
dockingPoint,
source,
target,
incomingConnection,
outgoingConnection,
oldOutgoing = shape.outgoing.slice(),
oldIncoming = shape.incoming.slice();
var mid;
if ((0, _minDash.isNumber)(positionOrBounds.width)) {
mid = (0, _LayoutUtil.getMid)(positionOrBounds);
} else {
mid = positionOrBounds;
}
var intersection = (0, _LineIntersection.getApproxIntersection)(waypoints, mid);
if (intersection) {
waypointsBefore = waypoints.slice(0, intersection.index);
waypointsAfter = waypoints.slice(intersection.index + (intersection.bendpoint ? 1 : 0)); // due to inaccuracy intersection might have been found
if (!waypointsBefore.length || !waypointsAfter.length) {
return;
}
dockingPoint = intersection.bendpoint ? waypoints[intersection.index] : mid; // if last waypointBefore is inside shape's bounds, ignore docking point
if (!isPointInsideBBox(shape, waypointsBefore[waypointsBefore.length - 1])) {
waypointsBefore.push(copy(dockingPoint));
} // if first waypointAfter is inside shape's bounds, ignore docking point
if (!isPointInsideBBox(shape, waypointsAfter[0])) {
waypointsAfter.unshift(copy(dockingPoint));
}
}
source = targetFlow.source;
target = targetFlow.target;
if (bpmnRules.canConnect(source, shape, targetFlow)) {
// reconnect source -> inserted shape
modeling.reconnectEnd(targetFlow, shape, waypointsBefore || mid);
incomingConnection = targetFlow;
}
if (bpmnRules.canConnect(shape, target, targetFlow)) {
if (!incomingConnection) {
// reconnect inserted shape -> end
modeling.reconnectStart(targetFlow, shape, waypointsAfter || mid);
outgoingConnection = targetFlow;
} else {
outgoingConnection = modeling.connect(shape, target, {
type: targetFlow.type,
waypoints: waypointsAfter
});
}
}
var duplicateConnections = [].concat(incomingConnection && (0, _minDash.filter)(oldIncoming, function (connection) {
return connection.source === incomingConnection.source;
}) || [], outgoingConnection && (0, _minDash.filter)(oldOutgoing, function (connection) {
return connection.target === outgoingConnection.target;
}) || []);
if (duplicateConnections.length) {
modeling.removeElements(duplicateConnections);
}
}
this.preExecute('elements.move', function (context) {
var newParent = context.newParent,
shapes = context.shapes,
delta = context.delta,
shape = shapes[0];
if (!shape || !newParent) {
return;
} // if the new parent is a connection,
// change it to the new parent's parent
if (newParent && newParent.waypoints) {
context.newParent = newParent = newParent.parent;
}
var shapeMid = (0, _LayoutUtil.getMid)(shape);
var newShapeMid = {
x: shapeMid.x + delta.x,
y: shapeMid.y + delta.y
}; // find a connection which intersects with the
// element's mid point
var connection = (0, _minDash.find)(newParent.children, function (element) {
var canInsert = bpmnRules.canInsert(shapes, element);
return canInsert && (0, _LineIntersection.getApproxIntersection)(element.waypoints, newShapeMid);
});
if (connection) {
context.targetFlow = connection;
context.position = newShapeMid;
}
}, true);
this.postExecuted('elements.move', function (context) {
var shapes = context.shapes,
targetFlow = context.targetFlow,
position = context.position;
if (targetFlow) {
insertShape(shapes[0], targetFlow, position);
}
}, true);
this.preExecute('shape.create', function (context) {
var parent = context.parent,
shape = context.shape;
if (bpmnRules.canInsert(shape, parent)) {
context.targetFlow = parent;
context.parent = parent.parent;
}
}, true);
this.postExecuted('shape.create', function (context) {
var shape = context.shape,
targetFlow = context.targetFlow,
positionOrBounds = context.position;
if (targetFlow) {
insertShape(shape, targetFlow, positionOrBounds);
}
}, true);
}
(0, _inherits.default)(DropOnFlowBehavior, _CommandInterceptor.default);
DropOnFlowBehavior.$inject = ['eventBus', 'bpmnRules', 'modeling']; // helpers /////////////////////
function isPointInsideBBox(bbox, point) {
var x = point.x,
y = point.y;
return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
}
function copy(obj) {
return (0, _minDash.assign)({}, obj);
}
},{"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/LineIntersection":323,"inherits":349,"min-dash":559}],74:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = EventBasedGatewayBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function EventBasedGatewayBehavior(eventBus, modeling) {
_CommandInterceptor.default.call(this, eventBus);
/**
* Remove existing sequence flows of event-based target before connecting
* from event-based gateway.
*/
this.preExecuted('connection.create', function (event) {
var context = event.context,
source = context.source,
target = context.target,
existingIncomingConnections = target.incoming.slice();
if (context.hints && context.hints.createElementsBehavior === false) {
return;
}
if ((0, _ModelUtil.is)(source, 'bpmn:EventBasedGateway') && target.incoming.length) {
existingIncomingConnections.filter(isSequenceFlow).forEach(function (sequenceFlow) {
modeling.removeConnection(sequenceFlow);
});
}
});
/**
* After replacing shape with event-based gateway, remove incoming sequence
* flows of event-based targets which do not belong to event-based gateway
* source.
*/
this.preExecuted('shape.replace', function (event) {
var newShape = event.context.newShape,
newShapeTargets,
newShapeTargetsIncomingSequenceFlows;
if (!(0, _ModelUtil.is)(newShape, 'bpmn:EventBasedGateway')) {
return;
}
newShapeTargets = newShape.outgoing.filter(isSequenceFlow).map(function (sequenceFlow) {
return sequenceFlow.target;
});
newShapeTargetsIncomingSequenceFlows = newShapeTargets.reduce(function (sequenceFlows, target) {
var incomingSequenceFlows = target.incoming.filter(isSequenceFlow);
return sequenceFlows.concat(incomingSequenceFlows);
}, []);
newShapeTargetsIncomingSequenceFlows.forEach(function (sequenceFlow) {
if (sequenceFlow.source !== newShape) {
modeling.removeConnection(sequenceFlow);
}
});
});
}
EventBasedGatewayBehavior.$inject = ['eventBus', 'modeling'];
(0, _inherits.default)(EventBasedGatewayBehavior, _CommandInterceptor.default); // helpers //////////////////////
function isSequenceFlow(connection) {
return (0, _ModelUtil.is)(connection, 'bpmn:SequenceFlow');
}
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],75:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = FixHoverBehavior;
var _LaneUtil = require("../util/LaneUtil");
var _ModelUtil = require("../../../util/ModelUtil");
var _ModelingUtil = require("../util/ModelingUtil");
var HIGH_PRIORITY = 1500;
var HIGHEST_PRIORITY = 2000;
/**
* Correct hover targets in certain situations to improve diagram interaction.
*
* @param {ElementRegistry} elementRegistry
* @param {EventBus} eventBus
* @param {Canvas} canvas
*/
function FixHoverBehavior(elementRegistry, eventBus, canvas) {
eventBus.on(['create.hover', 'create.move', 'create.end', 'shape.move.hover', 'shape.move.move', 'shape.move.end'], HIGH_PRIORITY, function (event) {
var context = event.context,
shape = context.shape || event.shape,
hover = event.hover; // ensure elements are not dropped onto a bpmn:Lane but onto
// the underlying bpmn:Participant
if ((0, _ModelUtil.is)(hover, 'bpmn:Lane') && !(0, _ModelingUtil.isAny)(shape, ['bpmn:Lane', 'bpmn:Participant'])) {
event.hover = (0, _LaneUtil.getLanesRoot)(hover);
event.hoverGfx = elementRegistry.getGraphics(event.hover);
}
var rootElement = canvas.getRootElement(); // ensure bpmn:Group and label elements are dropped
// always onto the root
if (hover !== rootElement && (shape.labelTarget || (0, _ModelUtil.is)(shape, 'bpmn:Group'))) {
event.hover = rootElement;
event.hoverGfx = elementRegistry.getGraphics(event.hover);
}
});
eventBus.on(['connect.hover', 'connect.out', 'connect.end', 'connect.cleanup', 'global-connect.hover', 'global-connect.out', 'global-connect.end', 'global-connect.cleanup'], HIGH_PRIORITY, function (event) {
var hover = event.hover; // ensure connections start/end on bpmn:Participant,
// not the underlying bpmn:Lane
if ((0, _ModelUtil.is)(hover, 'bpmn:Lane')) {
event.hover = (0, _LaneUtil.getLanesRoot)(hover) || hover;
event.hoverGfx = elementRegistry.getGraphics(event.hover);
}
});
eventBus.on(['bendpoint.move.hover'], HIGH_PRIORITY, function (event) {
var context = event.context,
hover = event.hover,
type = context.type; // ensure reconnect start/end on bpmn:Participant,
// not the underlying bpmn:Lane
if ((0, _ModelUtil.is)(hover, 'bpmn:Lane') && /reconnect/.test(type)) {
event.hover = (0, _LaneUtil.getLanesRoot)(hover) || hover;
event.hoverGfx = elementRegistry.getGraphics(event.hover);
}
});
eventBus.on(['connect.start'], HIGH_PRIORITY, function (event) {
var context = event.context,
start = context.start; // ensure connect start on bpmn:Participant,
// not the underlying bpmn:Lane
if ((0, _ModelUtil.is)(start, 'bpmn:Lane')) {
context.start = (0, _LaneUtil.getLanesRoot)(start) || start;
}
}); // allow movement of participants from lanes
eventBus.on('shape.move.start', HIGHEST_PRIORITY, function (event) {
var shape = event.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:Lane')) {
event.shape = (0, _LaneUtil.getLanesRoot)(shape) || shape;
}
});
}
FixHoverBehavior.$inject = ['elementRegistry', 'eventBus', 'canvas'];
},{"../../../util/ModelUtil":142,"../util/LaneUtil":112,"../util/ModelingUtil":113}],76:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = GroupBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _Collections = require("diagram-js/lib/util/Collections");
var _ModelUtil = require("../../../util/ModelUtil");
var _CategoryUtil = require("./util/CategoryUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var HIGH_PRIORITY = 2000;
/**
* BPMN specific Group behavior
*/
function GroupBehavior(bpmnFactory, canvas, elementRegistry, eventBus, injector, moddleCopy) {
injector.invoke(_CommandInterceptor.default, this);
/**
* Gets process definitions
*
* @return {ModdleElement} definitions
*/
function getDefinitions() {
var rootElement = canvas.getRootElement(),
businessObject = (0, _ModelUtil.getBusinessObject)(rootElement);
return businessObject.$parent;
}
/**
* Removes a referenced category value for a given group shape
*
* @param {djs.model.Shape} shape
*/
function removeReferencedCategoryValue(shape) {
var businessObject = (0, _ModelUtil.getBusinessObject)(shape),
categoryValue = businessObject.categoryValueRef;
if (!categoryValue) {
return;
}
var category = categoryValue.$parent;
if (!categoryValue) {
return;
}
(0, _Collections.remove)(category.categoryValue, categoryValue); // cleanup category if it is empty
if (category && !category.categoryValue.length) {
removeCategory(category);
}
}
/**
* Removes a given category from the definitions
*
* @param {ModdleElement} category
*/
function removeCategory(category) {
var definitions = getDefinitions();
(0, _Collections.remove)(definitions.get('rootElements'), category);
}
/**
* Returns all group element in the current registry
*
* @return {Array} a list of group shapes
*/
function getGroupElements() {
return elementRegistry.filter(function (e) {
return (0, _ModelUtil.is)(e, 'bpmn:Group');
});
}
/**
* Returns true if given categoryValue is referenced in one of the given elements
*
* @param {Array} elements
* @param {ModdleElement} categoryValue
* @return {boolean}
*/
function isReferenced(elements, categoryValue) {
return elements.some(function (e) {
var businessObject = (0, _ModelUtil.getBusinessObject)(e);
return businessObject.categoryValueRef && businessObject.categoryValueRef === categoryValue;
});
}
/**
* remove referenced category + value when group was deleted
*/
this.executed('shape.delete', function (event) {
var context = event.context,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:Group')) {
var businessObject = (0, _ModelUtil.getBusinessObject)(shape),
categoryValueRef = businessObject.categoryValueRef,
groupElements = getGroupElements();
if (!isReferenced(groupElements, categoryValueRef)) {
removeReferencedCategoryValue(shape);
}
}
});
/**
* re-attach removed category
*/
this.reverted('shape.delete', function (event) {
var context = event.context,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:Group')) {
var businessObject = (0, _ModelUtil.getBusinessObject)(shape),
categoryValueRef = businessObject.categoryValueRef,
definitions = getDefinitions(),
category = categoryValueRef ? categoryValueRef.$parent : null;
(0, _Collections.add)(category.get('categoryValue'), categoryValueRef);
(0, _Collections.add)(definitions.get('rootElements'), category);
}
});
/**
* create new category + value when group was created
*/
this.execute('shape.create', function (event) {
var context = event.context,
shape = context.shape,
businessObject = (0, _ModelUtil.getBusinessObject)(shape);
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
var definitions = getDefinitions(),
categoryValue = (0, _CategoryUtil.createCategoryValue)(definitions, bpmnFactory); // link the reference to the Group
businessObject.categoryValueRef = categoryValue;
}
});
this.revert('shape.create', function (event) {
var context = event.context,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:Group')) {
removeReferencedCategoryValue(shape);
delete (0, _ModelUtil.getBusinessObject)(shape).categoryValueRef;
}
}); // copy bpmn:CategoryValue when copying element
eventBus.on('moddleCopy.canCopyProperty', HIGH_PRIORITY, function (context) {
var property = context.property,
categoryValue;
if ((0, _ModelUtil.is)(property, 'bpmn:CategoryValue')) {
categoryValue = (0, _CategoryUtil.createCategoryValue)(getDefinitions(), bpmnFactory); // return copy of category
return moddleCopy.copyElement(property, categoryValue);
}
});
}
GroupBehavior.$inject = ['bpmnFactory', 'canvas', 'elementRegistry', 'eventBus', 'injector', 'moddleCopy'];
(0, _inherits.default)(GroupBehavior, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"./util/CategoryUtil":95,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/util/Collections":315,"inherits":349}],77:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ImportDockingFix;
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _LineIntersect = _interopRequireDefault(require("./util/LineIntersect"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Fix broken dockings after DI imports.
*
* @param {EventBus} eventBus
*/
function ImportDockingFix(eventBus) {
function adjustDocking(startPoint, nextPoint, elementMid) {
var elementTop = {
x: elementMid.x,
y: elementMid.y - 50
};
var elementLeft = {
x: elementMid.x - 50,
y: elementMid.y
};
var verticalIntersect = (0, _LineIntersect.default)(startPoint, nextPoint, elementMid, elementTop),
horizontalIntersect = (0, _LineIntersect.default)(startPoint, nextPoint, elementMid, elementLeft); // original is horizontal or vertical center cross intersection
var centerIntersect;
if (verticalIntersect && horizontalIntersect) {
if (getDistance(verticalIntersect, elementMid) > getDistance(horizontalIntersect, elementMid)) {
centerIntersect = horizontalIntersect;
} else {
centerIntersect = verticalIntersect;
}
} else {
centerIntersect = verticalIntersect || horizontalIntersect;
}
startPoint.original = centerIntersect;
}
function fixDockings(connection) {
var waypoints = connection.waypoints;
adjustDocking(waypoints[0], waypoints[1], (0, _LayoutUtil.getMid)(connection.source));
adjustDocking(waypoints[waypoints.length - 1], waypoints[waypoints.length - 2], (0, _LayoutUtil.getMid)(connection.target));
}
eventBus.on('bpmnElement.added', function (e) {
var element = e.element;
if (element.waypoints) {
fixDockings(element);
}
});
}
ImportDockingFix.$inject = ['eventBus']; // helpers //////////////////////
function getDistance(p1, p2) {
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
}
},{"./util/LineIntersect":99,"diagram-js/lib/layout/LayoutUtil":302}],78:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = IsHorizontalFix;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _ModelingUtil = require("../util/ModelingUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* A component that makes sure that each created or updated
* Pool and Lane is assigned an isHorizontal property set to true.
*
* @param {EventBus} eventBus
*/
function IsHorizontalFix(eventBus) {
_CommandInterceptor.default.call(this, eventBus);
var elementTypesToUpdate = ['bpmn:Participant', 'bpmn:Lane'];
this.executed(['shape.move', 'shape.create', 'shape.resize'], function (event) {
var bo = (0, _ModelUtil.getBusinessObject)(event.context.shape);
if ((0, _ModelingUtil.isAny)(bo, elementTypesToUpdate) && !bo.di.get('isHorizontal')) {
// set attribute directly to avoid modeling#updateProperty side effects
bo.di.set('isHorizontal', true);
}
});
}
IsHorizontalFix.$inject = ['eventBus'];
(0, _inherits.default)(IsHorizontalFix, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"../util/ModelingUtil":113,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],79:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.asEdges = asEdges;
exports.default = LabelBehavior;
exports.getReferencePoint = getReferencePoint;
exports.getReferencePointDelta = getReferencePointDelta;
var _minDash = require("min-dash");
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../../util/ModelUtil");
var _LabelUtil = require("../../../util/LabelUtil");
var _LabelUtil2 = require("../../label-editing/LabelUtil");
var _LabelLayoutUtil = require("./util/LabelLayoutUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _AttachUtil = require("diagram-js/lib/util/AttachUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _PositionUtil = require("diagram-js/lib/util/PositionUtil");
var _GeometricUtil = require("./util/GeometricUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var DEFAULT_LABEL_DIMENSIONS = {
width: 90,
height: 20
};
var NAME_PROPERTY = 'name';
var TEXT_PROPERTY = 'text';
/**
* A component that makes sure that external labels are added
* together with respective elements and properly updated (DI wise)
* during move.
*
* @param {EventBus} eventBus
* @param {Modeling} modeling
* @param {BpmnFactory} bpmnFactory
* @param {TextRenderer} textRenderer
*/
function LabelBehavior(eventBus, modeling, bpmnFactory, textRenderer) {
_CommandInterceptor.default.call(this, eventBus); // update label if name property was updated
this.postExecute('element.updateProperties', function (e) {
var context = e.context,
element = context.element,
properties = context.properties;
if (NAME_PROPERTY in properties) {
modeling.updateLabel(element, properties[NAME_PROPERTY]);
}
if (TEXT_PROPERTY in properties && (0, _ModelUtil.is)(element, 'bpmn:TextAnnotation')) {
var newBounds = textRenderer.getTextAnnotationBounds({
x: element.x,
y: element.y,
width: element.width,
height: element.height
}, properties[TEXT_PROPERTY] || '');
modeling.updateLabel(element, properties.text, newBounds);
}
}); // create label shape after shape/connection was created
this.postExecute(['shape.create', 'connection.create'], function (e) {
var context = e.context,
hints = context.hints || {};
if (hints.createElementsBehavior === false) {
return;
}
var element = context.shape || context.connection,
businessObject = element.businessObject;
if ((0, _LabelUtil.isLabel)(element) || !(0, _LabelUtil.isLabelExternal)(element)) {
return;
} // only create label if attribute available
if (!(0, _LabelUtil2.getLabel)(element)) {
return;
}
var labelCenter = (0, _LabelUtil.getExternalLabelMid)(element); // we don't care about x and y
var labelDimensions = textRenderer.getExternalLabelBounds(DEFAULT_LABEL_DIMENSIONS, (0, _LabelUtil2.getLabel)(element));
modeling.createLabel(element, labelCenter, {
id: businessObject.id + '_label',
businessObject: businessObject,
width: labelDimensions.width,
height: labelDimensions.height
});
}); // update label after label shape was deleted
this.postExecute('shape.delete', function (event) {
var context = event.context,
labelTarget = context.labelTarget,
hints = context.hints || {}; // check if label
if (labelTarget && hints.unsetLabel !== false) {
modeling.updateLabel(labelTarget, null, null, {
removeShape: false
});
}
}); // update di information on label creation
this.postExecute(['label.create'], function (event) {
var context = event.context,
element = context.shape,
businessObject,
di; // we want to trigger on real labels only
if (!element.labelTarget) {
return;
} // we want to trigger on BPMN elements only
if (!(0, _ModelUtil.is)(element.labelTarget || element, 'bpmn:BaseElement')) {
return;
}
businessObject = element.businessObject, di = businessObject.di;
if (!di.label) {
di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
bounds: bpmnFactory.create('dc:Bounds')
});
}
(0, _minDash.assign)(di.label.bounds, {
x: element.x,
y: element.y,
width: element.width,
height: element.height
});
});
function getVisibleLabelAdjustment(event) {
var context = event.context,
connection = context.connection,
label = connection.label,
hints = (0, _minDash.assign)({}, context.hints),
newWaypoints = context.newWaypoints || connection.waypoints,
oldWaypoints = context.oldWaypoints;
if (typeof hints.startChanged === 'undefined') {
hints.startChanged = !!hints.connectionStart;
}
if (typeof hints.endChanged === 'undefined') {
hints.endChanged = !!hints.connectionEnd;
}
return (0, _LabelLayoutUtil.getLabelAdjustment)(label, newWaypoints, oldWaypoints, hints);
}
this.postExecute(['connection.layout', 'connection.updateWaypoints'], function (event) {
var context = event.context,
hints = context.hints || {};
if (hints.labelBehavior === false) {
return;
}
var connection = context.connection,
label = connection.label,
labelAdjustment; // handle missing label as well as the case
// that the label parent does not exist (yet),
// because it is being pasted / created via multi element create
//
// Cf. https://github.com/bpmn-io/bpmn-js/pull/1227
if (!label || !label.parent) {
return;
}
labelAdjustment = getVisibleLabelAdjustment(event);
modeling.moveShape(label, labelAdjustment);
}); // keep label position on shape replace
this.postExecute(['shape.replace'], function (event) {
var context = event.context,
newShape = context.newShape,
oldShape = context.oldShape;
var businessObject = (0, _ModelUtil.getBusinessObject)(newShape);
if (businessObject && (0, _LabelUtil.isLabelExternal)(businessObject) && oldShape.label && newShape.label) {
newShape.label.x = oldShape.label.x;
newShape.label.y = oldShape.label.y;
}
}); // move external label after resizing
this.postExecute('shape.resize', function (event) {
var context = event.context,
shape = context.shape,
newBounds = context.newBounds,
oldBounds = context.oldBounds;
if ((0, _LabelUtil.hasExternalLabel)(shape)) {
var label = shape.label,
labelMid = (0, _LayoutUtil.getMid)(label),
edges = asEdges(oldBounds); // get nearest border point to label as reference point
var referencePoint = getReferencePoint(labelMid, edges);
var delta = getReferencePointDelta(referencePoint, oldBounds, newBounds);
modeling.moveShape(label, delta);
}
});
}
(0, _inherits.default)(LabelBehavior, _CommandInterceptor.default);
LabelBehavior.$inject = ['eventBus', 'modeling', 'bpmnFactory', 'textRenderer']; // helpers //////////////////////
/**
* Calculates a reference point delta relative to a new position
* of a certain element's bounds
*
* @param {Point} point
* @param {Bounds} oldBounds
* @param {Bounds} newBounds
*
* @return {Delta} delta
*/
function getReferencePointDelta(referencePoint, oldBounds, newBounds) {
var newReferencePoint = (0, _AttachUtil.getNewAttachPoint)(referencePoint, oldBounds, newBounds);
return (0, _LayoutUtil.roundPoint)((0, _PositionUtil.delta)(newReferencePoint, referencePoint));
}
/**
* Generates the nearest point (reference point) for a given point
* onto given set of lines
*
* @param {Array} lines
* @param {Point} point
*
* @param {Point}
*/
function getReferencePoint(point, lines) {
if (!lines.length) {
return;
}
var nearestLine = getNearestLine(point, lines);
return (0, _GeometricUtil.perpendicularFoot)(point, nearestLine);
}
/**
* Convert the given bounds to a lines array containing all edges
*
* @param {Bounds|Point} bounds
*
* @return Array
*/
function asEdges(bounds) {
return [[// top
{
x: bounds.x,
y: bounds.y
}, {
x: bounds.x + (bounds.width || 0),
y: bounds.y
}], [// right
{
x: bounds.x + (bounds.width || 0),
y: bounds.y
}, {
x: bounds.x + (bounds.width || 0),
y: bounds.y + (bounds.height || 0)
}], [// bottom
{
x: bounds.x,
y: bounds.y + (bounds.height || 0)
}, {
x: bounds.x + (bounds.width || 0),
y: bounds.y + (bounds.height || 0)
}], [// left
{
x: bounds.x,
y: bounds.y
}, {
x: bounds.x,
y: bounds.y + (bounds.height || 0)
}]];
}
/**
* Returns the nearest line for a given point by distance
* @param {Point} point
* @param Array lines
*
* @return Array
*/
function getNearestLine(point, lines) {
var distances = lines.map(function (l) {
return {
line: l,
distance: (0, _GeometricUtil.getDistancePointLine)(point, l)
};
});
var sorted = (0, _minDash.sortBy)(distances, 'distance');
return sorted[0].line;
}
},{"../../../util/LabelUtil":141,"../../../util/ModelUtil":142,"../../label-editing/LabelUtil":53,"./util/GeometricUtil":96,"./util/LabelLayoutUtil":97,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/AttachUtil":313,"diagram-js/lib/util/PositionUtil":327,"inherits":349,"min-dash":559}],80:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ModelingFeedback;
var _ModelUtil = require("../../../util/ModelUtil");
var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
function ModelingFeedback(eventBus, tooltips, translate) {
function showError(position, message, timeout) {
tooltips.add({
position: {
x: position.x + 5,
y: position.y + 5
},
type: 'error',
timeout: timeout || 2000,
html: '
' + message + '
'
});
}
eventBus.on(['shape.move.rejected', 'create.rejected'], function (event) {
var context = event.context,
shape = context.shape,
target = context.target;
if ((0, _ModelUtil.is)(target, 'bpmn:Collaboration') && (0, _ModelUtil.is)(shape, 'bpmn:FlowNode')) {
showError(event, translate(COLLAB_ERR_MSG));
}
});
}
ModelingFeedback.$inject = ['eventBus', 'tooltips', 'translate'];
},{"../../../util/ModelUtil":142}],81:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = RemoveElementBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../../util/ModelUtil");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _LineIntersect = _interopRequireDefault(require("./util/LineIntersect"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function RemoveElementBehavior(eventBus, bpmnRules, modeling) {
_CommandInterceptor.default.call(this, eventBus);
/**
* Combine sequence flows when deleting an element
* if there is one incoming and one outgoing
* sequence flow
*/
this.preExecute('shape.delete', function (e) {
var shape = e.context.shape; // only handle [a] -> [shape] -> [b] patterns
if (shape.incoming.length !== 1 || shape.outgoing.length !== 1) {
return;
}
var inConnection = shape.incoming[0],
outConnection = shape.outgoing[0]; // only handle sequence flows
if (!(0, _ModelUtil.is)(inConnection, 'bpmn:SequenceFlow') || !(0, _ModelUtil.is)(outConnection, 'bpmn:SequenceFlow')) {
return;
}
if (bpmnRules.canConnect(inConnection.source, outConnection.target, inConnection)) {
// compute new, combined waypoints
var newWaypoints = getNewWaypoints(inConnection.waypoints, outConnection.waypoints);
modeling.reconnectEnd(inConnection, outConnection.target, newWaypoints);
}
});
}
(0, _inherits.default)(RemoveElementBehavior, _CommandInterceptor.default);
RemoveElementBehavior.$inject = ['eventBus', 'bpmnRules', 'modeling']; // helpers //////////////////////
function getDocking(point) {
return point.original || point;
}
function getNewWaypoints(inWaypoints, outWaypoints) {
var intersection = (0, _LineIntersect.default)(getDocking(inWaypoints[inWaypoints.length - 2]), getDocking(inWaypoints[inWaypoints.length - 1]), getDocking(outWaypoints[1]), getDocking(outWaypoints[0]));
if (intersection) {
return [].concat(inWaypoints.slice(0, inWaypoints.length - 1), [intersection], outWaypoints.slice(1));
} else {
return [getDocking(inWaypoints[0]), getDocking(outWaypoints[outWaypoints.length - 1])];
}
}
},{"../../../util/ModelUtil":142,"./util/LineIntersect":99,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],82:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = RemoveParticipantBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN specific remove behavior
*/
function RemoveParticipantBehavior(eventBus, modeling) {
_CommandInterceptor.default.call(this, eventBus);
/**
* morph collaboration diagram into process diagram
* after the last participant has been removed
*/
this.preExecute('shape.delete', function (context) {
var shape = context.shape,
parent = shape.parent; // activate the behavior if the shape to be removed
// is a participant
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
context.collaborationRoot = parent;
}
}, true);
this.postExecute('shape.delete', function (context) {
var collaborationRoot = context.collaborationRoot;
if (collaborationRoot && !collaborationRoot.businessObject.participants.length) {
// replace empty collaboration with process diagram
modeling.makeProcess();
}
}, true);
}
RemoveParticipantBehavior.$inject = ['eventBus', 'modeling'];
(0, _inherits.default)(RemoveParticipantBehavior, _CommandInterceptor.default);
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],83:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ReplaceConnectionBehavior;
var _minDash = require("min-dash");
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules, injector) {
_CommandInterceptor.default.call(this, eventBus);
var dragging = injector.get('dragging', false);
function fixConnection(connection) {
var source = connection.source,
target = connection.target,
parent = connection.parent; // do not do anything if connection
// is already deleted (may happen due to other
// behaviors plugged-in before)
if (!parent) {
return;
}
var replacementType, remove;
/**
* Check if incoming or outgoing connections
* can stay or could be substituted with an
* appropriate replacement.
*
* This holds true for SequenceFlow <> MessageFlow.
*/
if ((0, _ModelUtil.is)(connection, 'bpmn:SequenceFlow')) {
if (!bpmnRules.canConnectSequenceFlow(source, target)) {
remove = true;
}
if (bpmnRules.canConnectMessageFlow(source, target)) {
replacementType = 'bpmn:MessageFlow';
}
} // transform message flows into sequence flows, if possible
if ((0, _ModelUtil.is)(connection, 'bpmn:MessageFlow')) {
if (!bpmnRules.canConnectMessageFlow(source, target)) {
remove = true;
}
if (bpmnRules.canConnectSequenceFlow(source, target)) {
replacementType = 'bpmn:SequenceFlow';
}
}
if ((0, _ModelUtil.is)(connection, 'bpmn:Association') && !bpmnRules.canConnectAssociation(source, target)) {
remove = true;
} // remove invalid connection,
// unless it has been removed already
if (remove) {
modeling.removeConnection(connection);
} // replace SequenceFlow <> MessageFlow
if (replacementType) {
modeling.connect(source, target, {
type: replacementType,
waypoints: connection.waypoints.slice()
});
}
}
function replaceReconnectedConnection(event) {
var context = event.context,
connection = context.connection,
source = context.newSource || connection.source,
target = context.newTarget || connection.target,
allowed,
replacement;
allowed = bpmnRules.canConnect(source, target);
if (!allowed || allowed.type === connection.type) {
return;
}
replacement = modeling.connect(source, target, {
type: allowed.type,
waypoints: connection.waypoints.slice()
}); // remove old connection
modeling.removeConnection(connection); // replace connection in context to reconnect end/start
context.connection = replacement;
if (dragging) {
cleanDraggingSelection(connection, replacement);
}
} // monkey-patch selection saved in dragging in order to re-select it when operation is finished
function cleanDraggingSelection(oldConnection, newConnection) {
var context = dragging.context(),
previousSelection = context && context.payload.previousSelection,
index; // do nothing if not dragging or no selection was present
if (!previousSelection || !previousSelection.length) {
return;
}
index = previousSelection.indexOf(oldConnection);
if (index === -1) {
return;
}
previousSelection.splice(index, 1, newConnection);
} // lifecycle hooks
this.postExecuted('elements.move', function (context) {
var closure = context.closure,
allConnections = closure.allConnections;
(0, _minDash.forEach)(allConnections, fixConnection);
}, true);
this.preExecute('connection.reconnect', replaceReconnectedConnection);
this.postExecuted('element.updateProperties', function (event) {
var context = event.context,
properties = context.properties,
element = context.element,
businessObject = element.businessObject,
connection; // remove condition on change to default
if (properties.default) {
connection = (0, _minDash.find)(element.outgoing, (0, _minDash.matchPattern)({
id: element.businessObject.default.id
}));
if (connection) {
modeling.updateProperties(connection, {
conditionExpression: undefined
});
}
} // remove default from source on change to conditional
if (properties.conditionExpression && businessObject.sourceRef.default === businessObject) {
modeling.updateProperties(element.source, {
default: undefined
});
}
});
}
(0, _inherits.default)(ReplaceConnectionBehavior, _CommandInterceptor.default);
ReplaceConnectionBehavior.$inject = ['eventBus', 'modeling', 'bpmnRules', 'injector'];
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349,"min-dash":559}],84:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ReplaceElementBehaviour;
var _inherits = _interopRequireDefault(require("inherits"));
var _minDash = require("min-dash");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _DiUtil = require("../../../util/DiUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN-specific replace behavior.
*/
function ReplaceElementBehaviour(bpmnReplace, bpmnRules, elementRegistry, injector, modeling, selection) {
injector.invoke(_CommandInterceptor.default, this);
this._bpmnReplace = bpmnReplace;
this._elementRegistry = elementRegistry;
this._selection = selection; // replace elements on move
this.postExecuted(['elements.move'], 500, function (event) {
var context = event.context,
target = context.newParent,
newHost = context.newHost,
elements = [];
(0, _minDash.forEach)(context.closure.topLevel, function (topLevelElements) {
if ((0, _DiUtil.isEventSubProcess)(topLevelElements)) {
elements = elements.concat(topLevelElements.children);
} else {
elements = elements.concat(topLevelElements);
}
}); // set target to host if attaching
if (elements.length === 1 && newHost) {
target = newHost;
}
var canReplace = bpmnRules.canReplace(elements, target);
if (canReplace) {
this.replaceElements(elements, canReplace.replacements, newHost);
}
}, this); // update attachments on host replace
this.postExecute(['shape.replace'], 1500, function (e) {
var context = e.context,
oldShape = context.oldShape,
newShape = context.newShape,
attachers = oldShape.attachers,
canReplace;
if (attachers && attachers.length) {
canReplace = bpmnRules.canReplace(attachers, newShape);
this.replaceElements(attachers, canReplace.replacements);
}
}, this); // keep ID on shape replace
this.postExecuted(['shape.replace'], 1500, function (e) {
var context = e.context,
oldShape = context.oldShape,
newShape = context.newShape;
modeling.unclaimId(oldShape.businessObject.id, oldShape.businessObject);
modeling.updateProperties(newShape, {
id: oldShape.id
});
});
}
(0, _inherits.default)(ReplaceElementBehaviour, _CommandInterceptor.default);
ReplaceElementBehaviour.prototype.replaceElements = function (elements, newElements) {
var elementRegistry = this._elementRegistry,
bpmnReplace = this._bpmnReplace,
selection = this._selection;
(0, _minDash.forEach)(newElements, function (replacement) {
var newElement = {
type: replacement.newElementType
};
var oldElement = elementRegistry.get(replacement.oldElementId);
var idx = elements.indexOf(oldElement);
elements[idx] = bpmnReplace.replaceElement(oldElement, newElement, {
select: false
});
});
if (newElements) {
selection.select(elements);
}
};
ReplaceElementBehaviour.$inject = ['bpmnReplace', 'bpmnRules', 'elementRegistry', 'injector', 'modeling', 'selection'];
},{"../../../util/DiUtil":140,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349,"min-dash":559}],85:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TEXT_ANNOTATION_MIN_DIMENSIONS = exports.SUB_PROCESS_MIN_DIMENSIONS = exports.PARTICIPANT_MIN_DIMENSIONS = exports.LANE_MIN_DIMENSIONS = void 0;
exports.default = ResizeBehavior;
var _ModelUtil = require("../../../util/ModelUtil");
var _DiUtil = require("../../../util/DiUtil");
var _ResizeUtil = require("./util/ResizeUtil");
var HIGH_PRIORITY = 1500;
var LANE_MIN_DIMENSIONS = {
width: 300,
height: 60
};
exports.LANE_MIN_DIMENSIONS = LANE_MIN_DIMENSIONS;
var PARTICIPANT_MIN_DIMENSIONS = {
width: 300,
height: 150
};
exports.PARTICIPANT_MIN_DIMENSIONS = PARTICIPANT_MIN_DIMENSIONS;
var SUB_PROCESS_MIN_DIMENSIONS = {
width: 140,
height: 120
};
exports.SUB_PROCESS_MIN_DIMENSIONS = SUB_PROCESS_MIN_DIMENSIONS;
var TEXT_ANNOTATION_MIN_DIMENSIONS = {
width: 50,
height: 30
};
/**
* Set minimum bounds/resize constraints on resize.
*
* @param {EventBus} eventBus
*/
exports.TEXT_ANNOTATION_MIN_DIMENSIONS = TEXT_ANNOTATION_MIN_DIMENSIONS;
function ResizeBehavior(eventBus) {
eventBus.on('resize.start', HIGH_PRIORITY, function (event) {
var context = event.context,
shape = context.shape,
direction = context.direction,
balanced = context.balanced;
if ((0, _ModelUtil.is)(shape, 'bpmn:Lane') || (0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
context.resizeConstraints = (0, _ResizeUtil.getParticipantResizeConstraints)(shape, direction, balanced);
}
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
context.minDimensions = PARTICIPANT_MIN_DIMENSIONS;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:SubProcess') && (0, _DiUtil.isExpanded)(shape)) {
context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:TextAnnotation')) {
context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
}
});
}
ResizeBehavior.$inject = ['eventBus'];
},{"../../../util/DiUtil":140,"../../../util/ModelUtil":142,"./util/ResizeUtil":100}],86:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ResizeLaneBehavior;
var _ModelUtil = require("../../../util/ModelUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _Mouse = require("diagram-js/lib/util/Mouse");
var SLIGHTLY_HIGHER_PRIORITY = 1001;
/**
* Invoke {@link Modeling#resizeLane} instead of
* {@link Modeling#resizeShape} when resizing a Lane
* or Participant shape.
*/
function ResizeLaneBehavior(eventBus, modeling) {
eventBus.on('resize.start', SLIGHTLY_HIGHER_PRIORITY + 500, function (event) {
var context = event.context,
shape = context.shape;
if ((0, _ModelUtil.is)(shape, 'bpmn:Lane') || (0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
// should we resize the opposite lane(s) in
// order to compensate for the resize operation?
context.balanced = !(0, _Mouse.hasPrimaryModifier)(event);
}
});
/**
* Intercept resize end and call resize lane function instead.
*/
eventBus.on('resize.end', SLIGHTLY_HIGHER_PRIORITY, function (event) {
var context = event.context,
shape = context.shape,
canExecute = context.canExecute,
newBounds = context.newBounds;
if ((0, _ModelUtil.is)(shape, 'bpmn:Lane') || (0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
if (canExecute) {
// ensure we have actual pixel values for new bounds
// (important when zoom level was > 1 during move)
newBounds = (0, _LayoutUtil.roundBounds)(newBounds); // perform the actual resize
modeling.resizeLane(shape, newBounds, context.balanced);
} // stop propagation
return false;
}
});
}
ResizeLaneBehavior.$inject = ['eventBus', 'modeling'];
},{"../../../util/ModelUtil":142,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/Mouse":325}],87:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = RootElementReferenceBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _minDash = require("min-dash");
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _Collections = require("diagram-js/lib/util/Collections");
var _ModelUtil = require("../../../util/ModelUtil");
var _ModelingUtil = require("../util/ModelingUtil");
var _DiUtil = require("../../../util/DiUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 500;
/**
* Add referenced root elements (error, escalation, message, signal) if they don't exist.
* Copy referenced root elements on copy & paste.
*/
function RootElementReferenceBehavior(bpmnjs, eventBus, injector, moddleCopy, bpmnFactory) {
injector.invoke(_CommandInterceptor.default, this);
function canHaveRootElementReference(element) {
return (0, _ModelingUtil.isAny)(element, ['bpmn:ReceiveTask', 'bpmn:SendTask']) || hasAnyEventDefinition(element, ['bpmn:ErrorEventDefinition', 'bpmn:EscalationEventDefinition', 'bpmn:MessageEventDefinition', 'bpmn:SignalEventDefinition']);
}
function hasRootElement(rootElement) {
var definitions = bpmnjs.getDefinitions(),
rootElements = definitions.get('rootElements');
return !!(0, _minDash.find)(rootElements, (0, _minDash.matchPattern)({
id: rootElement.id
}));
}
function getRootElementReferencePropertyName(eventDefinition) {
if ((0, _ModelUtil.is)(eventDefinition, 'bpmn:ErrorEventDefinition')) {
return 'errorRef';
} else if ((0, _ModelUtil.is)(eventDefinition, 'bpmn:EscalationEventDefinition')) {
return 'escalationRef';
} else if ((0, _ModelUtil.is)(eventDefinition, 'bpmn:MessageEventDefinition')) {
return 'messageRef';
} else if ((0, _ModelUtil.is)(eventDefinition, 'bpmn:SignalEventDefinition')) {
return 'signalRef';
}
}
function getRootElement(businessObject) {
if ((0, _ModelingUtil.isAny)(businessObject, ['bpmn:ReceiveTask', 'bpmn:SendTask'])) {
return businessObject.get('messageRef');
}
var eventDefinitions = businessObject.get('eventDefinitions'),
eventDefinition = eventDefinitions[0];
return eventDefinition.get(getRootElementReferencePropertyName(eventDefinition));
}
function setRootElement(businessObject, rootElement) {
if ((0, _ModelingUtil.isAny)(businessObject, ['bpmn:ReceiveTask', 'bpmn:SendTask'])) {
return businessObject.set('messageRef', rootElement);
}
var eventDefinitions = businessObject.get('eventDefinitions'),
eventDefinition = eventDefinitions[0];
return eventDefinition.set(getRootElementReferencePropertyName(eventDefinition), rootElement);
} // create shape
this.executed('shape.create', function (context) {
var shape = context.shape;
if (!canHaveRootElementReference(shape)) {
return;
}
var businessObject = (0, _ModelUtil.getBusinessObject)(shape),
rootElement = getRootElement(businessObject),
rootElements;
if (rootElement && !hasRootElement(rootElement)) {
rootElements = bpmnjs.getDefinitions().get('rootElements'); // add root element
(0, _Collections.add)(rootElements, rootElement);
context.addedRootElement = rootElement;
}
}, true);
this.reverted('shape.create', function (context) {
var addedRootElement = context.addedRootElement;
if (!addedRootElement) {
return;
}
var rootElements = bpmnjs.getDefinitions().get('rootElements'); // remove root element
(0, _Collections.remove)(rootElements, addedRootElement);
}, true);
eventBus.on('copyPaste.copyElement', function (context) {
var descriptor = context.descriptor,
element = context.element;
if (!canHaveRootElementReference(element)) {
return;
}
var businessObject = (0, _ModelUtil.getBusinessObject)(element),
rootElement = getRootElement(businessObject);
if (rootElement) {
descriptor.referencedRootElement = rootElement;
}
});
eventBus.on('copyPaste.pasteElement', LOW_PRIORITY, function (context) {
var descriptor = context.descriptor,
businessObject = descriptor.businessObject;
if (!canHaveRootElementReference(businessObject)) {
return;
}
var referencedRootElement = descriptor.referencedRootElement;
if (!referencedRootElement) {
return;
}
if (!hasRootElement(referencedRootElement)) {
referencedRootElement = moddleCopy.copyElement(referencedRootElement, bpmnFactory.create(referencedRootElement.$type));
}
setRootElement(businessObject, referencedRootElement);
});
}
RootElementReferenceBehavior.$inject = ['bpmnjs', 'eventBus', 'injector', 'moddleCopy', 'bpmnFactory'];
(0, _inherits.default)(RootElementReferenceBehavior, _CommandInterceptor.default); // helpers //////////
function hasAnyEventDefinition(element, types) {
if (!(0, _minDash.isArray)(types)) {
types = [types];
}
return (0, _minDash.some)(types, function (type) {
return (0, _DiUtil.hasEventDefinition)(element, type);
});
}
},{"../../../util/DiUtil":140,"../../../util/ModelUtil":142,"../util/ModelingUtil":113,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/util/Collections":315,"inherits":349,"min-dash":559}],88:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = SpaceToolBehavior;
var _minDash = require("min-dash");
var _ModelUtil = require("../../../util/ModelUtil");
var _DiUtil = require("../../../util/DiUtil");
var _ResizeBehavior = require("./ResizeBehavior");
var _LaneUtil = require("../util/LaneUtil");
var max = Math.max;
function SpaceToolBehavior(eventBus) {
eventBus.on('spaceTool.getMinDimensions', function (context) {
var shapes = context.shapes,
axis = context.axis,
start = context.start,
minDimensions = {};
(0, _minDash.forEach)(shapes, function (shape) {
var id = shape.id;
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
if (isHorizontal(axis)) {
minDimensions[id] = _ResizeBehavior.PARTICIPANT_MIN_DIMENSIONS;
} else {
minDimensions[id] = {
width: _ResizeBehavior.PARTICIPANT_MIN_DIMENSIONS.width,
height: getParticipantMinHeight(shape, start)
};
}
}
if ((0, _ModelUtil.is)(shape, 'bpmn:SubProcess') && (0, _DiUtil.isExpanded)(shape)) {
minDimensions[id] = _ResizeBehavior.SUB_PROCESS_MIN_DIMENSIONS;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:TextAnnotation')) {
minDimensions[id] = _ResizeBehavior.TEXT_ANNOTATION_MIN_DIMENSIONS;
}
});
return minDimensions;
});
}
SpaceToolBehavior.$inject = ['eventBus']; // helpers //////////
function isHorizontal(axis) {
return axis === 'x';
}
/**
* Get minimum height for participant taking lanes into account.
*
* @param {} participant
* @param {number} start
*
* @returns {Object}
*/
function getParticipantMinHeight(participant, start) {
var lanesMinHeight;
if (!hasChildLanes(participant)) {
return _ResizeBehavior.PARTICIPANT_MIN_DIMENSIONS.height;
}
lanesMinHeight = getLanesMinHeight(participant, start);
return max(_ResizeBehavior.PARTICIPANT_MIN_DIMENSIONS.height, lanesMinHeight);
}
function hasChildLanes(element) {
return !!(0, _LaneUtil.getChildLanes)(element).length;
}
function getLanesMinHeight(participant, resizeStart) {
var lanes = (0, _LaneUtil.getChildLanes)(participant),
resizedLane; // find the nested lane which is currently resized
resizedLane = findResizedLane(lanes, resizeStart); // resized lane cannot shrink below the minimum height
// but remaining lanes' dimensions are kept intact
return participant.height - resizedLane.height + _ResizeBehavior.LANE_MIN_DIMENSIONS.height;
}
/**
* Find nested lane which is currently resized.
*
* @param {Array} lanes
* @param {number} resizeStart
*/
function findResizedLane(lanes, resizeStart) {
var i, lane, childLanes;
for (i = 0; i < lanes.length; i++) {
lane = lanes[i]; // resizing current lane or a lane nested
if (resizeStart >= lane.y && resizeStart <= lane.y + lane.height) {
childLanes = (0, _LaneUtil.getChildLanes)(lane); // a nested lane is resized
if (childLanes.length) {
return findResizedLane(childLanes, resizeStart);
} // current lane is the resized one
return lane;
}
}
}
},{"../../../util/DiUtil":140,"../../../util/ModelUtil":142,"../util/LaneUtil":112,"./ResizeBehavior":85,"min-dash":559}],89:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = SubProcessStartEventBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _DiUtil = require("../../../util/DiUtil.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Add start event replacing element with expanded sub process.
*
* @param {Injector} injector
* @param {Modeling} modeling
*/
function SubProcessStartEventBehavior(injector, modeling) {
injector.invoke(_CommandInterceptor.default, this);
this.postExecuted('shape.replace', function (event) {
var oldShape = event.context.oldShape,
newShape = event.context.newShape;
if (!(0, _ModelUtil.is)(newShape, 'bpmn:SubProcess') || !(0, _ModelUtil.is)(oldShape, 'bpmn:Task') || !(0, _DiUtil.isExpanded)(newShape)) {
return;
}
var position = getStartEventPosition(newShape);
modeling.createShape({
type: 'bpmn:StartEvent'
}, position, newShape);
});
}
SubProcessStartEventBehavior.$inject = ['injector', 'modeling'];
(0, _inherits.default)(SubProcessStartEventBehavior, _CommandInterceptor.default); // helpers //////////
function getStartEventPosition(shape) {
return {
x: shape.x + shape.width / 6,
y: shape.y + shape.height / 2
};
}
},{"../../../util/DiUtil.js":140,"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],90:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ToggleElementCollapseBehaviour;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _ResizeUtil = require("diagram-js/lib/features/resize/ResizeUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 500;
function ToggleElementCollapseBehaviour(eventBus, elementFactory, modeling, resize) {
_CommandInterceptor.default.call(this, eventBus);
function hideEmptyLabels(children) {
if (children.length) {
children.forEach(function (child) {
if (child.type === 'label' && !child.businessObject.name) {
child.hidden = true;
}
});
}
}
function expandedBounds(shape, defaultSize) {
var children = shape.children,
newBounds = defaultSize,
visibleElements,
visibleBBox;
visibleElements = filterVisible(children).concat([shape]);
visibleBBox = (0, _ResizeUtil.computeChildrenBBox)(visibleElements);
if (visibleBBox) {
// center to visibleBBox with max(defaultSize, childrenBounds)
newBounds.width = Math.max(visibleBBox.width, newBounds.width);
newBounds.height = Math.max(visibleBBox.height, newBounds.height);
newBounds.x = visibleBBox.x + (visibleBBox.width - newBounds.width) / 2;
newBounds.y = visibleBBox.y + (visibleBBox.height - newBounds.height) / 2;
} else {
// center to collapsed shape with defaultSize
newBounds.x = shape.x + (shape.width - newBounds.width) / 2;
newBounds.y = shape.y + (shape.height - newBounds.height) / 2;
}
return newBounds;
}
function collapsedBounds(shape, defaultSize) {
return {
x: shape.x + (shape.width - defaultSize.width) / 2,
y: shape.y + (shape.height - defaultSize.height) / 2,
width: defaultSize.width,
height: defaultSize.height
};
}
this.executed(['shape.toggleCollapse'], LOW_PRIORITY, function (e) {
var context = e.context,
shape = context.shape;
if (!(0, _ModelUtil.is)(shape, 'bpmn:SubProcess')) {
return;
}
if (!shape.collapsed) {
// all children got made visible through djs, hide empty labels
hideEmptyLabels(shape.children); // remove collapsed marker
(0, _ModelUtil.getBusinessObject)(shape).di.isExpanded = true;
} else {
// place collapsed marker
(0, _ModelUtil.getBusinessObject)(shape).di.isExpanded = false;
}
});
this.reverted(['shape.toggleCollapse'], LOW_PRIORITY, function (e) {
var context = e.context;
var shape = context.shape; // revert removing/placing collapsed marker
if (!shape.collapsed) {
(0, _ModelUtil.getBusinessObject)(shape).di.isExpanded = true;
} else {
(0, _ModelUtil.getBusinessObject)(shape).di.isExpanded = false;
}
});
this.postExecuted(['shape.toggleCollapse'], LOW_PRIORITY, function (e) {
var shape = e.context.shape,
defaultSize = elementFactory._getDefaultSize(shape),
newBounds;
if (shape.collapsed) {
// resize to default size of collapsed shapes
newBounds = collapsedBounds(shape, defaultSize);
} else {
// resize to bounds of max(visible children, defaultSize)
newBounds = expandedBounds(shape, defaultSize);
}
modeling.resizeShape(shape, newBounds, null, {
autoResize: shape.collapsed ? false : 'nwse'
});
});
}
(0, _inherits.default)(ToggleElementCollapseBehaviour, _CommandInterceptor.default);
ToggleElementCollapseBehaviour.$inject = ['eventBus', 'elementFactory', 'modeling']; // helpers //////////////////////
function filterVisible(elements) {
return elements.filter(function (e) {
return !e.hidden;
});
}
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"diagram-js/lib/features/resize/ResizeUtil":270,"inherits":349}],91:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UnclaimIdBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
var _DiUtil = require("../../../util/DiUtil");
var _LabelUtil = require("../../../util/LabelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Unclaims model IDs on element deletion.
*
* @param {Canvas} canvas
* @param {Injector} injector
* @param {Moddle} moddle
* @param {Modeling} modeling
*/
function UnclaimIdBehavior(canvas, injector, moddle, modeling) {
injector.invoke(_CommandInterceptor.default, this);
this.preExecute('shape.delete', function (event) {
var context = event.context,
shape = context.shape,
shapeBo = shape.businessObject;
if ((0, _LabelUtil.isLabel)(shape)) {
return;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant') && (0, _DiUtil.isExpanded)(shape)) {
moddle.ids.unclaim(shapeBo.processRef.id);
}
modeling.unclaimId(shapeBo.id, shapeBo);
});
this.preExecute('connection.delete', function (event) {
var context = event.context,
connection = context.connection,
connectionBo = connection.businessObject;
modeling.unclaimId(connectionBo.id, connectionBo);
});
this.preExecute('canvas.updateRoot', function () {
var rootElement = canvas.getRootElement(),
rootElementBo = rootElement.businessObject;
moddle.ids.unclaim(rootElementBo.id);
});
}
(0, _inherits.default)(UnclaimIdBehavior, _CommandInterceptor.default);
UnclaimIdBehavior.$inject = ['canvas', 'injector', 'moddle', 'modeling'];
},{"../../../util/DiUtil":140,"../../../util/LabelUtil":141,"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],92:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DeleteSequenceFlowBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* A behavior that unsets the Default property of
* sequence flow source on element delete, if the
* removed element is the Gateway or Task's default flow.
*
* @param {EventBus} eventBus
* @param {Modeling} modeling
*/
function DeleteSequenceFlowBehavior(eventBus, modeling) {
_CommandInterceptor.default.call(this, eventBus);
this.preExecute('connection.delete', function (event) {
var context = event.context,
connection = context.connection,
source = connection.source;
if (isDefaultFlow(connection, source)) {
modeling.updateProperties(source, {
'default': null
});
}
});
}
(0, _inherits.default)(DeleteSequenceFlowBehavior, _CommandInterceptor.default);
DeleteSequenceFlowBehavior.$inject = ['eventBus', 'modeling']; // helpers //////////////////////
function isDefaultFlow(connection, source) {
if (!(0, _ModelUtil.is)(connection, 'bpmn:SequenceFlow')) {
return false;
}
var sourceBo = (0, _ModelUtil.getBusinessObject)(source),
sequenceFlow = (0, _ModelUtil.getBusinessObject)(connection);
return sourceBo.get('default') === sequenceFlow;
}
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],93:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UpdateFlowNodeRefsBehavior;
var _inherits = _interopRequireDefault(require("inherits"));
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _ModelUtil = require("../../../util/ModelUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 500,
HIGH_PRIORITY = 5000;
/**
* BPMN specific delete lane behavior
*/
function UpdateFlowNodeRefsBehavior(eventBus, modeling, translate) {
_CommandInterceptor.default.call(this, eventBus);
/**
* Ok, this is it:
*
* We have to update the Lane#flowNodeRefs _and_
* FlowNode#lanes with every FlowNode move/resize and
* Lane move/resize.
*
* We want to group that stuff to recompute containments
* as efficient as possible.
*
* Yea!
*/
// the update context
var context;
function initContext() {
context = context || new UpdateContext();
context.enter();
return context;
}
function getContext() {
if (!context) {
throw new Error(translate('out of bounds release'));
}
return context;
}
function releaseContext() {
if (!context) {
throw new Error(translate('out of bounds release'));
}
var triggerUpdate = context.leave();
if (triggerUpdate) {
modeling.updateLaneRefs(context.flowNodes, context.lanes);
context = null;
}
return triggerUpdate;
}
var laneRefUpdateEvents = ['spaceTool', 'lane.add', 'lane.resize', 'lane.split', 'elements.create', 'elements.delete', 'elements.move', 'shape.create', 'shape.delete', 'shape.move', 'shape.resize']; // listen to a lot of stuff to group lane updates
this.preExecute(laneRefUpdateEvents, HIGH_PRIORITY, function (event) {
initContext();
});
this.postExecuted(laneRefUpdateEvents, LOW_PRIORITY, function (event) {
releaseContext();
}); // Mark flow nodes + lanes that need an update
this.preExecute(['shape.create', 'shape.move', 'shape.delete', 'shape.resize'], function (event) {
var context = event.context,
shape = context.shape;
var updateContext = getContext(); // no need to update labels
if (shape.labelTarget) {
return;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:Lane')) {
updateContext.addLane(shape);
}
if ((0, _ModelUtil.is)(shape, 'bpmn:FlowNode')) {
updateContext.addFlowNode(shape);
}
});
}
UpdateFlowNodeRefsBehavior.$inject = ['eventBus', 'modeling', 'translate'];
(0, _inherits.default)(UpdateFlowNodeRefsBehavior, _CommandInterceptor.default);
function UpdateContext() {
this.flowNodes = [];
this.lanes = [];
this.counter = 0;
this.addLane = function (lane) {
this.lanes.push(lane);
};
this.addFlowNode = function (flowNode) {
this.flowNodes.push(flowNode);
};
this.enter = function () {
this.counter++;
};
this.leave = function () {
this.counter--;
return !this.counter;
};
}
},{"../../../util/ModelUtil":142,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349}],94:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _AdaptiveLabelPositioningBehavior = _interopRequireDefault(require("./AdaptiveLabelPositioningBehavior"));
var _AppendBehavior = _interopRequireDefault(require("./AppendBehavior"));
var _AssociationBehavior = _interopRequireDefault(require("./AssociationBehavior"));
var _AttachEventBehavior = _interopRequireDefault(require("./AttachEventBehavior"));
var _BoundaryEventBehavior = _interopRequireDefault(require("./BoundaryEventBehavior"));
var _RootElementReferenceBehavior = _interopRequireDefault(require("./RootElementReferenceBehavior"));
var _CreateBehavior = _interopRequireDefault(require("./CreateBehavior"));
var _FixHoverBehavior = _interopRequireDefault(require("./FixHoverBehavior"));
var _CreateDataObjectBehavior = _interopRequireDefault(require("./CreateDataObjectBehavior"));
var _CreateParticipantBehavior = _interopRequireDefault(require("./CreateParticipantBehavior"));
var _DataInputAssociationBehavior = _interopRequireDefault(require("./DataInputAssociationBehavior"));
var _DataStoreBehavior = _interopRequireDefault(require("./DataStoreBehavior"));
var _DeleteLaneBehavior = _interopRequireDefault(require("./DeleteLaneBehavior"));
var _DetachEventBehavior = _interopRequireDefault(require("./DetachEventBehavior"));
var _DropOnFlowBehavior = _interopRequireDefault(require("./DropOnFlowBehavior"));
var _EventBasedGatewayBehavior = _interopRequireDefault(require("./EventBasedGatewayBehavior"));
var _GroupBehavior = _interopRequireDefault(require("./GroupBehavior"));
var _ImportDockingFix = _interopRequireDefault(require("./ImportDockingFix"));
var _IsHorizontalFix = _interopRequireDefault(require("./IsHorizontalFix"));
var _LabelBehavior = _interopRequireDefault(require("./LabelBehavior"));
var _ModelingFeedback = _interopRequireDefault(require("./ModelingFeedback"));
var _ReplaceConnectionBehavior = _interopRequireDefault(require("./ReplaceConnectionBehavior"));
var _RemoveParticipantBehavior = _interopRequireDefault(require("./RemoveParticipantBehavior"));
var _ReplaceElementBehaviour = _interopRequireDefault(require("./ReplaceElementBehaviour"));
var _ResizeBehavior = _interopRequireDefault(require("./ResizeBehavior"));
var _ResizeLaneBehavior = _interopRequireDefault(require("./ResizeLaneBehavior"));
var _RemoveElementBehavior = _interopRequireDefault(require("./RemoveElementBehavior"));
var _SpaceToolBehavior = _interopRequireDefault(require("./SpaceToolBehavior"));
var _SubProcessStartEventBehavior = _interopRequireDefault(require("./SubProcessStartEventBehavior"));
var _ToggleElementCollapseBehaviour = _interopRequireDefault(require("./ToggleElementCollapseBehaviour"));
var _UnclaimIdBehavior = _interopRequireDefault(require("./UnclaimIdBehavior"));
var _UpdateFlowNodeRefsBehavior = _interopRequireDefault(require("./UpdateFlowNodeRefsBehavior"));
var _UnsetDefaultFlowBehavior = _interopRequireDefault(require("./UnsetDefaultFlowBehavior"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['adaptiveLabelPositioningBehavior', 'appendBehavior', 'associationBehavior', 'attachEventBehavior', 'boundaryEventBehavior', 'rootElementReferenceBehavior', 'createBehavior', 'fixHoverBehavior', 'createDataObjectBehavior', 'createParticipantBehavior', 'dataStoreBehavior', 'dataInputAssociationBehavior', 'deleteLaneBehavior', 'detachEventBehavior', 'dropOnFlowBehavior', 'eventBasedGatewayBehavior', 'groupBehavior', 'importDockingFix', 'isHorizontalFix', 'labelBehavior', 'modelingFeedback', 'removeElementBehavior', 'removeParticipantBehavior', 'replaceConnectionBehavior', 'replaceElementBehaviour', 'resizeBehavior', 'resizeLaneBehavior', 'toggleElementCollapseBehaviour', 'spaceToolBehavior', 'subProcessStartEventBehavior', 'unclaimIdBehavior', 'unsetDefaultFlowBehavior', 'updateFlowNodeRefsBehavior'],
adaptiveLabelPositioningBehavior: ['type', _AdaptiveLabelPositioningBehavior.default],
appendBehavior: ['type', _AppendBehavior.default],
associationBehavior: ['type', _AssociationBehavior.default],
attachEventBehavior: ['type', _AttachEventBehavior.default],
boundaryEventBehavior: ['type', _BoundaryEventBehavior.default],
rootElementReferenceBehavior: ['type', _RootElementReferenceBehavior.default],
createBehavior: ['type', _CreateBehavior.default],
fixHoverBehavior: ['type', _FixHoverBehavior.default],
createDataObjectBehavior: ['type', _CreateDataObjectBehavior.default],
createParticipantBehavior: ['type', _CreateParticipantBehavior.default],
dataInputAssociationBehavior: ['type', _DataInputAssociationBehavior.default],
dataStoreBehavior: ['type', _DataStoreBehavior.default],
deleteLaneBehavior: ['type', _DeleteLaneBehavior.default],
detachEventBehavior: ['type', _DetachEventBehavior.default],
dropOnFlowBehavior: ['type', _DropOnFlowBehavior.default],
eventBasedGatewayBehavior: ['type', _EventBasedGatewayBehavior.default],
groupBehavior: ['type', _GroupBehavior.default],
importDockingFix: ['type', _ImportDockingFix.default],
isHorizontalFix: ['type', _IsHorizontalFix.default],
labelBehavior: ['type', _LabelBehavior.default],
modelingFeedback: ['type', _ModelingFeedback.default],
replaceConnectionBehavior: ['type', _ReplaceConnectionBehavior.default],
removeParticipantBehavior: ['type', _RemoveParticipantBehavior.default],
replaceElementBehaviour: ['type', _ReplaceElementBehaviour.default],
resizeBehavior: ['type', _ResizeBehavior.default],
resizeLaneBehavior: ['type', _ResizeLaneBehavior.default],
removeElementBehavior: ['type', _RemoveElementBehavior.default],
toggleElementCollapseBehaviour: ['type', _ToggleElementCollapseBehaviour.default],
spaceToolBehavior: ['type', _SpaceToolBehavior.default],
subProcessStartEventBehavior: ['type', _SubProcessStartEventBehavior.default],
unclaimIdBehavior: ['type', _UnclaimIdBehavior.default],
updateFlowNodeRefsBehavior: ['type', _UpdateFlowNodeRefsBehavior.default],
unsetDefaultFlowBehavior: ['type', _UnsetDefaultFlowBehavior.default]
};
exports.default = _default;
},{"./AdaptiveLabelPositioningBehavior":61,"./AppendBehavior":62,"./AssociationBehavior":63,"./AttachEventBehavior":64,"./BoundaryEventBehavior":65,"./CreateBehavior":66,"./CreateDataObjectBehavior":67,"./CreateParticipantBehavior":68,"./DataInputAssociationBehavior":69,"./DataStoreBehavior":70,"./DeleteLaneBehavior":71,"./DetachEventBehavior":72,"./DropOnFlowBehavior":73,"./EventBasedGatewayBehavior":74,"./FixHoverBehavior":75,"./GroupBehavior":76,"./ImportDockingFix":77,"./IsHorizontalFix":78,"./LabelBehavior":79,"./ModelingFeedback":80,"./RemoveElementBehavior":81,"./RemoveParticipantBehavior":82,"./ReplaceConnectionBehavior":83,"./ReplaceElementBehaviour":84,"./ResizeBehavior":85,"./ResizeLaneBehavior":86,"./RootElementReferenceBehavior":87,"./SpaceToolBehavior":88,"./SubProcessStartEventBehavior":89,"./ToggleElementCollapseBehaviour":90,"./UnclaimIdBehavior":91,"./UnsetDefaultFlowBehavior":92,"./UpdateFlowNodeRefsBehavior":93}],95:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCategoryValue = createCategoryValue;
var _Collections = require("diagram-js/lib/util/Collections");
var _ModelUtil = require("../../../../util/ModelUtil");
/**
* Creates a new bpmn:CategoryValue inside a new bpmn:Category
*
* @param {ModdleElement} definitions
* @param {BpmnFactory} bpmnFactory
*
* @return {ModdleElement} categoryValue.
*/
function createCategoryValue(definitions, bpmnFactory) {
var categoryValue = bpmnFactory.create('bpmn:CategoryValue'),
category = bpmnFactory.create('bpmn:Category', {
categoryValue: [categoryValue]
}); // add to correct place
(0, _Collections.add)(definitions.get('rootElements'), category);
(0, _ModelUtil.getBusinessObject)(category).$parent = definitions;
(0, _ModelUtil.getBusinessObject)(categoryValue).$parent = category;
return categoryValue;
}
},{"../../../../util/ModelUtil":142,"diagram-js/lib/util/Collections":315}],96:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAngle = getAngle;
exports.getDistancePointLine = getDistancePointLine;
exports.getDistancePointPoint = getDistancePointPoint;
exports.perpendicularFoot = perpendicularFoot;
exports.rotateVector = rotateVector;
exports.vectorLength = vectorLength;
/**
* Returns the length of a vector
*
* @param {Vector}
* @return {Float}
*/
function vectorLength(v) {
return Math.sqrt(Math.pow(v.x, 2) + Math.pow(v.y, 2));
}
/**
* Calculates the angle between a line a the yAxis
*
* @param {Array}
* @return {Float}
*/
function getAngle(line) {
// return value is between 0, 180 and -180, -0
// @janstuemmel: maybe replace return a/b with b/a
return Math.atan((line[1].y - line[0].y) / (line[1].x - line[0].x));
}
/**
* Rotates a vector by a given angle
*
* @param {Vector}
* @param {Float} Angle in radians
* @return {Vector}
*/
function rotateVector(vector, angle) {
return !angle ? vector : {
x: Math.cos(angle) * vector.x - Math.sin(angle) * vector.y,
y: Math.sin(angle) * vector.x + Math.cos(angle) * vector.y
};
}
/**
* Solves a 2D equation system
* a + r*b = c, where a,b,c are 2D vectors
*
* @param {Vector}
* @param {Vector}
* @param {Vector}
* @return {Float}
*/
function solveLambaSystem(a, b, c) {
// the 2d system
var system = [{
n: a[0] - c[0],
lambda: b[0]
}, {
n: a[1] - c[1],
lambda: b[1]
}]; // solve
var n = system[0].n * b[0] + system[1].n * b[1],
l = system[0].lambda * b[0] + system[1].lambda * b[1];
return -n / l;
}
/**
* Position of perpendicular foot
*
* @param {Point}
* @param [ {Point}, {Point} ] line defined through two points
* @return {Point} the perpendicular foot position
*/
function perpendicularFoot(point, line) {
var a = line[0],
b = line[1]; // relative position of b from a
var bd = {
x: b.x - a.x,
y: b.y - a.y
}; // solve equation system to the parametrized vectors param real value
var r = solveLambaSystem([a.x, a.y], [bd.x, bd.y], [point.x, point.y]);
return {
x: a.x + r * bd.x,
y: a.y + r * bd.y
};
}
/**
* Calculates the distance between a point and a line
*
* @param {Point}
* @param [ {Point}, {Point} ] line defined through two points
* @return {Float} distance
*/
function getDistancePointLine(point, line) {
var pfPoint = perpendicularFoot(point, line); // distance vector
var connectionVector = {
x: pfPoint.x - point.x,
y: pfPoint.y - point.y
};
return vectorLength(connectionVector);
}
/**
* Calculates the distance between two points
*
* @param {Point}
* @param {Point}
* @return {Float} distance
*/
function getDistancePointPoint(point1, point2) {
return vectorLength({
x: point1.x - point2.x,
y: point1.y - point2.y
});
}
},{}],97:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findNewLabelLineStartIndex = findNewLabelLineStartIndex;
exports.getLabelAdjustment = getLabelAdjustment;
var _GeometricUtil = require("./GeometricUtil");
var _LineAttachmentUtil = require("./LineAttachmentUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
function findNewLabelLineStartIndex(oldWaypoints, newWaypoints, attachment, hints) {
var index = attachment.segmentIndex;
var offset = newWaypoints.length - oldWaypoints.length; // segmentMove happened
if (hints.segmentMove) {
var oldSegmentStartIndex = hints.segmentMove.segmentStartIndex,
newSegmentStartIndex = hints.segmentMove.newSegmentStartIndex; // if label was on moved segment return new segment index
if (index === oldSegmentStartIndex) {
return newSegmentStartIndex;
} // label is after new segment index
if (index >= newSegmentStartIndex) {
return index + offset < newSegmentStartIndex ? newSegmentStartIndex : index + offset;
} // if label is before new segment index
return index;
} // bendpointMove happened
if (hints.bendpointMove) {
var insert = hints.bendpointMove.insert,
bendpointIndex = hints.bendpointMove.bendpointIndex,
newIndex; // waypoints length didnt change
if (offset === 0) {
return index;
} // label behind new/removed bendpoint
if (index >= bendpointIndex) {
newIndex = insert ? index + 1 : index - 1;
} // label before new/removed bendpoint
if (index < bendpointIndex) {
newIndex = index; // decide label should take right or left segment
if (insert && attachment.type !== 'bendpoint' && bendpointIndex - 1 === index) {
var rel = relativePositionMidWaypoint(newWaypoints, bendpointIndex);
if (rel < attachment.relativeLocation) {
newIndex++;
}
}
}
return newIndex;
} // start/end changed
if (offset === 0) {
return index;
}
if (hints.connectionStart) {
return index === 0 ? 0 : null;
}
if (hints.connectionEnd) {
return index === oldWaypoints.length - 2 ? newWaypoints.length - 2 : null;
} // if nothing fits, return null
return null;
}
/**
* Calculate the required adjustment (move delta) for the given label
* after the connection waypoints got updated.
*
* @param {djs.model.Label} label
* @param {Array} newWaypoints
* @param {Array} oldWaypoints
* @param {Object} hints
*
* @return {Point} delta
*/
function getLabelAdjustment(label, newWaypoints, oldWaypoints, hints) {
var x = 0,
y = 0;
var labelPosition = getLabelMid(label); // get closest attachment
var attachment = (0, _LineAttachmentUtil.getAttachment)(labelPosition, oldWaypoints),
oldLabelLineIndex = attachment.segmentIndex,
newLabelLineIndex = findNewLabelLineStartIndex(oldWaypoints, newWaypoints, attachment, hints);
if (newLabelLineIndex === null) {
return {
x: x,
y: y
};
} // should never happen
// TODO(@janstuemmel): throw an error here when connectionSegmentMove is refactored
if (newLabelLineIndex < 0 || newLabelLineIndex > newWaypoints.length - 2) {
return {
x: x,
y: y
};
}
var oldLabelLine = getLine(oldWaypoints, oldLabelLineIndex),
newLabelLine = getLine(newWaypoints, newLabelLineIndex),
oldFoot = attachment.position;
var relativeFootPosition = getRelativeFootPosition(oldLabelLine, oldFoot),
angleDelta = getAngleDelta(oldLabelLine, newLabelLine); // special rule if label on bendpoint
if (attachment.type === 'bendpoint') {
var offset = newWaypoints.length - oldWaypoints.length,
oldBendpointIndex = attachment.bendpointIndex,
oldBendpoint = oldWaypoints[oldBendpointIndex]; // bendpoint position hasn't changed, return same position
if (newWaypoints.indexOf(oldBendpoint) !== -1) {
return {
x: x,
y: y
};
} // new bendpoint and old bendpoint have same index, then just return the offset
if (offset === 0) {
var newBendpoint = newWaypoints[oldBendpointIndex];
return {
x: newBendpoint.x - attachment.position.x,
y: newBendpoint.y - attachment.position.y
};
} // if bendpoints get removed
if (offset < 0 && oldBendpointIndex !== 0 && oldBendpointIndex < oldWaypoints.length - 1) {
relativeFootPosition = relativePositionMidWaypoint(oldWaypoints, oldBendpointIndex);
}
}
var newFoot = {
x: (newLabelLine[1].x - newLabelLine[0].x) * relativeFootPosition + newLabelLine[0].x,
y: (newLabelLine[1].y - newLabelLine[0].y) * relativeFootPosition + newLabelLine[0].y
}; // the rotated vector to label
var newLabelVector = (0, _GeometricUtil.rotateVector)({
x: labelPosition.x - oldFoot.x,
y: labelPosition.y - oldFoot.y
}, angleDelta); // the new relative position
x = newFoot.x + newLabelVector.x - labelPosition.x;
y = newFoot.y + newLabelVector.y - labelPosition.y;
return (0, _LayoutUtil.roundPoint)({
x: x,
y: y
});
} // HELPERS //////////////////////
function relativePositionMidWaypoint(waypoints, idx) {
var distanceSegment1 = (0, _GeometricUtil.getDistancePointPoint)(waypoints[idx - 1], waypoints[idx]),
distanceSegment2 = (0, _GeometricUtil.getDistancePointPoint)(waypoints[idx], waypoints[idx + 1]);
var relativePosition = distanceSegment1 / (distanceSegment1 + distanceSegment2);
return relativePosition;
}
function getLabelMid(label) {
return {
x: label.x + label.width / 2,
y: label.y + label.height / 2
};
}
function getAngleDelta(l1, l2) {
var a1 = (0, _GeometricUtil.getAngle)(l1),
a2 = (0, _GeometricUtil.getAngle)(l2);
return a2 - a1;
}
function getLine(waypoints, idx) {
return [waypoints[idx], waypoints[idx + 1]];
}
function getRelativeFootPosition(line, foot) {
var length = (0, _GeometricUtil.getDistancePointPoint)(line[0], line[1]),
lengthToFoot = (0, _GeometricUtil.getDistancePointPoint)(line[0], foot);
return length === 0 ? 0 : lengthToFoot / length;
}
},{"./GeometricUtil":96,"./LineAttachmentUtil":98,"diagram-js/lib/layout/LayoutUtil":302}],98:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAttachment = getAttachment;
var sqrt = Math.sqrt,
min = Math.min,
max = Math.max,
abs = Math.abs;
/**
* Calculate the square (power to two) of a number.
*
* @param {number} n
*
* @return {number}
*/
function sq(n) {
return Math.pow(n, 2);
}
/**
* Get distance between two points.
*
* @param {Point} p1
* @param {Point} p2
*
* @return {number}
*/
function getDistance(p1, p2) {
return sqrt(sq(p1.x - p2.x) + sq(p1.y - p2.y));
}
/**
* Return the attachment of the given point on the specified line.
*
* The attachment is either a bendpoint (attached to the given point)
* or segment (attached to a location on a line segment) attachment:
*
* ```javascript
* var pointAttachment = {
* type: 'bendpoint',
* bendpointIndex: 3,
* position: { x: 10, y: 10 } // the attach point on the line
* };
*
* var segmentAttachment = {
* type: 'segment',
* segmentIndex: 2,
* relativeLocation: 0.31, // attach point location between 0 (at start) and 1 (at end)
* position: { x: 10, y: 10 } // the attach point on the line
* };
* ```
*
* @param {Point} point
* @param {Array} line
*
* @return {Object} attachment
*/
function getAttachment(point, line) {
var idx = 0,
segmentStart,
segmentEnd,
segmentStartDistance,
segmentEndDistance,
attachmentPosition,
minDistance,
intersections,
attachment,
attachmentDistance,
closestAttachmentDistance,
closestAttachment;
for (idx = 0; idx < line.length - 1; idx++) {
segmentStart = line[idx];
segmentEnd = line[idx + 1];
if (pointsEqual(segmentStart, segmentEnd)) {
intersections = [segmentStart];
} else {
segmentStartDistance = getDistance(point, segmentStart);
segmentEndDistance = getDistance(point, segmentEnd);
minDistance = min(segmentStartDistance, segmentEndDistance);
intersections = getCircleSegmentIntersections(segmentStart, segmentEnd, point, minDistance);
}
if (intersections.length < 1) {
throw new Error('expected between [1, 2] circle -> line intersections');
} // one intersection -> bendpoint attachment
if (intersections.length === 1) {
attachment = {
type: 'bendpoint',
position: intersections[0],
segmentIndex: idx,
bendpointIndex: pointsEqual(segmentStart, intersections[0]) ? idx : idx + 1
};
} // two intersections -> segment attachment
if (intersections.length === 2) {
attachmentPosition = mid(intersections[0], intersections[1]);
attachment = {
type: 'segment',
position: attachmentPosition,
segmentIndex: idx,
relativeLocation: getDistance(segmentStart, attachmentPosition) / getDistance(segmentStart, segmentEnd)
};
}
attachmentDistance = getDistance(attachment.position, point);
if (!closestAttachment || closestAttachmentDistance > attachmentDistance) {
closestAttachment = attachment;
closestAttachmentDistance = attachmentDistance;
}
}
return closestAttachment;
}
/**
* Gets the intersection between a circle and a line segment.
*
* @param {Point} s1 segment start
* @param {Point} s2 segment end
* @param {Point} cc circle center
* @param {number} cr circle radius
*
* @return {Array} intersections
*/
function getCircleSegmentIntersections(s1, s2, cc, cr) {
var baX = s2.x - s1.x;
var baY = s2.y - s1.y;
var caX = cc.x - s1.x;
var caY = cc.y - s1.y;
var a = baX * baX + baY * baY;
var bBy2 = baX * caX + baY * caY;
var c = caX * caX + caY * caY - cr * cr;
var pBy2 = bBy2 / a;
var q = c / a;
var disc = pBy2 * pBy2 - q; // check against negative value to work around
// negative, very close to zero results (-4e-15)
// being produced in some environments
if (disc < 0 && disc > -0.000001) {
disc = 0;
}
if (disc < 0) {
return [];
} // if disc == 0 ... dealt with later
var tmpSqrt = sqrt(disc);
var abScalingFactor1 = -pBy2 + tmpSqrt;
var abScalingFactor2 = -pBy2 - tmpSqrt;
var i1 = {
x: s1.x - baX * abScalingFactor1,
y: s1.y - baY * abScalingFactor1
};
if (disc === 0) {
// abScalingFactor1 == abScalingFactor2
return [i1];
}
var i2 = {
x: s1.x - baX * abScalingFactor2,
y: s1.y - baY * abScalingFactor2
}; // return only points on line segment
return [i1, i2].filter(function (p) {
return isPointInSegment(p, s1, s2);
});
}
function isPointInSegment(p, segmentStart, segmentEnd) {
return fenced(p.x, segmentStart.x, segmentEnd.x) && fenced(p.y, segmentStart.y, segmentEnd.y);
}
function fenced(n, rangeStart, rangeEnd) {
// use matching threshold to work around
// precision errors in intersection computation
return n >= min(rangeStart, rangeEnd) - EQUAL_THRESHOLD && n <= max(rangeStart, rangeEnd) + EQUAL_THRESHOLD;
}
/**
* Calculate mid of two points.
*
* @param {Point} p1
* @param {Point} p2
*
* @return {Point}
*/
function mid(p1, p2) {
return {
x: (p1.x + p2.x) / 2,
y: (p1.y + p2.y) / 2
};
}
var EQUAL_THRESHOLD = 0.1;
function pointsEqual(p1, p2) {
return abs(p1.x - p2.x) <= EQUAL_THRESHOLD && abs(p1.y - p2.y) <= EQUAL_THRESHOLD;
}
},{}],99:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = lineIntersect;
/**
* Returns the intersection between two line segments a and b.
*
* @param {Point} l1s
* @param {Point} l1e
* @param {Point} l2s
* @param {Point} l2e
*
* @return {Point}
*/
function lineIntersect(l1s, l1e, l2s, l2e) {
// if the lines intersect, the result contains the x and y of the
// intersection (treating the lines as infinite) and booleans for
// whether line segment 1 or line segment 2 contain the point
var denominator, a, b, c, numerator;
denominator = (l2e.y - l2s.y) * (l1e.x - l1s.x) - (l2e.x - l2s.x) * (l1e.y - l1s.y);
if (denominator == 0) {
return null;
}
a = l1s.y - l2s.y;
b = l1s.x - l2s.x;
numerator = (l2e.x - l2s.x) * a - (l2e.y - l2s.y) * b;
c = numerator / denominator; // if we cast these lines infinitely in
// both directions, they intersect here
return {
x: Math.round(l1s.x + c * (l1e.x - l1s.x)),
y: Math.round(l1s.y + c * (l1e.y - l1s.y))
};
}
},{}],100:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getParticipantResizeConstraints = getParticipantResizeConstraints;
var _ModelUtil = require("../../../../util/ModelUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _LaneUtil = require("../../../modeling/util/LaneUtil");
var _ResizeBehavior = require("../ResizeBehavior");
var abs = Math.abs,
min = Math.min,
max = Math.max;
function addToTrbl(trbl, attr, value, choice) {
var current = trbl[attr]; // make sure to set the value if it does not exist
// or apply the correct value by comparing against
// choice(value, currentValue)
trbl[attr] = current === undefined ? value : choice(value, current);
}
function addMin(trbl, attr, value) {
return addToTrbl(trbl, attr, value, min);
}
function addMax(trbl, attr, value) {
return addToTrbl(trbl, attr, value, max);
}
var LANE_RIGHT_PADDING = 20,
LANE_LEFT_PADDING = 50,
LANE_TOP_PADDING = 20,
LANE_BOTTOM_PADDING = 20;
function getParticipantResizeConstraints(laneShape, resizeDirection, balanced) {
var lanesRoot = (0, _LaneUtil.getLanesRoot)(laneShape);
var isFirst = true,
isLast = true; // max top/bottom size for lanes
var allLanes = (0, _LaneUtil.collectLanes)(lanesRoot, [lanesRoot]);
var laneTrbl = (0, _LayoutUtil.asTRBL)(laneShape);
var maxTrbl = {},
minTrbl = {};
if (/e/.test(resizeDirection)) {
minTrbl.right = laneTrbl.left + _ResizeBehavior.LANE_MIN_DIMENSIONS.width;
} else if (/w/.test(resizeDirection)) {
minTrbl.left = laneTrbl.right - _ResizeBehavior.LANE_MIN_DIMENSIONS.width;
}
allLanes.forEach(function (other) {
var otherTrbl = (0, _LayoutUtil.asTRBL)(other);
if (/n/.test(resizeDirection)) {
if (otherTrbl.top < laneTrbl.top - 10) {
isFirst = false;
} // max top size (based on next element)
if (balanced && abs(laneTrbl.top - otherTrbl.bottom) < 10) {
addMax(maxTrbl, 'top', otherTrbl.top + _ResizeBehavior.LANE_MIN_DIMENSIONS.height);
} // min top size (based on self or nested element)
if (abs(laneTrbl.top - otherTrbl.top) < 5) {
addMin(minTrbl, 'top', otherTrbl.bottom - _ResizeBehavior.LANE_MIN_DIMENSIONS.height);
}
}
if (/s/.test(resizeDirection)) {
if (otherTrbl.bottom > laneTrbl.bottom + 10) {
isLast = false;
} // max bottom size (based on previous element)
if (balanced && abs(laneTrbl.bottom - otherTrbl.top) < 10) {
addMin(maxTrbl, 'bottom', otherTrbl.bottom - _ResizeBehavior.LANE_MIN_DIMENSIONS.height);
} // min bottom size (based on self or nested element)
if (abs(laneTrbl.bottom - otherTrbl.bottom) < 5) {
addMax(minTrbl, 'bottom', otherTrbl.top + _ResizeBehavior.LANE_MIN_DIMENSIONS.height);
}
}
}); // max top/bottom/left/right size based on flow nodes
var flowElements = lanesRoot.children.filter(function (s) {
return !s.hidden && !s.waypoints && ((0, _ModelUtil.is)(s, 'bpmn:FlowElement') || (0, _ModelUtil.is)(s, 'bpmn:Artifact'));
});
flowElements.forEach(function (flowElement) {
var flowElementTrbl = (0, _LayoutUtil.asTRBL)(flowElement);
if (isFirst && /n/.test(resizeDirection)) {
addMin(minTrbl, 'top', flowElementTrbl.top - LANE_TOP_PADDING);
}
if (/e/.test(resizeDirection)) {
addMax(minTrbl, 'right', flowElementTrbl.right + LANE_RIGHT_PADDING);
}
if (isLast && /s/.test(resizeDirection)) {
addMax(minTrbl, 'bottom', flowElementTrbl.bottom + LANE_BOTTOM_PADDING);
}
if (/w/.test(resizeDirection)) {
addMin(minTrbl, 'left', flowElementTrbl.left - LANE_LEFT_PADDING);
}
});
return {
min: minTrbl,
max: maxTrbl
};
}
},{"../../../../util/ModelUtil":142,"../../../modeling/util/LaneUtil":112,"../ResizeBehavior":85,"diagram-js/lib/layout/LayoutUtil":302}],101:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AddLaneHandler;
var _minDash = require("min-dash");
var _Elements = require("diagram-js/lib/util/Elements");
var _LaneUtil = require("../util/LaneUtil");
/**
* A handler that allows us to add a new lane
* above or below an existing one.
*
* @param {Modeling} modeling
* @param {SpaceTool} spaceTool
*/
function AddLaneHandler(modeling, spaceTool) {
this._modeling = modeling;
this._spaceTool = spaceTool;
}
AddLaneHandler.$inject = ['modeling', 'spaceTool'];
AddLaneHandler.prototype.preExecute = function (context) {
var spaceTool = this._spaceTool,
modeling = this._modeling;
var shape = context.shape,
location = context.location;
var lanesRoot = (0, _LaneUtil.getLanesRoot)(shape);
var isRoot = lanesRoot === shape,
laneParent = isRoot ? shape : shape.parent;
var existingChildLanes = (0, _LaneUtil.getChildLanes)(laneParent); // (0) add a lane if we currently got none and are adding to root
if (!existingChildLanes.length) {
modeling.createShape({
type: 'bpmn:Lane'
}, {
x: shape.x + _LaneUtil.LANE_INDENTATION,
y: shape.y,
width: shape.width - _LaneUtil.LANE_INDENTATION,
height: shape.height
}, laneParent);
} // (1) collect affected elements to create necessary space
var allAffected = [];
(0, _Elements.eachElement)(lanesRoot, function (element) {
allAffected.push(element); // handle element labels in the diagram root
if (element.label) {
allAffected.push(element.label);
}
if (element === shape) {
return [];
}
return (0, _minDash.filter)(element.children, function (c) {
return c !== shape;
});
});
var offset = location === 'top' ? -120 : 120,
lanePosition = location === 'top' ? shape.y : shape.y + shape.height,
spacePos = lanePosition + (location === 'top' ? 10 : -10),
direction = location === 'top' ? 'n' : 's';
var adjustments = spaceTool.calculateAdjustments(allAffected, 'y', offset, spacePos);
spaceTool.makeSpace(adjustments.movingShapes, adjustments.resizingShapes, {
x: 0,
y: offset
}, direction, spacePos); // (2) create new lane at open space
context.newLane = modeling.createShape({
type: 'bpmn:Lane'
}, {
x: shape.x + (isRoot ? _LaneUtil.LANE_INDENTATION : 0),
y: lanePosition - (location === 'top' ? 120 : 0),
width: shape.width - (isRoot ? _LaneUtil.LANE_INDENTATION : 0),
height: 120
}, laneParent);
};
},{"../util/LaneUtil":112,"diagram-js/lib/util/Elements":317,"min-dash":559}],102:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = IdClaimHandler;
function IdClaimHandler(moddle) {
this._moddle = moddle;
}
IdClaimHandler.$inject = ['moddle'];
IdClaimHandler.prototype.execute = function (context) {
var ids = this._moddle.ids,
id = context.id,
element = context.element,
claiming = context.claiming;
if (claiming) {
ids.claim(id, element);
} else {
ids.unclaim(id);
}
};
/**
* Command revert implementation.
*/
IdClaimHandler.prototype.revert = function (context) {
var ids = this._moddle.ids,
id = context.id,
element = context.element,
claiming = context.claiming;
if (claiming) {
ids.unclaim(id);
} else {
ids.claim(id, element);
}
};
},{}],103:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ResizeLaneHandler;
var _ModelUtil = require("../../../util/ModelUtil");
var _LaneUtil = require("../util/LaneUtil");
var _Elements = require("diagram-js/lib/util/Elements");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _ResizeUtil = require("diagram-js/lib/features/resize/ResizeUtil");
/**
* A handler that resizes a lane.
*
* @param {Modeling} modeling
*/
function ResizeLaneHandler(modeling, spaceTool) {
this._modeling = modeling;
this._spaceTool = spaceTool;
}
ResizeLaneHandler.$inject = ['modeling', 'spaceTool'];
ResizeLaneHandler.prototype.preExecute = function (context) {
var shape = context.shape,
newBounds = context.newBounds,
balanced = context.balanced;
if (balanced !== false) {
this.resizeBalanced(shape, newBounds);
} else {
this.resizeSpace(shape, newBounds);
}
};
/**
* Resize balanced, adjusting next / previous lane sizes.
*
* @param {djs.model.Shape} shape
* @param {Bounds} newBounds
*/
ResizeLaneHandler.prototype.resizeBalanced = function (shape, newBounds) {
var modeling = this._modeling;
var resizeNeeded = (0, _LaneUtil.computeLanesResize)(shape, newBounds); // resize the lane
modeling.resizeShape(shape, newBounds); // resize other lanes as needed
resizeNeeded.forEach(function (r) {
modeling.resizeShape(r.shape, r.newBounds);
});
};
/**
* Resize, making actual space and moving below / above elements.
*
* @param {djs.model.Shape} shape
* @param {Bounds} newBounds
*/
ResizeLaneHandler.prototype.resizeSpace = function (shape, newBounds) {
var spaceTool = this._spaceTool;
var shapeTrbl = (0, _LayoutUtil.asTRBL)(shape),
newTrbl = (0, _LayoutUtil.asTRBL)(newBounds);
var trblDiff = (0, _ResizeUtil.substractTRBL)(newTrbl, shapeTrbl);
var lanesRoot = (0, _LaneUtil.getLanesRoot)(shape);
var allAffected = [],
allLanes = [];
(0, _Elements.eachElement)(lanesRoot, function (element) {
allAffected.push(element);
if ((0, _ModelUtil.is)(element, 'bpmn:Lane') || (0, _ModelUtil.is)(element, 'bpmn:Participant')) {
allLanes.push(element);
}
return element.children;
});
var change, spacePos, direction, offset, adjustments;
if (trblDiff.bottom || trblDiff.top) {
change = trblDiff.bottom || trblDiff.top;
spacePos = shape.y + (trblDiff.bottom ? shape.height : 0) + (trblDiff.bottom ? -10 : 10);
direction = trblDiff.bottom ? 's' : 'n';
offset = trblDiff.top > 0 || trblDiff.bottom < 0 ? -change : change;
adjustments = spaceTool.calculateAdjustments(allAffected, 'y', offset, spacePos);
spaceTool.makeSpace(adjustments.movingShapes, adjustments.resizingShapes, {
x: 0,
y: change
}, direction);
}
if (trblDiff.left || trblDiff.right) {
change = trblDiff.right || trblDiff.left;
spacePos = shape.x + (trblDiff.right ? shape.width : 0) + (trblDiff.right ? -10 : 100);
direction = trblDiff.right ? 'e' : 'w';
offset = trblDiff.left > 0 || trblDiff.right < 0 ? -change : change;
adjustments = spaceTool.calculateAdjustments(allLanes, 'x', offset, spacePos);
spaceTool.makeSpace(adjustments.movingShapes, adjustments.resizingShapes, {
x: change,
y: 0
}, direction);
}
};
},{"../../../util/ModelUtil":142,"../util/LaneUtil":112,"diagram-js/lib/features/resize/ResizeUtil":270,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/Elements":317}],104:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = SetColorHandler;
var _minDash = require("min-dash");
var DEFAULT_COLORS = {
fill: undefined,
stroke: undefined
};
function SetColorHandler(commandStack) {
this._commandStack = commandStack;
}
SetColorHandler.$inject = ['commandStack'];
SetColorHandler.prototype.postExecute = function (context) {
var elements = context.elements,
colors = context.colors || DEFAULT_COLORS;
var self = this;
var di = {};
if ('fill' in colors) {
(0, _minDash.assign)(di, {
fill: colors.fill
});
}
if ('stroke' in colors) {
(0, _minDash.assign)(di, {
stroke: colors.stroke
});
}
(0, _minDash.forEach)(elements, function (element) {
self._commandStack.execute('element.updateProperties', {
element: element,
properties: {
di: di
}
});
});
};
},{"min-dash":559}],105:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = SplitLaneHandler;
var _LaneUtil = require("../util/LaneUtil");
/**
* A handler that splits a lane into a number of sub-lanes,
* creating new sub lanes, if necessary.
*
* @param {Modeling} modeling
*/
function SplitLaneHandler(modeling, translate) {
this._modeling = modeling;
this._translate = translate;
}
SplitLaneHandler.$inject = ['modeling', 'translate'];
SplitLaneHandler.prototype.preExecute = function (context) {
var modeling = this._modeling,
translate = this._translate;
var shape = context.shape,
newLanesCount = context.count;
var childLanes = (0, _LaneUtil.getChildLanes)(shape),
existingLanesCount = childLanes.length;
if (existingLanesCount > newLanesCount) {
throw new Error(translate('more than {count} child lanes', {
count: newLanesCount
}));
}
var newLanesHeight = Math.round(shape.height / newLanesCount); // Iterate from top to bottom in child lane order,
// resizing existing lanes and creating new ones
// so that they split the parent proportionally.
//
// Due to rounding related errors, the bottom lane
// needs to take up all the remaining space.
var laneY, laneHeight, laneBounds, newLaneAttrs, idx;
for (idx = 0; idx < newLanesCount; idx++) {
laneY = shape.y + idx * newLanesHeight; // if bottom lane
if (idx === newLanesCount - 1) {
laneHeight = shape.height - newLanesHeight * idx;
} else {
laneHeight = newLanesHeight;
}
laneBounds = {
x: shape.x + _LaneUtil.LANE_INDENTATION,
y: laneY,
width: shape.width - _LaneUtil.LANE_INDENTATION,
height: laneHeight
};
if (idx < existingLanesCount) {
// resize existing lane
modeling.resizeShape(childLanes[idx], laneBounds);
} else {
// create a new lane at position
newLaneAttrs = {
type: 'bpmn:Lane'
};
modeling.createShape(newLaneAttrs, laneBounds, shape);
}
}
};
},{"../util/LaneUtil":112}],106:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UpdateCanvasRootHandler;
var _Collections = require("diagram-js/lib/util/Collections");
function UpdateCanvasRootHandler(canvas, modeling) {
this._canvas = canvas;
this._modeling = modeling;
}
UpdateCanvasRootHandler.$inject = ['canvas', 'modeling'];
UpdateCanvasRootHandler.prototype.execute = function (context) {
var canvas = this._canvas;
var newRoot = context.newRoot,
newRootBusinessObject = newRoot.businessObject,
oldRoot = canvas.getRootElement(),
oldRootBusinessObject = oldRoot.businessObject,
bpmnDefinitions = oldRootBusinessObject.$parent,
diPlane = oldRootBusinessObject.di; // (1) replace process old <> new root
canvas.setRootElement(newRoot, true); // (2) update root elements
(0, _Collections.add)(bpmnDefinitions.rootElements, newRootBusinessObject);
newRootBusinessObject.$parent = bpmnDefinitions;
(0, _Collections.remove)(bpmnDefinitions.rootElements, oldRootBusinessObject);
oldRootBusinessObject.$parent = null; // (3) wire di
oldRootBusinessObject.di = null;
diPlane.bpmnElement = newRootBusinessObject;
newRootBusinessObject.di = diPlane;
context.oldRoot = oldRoot; // TODO(nikku): return changed elements?
// return [ newRoot, oldRoot ];
};
UpdateCanvasRootHandler.prototype.revert = function (context) {
var canvas = this._canvas;
var newRoot = context.newRoot,
newRootBusinessObject = newRoot.businessObject,
oldRoot = context.oldRoot,
oldRootBusinessObject = oldRoot.businessObject,
bpmnDefinitions = newRootBusinessObject.$parent,
diPlane = newRootBusinessObject.di; // (1) replace process old <> new root
canvas.setRootElement(oldRoot, true); // (2) update root elements
(0, _Collections.remove)(bpmnDefinitions.rootElements, newRootBusinessObject);
newRootBusinessObject.$parent = null;
(0, _Collections.add)(bpmnDefinitions.rootElements, oldRootBusinessObject);
oldRootBusinessObject.$parent = bpmnDefinitions; // (3) wire di
newRootBusinessObject.di = null;
diPlane.bpmnElement = oldRootBusinessObject;
oldRootBusinessObject.di = diPlane; // TODO(nikku): return changed elements?
// return [ newRoot, oldRoot ];
};
},{"diagram-js/lib/util/Collections":315}],107:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UpdateFlowNodeRefsHandler;
var _LaneUtil = require("../util/LaneUtil");
var _ModelUtil = require("../../../util/ModelUtil");
var _Collections = require("diagram-js/lib/util/Collections");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var FLOW_NODE_REFS_ATTR = 'flowNodeRef',
LANES_ATTR = 'lanes';
/**
* A handler that updates lane refs on changed elements
*/
function UpdateFlowNodeRefsHandler(elementRegistry) {
this._elementRegistry = elementRegistry;
}
UpdateFlowNodeRefsHandler.$inject = ['elementRegistry'];
UpdateFlowNodeRefsHandler.prototype.computeUpdates = function (flowNodeShapes, laneShapes) {
var handledNodes = [];
var updates = [];
var participantCache = {};
var allFlowNodeShapes = [];
function isInLaneShape(element, laneShape) {
var laneTrbl = (0, _LayoutUtil.asTRBL)(laneShape);
var elementMid = {
x: element.x + element.width / 2,
y: element.y + element.height / 2
};
return elementMid.x > laneTrbl.left && elementMid.x < laneTrbl.right && elementMid.y > laneTrbl.top && elementMid.y < laneTrbl.bottom;
}
function addFlowNodeShape(flowNodeShape) {
if (handledNodes.indexOf(flowNodeShape) === -1) {
allFlowNodeShapes.push(flowNodeShape);
handledNodes.push(flowNodeShape);
}
}
function getAllLaneShapes(flowNodeShape) {
var root = (0, _LaneUtil.getLanesRoot)(flowNodeShape);
if (!participantCache[root.id]) {
participantCache[root.id] = (0, _LaneUtil.collectLanes)(root);
}
return participantCache[root.id];
}
function getNewLanes(flowNodeShape) {
if (!flowNodeShape.parent) {
return [];
}
var allLaneShapes = getAllLaneShapes(flowNodeShape);
return allLaneShapes.filter(function (l) {
return isInLaneShape(flowNodeShape, l);
}).map(function (shape) {
return shape.businessObject;
});
}
laneShapes.forEach(function (laneShape) {
var root = (0, _LaneUtil.getLanesRoot)(laneShape);
if (!root || handledNodes.indexOf(root) !== -1) {
return;
}
var children = root.children.filter(function (c) {
return (0, _ModelUtil.is)(c, 'bpmn:FlowNode');
});
children.forEach(addFlowNodeShape);
handledNodes.push(root);
});
flowNodeShapes.forEach(addFlowNodeShape);
allFlowNodeShapes.forEach(function (flowNodeShape) {
var flowNode = flowNodeShape.businessObject;
var lanes = flowNode.get(LANES_ATTR),
remove = lanes.slice(),
add = getNewLanes(flowNodeShape);
updates.push({
flowNode: flowNode,
remove: remove,
add: add
});
});
laneShapes.forEach(function (laneShape) {
var lane = laneShape.businessObject; // lane got removed XX-)
if (!laneShape.parent) {
lane.get(FLOW_NODE_REFS_ATTR).forEach(function (flowNode) {
updates.push({
flowNode: flowNode,
remove: [lane],
add: []
});
});
}
});
return updates;
};
UpdateFlowNodeRefsHandler.prototype.execute = function (context) {
var updates = context.updates;
if (!updates) {
updates = context.updates = this.computeUpdates(context.flowNodeShapes, context.laneShapes);
}
updates.forEach(function (update) {
var flowNode = update.flowNode,
lanes = flowNode.get(LANES_ATTR); // unwire old
update.remove.forEach(function (oldLane) {
(0, _Collections.remove)(lanes, oldLane);
(0, _Collections.remove)(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
}); // wire new
update.add.forEach(function (newLane) {
(0, _Collections.add)(lanes, newLane);
(0, _Collections.add)(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
});
}); // TODO(nikku): return changed elements
// return [ ... ];
};
UpdateFlowNodeRefsHandler.prototype.revert = function (context) {
var updates = context.updates;
updates.forEach(function (update) {
var flowNode = update.flowNode,
lanes = flowNode.get(LANES_ATTR); // unwire new
update.add.forEach(function (newLane) {
(0, _Collections.remove)(lanes, newLane);
(0, _Collections.remove)(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
}); // wire old
update.remove.forEach(function (oldLane) {
(0, _Collections.add)(lanes, oldLane);
(0, _Collections.add)(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
});
}); // TODO(nikku): return changed elements
// return [ ... ];
};
},{"../../../util/ModelUtil":142,"../util/LaneUtil":112,"diagram-js/lib/layout/LayoutUtil":302,"diagram-js/lib/util/Collections":315}],108:[function(require,module,exports){
'use strict';
var reduce = require('min-dash').reduce,
keys = require('min-dash').keys,
forEach = require('min-dash').forEach,
is = require('../../../util/ModelUtil').is,
getBusinessObject = require('../../../util/ModelUtil').getBusinessObject;
function UpdateModdlePropertiesHandler(elementRegistry) {
this._elementRegistry = elementRegistry;
}
UpdateModdlePropertiesHandler.$inject = ['elementRegistry'];
module.exports = UpdateModdlePropertiesHandler;
UpdateModdlePropertiesHandler.prototype.execute = function(context) {
var element = context.element,
moddleElement = context.moddleElement,
properties = context.properties;
if (!moddleElement) {
throw new Error(' required');
}
var changed = context.changed || this.getVisualReferences(moddleElement).concat(element);
var oldProperties = context.oldProperties || getModdleProperties(moddleElement, keys(properties));
setModdleProperties(moddleElement, properties);
context.oldProperties = oldProperties;
context.changed = changed;
return changed;
};
UpdateModdlePropertiesHandler.prototype.revert = function(context) {
var oldProperties = context.oldProperties,
moddleElement = context.moddleElement,
changed = context.changed;
setModdleProperties(moddleElement, oldProperties);
return changed;
};
/**
* Return visual references of given moddle element within the diagram.
*
* @param {ModdleElement} moddleElement
*
* @return {Array}
*/
UpdateModdlePropertiesHandler.prototype.getVisualReferences = function(moddleElement) {
var elementRegistry = this._elementRegistry;
if (is(moddleElement, 'bpmn:DataObject')) {
return getAllDataObjectReferences(moddleElement, elementRegistry);
}
return [];
};
// helpers /////////////////
function getModdleProperties(moddleElement, propertyNames) {
return reduce(propertyNames, function(result, key) {
result[key] = moddleElement.get(key);
return result;
}, {});
}
function setModdleProperties(moddleElement, properties) {
forEach(properties, function(value, key) {
moddleElement.set(key, value);
});
}
function getAllDataObjectReferences(dataObject, elementRegistry) {
return elementRegistry.filter(function(element) {
return (
is(element, 'bpmn:DataObjectReference') &&
getBusinessObject(element).dataObjectRef === dataObject
);
});
}
},{"../../../util/ModelUtil":142,"min-dash":559}],109:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UpdatePropertiesHandler;
var _minDash = require("min-dash");
var _ModelUtil = require("../../../util/ModelUtil");
var DEFAULT_FLOW = 'default',
ID = 'id',
DI = 'di';
var NULL_DIMENSIONS = {
width: 0,
height: 0
};
/**
* A handler that implements a BPMN 2.0 property update.
*
* This should be used to set simple properties on elements with
* an underlying BPMN business object.
*
* Use respective diagram-js provided handlers if you would
* like to perform automated modeling.
*/
function UpdatePropertiesHandler(elementRegistry, moddle, translate, modeling, textRenderer) {
this._elementRegistry = elementRegistry;
this._moddle = moddle;
this._translate = translate;
this._modeling = modeling;
this._textRenderer = textRenderer;
}
UpdatePropertiesHandler.$inject = ['elementRegistry', 'moddle', 'translate', 'modeling', 'textRenderer']; // api //////////////////////
/**
* Updates a BPMN element with a list of new properties
*
* @param {Object} context
* @param {djs.model.Base} context.element the element to update
* @param {Object} context.properties a list of properties to set on the element's
* businessObject (the BPMN model element)
*
* @return {Array} the updated element
*/
UpdatePropertiesHandler.prototype.execute = function (context) {
var element = context.element,
changed = [element],
translate = this._translate;
if (!element) {
throw new Error(translate('element required'));
}
var elementRegistry = this._elementRegistry,
ids = this._moddle.ids;
var businessObject = element.businessObject,
properties = unwrapBusinessObjects(context.properties),
oldProperties = context.oldProperties || getProperties(businessObject, properties);
if (isIdChange(properties, businessObject)) {
ids.unclaim(businessObject[ID]);
elementRegistry.updateId(element, properties[ID]);
ids.claim(properties[ID], businessObject);
} // correctly indicate visual changes on default flow updates
if (DEFAULT_FLOW in properties) {
if (properties[DEFAULT_FLOW]) {
changed.push(elementRegistry.get(properties[DEFAULT_FLOW].id));
}
if (businessObject[DEFAULT_FLOW]) {
changed.push(elementRegistry.get(businessObject[DEFAULT_FLOW].id));
}
} // update properties
setProperties(businessObject, properties); // store old values
context.oldProperties = oldProperties;
context.changed = changed; // indicate changed on objects affected by the update
return changed;
};
UpdatePropertiesHandler.prototype.postExecute = function (context) {
var element = context.element,
label = element.label;
var text = label && (0, _ModelUtil.getBusinessObject)(label).name;
if (!text) {
return;
} // get layouted text bounds and resize external
// external label accordingly
var newLabelBounds = this._textRenderer.getExternalLabelBounds(label, text);
this._modeling.resizeShape(label, newLabelBounds, NULL_DIMENSIONS);
};
/**
* Reverts the update on a BPMN elements properties.
*
* @param {Object} context
*
* @return {djs.model.Base} the updated element
*/
UpdatePropertiesHandler.prototype.revert = function (context) {
var element = context.element,
properties = context.properties,
oldProperties = context.oldProperties,
businessObject = element.businessObject,
elementRegistry = this._elementRegistry,
ids = this._moddle.ids; // update properties
setProperties(businessObject, oldProperties);
if (isIdChange(properties, businessObject)) {
ids.unclaim(properties[ID]);
elementRegistry.updateId(element, oldProperties[ID]);
ids.claim(oldProperties[ID], businessObject);
}
return context.changed;
};
function isIdChange(properties, businessObject) {
return ID in properties && properties[ID] !== businessObject[ID];
}
function getProperties(businessObject, properties) {
var propertyNames = (0, _minDash.keys)(properties);
return (0, _minDash.reduce)(propertyNames, function (result, key) {
// handle DI separately
if (key !== DI) {
result[key] = businessObject.get(key);
} else {
result[key] = getDiProperties(businessObject.di, (0, _minDash.keys)(properties.di));
}
return result;
}, {});
}
function getDiProperties(di, propertyNames) {
return (0, _minDash.reduce)(propertyNames, function (result, key) {
result[key] = di.get(key);
return result;
}, {});
}
function setProperties(businessObject, properties) {
(0, _minDash.forEach)(properties, function (value, key) {
if (key !== DI) {
businessObject.set(key, value);
} else {
// only update, if businessObject.di exists
if (businessObject.di) {
setDiProperties(businessObject.di, value);
}
}
});
}
function setDiProperties(di, properties) {
(0, _minDash.forEach)(properties, function (value, key) {
di.set(key, value);
});
}
var referencePropertyNames = ['default'];
/**
* Make sure we unwrap the actual business object
* behind diagram element that may have been
* passed as arguments.
*
* @param {Object} properties
*
* @return {Object} unwrappedProps
*/
function unwrapBusinessObjects(properties) {
var unwrappedProps = (0, _minDash.assign)({}, properties);
referencePropertyNames.forEach(function (name) {
if (name in properties) {
unwrappedProps[name] = (0, _ModelUtil.getBusinessObject)(unwrappedProps[name]);
}
});
return unwrappedProps;
}
},{"../../../util/ModelUtil":142,"min-dash":559}],110:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = UpdateSemanticParentHandler;
function UpdateSemanticParentHandler(bpmnUpdater) {
this._bpmnUpdater = bpmnUpdater;
}
UpdateSemanticParentHandler.$inject = ['bpmnUpdater'];
UpdateSemanticParentHandler.prototype.execute = function (context) {
var dataStoreBo = context.dataStoreBo,
newSemanticParent = context.newSemanticParent,
newDiParent = context.newDiParent;
context.oldSemanticParent = dataStoreBo.$parent;
context.oldDiParent = dataStoreBo.di.$parent; // update semantic parent
this._bpmnUpdater.updateSemanticParent(dataStoreBo, newSemanticParent); // update DI parent
this._bpmnUpdater.updateDiParent(dataStoreBo.di, newDiParent);
};
UpdateSemanticParentHandler.prototype.revert = function (context) {
var dataStoreBo = context.dataStoreBo,
oldSemanticParent = context.oldSemanticParent,
oldDiParent = context.oldDiParent; // update semantic parent
this._bpmnUpdater.updateSemanticParent(dataStoreBo, oldSemanticParent); // update DI parent
this._bpmnUpdater.updateDiParent(dataStoreBo.di, oldDiParent);
};
},{}],111:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _behavior = _interopRequireDefault(require("./behavior"));
var _rules = _interopRequireDefault(require("../rules"));
var _diOrdering = _interopRequireDefault(require("../di-ordering"));
var _ordering = _interopRequireDefault(require("../ordering"));
var _replace = _interopRequireDefault(require("../replace"));
var _command = _interopRequireDefault(require("diagram-js/lib/command"));
var _tooltips = _interopRequireDefault(require("diagram-js/lib/features/tooltips"));
var _labelSupport = _interopRequireDefault(require("diagram-js/lib/features/label-support"));
var _attachSupport = _interopRequireDefault(require("diagram-js/lib/features/attach-support"));
var _selection = _interopRequireDefault(require("diagram-js/lib/features/selection"));
var _changeSupport = _interopRequireDefault(require("diagram-js/lib/features/change-support"));
var _spaceTool = _interopRequireDefault(require("diagram-js/lib/features/space-tool"));
var _BpmnFactory = _interopRequireDefault(require("./BpmnFactory"));
var _BpmnUpdater = _interopRequireDefault(require("./BpmnUpdater"));
var _ElementFactory = _interopRequireDefault(require("./ElementFactory"));
var _Modeling = _interopRequireDefault(require("./Modeling"));
var _BpmnLayouter = _interopRequireDefault(require("./BpmnLayouter"));
var _CroppingConnectionDocking = _interopRequireDefault(require("diagram-js/lib/layout/CroppingConnectionDocking"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__init__: ['modeling', 'bpmnUpdater'],
__depends__: [_behavior.default, _rules.default, _diOrdering.default, _ordering.default, _replace.default, _command.default, _tooltips.default, _labelSupport.default, _attachSupport.default, _selection.default, _changeSupport.default, _spaceTool.default],
bpmnFactory: ['type', _BpmnFactory.default],
bpmnUpdater: ['type', _BpmnUpdater.default],
elementFactory: ['type', _ElementFactory.default],
modeling: ['type', _Modeling.default],
layouter: ['type', _BpmnLayouter.default],
connectionDocking: ['type', _CroppingConnectionDocking.default]
};
exports.default = _default;
},{"../di-ordering":36,"../ordering":115,"../replace":125,"../rules":127,"./BpmnFactory":56,"./BpmnLayouter":57,"./BpmnUpdater":58,"./ElementFactory":59,"./Modeling":60,"./behavior":94,"diagram-js/lib/command":148,"diagram-js/lib/features/attach-support":162,"diagram-js/lib/features/change-support":179,"diagram-js/lib/features/label-support":221,"diagram-js/lib/features/selection":280,"diagram-js/lib/features/space-tool":290,"diagram-js/lib/features/tooltips":294,"diagram-js/lib/layout/CroppingConnectionDocking":301}],112:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LANE_INDENTATION = void 0;
exports.collectLanes = collectLanes;
exports.computeLanesResize = computeLanesResize;
exports.getChildLanes = getChildLanes;
exports.getLanesRoot = getLanesRoot;
var _ModelUtil = require("../../../util/ModelUtil");
var _ModelingUtil = require("./ModelingUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _ResizeUtil = require("diagram-js/lib/features/resize/ResizeUtil");
var abs = Math.abs;
function getTRBLResize(oldBounds, newBounds) {
return (0, _ResizeUtil.substractTRBL)((0, _LayoutUtil.asTRBL)(newBounds), (0, _LayoutUtil.asTRBL)(oldBounds));
}
var LANE_PARENTS = ['bpmn:Participant', 'bpmn:Process', 'bpmn:SubProcess'];
var LANE_INDENTATION = 30;
/**
* Collect all lane shapes in the given paren
*
* @param {djs.model.Shape} shape
* @param {Array} [collectedShapes]
*
* @return {Array}
*/
exports.LANE_INDENTATION = LANE_INDENTATION;
function collectLanes(shape, collectedShapes) {
collectedShapes = collectedShapes || [];
shape.children.filter(function (s) {
if ((0, _ModelUtil.is)(s, 'bpmn:Lane')) {
collectLanes(s, collectedShapes);
collectedShapes.push(s);
}
});
return collectedShapes;
}
/**
* Return the lane children of the given element.
*
* @param {djs.model.Shape} shape
*
* @return {Array}
*/
function getChildLanes(shape) {
return shape.children.filter(function (c) {
return (0, _ModelUtil.is)(c, 'bpmn:Lane');
});
}
/**
* Return the root element containing the given lane shape
*
* @param {djs.model.Shape} shape
*
* @return {djs.model.Shape}
*/
function getLanesRoot(shape) {
return (0, _ModelingUtil.getParent)(shape, LANE_PARENTS) || shape;
}
/**
* Compute the required resize operations for lanes
* adjacent to the given shape, assuming it will be
* resized to the given new bounds.
*
* @param {djs.model.Shape} shape
* @param {Bounds} newBounds
*
* @return {Array}
*/
function computeLanesResize(shape, newBounds) {
var rootElement = getLanesRoot(shape);
var initialShapes = (0, _ModelUtil.is)(rootElement, 'bpmn:Process') ? [] : [rootElement];
var allLanes = collectLanes(rootElement, initialShapes),
shapeTrbl = (0, _LayoutUtil.asTRBL)(shape),
shapeNewTrbl = (0, _LayoutUtil.asTRBL)(newBounds),
trblResize = getTRBLResize(shape, newBounds),
resizeNeeded = [];
allLanes.forEach(function (other) {
if (other === shape) {
return;
}
var topResize = 0,
rightResize = trblResize.right,
bottomResize = 0,
leftResize = trblResize.left;
var otherTrbl = (0, _LayoutUtil.asTRBL)(other);
if (trblResize.top) {
if (abs(otherTrbl.bottom - shapeTrbl.top) < 10) {
bottomResize = shapeNewTrbl.top - otherTrbl.bottom;
}
if (abs(otherTrbl.top - shapeTrbl.top) < 5) {
topResize = shapeNewTrbl.top - otherTrbl.top;
}
}
if (trblResize.bottom) {
if (abs(otherTrbl.top - shapeTrbl.bottom) < 10) {
topResize = shapeNewTrbl.bottom - otherTrbl.top;
}
if (abs(otherTrbl.bottom - shapeTrbl.bottom) < 5) {
bottomResize = shapeNewTrbl.bottom - otherTrbl.bottom;
}
}
if (topResize || rightResize || bottomResize || leftResize) {
resizeNeeded.push({
shape: other,
newBounds: (0, _ResizeUtil.resizeTRBL)(other, {
top: topResize,
right: rightResize,
bottom: bottomResize,
left: leftResize
})
});
}
});
return resizeNeeded;
}
},{"../../../util/ModelUtil":142,"./ModelingUtil":113,"diagram-js/lib/features/resize/ResizeUtil":270,"diagram-js/lib/layout/LayoutUtil":302}],113:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getParent = getParent;
exports.isAny = isAny;
var _minDash = require("min-dash");
var _ModelUtil = require("../../../util/ModelUtil");
/**
* Return true if element has any of the given types.
*
* @param {djs.model.Base} element
* @param {Array} types
*
* @return {boolean}
*/
function isAny(element, types) {
return (0, _minDash.some)(types, function (t) {
return (0, _ModelUtil.is)(element, t);
});
}
/**
* Return the parent of the element with any of the given types.
*
* @param {djs.model.Base} element
* @param {string|Array} anyType
*
* @return {djs.model.Base}
*/
function getParent(element, anyType) {
if (typeof anyType === 'string') {
anyType = [anyType];
}
while (element = element.parent) {
if (isAny(element, anyType)) {
return element;
}
}
return null;
}
},{"../../../util/ModelUtil":142,"min-dash":559}],114:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnOrderingProvider;
var _inherits = _interopRequireDefault(require("inherits"));
var _OrderingProvider = _interopRequireDefault(require("diagram-js/lib/features/ordering/OrderingProvider"));
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _minDash = require("min-dash");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* a simple ordering provider that makes sure:
*
* (0) labels and groups are rendered always on top
* (1) elements are ordered by a {level} property
*/
function BpmnOrderingProvider(eventBus, canvas, translate) {
_OrderingProvider.default.call(this, eventBus);
var orders = [{
type: 'bpmn:SubProcess',
order: {
level: 6
}
}, {
type: 'bpmn:SequenceFlow',
order: {
level: 3,
containers: ['bpmn:Participant', 'bpmn:FlowElementsContainer']
}
}, // handle DataAssociation(s) like message flows and render them always on top
{
type: 'bpmn:DataAssociation',
order: {
level: 9,
containers: ['bpmn:Collaboration', 'bpmn:Process']
}
}, {
type: 'bpmn:MessageFlow',
order: {
level: 9,
containers: ['bpmn:Collaboration']
}
}, {
type: 'bpmn:Association',
order: {
level: 6,
containers: ['bpmn:Participant', 'bpmn:FlowElementsContainer', 'bpmn:Collaboration']
}
}, {
type: 'bpmn:BoundaryEvent',
order: {
level: 8
}
}, {
type: 'bpmn:Group',
order: {
level: 10,
containers: ['bpmn:Collaboration', 'bpmn:Process']
}
}, {
type: 'bpmn:FlowElement',
order: {
level: 5
}
}, {
type: 'bpmn:Participant',
order: {
level: -2
}
}, {
type: 'bpmn:Lane',
order: {
level: -1
}
}];
function computeOrder(element) {
if (element.labelTarget) {
return {
level: 10
};
}
var entry = (0, _minDash.find)(orders, function (o) {
return (0, _ModelingUtil.isAny)(element, [o.type]);
});
return entry && entry.order || {
level: 1
};
}
function getOrder(element) {
var order = element.order;
if (!order) {
element.order = order = computeOrder(element);
}
return order;
}
function findActualParent(element, newParent, containers) {
var actualParent = newParent;
while (actualParent) {
if ((0, _ModelingUtil.isAny)(actualParent, containers)) {
break;
}
actualParent = actualParent.parent;
}
if (!actualParent) {
throw new Error(translate('no parent for {element} in {parent}', {
element: element.id,
parent: newParent.id
}));
}
return actualParent;
}
this.getOrdering = function (element, newParent) {
// render labels always on top
if (element.labelTarget) {
return {
parent: canvas.getRootElement(),
index: -1
};
}
var elementOrder = getOrder(element);
if (elementOrder.containers) {
newParent = findActualParent(element, newParent, elementOrder.containers);
}
var currentIndex = newParent.children.indexOf(element);
var insertIndex = (0, _minDash.findIndex)(newParent.children, function (child) {
// do not compare with labels, they are created
// in the wrong order (right after elements) during import and
// mess up the positioning.
if (!element.labelTarget && child.labelTarget) {
return false;
}
return elementOrder.level < getOrder(child).level;
}); // if the element is already in the child list at
// a smaller index, we need to adjust the insert index.
// this takes into account that the element is being removed
// before being re-inserted
if (insertIndex !== -1) {
if (currentIndex !== -1 && currentIndex < insertIndex) {
insertIndex -= 1;
}
}
return {
index: insertIndex,
parent: newParent
};
};
}
BpmnOrderingProvider.$inject = ['eventBus', 'canvas', 'translate'];
(0, _inherits.default)(BpmnOrderingProvider, _OrderingProvider.default);
},{"../modeling/util/ModelingUtil":113,"diagram-js/lib/features/ordering/OrderingProvider":254,"inherits":349,"min-dash":559}],115:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _translate = _interopRequireDefault(require("diagram-js/lib/i18n/translate"));
var _BpmnOrderingProvider = _interopRequireDefault(require("./BpmnOrderingProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_translate.default],
__init__: ['bpmnOrderingProvider'],
bpmnOrderingProvider: ['type', _BpmnOrderingProvider.default]
};
exports.default = _default;
},{"./BpmnOrderingProvider":114,"diagram-js/lib/i18n/translate":298}],116:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = PaletteProvider;
var _minDash = require("min-dash");
/**
* A palette provider for BPMN 2.0 elements.
*/
function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool, handTool, globalConnect, translate) {
this._palette = palette;
this._create = create;
this._elementFactory = elementFactory;
this._spaceTool = spaceTool;
this._lassoTool = lassoTool;
this._handTool = handTool;
this._globalConnect = globalConnect;
this._translate = translate;
palette.registerProvider(this);
}
PaletteProvider.$inject = ['palette', 'create', 'elementFactory', 'spaceTool', 'lassoTool', 'handTool', 'globalConnect', 'translate'];
PaletteProvider.prototype.getPaletteEntries = function (element) {
var actions = {},
create = this._create,
elementFactory = this._elementFactory,
spaceTool = this._spaceTool,
lassoTool = this._lassoTool,
handTool = this._handTool,
globalConnect = this._globalConnect,
translate = this._translate;
function createAction(type, group, className, title, options) {
function createListener(event) {
var shape = elementFactory.createShape((0, _minDash.assign)({
type: type
}, options));
if (options) {
shape.businessObject.di.isExpanded = options.isExpanded;
}
create.start(event, shape);
}
var shortType = type.replace(/^bpmn:/, '');
return {
group: group,
className: className,
title: title || translate('Create {type}', {
type: shortType
}),
action: {
dragstart: createListener,
click: createListener
}
};
}
function createSubprocess(event) {
var subProcess = elementFactory.createShape({
type: 'bpmn:SubProcess',
x: 0,
y: 0,
isExpanded: true
});
var startEvent = elementFactory.createShape({
type: 'bpmn:StartEvent',
x: 40,
y: 82,
parent: subProcess
});
create.start(event, [subProcess, startEvent], {
hints: {
autoSelect: [startEvent]
}
});
}
function createParticipant(event) {
create.start(event, elementFactory.createParticipantShape());
}
(0, _minDash.assign)(actions, {
'hand-tool': {
group: 'tools',
className: 'bpmn-icon-hand-tool',
title: translate('Activate the hand tool'),
action: {
click: function (event) {
handTool.activateHand(event);
}
}
},
'lasso-tool': {
group: 'tools',
className: 'bpmn-icon-lasso-tool',
title: translate('Activate the lasso tool'),
action: {
click: function (event) {
lassoTool.activateSelection(event);
}
}
},
'space-tool': {
group: 'tools',
className: 'bpmn-icon-space-tool',
title: translate('Activate the create/remove space tool'),
action: {
click: function (event) {
spaceTool.activateSelection(event);
}
}
},
'global-connect-tool': {
group: 'tools',
className: 'bpmn-icon-connection-multi',
title: translate('Activate the global connect tool'),
action: {
click: function (event) {
globalConnect.toggle(event);
}
}
},
'tool-separator': {
group: 'tools',
separator: true
},
'create.start-event': createAction('bpmn:StartEvent', 'event', 'bpmn-icon-start-event-none', translate('Create StartEvent')),
'create.intermediate-event': createAction('bpmn:IntermediateThrowEvent', 'event', 'bpmn-icon-intermediate-event-none', translate('Create Intermediate/Boundary Event')),
'create.end-event': createAction('bpmn:EndEvent', 'event', 'bpmn-icon-end-event-none', translate('Create EndEvent')),
'create.exclusive-gateway': createAction('bpmn:ExclusiveGateway', 'gateway', 'bpmn-icon-gateway-none', translate('Create Gateway')),
'create.task': createAction('bpmn:Task', 'activity', 'bpmn-icon-task', translate('Create Task')),
'create.data-object': createAction('bpmn:DataObjectReference', 'data-object', 'bpmn-icon-data-object', translate('Create DataObjectReference')),
'create.data-store': createAction('bpmn:DataStoreReference', 'data-store', 'bpmn-icon-data-store', translate('Create DataStoreReference')),
'create.subprocess-expanded': {
group: 'activity',
className: 'bpmn-icon-subprocess-expanded',
title: translate('Create expanded SubProcess'),
action: {
dragstart: createSubprocess,
click: createSubprocess
}
},
'create.participant-expanded': {
group: 'collaboration',
className: 'bpmn-icon-participant',
title: translate('Create Pool/Participant'),
action: {
dragstart: createParticipant,
click: createParticipant
}
},
'create.group': createAction('bpmn:Group', 'artifact', 'bpmn-icon-group', translate('Create Group'))
});
return actions;
};
},{"min-dash":559}],117:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _palette = _interopRequireDefault(require("diagram-js/lib/features/palette"));
var _create = _interopRequireDefault(require("diagram-js/lib/features/create"));
var _spaceTool = _interopRequireDefault(require("diagram-js/lib/features/space-tool"));
var _lassoTool = _interopRequireDefault(require("diagram-js/lib/features/lasso-tool"));
var _handTool = _interopRequireDefault(require("diagram-js/lib/features/hand-tool"));
var _globalConnect = _interopRequireDefault(require("diagram-js/lib/features/global-connect"));
var _translate = _interopRequireDefault(require("diagram-js/lib/i18n/translate"));
var _PaletteProvider = _interopRequireDefault(require("./PaletteProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_palette.default, _create.default, _spaceTool.default, _lassoTool.default, _handTool.default, _globalConnect.default, _translate.default],
__init__: ['paletteProvider'],
paletteProvider: ['type', _PaletteProvider.default]
};
exports.default = _default;
},{"./PaletteProvider":116,"diagram-js/lib/features/create":193,"diagram-js/lib/features/global-connect":201,"diagram-js/lib/features/hand-tool":209,"diagram-js/lib/features/lasso-tool":223,"diagram-js/lib/features/palette":260,"diagram-js/lib/features/space-tool":290,"diagram-js/lib/i18n/translate":298}],118:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ReplaceMenuProvider;
var _ModelUtil = require("../../util/ModelUtil");
var _DiUtil = require("../../util/DiUtil");
var _TypeUtil = require("./util/TypeUtil");
var _minDash = require("min-dash");
var replaceOptions = _interopRequireWildcard(require("../replace/ReplaceOptions"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* This module is an element agnostic replace menu provider for the popup menu.
*/
function ReplaceMenuProvider(popupMenu, modeling, moddle, bpmnReplace, rules, translate) {
this._popupMenu = popupMenu;
this._modeling = modeling;
this._moddle = moddle;
this._bpmnReplace = bpmnReplace;
this._rules = rules;
this._translate = translate;
this.register();
}
ReplaceMenuProvider.$inject = ['popupMenu', 'modeling', 'moddle', 'bpmnReplace', 'rules', 'translate'];
/**
* Register replace menu provider in the popup menu
*/
ReplaceMenuProvider.prototype.register = function () {
this._popupMenu.registerProvider('bpmn-replace', this);
};
/**
* Get all entries from replaceOptions for the given element and apply filters
* on them. Get for example only elements, which are different from the current one.
*
* @param {djs.model.Base} element
*
* @return {Array} a list of menu entry items
*/
ReplaceMenuProvider.prototype.getEntries = function (element) {
var businessObject = element.businessObject;
var rules = this._rules;
var entries;
if (!rules.allowed('shape.replace', {
element: element
})) {
return [];
}
var differentType = (0, _TypeUtil.isDifferentType)(element);
if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataObjectReference')) {
return this._createEntries(element, replaceOptions.DATA_OBJECT_REFERENCE);
}
if ((0, _ModelUtil.is)(businessObject, 'bpmn:DataStoreReference')) {
return this._createEntries(element, replaceOptions.DATA_STORE_REFERENCE);
} // start events outside sub processes
if ((0, _ModelUtil.is)(businessObject, 'bpmn:StartEvent') && !(0, _ModelUtil.is)(businessObject.$parent, 'bpmn:SubProcess')) {
entries = (0, _minDash.filter)(replaceOptions.START_EVENT, differentType);
return this._createEntries(element, entries);
} // expanded/collapsed pools
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Participant')) {
entries = (0, _minDash.filter)(replaceOptions.PARTICIPANT, function (entry) {
return (0, _DiUtil.isExpanded)(businessObject) !== entry.target.isExpanded;
});
return this._createEntries(element, entries);
} // start events inside event sub processes
if ((0, _ModelUtil.is)(businessObject, 'bpmn:StartEvent') && (0, _DiUtil.isEventSubProcess)(businessObject.$parent)) {
entries = (0, _minDash.filter)(replaceOptions.EVENT_SUB_PROCESS_START_EVENT, function (entry) {
var target = entry.target;
var isInterrupting = target.isInterrupting !== false;
var isInterruptingEqual = (0, _ModelUtil.getBusinessObject)(element).isInterrupting === isInterrupting; // filters elements which types and event definition are equal but have have different interrupting types
return differentType(entry) || !differentType(entry) && !isInterruptingEqual;
});
return this._createEntries(element, entries);
} // start events inside sub processes
if ((0, _ModelUtil.is)(businessObject, 'bpmn:StartEvent') && !(0, _DiUtil.isEventSubProcess)(businessObject.$parent) && (0, _ModelUtil.is)(businessObject.$parent, 'bpmn:SubProcess')) {
entries = (0, _minDash.filter)(replaceOptions.START_EVENT_SUB_PROCESS, differentType);
return this._createEntries(element, entries);
} // end events
if ((0, _ModelUtil.is)(businessObject, 'bpmn:EndEvent')) {
entries = (0, _minDash.filter)(replaceOptions.END_EVENT, function (entry) {
var target = entry.target; // hide cancel end events outside transactions
if (target.eventDefinitionType == 'bpmn:CancelEventDefinition' && !(0, _ModelUtil.is)(businessObject.$parent, 'bpmn:Transaction')) {
return false;
}
return differentType(entry);
});
return this._createEntries(element, entries);
} // boundary events
if ((0, _ModelUtil.is)(businessObject, 'bpmn:BoundaryEvent')) {
entries = (0, _minDash.filter)(replaceOptions.BOUNDARY_EVENT, function (entry) {
var target = entry.target;
if (target.eventDefinition == 'bpmn:CancelEventDefinition' && !(0, _ModelUtil.is)(businessObject.attachedToRef, 'bpmn:Transaction')) {
return false;
}
var cancelActivity = target.cancelActivity !== false;
var isCancelActivityEqual = businessObject.cancelActivity == cancelActivity;
return differentType(entry) || !differentType(entry) && !isCancelActivityEqual;
});
return this._createEntries(element, entries);
} // intermediate events
if ((0, _ModelUtil.is)(businessObject, 'bpmn:IntermediateCatchEvent') || (0, _ModelUtil.is)(businessObject, 'bpmn:IntermediateThrowEvent')) {
entries = (0, _minDash.filter)(replaceOptions.INTERMEDIATE_EVENT, differentType);
return this._createEntries(element, entries);
} // gateways
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Gateway')) {
entries = (0, _minDash.filter)(replaceOptions.GATEWAY, differentType);
return this._createEntries(element, entries);
} // transactions
if ((0, _ModelUtil.is)(businessObject, 'bpmn:Transaction')) {
entries = (0, _minDash.filter)(replaceOptions.TRANSACTION, differentType);
return this._createEntries(element, entries);
} // expanded event sub processes
if ((0, _DiUtil.isEventSubProcess)(businessObject) && (0, _DiUtil.isExpanded)(businessObject)) {
entries = (0, _minDash.filter)(replaceOptions.EVENT_SUB_PROCESS, differentType);
return this._createEntries(element, entries);
} // expanded sub processes
if ((0, _ModelUtil.is)(businessObject, 'bpmn:SubProcess') && (0, _DiUtil.isExpanded)(businessObject)) {
entries = (0, _minDash.filter)(replaceOptions.SUBPROCESS_EXPANDED, differentType);
return this._createEntries(element, entries);
} // collapsed ad hoc sub processes
if ((0, _ModelUtil.is)(businessObject, 'bpmn:AdHocSubProcess') && !(0, _DiUtil.isExpanded)(businessObject)) {
entries = (0, _minDash.filter)(replaceOptions.TASK, function (entry) {
var target = entry.target;
var isTargetSubProcess = target.type === 'bpmn:SubProcess';
var isTargetExpanded = target.isExpanded === true;
return (0, _TypeUtil.isDifferentType)(element, target) && (!isTargetSubProcess || isTargetExpanded);
});
return this._createEntries(element, entries);
} // sequence flows
if ((0, _ModelUtil.is)(businessObject, 'bpmn:SequenceFlow')) {
return this._createSequenceFlowEntries(element, replaceOptions.SEQUENCE_FLOW);
} // flow nodes
if ((0, _ModelUtil.is)(businessObject, 'bpmn:FlowNode')) {
entries = (0, _minDash.filter)(replaceOptions.TASK, differentType); // collapsed SubProcess can not be replaced with itself
if ((0, _ModelUtil.is)(businessObject, 'bpmn:SubProcess') && !(0, _DiUtil.isExpanded)(businessObject)) {
entries = (0, _minDash.filter)(entries, function (entry) {
return entry.label !== 'Sub Process (collapsed)';
});
}
return this._createEntries(element, entries);
}
return [];
};
/**
* Get a list of header items for the given element. This includes buttons
* for multi instance markers and for the ad hoc marker.
*
* @param {djs.model.Base} element
*
* @return {Array} a list of menu entry items
*/
ReplaceMenuProvider.prototype.getHeaderEntries = function (element) {
var headerEntries = [];
if ((0, _ModelUtil.is)(element, 'bpmn:Activity') && !(0, _DiUtil.isEventSubProcess)(element)) {
headerEntries = headerEntries.concat(this._getLoopEntries(element));
}
if ((0, _ModelUtil.is)(element, 'bpmn:DataObjectReference')) {
headerEntries = headerEntries.concat(this._getDataObjectIsCollection(element));
}
if ((0, _ModelUtil.is)(element, 'bpmn:SubProcess') && !(0, _ModelUtil.is)(element, 'bpmn:Transaction') && !(0, _DiUtil.isEventSubProcess)(element)) {
headerEntries.push(this._getAdHocEntry(element));
}
return headerEntries;
};
/**
* Creates an array of menu entry objects for a given element and filters the replaceOptions
* according to a filter function.
*
* @param {djs.model.Base} element
* @param {Object} replaceOptions
*
* @return {Array} a list of menu items
*/
ReplaceMenuProvider.prototype._createEntries = function (element, replaceOptions) {
var menuEntries = [];
var self = this;
(0, _minDash.forEach)(replaceOptions, function (definition) {
var entry = self._createMenuEntry(definition, element);
menuEntries.push(entry);
});
return menuEntries;
};
/**
* Creates an array of menu entry objects for a given sequence flow.
*
* @param {djs.model.Base} element
* @param {Object} replaceOptions
* @return {Array} a list of menu items
*/
ReplaceMenuProvider.prototype._createSequenceFlowEntries = function (element, replaceOptions) {
var businessObject = (0, _ModelUtil.getBusinessObject)(element);
var menuEntries = [];
var modeling = this._modeling,
moddle = this._moddle;
var self = this;
(0, _minDash.forEach)(replaceOptions, function (entry) {
switch (entry.actionName) {
case 'replace-with-default-flow':
if (businessObject.sourceRef.default !== businessObject && ((0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:ExclusiveGateway') || (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:InclusiveGateway') || (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:ComplexGateway') || (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:Activity'))) {
menuEntries.push(self._createMenuEntry(entry, element, function () {
modeling.updateProperties(element.source, {
default: businessObject
});
}));
}
break;
case 'replace-with-conditional-flow':
if (!businessObject.conditionExpression && (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:Activity')) {
menuEntries.push(self._createMenuEntry(entry, element, function () {
var conditionExpression = moddle.create('bpmn:FormalExpression', {
body: ''
});
modeling.updateProperties(element, {
conditionExpression: conditionExpression
});
}));
}
break;
default:
// default flows
if ((0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:Activity') && businessObject.conditionExpression) {
return menuEntries.push(self._createMenuEntry(entry, element, function () {
modeling.updateProperties(element, {
conditionExpression: undefined
});
}));
} // conditional flows
if (((0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:ExclusiveGateway') || (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:InclusiveGateway') || (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:ComplexGateway') || (0, _ModelUtil.is)(businessObject.sourceRef, 'bpmn:Activity')) && businessObject.sourceRef.default === businessObject) {
return menuEntries.push(self._createMenuEntry(entry, element, function () {
modeling.updateProperties(element.source, {
default: undefined
});
}));
}
}
});
return menuEntries;
};
/**
* Creates and returns a single menu entry item.
*
* @param {Object} definition a single replace options definition object
* @param {djs.model.Base} element
* @param {Function} [action] an action callback function which gets called when
* the menu entry is being triggered.
*
* @return {Object} menu entry item
*/
ReplaceMenuProvider.prototype._createMenuEntry = function (definition, element, action) {
var translate = this._translate;
var replaceElement = this._bpmnReplace.replaceElement;
var replaceAction = function () {
return replaceElement(element, definition.target);
};
action = action || replaceAction;
var menuEntry = {
label: translate(definition.label),
className: definition.className,
id: definition.actionName,
action: action
};
return menuEntry;
};
/**
* Get a list of menu items containing buttons for multi instance markers
*
* @param {djs.model.Base} element
*
* @return {Array} a list of menu items
*/
ReplaceMenuProvider.prototype._getLoopEntries = function (element) {
var self = this;
var translate = this._translate;
function toggleLoopEntry(event, entry) {
var loopCharacteristics;
if (entry.active) {
loopCharacteristics = undefined;
} else {
loopCharacteristics = self._moddle.create(entry.options.loopCharacteristics);
if (entry.options.isSequential) {
loopCharacteristics.isSequential = entry.options.isSequential;
}
}
self._modeling.updateProperties(element, {
loopCharacteristics: loopCharacteristics
});
}
var businessObject = (0, _ModelUtil.getBusinessObject)(element),
loopCharacteristics = businessObject.loopCharacteristics;
var isSequential, isLoop, isParallel;
if (loopCharacteristics) {
isSequential = loopCharacteristics.isSequential;
isLoop = loopCharacteristics.isSequential === undefined;
isParallel = loopCharacteristics.isSequential !== undefined && !loopCharacteristics.isSequential;
}
var loopEntries = [{
id: 'toggle-parallel-mi',
className: 'bpmn-icon-parallel-mi-marker',
title: translate('Parallel Multi Instance'),
active: isParallel,
action: toggleLoopEntry,
options: {
loopCharacteristics: 'bpmn:MultiInstanceLoopCharacteristics',
isSequential: false
}
}, {
id: 'toggle-sequential-mi',
className: 'bpmn-icon-sequential-mi-marker',
title: translate('Sequential Multi Instance'),
active: isSequential,
action: toggleLoopEntry,
options: {
loopCharacteristics: 'bpmn:MultiInstanceLoopCharacteristics',
isSequential: true
}
}, {
id: 'toggle-loop',
className: 'bpmn-icon-loop-marker',
title: translate('Loop'),
active: isLoop,
action: toggleLoopEntry,
options: {
loopCharacteristics: 'bpmn:StandardLoopCharacteristics'
}
}];
return loopEntries;
};
/**
* Get a list of menu items containing buttons for multi instance markers
*
* @param {djs.model.Base} element
*
* @return {Array} a list of menu items
*/
ReplaceMenuProvider.prototype._getDataObjectIsCollection = function (element) {
var self = this;
var translate = this._translate;
function toggleIsCollection(event, entry) {
self._modeling.updateModdleProperties(element, dataObject, {
isCollection: !entry.active
});
}
var dataObject = element.businessObject.dataObjectRef,
isCollection = dataObject.isCollection;
var dataObjectEntries = [{
id: 'toggle-is-collection',
className: 'bpmn-icon-parallel-mi-marker',
title: translate('Collection'),
active: isCollection,
action: toggleIsCollection
}];
return dataObjectEntries;
};
/**
* Get the menu items containing a button for the ad hoc marker
*
* @param {djs.model.Base} element
*
* @return {Object} a menu item
*/
ReplaceMenuProvider.prototype._getAdHocEntry = function (element) {
var translate = this._translate;
var businessObject = (0, _ModelUtil.getBusinessObject)(element);
var isAdHoc = (0, _ModelUtil.is)(businessObject, 'bpmn:AdHocSubProcess');
var replaceElement = this._bpmnReplace.replaceElement;
var adHocEntry = {
id: 'toggle-adhoc',
className: 'bpmn-icon-ad-hoc-marker',
title: translate('Ad-hoc'),
active: isAdHoc,
action: function (event, entry) {
if (isAdHoc) {
return replaceElement(element, {
type: 'bpmn:SubProcess'
}, {
autoResize: false,
layoutConnection: false
});
} else {
return replaceElement(element, {
type: 'bpmn:AdHocSubProcess'
}, {
autoResize: false,
layoutConnection: false
});
}
}
};
return adHocEntry;
};
},{"../../util/DiUtil":140,"../../util/ModelUtil":142,"../replace/ReplaceOptions":124,"./util/TypeUtil":120,"min-dash":559}],119:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _popupMenu = _interopRequireDefault(require("diagram-js/lib/features/popup-menu"));
var _replace = _interopRequireDefault(require("../replace"));
var _ReplaceMenuProvider = _interopRequireDefault(require("./ReplaceMenuProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_popupMenu.default, _replace.default],
__init__: ['replaceMenuProvider'],
replaceMenuProvider: ['type', _ReplaceMenuProvider.default]
};
exports.default = _default;
},{"../replace":125,"./ReplaceMenuProvider":118,"diagram-js/lib/features/popup-menu":262}],120:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isDifferentType = isDifferentType;
var _ModelUtil = require("../../../util/ModelUtil");
var _DiUtil = require("../../../util/DiUtil");
/**
* Returns true, if an element is from a different type
* than a target definition. Takes into account the type,
* event definition type and triggeredByEvent property.
*
* @param {djs.model.Base} element
*
* @return {boolean}
*/
function isDifferentType(element) {
return function (entry) {
var target = entry.target;
var businessObject = (0, _ModelUtil.getBusinessObject)(element),
eventDefinition = businessObject.eventDefinitions && businessObject.eventDefinitions[0];
var isTypeEqual = businessObject.$type === target.type;
var isEventDefinitionEqual = (eventDefinition && eventDefinition.$type) === target.eventDefinitionType;
var isTriggeredByEventEqual = businessObject.triggeredByEvent === target.triggeredByEvent;
var isExpandedEqual = target.isExpanded === undefined || target.isExpanded === (0, _DiUtil.isExpanded)(businessObject);
return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;
};
}
},{"../../../util/DiUtil":140,"../../../util/ModelUtil":142}],121:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnReplacePreview;
var _CommandInterceptor = _interopRequireDefault(require("diagram-js/lib/command/CommandInterceptor"));
var _inherits = _interopRequireDefault(require("inherits"));
var _css = _interopRequireDefault(require("css.escape"));
var _minDash = require("min-dash");
var _minDom = require("min-dom");
var _tinySvg = require("tiny-svg");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOW_PRIORITY = 250;
function BpmnReplacePreview(eventBus, elementRegistry, elementFactory, canvas, previewSupport) {
_CommandInterceptor.default.call(this, eventBus);
/**
* Replace the visuals of all elements in the context which can be replaced
*
* @param {Object} context
*/
function replaceVisual(context) {
var replacements = context.canExecute.replacements;
(0, _minDash.forEach)(replacements, function (replacement) {
var id = replacement.oldElementId;
var newElement = {
type: replacement.newElementType
}; // if the visual of the element is already replaced
if (context.visualReplacements[id]) {
return;
}
var element = elementRegistry.get(id);
(0, _minDash.assign)(newElement, {
x: element.x,
y: element.y
}); // create a temporary shape
var tempShape = elementFactory.createShape(newElement);
canvas.addShape(tempShape, element.parent); // select the original SVG element related to the element and hide it
var gfx = (0, _minDom.query)('[data-element-id="' + (0, _css.default)(element.id) + '"]', context.dragGroup);
if (gfx) {
(0, _tinySvg.attr)(gfx, {
display: 'none'
});
} // clone the gfx of the temporary shape and add it to the drag group
var dragger = previewSupport.addDragger(tempShape, context.dragGroup);
context.visualReplacements[id] = dragger;
canvas.removeShape(tempShape);
});
}
/**
* Restore the original visuals of the previously replaced elements
*
* @param {Object} context
*/
function restoreVisual(context) {
var visualReplacements = context.visualReplacements;
(0, _minDash.forEach)(visualReplacements, function (dragger, id) {
var originalGfx = (0, _minDom.query)('[data-element-id="' + (0, _css.default)(id) + '"]', context.dragGroup);
if (originalGfx) {
(0, _tinySvg.attr)(originalGfx, {
display: 'inline'
});
}
dragger.remove();
if (visualReplacements[id]) {
delete visualReplacements[id];
}
});
}
eventBus.on('shape.move.move', LOW_PRIORITY, function (event) {
var context = event.context,
canExecute = context.canExecute;
if (!context.visualReplacements) {
context.visualReplacements = {};
}
if (canExecute && canExecute.replacements) {
replaceVisual(context);
} else {
restoreVisual(context);
}
});
}
BpmnReplacePreview.$inject = ['eventBus', 'elementRegistry', 'elementFactory', 'canvas', 'previewSupport'];
(0, _inherits.default)(BpmnReplacePreview, _CommandInterceptor.default);
},{"css.escape":333,"diagram-js/lib/command/CommandInterceptor":146,"inherits":349,"min-dash":559,"min-dom":560,"tiny-svg":571}],122:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _previewSupport = _interopRequireDefault(require("diagram-js/lib/features/preview-support"));
var _BpmnReplacePreview = _interopRequireDefault(require("./BpmnReplacePreview"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_previewSupport.default],
__init__: ['bpmnReplacePreview'],
bpmnReplacePreview: ['type', _BpmnReplacePreview.default]
};
exports.default = _default;
},{"./BpmnReplacePreview":121,"diagram-js/lib/features/preview-support":264}],123:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnReplace;
var _minDash = require("min-dash");
var _ModelUtil = require("../../util/ModelUtil");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _DiUtil = require("../../util/DiUtil");
var _ModdleCopy = require("../copy-paste/ModdleCopy");
function copyProperties(source, target, properties) {
if (!(0, _minDash.isArray)(properties)) {
properties = [properties];
}
(0, _minDash.forEach)(properties, function (property) {
if (!(0, _minDash.isUndefined)(source[property])) {
target[property] = source[property];
}
});
}
var CUSTOM_PROPERTIES = ['cancelActivity', 'instantiate', 'eventGatewayType', 'triggeredByEvent', 'isInterrupting'];
function toggeling(element, target) {
var oldCollapsed = element && (0, _minDash.has)(element, 'collapsed') ? element.collapsed : !(0, _DiUtil.isExpanded)(element);
var targetCollapsed;
if (target && ((0, _minDash.has)(target, 'collapsed') || (0, _minDash.has)(target, 'isExpanded'))) {
// property is explicitly set so use it
targetCollapsed = (0, _minDash.has)(target, 'collapsed') ? target.collapsed : !target.isExpanded;
} else {
// keep old state
targetCollapsed = oldCollapsed;
}
if (oldCollapsed !== targetCollapsed) {
element.collapsed = oldCollapsed;
return true;
}
return false;
}
/**
* This module takes care of replacing BPMN elements
*/
function BpmnReplace(bpmnFactory, elementFactory, moddleCopy, modeling, replace, rules, selection) {
/**
* Prepares a new business object for the replacement element
* and triggers the replace operation.
*
* @param {djs.model.Base} element
* @param {Object} target
* @param {Object} [hints]
*
* @return {djs.model.Base} the newly created element
*/
function replaceElement(element, target, hints) {
hints = hints || {};
var type = target.type,
oldBusinessObject = element.businessObject;
if (isSubProcess(oldBusinessObject)) {
if (type === 'bpmn:SubProcess') {
if (toggeling(element, target)) {
// expanding or collapsing process
modeling.toggleCollapse(element);
return element;
}
}
}
var newBusinessObject = bpmnFactory.create(type);
var newElement = {
type: type,
businessObject: newBusinessObject
};
var elementProps = (0, _ModdleCopy.getPropertyNames)(oldBusinessObject.$descriptor),
newElementProps = (0, _ModdleCopy.getPropertyNames)(newBusinessObject.$descriptor, true),
copyProps = intersection(elementProps, newElementProps); // initialize special properties defined in target definition
(0, _minDash.assign)(newBusinessObject, (0, _minDash.pick)(target, CUSTOM_PROPERTIES));
var properties = (0, _minDash.filter)(copyProps, function (propertyName) {
// copying event definitions, unless we replace
if (propertyName === 'eventDefinitions') {
return hasEventDefinition(element, target.eventDefinitionType);
} // retain loop characteristics if the target element
// is not an event sub process
if (propertyName === 'loopCharacteristics') {
return !(0, _DiUtil.isEventSubProcess)(newBusinessObject);
} // so the applied properties from 'target' don't get lost
if ((0, _minDash.has)(newBusinessObject, propertyName)) {
return false;
}
if (propertyName === 'processRef' && target.isExpanded === false) {
return false;
}
if (propertyName === 'triggeredByEvent') {
return false;
}
return true;
});
newBusinessObject = moddleCopy.copyElement(oldBusinessObject, newBusinessObject, properties); // initialize custom BPMN extensions
if (target.eventDefinitionType) {
// only initialize with new eventDefinition
// if we did not set an event definition yet,
// i.e. because we copied it
if (!hasEventDefinition(newBusinessObject, target.eventDefinitionType)) {
newElement.eventDefinitionType = target.eventDefinitionType;
newElement.eventDefinitionAttrs = target.eventDefinitionAttrs;
}
}
if ((0, _ModelUtil.is)(oldBusinessObject, 'bpmn:Activity')) {
if (isSubProcess(oldBusinessObject)) {
// no toggeling, so keep old state
newElement.isExpanded = (0, _DiUtil.isExpanded)(oldBusinessObject);
} // else if property is explicitly set, use it
else if (target && (0, _minDash.has)(target, 'isExpanded')) {
newElement.isExpanded = target.isExpanded;
} // TODO: need also to respect min/max Size
// copy size, from an expanded subprocess to an expanded alternative subprocess
// except bpmn:Task, because Task is always expanded
if ((0, _DiUtil.isExpanded)(oldBusinessObject) && !(0, _ModelUtil.is)(oldBusinessObject, 'bpmn:Task') && newElement.isExpanded) {
newElement.width = element.width;
newElement.height = element.height;
}
} // remove children if not expanding sub process
if (isSubProcess(oldBusinessObject) && !isSubProcess(newBusinessObject)) {
hints.moveChildren = false;
} // transform collapsed/expanded pools
if ((0, _ModelUtil.is)(oldBusinessObject, 'bpmn:Participant')) {
// create expanded pool
if (target.isExpanded === true) {
newBusinessObject.processRef = bpmnFactory.create('bpmn:Process');
} else {
// remove children when transforming to collapsed pool
hints.moveChildren = false;
} // apply same width and default height
newElement.width = element.width;
newElement.height = elementFactory._getDefaultSize(newBusinessObject).height;
}
if (!rules.allowed('shape.resize', {
shape: newBusinessObject
})) {
newElement.height = elementFactory._getDefaultSize(newBusinessObject).height;
newElement.width = elementFactory._getDefaultSize(newBusinessObject).width;
}
newBusinessObject.name = oldBusinessObject.name; // retain default flow's reference between inclusive <-> exclusive gateways and activities
if ((0, _ModelingUtil.isAny)(oldBusinessObject, ['bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway', 'bpmn:Activity']) && (0, _ModelingUtil.isAny)(newBusinessObject, ['bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway', 'bpmn:Activity'])) {
newBusinessObject.default = oldBusinessObject.default;
}
if (target.host && !(0, _ModelUtil.is)(oldBusinessObject, 'bpmn:BoundaryEvent') && (0, _ModelUtil.is)(newBusinessObject, 'bpmn:BoundaryEvent')) {
newElement.host = target.host;
} // The DataStoreReference element is 14px wider than the DataObjectReference element
// This ensures that they stay centered on the x axis when replaced
if (newElement.type === 'bpmn:DataStoreReference' || newElement.type === 'bpmn:DataObjectReference') {
newElement.x = element.x + (element.width - newElement.width) / 2;
}
newElement.di = {}; // fill and stroke will be set to DI
copyProperties(oldBusinessObject.di, newElement.di, ['fill', 'stroke']);
newElement = replace.replaceElement(element, newElement, hints);
if (hints.select !== false) {
selection.select(newElement);
}
return newElement;
}
this.replaceElement = replaceElement;
}
BpmnReplace.$inject = ['bpmnFactory', 'elementFactory', 'moddleCopy', 'modeling', 'replace', 'rules', 'selection'];
function isSubProcess(bo) {
return (0, _ModelUtil.is)(bo, 'bpmn:SubProcess');
}
function hasEventDefinition(element, type) {
var bo = (0, _ModelUtil.getBusinessObject)(element);
return type && bo.get('eventDefinitions').some(function (definition) {
return (0, _ModelUtil.is)(definition, type);
});
}
/**
* Compute intersection between two arrays.
*/
function intersection(a1, a2) {
return a1.filter(function (el) {
return a2.indexOf(el) !== -1;
});
}
},{"../../util/DiUtil":140,"../../util/ModelUtil":142,"../copy-paste/ModdleCopy":33,"../modeling/util/ModelingUtil":113,"min-dash":559}],124:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TRANSACTION = exports.TASK = exports.SUBPROCESS_EXPANDED = exports.START_EVENT_SUB_PROCESS = exports.START_EVENT = exports.SEQUENCE_FLOW = exports.PARTICIPANT = exports.INTERMEDIATE_EVENT = exports.GATEWAY = exports.EVENT_SUB_PROCESS_START_EVENT = exports.EVENT_SUB_PROCESS = exports.END_EVENT = exports.DATA_STORE_REFERENCE = exports.DATA_OBJECT_REFERENCE = exports.BOUNDARY_EVENT = void 0;
var START_EVENT = [{
label: 'Start Event',
actionName: 'replace-with-none-start',
className: 'bpmn-icon-start-event-none',
target: {
type: 'bpmn:StartEvent'
}
}, {
label: 'Intermediate Throw Event',
actionName: 'replace-with-none-intermediate-throwing',
className: 'bpmn-icon-intermediate-event-none',
target: {
type: 'bpmn:IntermediateThrowEvent'
}
}, {
label: 'End Event',
actionName: 'replace-with-none-end',
className: 'bpmn-icon-end-event-none',
target: {
type: 'bpmn:EndEvent'
}
}, {
label: 'Message Start Event',
actionName: 'replace-with-message-start',
className: 'bpmn-icon-start-event-message',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition'
}
}, {
label: 'Timer Start Event',
actionName: 'replace-with-timer-start',
className: 'bpmn-icon-start-event-timer',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:TimerEventDefinition'
}
}, {
label: 'Conditional Start Event',
actionName: 'replace-with-conditional-start',
className: 'bpmn-icon-start-event-condition',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
}
}, {
label: 'Signal Start Event',
actionName: 'replace-with-signal-start',
className: 'bpmn-icon-start-event-signal',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition'
}
}];
exports.START_EVENT = START_EVENT;
var START_EVENT_SUB_PROCESS = [{
label: 'Start Event',
actionName: 'replace-with-none-start',
className: 'bpmn-icon-start-event-none',
target: {
type: 'bpmn:StartEvent'
}
}, {
label: 'Intermediate Throw Event',
actionName: 'replace-with-none-intermediate-throwing',
className: 'bpmn-icon-intermediate-event-none',
target: {
type: 'bpmn:IntermediateThrowEvent'
}
}, {
label: 'End Event',
actionName: 'replace-with-none-end',
className: 'bpmn-icon-end-event-none',
target: {
type: 'bpmn:EndEvent'
}
}];
exports.START_EVENT_SUB_PROCESS = START_EVENT_SUB_PROCESS;
var INTERMEDIATE_EVENT = [{
label: 'Start Event',
actionName: 'replace-with-none-start',
className: 'bpmn-icon-start-event-none',
target: {
type: 'bpmn:StartEvent'
}
}, {
label: 'Intermediate Throw Event',
actionName: 'replace-with-none-intermediate-throw',
className: 'bpmn-icon-intermediate-event-none',
target: {
type: 'bpmn:IntermediateThrowEvent'
}
}, {
label: 'End Event',
actionName: 'replace-with-none-end',
className: 'bpmn-icon-end-event-none',
target: {
type: 'bpmn:EndEvent'
}
}, {
label: 'Message Intermediate Catch Event',
actionName: 'replace-with-message-intermediate-catch',
className: 'bpmn-icon-intermediate-event-catch-message',
target: {
type: 'bpmn:IntermediateCatchEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition'
}
}, {
label: 'Message Intermediate Throw Event',
actionName: 'replace-with-message-intermediate-throw',
className: 'bpmn-icon-intermediate-event-throw-message',
target: {
type: 'bpmn:IntermediateThrowEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition'
}
}, {
label: 'Timer Intermediate Catch Event',
actionName: 'replace-with-timer-intermediate-catch',
className: 'bpmn-icon-intermediate-event-catch-timer',
target: {
type: 'bpmn:IntermediateCatchEvent',
eventDefinitionType: 'bpmn:TimerEventDefinition'
}
}, {
label: 'Escalation Intermediate Throw Event',
actionName: 'replace-with-escalation-intermediate-throw',
className: 'bpmn-icon-intermediate-event-throw-escalation',
target: {
type: 'bpmn:IntermediateThrowEvent',
eventDefinitionType: 'bpmn:EscalationEventDefinition'
}
}, {
label: 'Conditional Intermediate Catch Event',
actionName: 'replace-with-conditional-intermediate-catch',
className: 'bpmn-icon-intermediate-event-catch-condition',
target: {
type: 'bpmn:IntermediateCatchEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
}
}, {
label: 'Link Intermediate Catch Event',
actionName: 'replace-with-link-intermediate-catch',
className: 'bpmn-icon-intermediate-event-catch-link',
target: {
type: 'bpmn:IntermediateCatchEvent',
eventDefinitionType: 'bpmn:LinkEventDefinition',
eventDefinitionAttrs: {
name: ''
}
}
}, {
label: 'Link Intermediate Throw Event',
actionName: 'replace-with-link-intermediate-throw',
className: 'bpmn-icon-intermediate-event-throw-link',
target: {
type: 'bpmn:IntermediateThrowEvent',
eventDefinitionType: 'bpmn:LinkEventDefinition',
eventDefinitionAttrs: {
name: ''
}
}
}, {
label: 'Compensation Intermediate Throw Event',
actionName: 'replace-with-compensation-intermediate-throw',
className: 'bpmn-icon-intermediate-event-throw-compensation',
target: {
type: 'bpmn:IntermediateThrowEvent',
eventDefinitionType: 'bpmn:CompensateEventDefinition'
}
}, {
label: 'Signal Intermediate Catch Event',
actionName: 'replace-with-signal-intermediate-catch',
className: 'bpmn-icon-intermediate-event-catch-signal',
target: {
type: 'bpmn:IntermediateCatchEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition'
}
}, {
label: 'Signal Intermediate Throw Event',
actionName: 'replace-with-signal-intermediate-throw',
className: 'bpmn-icon-intermediate-event-throw-signal',
target: {
type: 'bpmn:IntermediateThrowEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition'
}
}];
exports.INTERMEDIATE_EVENT = INTERMEDIATE_EVENT;
var END_EVENT = [{
label: 'Start Event',
actionName: 'replace-with-none-start',
className: 'bpmn-icon-start-event-none',
target: {
type: 'bpmn:StartEvent'
}
}, {
label: 'Intermediate Throw Event',
actionName: 'replace-with-none-intermediate-throw',
className: 'bpmn-icon-intermediate-event-none',
target: {
type: 'bpmn:IntermediateThrowEvent'
}
}, {
label: 'End Event',
actionName: 'replace-with-none-end',
className: 'bpmn-icon-end-event-none',
target: {
type: 'bpmn:EndEvent'
}
}, {
label: 'Message End Event',
actionName: 'replace-with-message-end',
className: 'bpmn-icon-end-event-message',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition'
}
}, {
label: 'Escalation End Event',
actionName: 'replace-with-escalation-end',
className: 'bpmn-icon-end-event-escalation',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:EscalationEventDefinition'
}
}, {
label: 'Error End Event',
actionName: 'replace-with-error-end',
className: 'bpmn-icon-end-event-error',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:ErrorEventDefinition'
}
}, {
label: 'Cancel End Event',
actionName: 'replace-with-cancel-end',
className: 'bpmn-icon-end-event-cancel',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:CancelEventDefinition'
}
}, {
label: 'Compensation End Event',
actionName: 'replace-with-compensation-end',
className: 'bpmn-icon-end-event-compensation',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:CompensateEventDefinition'
}
}, {
label: 'Signal End Event',
actionName: 'replace-with-signal-end',
className: 'bpmn-icon-end-event-signal',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition'
}
}, {
label: 'Terminate End Event',
actionName: 'replace-with-terminate-end',
className: 'bpmn-icon-end-event-terminate',
target: {
type: 'bpmn:EndEvent',
eventDefinitionType: 'bpmn:TerminateEventDefinition'
}
}];
exports.END_EVENT = END_EVENT;
var GATEWAY = [{
label: 'Exclusive Gateway',
actionName: 'replace-with-exclusive-gateway',
className: 'bpmn-icon-gateway-xor',
target: {
type: 'bpmn:ExclusiveGateway'
}
}, {
label: 'Parallel Gateway',
actionName: 'replace-with-parallel-gateway',
className: 'bpmn-icon-gateway-parallel',
target: {
type: 'bpmn:ParallelGateway'
}
}, {
label: 'Inclusive Gateway',
actionName: 'replace-with-inclusive-gateway',
className: 'bpmn-icon-gateway-or',
target: {
type: 'bpmn:InclusiveGateway'
}
}, {
label: 'Complex Gateway',
actionName: 'replace-with-complex-gateway',
className: 'bpmn-icon-gateway-complex',
target: {
type: 'bpmn:ComplexGateway'
}
}, {
label: 'Event based Gateway',
actionName: 'replace-with-event-based-gateway',
className: 'bpmn-icon-gateway-eventbased',
target: {
type: 'bpmn:EventBasedGateway',
instantiate: false,
eventGatewayType: 'Exclusive'
}
} // Gateways deactivated until https://github.com/bpmn-io/bpmn-js/issues/194
// {
// label: 'Event based instantiating Gateway',
// actionName: 'replace-with-exclusive-event-based-gateway',
// className: 'bpmn-icon-exclusive-event-based',
// target: {
// type: 'bpmn:EventBasedGateway'
// },
// options: {
// businessObject: { instantiate: true, eventGatewayType: 'Exclusive' }
// }
// },
// {
// label: 'Parallel Event based instantiating Gateway',
// actionName: 'replace-with-parallel-event-based-instantiate-gateway',
// className: 'bpmn-icon-parallel-event-based-instantiate-gateway',
// target: {
// type: 'bpmn:EventBasedGateway'
// },
// options: {
// businessObject: { instantiate: true, eventGatewayType: 'Parallel' }
// }
// }
];
exports.GATEWAY = GATEWAY;
var SUBPROCESS_EXPANDED = [{
label: 'Transaction',
actionName: 'replace-with-transaction',
className: 'bpmn-icon-transaction',
target: {
type: 'bpmn:Transaction',
isExpanded: true
}
}, {
label: 'Event Sub Process',
actionName: 'replace-with-event-subprocess',
className: 'bpmn-icon-event-subprocess-expanded',
target: {
type: 'bpmn:SubProcess',
triggeredByEvent: true,
isExpanded: true
}
}, {
label: 'Sub Process (collapsed)',
actionName: 'replace-with-collapsed-subprocess',
className: 'bpmn-icon-subprocess-collapsed',
target: {
type: 'bpmn:SubProcess',
isExpanded: false
}
}];
exports.SUBPROCESS_EXPANDED = SUBPROCESS_EXPANDED;
var TRANSACTION = [{
label: 'Sub Process',
actionName: 'replace-with-subprocess',
className: 'bpmn-icon-subprocess-expanded',
target: {
type: 'bpmn:SubProcess',
isExpanded: true
}
}, {
label: 'Event Sub Process',
actionName: 'replace-with-event-subprocess',
className: 'bpmn-icon-event-subprocess-expanded',
target: {
type: 'bpmn:SubProcess',
triggeredByEvent: true,
isExpanded: true
}
}];
exports.TRANSACTION = TRANSACTION;
var EVENT_SUB_PROCESS = [{
label: 'Sub Process',
actionName: 'replace-with-subprocess',
className: 'bpmn-icon-subprocess-expanded',
target: {
type: 'bpmn:SubProcess',
isExpanded: true
}
}, {
label: 'Transaction',
actionName: 'replace-with-transaction',
className: 'bpmn-icon-transaction',
target: {
type: 'bpmn:Transaction',
isExpanded: true
}
}];
exports.EVENT_SUB_PROCESS = EVENT_SUB_PROCESS;
var TASK = [{
label: 'Task',
actionName: 'replace-with-task',
className: 'bpmn-icon-task',
target: {
type: 'bpmn:Task'
}
}, {
label: 'Send Task',
actionName: 'replace-with-send-task',
className: 'bpmn-icon-send',
target: {
type: 'bpmn:SendTask'
}
}, {
label: 'Receive Task',
actionName: 'replace-with-receive-task',
className: 'bpmn-icon-receive',
target: {
type: 'bpmn:ReceiveTask'
}
}, {
label: 'User Task',
actionName: 'replace-with-user-task',
className: 'bpmn-icon-user',
target: {
type: 'bpmn:UserTask'
}
}, {
label: 'Manual Task',
actionName: 'replace-with-manual-task',
className: 'bpmn-icon-manual',
target: {
type: 'bpmn:ManualTask'
}
}, {
label: 'Business Rule Task',
actionName: 'replace-with-rule-task',
className: 'bpmn-icon-business-rule',
target: {
type: 'bpmn:BusinessRuleTask'
}
}, {
label: 'Service Task',
actionName: 'replace-with-service-task',
className: 'bpmn-icon-service',
target: {
type: 'bpmn:ServiceTask'
}
}, {
label: 'Script Task',
actionName: 'replace-with-script-task',
className: 'bpmn-icon-script',
target: {
type: 'bpmn:ScriptTask'
}
}, {
label: 'Call Activity',
actionName: 'replace-with-call-activity',
className: 'bpmn-icon-call-activity',
target: {
type: 'bpmn:CallActivity'
}
}, {
label: 'Sub Process (collapsed)',
actionName: 'replace-with-collapsed-subprocess',
className: 'bpmn-icon-subprocess-collapsed',
target: {
type: 'bpmn:SubProcess',
isExpanded: false
}
}, {
label: 'Sub Process (expanded)',
actionName: 'replace-with-expanded-subprocess',
className: 'bpmn-icon-subprocess-expanded',
target: {
type: 'bpmn:SubProcess',
isExpanded: true
}
}];
exports.TASK = TASK;
var DATA_OBJECT_REFERENCE = [{
label: 'Data Store Reference',
actionName: 'replace-with-data-store-reference',
className: 'bpmn-icon-data-store',
target: {
type: 'bpmn:DataStoreReference'
}
}];
exports.DATA_OBJECT_REFERENCE = DATA_OBJECT_REFERENCE;
var DATA_STORE_REFERENCE = [{
label: 'Data Object Reference',
actionName: 'replace-with-data-object-reference',
className: 'bpmn-icon-data-object',
target: {
type: 'bpmn:DataObjectReference'
}
}];
exports.DATA_STORE_REFERENCE = DATA_STORE_REFERENCE;
var BOUNDARY_EVENT = [{
label: 'Message Boundary Event',
actionName: 'replace-with-message-boundary',
className: 'bpmn-icon-intermediate-event-catch-message',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition'
}
}, {
label: 'Timer Boundary Event',
actionName: 'replace-with-timer-boundary',
className: 'bpmn-icon-intermediate-event-catch-timer',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:TimerEventDefinition'
}
}, {
label: 'Escalation Boundary Event',
actionName: 'replace-with-escalation-boundary',
className: 'bpmn-icon-intermediate-event-catch-escalation',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:EscalationEventDefinition'
}
}, {
label: 'Conditional Boundary Event',
actionName: 'replace-with-conditional-boundary',
className: 'bpmn-icon-intermediate-event-catch-condition',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
}
}, {
label: 'Error Boundary Event',
actionName: 'replace-with-error-boundary',
className: 'bpmn-icon-intermediate-event-catch-error',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:ErrorEventDefinition'
}
}, {
label: 'Cancel Boundary Event',
actionName: 'replace-with-cancel-boundary',
className: 'bpmn-icon-intermediate-event-catch-cancel',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:CancelEventDefinition'
}
}, {
label: 'Signal Boundary Event',
actionName: 'replace-with-signal-boundary',
className: 'bpmn-icon-intermediate-event-catch-signal',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition'
}
}, {
label: 'Compensation Boundary Event',
actionName: 'replace-with-compensation-boundary',
className: 'bpmn-icon-intermediate-event-catch-compensation',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:CompensateEventDefinition'
}
}, {
label: 'Message Boundary Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-message-boundary',
className: 'bpmn-icon-intermediate-event-catch-non-interrupting-message',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition',
cancelActivity: false
}
}, {
label: 'Timer Boundary Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-timer-boundary',
className: 'bpmn-icon-intermediate-event-catch-non-interrupting-timer',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:TimerEventDefinition',
cancelActivity: false
}
}, {
label: 'Escalation Boundary Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-escalation-boundary',
className: 'bpmn-icon-intermediate-event-catch-non-interrupting-escalation',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:EscalationEventDefinition',
cancelActivity: false
}
}, {
label: 'Conditional Boundary Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-conditional-boundary',
className: 'bpmn-icon-intermediate-event-catch-non-interrupting-condition',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition',
cancelActivity: false
}
}, {
label: 'Signal Boundary Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-signal-boundary',
className: 'bpmn-icon-intermediate-event-catch-non-interrupting-signal',
target: {
type: 'bpmn:BoundaryEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition',
cancelActivity: false
}
}];
exports.BOUNDARY_EVENT = BOUNDARY_EVENT;
var EVENT_SUB_PROCESS_START_EVENT = [{
label: 'Message Start Event',
actionName: 'replace-with-message-start',
className: 'bpmn-icon-start-event-message',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition'
}
}, {
label: 'Timer Start Event',
actionName: 'replace-with-timer-start',
className: 'bpmn-icon-start-event-timer',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:TimerEventDefinition'
}
}, {
label: 'Conditional Start Event',
actionName: 'replace-with-conditional-start',
className: 'bpmn-icon-start-event-condition',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
}
}, {
label: 'Signal Start Event',
actionName: 'replace-with-signal-start',
className: 'bpmn-icon-start-event-signal',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition'
}
}, {
label: 'Error Start Event',
actionName: 'replace-with-error-start',
className: 'bpmn-icon-start-event-error',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:ErrorEventDefinition'
}
}, {
label: 'Escalation Start Event',
actionName: 'replace-with-escalation-start',
className: 'bpmn-icon-start-event-escalation',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:EscalationEventDefinition'
}
}, {
label: 'Compensation Start Event',
actionName: 'replace-with-compensation-start',
className: 'bpmn-icon-start-event-compensation',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:CompensateEventDefinition'
}
}, {
label: 'Message Start Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-message-start',
className: 'bpmn-icon-start-event-non-interrupting-message',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:MessageEventDefinition',
isInterrupting: false
}
}, {
label: 'Timer Start Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-timer-start',
className: 'bpmn-icon-start-event-non-interrupting-timer',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:TimerEventDefinition',
isInterrupting: false
}
}, {
label: 'Conditional Start Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-conditional-start',
className: 'bpmn-icon-start-event-non-interrupting-condition',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition',
isInterrupting: false
}
}, {
label: 'Signal Start Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-signal-start',
className: 'bpmn-icon-start-event-non-interrupting-signal',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:SignalEventDefinition',
isInterrupting: false
}
}, {
label: 'Escalation Start Event (non-interrupting)',
actionName: 'replace-with-non-interrupting-escalation-start',
className: 'bpmn-icon-start-event-non-interrupting-escalation',
target: {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:EscalationEventDefinition',
isInterrupting: false
}
}];
exports.EVENT_SUB_PROCESS_START_EVENT = EVENT_SUB_PROCESS_START_EVENT;
var SEQUENCE_FLOW = [{
label: 'Sequence Flow',
actionName: 'replace-with-sequence-flow',
className: 'bpmn-icon-connection'
}, {
label: 'Default Flow',
actionName: 'replace-with-default-flow',
className: 'bpmn-icon-default-flow'
}, {
label: 'Conditional Flow',
actionName: 'replace-with-conditional-flow',
className: 'bpmn-icon-conditional-flow'
}];
exports.SEQUENCE_FLOW = SEQUENCE_FLOW;
var PARTICIPANT = [{
label: 'Expanded Pool',
actionName: 'replace-with-expanded-pool',
className: 'bpmn-icon-participant',
target: {
type: 'bpmn:Participant',
isExpanded: true
}
}, {
label: 'Collapsed Pool',
actionName: 'replace-with-collapsed-pool',
// TODO(@janstuemmel): maybe design new icon
className: 'bpmn-icon-lane',
target: {
type: 'bpmn:Participant',
isExpanded: false
}
}];
exports.PARTICIPANT = PARTICIPANT;
},{}],125:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _copyPaste = _interopRequireDefault(require("../copy-paste"));
var _replace = _interopRequireDefault(require("diagram-js/lib/features/replace"));
var _selection = _interopRequireDefault(require("diagram-js/lib/features/selection"));
var _BpmnReplace = _interopRequireDefault(require("./BpmnReplace"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_copyPaste.default, _replace.default, _selection.default],
bpmnReplace: ['type', _BpmnReplace.default]
};
exports.default = _default;
},{"../copy-paste":34,"./BpmnReplace":123,"diagram-js/lib/features/replace":266,"diagram-js/lib/features/selection":280}],126:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnRules;
var _minDash = require("min-dash");
var _inherits = _interopRequireDefault(require("inherits"));
var _ModelUtil = require("../../util/ModelUtil");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _LabelUtil = require("../../util/LabelUtil");
var _DiUtil = require("../../util/DiUtil");
var _RuleProvider = _interopRequireDefault(require("diagram-js/lib/features/rules/RuleProvider"));
var _BpmnSnappingUtil = require("../snapping/BpmnSnappingUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* BPMN specific modeling rule
*/
function BpmnRules(eventBus) {
_RuleProvider.default.call(this, eventBus);
}
(0, _inherits.default)(BpmnRules, _RuleProvider.default);
BpmnRules.$inject = ['eventBus'];
BpmnRules.prototype.init = function () {
this.addRule('connection.start', function (context) {
var source = context.source;
return canStartConnection(source);
});
this.addRule('connection.create', function (context) {
var source = context.source,
target = context.target,
hints = context.hints || {},
targetParent = hints.targetParent,
targetAttach = hints.targetAttach; // don't allow incoming connections on
// newly created boundary events
// to boundary events
if (targetAttach) {
return false;
} // temporarily set target parent for scoping
// checks to work
if (targetParent) {
target.parent = targetParent;
}
try {
return canConnect(source, target);
} finally {
// unset temporary target parent
if (targetParent) {
target.parent = null;
}
}
});
this.addRule('connection.reconnect', function (context) {
var connection = context.connection,
source = context.source,
target = context.target;
return canConnect(source, target, connection);
});
this.addRule('connection.updateWaypoints', function (context) {
return {
type: context.connection.type
};
});
this.addRule('shape.resize', function (context) {
var shape = context.shape,
newBounds = context.newBounds;
return canResize(shape, newBounds);
});
this.addRule('elements.create', function (context) {
var elements = context.elements,
position = context.position,
target = context.target;
return (0, _minDash.every)(elements, function (element) {
if (isConnection(element)) {
return canConnect(element.source, element.target, element);
}
if (element.host) {
return canAttach(element, element.host, null, position);
}
return canCreate(element, target, null, position);
});
});
this.addRule('elements.move', function (context) {
var target = context.target,
shapes = context.shapes,
position = context.position;
return canAttach(shapes, target, null, position) || canReplace(shapes, target, position) || canMove(shapes, target, position) || canInsert(shapes, target, position);
});
this.addRule('shape.create', function (context) {
return canCreate(context.shape, context.target, context.source, context.position);
});
this.addRule('shape.attach', function (context) {
return canAttach(context.shape, context.target, null, context.position);
});
this.addRule('element.copy', function (context) {
var element = context.element,
elements = context.elements;
return canCopy(elements, element);
});
};
BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow;
BpmnRules.prototype.canConnectDataAssociation = canConnectDataAssociation;
BpmnRules.prototype.canConnectAssociation = canConnectAssociation;
BpmnRules.prototype.canMove = canMove;
BpmnRules.prototype.canAttach = canAttach;
BpmnRules.prototype.canReplace = canReplace;
BpmnRules.prototype.canDrop = canDrop;
BpmnRules.prototype.canInsert = canInsert;
BpmnRules.prototype.canCreate = canCreate;
BpmnRules.prototype.canConnect = canConnect;
BpmnRules.prototype.canResize = canResize;
BpmnRules.prototype.canCopy = canCopy;
/**
* Utility functions for rule checking
*/
/**
* Checks if given element can be used for starting connection.
*
* @param {Element} source
* @return {boolean}
*/
function canStartConnection(element) {
if (nonExistingOrLabel(element)) {
return null;
}
return (0, _ModelingUtil.isAny)(element, ['bpmn:FlowNode', 'bpmn:InteractionNode', 'bpmn:DataObjectReference', 'bpmn:DataStoreReference', 'bpmn:Group']);
}
function nonExistingOrLabel(element) {
return !element || (0, _LabelUtil.isLabel)(element);
}
function isSame(a, b) {
return a === b;
}
function getOrganizationalParent(element) {
do {
if ((0, _ModelUtil.is)(element, 'bpmn:Process')) {
return (0, _ModelUtil.getBusinessObject)(element);
}
if ((0, _ModelUtil.is)(element, 'bpmn:Participant')) {
return (0, _ModelUtil.getBusinessObject)(element).processRef || (0, _ModelUtil.getBusinessObject)(element);
}
} while (element = element.parent);
}
function isTextAnnotation(element) {
return (0, _ModelUtil.is)(element, 'bpmn:TextAnnotation');
}
function isGroup(element) {
return (0, _ModelUtil.is)(element, 'bpmn:Group') && !element.labelTarget;
}
function isCompensationBoundary(element) {
return (0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent') && hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
}
function isForCompensation(e) {
return (0, _ModelUtil.getBusinessObject)(e).isForCompensation;
}
function isSameOrganization(a, b) {
var parentA = getOrganizationalParent(a),
parentB = getOrganizationalParent(b);
return parentA === parentB;
}
function isMessageFlowSource(element) {
return (0, _ModelUtil.is)(element, 'bpmn:InteractionNode') && !(0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent') && (!(0, _ModelUtil.is)(element, 'bpmn:Event') || (0, _ModelUtil.is)(element, 'bpmn:ThrowEvent') && hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition'));
}
function isMessageFlowTarget(element) {
return (0, _ModelUtil.is)(element, 'bpmn:InteractionNode') && !isForCompensation(element) && (!(0, _ModelUtil.is)(element, 'bpmn:Event') || (0, _ModelUtil.is)(element, 'bpmn:CatchEvent') && hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')) && !((0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent') && !hasEventDefinition(element, 'bpmn:MessageEventDefinition'));
}
function getScopeParent(element) {
var parent = element;
while (parent = parent.parent) {
if ((0, _ModelUtil.is)(parent, 'bpmn:FlowElementsContainer')) {
return (0, _ModelUtil.getBusinessObject)(parent);
}
if ((0, _ModelUtil.is)(parent, 'bpmn:Participant')) {
return (0, _ModelUtil.getBusinessObject)(parent).processRef;
}
}
return null;
}
function isSameScope(a, b) {
var scopeParentA = getScopeParent(a),
scopeParentB = getScopeParent(b);
return scopeParentA === scopeParentB;
}
function hasEventDefinition(element, eventDefinition) {
var bo = (0, _ModelUtil.getBusinessObject)(element);
return !!(0, _minDash.find)(bo.eventDefinitions || [], function (definition) {
return (0, _ModelUtil.is)(definition, eventDefinition);
});
}
function hasEventDefinitionOrNone(element, eventDefinition) {
var bo = (0, _ModelUtil.getBusinessObject)(element);
return (bo.eventDefinitions || []).every(function (definition) {
return (0, _ModelUtil.is)(definition, eventDefinition);
});
}
function isSequenceFlowSource(element) {
return (0, _ModelUtil.is)(element, 'bpmn:FlowNode') && !(0, _ModelUtil.is)(element, 'bpmn:EndEvent') && !(0, _DiUtil.isEventSubProcess)(element) && !((0, _ModelUtil.is)(element, 'bpmn:IntermediateThrowEvent') && hasEventDefinition(element, 'bpmn:LinkEventDefinition')) && !isCompensationBoundary(element) && !isForCompensation(element);
}
function isSequenceFlowTarget(element) {
return (0, _ModelUtil.is)(element, 'bpmn:FlowNode') && !(0, _ModelUtil.is)(element, 'bpmn:StartEvent') && !(0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent') && !(0, _DiUtil.isEventSubProcess)(element) && !((0, _ModelUtil.is)(element, 'bpmn:IntermediateCatchEvent') && hasEventDefinition(element, 'bpmn:LinkEventDefinition')) && !isForCompensation(element);
}
function isEventBasedTarget(element) {
return (0, _ModelUtil.is)(element, 'bpmn:ReceiveTask') || (0, _ModelUtil.is)(element, 'bpmn:IntermediateCatchEvent') && (hasEventDefinition(element, 'bpmn:MessageEventDefinition') || hasEventDefinition(element, 'bpmn:TimerEventDefinition') || hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') || hasEventDefinition(element, 'bpmn:SignalEventDefinition'));
}
function isConnection(element) {
return element.waypoints;
}
function getParents(element) {
var parents = [];
while (element) {
element = element.parent;
if (element) {
parents.push(element);
}
}
return parents;
}
function isParent(possibleParent, element) {
var allParents = getParents(element);
return allParents.indexOf(possibleParent) !== -1;
}
function canConnect(source, target, connection) {
if (nonExistingOrLabel(source) || nonExistingOrLabel(target)) {
return null;
}
if (!(0, _ModelUtil.is)(connection, 'bpmn:DataAssociation')) {
if (canConnectMessageFlow(source, target)) {
return {
type: 'bpmn:MessageFlow'
};
}
if (canConnectSequenceFlow(source, target)) {
return {
type: 'bpmn:SequenceFlow'
};
}
}
var connectDataAssociation = canConnectDataAssociation(source, target);
if (connectDataAssociation) {
return connectDataAssociation;
}
if (isCompensationBoundary(source) && isForCompensation(target)) {
return {
type: 'bpmn:Association',
associationDirection: 'One'
};
}
if (canConnectAssociation(source, target)) {
return {
type: 'bpmn:Association'
};
}
return false;
}
/**
* Can an element be dropped into the target element
*
* @return {boolean}
*/
function canDrop(element, target, position) {
// can move labels and groups everywhere
if ((0, _LabelUtil.isLabel)(element) || isGroup(element)) {
return true;
} // disallow to create elements on collapsed pools
if ((0, _ModelUtil.is)(target, 'bpmn:Participant') && !(0, _DiUtil.isExpanded)(target)) {
return false;
} // allow to create new participants on
// existing collaboration and process diagrams
if ((0, _ModelUtil.is)(element, 'bpmn:Participant')) {
return (0, _ModelUtil.is)(target, 'bpmn:Process') || (0, _ModelUtil.is)(target, 'bpmn:Collaboration');
} // allow moving DataInput / DataOutput within its original container only
if ((0, _ModelingUtil.isAny)(element, ['bpmn:DataInput', 'bpmn:DataOutput'])) {
if (element.parent) {
return target === element.parent;
}
} // allow creating lanes on participants and other lanes only
if ((0, _ModelUtil.is)(element, 'bpmn:Lane')) {
return (0, _ModelUtil.is)(target, 'bpmn:Participant') || (0, _ModelUtil.is)(target, 'bpmn:Lane');
} // disallow dropping boundary events which cannot replace with intermediate event
if ((0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent') && !isDroppableBoundaryEvent(element)) {
return false;
} // drop flow elements onto flow element containers
// and participants
if ((0, _ModelUtil.is)(element, 'bpmn:FlowElement') && !(0, _ModelUtil.is)(element, 'bpmn:DataStoreReference')) {
if ((0, _ModelUtil.is)(target, 'bpmn:FlowElementsContainer')) {
return (0, _DiUtil.isExpanded)(target);
}
return (0, _ModelingUtil.isAny)(target, ['bpmn:Participant', 'bpmn:Lane']);
} // account for the fact that data associations are always
// rendered and moved to top (Process or Collaboration level)
//
// artifacts may be placed wherever, too
if ((0, _ModelingUtil.isAny)(element, ['bpmn:Artifact', 'bpmn:DataAssociation', 'bpmn:DataStoreReference'])) {
return (0, _ModelingUtil.isAny)(target, ['bpmn:Collaboration', 'bpmn:Lane', 'bpmn:Participant', 'bpmn:Process', 'bpmn:SubProcess']);
}
if ((0, _ModelUtil.is)(element, 'bpmn:MessageFlow')) {
return (0, _ModelUtil.is)(target, 'bpmn:Collaboration') || element.source.parent == target || element.target.parent == target;
}
return false;
}
function isDroppableBoundaryEvent(event) {
return (0, _ModelUtil.getBusinessObject)(event).cancelActivity && (hasNoEventDefinition(event) || hasCommonBoundaryIntermediateEventDefinition(event));
}
function isBoundaryEvent(element) {
return !(0, _LabelUtil.isLabel)(element) && (0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent');
}
function isLane(element) {
return (0, _ModelUtil.is)(element, 'bpmn:Lane');
}
/**
* We treat IntermediateThrowEvents as boundary events during create,
* this must be reflected in the rules.
*/
function isBoundaryCandidate(element) {
if (isBoundaryEvent(element)) {
return true;
}
if ((0, _ModelUtil.is)(element, 'bpmn:IntermediateThrowEvent') && hasNoEventDefinition(element)) {
return true;
}
return (0, _ModelUtil.is)(element, 'bpmn:IntermediateCatchEvent') && hasCommonBoundaryIntermediateEventDefinition(element);
}
function hasNoEventDefinition(element) {
var bo = (0, _ModelUtil.getBusinessObject)(element);
return bo && !(bo.eventDefinitions && bo.eventDefinitions.length);
}
function hasCommonBoundaryIntermediateEventDefinition(element) {
return hasOneOfEventDefinitions(element, ['bpmn:MessageEventDefinition', 'bpmn:TimerEventDefinition', 'bpmn:SignalEventDefinition', 'bpmn:ConditionalEventDefinition']);
}
function hasOneOfEventDefinitions(element, eventDefinitions) {
return eventDefinitions.some(function (definition) {
return hasEventDefinition(element, definition);
});
}
function isReceiveTaskAfterEventBasedGateway(element) {
return (0, _ModelUtil.is)(element, 'bpmn:ReceiveTask') && (0, _minDash.find)(element.incoming, function (incoming) {
return (0, _ModelUtil.is)(incoming.source, 'bpmn:EventBasedGateway');
});
}
function canAttach(elements, target, source, position) {
if (!Array.isArray(elements)) {
elements = [elements];
} // only (re-)attach one element at a time
if (elements.length !== 1) {
return false;
}
var element = elements[0]; // do not attach labels
if ((0, _LabelUtil.isLabel)(element)) {
return false;
} // only handle boundary events
if (!isBoundaryCandidate(element)) {
return false;
} // disallow drop on event sub processes
if ((0, _DiUtil.isEventSubProcess)(target)) {
return false;
} // only allow drop on non compensation activities
if (!(0, _ModelUtil.is)(target, 'bpmn:Activity') || isForCompensation(target)) {
return false;
} // only attach to subprocess border
if (position && !(0, _BpmnSnappingUtil.getBoundaryAttachment)(position, target)) {
return false;
} // do not attach on receive tasks after event based gateways
if (isReceiveTaskAfterEventBasedGateway(target)) {
return false;
}
return 'attach';
}
/**
* Defines how to replace elements for a given target.
*
* Returns an array containing all elements which will be replaced.
*
* @example
*
* [{ id: 'IntermediateEvent_2',
* type: 'bpmn:StartEvent'
* },
* { id: 'IntermediateEvent_5',
* type: 'bpmn:EndEvent'
* }]
*
* @param {Array} elements
* @param {Object} target
*
* @return {Object} an object containing all elements which have to be replaced
*/
function canReplace(elements, target, position) {
if (!target) {
return false;
}
var canExecute = {
replacements: []
};
(0, _minDash.forEach)(elements, function (element) {
if (!(0, _DiUtil.isEventSubProcess)(target)) {
if ((0, _ModelUtil.is)(element, 'bpmn:StartEvent') && element.type !== 'label' && canDrop(element, target)) {
// replace a non-interrupting start event by a blank interrupting start event
// when the target is not an event sub process
if (!(0, _DiUtil.isInterrupting)(element)) {
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:StartEvent'
});
} // replace an error/escalation/compensate start event by a blank interrupting start event
// when the target is not an event sub process
if ((0, _DiUtil.hasErrorEventDefinition)(element) || (0, _DiUtil.hasEscalationEventDefinition)(element) || (0, _DiUtil.hasCompensateEventDefinition)(element)) {
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:StartEvent'
});
} // replace a typed start event by a blank interrupting start event
// when the target is a sub process but not an event sub process
if (hasOneOfEventDefinitions(element, ['bpmn:MessageEventDefinition', 'bpmn:TimerEventDefinition', 'bpmn:SignalEventDefinition', 'bpmn:ConditionalEventDefinition']) && (0, _ModelUtil.is)(target, 'bpmn:SubProcess')) {
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:StartEvent'
});
}
}
}
if (!(0, _ModelUtil.is)(target, 'bpmn:Transaction')) {
if (hasEventDefinition(element, 'bpmn:CancelEventDefinition') && element.type !== 'label') {
if ((0, _ModelUtil.is)(element, 'bpmn:EndEvent') && canDrop(element, target)) {
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:EndEvent'
});
}
if ((0, _ModelUtil.is)(element, 'bpmn:BoundaryEvent') && canAttach(element, target, null, position)) {
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:BoundaryEvent'
});
}
}
}
});
return canExecute.replacements.length ? canExecute : false;
}
function canMove(elements, target) {
// do not move selection containing lanes
if ((0, _minDash.some)(elements, isLane)) {
return false;
} // allow default move check to start move operation
if (!target) {
return true;
}
return elements.every(function (element) {
return canDrop(element, target);
});
}
function canCreate(shape, target, source, position) {
if (!target) {
return false;
}
if ((0, _LabelUtil.isLabel)(shape) || isGroup(shape)) {
return true;
}
if (isSame(source, target)) {
return false;
} // ensure we do not drop the element
// into source
if (source && isParent(source, target)) {
return false;
}
return canDrop(shape, target, position) || canInsert(shape, target, position);
}
function canResize(shape, newBounds) {
if ((0, _ModelUtil.is)(shape, 'bpmn:SubProcess')) {
return (0, _DiUtil.isExpanded)(shape) && (!newBounds || newBounds.width >= 100 && newBounds.height >= 80);
}
if ((0, _ModelUtil.is)(shape, 'bpmn:Lane')) {
return !newBounds || newBounds.width >= 130 && newBounds.height >= 60;
}
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
return !newBounds || newBounds.width >= 250 && newBounds.height >= 50;
}
if (isTextAnnotation(shape)) {
return true;
}
if (isGroup(shape)) {
return true;
}
return false;
}
/**
* Check, whether one side of the relationship
* is a text annotation.
*/
function isOneTextAnnotation(source, target) {
var sourceTextAnnotation = isTextAnnotation(source),
targetTextAnnotation = isTextAnnotation(target);
return (sourceTextAnnotation || targetTextAnnotation) && sourceTextAnnotation !== targetTextAnnotation;
}
function canConnectAssociation(source, target) {
// do not connect connections
if (isConnection(source) || isConnection(target)) {
return false;
} // compensation boundary events are exception
if (isCompensationBoundary(source) && isForCompensation(target)) {
return true;
} // don't connect parent <-> child
if (isParent(target, source) || isParent(source, target)) {
return false;
} // allow connection of associations between and
if (isOneTextAnnotation(source, target)) {
return true;
} // can connect associations where we can connect
// data associations, too (!)
return !!canConnectDataAssociation(source, target);
}
function canConnectMessageFlow(source, target) {
// during connect user might move mouse out of canvas
// https://github.com/bpmn-io/bpmn-js/issues/1033
if (getRootElement(source) && !getRootElement(target)) {
return false;
}
return isMessageFlowSource(source) && isMessageFlowTarget(target) && !isSameOrganization(source, target);
}
function canConnectSequenceFlow(source, target) {
if (isEventBasedTarget(target) && target.incoming.length > 0 && areOutgoingEventBasedGatewayConnections(target.incoming) && !(0, _ModelUtil.is)(source, 'bpmn:EventBasedGateway')) {
return false;
}
return isSequenceFlowSource(source) && isSequenceFlowTarget(target) && isSameScope(source, target) && !((0, _ModelUtil.is)(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target));
}
function canConnectDataAssociation(source, target) {
if ((0, _ModelingUtil.isAny)(source, ['bpmn:DataObjectReference', 'bpmn:DataStoreReference']) && (0, _ModelingUtil.isAny)(target, ['bpmn:Activity', 'bpmn:ThrowEvent'])) {
return {
type: 'bpmn:DataInputAssociation'
};
}
if ((0, _ModelingUtil.isAny)(target, ['bpmn:DataObjectReference', 'bpmn:DataStoreReference']) && (0, _ModelingUtil.isAny)(source, ['bpmn:Activity', 'bpmn:CatchEvent'])) {
return {
type: 'bpmn:DataOutputAssociation'
};
}
return false;
}
function canInsert(shape, flow, position) {
if (!flow) {
return false;
}
if (Array.isArray(shape)) {
if (shape.length !== 1) {
return false;
}
shape = shape[0];
}
if (flow.source === shape || flow.target === shape) {
return false;
} // return true if we can drop on the
// underlying flow parent
//
// at this point we are not really able to talk
// about connection rules (yet)
return (0, _ModelingUtil.isAny)(flow, ['bpmn:SequenceFlow', 'bpmn:MessageFlow']) && !(0, _LabelUtil.isLabel)(flow) && (0, _ModelUtil.is)(shape, 'bpmn:FlowNode') && !(0, _ModelUtil.is)(shape, 'bpmn:BoundaryEvent') && canDrop(shape, flow.parent, position);
}
function includes(elements, element) {
return elements && element && elements.indexOf(element) !== -1;
}
function canCopy(elements, element) {
if ((0, _LabelUtil.isLabel)(element)) {
return true;
}
if ((0, _ModelUtil.is)(element, 'bpmn:Lane') && !includes(elements, element.parent)) {
return false;
}
return true;
}
function isOutgoingEventBasedGatewayConnection(connection) {
if (connection && connection.source) {
return (0, _ModelUtil.is)(connection.source, 'bpmn:EventBasedGateway');
}
}
function areOutgoingEventBasedGatewayConnections(connections) {
connections = connections || [];
return connections.some(isOutgoingEventBasedGatewayConnection);
}
function getRootElement(element) {
return (0, _ModelingUtil.getParent)(element, 'bpmn:Process') || (0, _ModelingUtil.getParent)(element, 'bpmn:Collaboration');
}
},{"../../util/DiUtil":140,"../../util/LabelUtil":141,"../../util/ModelUtil":142,"../modeling/util/ModelingUtil":113,"../snapping/BpmnSnappingUtil":132,"diagram-js/lib/features/rules/RuleProvider":272,"inherits":349,"min-dash":559}],127:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _rules = _interopRequireDefault(require("diagram-js/lib/features/rules"));
var _BpmnRules = _interopRequireDefault(require("./BpmnRules"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_rules.default],
__init__: ['bpmnRules'],
bpmnRules: ['type', _BpmnRules.default]
};
exports.default = _default;
},{"./BpmnRules":126,"diagram-js/lib/features/rules":274}],128:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnSearchProvider;
var _minDash = require("min-dash");
var _LabelUtil = require("../label-editing/LabelUtil");
/**
* Provides ability to search through BPMN elements
*/
function BpmnSearchProvider(elementRegistry, searchPad, canvas) {
this._elementRegistry = elementRegistry;
this._canvas = canvas;
searchPad.registerProvider(this);
}
BpmnSearchProvider.$inject = ['elementRegistry', 'searchPad', 'canvas'];
/**
* Finds all elements that match given pattern
*
* :
* {
* primaryTokens: >,
* secondaryTokens: >,
* element:
* }
*
* :
* {
* normal|matched:
* }
*
* @param {string} pattern
* @return {Array}
*/
BpmnSearchProvider.prototype.find = function (pattern) {
var rootElement = this._canvas.getRootElement();
var elements = this._elementRegistry.filter(function (element) {
if (element.labelTarget) {
return false;
}
return true;
}); // do not include root element
elements = (0, _minDash.filter)(elements, function (element) {
return element !== rootElement;
});
elements = (0, _minDash.map)(elements, function (element) {
return {
primaryTokens: matchAndSplit((0, _LabelUtil.getLabel)(element), pattern),
secondaryTokens: matchAndSplit(element.id, pattern),
element: element
};
}); // exclude non-matched elements
elements = (0, _minDash.filter)(elements, function (element) {
return hasMatched(element.primaryTokens) || hasMatched(element.secondaryTokens);
});
elements = (0, _minDash.sortBy)(elements, function (element) {
return (0, _LabelUtil.getLabel)(element.element) + element.element.id;
});
return elements;
};
function hasMatched(tokens) {
var matched = (0, _minDash.filter)(tokens, function (t) {
return !!t.matched;
});
return matched.length > 0;
}
function matchAndSplit(text, pattern) {
var tokens = [],
originalText = text;
if (!text) {
return tokens;
}
text = text.toLowerCase();
pattern = pattern.toLowerCase();
var i = text.indexOf(pattern);
if (i > -1) {
if (i !== 0) {
tokens.push({
normal: originalText.substr(0, i)
});
}
tokens.push({
matched: originalText.substr(i, pattern.length)
});
if (pattern.length + i < text.length) {
tokens.push({
normal: originalText.substr(pattern.length + i, text.length)
});
}
} else {
tokens.push({
normal: originalText
});
}
return tokens;
}
},{"../label-editing/LabelUtil":53,"min-dash":559}],129:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _searchPad = _interopRequireDefault(require("diagram-js/lib/features/search-pad"));
var _BpmnSearchProvider = _interopRequireDefault(require("./BpmnSearchProvider"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_searchPad.default],
__init__: ['bpmnSearch'],
bpmnSearch: ['type', _BpmnSearchProvider.default]
};
exports.default = _default;
},{"./BpmnSearchProvider":128,"diagram-js/lib/features/search-pad":276}],130:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnConnectSnapping;
var _SnapUtil = require("diagram-js/lib/features/snapping/SnapUtil");
var _KeyboardUtil = require("diagram-js/lib/features/keyboard/KeyboardUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _ModelUtil = require("../../util/ModelUtil");
var _ModelingUtil = require("../modeling/util/ModelingUtil");
var _minDash = require("min-dash");
var HIGHER_PRIORITY = 1250;
var BOUNDARY_TO_HOST_THRESHOLD = 40;
var TARGET_BOUNDS_PADDING = 20,
TASK_BOUNDS_PADDING = 10;
var TARGET_CENTER_PADDING = 20;
var AXES = ['x', 'y'];
var abs = Math.abs;
/**
* Snap during connect.
*
* @param {EventBus} eventBus
*/
function BpmnConnectSnapping(eventBus) {
eventBus.on(['connect.hover', 'connect.move', 'connect.end'], HIGHER_PRIORITY, function (event) {
var context = event.context,
canExecute = context.canExecute,
start = context.start,
hover = context.hover,
source = context.source,
target = context.target; // do NOT snap on CMD
if (event.originalEvent && (0, _KeyboardUtil.isCmd)(event.originalEvent)) {
return;
}
if (!context.initialConnectionStart) {
context.initialConnectionStart = context.connectionStart;
} // snap hover
if (canExecute && hover) {
snapToShape(event, hover, getTargetBoundsPadding(hover));
}
if (hover && isAnyType(canExecute, ['bpmn:Association', 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation', 'bpmn:SequenceFlow'])) {
context.connectionStart = (0, _SnapUtil.mid)(start); // snap hover
if ((0, _ModelingUtil.isAny)(hover, ['bpmn:Event', 'bpmn:Gateway'])) {
snapToPosition(event, (0, _SnapUtil.mid)(hover));
} // snap hover
if ((0, _ModelingUtil.isAny)(hover, ['bpmn:Task', 'bpmn:SubProcess'])) {
snapToTargetMid(event, hover);
} // snap source and target
if ((0, _ModelUtil.is)(source, 'bpmn:BoundaryEvent') && target === source.host) {
snapBoundaryEventLoop(event);
}
} else if (isType(canExecute, 'bpmn:MessageFlow')) {
if ((0, _ModelUtil.is)(start, 'bpmn:Event')) {
// snap start
context.connectionStart = (0, _SnapUtil.mid)(start);
}
if ((0, _ModelUtil.is)(hover, 'bpmn:Event')) {
// snap hover
snapToPosition(event, (0, _SnapUtil.mid)(hover));
}
} else {
// un-snap source
context.connectionStart = context.initialConnectionStart;
}
});
}
BpmnConnectSnapping.$inject = ['eventBus']; // helpers //////////
// snap to target if event in target
function snapToShape(event, target, padding) {
AXES.forEach(function (axis) {
var dimensionForAxis = getDimensionForAxis(axis, target);
if (event[axis] < target[axis] + padding) {
(0, _SnapUtil.setSnapped)(event, axis, target[axis] + padding);
} else if (event[axis] > target[axis] + dimensionForAxis - padding) {
(0, _SnapUtil.setSnapped)(event, axis, target[axis] + dimensionForAxis - padding);
}
});
} // snap to target mid if event in target mid
function snapToTargetMid(event, target) {
var targetMid = (0, _SnapUtil.mid)(target);
AXES.forEach(function (axis) {
if (isMid(event, target, axis)) {
(0, _SnapUtil.setSnapped)(event, axis, targetMid[axis]);
}
});
} // snap to prevent loop overlapping boundary event
function snapBoundaryEventLoop(event) {
var context = event.context,
source = context.source,
target = context.target;
if (isReverse(context)) {
return;
}
var sourceMid = (0, _SnapUtil.mid)(source),
orientation = (0, _LayoutUtil.getOrientation)(sourceMid, target, -10),
axes = [];
if (/top|bottom/.test(orientation)) {
axes.push('x');
}
if (/left|right/.test(orientation)) {
axes.push('y');
}
axes.forEach(function (axis) {
var coordinate = event[axis],
newCoordinate;
if (abs(coordinate - sourceMid[axis]) < BOUNDARY_TO_HOST_THRESHOLD) {
if (coordinate > sourceMid[axis]) {
newCoordinate = sourceMid[axis] + BOUNDARY_TO_HOST_THRESHOLD;
} else {
newCoordinate = sourceMid[axis] - BOUNDARY_TO_HOST_THRESHOLD;
}
(0, _SnapUtil.setSnapped)(event, axis, newCoordinate);
}
});
}
function snapToPosition(event, position) {
(0, _SnapUtil.setSnapped)(event, 'x', position.x);
(0, _SnapUtil.setSnapped)(event, 'y', position.y);
}
function isType(attrs, type) {
return attrs && attrs.type === type;
}
function isAnyType(attrs, types) {
return (0, _minDash.some)(types, function (type) {
return isType(attrs, type);
});
}
function getDimensionForAxis(axis, element) {
return axis === 'x' ? element.width : element.height;
}
function getTargetBoundsPadding(target) {
if ((0, _ModelUtil.is)(target, 'bpmn:Task')) {
return TASK_BOUNDS_PADDING;
} else {
return TARGET_BOUNDS_PADDING;
}
}
function isMid(event, target, axis) {
return event[axis] > target[axis] + TARGET_CENTER_PADDING && event[axis] < target[axis] + getDimensionForAxis(axis, target) - TARGET_CENTER_PADDING;
}
function isReverse(context) {
var hover = context.hover,
source = context.source;
return hover && source && hover === source;
}
},{"../../util/ModelUtil":142,"../modeling/util/ModelingUtil":113,"diagram-js/lib/features/keyboard/KeyboardUtil":218,"diagram-js/lib/features/snapping/SnapUtil":284,"diagram-js/lib/layout/LayoutUtil":302,"min-dash":559}],131:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnCreateMoveSnapping;
var _inherits = _interopRequireDefault(require("inherits"));
var _CreateMoveSnapping = _interopRequireDefault(require("diagram-js/lib/features/snapping/CreateMoveSnapping"));
var _SnapUtil = require("diagram-js/lib/features/snapping/SnapUtil");
var _DiUtil = require("../../util/DiUtil");
var _ModelUtil = require("../../util/ModelUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _BpmnSnappingUtil = require("./BpmnSnappingUtil");
var _minDash = require("min-dash");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var HIGH_PRIORITY = 1500;
/**
* Snap during create and move.
*
* @param {EventBus} eventBus
* @param {Injector} injector
*/
function BpmnCreateMoveSnapping(eventBus, injector) {
injector.invoke(_CreateMoveSnapping.default, this); // creating first participant
eventBus.on(['create.move', 'create.end'], HIGH_PRIORITY, setSnappedIfConstrained); // snap boundary events
eventBus.on(['create.move', 'create.end', 'shape.move.move', 'shape.move.end'], HIGH_PRIORITY, function (event) {
var context = event.context,
canExecute = context.canExecute,
target = context.target;
var canAttach = canExecute && (canExecute === 'attach' || canExecute.attach);
if (canAttach && !(0, _SnapUtil.isSnapped)(event)) {
snapBoundaryEvent(event, target);
}
});
}
(0, _inherits.default)(BpmnCreateMoveSnapping, _CreateMoveSnapping.default);
BpmnCreateMoveSnapping.$inject = ['eventBus', 'injector'];
BpmnCreateMoveSnapping.prototype.initSnap = function (event) {
var snapContext = _CreateMoveSnapping.default.prototype.initSnap.call(this, event);
var shape = event.shape;
var isMove = !!this._elementRegistry.get(shape.id); // snap to docking points
(0, _minDash.forEach)(shape.outgoing, function (connection) {
var docking = connection.waypoints[0];
docking = docking.original || docking;
snapContext.setSnapOrigin(connection.id + '-docking', getDockingSnapOrigin(docking, isMove, event));
});
(0, _minDash.forEach)(shape.incoming, function (connection) {
var docking = connection.waypoints[connection.waypoints.length - 1];
docking = docking.original || docking;
snapContext.setSnapOrigin(connection.id + '-docking', getDockingSnapOrigin(docking, isMove, event));
});
if ((0, _ModelUtil.is)(shape, 'bpmn:Participant')) {
// snap to borders with higher priority
snapContext.setSnapLocations(['top-left', 'bottom-right', 'mid']);
}
return snapContext;
};
BpmnCreateMoveSnapping.prototype.addSnapTargetPoints = function (snapPoints, shape, target) {
_CreateMoveSnapping.default.prototype.addSnapTargetPoints.call(this, snapPoints, shape, target);
var snapTargets = this.getSnapTargets(shape, target);
(0, _minDash.forEach)(snapTargets, function (snapTarget) {
// handle TRBL alignment
//
// * with container elements
// * with text annotations
if (isContainer(snapTarget) || areAll([shape, snapTarget], 'bpmn:TextAnnotation')) {
snapPoints.add('top-left', (0, _SnapUtil.topLeft)(snapTarget));
snapPoints.add('bottom-right', (0, _SnapUtil.bottomRight)(snapTarget));
}
});
var elementRegistry = this._elementRegistry; // snap to docking points if not create mode
(0, _minDash.forEach)(shape.incoming, function (connection) {
if (elementRegistry.get(shape.id)) {
if (!includes(snapTargets, connection.source)) {
snapPoints.add('mid', (0, _LayoutUtil.getMid)(connection.source));
}
var docking = connection.waypoints[0];
snapPoints.add(connection.id + '-docking', docking.original || docking);
}
});
(0, _minDash.forEach)(shape.outgoing, function (connection) {
if (elementRegistry.get(shape.id)) {
if (!includes(snapTargets, connection.target)) {
snapPoints.add('mid', (0, _LayoutUtil.getMid)(connection.target));
}
var docking = connection.waypoints[connection.waypoints.length - 1];
snapPoints.add(connection.id + '-docking', docking.original || docking);
}
}); // add sequence flow parents as snap targets
if ((0, _ModelUtil.is)(target, 'bpmn:SequenceFlow')) {
snapPoints = this.addSnapTargetPoints(snapPoints, shape, target.parent);
}
return snapPoints;
};
BpmnCreateMoveSnapping.prototype.getSnapTargets = function (shape, target) {
return _CreateMoveSnapping.default.prototype.getSnapTargets.call(this, shape, target).filter(function (snapTarget) {
// do not snap to lanes
return !(0, _ModelUtil.is)(snapTarget, 'bpmn:Lane');
});
}; // helpers //////////
function snapBoundaryEvent(event, target) {
var targetTRBL = (0, _LayoutUtil.asTRBL)(target);
var direction = (0, _BpmnSnappingUtil.getBoundaryAttachment)(event, target);
var context = event.context,
shape = context.shape;
var offset;
if (shape.parent) {
offset = {
x: 0,
y: 0
};
} else {
offset = (0, _LayoutUtil.getMid)(shape);
}
if (/top/.test(direction)) {
(0, _SnapUtil.setSnapped)(event, 'y', targetTRBL.top - offset.y);
} else if (/bottom/.test(direction)) {
(0, _SnapUtil.setSnapped)(event, 'y', targetTRBL.bottom - offset.y);
}
if (/left/.test(direction)) {
(0, _SnapUtil.setSnapped)(event, 'x', targetTRBL.left - offset.x);
} else if (/right/.test(direction)) {
(0, _SnapUtil.setSnapped)(event, 'x', targetTRBL.right - offset.x);
}
}
function areAll(elements, type) {
return elements.every(function (el) {
return (0, _ModelUtil.is)(el, type);
});
}
function isContainer(element) {
if ((0, _ModelUtil.is)(element, 'bpmn:SubProcess') && (0, _DiUtil.isExpanded)(element)) {
return true;
}
return (0, _ModelUtil.is)(element, 'bpmn:Participant');
}
function setSnappedIfConstrained(event) {
var context = event.context,
createConstraints = context.createConstraints;
if (!createConstraints) {
return;
}
var top = createConstraints.top,
right = createConstraints.right,
bottom = createConstraints.bottom,
left = createConstraints.left;
if (left && left >= event.x || right && right <= event.x) {
(0, _SnapUtil.setSnapped)(event, 'x', event.x);
}
if (top && top >= event.y || bottom && bottom <= event.y) {
(0, _SnapUtil.setSnapped)(event, 'y', event.y);
}
}
function includes(array, value) {
return array.indexOf(value) !== -1;
}
function getDockingSnapOrigin(docking, isMove, event) {
return isMove ? {
x: docking.x - event.x,
y: docking.y - event.y
} : {
x: docking.x,
y: docking.y
};
}
},{"../../util/DiUtil":140,"../../util/ModelUtil":142,"./BpmnSnappingUtil":132,"diagram-js/lib/features/snapping/CreateMoveSnapping":281,"diagram-js/lib/features/snapping/SnapUtil":284,"diagram-js/lib/layout/LayoutUtil":302,"inherits":349,"min-dash":559}],132:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getBoundaryAttachment = getBoundaryAttachment;
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
function getBoundaryAttachment(position, targetBounds) {
var orientation = (0, _LayoutUtil.getOrientation)(position, targetBounds, -15);
if (orientation !== 'intersect') {
return orientation;
} else {
return null;
}
}
},{"diagram-js/lib/layout/LayoutUtil":302}],133:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BpmnConnectSnapping = _interopRequireDefault(require("./BpmnConnectSnapping"));
var _BpmnCreateMoveSnapping = _interopRequireDefault(require("./BpmnCreateMoveSnapping"));
var _snapping = _interopRequireDefault(require("diagram-js/lib/features/snapping"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_snapping.default],
__init__: ['connectSnapping', 'createMoveSnapping'],
connectSnapping: ['type', _BpmnConnectSnapping.default],
createMoveSnapping: ['type', _BpmnCreateMoveSnapping.default]
};
exports.default = _default;
},{"./BpmnConnectSnapping":130,"./BpmnCreateMoveSnapping":131,"diagram-js/lib/features/snapping":286}],134:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnImporter;
var _minDash = require("min-dash");
var _ModelUtil = require("../util/ModelUtil");
var _LabelUtil = require("../util/LabelUtil");
var _LayoutUtil = require("diagram-js/lib/layout/LayoutUtil");
var _DiUtil = require("../util/DiUtil");
var _LabelUtil2 = require("../features/label-editing/LabelUtil");
var _Util = require("./Util");
function elementData(semantic, attrs) {
return (0, _minDash.assign)({
id: semantic.id,
type: semantic.$type,
businessObject: semantic
}, attrs);
}
function getWaypoints(bo, source, target) {
var waypoints = bo.di.waypoint;
if (!waypoints || waypoints.length < 2) {
return [(0, _LayoutUtil.getMid)(source), (0, _LayoutUtil.getMid)(target)];
}
return waypoints.map(function (p) {
return {
x: p.x,
y: p.y
};
});
}
function notYetDrawn(translate, semantic, refSemantic, property) {
return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
element: (0, _Util.elementToString)(refSemantic),
referenced: (0, _Util.elementToString)(semantic),
property: property
}));
}
/**
* An importer that adds bpmn elements to the canvas
*
* @param {EventBus} eventBus
* @param {Canvas} canvas
* @param {ElementFactory} elementFactory
* @param {ElementRegistry} elementRegistry
* @param {Function} translate
* @param {TextRenderer} textRenderer
*/
function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry, translate, textRenderer) {
this._eventBus = eventBus;
this._canvas = canvas;
this._elementFactory = elementFactory;
this._elementRegistry = elementRegistry;
this._translate = translate;
this._textRenderer = textRenderer;
}
BpmnImporter.$inject = ['eventBus', 'canvas', 'elementFactory', 'elementRegistry', 'translate', 'textRenderer'];
/**
* Add bpmn element (semantic) to the canvas onto the
* specified parent shape.
*/
BpmnImporter.prototype.add = function (semantic, parentElement) {
var di = semantic.di,
element,
translate = this._translate,
hidden;
var parentIndex; // ROOT ELEMENT
// handle the special case that we deal with a
// invisible root element (process or collaboration)
if ((0, _ModelUtil.is)(di, 'bpmndi:BPMNPlane')) {
// add a virtual element (not being drawn)
element = this._elementFactory.createRoot(elementData(semantic));
this._canvas.setRootElement(element);
} // SHAPE
else if ((0, _ModelUtil.is)(di, 'bpmndi:BPMNShape')) {
var collapsed = !(0, _DiUtil.isExpanded)(semantic),
isFrame = isFrameElement(semantic);
hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
var bounds = semantic.di.bounds;
element = this._elementFactory.createShape(elementData(semantic, {
collapsed: collapsed,
hidden: hidden,
x: Math.round(bounds.x),
y: Math.round(bounds.y),
width: Math.round(bounds.width),
height: Math.round(bounds.height),
isFrame: isFrame
}));
if ((0, _ModelUtil.is)(semantic, 'bpmn:BoundaryEvent')) {
this._attachBoundary(semantic, element);
} // insert lanes behind other flow nodes (cf. #727)
if ((0, _ModelUtil.is)(semantic, 'bpmn:Lane')) {
parentIndex = 0;
}
if ((0, _ModelUtil.is)(semantic, 'bpmn:DataStoreReference')) {
// check whether data store is inside our outside of its semantic parent
if (!isPointInsideBBox(parentElement, (0, _LayoutUtil.getMid)(bounds))) {
parentElement = this._canvas.getRootElement();
}
}
this._canvas.addShape(element, parentElement, parentIndex);
} // CONNECTION
else if ((0, _ModelUtil.is)(di, 'bpmndi:BPMNEdge')) {
var source = this._getSource(semantic),
target = this._getTarget(semantic);
hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
element = this._elementFactory.createConnection(elementData(semantic, {
hidden: hidden,
source: source,
target: target,
waypoints: getWaypoints(semantic, source, target)
}));
if ((0, _ModelUtil.is)(semantic, 'bpmn:DataAssociation')) {
// render always on top; this ensures DataAssociations
// are rendered correctly across different "hacks" people
// love to model such as cross participant / sub process
// associations
parentElement = null;
} // insert sequence flows behind other flow nodes (cf. #727)
if ((0, _ModelUtil.is)(semantic, 'bpmn:SequenceFlow')) {
parentIndex = 0;
}
this._canvas.addConnection(element, parentElement, parentIndex);
} else {
throw new Error(translate('unknown di {di} for element {semantic}', {
di: (0, _Util.elementToString)(di),
semantic: (0, _Util.elementToString)(semantic)
}));
} // (optional) LABEL
if ((0, _LabelUtil.isLabelExternal)(semantic) && (0, _LabelUtil2.getLabel)(element)) {
this.addLabel(semantic, element);
}
this._eventBus.fire('bpmnElement.added', {
element: element
});
return element;
};
/**
* Attach the boundary element to the given host
*
* @param {ModdleElement} boundarySemantic
* @param {djs.model.Base} boundaryElement
*/
BpmnImporter.prototype._attachBoundary = function (boundarySemantic, boundaryElement) {
var translate = this._translate;
var hostSemantic = boundarySemantic.attachedToRef;
if (!hostSemantic) {
throw new Error(translate('missing {semantic}#attachedToRef', {
semantic: (0, _Util.elementToString)(boundarySemantic)
}));
}
var host = this._elementRegistry.get(hostSemantic.id),
attachers = host && host.attachers;
if (!host) {
throw notYetDrawn(translate, boundarySemantic, hostSemantic, 'attachedToRef');
} // wire element.host <> host.attachers
boundaryElement.host = host;
if (!attachers) {
host.attachers = attachers = [];
}
if (attachers.indexOf(boundaryElement) === -1) {
attachers.push(boundaryElement);
}
};
/**
* add label for an element
*/
BpmnImporter.prototype.addLabel = function (semantic, element) {
var bounds, text, label;
bounds = (0, _LabelUtil.getExternalLabelBounds)(semantic, element);
text = (0, _LabelUtil2.getLabel)(element);
if (text) {
// get corrected bounds from actual layouted text
bounds = this._textRenderer.getExternalLabelBounds(bounds, text);
}
label = this._elementFactory.createLabel(elementData(semantic, {
id: semantic.id + '_label',
labelTarget: element,
type: 'label',
hidden: element.hidden || !(0, _LabelUtil2.getLabel)(element),
x: Math.round(bounds.x),
y: Math.round(bounds.y),
width: Math.round(bounds.width),
height: Math.round(bounds.height)
}));
return this._canvas.addShape(label, element.parent);
};
/**
* Return the drawn connection end based on the given side.
*
* @throws {Error} if the end is not yet drawn
*/
BpmnImporter.prototype._getEnd = function (semantic, side) {
var element,
refSemantic,
type = semantic.$type,
translate = this._translate;
refSemantic = semantic[side + 'Ref']; // handle mysterious isMany DataAssociation#sourceRef
if (side === 'source' && type === 'bpmn:DataInputAssociation') {
refSemantic = refSemantic && refSemantic[0];
} // fix source / target for DataInputAssociation / DataOutputAssociation
if (side === 'source' && type === 'bpmn:DataOutputAssociation' || side === 'target' && type === 'bpmn:DataInputAssociation') {
refSemantic = semantic.$parent;
}
element = refSemantic && this._getElement(refSemantic);
if (element) {
return element;
}
if (refSemantic) {
throw notYetDrawn(translate, semantic, refSemantic, side + 'Ref');
} else {
throw new Error(translate('{semantic}#{side} Ref not specified', {
semantic: (0, _Util.elementToString)(semantic),
side: side
}));
}
};
BpmnImporter.prototype._getSource = function (semantic) {
return this._getEnd(semantic, 'source');
};
BpmnImporter.prototype._getTarget = function (semantic) {
return this._getEnd(semantic, 'target');
};
BpmnImporter.prototype._getElement = function (semantic) {
return this._elementRegistry.get(semantic.id);
}; // helpers ////////////////////
function isPointInsideBBox(bbox, point) {
var x = point.x,
y = point.y;
return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
}
function isFrameElement(semantic) {
return (0, _ModelUtil.is)(semantic, 'bpmn:Group');
}
},{"../features/label-editing/LabelUtil":53,"../util/DiUtil":140,"../util/LabelUtil":141,"../util/ModelUtil":142,"./Util":137,"diagram-js/lib/layout/LayoutUtil":302,"min-dash":559}],135:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BpmnTreeWalker;
var _minDash = require("min-dash");
var _objectRefs = _interopRequireDefault(require("object-refs"));
var _Util = require("./Util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var diRefs = new _objectRefs.default({
name: 'bpmnElement',
enumerable: true
}, {
name: 'di',
configurable: true
});
/**
* Returns true if an element has the given meta-model type
*
* @param {ModdleElement} element
* @param {string} type
*
* @return {boolean}
*/
function is(element, type) {
return element.$instanceOf(type);
}
/**
* Find a suitable display candidate for definitions where the DI does not
* correctly specify one.
*/
function findDisplayCandidate(definitions) {
return (0, _minDash.find)(definitions.rootElements, function (e) {
return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration');
});
}
function BpmnTreeWalker(handler, translate) {
// list of containers already walked
var handledElements = {}; // list of elements to handle deferred to ensure
// prerequisites are drawn
var deferred = []; // Helpers //////////////////////
function contextual(fn, ctx) {
return function (e) {
fn(e, ctx);
};
}
function handled(element) {
handledElements[element.id] = element;
}
function isHandled(element) {
return handledElements[element.id];
}
function visit(element, ctx) {
var gfx = element.gfx; // avoid multiple rendering of elements
if (gfx) {
throw new Error(translate('already rendered {element}', {
element: (0, _Util.elementToString)(element)
}));
} // call handler
return handler.element(element, ctx);
}
function visitRoot(element, diagram) {
return handler.root(element, diagram);
}
function visitIfDi(element, ctx) {
try {
var gfx = element.di && visit(element, ctx);
handled(element);
return gfx;
} catch (e) {
logError(e.message, {
element: element,
error: e
});
console.error(translate('failed to import {element}', {
element: (0, _Util.elementToString)(element)
}));
console.error(e);
}
}
function logError(message, context) {
handler.error(message, context);
} // DI handling //////////////////////
function registerDi(di) {
var bpmnElement = di.bpmnElement;
if (bpmnElement) {
if (bpmnElement.di) {
logError(translate('multiple DI elements defined for {element}', {
element: (0, _Util.elementToString)(bpmnElement)
}), {
element: bpmnElement
});
} else {
diRefs.bind(bpmnElement, 'di');
bpmnElement.di = di;
}
} else {
logError(translate('no bpmnElement referenced in {element}', {
element: (0, _Util.elementToString)(di)
}), {
element: di
});
}
}
function handleDiagram(diagram) {
handlePlane(diagram.plane);
}
function handlePlane(plane) {
registerDi(plane);
(0, _minDash.forEach)(plane.planeElement, handlePlaneElement);
}
function handlePlaneElement(planeElement) {
registerDi(planeElement);
} // Semantic handling //////////////////////
/**
* Handle definitions and return the rendered diagram (if any)
*
* @param {ModdleElement} definitions to walk and import
* @param {ModdleElement} [diagram] specific diagram to import and display
*
* @throws {Error} if no diagram to display could be found
*/
function handleDefinitions(definitions, diagram) {
// make sure we walk the correct bpmnElement
var diagrams = definitions.diagrams;
if (diagram && diagrams.indexOf(diagram) === -1) {
throw new Error(translate('diagram not part of bpmn:Definitions'));
}
if (!diagram && diagrams && diagrams.length) {
diagram = diagrams[0];
} // no diagram -> nothing to import
if (!diagram) {
throw new Error(translate('no diagram to display'));
} // load DI from selected diagram only
handleDiagram(diagram);
var plane = diagram.plane;
if (!plane) {
throw new Error(translate('no plane for {element}', {
element: (0, _Util.elementToString)(diagram)
}));
}
var rootElement = plane.bpmnElement; // ensure we default to a suitable display candidate (process or collaboration),
// even if non is specified in DI
if (!rootElement) {
rootElement = findDisplayCandidate(definitions);
if (!rootElement) {
throw new Error(translate('no process or collaboration to display'));
} else {
logError(translate('correcting missing bpmnElement on {plane} to {rootElement}', {
plane: (0, _Util.elementToString)(plane),
rootElement: (0, _Util.elementToString)(rootElement)
})); // correct DI on the fly
plane.bpmnElement = rootElement;
registerDi(plane);
}
}
var ctx = visitRoot(rootElement, plane);
if (is(rootElement, 'bpmn:Process')) {
handleProcess(rootElement, ctx);
} else if (is(rootElement, 'bpmn:Collaboration')) {
handleCollaboration(rootElement, ctx); // force drawing of everything not yet drawn that is part of the target DI
handleUnhandledProcesses(definitions.rootElements, ctx);
} else {
throw new Error(translate('unsupported bpmnElement for {plane}: {rootElement}', {
plane: (0, _Util.elementToString)(plane),
rootElement: (0, _Util.elementToString)(rootElement)
}));
} // handle all deferred elements
handleDeferred(deferred);
}
function handleDeferred() {
var fn; // drain deferred until empty
while (deferred.length) {
fn = deferred.shift();
fn();
}
}
function handleProcess(process, context) {
handleFlowElementsContainer(process, context);
handleIoSpecification(process.ioSpecification, context);
handleArtifacts(process.artifacts, context); // log process handled
handled(process);
}
function handleUnhandledProcesses(rootElements, ctx) {
// walk through all processes that have not yet been drawn and draw them
// if they contain lanes with DI information.
// we do this to pass the free-floating lane test cases in the MIWG test suite
var processes = (0, _minDash.filter)(rootElements, function (e) {
return !isHandled(e) && is(e, 'bpmn:Process') && e.laneSets;
});
processes.forEach(contextual(handleProcess, ctx));
}
function handleMessageFlow(messageFlow, context) {
visitIfDi(messageFlow, context);
}
function handleMessageFlows(messageFlows, context) {
(0, _minDash.forEach)(messageFlows, contextual(handleMessageFlow, context));
}
function handleDataAssociation(association, context) {
visitIfDi(association, context);
}
function handleDataInput(dataInput, context) {
visitIfDi(dataInput, context);
}
function handleDataOutput(dataOutput, context) {
visitIfDi(dataOutput, context);
}
function handleArtifact(artifact, context) {
// bpmn:TextAnnotation
// bpmn:Group
// bpmn:Association
visitIfDi(artifact, context);
}
function handleArtifacts(artifacts, context) {
(0, _minDash.forEach)(artifacts, function (e) {
if (is(e, 'bpmn:Association')) {
deferred.push(function () {
handleArtifact(e, context);
});
} else {
handleArtifact(e, context);
}
});
}
function handleIoSpecification(ioSpecification, context) {
if (!ioSpecification) {
return;
}
(0, _minDash.forEach)(ioSpecification.dataInputs, contextual(handleDataInput, context));
(0, _minDash.forEach)(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
}
function handleSubProcess(subProcess, context) {
handleFlowElementsContainer(subProcess, context);
handleArtifacts(subProcess.artifacts, context);
}
function handleFlowNode(flowNode, context) {
var childCtx = visitIfDi(flowNode, context);
if (is(flowNode, 'bpmn:SubProcess')) {
handleSubProcess(flowNode, childCtx || context);
}
if (is(flowNode, 'bpmn:Activity')) {
handleIoSpecification(flowNode.ioSpecification, context);
} // defer handling of associations
// affected types:
//
// * bpmn:Activity
// * bpmn:ThrowEvent
// * bpmn:CatchEvent
//
deferred.push(function () {
(0, _minDash.forEach)(flowNode.dataInputAssociations, contextual(handleDataAssociation, context));
(0, _minDash.forEach)(flowNode.dataOutputAssociations, contextual(handleDataAssociation, context));
});
}
function handleSequenceFlow(sequenceFlow, context) {
visitIfDi(sequenceFlow, context);
}
function handleDataElement(dataObject, context) {
visitIfDi(dataObject, context);
}
function handleLane(lane, context) {
deferred.push(function () {
var newContext = visitIfDi(lane, context);
if (lane.childLaneSet) {
handleLaneSet(lane.childLaneSet, newContext || context);
}
wireFlowNodeRefs(lane);
});
}
function handleLaneSet(laneSet, context) {
(0, _minDash.forEach)(laneSet.lanes, contextual(handleLane, context));
}
function handleLaneSets(laneSets, context) {
(0, _minDash.forEach)(laneSets, contextual(handleLaneSet, context));
}
function handleFlowElementsContainer(container, context) {
handleFlowElements(container.flowElements, context);
if (container.laneSets) {
handleLaneSets(container.laneSets, context);
}
}
function handleFlowElements(flowElements, context) {
(0, _minDash.forEach)(flowElements, function (e) {
if (is(e, 'bpmn:SequenceFlow')) {
deferred.push(function () {
handleSequenceFlow(e, context);
});
} else if (is(e, 'bpmn:BoundaryEvent')) {
deferred.unshift(function () {
handleFlowNode(e, context);
});
} else if (is(e, 'bpmn:FlowNode')) {
handleFlowNode(e, context);
} else if (is(e, 'bpmn:DataObject')) {// SKIP (assume correct referencing via DataObjectReference)
} else if (is(e, 'bpmn:DataStoreReference')) {
handleDataElement(e, context);
} else if (is(e, 'bpmn:DataObjectReference')) {
handleDataElement(e, context);
} else {
logError(translate('unrecognized flowElement {element} in context {context}', {
element: (0, _Util.elementToString)(e),
context: context ? (0, _Util.elementToString)(context.businessObject) : 'null'
}), {
element: e,
context: context
});
}
});
}
function handleParticipant(participant, context) {
var newCtx = visitIfDi(participant, context);
var process = participant.processRef;
if (process) {
handleProcess(process, newCtx || context);
}
}
function handleCollaboration(collaboration) {
(0, _minDash.forEach)(collaboration.participants, contextual(handleParticipant));
handleArtifacts(collaboration.artifacts); // handle message flows latest in the process
deferred.push(function () {
handleMessageFlows(collaboration.messageFlows);
});
}
function wireFlowNodeRefs(lane) {
// wire the virtual flowNodeRefs <-> relationship
(0, _minDash.forEach)(lane.flowNodeRef, function (flowNode) {
var lanes = flowNode.get('lanes');
if (lanes) {
lanes.push(lane);
}
});
} // API //////////////////////
return {
handleDeferred: handleDeferred,
handleDefinitions: handleDefinitions,
handleSubProcess: handleSubProcess,
registerDi: registerDi
};
}
},{"./Util":137,"min-dash":559,"object-refs":564}],136:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.importBpmnDiagram = importBpmnDiagram;
var _BpmnTreeWalker = _interopRequireDefault(require("./BpmnTreeWalker"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* The importBpmnDiagram result.
*
* @typedef {Object} ImportBPMNDiagramResult
*
* @property {Array} warnings
*/
/**
* The importBpmnDiagram error.
*
* @typedef {Error} ImportBPMNDiagramError
*
* @property {Array} warnings
*/
/**
* Import the definitions into a diagram.
*
* Errors and warnings are reported through the specified callback.
*
* @param {djs.Diagram} diagram
* @param {ModdleElement} definitions
* @param {ModdleElement} [bpmnDiagram] the diagram to be rendered
* (if not provided, the first one will be rendered)
*
* Returns {Promise}
*/
function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
var importer, eventBus, translate;
var error,
warnings = [];
/**
* Walk the diagram semantically, importing (=drawing)
* all elements you encounter.
*
* @param {ModdleElement} definitions
* @param {ModdleElement} bpmnDiagram
*/
function render(definitions, bpmnDiagram) {
var visitor = {
root: function (element) {
return importer.add(element);
},
element: function (element, parentShape) {
return importer.add(element, parentShape);
},
error: function (message, context) {
warnings.push({
message: message,
context: context
});
}
};
var walker = new _BpmnTreeWalker.default(visitor, translate); // traverse BPMN 2.0 document model,
// starting at definitions
walker.handleDefinitions(definitions, bpmnDiagram);
}
return new Promise(function (resolve, reject) {
try {
importer = diagram.get('bpmnImporter');
eventBus = diagram.get('eventBus');
translate = diagram.get('translate');
eventBus.fire('import.render.start', {
definitions: definitions
});
render(definitions, bpmnDiagram);
eventBus.fire('import.render.complete', {
error: error,
warnings: warnings
});
return resolve({
warnings: warnings
});
} catch (e) {
e.warnings = warnings;
return reject(e);
}
});
}
},{"./BpmnTreeWalker":135}],137:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.elementToString = elementToString;
function elementToString(e) {
if (!e) {
return '';
}
return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
}
},{}],138:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _translate = _interopRequireDefault(require("diagram-js/lib/i18n/translate"));
var _BpmnImporter = _interopRequireDefault(require("./BpmnImporter"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
__depends__: [_translate.default],
bpmnImporter: ['type', _BpmnImporter.default]
};
exports.default = _default;
},{"./BpmnImporter":134,"diagram-js/lib/i18n/translate":298}],139:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.wrapForCompatibility = wrapForCompatibility;
var _minDash = require("min-dash");
// TODO(nikku): remove with future bpmn-js version
/**
* Wraps APIs to check:
*
* 1) If a callback is passed -> Warn users about callback deprecation.
* 2) If Promise class is implemented in current environment.
*
* @private
*/
function wrapForCompatibility(api) {
return function () {
if (!window.Promise) {
throw new Error('Promises is not supported in this environment. Please polyfill Promise.');
}
var argLen = arguments.length;
if (argLen >= 1 && (0, _minDash.isFunction)(arguments[argLen - 1])) {
var callback = arguments[argLen - 1];
console.warn(new Error('Passing callbacks to ' + api.name + ' is deprecated and will be removed in a future major release. ' + 'Please switch to promises: https://bpmn.io/l/moving-to-promises.html'));
var argsWithoutCallback = Array.prototype.slice.call(arguments, 0, -1);
api.apply(this, argsWithoutCallback).then(function (result) {
var firstKey = Object.keys(result)[0]; // The APIs we are wrapping all resolve a single item depending on the API.
// For instance, importXML resolves { warnings } and saveXML returns { xml }.
// That's why we can call the callback with the first item of result.
return callback(null, result[firstKey]); // Passing a second paramter instead of catch because we don't want to
// catch errors thrown by callback().
}, function (err) {
return callback(err, err.warnings);
});
} else {
return api.apply(this, arguments);
}
};
}
},{"min-dash":559}],140:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasCompensateEventDefinition = hasCompensateEventDefinition;
exports.hasErrorEventDefinition = hasErrorEventDefinition;
exports.hasEscalationEventDefinition = hasEscalationEventDefinition;
exports.hasEventDefinition = hasEventDefinition;
exports.isEventSubProcess = isEventSubProcess;
exports.isExpanded = isExpanded;
exports.isInterrupting = isInterrupting;
var _ModelUtil = require("./ModelUtil");
var _minDash = require("min-dash");
function isExpanded(element) {
if ((0, _ModelUtil.is)(element, 'bpmn:CallActivity')) {
return false;
}
if ((0, _ModelUtil.is)(element, 'bpmn:SubProcess')) {
return (0, _ModelUtil.getBusinessObject)(element).di && !!(0, _ModelUtil.getBusinessObject)(element).di.isExpanded;
}
if ((0, _ModelUtil.is)(element, 'bpmn:Participant')) {
return !!(0, _ModelUtil.getBusinessObject)(element).processRef;
}
return true;
}
function isInterrupting(element) {
return element && (0, _ModelUtil.getBusinessObject)(element).isInterrupting !== false;
}
function isEventSubProcess(element) {
return element && !!(0, _ModelUtil.getBusinessObject)(element).triggeredByEvent;
}
function hasEventDefinition(element, eventType) {
var bo = (0, _ModelUtil.getBusinessObject)(element),
hasEventDefinition = false;
if (bo.eventDefinitions) {
(0, _minDash.forEach)(bo.eventDefinitions, function (event) {
if ((0, _ModelUtil.is)(event, eventType)) {
hasEventDefinition = true;
}
});
}
return hasEventDefinition;
}
function hasErrorEventDefinition(element) {
return hasEventDefinition(element, 'bpmn:ErrorEventDefinition');
}
function hasEscalationEventDefinition(element) {
return hasEventDefinition(element, 'bpmn:EscalationEventDefinition');
}
function hasCompensateEventDefinition(element) {
return hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
}
},{"./ModelUtil":142,"min-dash":559}],141:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FLOW_LABEL_INDENT = exports.DEFAULT_LABEL_SIZE = void 0;
exports.getExternalLabelBounds = getExternalLabelBounds;
exports.getExternalLabelMid = getExternalLabelMid;
exports.getFlowLabelPosition = getFlowLabelPosition;
exports.getWaypointsMid = getWaypointsMid;
exports.hasExternalLabel = hasExternalLabel;
exports.isLabel = isLabel;
exports.isLabelExternal = isLabelExternal;
var _minDash = require("min-dash");
var _ModelUtil = require("./ModelUtil");
var DEFAULT_LABEL_SIZE = {
width: 90,
height: 20
};
exports.DEFAULT_LABEL_SIZE = DEFAULT_LABEL_SIZE;
var FLOW_LABEL_INDENT = 15;
/**
* Returns true if the given semantic has an external label
*
* @param {BpmnElement} semantic
* @return {boolean} true if has label
*/
exports.FLOW_LABEL_INDENT = FLOW_LABEL_INDENT;
function isLabelExternal(semantic) {
return (0, _ModelUtil.is)(semantic, 'bpmn:Event') || (0, _ModelUtil.is)(semantic, 'bpmn:Gateway') || (0, _ModelUtil.is)(semantic, 'bpmn:DataStoreReference') || (0, _ModelUtil.is)(semantic, 'bpmn:DataObjectReference') || (0, _ModelUtil.is)(semantic, 'bpmn:DataInput') || (0, _ModelUtil.is)(semantic, 'bpmn:DataOutput') || (0, _ModelUtil.is)(semantic, 'bpmn:SequenceFlow') || (0, _ModelUtil.is)(semantic, 'bpmn:MessageFlow') || (0, _ModelUtil.is)(semantic, 'bpmn:Group');
}
/**
* Returns true if the given element has an external label
*
* @param {djs.model.shape} element
* @return {boolean} true if has label
*/
function hasExternalLabel(element) {
return isLabel(element.label);
}
/**
* Get the position for sequence flow labels
*
* @param {Array} waypoints
* @return {Point} the label position
*/
function getFlowLabelPosition(waypoints) {
// get the waypoints mid
var mid = waypoints.length / 2 - 1;
var first = waypoints[Math.floor(mid)];
var second = waypoints[Math.ceil(mid + 0.01)]; // get position
var position = getWaypointsMid(waypoints); // calculate angle
var angle = Math.atan((second.y - first.y) / (second.x - first.x));
var x = position.x,
y = position.y;
if (Math.abs(angle) < Math.PI / 2) {
y -= FLOW_LABEL_INDENT;
} else {
x += FLOW_LABEL_INDENT;
}
return {
x: x,
y: y
};
}
/**
* Get the middle of a number of waypoints
*
* @param {Array} waypoints
* @return {Point} the mid point
*/
function getWaypointsMid(waypoints) {
var mid = waypoints.length / 2 - 1;
var first = waypoints[Math.floor(mid)];
var second = waypoints[Math.ceil(mid + 0.01)];
return {
x: first.x + (second.x - first.x) / 2,
y: first.y + (second.y - first.y) / 2
};
}
function getExternalLabelMid(element) {
if (element.waypoints) {
return getFlowLabelPosition(element.waypoints);
} else if ((0, _ModelUtil.is)(element, 'bpmn:Group')) {
return {
x: element.x + element.width / 2,
y: element.y + DEFAULT_LABEL_SIZE.height / 2
};
} else {
return {
x: element.x + element.width / 2,
y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2
};
}
}
/**
* Returns the bounds of an elements label, parsed from the elements DI or
* generated from its bounds.
*
* @param {BpmnElement} semantic
* @param {djs.model.Base} element
*/
function getExternalLabelBounds(semantic, element) {
var mid,
size,
bounds,
di = semantic.di,
label = di.label;
if (label && label.bounds) {
bounds = label.bounds;
size = {
width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width),
height: bounds.height
};
mid = {
x: bounds.x + bounds.width / 2,
y: bounds.y + bounds.height / 2
};
} else {
mid = getExternalLabelMid(element);
size = DEFAULT_LABEL_SIZE;
}
return (0, _minDash.assign)({
x: mid.x - size.width / 2,
y: mid.y - size.height / 2
}, size);
}
function isLabel(element) {
return element && !!element.labelTarget;
}
},{"./ModelUtil":142,"min-dash":559}],142:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getBusinessObject = getBusinessObject;
exports.is = is;
/**
* Is an element of the given BPMN type?
*
* @param {djs.model.Base|ModdleElement} element
* @param {string} type
*
* @return {boolean}
*/
function is(element, type) {
var bo = getBusinessObject(element);
return bo && typeof bo.$instanceOf === 'function' && bo.$instanceOf(type);
}
/**
* Return the business object for a given element.
*
* @param {djs.model.Base|ModdleElement} element
*
* @return {ModdleElement}
*/
function getBusinessObject(element) {
return element && element.businessObject || element;
}
},{}],143:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LINK_STYLES = exports.BPMNIO_IMG = void 0;
exports.open = open;
var _minDom = require("min-dom");
/**
* This file must not be changed or exchanged.
*
* @see http://bpmn.io/license for more information.
*/
// inlined ../../resources/logo.svg
var BPMNIO_LOGO_SVG = '';
var BPMNIO_IMG = BPMNIO_LOGO_SVG;
exports.BPMNIO_IMG = BPMNIO_IMG;
function css(attrs) {
return attrs.join(';');
}
var LINK_STYLES = css(['color: #404040']);
exports.LINK_STYLES = LINK_STYLES;
var LIGHTBOX_STYLES = css(['z-index: 1001', 'position: fixed', 'top: 0', 'left: 0', 'right: 0', 'bottom: 0']);
var BACKDROP_STYLES = css(['width: 100%', 'height: 100%', 'background: rgba(40,40,40,0.2)']);
var NOTICE_STYLES = css(['position: absolute', 'left: 50%', 'top: 40%', 'transform: translate(-50%)', 'width: 260px', 'padding: 10px', 'background: white', 'box-shadow: 0 1px 4px rgba(0,0,0,0.3)', 'font-family: Helvetica, Arial, sans-serif', 'font-size: 14px', 'display: flex', 'line-height: 1.3']);
var LIGHTBOX_MARKUP = '
' + '' + '
' + '' + BPMNIO_IMG + '' + '' + 'Web-based tooling for BPMN, DMN and CMMN diagrams ' + 'powered by bpmn.io.' + '' + '
' + '
';
var lightbox;
function open() {
if (!lightbox) {
lightbox = (0, _minDom.domify)(LIGHTBOX_MARKUP);
_minDom.delegate.bind(lightbox, '.backdrop', 'click', function (event) {
document.body.removeChild(lightbox);
});
}
document.body.appendChild(lightbox);
}
},{"min-dom":560}],144:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _Diagram.default;
}
});
var _Diagram = _interopRequireDefault(require("./lib/Diagram"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
},{"./lib/Diagram":145}],145:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Diagram;
var _didi = require("didi");
var _core = _interopRequireDefault(require("./core"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Bootstrap an injector from a list of modules, instantiating a number of default components
*
* @ignore
* @param {Array} bootstrapModules
*
* @return {didi.Injector} a injector to use to access the components
*/
function bootstrap(bootstrapModules) {
var modules = [],
components = [];
function hasModule(m) {
return modules.indexOf(m) >= 0;
}
function addModule(m) {
modules.push(m);
}
function visit(m) {
if (hasModule(m)) {
return;
}
(m.__depends__ || []).forEach(visit);
if (hasModule(m)) {
return;
}
addModule(m);
(m.__init__ || []).forEach(function (c) {
components.push(c);
});
}
bootstrapModules.forEach(visit);
var injector = new _didi.Injector(modules);
components.forEach(function (c) {
try {
// eagerly resolve component (fn or string)
injector[typeof c === 'string' ? 'get' : 'invoke'](c);
} catch (e) {
console.error('Failed to instantiate component');
console.error(e.stack);
throw e;
}
});
return injector;
}
/**
* Creates an injector from passed options.
*
* @ignore
* @param {Object} options
* @return {didi.Injector}
*/
function createInjector(options) {
options = options || {};
var configModule = {
'config': ['value', options]
};
var modules = [configModule, _core.default].concat(options.modules || []);
return bootstrap(modules);
}
/**
* The main diagram-js entry point that bootstraps the diagram with the given
* configuration.
*
* To register extensions with the diagram, pass them as Array to the constructor.
*
* @class djs.Diagram
* @memberOf djs
* @constructor
*
* @example
*
*
Creating a plug-in that logs whenever a shape is added to the canvas.
*
* // plug-in implemenentation
* function MyLoggingPlugin(eventBus) {
* eventBus.on('shape.added', function(event) {
* console.log('shape ', event.shape, ' was added to the diagram');
* });
* }
*
* // export as module
* export default {
* __init__: [ 'myLoggingPlugin' ],
* myLoggingPlugin: [ 'type', MyLoggingPlugin ]
* };
*
*
* // instantiate the diagram with the new plug-in
*
* import MyLoggingModule from 'path-to-my-logging-plugin';
*
* var diagram = new Diagram({
* modules: [
* MyLoggingModule
* ]
* });
*
* diagram.invoke([ 'canvas', function(canvas) {
* // add shape to drawing canvas
* canvas.addShape({ x: 10, y: 10 });
* });
*
* // 'shape ... was added to the diagram' logged to console
*
* @param {Object} options
* @param {Array} [options.modules] external modules to instantiate with the diagram
* @param {didi.Injector} [injector] an (optional) injector to bootstrap the diagram with
*/
function Diagram(options, injector) {
// create injector unless explicitly specified
this.injector = injector = injector || createInjector(options); // API
/**
* Resolves a diagram service
*
* @method Diagram#get
*
* @param {string} name the name of the diagram service to be retrieved
* @param {boolean} [strict=true] if false, resolve missing services to null
*/
this.get = injector.get;
/**
* Executes a function into which diagram services are injected
*
* @method Diagram#invoke
*
* @param {Function|Object[]} fn the function to resolve
* @param {Object} locals a number of locals to use to resolve certain dependencies
*/
this.invoke = injector.invoke; // init
// indicate via event
/**
* An event indicating that all plug-ins are loaded.
*
* Use this event to fire other events to interested plug-ins
*
* @memberOf Diagram
*
* @event diagram.init
*
* @example
*
* eventBus.on('diagram.init', function() {
* eventBus.fire('my-custom-event', { foo: 'BAR' });
* });
*
* @type {Object}
*/
this.get('eventBus').fire('diagram.init');
}
/**
* Destroys the diagram
*
* @method Diagram#destroy
*/
Diagram.prototype.destroy = function () {
this.get('eventBus').fire('diagram.destroy');
};
/**
* Clear the diagram, removing all contents.
*/
Diagram.prototype.clear = function () {
this.get('eventBus').fire('diagram.clear');
};
},{"./core":154,"didi":346}],146:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CommandInterceptor;
var _minDash = require("min-dash");
var DEFAULT_PRIORITY = 1000;
/**
* A utility that can be used to plug-in into the command execution for
* extension and/or validation.
*
* @param {EventBus} eventBus
*
* @example
*
* import inherits from 'inherits';
*
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
*
* function CommandLogger(eventBus) {
* CommandInterceptor.call(this, eventBus);
*
* this.preExecute(function(event) {
* console.log('command pre-execute', event);
* });
* }
*
* inherits(CommandLogger, CommandInterceptor);
*
*/
function CommandInterceptor(eventBus) {
this._eventBus = eventBus;
}
CommandInterceptor.$inject = ['eventBus'];
function unwrapEvent(fn, that) {
return function (event) {
return fn.call(that || null, event.context, event.command, event);
};
}
/**
* Register an interceptor for a command execution
*
* @param {string|Array} [events] list of commands to register on
* @param {string} [hook] command hook, i.e. preExecute, executed to listen on
* @param {number} [priority] the priority on which to hook into the execution
* @param {Function} handlerFn interceptor to be invoked with (event)
* @param {boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
* listener instead
* @param {Object} [that] Pass context (`this`) to the handler function
*/
CommandInterceptor.prototype.on = function (events, hook, priority, handlerFn, unwrap, that) {
if ((0, _minDash.isFunction)(hook) || (0, _minDash.isNumber)(hook)) {
that = unwrap;
unwrap = handlerFn;
handlerFn = priority;
priority = hook;
hook = null;
}
if ((0, _minDash.isFunction)(priority)) {
that = unwrap;
unwrap = handlerFn;
handlerFn = priority;
priority = DEFAULT_PRIORITY;
}
if ((0, _minDash.isObject)(unwrap)) {
that = unwrap;
unwrap = false;
}
if (!(0, _minDash.isFunction)(handlerFn)) {
throw new Error('handlerFn must be a function');
}
if (!(0, _minDash.isArray)(events)) {
events = [events];
}
var eventBus = this._eventBus;
(0, _minDash.forEach)(events, function (event) {
// concat commandStack(.event)?(.hook)?
var fullEvent = ['commandStack', event, hook].filter(function (e) {
return e;
}).join('.');
eventBus.on(fullEvent, priority, unwrap ? unwrapEvent(handlerFn, that) : handlerFn, that);
});
};
var hooks = ['canExecute', 'preExecute', 'preExecuted', 'execute', 'executed', 'postExecute', 'postExecuted', 'revert', 'reverted'];
/*
* Install hook shortcuts
*
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
* which will in term forward to CommandInterceptor#on.
*/
(0, _minDash.forEach)(hooks, function (hook) {
/**
* {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
*
* A named hook for plugging into the command execution
*
* @param {string|Array} [events] list of commands to register on
* @param {number} [priority] the priority on which to hook into the execution
* @param {Function} handlerFn interceptor to be invoked with (event)
* @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
* listener instead
* @param {Object} [that] Pass context (`this`) to the handler function
*/
CommandInterceptor.prototype[hook] = function (events, priority, handlerFn, unwrap, that) {
if ((0, _minDash.isFunction)(events) || (0, _minDash.isNumber)(events)) {
that = unwrap;
unwrap = handlerFn;
handlerFn = priority;
priority = events;
events = null;
}
this.on(events, hook, priority, handlerFn, unwrap, that);
};
});
},{"min-dash":559}],147:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CommandStack;
var _minDash = require("min-dash");
/**
* A service that offers un- and redoable execution of commands.
*
* The command stack is responsible for executing modeling actions
* in a un- and redoable manner. To do this it delegates the actual
* command execution to {@link CommandHandler}s.
*
* Command handlers provide {@link CommandHandler#execute(ctx)} and
* {@link CommandHandler#revert(ctx)} methods to un- and redo a command
* identified by a command context.
*
*
* ## Life-Cycle events
*
* In the process the command stack fires a number of life-cycle events
* that other components to participate in the command execution.
*
* * preExecute
* * preExecuted
* * execute
* * executed
* * postExecute
* * postExecuted
* * revert
* * reverted
*
* A special event is used for validating, whether a command can be
* performed prior to its execution.
*
* * canExecute
*
* Each of the events is fired as `commandStack.{eventName}` and
* `commandStack.{commandName}.{eventName}`, respectively. This gives
* components fine grained control on where to hook into.
*
* The event object fired transports `command`, the name of the
* command and `context`, the command context.
*
*
* ## Creating Command Handlers
*
* Command handlers should provide the {@link CommandHandler#execute(ctx)}
* and {@link CommandHandler#revert(ctx)} methods to implement
* redoing and undoing of a command.
*
* A command handler _must_ ensure undo is performed properly in order
* not to break the undo chain. It must also return the shapes that
* got changed during the `execute` and `revert` operations.
*
* Command handlers may execute other modeling operations (and thus
* commands) in their `preExecute` and `postExecute` phases. The command
* stack will properly group all commands together into a logical unit
* that may be re- and undone atomically.
*
* Command handlers must not execute other commands from within their
* core implementation (`execute`, `revert`).
*
*
* ## Change Tracking
*
* During the execution of the CommandStack it will keep track of all
* elements that have been touched during the command's execution.
*
* At the end of the CommandStack execution it will notify interested
* components via an 'elements.changed' event with all the dirty
* elements.
*
* The event can be picked up by components that are interested in the fact
* that elements have been changed. One use case for this is updating
* their graphical representation after moving / resizing or deletion.
*
* @see CommandHandler
*
* @param {EventBus} eventBus
* @param {Injector} injector
*/
function CommandStack(eventBus, injector) {
/**
* A map of all registered command handlers.
*
* @type {Object}
*/
this._handlerMap = {};
/**
* A stack containing all re/undoable actions on the diagram
*
* @type {Array}
*/
this._stack = [];
/**
* The current index on the stack
*
* @type {number}
*/
this._stackIdx = -1;
/**
* Current active commandStack execution
*
* @type {Object}
*/
this._currentExecution = {
actions: [],
dirty: []
};
this._injector = injector;
this._eventBus = eventBus;
this._uid = 1;
eventBus.on(['diagram.destroy', 'diagram.clear'], function () {
this.clear(false);
}, this);
}
CommandStack.$inject = ['eventBus', 'injector'];
/**
* Execute a command
*
* @param {string} command the command to execute
* @param {Object} context the environment to execute the command in
*/
CommandStack.prototype.execute = function (command, context) {
if (!command) {
throw new Error('command required');
}
var action = {
command: command,
context: context
};
this._pushAction(action);
this._internalExecute(action);
this._popAction(action);
};
/**
* Ask whether a given command can be executed.
*
* Implementors may hook into the mechanism on two ways:
*
* * in event listeners:
*
* Users may prevent the execution via an event listener.
* It must prevent the default action for `commandStack.(.)canExecute` events.
*
* * in command handlers:
*
* If the method {@link CommandHandler#canExecute} is implemented in a handler
* it will be called to figure out whether the execution is allowed.
*
* @param {string} command the command to execute
* @param {Object} context the environment to execute the command in
*
* @return {boolean} true if the command can be executed
*/
CommandStack.prototype.canExecute = function (command, context) {
var action = {
command: command,
context: context
};
var handler = this._getHandler(command);
var result = this._fire(command, 'canExecute', action); // handler#canExecute will only be called if no listener
// decided on a result already
if (result === undefined) {
if (!handler) {
return false;
}
if (handler.canExecute) {
result = handler.canExecute(context);
}
}
return result;
};
/**
* Clear the command stack, erasing all undo / redo history
*/
CommandStack.prototype.clear = function (emit) {
this._stack.length = 0;
this._stackIdx = -1;
if (emit !== false) {
this._fire('changed');
}
};
/**
* Undo last command(s)
*/
CommandStack.prototype.undo = function () {
var action = this._getUndoAction(),
next;
if (action) {
this._pushAction(action);
while (action) {
this._internalUndo(action);
next = this._getUndoAction();
if (!next || next.id !== action.id) {
break;
}
action = next;
}
this._popAction();
}
};
/**
* Redo last command(s)
*/
CommandStack.prototype.redo = function () {
var action = this._getRedoAction(),
next;
if (action) {
this._pushAction(action);
while (action) {
this._internalExecute(action, true);
next = this._getRedoAction();
if (!next || next.id !== action.id) {
break;
}
action = next;
}
this._popAction();
}
};
/**
* Register a handler instance with the command stack
*
* @param {string} command
* @param {CommandHandler} handler
*/
CommandStack.prototype.register = function (command, handler) {
this._setHandler(command, handler);
};
/**
* Register a handler type with the command stack
* by instantiating it and injecting its dependencies.
*
* @param {string} command
* @param {Function} a constructor for a {@link CommandHandler}
*/
CommandStack.prototype.registerHandler = function (command, handlerCls) {
if (!command || !handlerCls) {
throw new Error('command and handlerCls must be defined');
}
var handler = this._injector.instantiate(handlerCls);
this.register(command, handler);
};
CommandStack.prototype.canUndo = function () {
return !!this._getUndoAction();
};
CommandStack.prototype.canRedo = function () {
return !!this._getRedoAction();
}; // stack access //////////////////////
CommandStack.prototype._getRedoAction = function () {
return this._stack[this._stackIdx + 1];
};
CommandStack.prototype._getUndoAction = function () {
return this._stack[this._stackIdx];
}; // internal functionality //////////////////////
CommandStack.prototype._internalUndo = function (action) {
var self = this;
var command = action.command,
context = action.context;
var handler = this._getHandler(command); // guard against illegal nested command stack invocations
this._atomicDo(function () {
self._fire(command, 'revert', action);
if (handler.revert) {
self._markDirty(handler.revert(context));
}
self._revertedAction(action);
self._fire(command, 'reverted', action);
});
};
CommandStack.prototype._fire = function (command, qualifier, event) {
if (arguments.length < 3) {
event = qualifier;
qualifier = null;
}
var names = qualifier ? [command + '.' + qualifier, qualifier] : [command],
i,
name,
result;
event = this._eventBus.createEvent(event);
for (i = 0; name = names[i]; i++) {
result = this._eventBus.fire('commandStack.' + name, event);
if (event.cancelBubble) {
break;
}
}
return result;
};
CommandStack.prototype._createId = function () {
return this._uid++;
};
CommandStack.prototype._atomicDo = function (fn) {
var execution = this._currentExecution;
execution.atomic = true;
try {
fn();
} finally {
execution.atomic = false;
}
};
CommandStack.prototype._internalExecute = function (action, redo) {
var self = this;
var command = action.command,
context = action.context;
var handler = this._getHandler(command);
if (!handler) {
throw new Error('no command handler registered for <' + command + '>');
}
this._pushAction(action);
if (!redo) {
this._fire(command, 'preExecute', action);
if (handler.preExecute) {
handler.preExecute(context);
}
this._fire(command, 'preExecuted', action);
} // guard against illegal nested command stack invocations
this._atomicDo(function () {
self._fire(command, 'execute', action);
if (handler.execute) {
// actual execute + mark return results as dirty
self._markDirty(handler.execute(context));
} // log to stack
self._executedAction(action, redo);
self._fire(command, 'executed', action);
});
if (!redo) {
this._fire(command, 'postExecute', action);
if (handler.postExecute) {
handler.postExecute(context);
}
this._fire(command, 'postExecuted', action);
}
this._popAction(action);
};
CommandStack.prototype._pushAction = function (action) {
var execution = this._currentExecution,
actions = execution.actions;
var baseAction = actions[0];
if (execution.atomic) {
throw new Error('illegal invocation in or phase (action: ' + action.command + ')');
}
if (!action.id) {
action.id = baseAction && baseAction.id || this._createId();
}
actions.push(action);
};
CommandStack.prototype._popAction = function () {
var execution = this._currentExecution,
actions = execution.actions,
dirty = execution.dirty;
actions.pop();
if (!actions.length) {
this._eventBus.fire('elements.changed', {
elements: (0, _minDash.uniqueBy)('id', dirty.reverse())
});
dirty.length = 0;
this._fire('changed');
}
};
CommandStack.prototype._markDirty = function (elements) {
var execution = this._currentExecution;
if (!elements) {
return;
}
elements = (0, _minDash.isArray)(elements) ? elements : [elements];
execution.dirty = execution.dirty.concat(elements);
};
CommandStack.prototype._executedAction = function (action, redo) {
var stackIdx = ++this._stackIdx;
if (!redo) {
this._stack.splice(stackIdx, this._stack.length, action);
}
};
CommandStack.prototype._revertedAction = function (action) {
this._stackIdx--;
};
CommandStack.prototype._getHandler = function (command) {
return this._handlerMap[command];
};
CommandStack.prototype._setHandler = function (command, handler) {
if (!command || !handler) {
throw new Error('command and handler required');
}
if (this._handlerMap[command]) {
throw new Error('overriding handler for command <' + command + '>');
}
this._handlerMap[command] = handler;
};
},{"min-dash":559}],148:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _CommandStack = _interopRequireDefault(require("./CommandStack"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
commandStack: ['type', _CommandStack.default]
};
exports.default = _default;
},{"./CommandStack":147}],149:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Canvas;
var _minDash = require("min-dash");
var _Collections = require("../util/Collections");
var _Elements = require("../util/Elements");
var _tinySvg = require("tiny-svg");
function round(number, resolution) {
return Math.round(number * resolution) / resolution;
}
function ensurePx(number) {
return (0, _minDash.isNumber)(number) ? number + 'px' : number;
}
/**
* Creates a HTML container element for a SVG element with
* the given configuration
*
* @param {Object} options
* @return {HTMLElement} the container element
*/
function createContainer(options) {
options = (0, _minDash.assign)({}, {
width: '100%',
height: '100%'
}, options);
var container = options.container || document.body; // create a
around the svg element with the respective size
// this way we can always get the correct container size
// (this is impossible for