feat(modeling): add message flow modeling

Related to #199
Closes #201
This commit is contained in:
Nico Rehwaldt
2015-04-16 09:11:04 +02:00
committed by Ricardo Matias
parent 6011de1c4a
commit c14a87e5ad
21 changed files with 1114 additions and 647 deletions

View File

@ -14,14 +14,17 @@ var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler'),
* @param {EventBus} eventBus
* @param {ElementFactory} elementFactory
* @param {CommandStack} commandStack
* @param {BpmnRules} bpmnRules
*/
function Modeling(eventBus, elementFactory, commandStack) {
function Modeling(eventBus, elementFactory, commandStack, bpmnRules) {
BaseModeling.call(this, eventBus, elementFactory, commandStack);
this._bpmnRules = bpmnRules;
}
inherits(Modeling, BaseModeling);
Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack' ];
Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack', 'bpmnRules' ];
module.exports = Modeling;
@ -44,17 +47,19 @@ Modeling.prototype.updateLabel = function(element, newLabel) {
};
var getSharedParent = require('./ModelingUtil').getSharedParent;
Modeling.prototype.connect = function(source, target, attrs) {
var sourceBo = source.businessObject,
targetBo = target.businessObject;
var bpmnRules = this._bpmnRules;
if (!attrs) {
if (sourceBo.$instanceOf('bpmn:FlowNode') &&
targetBo.$instanceOf('bpmn:FlowNode') &&
!sourceBo.$instanceOf('bpmn:EndEvent') &&
!targetBo.$instanceOf('bpmn:StartEvent')) {
if (bpmnRules.canConnectMessageFlow(source, target)) {
attrs = {
type: 'bpmn:MessageFlow'
};
} else
if (bpmnRules.canConnectSequenceFlow(source, target)) {
attrs = {
type: 'bpmn:SequenceFlow'
};
@ -65,7 +70,7 @@ Modeling.prototype.connect = function(source, target, attrs) {
}
}
return this.createConnection(source, target, attrs, source.parent);
return this.createConnection(source, target, attrs, getSharedParent(source, target));
};