Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// insert sequence flows behind other flow nodes (cf. #727)
let parentIndex;
if (is(semantic, 'bpmn:SequenceFlow')) {
parentIndex = 0;
}
this._canvas.addConnection(element, parentShape, parentIndex);
} else {
throw new Error(this._translate('unknown di {di} for element {semantic}', {
di: elementToString(di),
semantic: elementToString(semantic)
}));
}
// (optional) external LABEL
if (isLabelExternal(semantic) && semantic.name) {
this._addLabel(semantic, element);
}
} else {
if (isMessageFlow) {
/*
* Messages are attached to a participant band. They are separate shapes
* but move with the band. They do not have an underlying DI element.
* If no message is attached to the message flow, we first have to create one.
*/
const choreo = this._canvas.getRootElement().businessObject;
const definitions = choreo.$parent;
let message = semantic.messageRef;
if (!message) {
message = this._moddle.create('bpmn:Message');
message.id = this._moddle.ids.nextPrefixed('Message_', message);
definitions.rootElements.unshift(message);
width: width,
height: bbox.height + paddingTop + paddingBottom,
x: mid.x - width / 2,
y: bbox.y - paddingTop
});
assign(style, {
fontSize: externalFontSize + 'px',
lineHeight: externalLineHeight,
paddingTop: paddingTop + 'px',
paddingBottom: paddingBottom + 'px'
});
}
// external label not yet created
if (isLabelExternal(target)
&& !hasExternalLabel(target)
&& !isLabel(target)) {
let externalLabelMid = getExternalLabelMid(element);
let absoluteBBox = canvas.getAbsoluteBBox({
x: externalLabelMid.x,
y: externalLabelMid.y,
width: 0,
height: 0
});
let height = externalFontSize + paddingTop + paddingBottom;
assign(bounds, {
width: width,
RestoreFromCacheVisitor.prototype.visit = function(element, parentShape) {
const shape = this.getShape(element, parentShape);
if (!parentShape) {
this._canvas.setRootElement(shape, true);
} else {
if (is(shape, 'bpmn:SequenceFlow') || is(shape, 'bpmn:Association')) {
this._canvas.addConnection(shape, parentShape);
} else {
this._canvas.addShape(shape, parentShape);
}
// add label if necessary
if (isLabelExternal(element) && element.name) {
const label = this.getLabel(element);
if (label) {
this._canvas.addShape(label, parentShape);
}
}
}
return shape;
};
this.preExecute = function(ctx) {
var element = ctx.element,
businessObject = element.businessObject,
newLabel = ctx.newLabel,
newNumber=ctx.newNumber;
if (!isLabel(element)
&& isLabelExternal(element)
&& !hasExternalLabel(element)
&& (newLabel !== '' || newNumber!=='')) {
// create label
var paddingTop = 7;
var labelCenter = getExternalLabelMid(element);
labelCenter = {
x: labelCenter.x,
y: labelCenter.y + paddingTop
};
modeling.createLabel(element, labelCenter, {
id: businessObject.id + '_label',
businessObject: businessObject
return;
}
let context = {
text: text
};
// bounds
let bounds = this.getEditingBBox(element);
assign(context, bounds);
let options = {};
// external labels
if (isLabelExternal(element)) {
assign(options, {
autoResize: true
});
}
// text annotations
if (is(element, TEXTANNOTATION)) {
assign(options, {
resizable: true,
autoResize: true
});
}
assign(context, {
options: options
});
this.postExecute = function(ctx) {
var element = ctx.element,
label = element.label || element,
newLabel = ctx.newLabel,
newBounds = ctx.newBounds;
if (isLabel(label) && newLabel.trim() === '') {
modeling.removeShape(label);
return;
}
// ignore internal labels for elements except text annotations
if (!isLabelExternal(element) && !is(element, TEXTANNOTATION)) {
return;
}
var bo = getBusinessObject(label);
var text = bo.name || bo.text;
// don't resize without text
if (!text) {
return;
}
// resize element based on label _or_ pre-defined bounds
if (typeof newBounds === 'undefined') {
newBounds = textRenderer.getLayoutedBounds(label, text);
}