2014-07-23 16:53:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var BaseModeling = require('diagram-js/lib/features/modeling/Modeling');
|
|
|
|
|
2015-01-06 15:28:39 +00:00
|
|
|
var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler');
|
2014-07-23 16:53:33 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
|
2014-07-23 16:53:33 +00:00
|
|
|
/**
|
|
|
|
* BPMN 2.0 modeling features activator
|
|
|
|
*
|
|
|
|
* @param {EventBus} eventBus
|
2014-12-07 12:08:50 +00:00
|
|
|
* @param {ElementFactory} elementFactory
|
2014-07-23 16:53:33 +00:00
|
|
|
* @param {CommandStack} commandStack
|
|
|
|
*/
|
2014-12-07 12:08:50 +00:00
|
|
|
function Modeling(eventBus, elementFactory, commandStack) {
|
|
|
|
BaseModeling.call(this, eventBus, elementFactory, commandStack);
|
2014-07-23 16:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Modeling.prototype = Object.create(BaseModeling.prototype);
|
|
|
|
|
2014-12-07 12:08:50 +00:00
|
|
|
Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack' ];
|
2014-07-23 16:53:33 +00:00
|
|
|
|
|
|
|
module.exports = Modeling;
|
|
|
|
|
2015-01-06 15:28:39 +00:00
|
|
|
Modeling.prototype.getHandlers = function() {
|
|
|
|
var handlers = BaseModeling.prototype.getHandlers.call(this);
|
2014-07-23 16:53:33 +00:00
|
|
|
|
2015-01-06 15:28:39 +00:00
|
|
|
handlers['element.updateProperties'] = UpdatePropertiesHandler;
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2015-01-06 15:28:39 +00:00
|
|
|
return handlers;
|
2014-07-23 16:53:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-08-04 07:32:36 +00:00
|
|
|
Modeling.prototype.updateLabel = function(element, newLabel) {
|
|
|
|
this._commandStack.execute('element.updateLabel', {
|
|
|
|
element: element,
|
|
|
|
newLabel: newLabel
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-09-11 14:44:56 +00:00
|
|
|
Modeling.prototype.connect = function(source, target, attrs) {
|
|
|
|
|
|
|
|
var sourceBo = source.businessObject,
|
|
|
|
targetBo = target.businessObject;
|
|
|
|
|
|
|
|
if (!attrs) {
|
2015-01-14 17:48:06 +00:00
|
|
|
if (sourceBo.$instanceOf('bpmn:FlowNode') &&
|
|
|
|
targetBo.$instanceOf('bpmn:FlowNode') &&
|
|
|
|
!sourceBo.$instanceOf('bpmn:EndEvent') &&
|
|
|
|
!targetBo.$instanceOf('bpmn:StartEvent')) {
|
|
|
|
|
2014-09-11 14:44:56 +00:00
|
|
|
attrs = {
|
|
|
|
type: 'bpmn:SequenceFlow'
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
attrs = {
|
|
|
|
type: 'bpmn:Association'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.createConnection(source, target, attrs, source.parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
};
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
Modeling.prototype.updateProperties = function(element, properties) {
|
|
|
|
this._commandStack.execute('element.updateProperties', {
|
|
|
|
element: element,
|
|
|
|
properties: properties
|
|
|
|
});
|
|
|
|
};
|