2014-07-23 16:53:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
|
|
var BaseModeling = require('diagram-js/lib/features/modeling/Modeling');
|
|
|
|
|
2014-08-28 14:17:55 +00:00
|
|
|
var CreateShapeHandler = require('diagram-js/lib/features/modeling/cmd/CreateShapeHandler'),
|
2014-08-22 13:20:48 +00:00
|
|
|
DeleteShapeHandler = require('diagram-js/lib/features/modeling/cmd/DeleteShapeHandler'),
|
2014-08-28 14:17:55 +00:00
|
|
|
MoveShapeHandler = require('diagram-js/lib/features/modeling/cmd/MoveShapeHandler'),
|
2014-10-27 11:07:57 +00:00
|
|
|
MoveShapesHandler = require('diagram-js/lib/features/modeling/cmd/MoveShapesHandler'),
|
2014-10-10 07:06:21 +00:00
|
|
|
ResizeShapeHandler = require('diagram-js/lib/features/modeling/cmd/ResizeShapeHandler'),
|
2014-08-22 13:20:48 +00:00
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler'),
|
|
|
|
|
2014-08-28 15:38:51 +00:00
|
|
|
AppendShapeHandler = require('diagram-js/lib/features/modeling/cmd/AppendShapeHandler'),
|
2014-08-22 13:20:48 +00:00
|
|
|
|
2014-07-30 14:07:43 +00:00
|
|
|
CreateLabelHandler = require('diagram-js/lib/features/modeling/cmd/CreateLabelHandler'),
|
|
|
|
|
2014-08-28 14:17:55 +00:00
|
|
|
CreateConnectionHandler = require('diagram-js/lib/features/modeling/cmd/CreateConnectionHandler'),
|
|
|
|
DeleteConnectionHandler = require('diagram-js/lib/features/modeling/cmd/DeleteConnectionHandler'),
|
|
|
|
MoveConnectionHandler = require('diagram-js/lib/features/modeling/cmd/MoveConnectionHandler'),
|
|
|
|
LayoutConnectionHandler = require('diagram-js/lib/features/modeling/cmd/LayoutConnectionHandler');
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
Modeling.prototype.registerHandlers = function(commandStack) {
|
|
|
|
commandStack.registerHandler('shape.create', CreateShapeHandler);
|
2014-08-22 13:20:48 +00:00
|
|
|
commandStack.registerHandler('shape.delete', DeleteShapeHandler);
|
2014-07-30 14:07:43 +00:00
|
|
|
commandStack.registerHandler('shape.move', MoveShapeHandler);
|
2014-10-27 11:07:57 +00:00
|
|
|
commandStack.registerHandler('shapes.move', MoveShapesHandler);
|
2014-10-10 07:06:21 +00:00
|
|
|
commandStack.registerHandler('shape.resize', ResizeShapeHandler);
|
2014-07-30 14:07:43 +00:00
|
|
|
|
|
|
|
commandStack.registerHandler('shape.append', AppendShapeHandler);
|
|
|
|
|
2014-07-23 16:53:33 +00:00
|
|
|
commandStack.registerHandler('label.create', CreateLabelHandler);
|
2014-07-30 14:07:43 +00:00
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
commandStack.registerHandler('element.updateProperties', UpdatePropertiesHandler);
|
|
|
|
|
2014-07-30 14:07:43 +00:00
|
|
|
commandStack.registerHandler('connection.create', CreateConnectionHandler);
|
2014-08-22 13:20:48 +00:00
|
|
|
commandStack.registerHandler('connection.delete', DeleteConnectionHandler);
|
2014-08-28 14:17:55 +00:00
|
|
|
commandStack.registerHandler('connection.move', MoveConnectionHandler);
|
2014-07-30 14:07:43 +00:00
|
|
|
commandStack.registerHandler('connection.layout', LayoutConnectionHandler);
|
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) {
|
|
|
|
if (sourceBo.$instanceOf('bpmn:FlowNode') && targetBo.$instanceOf('bpmn:FlowNode')) {
|
|
|
|
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
|
|
|
|
});
|
|
|
|
};
|