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59UANID0gsyAx7YDg4OJAcwsh6qxdqoQSQYBEpgpIIDBw6AKAUwh1oJEiOLgNIGoWzy4MEDhg0bNqBkEWSDYJk2gAhfPQCFBkamHVSxBhBgAH1c5Gm2siu5AAAAAElFTkSuQmCC',
|
|
|
|
TRASH: 'iVBORw0KGgoAAAANSUhEUgAAABIAAAATCAYAAACdkl3yAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQtJREFUeNqsVNENgyAQBeM/3aCM4AZlBDagG3QFR3AENygbYCeoTlBG0AksR8QgAbGNl7xEAu+9O84Dz/OMTgkQSogJ2I7gGuUHQnDoZvAw+CSEnosJnCMxIZIg7uHt+KWX5cWg/veKsCsLY+xK44toLrSBNPwJFmWweSeE1FVV7SqM44iGYYBPZvCKdU0YoTkXSil3Ryu/CNOdJpsp4pwjKeVms2kai1gUqfShvL7vty5a27KOCI2OEAsQZoyhruvsck9o8IVS7r5ptjRwDkvbEy5S7Y0FtNwz0DmhDg5SSlH4PwkhfCN9qDQQClvdtu1Pz4g6OLAPnx/Omps3emDW4KKmlX/WC/kVYACiNOUTeEjwagAAAABJRU5ErkJggg=='
|
|
|
|
};
|
|
|
|
|
|
|
|
/* jshint +W101 */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A provider for BPMN 2.0 elements context pad
|
|
|
|
*
|
|
|
|
* @param {ContextPad} contextPad
|
|
|
|
*/
|
2014-07-18 13:29:41 +00:00
|
|
|
function ContextPadProvider(contextPad, directEditing, bpmnModeling, selection) {
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
contextPad.registerProvider(this);
|
|
|
|
|
2014-07-18 13:29:41 +00:00
|
|
|
this._selection = selection;
|
2014-06-27 15:52:34 +00:00
|
|
|
this._directEditing = directEditing;
|
|
|
|
this._bpmnModeling = bpmnModeling;
|
|
|
|
}
|
|
|
|
|
2014-07-18 13:29:41 +00:00
|
|
|
ContextPadProvider.$inject = [ 'contextPad', 'directEditing', 'bpmnModeling', 'selection' ];
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
|
|
|
|
|
var directEditing = this._directEditing,
|
2014-07-18 13:29:41 +00:00
|
|
|
bpmnModeling = this._bpmnModeling,
|
|
|
|
selection = this._selection;
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
var actions = {};
|
|
|
|
|
|
|
|
if (element.type === 'label') {
|
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
var bpmnElement = element.businessObject;
|
|
|
|
|
|
|
|
function append(element, type) {
|
|
|
|
var target = bpmnModeling.appendFlowNode(element, null, type);
|
2014-07-18 13:29:41 +00:00
|
|
|
|
|
|
|
selection.select(target);
|
2014-06-27 15:52:34 +00:00
|
|
|
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(e) {
|
|
|
|
append(element, 'bpmn:EndEvent');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'action.model-gateway': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.GATEWAY,
|
|
|
|
action: function(e) {
|
|
|
|
append(element, 'bpmn:Gateway');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'action.model-task': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.TASK,
|
|
|
|
action: function(e) {
|
|
|
|
append(element, 'bpmn:Task');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
_.extend(actions, {
|
|
|
|
'action.delete': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.TRASH,
|
|
|
|
action: function(e) {
|
|
|
|
console.log('action.delete', e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = ContextPadProvider;
|