2014-06-27 15:52:34 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
|
|
|
|
|
|
/* jshint -W101 */
|
|
|
|
|
|
|
|
var images = {
|
2014-08-27 13:50:40 +00:00
|
|
|
EVENT_END: 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAEbSURBVDiNtZUxisMwEEWfnDKQwqdIGXAjUJlrLVssi2+im1jgxpAyre6QlMlPYStoN7Z3Dc6HKWz4j5nxl2wkMSdjzAbYD49nSbdZg6SXAnZADTTABdBQl+FdDexGvSOwIxAzyFRF4Pjbb/KRjTFfwAdgAKy1OOeoqgqArusIIdC27XNA4FvS58vIQ2d3QGVZynuvKXnvVZZl6vSed5rvLCZYjHESlhRjzKEx7TQB67Sbuc7GOs12WufABpC19t+wJGttAjaSKIacHQCcc7MRG1PmORhjNgV9aLfA82suUebZAvtiMeEPFcAZuEKfs6XKPFfgXKg/myeAEMJiYOY5Sbq9LTbrBlsrHr33XQ5a6fpa/YL9MfKYlv4CHqE/UXeUBA2YAAAAAElFTkSuQmCC',
|
2014-06-27 15:52:34 +00:00
|
|
|
GATEWAY: 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAG1JREFUeNqs1MsJACEMBFC1gfR/sqSUlEXZFVEzcWEG5vrAT5LNLFFyAdW32AigKiLWirAI6oiq9iIMQQP5gjAP2pAIO0EugrAVChEPm6Fr5IQ1oyRW2EejXjb1+akfkjoi1KH9tUYya7E9AgwA8H6jTs2UBDgAAAAASUVORK5CYII=',
|
|
|
|
TASK: 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFW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CN9qDQQClvdtu1Pz4g6OLAPnx/Omps3emDW4KKmlX/WC/kVYACiNOUTeEjwagAAAABJRU5ErkJggg=='
|
|
|
|
};
|
|
|
|
|
|
|
|
/* jshint +W101 */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A provider for BPMN 2.0 elements context pad
|
|
|
|
*
|
|
|
|
* @param {ContextPad} contextPad
|
|
|
|
*/
|
2014-07-23 16:53:33 +00:00
|
|
|
function ContextPadProvider(contextPad, directEditing, modeling, 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;
|
2014-07-23 16:53:33 +00:00
|
|
|
this._modeling = modeling;
|
2014-06-27 15:52:34 +00:00
|
|
|
}
|
|
|
|
|
2014-07-23 16:53:33 +00:00
|
|
|
ContextPadProvider.$inject = [ 'contextPad', 'directEditing', 'modeling', 'selection' ];
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
|
|
|
|
|
var directEditing = this._directEditing,
|
2014-07-23 16:53:33 +00:00
|
|
|
modeling = this._modeling,
|
2014-07-18 13:29:41 +00:00
|
|
|
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) {
|
2014-08-05 11:57:32 +00:00
|
|
|
|
|
|
|
var target;
|
|
|
|
|
|
|
|
if(type === 'bpmn:TextAnnotation') {
|
|
|
|
target = modeling.appendTextAnnotation(element, type);
|
|
|
|
} else {
|
|
|
|
target = modeling.appendFlowNode(element, 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': {
|
2014-08-05 11:57:32 +00:00
|
|
|
imageUrl: 'data:image/png;base64,' + images.EVENT_END,
|
2014-08-01 14:19:15 +00:00
|
|
|
action: function() {
|
2014-06-27 15:52:34 +00:00
|
|
|
append(element, 'bpmn:EndEvent');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'action.model-gateway': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.GATEWAY,
|
2014-08-02 14:37:43 +00:00
|
|
|
action: function(e) {
|
|
|
|
append(element, 'bpmn:ExclusiveGateway');
|
2014-06-27 15:52:34 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
'action.model-task': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.TASK,
|
2014-08-01 14:19:15 +00:00
|
|
|
action: function() {
|
2014-06-27 15:52:34 +00:00
|
|
|
append(element, 'bpmn:Task');
|
|
|
|
}
|
2014-08-01 14:19:15 +00:00
|
|
|
},
|
|
|
|
'action.model-intermediate-event': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.INTER_THROW_EVENT,
|
|
|
|
action: function() {
|
|
|
|
append(element, 'bpmn:IntermediateThrowEvent');
|
|
|
|
}
|
2014-08-05 11:57:32 +00:00
|
|
|
},
|
|
|
|
'action.model-text-Annotation': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.TEXT_ANNOTATION,
|
|
|
|
action: function() {
|
|
|
|
append(element, 'bpmn:TextAnnotation');
|
|
|
|
}
|
2014-06-27 15:52:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
_.extend(actions, {
|
|
|
|
'action.delete': {
|
|
|
|
imageUrl: 'data:image/png;base64,' + images.TRASH,
|
|
|
|
action: function(e) {
|
|
|
|
console.log('action.delete', e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = ContextPadProvider;
|