mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-13 18:46:05 +00:00
c67709ce34
Closes #90
118 lines
5.6 KiB
JavaScript
118 lines
5.6 KiB
JavaScript
'use strict';
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
/* jshint -W101 */
|
|
|
|
var images = {
|
|
EVENT_END: 'iVBORw0KGgoAAAANSUhEUgAAABMAAAAUCAYAAABvVQZ0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAGdSURBVDiNrZTPitNQGMV/NxAYlJCm+gzicqZU6K4IggZduO6iM88kBtqhHbLIO+g7WMJMuxAlSLsRBlRmGQjkuLCXNmmntmUOfHDv4vy4f77vGEnUZYx5AoTAi2U9A74BX5b1SdKfDaOkSgHvgFtAtowxqu1/Aq83vGuQR8DAGsIwVBRFStNUeZ4rTVNFUaQwDC20BD4AJ9tgV4A8z1Mcx9qlOI7leZ6Fjiow4BWgIAiUZdlOkFWWZWo0GuUS+NK+/WPgB6DRaLQXyGowGNjTfQdOAC4Adbvdg0CSVJalOp2OBZ47wBlAr9fb+On/yRhDv9+325YDnAK0Wq2DYQDtdtsuTwHuXNdVnucHX1OS8jyX67oC7pyjjnOPHOCmKApms9lRgOl0SlEUADcOcA2QpulRsMlkYpfX8ICtAWtNOx6PD4INh8Nq02ptnJrNphaLxV6g+XyuIAiq46TaoPu+XyZJshOUJIl837eg6qBrFUGX7B9BAj6yLYLWoO+BX3B/OPIvPN/WvUbbY/sp8IZVbD8HvrKK7c+Sftd9fwFj56oBfolA4gAAAABJRU5ErkJggg==',
|
|
GATEWAY: 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAG1JREFUeNqs1MsJACEMBFC1gfR/sqSUlEXZFVEzcWEG5vrAT5LNLFFyAdW32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u/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;
|
|
|
|
if(type === 'bpmn:TextAnnotation') {
|
|
target = modeling.appendTextAnnotation(element, type);
|
|
} else {
|
|
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_END,
|
|
action: function() {
|
|
append(element, 'bpmn:EndEvent');
|
|
}
|
|
},
|
|
'action.model-gateway': {
|
|
imageUrl: 'data:image/png;base64,' + images.GATEWAY,
|
|
action: function(e) {
|
|
append(element, 'bpmn:ExclusiveGateway');
|
|
}
|
|
},
|
|
'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');
|
|
}
|
|
},
|
|
'action.model-text-Annotation': {
|
|
imageUrl: 'data:image/png;base64,' + images.TEXT_ANNOTATION,
|
|
action: function() {
|
|
append(element, 'bpmn:TextAnnotation');
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
/*
|
|
_.extend(actions, {
|
|
'action.delete': {
|
|
imageUrl: 'data:image/png;base64,' + images.TRASH,
|
|
action: function(e) {
|
|
console.log('action.delete', e);
|
|
}
|
|
}
|
|
});
|
|
*/
|
|
|
|
return actions;
|
|
};
|
|
|
|
|
|
module.exports = ContextPadProvider; |