chore: adjust features to new DI structure
Related to https://github.com/bpmn-io/bpmn-js/issues/1472
This commit is contained in:
parent
2b11d871cd
commit
769bcbeeff
|
@ -197,7 +197,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(businessObject)) {
|
if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
|
||||||
|
|
||||||
var childLanes = getChildLanes(element);
|
var childLanes = getChildLanes(element);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
getBusinessObject,
|
getBusinessObject,
|
||||||
|
getDi,
|
||||||
is
|
is
|
||||||
} from '../../util/ModelUtil';
|
} from '../../util/ModelUtil';
|
||||||
|
|
||||||
|
@ -45,23 +46,13 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
|
||||||
element = context.element;
|
element = context.element;
|
||||||
|
|
||||||
var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
|
var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
|
||||||
|
var di = descriptor.oldDi = getDi(element);
|
||||||
|
|
||||||
descriptor.type = element.type;
|
descriptor.type = element.type;
|
||||||
|
|
||||||
copyProperties(businessObject, descriptor, 'name');
|
copyProperties(businessObject, descriptor, 'name');
|
||||||
|
|
||||||
descriptor.di = {};
|
copyProperties(di, descriptor, 'isExpanded');
|
||||||
|
|
||||||
// colors will be set to DI
|
|
||||||
copyProperties(businessObject.di, descriptor.di, [
|
|
||||||
'fill',
|
|
||||||
'stroke',
|
|
||||||
'background-color',
|
|
||||||
'border-color',
|
|
||||||
'color'
|
|
||||||
]);
|
|
||||||
|
|
||||||
copyProperties(businessObject.di, descriptor, 'isExpanded');
|
|
||||||
|
|
||||||
if (isLabel(descriptor)) {
|
if (isLabel(descriptor)) {
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
@ -135,11 +126,13 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
|
||||||
var cache = context.cache,
|
var cache = context.cache,
|
||||||
descriptor = context.descriptor,
|
descriptor = context.descriptor,
|
||||||
oldBusinessObject = descriptor.oldBusinessObject,
|
oldBusinessObject = descriptor.oldBusinessObject,
|
||||||
newBusinessObject;
|
oldDi = descriptor.oldDi,
|
||||||
|
newBusinessObject, newDi;
|
||||||
|
|
||||||
// do NOT copy business object if external label
|
// do NOT copy business object if external label
|
||||||
if (isLabel(descriptor)) {
|
if (isLabel(descriptor)) {
|
||||||
descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
|
descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
|
||||||
|
descriptor.di = getDi(cache[ descriptor.labelTarget ]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -151,6 +144,13 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
|
||||||
newBusinessObject
|
newBusinessObject
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newDi = bpmnFactory.create(oldDi.$type);
|
||||||
|
|
||||||
|
descriptor.di = moddleCopy.copyElement(
|
||||||
|
oldDi,
|
||||||
|
newDi
|
||||||
|
);
|
||||||
|
|
||||||
// resolve references e.g. default sequence flow
|
// resolve references e.g. default sequence flow
|
||||||
resolveReferences(descriptor, cache);
|
resolveReferences(descriptor, cache);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { getDi } from '../../draw/BpmnRenderUtil';
|
import { getDi } from '../../draw/BpmnRenderUtil';
|
||||||
import { getBusinessObject } from '../../util/ModelUtil';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
filter,
|
filter,
|
||||||
|
@ -17,7 +16,7 @@ export default function BpmnDiOrdering(eventBus, canvas) {
|
||||||
|
|
||||||
function orderDi() {
|
function orderDi() {
|
||||||
var root = canvas.getRootElement(),
|
var root = canvas.getRootElement(),
|
||||||
rootDi = getBusinessObject(root).di,
|
rootDi = getDi(root),
|
||||||
elements,
|
elements,
|
||||||
diElements;
|
diElements;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
} from 'tiny-svg';
|
} from 'tiny-svg';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBusinessObject,
|
getDi,
|
||||||
is
|
is
|
||||||
} from '../../util/ModelUtil';
|
} from '../../util/ModelUtil';
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ LabelEditingPreview.$inject = [
|
||||||
// helpers ///////////////////
|
// helpers ///////////////////
|
||||||
|
|
||||||
function getStrokeColor(element, defaultColor) {
|
function getStrokeColor(element, defaultColor) {
|
||||||
var bo = getBusinessObject(element);
|
var di = getDi(element);
|
||||||
|
|
||||||
return bo.di.get('stroke') || defaultColor || 'black';
|
return di.get('stroke') || defaultColor || 'black';
|
||||||
}
|
}
|
|
@ -67,7 +67,8 @@ export default function UpdateLabelHandler(modeling, textRenderer) {
|
||||||
|
|
||||||
modeling.createLabel(element, labelCenter, {
|
modeling.createLabel(element, labelCenter, {
|
||||||
id: businessObject.id + '_label',
|
id: businessObject.id + '_label',
|
||||||
businessObject: businessObject
|
businessObject: businessObject,
|
||||||
|
di: element.di
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBusinessObject,
|
getBusinessObject,
|
||||||
|
getDi,
|
||||||
is
|
is
|
||||||
} from '../../util/ModelUtil';
|
} from '../../util/ModelUtil';
|
||||||
|
|
||||||
|
@ -307,8 +308,9 @@ BpmnUpdater.prototype.updateParent = function(element, oldParent) {
|
||||||
var parentShape = element.parent;
|
var parentShape = element.parent;
|
||||||
|
|
||||||
var businessObject = element.businessObject,
|
var businessObject = element.businessObject,
|
||||||
|
di = getDi(element),
|
||||||
parentBusinessObject = parentShape && parentShape.businessObject,
|
parentBusinessObject = parentShape && parentShape.businessObject,
|
||||||
parentDi = parentBusinessObject && parentBusinessObject.di;
|
parentDi = getDi(parentShape);
|
||||||
|
|
||||||
if (is(element, 'bpmn:FlowNode')) {
|
if (is(element, 'bpmn:FlowNode')) {
|
||||||
this.updateFlowNodeRefs(businessObject, parentBusinessObject, oldParent && oldParent.businessObject);
|
this.updateFlowNodeRefs(businessObject, parentBusinessObject, oldParent && oldParent.businessObject);
|
||||||
|
@ -336,13 +338,13 @@ BpmnUpdater.prototype.updateParent = function(element, oldParent) {
|
||||||
this.updateSemanticParent(businessObject.dataObjectRef, parentBusinessObject);
|
this.updateSemanticParent(businessObject.dataObjectRef, parentBusinessObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateDiParent(businessObject.di, parentDi);
|
this.updateDiParent(di, parentDi);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BpmnUpdater.prototype.updateBounds = function(shape) {
|
BpmnUpdater.prototype.updateBounds = function(shape) {
|
||||||
|
|
||||||
var di = shape.businessObject.di;
|
var di = getDi(shape);
|
||||||
|
|
||||||
var target = (shape instanceof Label) ? this._getLabel(di) : di;
|
var target = (shape instanceof Label) ? this._getLabel(di) : di;
|
||||||
|
|
||||||
|
@ -382,14 +384,17 @@ BpmnUpdater.prototype.updateFlowNodeRefs = function(businessObject, newContainme
|
||||||
|
|
||||||
|
|
||||||
// update existing sourceElement and targetElement di information
|
// update existing sourceElement and targetElement di information
|
||||||
BpmnUpdater.prototype.updateDiConnection = function(di, newSource, newTarget) {
|
BpmnUpdater.prototype.updateDiConnection = function(connection, newSource, newTarget) {
|
||||||
|
var connectionDi = getDi(connection),
|
||||||
|
newSourceDi = getDi(newSource),
|
||||||
|
newTargetDi = getDi(newTarget);
|
||||||
|
|
||||||
if (di.sourceElement && di.sourceElement.bpmnElement !== newSource) {
|
if (connectionDi.sourceElement && connectionDi.sourceElement.bpmnElement !== getBusinessObject(newSource)) {
|
||||||
di.sourceElement = newSource && newSource.di;
|
connectionDi.sourceElement = newSource && newSourceDi;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (di.targetElement && di.targetElement.bpmnElement !== newTarget) {
|
if (connectionDi.targetElement && connectionDi.targetElement.bpmnElement !== getBusinessObject(newTarget)) {
|
||||||
di.targetElement = newTarget && newTarget.di;
|
connectionDi.targetElement = newTarget && newTargetDi;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -405,6 +410,11 @@ BpmnUpdater.prototype.updateDiParent = function(di, parentDi) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cover the case where di.$parent === undefined and parentDi === null
|
||||||
|
if (!parentDi && !di.$parent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var planeElements = (parentDi || di.$parent).get('planeElement');
|
var planeElements = (parentDi || di.$parent).get('planeElement');
|
||||||
|
|
||||||
if (parentDi) {
|
if (parentDi) {
|
||||||
|
@ -614,69 +624,72 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent,
|
||||||
|
|
||||||
|
|
||||||
BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) {
|
BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) {
|
||||||
connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
|
var di = getDi(connection);
|
||||||
|
|
||||||
|
di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BpmnUpdater.prototype.updateConnection = function(context) {
|
BpmnUpdater.prototype.updateConnection = function(context) {
|
||||||
|
|
||||||
var connection = context.connection,
|
var connection = context.connection,
|
||||||
businessObject = getBusinessObject(connection),
|
businessObject = getBusinessObject(connection),
|
||||||
newSource = getBusinessObject(connection.source),
|
newSource = connection.source,
|
||||||
newTarget = getBusinessObject(connection.target),
|
newSourceBo = getBusinessObject(newSource),
|
||||||
|
newTarget = connection.target,
|
||||||
|
newTargetBo = getBusinessObject(connection.target),
|
||||||
visualParent;
|
visualParent;
|
||||||
|
|
||||||
if (!is(businessObject, 'bpmn:DataAssociation')) {
|
if (!is(businessObject, 'bpmn:DataAssociation')) {
|
||||||
|
|
||||||
var inverseSet = is(businessObject, 'bpmn:SequenceFlow');
|
var inverseSet = is(businessObject, 'bpmn:SequenceFlow');
|
||||||
|
|
||||||
if (businessObject.sourceRef !== newSource) {
|
if (businessObject.sourceRef !== newSourceBo) {
|
||||||
if (inverseSet) {
|
if (inverseSet) {
|
||||||
collectionRemove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject);
|
collectionRemove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject);
|
||||||
|
|
||||||
if (newSource && newSource.get('outgoing')) {
|
if (newSourceBo && newSourceBo.get('outgoing')) {
|
||||||
newSource.get('outgoing').push(businessObject);
|
newSourceBo.get('outgoing').push(businessObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
businessObject.sourceRef = newSource;
|
businessObject.sourceRef = newSourceBo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (businessObject.targetRef !== newTarget) {
|
if (businessObject.targetRef !== newTargetBo) {
|
||||||
if (inverseSet) {
|
if (inverseSet) {
|
||||||
collectionRemove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject);
|
collectionRemove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject);
|
||||||
|
|
||||||
if (newTarget && newTarget.get('incoming')) {
|
if (newTargetBo && newTargetBo.get('incoming')) {
|
||||||
newTarget.get('incoming').push(businessObject);
|
newTargetBo.get('incoming').push(businessObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
businessObject.targetRef = newTarget;
|
businessObject.targetRef = newTargetBo;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (is(businessObject, 'bpmn:DataInputAssociation')) {
|
if (is(businessObject, 'bpmn:DataInputAssociation')) {
|
||||||
|
|
||||||
// handle obnoxious isMsome sourceRef
|
// handle obnoxious isMsome sourceRef
|
||||||
businessObject.get('sourceRef')[0] = newSource;
|
businessObject.get('sourceRef')[0] = newSourceBo;
|
||||||
|
|
||||||
visualParent = context.parent || context.newParent || newTarget;
|
visualParent = context.parent || context.newParent || newTargetBo;
|
||||||
|
|
||||||
this.updateSemanticParent(businessObject, newTarget, visualParent);
|
this.updateSemanticParent(businessObject, newTargetBo, visualParent);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (is(businessObject, 'bpmn:DataOutputAssociation')) {
|
if (is(businessObject, 'bpmn:DataOutputAssociation')) {
|
||||||
visualParent = context.parent || context.newParent || newSource;
|
visualParent = context.parent || context.newParent || newSourceBo;
|
||||||
|
|
||||||
this.updateSemanticParent(businessObject, newSource, visualParent);
|
this.updateSemanticParent(businessObject, newSourceBo, visualParent);
|
||||||
|
|
||||||
// targetRef = new target
|
// targetRef = new target
|
||||||
businessObject.targetRef = newTarget;
|
businessObject.targetRef = newTargetBo;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateConnectionWaypoints(connection);
|
this.updateConnectionWaypoints(connection);
|
||||||
|
|
||||||
this.updateDiConnection(businessObject.di, newSource, newTarget);
|
this.updateDiConnection(connection, newSource, newTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,8 @@ ElementFactory.prototype.create = function(elementType, attrs) {
|
||||||
// we assume their businessObjects have already been created
|
// we assume their businessObjects have already been created
|
||||||
// and wired via attrs
|
// and wired via attrs
|
||||||
if (elementType === 'label') {
|
if (elementType === 'label') {
|
||||||
return this.baseCreate(elementType, assign({ type: 'label' }, DEFAULT_LABEL_SIZE, attrs));
|
var di = attrs.di || this._bpmnFactory.createDiLabel();
|
||||||
|
return this.baseCreate(elementType, assign({ type: 'label', di: di }, DEFAULT_LABEL_SIZE, attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.createBpmnElement(elementType, attrs);
|
return this.createBpmnElement(elementType, attrs);
|
||||||
|
@ -58,7 +59,8 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
|
|
||||||
attrs = attrs || {};
|
attrs = attrs || {};
|
||||||
|
|
||||||
var businessObject = attrs.businessObject;
|
var businessObject = attrs.businessObject,
|
||||||
|
di = attrs.di;
|
||||||
|
|
||||||
if (!businessObject) {
|
if (!businessObject) {
|
||||||
if (!attrs.type) {
|
if (!attrs.type) {
|
||||||
|
@ -68,18 +70,18 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
businessObject = this._bpmnFactory.create(attrs.type);
|
businessObject = this._bpmnFactory.create(attrs.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!businessObject.di) {
|
if (!di) {
|
||||||
if (elementType === 'root') {
|
if (elementType === 'root') {
|
||||||
businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], {
|
di = this._bpmnFactory.createDiPlane(businessObject, [], {
|
||||||
id: businessObject.id + '_di'
|
id: businessObject.id + '_di'
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
if (elementType === 'connection') {
|
if (elementType === 'connection') {
|
||||||
businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], {
|
di = this._bpmnFactory.createDiEdge(businessObject, [], {
|
||||||
id: businessObject.id + '_di'
|
id: businessObject.id + '_di'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, {
|
di = this._bpmnFactory.createDiShape(businessObject, {}, {
|
||||||
id: businessObject.id + '_di'
|
id: businessObject.id + '_di'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -91,12 +93,6 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
}, attrs);
|
}, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.di) {
|
|
||||||
assign(businessObject.di, attrs.di);
|
|
||||||
|
|
||||||
delete attrs.di;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyAttributes(businessObject, attrs, [
|
applyAttributes(businessObject, attrs, [
|
||||||
'processRef',
|
'processRef',
|
||||||
'isInterrupting',
|
'isInterrupting',
|
||||||
|
@ -105,11 +101,11 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (attrs.isExpanded) {
|
if (attrs.isExpanded) {
|
||||||
applyAttribute(businessObject.di, attrs, 'isExpanded');
|
applyAttribute(di, attrs, 'isExpanded');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is(businessObject, 'bpmn:ExclusiveGateway')) {
|
if (is(businessObject, 'bpmn:ExclusiveGateway')) {
|
||||||
businessObject.di.isMarkerVisible = true;
|
di.isMarkerVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventDefinitions,
|
var eventDefinitions,
|
||||||
|
@ -135,6 +131,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
|
|
||||||
attrs = assign({
|
attrs = assign({
|
||||||
businessObject: businessObject,
|
businessObject: businessObject,
|
||||||
|
di: di,
|
||||||
id: businessObject.id
|
id: businessObject.id
|
||||||
}, size, attrs);
|
}, size, attrs);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBusinessObject,
|
getBusinessObject,
|
||||||
|
getDi,
|
||||||
is
|
is
|
||||||
} from '../../../util/ModelUtil';
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
|
@ -45,8 +46,9 @@ export default function DataStoreBehavior(
|
||||||
|
|
||||||
commandStack.execute('dataStore.updateContainment', {
|
commandStack.execute('dataStore.updateContainment', {
|
||||||
dataStoreBo: dataStoreBo,
|
dataStoreBo: dataStoreBo,
|
||||||
|
dataStoreDi: getDi(dataStore),
|
||||||
newSemanticParent: newDataStoreParentBo.processRef || newDataStoreParentBo,
|
newSemanticParent: newDataStoreParentBo.processRef || newDataStoreParentBo,
|
||||||
newDiParent: newDataStoreParentBo.di
|
newDiParent: getDi(newDataStoreParent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ import inherits from 'inherits';
|
||||||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBusinessObject
|
getBusinessObject,
|
||||||
|
getDi
|
||||||
} from '../../../util/ModelUtil';
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -26,12 +27,14 @@ export default function IsHorizontalFix(eventBus) {
|
||||||
];
|
];
|
||||||
|
|
||||||
this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], function(event) {
|
this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], function(event) {
|
||||||
var bo = getBusinessObject(event.context.shape);
|
var shape = event.context.shape,
|
||||||
|
bo = getBusinessObject(shape),
|
||||||
|
di = getDi(shape);
|
||||||
|
|
||||||
if (isAny(bo, elementTypesToUpdate) && !bo.di.get('isHorizontal')) {
|
if (isAny(bo, elementTypesToUpdate) && !di.get('isHorizontal')) {
|
||||||
|
|
||||||
// set attribute directly to avoid modeling#updateProperty side effects
|
// set attribute directly to avoid modeling#updateProperty side effects
|
||||||
bo.di.set('isHorizontal', true);
|
di.set('isHorizontal', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ import inherits from 'inherits';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
is,
|
is,
|
||||||
getBusinessObject
|
getBusinessObject,
|
||||||
|
getDi
|
||||||
} from '../../../util/ModelUtil';
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -153,27 +154,27 @@ export default function LabelBehavior(
|
||||||
|
|
||||||
var context = event.context,
|
var context = event.context,
|
||||||
element = context.shape,
|
element = context.shape,
|
||||||
businessObject,
|
labelTarget = context.labelTarget,
|
||||||
di;
|
di;
|
||||||
|
|
||||||
// we want to trigger on real labels only
|
// we want to trigger on real labels only
|
||||||
if (!element.labelTarget) {
|
if (!labelTarget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want to trigger on BPMN elements only
|
// we want to trigger on BPMN elements only
|
||||||
if (!is(element.labelTarget || element, 'bpmn:BaseElement')) {
|
if (!is(labelTarget, 'bpmn:BaseElement')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
businessObject = element.businessObject,
|
di = getDi(labelTarget);
|
||||||
di = businessObject.di;
|
|
||||||
|
|
||||||
|
|
||||||
if (!di.label) {
|
if (!di.label) {
|
||||||
di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
|
di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
|
||||||
bounds: bpmnFactory.create('dc:Bounds')
|
bounds: bpmnFactory.create('dc:Bounds')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
element.di = di;
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(di.label.bounds, {
|
assign(di.label.bounds, {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import inherits from 'inherits';
|
||||||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBusinessObject,
|
getDi,
|
||||||
is
|
is
|
||||||
} from '../../../util/ModelUtil';
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
|
@ -85,11 +85,11 @@ export default function ToggleElementCollapseBehaviour(
|
||||||
hideEmptyLabels(shape.children);
|
hideEmptyLabels(shape.children);
|
||||||
|
|
||||||
// remove collapsed marker
|
// remove collapsed marker
|
||||||
getBusinessObject(shape).di.isExpanded = true;
|
getDi(shape).isExpanded = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// place collapsed marker
|
// place collapsed marker
|
||||||
getBusinessObject(shape).di.isExpanded = false;
|
getDi(shape).isExpanded = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,10 +101,10 @@ export default function ToggleElementCollapseBehaviour(
|
||||||
|
|
||||||
// revert removing/placing collapsed marker
|
// revert removing/placing collapsed marker
|
||||||
if (!shape.collapsed) {
|
if (!shape.collapsed) {
|
||||||
getBusinessObject(shape).di.isExpanded = true;
|
getDi(shape).isExpanded = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
getBusinessObject(shape).di.isExpanded = false;
|
getDi(shape).isExpanded = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ import {
|
||||||
remove as collectionRemove
|
remove as collectionRemove
|
||||||
} from 'diagram-js/lib/util/Collections';
|
} from 'diagram-js/lib/util/Collections';
|
||||||
|
|
||||||
|
import { getDi } from '../../../util/ModelUtil';
|
||||||
|
|
||||||
|
|
||||||
export default function UpdateCanvasRootHandler(canvas, modeling) {
|
export default function UpdateCanvasRootHandler(canvas, modeling) {
|
||||||
this._canvas = canvas;
|
this._canvas = canvas;
|
||||||
|
@ -24,7 +26,7 @@ UpdateCanvasRootHandler.prototype.execute = function(context) {
|
||||||
oldRoot = canvas.getRootElement(),
|
oldRoot = canvas.getRootElement(),
|
||||||
oldRootBusinessObject = oldRoot.businessObject,
|
oldRootBusinessObject = oldRoot.businessObject,
|
||||||
bpmnDefinitions = oldRootBusinessObject.$parent,
|
bpmnDefinitions = oldRootBusinessObject.$parent,
|
||||||
diPlane = oldRootBusinessObject.di;
|
diPlane = getDi(oldRoot);
|
||||||
|
|
||||||
// (1) replace process old <> new root
|
// (1) replace process old <> new root
|
||||||
canvas.setRootElement(newRoot, true);
|
canvas.setRootElement(newRoot, true);
|
||||||
|
@ -37,10 +39,10 @@ UpdateCanvasRootHandler.prototype.execute = function(context) {
|
||||||
oldRootBusinessObject.$parent = null;
|
oldRootBusinessObject.$parent = null;
|
||||||
|
|
||||||
// (3) wire di
|
// (3) wire di
|
||||||
oldRootBusinessObject.di = null;
|
oldRoot.di = null;
|
||||||
|
|
||||||
diPlane.bpmnElement = newRootBusinessObject;
|
diPlane.bpmnElement = newRootBusinessObject;
|
||||||
newRootBusinessObject.di = diPlane;
|
newRoot.di = diPlane;
|
||||||
|
|
||||||
context.oldRoot = oldRoot;
|
context.oldRoot = oldRoot;
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ UpdateCanvasRootHandler.prototype.revert = function(context) {
|
||||||
oldRoot = context.oldRoot,
|
oldRoot = context.oldRoot,
|
||||||
oldRootBusinessObject = oldRoot.businessObject,
|
oldRootBusinessObject = oldRoot.businessObject,
|
||||||
bpmnDefinitions = newRootBusinessObject.$parent,
|
bpmnDefinitions = newRootBusinessObject.$parent,
|
||||||
diPlane = newRootBusinessObject.di;
|
diPlane = getDi(newRoot);
|
||||||
|
|
||||||
// (1) replace process old <> new root
|
// (1) replace process old <> new root
|
||||||
canvas.setRootElement(oldRoot, true);
|
canvas.setRootElement(oldRoot, true);
|
||||||
|
@ -71,10 +73,10 @@ UpdateCanvasRootHandler.prototype.revert = function(context) {
|
||||||
oldRootBusinessObject.$parent = bpmnDefinitions;
|
oldRootBusinessObject.$parent = bpmnDefinitions;
|
||||||
|
|
||||||
// (3) wire di
|
// (3) wire di
|
||||||
newRootBusinessObject.di = null;
|
newRoot.di = null;
|
||||||
|
|
||||||
diPlane.bpmnElement = oldRootBusinessObject;
|
diPlane.bpmnElement = oldRootBusinessObject;
|
||||||
oldRootBusinessObject.di = diPlane;
|
oldRoot.di = diPlane;
|
||||||
|
|
||||||
// TODO(nikku): return changed elements?
|
// TODO(nikku): return changed elements?
|
||||||
// return [ newRoot, oldRoot ];
|
// return [ newRoot, oldRoot ];
|
||||||
|
|
|
@ -6,7 +6,8 @@ import {
|
||||||
} from 'min-dash';
|
} from 'min-dash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBusinessObject
|
getBusinessObject,
|
||||||
|
getDi
|
||||||
} from '../../../util/ModelUtil';
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
var DEFAULT_FLOW = 'default',
|
var DEFAULT_FLOW = 'default',
|
||||||
|
@ -74,7 +75,7 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
|
||||||
|
|
||||||
var businessObject = element.businessObject,
|
var businessObject = element.businessObject,
|
||||||
properties = unwrapBusinessObjects(context.properties),
|
properties = unwrapBusinessObjects(context.properties),
|
||||||
oldProperties = context.oldProperties || getProperties(businessObject, properties);
|
oldProperties = context.oldProperties || getProperties(element, properties);
|
||||||
|
|
||||||
if (isIdChange(properties, businessObject)) {
|
if (isIdChange(properties, businessObject)) {
|
||||||
ids.unclaim(businessObject[ID]);
|
ids.unclaim(businessObject[ID]);
|
||||||
|
@ -97,7 +98,7 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update properties
|
// update properties
|
||||||
setProperties(businessObject, properties);
|
setProperties(element, properties);
|
||||||
|
|
||||||
// store old values
|
// store old values
|
||||||
context.oldProperties = oldProperties;
|
context.oldProperties = oldProperties;
|
||||||
|
@ -142,7 +143,7 @@ UpdatePropertiesHandler.prototype.revert = function(context) {
|
||||||
ids = this._moddle.ids;
|
ids = this._moddle.ids;
|
||||||
|
|
||||||
// update properties
|
// update properties
|
||||||
setProperties(businessObject, oldProperties);
|
setProperties(element, oldProperties);
|
||||||
|
|
||||||
if (isIdChange(properties, businessObject)) {
|
if (isIdChange(properties, businessObject)) {
|
||||||
ids.unclaim(properties[ID]);
|
ids.unclaim(properties[ID]);
|
||||||
|
@ -161,16 +162,19 @@ function isIdChange(properties, businessObject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getProperties(businessObject, properties) {
|
function getProperties(element, properties) {
|
||||||
var propertyNames = keys(properties);
|
var propertyNames = keys(properties),
|
||||||
|
businessObject = element.businessObject,
|
||||||
|
di = getDi(element);
|
||||||
|
|
||||||
return reduce(propertyNames, function(result, key) {
|
return reduce(propertyNames, function(result, key) {
|
||||||
|
|
||||||
// handle DI separately
|
// handle DI separately
|
||||||
if (key !== DI) {
|
if (key !== DI) {
|
||||||
result[key] = businessObject.get(key);
|
result[key] = businessObject.get(key);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result[key] = getDiProperties(businessObject.di, keys(properties.di));
|
result[key] = getDiProperties(di, keys(properties.di));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -180,23 +184,26 @@ function getProperties(businessObject, properties) {
|
||||||
|
|
||||||
function getDiProperties(di, propertyNames) {
|
function getDiProperties(di, propertyNames) {
|
||||||
return reduce(propertyNames, function(result, key) {
|
return reduce(propertyNames, function(result, key) {
|
||||||
result[key] = di.get(key);
|
result[key] = di && di.get(key);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setProperties(businessObject, properties) {
|
function setProperties(element, properties) {
|
||||||
|
var businessObject = element.businessObject,
|
||||||
|
di = getDi(element);
|
||||||
|
|
||||||
forEach(properties, function(value, key) {
|
forEach(properties, function(value, key) {
|
||||||
|
|
||||||
if (key !== DI) {
|
if (key !== DI) {
|
||||||
businessObject.set(key, value);
|
businessObject.set(key, value);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// only update, if businessObject.di exists
|
// only update, if di exists
|
||||||
if (businessObject.di) {
|
if (di) {
|
||||||
setDiProperties(businessObject.di, value);
|
setDiProperties(di, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,21 +7,23 @@ UpdateSemanticParentHandler.$inject = [ 'bpmnUpdater' ];
|
||||||
|
|
||||||
UpdateSemanticParentHandler.prototype.execute = function(context) {
|
UpdateSemanticParentHandler.prototype.execute = function(context) {
|
||||||
var dataStoreBo = context.dataStoreBo,
|
var dataStoreBo = context.dataStoreBo,
|
||||||
|
dataStoreDi = context.dataStoreDi,
|
||||||
newSemanticParent = context.newSemanticParent,
|
newSemanticParent = context.newSemanticParent,
|
||||||
newDiParent = context.newDiParent;
|
newDiParent = context.newDiParent;
|
||||||
|
|
||||||
context.oldSemanticParent = dataStoreBo.$parent;
|
context.oldSemanticParent = dataStoreBo.$parent;
|
||||||
context.oldDiParent = dataStoreBo.di.$parent;
|
context.oldDiParent = dataStoreDi.$parent;
|
||||||
|
|
||||||
// update semantic parent
|
// update semantic parent
|
||||||
this._bpmnUpdater.updateSemanticParent(dataStoreBo, newSemanticParent);
|
this._bpmnUpdater.updateSemanticParent(dataStoreBo, newSemanticParent);
|
||||||
|
|
||||||
// update DI parent
|
// update DI parent
|
||||||
this._bpmnUpdater.updateDiParent(dataStoreBo.di, newDiParent);
|
this._bpmnUpdater.updateDiParent(dataStoreDi, newDiParent);
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateSemanticParentHandler.prototype.revert = function(context) {
|
UpdateSemanticParentHandler.prototype.revert = function(context) {
|
||||||
var dataStoreBo = context.dataStoreBo,
|
var dataStoreBo = context.dataStoreBo,
|
||||||
|
dataStoreDi = context.dataStoreDi,
|
||||||
oldSemanticParent = context.oldSemanticParent,
|
oldSemanticParent = context.oldSemanticParent,
|
||||||
oldDiParent = context.oldDiParent;
|
oldDiParent = context.oldDiParent;
|
||||||
|
|
||||||
|
@ -29,6 +31,6 @@ UpdateSemanticParentHandler.prototype.revert = function(context) {
|
||||||
this._bpmnUpdater.updateSemanticParent(dataStoreBo, oldSemanticParent);
|
this._bpmnUpdater.updateSemanticParent(dataStoreBo, oldSemanticParent);
|
||||||
|
|
||||||
// update DI parent
|
// update DI parent
|
||||||
this._bpmnUpdater.updateDiParent(dataStoreBo.di, oldDiParent);
|
this._bpmnUpdater.updateDiParent(dataStoreDi, oldDiParent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
assign
|
assign
|
||||||
} from 'min-dash';
|
} from 'min-dash';
|
||||||
|
import { getDi } from '../../util/ModelUtil';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +53,8 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
||||||
var shape = elementFactory.createShape(assign({ type: type }, options));
|
var shape = elementFactory.createShape(assign({ type: type }, options));
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
shape.businessObject.di.isExpanded = options.isExpanded;
|
var di = getDi(shape);
|
||||||
|
di.isExpanded = options.isExpanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
create.start(event, shape);
|
create.start(event, shape);
|
||||||
|
|
|
@ -99,7 +99,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
||||||
if (is(businessObject, 'bpmn:Participant')) {
|
if (is(businessObject, 'bpmn:Participant')) {
|
||||||
|
|
||||||
entries = filter(replaceOptions.PARTICIPANT, function(entry) {
|
entries = filter(replaceOptions.PARTICIPANT, function(entry) {
|
||||||
return isExpanded(businessObject) !== entry.target.isExpanded;
|
return isExpanded(element) !== entry.target.isExpanded;
|
||||||
});
|
});
|
||||||
|
|
||||||
return this._createEntries(element, entries);
|
return this._createEntries(element, entries);
|
||||||
|
@ -195,7 +195,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// expanded event sub processes
|
// expanded event sub processes
|
||||||
if (isEventSubProcess(businessObject) && isExpanded(businessObject)) {
|
if (isEventSubProcess(businessObject) && isExpanded(element)) {
|
||||||
|
|
||||||
entries = filter(replaceOptions.EVENT_SUB_PROCESS, differentType);
|
entries = filter(replaceOptions.EVENT_SUB_PROCESS, differentType);
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// expanded sub processes
|
// expanded sub processes
|
||||||
if (is(businessObject, 'bpmn:SubProcess') && isExpanded(businessObject)) {
|
if (is(businessObject, 'bpmn:SubProcess') && isExpanded(element)) {
|
||||||
|
|
||||||
entries = filter(replaceOptions.SUBPROCESS_EXPANDED, differentType);
|
entries = filter(replaceOptions.SUBPROCESS_EXPANDED, differentType);
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// collapsed ad hoc sub processes
|
// collapsed ad hoc sub processes
|
||||||
if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(businessObject)) {
|
if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(element)) {
|
||||||
|
|
||||||
entries = filter(replaceOptions.TASK, function(entry) {
|
entries = filter(replaceOptions.TASK, function(entry) {
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
||||||
entries = filter(replaceOptions.TASK, differentType);
|
entries = filter(replaceOptions.TASK, differentType);
|
||||||
|
|
||||||
// collapsed SubProcess can not be replaced with itself
|
// collapsed SubProcess can not be replaced with itself
|
||||||
if (is(businessObject, 'bpmn:SubProcess') && !isExpanded(businessObject)) {
|
if (is(businessObject, 'bpmn:SubProcess') && !isExpanded(element)) {
|
||||||
entries = filter(entries, function(entry) {
|
entries = filter(entries, function(entry) {
|
||||||
return entry.label !== 'Sub Process (collapsed)';
|
return entry.label !== 'Sub Process (collapsed)';
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ export function isDifferentType(element) {
|
||||||
|
|
||||||
var isExpandedEqual = (
|
var isExpandedEqual = (
|
||||||
target.isExpanded === undefined ||
|
target.isExpanded === undefined ||
|
||||||
target.isExpanded === isExpanded(businessObject)
|
target.isExpanded === isExpanded(element)
|
||||||
);
|
);
|
||||||
|
|
||||||
return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;
|
return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;
|
||||||
|
|
|
@ -2,15 +2,13 @@ import {
|
||||||
pick,
|
pick,
|
||||||
assign,
|
assign,
|
||||||
filter,
|
filter,
|
||||||
forEach,
|
|
||||||
isArray,
|
|
||||||
isUndefined,
|
|
||||||
has
|
has
|
||||||
} from 'min-dash';
|
} from 'min-dash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
is,
|
is,
|
||||||
getBusinessObject
|
getBusinessObject,
|
||||||
|
getDi
|
||||||
} from '../../util/ModelUtil';
|
} from '../../util/ModelUtil';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -24,17 +22,6 @@ import {
|
||||||
|
|
||||||
import { getPropertyNames } from '../copy-paste/ModdleCopy';
|
import { getPropertyNames } from '../copy-paste/ModdleCopy';
|
||||||
|
|
||||||
function copyProperties(source, target, properties) {
|
|
||||||
if (!isArray(properties)) {
|
|
||||||
properties = [ properties ];
|
|
||||||
}
|
|
||||||
|
|
||||||
forEach(properties, function(property) {
|
|
||||||
if (!isUndefined(source[property])) {
|
|
||||||
target[property] = source[property];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var CUSTOM_PROPERTIES = [
|
var CUSTOM_PROPERTIES = [
|
||||||
'cancelActivity',
|
'cancelActivity',
|
||||||
|
@ -121,7 +108,8 @@ export default function BpmnReplace(
|
||||||
|
|
||||||
var newElement = {
|
var newElement = {
|
||||||
type: type,
|
type: type,
|
||||||
businessObject: newBusinessObject
|
businessObject: newBusinessObject,
|
||||||
|
di: getDi(element)
|
||||||
};
|
};
|
||||||
|
|
||||||
var elementProps = getPropertyNames(oldBusinessObject.$descriptor),
|
var elementProps = getPropertyNames(oldBusinessObject.$descriptor),
|
||||||
|
@ -183,7 +171,7 @@ export default function BpmnReplace(
|
||||||
if (isSubProcess(oldBusinessObject)) {
|
if (isSubProcess(oldBusinessObject)) {
|
||||||
|
|
||||||
// no toggeling, so keep old state
|
// no toggeling, so keep old state
|
||||||
newElement.isExpanded = isExpanded(oldBusinessObject);
|
newElement.isExpanded = isExpanded(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// else if property is explicitly set, use it
|
// else if property is explicitly set, use it
|
||||||
|
@ -194,7 +182,7 @@ export default function BpmnReplace(
|
||||||
// TODO: need also to respect min/max Size
|
// TODO: need also to respect min/max Size
|
||||||
// copy size, from an expanded subprocess to an expanded alternative subprocess
|
// copy size, from an expanded subprocess to an expanded alternative subprocess
|
||||||
// except bpmn:Task, because Task is always expanded
|
// except bpmn:Task, because Task is always expanded
|
||||||
if ((isExpanded(oldBusinessObject) && !is(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) {
|
if ((isExpanded(element) && !is(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) {
|
||||||
newElement.width = element.width;
|
newElement.width = element.width;
|
||||||
newElement.height = element.height;
|
newElement.height = element.height;
|
||||||
}
|
}
|
||||||
|
@ -262,16 +250,6 @@ export default function BpmnReplace(
|
||||||
newElement.x = element.x + (element.width - newElement.width) / 2;
|
newElement.x = element.x + (element.width - newElement.width) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
newElement.di = {};
|
|
||||||
|
|
||||||
// colors will be set to DI
|
|
||||||
copyProperties(oldBusinessObject.di, newElement.di, [
|
|
||||||
'fill',
|
|
||||||
'stroke',
|
|
||||||
'background-color',
|
|
||||||
'border-color',
|
|
||||||
'color'
|
|
||||||
]);
|
|
||||||
|
|
||||||
newElement = replace.replaceElement(element, newElement, hints);
|
newElement = replace.replaceElement(element, newElement, hints);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue