CreateDataObjectBehavior.js 923 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import inherits from 'inherits';
  2. import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
  3. import { is } from '../../../util/ModelUtil';
  4. /**
  5. * BPMN specific create data object behavior
  6. */
  7. export default function CreateDataObjectBehavior(eventBus, bpmnFactory, moddle) {
  8. CommandInterceptor.call(this, eventBus);
  9. this.preExecute('shape.create', function(event) {
  10. var context = event.context,
  11. shape = context.shape;
  12. if (is(shape, 'bpmn:DataObjectReference') && shape.type !== 'label') {
  13. // create a DataObject every time a DataObjectReference is created
  14. var dataObject = bpmnFactory.create('bpmn:DataObject');
  15. // set the reference to the DataObject
  16. shape.businessObject.dataObjectRef = dataObject;
  17. }
  18. });
  19. }
  20. CreateDataObjectBehavior.$inject = [
  21. 'eventBus',
  22. 'bpmnFactory',
  23. 'moddle'
  24. ];
  25. inherits(CreateDataObjectBehavior, CommandInterceptor);