2014-06-11 12:41:55 +00:00
|
|
|
'use strict';
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2015-02-12 14:50:23 +00:00
|
|
|
var IdSupport = require('bpmn-moddle/lib/id-support'),
|
2014-08-04 14:34:37 +00:00
|
|
|
Ids = require('ids');
|
2014-03-18 16:01:24 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var Viewer = require('./Viewer');
|
2014-03-18 16:01:24 +00:00
|
|
|
|
2014-06-24 13:50:51 +00:00
|
|
|
var initialDiagram =
|
|
|
|
'<?xml version="1.0" encoding="UTF-8"?>' +
|
|
|
|
'<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
|
|
|
'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
|
|
|
|
'xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
|
|
|
|
'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" ' +
|
|
|
|
'targetNamespace="http://bpmn.io/schema/bpmn" ' +
|
|
|
|
'id="Definitions_1">' +
|
|
|
|
'<bpmn:process id="Process_1" isExecutable="false">' +
|
|
|
|
'<bpmn:startEvent id="StartEvent_1"/>' +
|
|
|
|
'</bpmn:process>' +
|
|
|
|
'<bpmndi:BPMNDiagram id="BPMNDiagram_1">' +
|
|
|
|
'<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">' +
|
|
|
|
'<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">' +
|
|
|
|
'<dc:Bounds height="36.0" width="36.0" x="173.0" y="102.0"/>' +
|
|
|
|
'</bpmndi:BPMNShape>' +
|
|
|
|
'</bpmndi:BPMNPlane>' +
|
|
|
|
'</bpmndi:BPMNDiagram>' +
|
|
|
|
'</bpmn:definitions>';
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-04-08 13:23:52 +00:00
|
|
|
/**
|
|
|
|
* A modeler for BPMN 2.0 diagrams.
|
2014-06-11 12:41:55 +00:00
|
|
|
*
|
2014-08-01 05:55:47 +00:00
|
|
|
* @class
|
|
|
|
*
|
|
|
|
* @inheritDoc djs.Viewer
|
2014-04-08 13:23:52 +00:00
|
|
|
*/
|
2014-04-04 16:48:37 +00:00
|
|
|
function Modeler(options) {
|
|
|
|
Viewer.call(this, options);
|
2014-03-18 16:01:24 +00:00
|
|
|
}
|
|
|
|
|
2014-04-04 16:48:37 +00:00
|
|
|
Modeler.prototype = Object.create(Viewer.prototype);
|
2014-03-18 16:01:24 +00:00
|
|
|
|
2014-06-24 13:50:51 +00:00
|
|
|
Modeler.prototype.createDiagram = function(done) {
|
|
|
|
return this.importXML(initialDiagram, done);
|
|
|
|
};
|
|
|
|
|
2014-08-04 14:34:37 +00:00
|
|
|
Modeler.prototype.createModdle = function() {
|
2015-02-12 14:50:23 +00:00
|
|
|
var moddle = Viewer.prototype.createModdle.call(this);
|
2014-08-04 14:34:37 +00:00
|
|
|
|
2014-08-11 15:45:47 +00:00
|
|
|
IdSupport.extend(moddle, new Ids([ 32, 36, 1 ]));
|
2014-08-04 14:34:37 +00:00
|
|
|
|
|
|
|
return moddle;
|
|
|
|
};
|
2014-06-24 13:50:51 +00:00
|
|
|
|
2014-08-08 12:42:50 +00:00
|
|
|
|
|
|
|
Modeler.prototype._interactionModules = [
|
2014-08-06 12:40:34 +00:00
|
|
|
// non-modeling components
|
2014-06-11 13:08:45 +00:00
|
|
|
require('./features/label-editing'),
|
2014-08-27 13:43:18 +00:00
|
|
|
require('diagram-js/lib/navigation/zoomscroll'),
|
|
|
|
require('diagram-js/lib/navigation/movecanvas'),
|
|
|
|
require('diagram-js/lib/navigation/touch')
|
2014-08-08 12:42:50 +00:00
|
|
|
];
|
2014-08-06 12:40:34 +00:00
|
|
|
|
2014-08-08 12:42:50 +00:00
|
|
|
Modeler.prototype._modelingModules = [
|
2014-08-06 12:40:34 +00:00
|
|
|
// modeling components
|
2015-01-06 15:00:11 +00:00
|
|
|
require('diagram-js/lib/features/keyboard'),
|
2014-08-12 17:04:54 +00:00
|
|
|
require('diagram-js/lib/features/snapping'),
|
2014-08-06 12:40:34 +00:00
|
|
|
require('diagram-js/lib/features/move'),
|
2015-01-14 17:48:06 +00:00
|
|
|
require('diagram-js/lib/features/bendpoints'),
|
2014-10-10 07:06:21 +00:00
|
|
|
require('diagram-js/lib/features/resize'),
|
2015-01-19 15:53:40 +00:00
|
|
|
require('diagram-js/lib/features/lasso-tool'),
|
2015-01-19 11:13:39 +00:00
|
|
|
require('diagram-js/lib/features/replace'),
|
2015-02-05 15:00:05 +00:00
|
|
|
require('diagram-js/lib/features/popup-menu'),
|
2015-01-19 11:13:39 +00:00
|
|
|
require('./features/replace'),
|
2014-08-27 13:43:18 +00:00
|
|
|
require('./features/modeling'),
|
2014-10-06 10:23:22 +00:00
|
|
|
require('./features/context-pad'),
|
2014-11-21 08:19:35 +00:00
|
|
|
require('./features/palette')
|
2014-08-08 12:42:50 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
// modules the modeler is composed of
|
|
|
|
//
|
|
|
|
// - viewer modules
|
|
|
|
// - interaction modules
|
|
|
|
// - modeling modules
|
|
|
|
|
|
|
|
Modeler.prototype._modules = [].concat(
|
|
|
|
Modeler.prototype._modules,
|
|
|
|
Modeler.prototype._interactionModules,
|
|
|
|
Modeler.prototype._modelingModules);
|
2014-06-11 12:41:55 +00:00
|
|
|
|
2014-06-24 13:50:51 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
module.exports = Modeler;
|