2018-04-02 19:01:53 +00:00
|
|
|
import inherits from 'inherits';
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import { is } from '../../../util/ModelUtil';
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BPMN specific create boundary event behavior
|
|
|
|
*/
|
2018-04-02 19:01:53 +00:00
|
|
|
export default function CreateBoundaryEventBehavior(
|
|
|
|
eventBus, modeling, elementFactory,
|
|
|
|
bpmnFactory) {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* replace intermediate event with boundary event when
|
|
|
|
* attaching it to a shape
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.preExecute('shape.create', function(context) {
|
|
|
|
var shape = context.shape,
|
|
|
|
host = context.host,
|
|
|
|
businessObject,
|
|
|
|
boundaryEvent;
|
|
|
|
|
|
|
|
var attrs = {
|
|
|
|
cancelActivity: true
|
|
|
|
};
|
|
|
|
|
|
|
|
if (host && is(shape, 'bpmn:IntermediateThrowEvent')) {
|
|
|
|
attrs.attachedToRef = host.businessObject;
|
|
|
|
|
|
|
|
businessObject = bpmnFactory.create('bpmn:BoundaryEvent', attrs);
|
|
|
|
|
|
|
|
boundaryEvent = {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
businessObject: businessObject
|
|
|
|
};
|
|
|
|
|
|
|
|
context.shape = elementFactory.createShape(boundaryEvent);
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
CreateBoundaryEventBehavior.$inject = [
|
|
|
|
'eventBus',
|
|
|
|
'modeling',
|
|
|
|
'elementFactory',
|
|
|
|
'bpmnFactory'
|
|
|
|
];
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
inherits(CreateBoundaryEventBehavior, CommandInterceptor);
|