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ygbYCeoTlBG0AksR8QgAbGNl7xEAu+9O84Dz/OMTgkQSogJ2I7gGuUHQnDoZvAw+CSEnosJnCMxIZIg7uHt+KWX5cWg/veKsCsLY+xK44toLrSBNPwJFmWweSeE1FVV7SqM44iGYYBPZvCKdU0YoTkXSil3Ryu/CNOdJpsp4pwjKeVms2kai1gUqfShvL7vty5a27KOCI2OEAsQZoyhruvsck9o8IVS7r5ptjRwDkvbEy5S7Y0FtNwz0DmhDg5SSlH4PwkhfCN9qDQQClvdtu1Pz4g6OLAPnx/Omps3emDW4KKmlX/WC/kVYACiNOUTeEjwagAAAABJRU5ErkJggg==' }; /* jshint +W101 */ /** * A provider for BPMN 2.0 elements context pad * * @param {ContextPad} contextPad */ function ContextPadProvider(contextPad, directEditing, modeling, selection) { contextPad.registerProvider(this); this._selection = selection; this._directEditing = directEditing; this._modeling = modeling; } ContextPadProvider.$inject = [ 'contextPad', 'directEditing', 'modeling', 'selection' ]; ContextPadProvider.prototype.getContextPadEntries = function(element) { var directEditing = this._directEditing, modeling = this._modeling, selection = this._selection; var actions = {}; if (element.type === 'label') { return actions; } var bpmnElement = element.businessObject; function append(element, type) { var target = modeling.appendFlowNode(element, type); selection.select(target); directEditing.activate(target); } if (bpmnElement.$instanceOf('bpmn:FlowNode') && !bpmnElement.$instanceOf('bpmn:EndEvent')) { _.extend(actions, { 'action.model-event': { imageUrl: 'data:image/png;base64,' + images.EVENT, action: function() { append(element, 'bpmn:EndEvent'); } }, 'action.model-gateway': { imageUrl: 'data:image/png;base64,' + images.GATEWAY, action: function() { append(element, 'bpmn:Gateway'); } }, 'action.model-task': { imageUrl: 'data:image/png;base64,' + images.TASK, action: function() { append(element, 'bpmn:Task'); } }, 'action.model-intermediate-event': { imageUrl: 'data:image/png;base64,' + images.INTER_THROW_EVENT, action: function() { append(element, 'bpmn:IntermediateThrowEvent'); } } }); } /* _.extend(actions, { 'action.delete': { imageUrl: 'data:image/png;base64,' + images.TRASH, action: function(e) { console.log('action.delete', e); } } }); */ return actions; }; module.exports = ContextPadProvider;