From 1aa4dc3048d39515c77c2565d0a050f6d5c9192f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ana=C3=ABl=20Closson?= Date: Wed, 6 Sep 2017 14:53:38 +0200 Subject: [PATCH] Reformat code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Issue-Id:: CLAMP-43 Change-Id: Ife5596c1fca86941e17fe84354bbab49d25f9ffa Signed-off-by: Anaël Closson --- .../resources/META-INF/resources/designer/index.js | 121752 +++++++++--------- .../resources/designer/scripts/CldsModelService.js | 736 +- .../META-INF/resources/designer/scripts/aOnBoot.js | 622 +- .../META-INF/resources/designer/scripts/app.js | 3367 +- .../resources/designer/scripts/authcontroller.js | 115 +- 5 files changed, 63309 insertions(+), 63283 deletions(-) diff --git a/src/main/resources/META-INF/resources/designer/index.js b/src/main/resources/META-INF/resources/designer/index.js index 75c175a8..89a688ac 100644 --- a/src/main/resources/META-INF/resources/designer/index.js +++ b/src/main/resources/META-INF/resources/designer/index.js @@ -1,68068 +1,68086 @@ -function activateMenu(){ - isImportSchema = true; +function activateMenu() { + isImportSchema = true; } -var abootDiagram=null; +var abootDiagram = null; -function cldsOpenDiagram(modelXml) -{ - cldsModelXml = modelXml; - console.log("cldsOpenDiagram: cldsModelXml=" + cldsModelXml); - $("#cldsopendiagrambtn").click(); +function cldsOpenDiagram(modelXml) { + cldsModelXml = modelXml; + console.log("cldsOpenDiagram: cldsModelXml=" + cldsModelXml); + $("#cldsopendiagrambtn").click(); } -function cldsGetDiagram() -{ - console.log("cldsGetDiagram: starting..."); - $("#cldsgetdiagrambtn").click(); - console.log("cldsGetDiagram: modelXML=" + modelXML); - return modelXML; + +function cldsGetDiagram() { + console.log("cldsGetDiagram: starting..."); + $("#cldsgetdiagrambtn").click(); + console.log("cldsGetDiagram: modelXML=" + modelXML); + return modelXML; } -function uploaddata(file) -{ - uploadfile= file; - $("#uploadmodel").click(); - + +function uploaddata(file) { + uploadfile = file; + $("#uploadmodel").click(); + } -function visibility_model() -{ - $("#openmodel").click(); - + +function visibility_model() { + $("#openmodel").click(); + } (function e(t, n, r) { - function s(o, u) { - if (!n[o]) { - if (!t[o]) { - var a = typeof require == "function" && require; - if (!u && a) return a(o, !0); - if (i) return i(o, !0); - var f = new Error("Cannot find module '" + o + "'"); - throw f.code = "MODULE_NOT_FOUND", f - } - var l = n[o] = { - exports: {} - }; - t[o][0].call(l.exports, function(e) { - var n = t[o][1][e]; - return s(n ? n : e) - }, l, l.exports, e, t, n, r) - } - return n[o].exports + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = typeof require == "function" && require; + if (!u && a) return a(o, !0); + if (i) return i(o, !0); + var f = new Error("Cannot find module '" + o + "'"); + throw f.code = "MODULE_NOT_FOUND", f + } + var l = n[o] = { + exports: {} + }; + t[o][0].call(l.exports, function(e) { + var n = t[o][1][e]; + return s(n ? n : e) + }, l, l.exports, e, t, n, r) } - var i = typeof require == "function" && require; - for (var o = 0; o < r.length; o++) s(r[o]); - return s; + return n[o].exports + } + var i = typeof require == "function" && require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s; }) - - ({ - "\\bpmn-js-examples-master\\modeler\\app\\index.js": - [function(require, module, exports) { +({ + "\\bpmn-js-examples-master\\modeler\\app\\index.js": - 'use strict'; + [function(require, module, exports) { + 'use strict'; - var $ = require('jquery'), - BpmnModeler = require('bpmn-js/lib/Modeler'); - var container = $('#js-drop-zone'); + var $ = require('jquery'), + BpmnModeler = require('bpmn-js/lib/Modeler'); - var canvas = $('#js-canvas'); + var container = $('#js-drop-zone'); - var renderer = new BpmnModeler({ - container: canvas - }); - abootDiagram=renderer; + var canvas = $('#js-canvas'); - var newDiagramXML = "\n\n \n \n \n \n \n \n \n \n \n \n"; - // - /*file_generate_test_case.addEventListener('click', function(e) { - + var renderer = new BpmnModeler({ + container: canvas + }); + abootDiagram = renderer; - });*/ + var newDiagramXML = "\n\n \n \n \n \n \n \n \n \n \n \n"; + // + /*file_generate_test_case.addEventListener('click', function(e) { - - function createNewDiagram(newDiagramXML) { - openDiagram(newDiagramXML); - - } - - function openDiagram(xml) { - renderer.importXML(xml, function(err) { + });*/ - if (err) { - container - .removeClass('with-diagram') - .addClass('with-error'); - container.find('.error pre').text(err.message); - console.error(err); - } else { - container - .removeClass('with-error') - .addClass('with-diagram'); - } + function createNewDiagram(newDiagramXML) { + openDiagram(newDiagramXML); + } - }); - } + function openDiagram(xml) { + renderer.importXML(xml, function(err) { - function saveSVG(done) { - renderer.saveSVG(done); - } + if (err) { + container + .removeClass('with-diagram') + .addClass('with-error'); - function saveDiagram(done) { + container.find('.error pre').text(err.message); - renderer.saveXML({ - format: true - }, function(err, xml) { - done(err, xml); - }); - } - + console.error(err); + } else { + container + .removeClass('with-error') + .addClass('with-diagram'); + } - function registerFileDrop(container, callback) { - function handleFileSelect(e) { - e.stopPropagation(); - e.preventDefault(); + }); + } - var files = e.dataTransfer.files; + function saveSVG(done) { + renderer.saveSVG(done); + } - var file = files[0]; + function saveDiagram(done) { - var reader = new FileReader(); + renderer.saveXML({ + format: true + }, function(err, xml) { + done(err, xml); + }); + } - reader.onload = function(e) { - var xml = e.target.result; + function registerFileDrop(container, callback) { - callback(xml); - }; + function handleFileSelect(e) { + e.stopPropagation(); + e.preventDefault(); - reader.readAsText(file); - } + var files = e.dataTransfer.files; - function handleDragOver(e) { - e.stopPropagation(); - e.preventDefault(); + var file = files[0]; - e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy. - } - if(container.get(0)){ - container.get(0).addEventListener('dragover', handleDragOver, false); - container.get(0).addEventListener('drop', handleFileSelect, false); - } - } + var reader = new FileReader(); + reader.onload = function(e) { - // //// file drag / drop /////////////////////// + var xml = e.target.result; - // check file api availability - if (!window.FileList || !window.FileReader) { - window.alert( - 'Looks like you use an older browser that does not support drag and drop. ' + - 'Try using Chrome, Firefox or the Internet Explorer > 10.'); - } else { - registerFileDrop(container, openDiagram); + callback(xml); + }; + + reader.readAsText(file); } - // bootstrap diagram functions - function openNewWin(linkURL) { - window.open(""+linkURL+"","_self"/*, "", "scrollbars, top="+winTop+", left="+winLeft+", height="+winHeight+", width="+winWidth+""*/); - } + function handleDragOver(e) { + e.stopPropagation(); + e.preventDefault(); - - $(document).on('ready', function(e) { + e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy. + } + if (container.get(0)) { + container.get(0).addEventListener('dragover', handleDragOver, false); + container.get(0).addEventListener('drop', handleFileSelect, false); + } + } - /* $('#js-create-diagram').click(function(e) {*/ - e.stopPropagation(); - e.preventDefault(); - createNewDiagram(newDiagramXML); - - /*});*/ - var fileInput = document.getElementById('fileInput'); - var file_generate_test_case = document.getElementById('file_generate_test_case'); - - var downloadLink = $('#js-download-diagram'); - var downloadSvgLink = $('#js-download-svg'); - var readLink = $('#file_generate_test_case'); - $('.buttons a').click(function(e) { - if (!$(this).is('.active')) { - e.preventDefault(); - e.stopPropagation(); - } - }); - $('#openmodel').click(function() { - - createNewDiagram(modelXML); - - } - ); - - $('#cldsgetdiagrambtn').click(function() { - console.log("cldsgetdiagrambtn: starting..."); - exportArtifacts(); - console.log("cldsgetdiagrambtn: modelXML=" + modelXML); - }); - $('#cldsopendiagrambtn').click(function() { - console.log("cldsopendiagrambtn: cldsModelXml=" + cldsModelXml); - createNewDiagram(cldsModelXml); - exportArtifacts(); - }); - $('#uploadmodel').click(function() { - var file = uploadfile; - var textType = /text.*/; - - var reader = new FileReader(); - - reader.onload = function(e) { - newDiagramXML = reader.result; - e.stopPropagation(); - e.preventDefault(); - createNewDiagram(newDiagramXML); - - } + // //// file drag / drop /////////////////////// - reader.readAsText(file); - exportArtifacts(); - }); - if(fileInput){ - fileInput.addEventListener('change', function(e) { - var file = fileInput.files[0]; - var textType = /text.*/; + // check file api availability + if (!window.FileList || !window.FileReader) { + window.alert( + 'Looks like you use an older browser that does not support drag and drop. ' + + 'Try using Chrome, Firefox or the Internet Explorer > 10.'); + } else { + registerFileDrop(container, openDiagram); + } + // bootstrap diagram functions + function openNewWin(linkURL) { + window.open("" + linkURL + "", "_self" /*, "", "scrollbars, top="+winTop+", left="+winLeft+", height="+winHeight+", width="+winWidth+""*/ ); + } - var reader = new FileReader(); - reader.onload = function(e) { - newDiagramXML = reader.result; - e.stopPropagation(); - e.preventDefault(); - createNewDiagram(newDiagramXML); - - } + $(document).on('ready', function(e) { - reader.readAsText(file); - exportArtifacts(); - }); - } - - function setEncoded(link, name, data) { - var encodedData = encodeURIComponent(data); - - var el=document.getElementById(selected_model); - var text = (el.innerText || el.textContent); - - - if (data) { - //var linkURL='data:application/bpmn20-xml;charset=UTF-8,' + encodedData; - link.addClass('active').attr({ - 'href':'data:application/bpmn20-xml;charset=UTF-8,' + encodedData,/*openNewWin( linkURL )*//*'*/ - 'download': text.trim()+'.utmxml', - 'target':'_blank' - }); - - } else { - link.removeClass('active'); - } - } - function setReadEncoded(link, name, data) { - var encodedData = encodeURIComponent(data); - - if (data) { - link.addClass('active').attr({ - 'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData, - 'download': name - }); - - - } else { - link.removeClass('active'); - } - } - var _ = require('lodash'); - /*var model = $( "#modelName" ).val(); - */ + /* $('#js-create-diagram').click(function(e) {*/ + e.stopPropagation(); + e.preventDefault(); - var exportArtifacts = _.debounce(function() { + createNewDiagram(newDiagramXML); - saveSVG(function(err, svg) { - setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg); - }); + /*});*/ + var fileInput = document.getElementById('fileInput'); + var file_generate_test_case = document.getElementById('file_generate_test_case'); - saveDiagram(function(err, xml) { - setEncoded(downloadLink, "model.utmxml", err ? null : xml); - }); - - }, 500); + var downloadLink = $('#js-download-diagram'); + var downloadSvgLink = $('#js-download-svg'); + var readLink = $('#file_generate_test_case'); + $('.buttons a').click(function(e) { + if (!$(this).is('.active')) { + e.preventDefault(); + e.stopPropagation(); + } + }); + $('#openmodel').click(function() { + + createNewDiagram(modelXML); - renderer.on('commandStack.changed', exportArtifacts); }); - }, { - "bpmn-js/lib/Modeler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Modeler.js", - "jquery": "\\bpmn-js-examples-master\\modeler\\node_modules\\jquery\\dist\\jquery.js", - "lodash": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Modeler.js": [function(require, module, exports) { - 'use strict'; - - var inherits = require('inherits'); - - var IdSupport = require('bpmn-moddle/lib/id-support'), - Ids = require('ids'); - - var Viewer = require('./Viewer'); - - var initialDiagram = - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; + $('#cldsgetdiagrambtn').click(function() { + console.log("cldsgetdiagrambtn: starting..."); + exportArtifacts(); + console.log("cldsgetdiagrambtn: modelXML=" + modelXML); + }); + $('#cldsopendiagrambtn').click(function() { + console.log("cldsopendiagrambtn: cldsModelXml=" + cldsModelXml); + createNewDiagram(cldsModelXml); + exportArtifacts(); + }); + $('#uploadmodel').click(function() { + var file = uploadfile; + var textType = /text.*/; - /** - * A modeler for BPMN 2.0 diagrams. - * - * ## Extending the Modeler - * - * In order to extend the viewer pass extension modules to bootstrap via the - * `additionalModules` option. An extension module is an object that exposes - * named services. - * - * The following example depicts the integration of a simple logging component - * that integrates with interaction events: - * - * - * ```javascript - * // logging component function InteractionLogger(eventBus) { - * eventBus.on('element.hover', function(event) { console.log() }) } - * - * InteractionLogger.$inject = [ 'eventBus' ]; // minification save - * // extension module var extensionModule = { __init__: [ 'interactionLogger' ], - * interactionLogger: [ 'type', InteractionLogger ] }; - * // extend the viewer var bpmnModeler = new Modeler({ additionalModules: [ - * extensionModule ] }); bpmnModeler.importXML(...); ``` - * - * ## Customizing / Replacing Components - * - * You can replace individual diagram components by redefining them in override - * modules. This works for all components, including those defined in the core. - * - * Pass in override modules via the `options.additionalModules` flag like this: - * - * ```javascript function CustomContextPadProvider(contextPad) { - * - * contextPad.registerProvider(this); - * - * this.getContextPadEntries = function(element) { // no entries, effectively - * disable the context pad return {}; }; } - * - * CustomContextPadProvider.$inject = [ 'contextPad' ]; - * - * var overrideModule = { contextPadProvider: [ 'type', CustomContextPadProvider ] }; - * - * var bpmnModeler = new Modeler({ additionalModules: [ overrideModule ]}); ``` - * - * @param {Object} - * [options] configuration options to pass to the viewer - * @param {DOMElement} - * [options.container] the container to render the viewer in, - * defaults to body. - * @param {String|Number} - * [options.width] the width of the viewer - * @param {String|Number} - * [options.height] the height of the viewer - * @param {Object} - * [options.moddleExtensions] extension packages to provide - * @param {Array - * } [options.modules] a list of modules to override the - * default modules - * @param {Array - * } [options.additionalModules] a list of modules to - * use with the default modules - */ - function Modeler(options) { - Viewer.call(this, options); - } + var reader = new FileReader(); - inherits(Modeler, Viewer); + reader.onload = function(e) { + newDiagramXML = reader.result; + e.stopPropagation(); + e.preventDefault(); + createNewDiagram(newDiagramXML); - Modeler.prototype.createDiagram = function(done) { - return this.importXML(initialDiagram, done); - }; + } - Modeler.prototype.createModdle = function() { - var moddle = Viewer.prototype.createModdle.call(this); + reader.readAsText(file); + exportArtifacts(); + }); + if (fileInput) { + fileInput.addEventListener('change', function(e) { + var file = fileInput.files[0]; + var textType = /text.*/; - IdSupport.extend(moddle, new Ids([32, 36, 1])); - return moddle; - }; + var reader = new FileReader(); + reader.onload = function(e) { + newDiagramXML = reader.result; + e.stopPropagation(); + e.preventDefault(); + createNewDiagram(newDiagramXML); - Modeler.prototype._interactionModules = [ - // non-modeling components - require('./features/label-editing'), - require('./features/keyboard'), - require('diagram-js/lib/navigation/zoomscroll'), - require('diagram-js/lib/navigation/movecanvas'), - require('diagram-js/lib/navigation/touch') - ]; + } - Modeler.prototype._modelingModules = [ - // modeling components - require('diagram-js/lib/features/move'), - require('diagram-js/lib/features/bendpoints'), - require('diagram-js/lib/features/resize'), - require('diagram-js/lib/features/space-tool'), - require('diagram-js/lib/features/lasso-tool'), - //require('./features/keyboard'), - require('./features/snapping'), - require('./features/modeling'), - require('./features/context-pad'), - require('./features/palette') - ]; + reader.readAsText(file); + exportArtifacts(); + }); + } + + function setEncoded(link, name, data) { + var encodedData = encodeURIComponent(data); + var el = document.getElementById(selected_model); + var text = (el.innerText || el.textContent); - // 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); + if (data) { + //var linkURL='data:application/bpmn20-xml;charset=UTF-8,' + encodedData; + link.addClass('active').attr({ + 'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData, + /*openNewWin( linkURL )*/ /*'*/ + 'download': text.trim() + '.utmxml', + 'target': '_blank' + }); + } else { + link.removeClass('active'); + } + } - module.exports = Modeler; + function setReadEncoded(link, name, data) { + var encodedData = encodeURIComponent(data); - }, { - "./Viewer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Viewer.js", - "./features/context-pad": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\index.js", - "./features/keyboard": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\index.js", - "./features/label-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\index.js", - "./features/modeling": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\index.js", - "./features/palette": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\index.js", - "./features/snapping": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\index.js", - "bpmn-moddle/lib/id-support": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\id-support.js", - "diagram-js/lib/features/bendpoints": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\bendpoints\\index.js", - "diagram-js/lib/features/lasso-tool": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\lasso-tool\\index.js", - "diagram-js/lib/features/move": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\move\\index.js", - "diagram-js/lib/features/resize": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\resize\\index.js", - "diagram-js/lib/features/space-tool": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\space-tool\\index.js", - "diagram-js/lib/navigation/movecanvas": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\navigation\\movecanvas\\index.js", - "diagram-js/lib/navigation/touch": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\navigation\\touch\\index.js", - "diagram-js/lib/navigation/zoomscroll": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\navigation\\zoomscroll\\index.js", - "ids": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\ids\\index.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Viewer.js": [function(require, module, exports) { - 'use strict'; + if (data) { + link.addClass('active').attr({ + 'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData, + 'download': name + }); - var assign = require('lodash/object/assign'), - omit = require('lodash/object/omit'), - isString = require('lodash/lang/isString'), - isNumber = require('lodash/lang/isNumber'); - var domify = require('min-dom/lib/domify'), - domQuery = require('min-dom/lib/query'), - domRemove = require('min-dom/lib/remove'); + } else { + link.removeClass('active'); + } + } + var _ = require('lodash'); + /*var model = $( "#modelName" ).val(); + */ - var Diagram = require('diagram-js'), - BpmnModdle = require('bpmn-moddle'); + var exportArtifacts = _.debounce(function() { - var Importer = require('./import/Importer'); + saveSVG(function(err, svg) { + setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg); + }); + saveDiagram(function(err, xml) { + setEncoded(downloadLink, "model.utmxml", err ? null : xml); + }); - function initListeners(diagram, listeners) { - var events = diagram.get('eventBus'); + }, 500); - listeners.forEach(function(l) { - events.on(l.event, l.handler); - }); - } + renderer.on('commandStack.changed', exportArtifacts); + }); + }, { + "bpmn-js/lib/Modeler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Modeler.js", + "jquery": "\\bpmn-js-examples-master\\modeler\\node_modules\\jquery\\dist\\jquery.js", + "lodash": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Modeler.js": [function(require, module, exports) { + 'use strict'; + + var inherits = require('inherits'); + + var IdSupport = require('bpmn-moddle/lib/id-support'), + Ids = require('ids'); + + var Viewer = require('./Viewer'); + + var initialDiagram = + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; + + + /** + * A modeler for BPMN 2.0 diagrams. + * + * ## Extending the Modeler + * + * In order to extend the viewer pass extension modules to bootstrap via the + * `additionalModules` option. An extension module is an object that exposes + * named services. + * + * The following example depicts the integration of a simple logging component + * that integrates with interaction events: + * + * + * ```javascript + * // logging component function InteractionLogger(eventBus) { + * eventBus.on('element.hover', function(event) { console.log() }) } + * + * InteractionLogger.$inject = [ 'eventBus' ]; // minification save + * // extension module var extensionModule = { __init__: [ 'interactionLogger' ], + * interactionLogger: [ 'type', InteractionLogger ] }; + * // extend the viewer var bpmnModeler = new Modeler({ additionalModules: [ + * extensionModule ] }); bpmnModeler.importXML(...); ``` + * + * ## Customizing / Replacing Components + * + * You can replace individual diagram components by redefining them in override + * modules. This works for all components, including those defined in the core. + * + * Pass in override modules via the `options.additionalModules` flag like this: + * + * ```javascript function CustomContextPadProvider(contextPad) { + * + * contextPad.registerProvider(this); + * + * this.getContextPadEntries = function(element) { // no entries, effectively + * disable the context pad return {}; }; } + * + * CustomContextPadProvider.$inject = [ 'contextPad' ]; + * + * var overrideModule = { contextPadProvider: [ 'type', CustomContextPadProvider ] }; + * + * var bpmnModeler = new Modeler({ additionalModules: [ overrideModule ]}); ``` + * + * @param {Object} + * [options] configuration options to pass to the viewer + * @param {DOMElement} + * [options.container] the container to render the viewer in, + * defaults to body. + * @param {String|Number} + * [options.width] the width of the viewer + * @param {String|Number} + * [options.height] the height of the viewer + * @param {Object} + * [options.moddleExtensions] extension packages to provide + * @param {Array + * } [options.modules] a list of modules to override the + * default modules + * @param {Array + * } [options.additionalModules] a list of modules to + * use with the default modules + */ + function Modeler(options) { + Viewer.call(this, options); + } - function checkValidationError(err) { + inherits(Modeler, Viewer); + + Modeler.prototype.createDiagram = function(done) { + return this.importXML(initialDiagram, done); + }; + + Modeler.prototype.createModdle = function() { + var moddle = Viewer.prototype.createModdle.call(this); + + IdSupport.extend(moddle, new Ids([32, 36, 1])); + + return moddle; + }; + + + Modeler.prototype._interactionModules = [ + // non-modeling components + require('./features/label-editing'), + require('./features/keyboard'), + require('diagram-js/lib/navigation/zoomscroll'), + require('diagram-js/lib/navigation/movecanvas'), + require('diagram-js/lib/navigation/touch') + ]; + + Modeler.prototype._modelingModules = [ + // modeling components + require('diagram-js/lib/features/move'), + require('diagram-js/lib/features/bendpoints'), + require('diagram-js/lib/features/resize'), + require('diagram-js/lib/features/space-tool'), + require('diagram-js/lib/features/lasso-tool'), + //require('./features/keyboard'), + require('./features/snapping'), + require('./features/modeling'), + require('./features/context-pad'), + require('./features/palette') + ]; + + + // 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); + + + module.exports = Modeler; + + }, { + "./Viewer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Viewer.js", + "./features/context-pad": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\index.js", + "./features/keyboard": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\index.js", + "./features/label-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\index.js", + "./features/modeling": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\index.js", + "./features/palette": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\index.js", + "./features/snapping": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\index.js", + "bpmn-moddle/lib/id-support": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\id-support.js", + "diagram-js/lib/features/bendpoints": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\bendpoints\\index.js", + "diagram-js/lib/features/lasso-tool": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\lasso-tool\\index.js", + "diagram-js/lib/features/move": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\move\\index.js", + "diagram-js/lib/features/resize": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\resize\\index.js", + "diagram-js/lib/features/space-tool": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\space-tool\\index.js", + "diagram-js/lib/navigation/movecanvas": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\navigation\\movecanvas\\index.js", + "diagram-js/lib/navigation/touch": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\navigation\\touch\\index.js", + "diagram-js/lib/navigation/zoomscroll": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\navigation\\zoomscroll\\index.js", + "ids": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\ids\\index.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\Viewer.js": [function(require, module, exports) { + 'use strict'; + + var assign = require('lodash/object/assign'), + omit = require('lodash/object/omit'), + isString = require('lodash/lang/isString'), + isNumber = require('lodash/lang/isNumber'); + + var domify = require('min-dom/lib/domify'), + domQuery = require('min-dom/lib/query'), + domRemove = require('min-dom/lib/remove'); + + var Diagram = require('diagram-js'), + BpmnModdle = require('bpmn-moddle'); + + var Importer = require('./import/Importer'); + + + function initListeners(diagram, listeners) { + var events = diagram.get('eventBus'); + + listeners.forEach(function(l) { + events.on(l.event, l.handler); + }); + } - // check if we can help the user by indicating wrong BPMN 2.0 xml - // (in case he or the exporting tool did not get that right) + function checkValidationError(err) { - var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/; - var match = pattern.exec(err.message); + // check if we can help the user by indicating wrong BPMN 2.0 xml + // (in case he or the exporting tool did not get that right) - if (match) { - err.message = - 'unparsable content <' + match[1] + '> detected; ' + - 'this may indicate an invalid BPMN 2.0 diagram file' + match[2]; - } + var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/; + var match = pattern.exec(err.message); - return err; - } + if (match) { + err.message = + 'unparsable content <' + match[1] + '> detected; ' + + 'this may indicate an invalid BPMN 2.0 diagram file' + match[2]; + } - var DEFAULT_OPTIONS = { - width: '100%', - height: '100%', - position: 'relative', - container: 'body' - }; + return err; + } + var DEFAULT_OPTIONS = { + width: '100%', + height: '100%', + position: 'relative', + container: 'body' + }; - /** - * Ensure the passed argument is a proper unit (defaulting to px) - */ - function ensureUnit(val) { - return val + (isNumber(val) ? 'px' : ''); - } - /** - * A viewer for BPMN 2.0 diagrams. - * - * Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that - * include additional features. - * - * ## Extending the Viewer - * - * In order to extend the viewer pass extension modules to bootstrap via the - * `additionalModules` option. An extension module is an object that exposes - * named services. - * - * The following example depicts the integration of a simple logging component - * that integrates with interaction events: - * - * - * ```javascript - * // logging component function InteractionLogger(eventBus) { - * eventBus.on('element.hover', function(event) { console.log() }) } - * - * InteractionLogger.$inject = [ 'eventBus' ]; // minification save - * // extension module var extensionModule = { __init__: [ 'interactionLogger' ], - * interactionLogger: [ 'type', InteractionLogger ] }; - * // extend the viewer var bpmnViewer = new Viewer({ additionalModules: [ - * extensionModule ] }); bpmnViewer.importXML(...); ``` - * - * @param {Object} - * [options] configuration options to pass to the viewer - * @param {DOMElement} - * [options.container] the container to render the viewer in, - * defaults to body. - * @param {String|Number} - * [options.width] the width of the viewer - * @param {String|Number} - * [options.height] the height of the viewer - * @param {Object} - * [options.moddleExtensions] extension packages to provide - * @param {Array - * } [options.modules] a list of modules to override the - * default modules - * @param {Array - * } [options.additionalModules] a list of modules to - * use with the default modules - */ - function Viewer(options) { + /** + * Ensure the passed argument is a proper unit (defaulting to px) + */ + function ensureUnit(val) { + return val + (isNumber(val) ? 'px' : ''); + } - this.options = options = assign({}, DEFAULT_OPTIONS, options || {}); + /** + * A viewer for BPMN 2.0 diagrams. + * + * Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that + * include additional features. + * + * ## Extending the Viewer + * + * In order to extend the viewer pass extension modules to bootstrap via the + * `additionalModules` option. An extension module is an object that exposes + * named services. + * + * The following example depicts the integration of a simple logging component + * that integrates with interaction events: + * + * + * ```javascript + * // logging component function InteractionLogger(eventBus) { + * eventBus.on('element.hover', function(event) { console.log() }) } + * + * InteractionLogger.$inject = [ 'eventBus' ]; // minification save + * // extension module var extensionModule = { __init__: [ 'interactionLogger' ], + * interactionLogger: [ 'type', InteractionLogger ] }; + * // extend the viewer var bpmnViewer = new Viewer({ additionalModules: [ + * extensionModule ] }); bpmnViewer.importXML(...); ``` + * + * @param {Object} + * [options] configuration options to pass to the viewer + * @param {DOMElement} + * [options.container] the container to render the viewer in, + * defaults to body. + * @param {String|Number} + * [options.width] the width of the viewer + * @param {String|Number} + * [options.height] the height of the viewer + * @param {Object} + * [options.moddleExtensions] extension packages to provide + * @param {Array + * } [options.modules] a list of modules to override the + * default modules + * @param {Array + * } [options.additionalModules] a list of modules to + * use with the default modules + */ + function Viewer(options) { + + this.options = options = assign({}, DEFAULT_OPTIONS, options || {}); + + var parent = options.container; + + // support jquery element + // unwrap it if passed + if (parent.get) { + parent = parent.get(0); + } - var parent = options.container; + // support selector + if (isString(parent)) { + parent = domQuery(parent); + } - // support jquery element - // unwrap it if passed - if (parent.get) { - parent = parent.get(0); - } + var container = this.container = domify('
'); + if (parent && parent.appendChild) { + parent.appendChild(container); + } - // support selector - if (isString(parent)) { - parent = domQuery(parent); - } - var container = this.container = domify('
'); - if(parent && parent.appendChild){ - parent.appendChild(container); - } - + assign(container.style, { + width: ensureUnit(options.width), + height: ensureUnit(options.height), + position: options.position + }); + + /** + * The code in the area must not be changed, + * see http://bpmn.io/license for more information + * + * + */ + + /* jshint -W101 */ + + // inlined ../resources/bpmnjs.png + var logoData = 'iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRFiMte9PrwldFwfcZPqtqN0+zEyOe1XLgjvuKncsJAZ70y6fXh3vDT////UrQV////G2zN+AAAABB0Uk5T////////////////////AOAjXRkAAAHDSURBVHjavJZJkoUgDEBJmAX8979tM8u3E6x20VlYJfFFMoL4vBDxATxZcakIOJTWSmxvKWVIkJ8jHvlRv1F2LFrVISCZI+tCtQx+XfewgVTfyY3plPiQEAzI3zWy+kR6NBhFBYeBuscJLOUuA2WVLpCjVIaFzrNQZArxAZKUQm6gsj37L9Cb7dnIBUKxENaaMJQqMpDXvSL+ktxdGRm2IsKgJGGPg7atwUG5CcFUEuSv+CwQqizTrvDTNXdMU2bMiDWZd8d7QIySWVRsb2vBBioxOFt4OinPBapL+neAb5KL5IJ8szOza2/DYoipUCx+CjO0Bpsv0V6mktNZ+k8rlABlWG0FrOpKYVo8DT3dBeLEjUBAj7moDogVii7nSS9QzZnFcOVBp1g2PyBQ3Vr5aIapN91VJy33HTJLC1iX2FY6F8gRdaAeIEfVONgtFCzZTmoLEdOjBDfsIOA6128gw3eu1shAajdZNAORxuQDJN5A5PbEG6gNIu24QJD5iNyRMZIr6bsHbCtCU/OaOaSvgkUyDMdDa1BXGf5HJ1To+/Ym6mCKT02Y+/Sa126ZKyd3jxhzpc1r8zVL6YM1Qy/kR4ABAFJ6iQUnivhAAAAAAElFTkSuQmCC'; + + /* jshint +W101 */ + + var linkMarkup = + '' + + '' + + ''; + if (container && container.appendChild) { + container.appendChild(domify(linkMarkup)); + } - assign(container.style, { - width: ensureUnit(options.width), - height: ensureUnit(options.height), - position: options.position - }); - /** - * The code in the area must not be changed, - * see http://bpmn.io/license for more information - * - * - */ + /* */ + } - /* jshint -W101 */ + Viewer.prototype.importXML = function(xml, done) { - // inlined ../resources/bpmnjs.png - var logoData = 'iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRFiMte9PrwldFwfcZPqtqN0+zEyOe1XLgjvuKncsJAZ70y6fXh3vDT////UrQV////G2zN+AAAABB0Uk5T////////////////////AOAjXRkAAAHDSURBVHjavJZJkoUgDEBJmAX8979tM8u3E6x20VlYJfFFMoL4vBDxATxZcakIOJTWSmxvKWVIkJ8jHvlRv1F2LFrVISCZI+tCtQx+XfewgVTfyY3plPiQEAzI3zWy+kR6NBhFBYeBuscJLOUuA2WVLpCjVIaFzrNQZArxAZKUQm6gsj37L9Cb7dnIBUKxENaaMJQqMpDXvSL+ktxdGRm2IsKgJGGPg7atwUG5CcFUEuSv+CwQqizTrvDTNXdMU2bMiDWZd8d7QIySWVRsb2vBBioxOFt4OinPBapL+neAb5KL5IJ8szOza2/DYoipUCx+CjO0Bpsv0V6mktNZ+k8rlABlWG0FrOpKYVo8DT3dBeLEjUBAj7moDogVii7nSS9QzZnFcOVBp1g2PyBQ3Vr5aIapN91VJy33HTJLC1iX2FY6F8gRdaAeIEfVONgtFCzZTmoLEdOjBDfsIOA6128gw3eu1shAajdZNAORxuQDJN5A5PbEG6gNIu24QJD5iNyRMZIr6bsHbCtCU/OaOaSvgkUyDMdDa1BXGf5HJ1To+/Ym6mCKT02Y+/Sa126ZKyd3jxhzpc1r8zVL6YM1Qy/kR4ABAFJ6iQUnivhAAAAAAElFTkSuQmCC'; + var self = this; - /* jshint +W101 */ + this.moddle = this.createModdle(); - var linkMarkup = - '' + - '' + - ''; - if(container && container.appendChild){ - container.appendChild(domify(linkMarkup)); - } - + this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) { - /* */ + if (err) { + err = checkValidationError(err); + return done(err); } - Viewer.prototype.importXML = function(xml, done) { + var parseWarnings = context.warnings; - var self = this; + self.importDefinitions(definitions, function(err, importWarnings) { + if (err) { + return done(err); + } - this.moddle = this.createModdle(); + done(null, parseWarnings.concat(importWarnings || [])); + }); + }); + }; - this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) { + Viewer.prototype.saveXML = function(options, done) { - if (err) { - err = checkValidationError(err); - return done(err); - } + if (!done) { + done = options; + options = {}; + } - var parseWarnings = context.warnings; + var definitions = this.definitions; - self.importDefinitions(definitions, function(err, importWarnings) { - if (err) { - return done(err); - } + if (!definitions) { + return done(new Error('no definitions loaded')); + } - done(null, parseWarnings.concat(importWarnings || [])); - }); - }); - }; + this.moddle.toXML(definitions, options, done); + }; - Viewer.prototype.saveXML = function(options, done) { - if (!done) { - done = options; - options = {}; - } + Viewer.prototype.createModdle = function() { + return new BpmnModdle(this.options.moddleExtensions); + }; - var definitions = this.definitions; + Viewer.prototype.saveSVG = function(options, done) { - if (!definitions) { - return done(new Error('no definitions loaded')); - } + if (!done) { + done = options; + options = {}; + } - this.moddle.toXML(definitions, options, done); - }; - + var canvas = this.get('canvas'); - Viewer.prototype.createModdle = function() { - return new BpmnModdle(this.options.moddleExtensions); - }; + var contentNode = canvas.getDefaultLayer(), + defsNode = canvas._svg.select('defs'); - Viewer.prototype.saveSVG = function(options, done) { + var contents = contentNode.innerSVG(), + defs = (defsNode && defsNode.outerSVG()) || ''; - if (!done) { - done = options; - options = {}; - } + var bbox = contentNode.getBBox(); - var canvas = this.get('canvas'); + var svg = + '\n' + + '\n' + + '\n' + + '' + + defs + contents + + ''; - var contentNode = canvas.getDefaultLayer(), - defsNode = canvas._svg.select('defs'); + done(null, svg); + }; - var contents = contentNode.innerSVG(), - defs = (defsNode && defsNode.outerSVG()) || ''; + Viewer.prototype.get = function(name) { - var bbox = contentNode.getBBox(); + if (!this.diagram) { + throw new Error('no diagram loaded'); + } - var svg = - '\n' + - '\n' + - '\n' + - '' + - defs + contents + - ''; + return this.diagram.get(name); + }; - done(null, svg); - }; + Viewer.prototype.invoke = function(fn) { - Viewer.prototype.get = function(name) { + if (!this.diagram) { + throw new Error('no diagram loaded'); + } - if (!this.diagram) { - throw new Error('no diagram loaded'); - } + return this.diagram.invoke(fn); + }; - return this.diagram.get(name); - }; + Viewer.prototype.importDefinitions = function(definitions, done) { - Viewer.prototype.invoke = function(fn) { + // use try/catch to not swallow synchronous exceptions + // that may be raised during model parsing + try { + if (this.diagram) { + this.clear(); + } - if (!this.diagram) { - throw new Error('no diagram loaded'); - } + this.definitions = definitions; - return this.diagram.invoke(fn); - }; + var diagram = this.diagram = this._createDiagram(this.options); - Viewer.prototype.importDefinitions = function(definitions, done) { + this._init(diagram); - // use try/catch to not swallow synchronous exceptions - // that may be raised during model parsing - try { - if (this.diagram) { - this.clear(); - } + Importer.importBpmnDiagram(diagram, definitions, done); + } catch (e) { + done(e); + } + }; - this.definitions = definitions; + Viewer.prototype._init = function(diagram) { + initListeners(diagram, this.__listeners || []); + }; - var diagram = this.diagram = this._createDiagram(this.options); + Viewer.prototype._createDiagram = function(options) { - this._init(diagram); + var modules = [].concat(options.modules || this.getModules(), options.additionalModules || []); - Importer.importBpmnDiagram(diagram, definitions, done); - } catch (e) { - done(e); - } - }; + // add self as an available service + modules.unshift({ + bpmnjs: ['value', this], + moddle: ['value', this.moddle] + }); - Viewer.prototype._init = function(diagram) { - initListeners(diagram, this.__listeners || []); - }; + options = omit(options, 'additionalModules'); - Viewer.prototype._createDiagram = function(options) { + options = assign(options, { + canvas: { + container: this.container + }, + modules: modules + }); - var modules = [].concat(options.modules || this.getModules(), options.additionalModules || []); + return new Diagram(options); + }; - // add self as an available service - modules.unshift({ - bpmnjs: ['value', this], - moddle: ['value', this.moddle] - }); - options = omit(options, 'additionalModules'); + Viewer.prototype.getModules = function() { + return this._modules; + }; - options = assign(options, { - canvas: { - container: this.container - }, - modules: modules - }); + /** + * Remove all drawn elements from the viewer. + * + * After calling this method the viewer can still be reused for opening another + * diagram. + */ + Viewer.prototype.clear = function() { + var diagram = this.diagram; - return new Diagram(options); - }; + if (diagram) { + diagram.destroy(); + } + }; + + /** + * Destroy the viewer instance and remove all its remainders from the document + * tree. + */ + Viewer.prototype.destroy = function() { + // clear underlying diagram + this.clear(); + + // remove container + domRemove(this.container); + }; + + /** + * Register an event listener on the viewer + * + * @param {String} + * event + * @param {Function} + * handler + */ + Viewer.prototype.on = function(event, handler) { + var diagram = this.diagram, + listeners = this.__listeners = this.__listeners || []; + + listeners.push({ + event: event, + handler: handler + }); + + if (diagram) { + diagram.get('eventBus').on(event, handler); + } + }; + + // modules the viewer is composed of + Viewer.prototype._modules = [ + require('./core'), + require('diagram-js/lib/features/selection'), + require('diagram-js/lib/features/overlays') + ]; + + module.exports = Viewer; + + }, { + "./core": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\core\\index.js", + "./import/Importer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Importer.js", + "bpmn-moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\index.js", + "diagram-js": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\index.js", + "diagram-js/lib/features/overlays": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\overlays\\index.js", + "diagram-js/lib/features/selection": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\selection\\index.js", + "lodash/lang/isNumber": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isNumber.js", + "lodash/lang/isString": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isString.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", + "lodash/object/omit": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\omit.js", + "min-dom/lib/domify": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\min-dom\\lib\\domify.js", + "min-dom/lib/query": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\min-dom\\lib\\query.js", + "min-dom/lib/remove": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\min-dom\\lib\\remove.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\core\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('../draw'), + require('../import') + ] + }; + }, { + "../draw": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\index.js", + "../import": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\BpmnRenderer.js": [function(require, module, exports) { + 'use strict'; + + var inherits = require('inherits'), + isArray = require('lodash/lang/isArray'), + isObject = require('lodash/lang/isObject'), + assign = require('lodash/object/assign'), + forEach = require('lodash/collection/forEach'), + every = require('lodash/collection/every'), + includes = require('lodash/collection/includes'), + some = require('lodash/collection/some'); + + var DefaultRenderer = require('diagram-js/lib/draw/Renderer'), + TextUtil = require('diagram-js/lib/util/Text'), + DiUtil = require('../util/DiUtil'); + + var createLine = DefaultRenderer.createLine; + + + function BpmnRenderer(events, styles, pathMap) { + + DefaultRenderer.call(this, styles); + + var TASK_BORDER_RADIUS = 10; + var INNER_OUTER_DIST = 3; + + var LABEL_STYLE = { + fontFamily: 'Arial, sans-serif', + fontSize: '12px' + }; + + var textUtil = new TextUtil({ + style: LABEL_STYLE, + size: { + width: 100 + } + }); + var markers = {}; - Viewer.prototype.getModules = function() { - return this._modules; - }; + function addMarker(id, element) { + markers[id] = element; + } - /** - * Remove all drawn elements from the viewer. - * - * After calling this method the viewer can still be reused for opening another - * diagram. - */ - Viewer.prototype.clear = function() { - var diagram = this.diagram; + function marker(id) { + return markers[id]; + } - if (diagram) { - diagram.destroy(); - } - }; + function initMarkers(svg) { - /** - * Destroy the viewer instance and remove all its remainders from the document - * tree. - */ - Viewer.prototype.destroy = function() { - // clear underlying diagram - this.clear(); + function createMarker(id, options) { + var attrs = assign({ + fill: 'black', + strokeWidth: 1, + strokeLinecap: 'round', + strokeDasharray: 'none' + }, options.attrs); - // remove container - domRemove(this.container); - }; + var ref = options.ref || { + x: 0, + y: 0 + }; - /** - * Register an event listener on the viewer - * - * @param {String} - * event - * @param {Function} - * handler - */ - Viewer.prototype.on = function(event, handler) { - var diagram = this.diagram, - listeners = this.__listeners = this.__listeners || []; + var scale = options.scale || 1; + + // fix for safari / chrome / firefox bug not correctly + // resetting stroke dash array + if (attrs.strokeDasharray === 'none') { + attrs.strokeDasharray = [10000, 1]; + } - listeners.push({ - event: event, - handler: handler + var marker = options.element + .attr(attrs) + .marker(0, 0, 20, 20, ref.x, ref.y) + .attr({ + markerWidth: 20 * scale, + markerHeight: 20 * scale }); - if (diagram) { - diagram.get('eventBus').on(event, handler); - } - }; + return addMarker(id, marker); + } - // modules the viewer is composed of - Viewer.prototype._modules = [ - require('./core'), - require('diagram-js/lib/features/selection'), - require('diagram-js/lib/features/overlays') - ]; - module.exports = Viewer; + createMarker('sequenceflow-end', { + element: svg.path('M 1 5 L 11 10 L 1 15 Z'), + ref: { + x: 11, + y: 10 + }, + scale: 0.5 + }); - }, { - "./core": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\core\\index.js", - "./import/Importer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Importer.js", - "bpmn-moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\index.js", - "diagram-js": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\index.js", - "diagram-js/lib/features/overlays": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\overlays\\index.js", - "diagram-js/lib/features/selection": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\selection\\index.js", - "lodash/lang/isNumber": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isNumber.js", - "lodash/lang/isString": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isString.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", - "lodash/object/omit": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\omit.js", - "min-dom/lib/domify": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\min-dom\\lib\\domify.js", - "min-dom/lib/query": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\min-dom\\lib\\query.js", - "min-dom/lib/remove": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\min-dom\\lib\\remove.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\core\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('../draw'), - require('../import') - ] - }; - }, { - "../draw": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\index.js", - "../import": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\BpmnRenderer.js": [function(require, module, exports) { - 'use strict'; + createMarker('messageflow-start', { + element: svg.circle(6, 6, 3.5), + attrs: { + fill: 'white', + stroke: 'black' + }, + ref: { + x: 6, + y: 6 + } + }); - var inherits = require('inherits'), - isArray = require('lodash/lang/isArray'), - isObject = require('lodash/lang/isObject'), - assign = require('lodash/object/assign'), - forEach = require('lodash/collection/forEach'), - every = require('lodash/collection/every'), - includes = require('lodash/collection/includes'), - some = require('lodash/collection/some'); + createMarker('messageflow-end', { + element: svg.path('m 1 5 l 0 -3 l 7 3 l -7 3 z'), + attrs: { + fill: 'white', + stroke: 'black', + strokeLinecap: 'butt' + }, + ref: { + x: 8.5, + y: 5 + } + }); - var DefaultRenderer = require('diagram-js/lib/draw/Renderer'), - TextUtil = require('diagram-js/lib/util/Text'), - DiUtil = require('../util/DiUtil'); + createMarker('data-association-end', { + element: svg.path('M 1 5 L 11 10 L 1 15'), + attrs: { + fill: 'white', + stroke: 'black' + }, + ref: { + x: 11, + y: 10 + }, + scale: 0.5 + }); - var createLine = DefaultRenderer.createLine; + createMarker('conditional-flow-marker', { + element: svg.path('M 0 10 L 8 6 L 16 10 L 8 14 Z'), + attrs: { + fill: 'white', + stroke: 'black' + }, + ref: { + x: -1, + y: 10 + }, + scale: 0.5 + }); + createMarker('conditional-default-flow-marker', { + element: svg.path('M 1 4 L 5 16'), + attrs: { + stroke: 'black' + }, + ref: { + x: -5, + y: 10 + }, + scale: 0.5 + }); + } - function BpmnRenderer(events, styles, pathMap) { + function computeStyle(custom, traits, defaultStyles) { + if (!isArray(traits)) { + defaultStyles = traits; + traits = []; + } - DefaultRenderer.call(this, styles); + return styles.style(traits || [], assign(defaultStyles, custom || {})); + } - var TASK_BORDER_RADIUS = 10; - var INNER_OUTER_DIST = 3; + function drawCircle(p, width, height, offset, attrs) { - var LABEL_STYLE = { - fontFamily: 'Arial, sans-serif', - fontSize: '12px' - }; + if (isObject(offset)) { + attrs = offset; + offset = 0; + } - var textUtil = new TextUtil({ - style: LABEL_STYLE, - size: { - width: 100 - } - }); + offset = offset || 0; - var markers = {}; + attrs = computeStyle(attrs, { + stroke: 'black', + strokeWidth: 2, + fill: 'white' + }); - function addMarker(id, element) { - markers[id] = element; - } + var cx = width / 2, + cy = height / 2; - function marker(id) { - return markers[id]; - } + return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr(attrs); + } - function initMarkers(svg) { + function drawRect(p, width, height, r, offset, attrs) { - function createMarker(id, options) { - var attrs = assign({ - fill: 'black', - strokeWidth: 1, - strokeLinecap: 'round', - strokeDasharray: 'none' - }, options.attrs); + if (isObject(offset)) { + attrs = offset; + offset = 0; + } - var ref = options.ref || { - x: 0, - y: 0 - }; + offset = offset || 0; - var scale = options.scale || 1; + attrs = computeStyle(attrs, { + stroke: 'black', + strokeWidth: 2, + fill: 'white' + }); - // fix for safari / chrome / firefox bug not correctly - // resetting stroke dash array - if (attrs.strokeDasharray === 'none') { - attrs.strokeDasharray = [10000, 1]; - } + return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr(attrs); + } - var marker = options.element - .attr(attrs) - .marker(0, 0, 20, 20, ref.x, ref.y) - .attr({ - markerWidth: 20 * scale, - markerHeight: 20 * scale - }); + function drawDiamond(p, width, height, attrs) { - return addMarker(id, marker); - } + var x_2 = width / 2; + var y_2 = height / 2; + var points = [x_2, 0, width, y_2, x_2, height, 0, y_2]; - createMarker('sequenceflow-end', { - element: svg.path('M 1 5 L 11 10 L 1 15 Z'), - ref: { - x: 11, - y: 10 - }, - scale: 0.5 - }); + attrs = computeStyle(attrs, { + stroke: 'black', + strokeWidth: 2, + fill: 'white' + }); - createMarker('messageflow-start', { - element: svg.circle(6, 6, 3.5), - attrs: { - fill: 'white', - stroke: 'black' - }, - ref: { - x: 6, - y: 6 - } - }); + return p.polygon(points).attr(attrs); + } - createMarker('messageflow-end', { - element: svg.path('m 1 5 l 0 -3 l 7 3 l -7 3 z'), - attrs: { - fill: 'white', - stroke: 'black', - strokeLinecap: 'butt' - }, - ref: { - x: 8.5, - y: 5 - } - }); + function drawLine(p, waypoints, attrs) { + attrs = computeStyle(attrs, ['no-fill'], { + stroke: 'black', + strokeWidth: 2, + fill: 'none' + }); - createMarker('data-association-end', { - element: svg.path('M 1 5 L 11 10 L 1 15'), - attrs: { - fill: 'white', - stroke: 'black' - }, - ref: { - x: 11, - y: 10 - }, - scale: 0.5 - }); + return createLine(waypoints, attrs).appendTo(p); + } - createMarker('conditional-flow-marker', { - element: svg.path('M 0 10 L 8 6 L 16 10 L 8 14 Z'), - attrs: { - fill: 'white', - stroke: 'black' - }, - ref: { - x: -1, - y: 10 - }, - scale: 0.5 - }); + function drawPath(p, d, attrs) { - createMarker('conditional-default-flow-marker', { - element: svg.path('M 1 4 L 5 16'), - attrs: { - stroke: 'black' - }, - ref: { - x: -5, - y: 10 - }, - scale: 0.5 - }); - } + attrs = computeStyle(attrs, ['no-fill'], { + strokeWidth: 2, + stroke: 'black' + }); - function computeStyle(custom, traits, defaultStyles) { - if (!isArray(traits)) { - defaultStyles = traits; - traits = []; - } + return p.path(d).attr(attrs); + } - return styles.style(traits || [], assign(defaultStyles, custom || {})); - } + function as(type) { + return function(p, element) { + return handlers[type](p, element); + }; + } - function drawCircle(p, width, height, offset, attrs) { + function renderer(type) { + return handlers[type]; + } - if (isObject(offset)) { - attrs = offset; - offset = 0; - } + function renderEventContent(element, p) { - offset = offset || 0; + var event = getSemantic(element); + var isThrowing = isThrowEvent(event); - attrs = computeStyle(attrs, { - stroke: 'black', - strokeWidth: 2, - fill: 'white' - }); + if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) { + return renderer('bpmn:MessageEventDefinition')(p, element, isThrowing); + } - var cx = width / 2, - cy = height / 2; + if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) { + return renderer('bpmn:TimerEventDefinition')(p, element, isThrowing); + } - return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr(attrs); - } + if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) { + return renderer('bpmn:ConditionalEventDefinition')(p, element); + } - function drawRect(p, width, height, r, offset, attrs) { + if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) { + return renderer('bpmn:SignalEventDefinition')(p, element, isThrowing); + } - if (isObject(offset)) { - attrs = offset; - offset = 0; - } + if (isTypedEvent(event, 'bpmn:CancelEventDefinition') && + isTypedEvent(event, 'bpmn:TerminateEventDefinition', { + parallelMultiple: false + })) { + return renderer('bpmn:MultipleEventDefinition')(p, element, isThrowing); + } - offset = offset || 0; + if (isTypedEvent(event, 'bpmn:CancelEventDefinition') && + isTypedEvent(event, 'bpmn:TerminateEventDefinition', { + parallelMultiple: true + })) { + return renderer('bpmn:ParallelMultipleEventDefinition')(p, element, isThrowing); + } - attrs = computeStyle(attrs, { - stroke: 'black', - strokeWidth: 2, - fill: 'white' - }); + if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) { + return renderer('bpmn:EscalationEventDefinition')(p, element, isThrowing); + } - return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr(attrs); - } + if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) { + return renderer('bpmn:LinkEventDefinition')(p, element, isThrowing); + } - function drawDiamond(p, width, height, attrs) { + if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) { + return renderer('bpmn:ErrorEventDefinition')(p, element, isThrowing); + } - var x_2 = width / 2; - var y_2 = height / 2; + if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) { + return renderer('bpmn:CancelEventDefinition')(p, element, isThrowing); + } - var points = [x_2, 0, width, y_2, x_2, height, 0, y_2]; + if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) { + return renderer('bpmn:CompensateEventDefinition')(p, element, isThrowing); + } - attrs = computeStyle(attrs, { - stroke: 'black', - strokeWidth: 2, - fill: 'white' - }); + if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) { + return renderer('bpmn:TerminateEventDefinition')(p, element, isThrowing); + } - return p.polygon(points).attr(attrs); - } + return null; + } - function drawLine(p, waypoints, attrs) { - attrs = computeStyle(attrs, ['no-fill'], { - stroke: 'black', - strokeWidth: 2, - fill: 'none' - }); + function renderLabel(p, label, options) { + return textUtil.createText(p, label || '', options).addClass('djs-label'); + } - return createLine(waypoints, attrs).appendTo(p); - } + function renderEmbeddedLabel(p, element, align) { + var semantic = getSemantic(element); + return renderLabel(p, semantic.name, { + box: element, + align: align, + padding: 5 + }); + } - function drawPath(p, d, attrs) { + function renderExternalLabel(p, element, align) { + var semantic = getSemantic(element); - attrs = computeStyle(attrs, ['no-fill'], { - strokeWidth: 2, - stroke: 'black' - }); + if (!semantic.name) { + element.hidden = true; + } - return p.path(d).attr(attrs); - } + return renderLabel(p, semantic.name, { + box: element, + align: align, + style: { + fontSize: '11px' + } + }); + } - function as(type) { - return function(p, element) { - return handlers[type](p, element); - }; - } + function renderLaneLabel(p, text, element) { + var textBox = renderLabel(p, text, { + box: { + height: 30, + width: element.height + }, + align: 'center-middle' + }); - function renderer(type) { - return handlers[type]; - } + var top = -1 * element.height; + textBox.transform( + 'rotate(270) ' + + 'translate(' + top + ',' + 0 + ')' + ); + } - function renderEventContent(element, p) { + function createPathFromConnection(connection) { + var waypoints = connection.waypoints; - var event = getSemantic(element); - var isThrowing = isThrowEvent(event); + var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y; + for (var i = 1; i < waypoints.length; i++) { + pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' '; + } + return pathData; + } - if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) { - return renderer('bpmn:MessageEventDefinition')(p, element, isThrowing); - } + var handlers = { + 'bpmn:Event': function(p, element, attrs) { + return drawCircle(p, element.width, element.height, attrs); + }, + 'bpmn:StartEvent': function(p, element) { + var attrs = {}; + var semantic = getSemantic(element); + + if (!semantic.isInterrupting) { + attrs = { + strokeDasharray: '6', + strokeLinecap: 'round' + }; + } - if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) { - return renderer('bpmn:TimerEventDefinition')(p, element, isThrowing); - } + var circle = renderer('bpmn:Event')(p, element, attrs); - if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) { - return renderer('bpmn:ConditionalEventDefinition')(p, element); - } + renderEventContent(element, p); - if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) { - return renderer('bpmn:SignalEventDefinition')(p, element, isThrowing); - } + return circle; + }, - if (isTypedEvent(event, 'bpmn:CancelEventDefinition') && - isTypedEvent(event, 'bpmn:TerminateEventDefinition', { - parallelMultiple: false - })) { - return renderer('bpmn:MultipleEventDefinition')(p, element, isThrowing); - } + 'bpmn:MultiBranchConnector': function(p, element) { + var attrs = {}; + element.height = 80; + element.width = 80; + var semantic = getSemantic(element); - if (isTypedEvent(event, 'bpmn:CancelEventDefinition') && - isTypedEvent(event, 'bpmn:TerminateEventDefinition', { - parallelMultiple: true - })) { - return renderer('bpmn:ParallelMultipleEventDefinition')(p, element, isThrowing); - } + if (!semantic.isInterrupting) { + attrs = { + strokeDasharray: '6', + strokeLinecap: 'round' + }; + } - if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) { - return renderer('bpmn:EscalationEventDefinition')(p, element, isThrowing); - } + var circle = renderer('bpmn:Event')(p, element, attrs); + var height = element.height / 2; + var width = element.width / 2; + var value = Math.round((height + width) / 4); + drawLine(p, [{ + x: 0, + y: Math.round(element.height / 2) + }, { + x: element.width, + y: Math.round(element.height / 2) + }]); + drawLine(p, [{ + x: Math.round(element.width / 2), + y: 0 + }, { + x: Math.round(element.width / 2), + y: element.height + }]); + renderEventContent(element, p); + + return circle; + }, + 'bpmn:ParentReturn': function(p, element) { + var attrs = {}; + var semantic = getSemantic(element); + + if (!semantic.isInterrupting) { + attrs = { + strokeDasharray: '6', + strokeLinecap: 'round' + }; + } - if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) { - return renderer('bpmn:LinkEventDefinition')(p, element, isThrowing); - } + // var circle = renderer('bpmn:Event')(p, element, attrs); + drawLine(p, [{ + x: 0, + y: 0 + }, { + x: 0, + y: element.height / 2 + }]); + drawLine(p, [{ + x: 0, + y: element.height / 2 + }, { + x: element.width / 2, + y: element.height + }]); + drawLine(p, [{ + x: 0, + y: 0 + }, { + x: element.width, + y: 0 + }]); + drawLine(p, [{ + x: element.width, + y: 0 + }, { + x: element.width, + y: element.height / 2 + }]); + drawLine(p, [ - if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) { - return renderer('bpmn:ErrorEventDefinition')(p, element, isThrowing); - } + { + x: element.width, + y: element.height / 2 + }, { + x: element.width / 2, + y: element.height + } + ]); + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center' + }); + renderEventContent(element, p); - if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) { - return renderer('bpmn:CancelEventDefinition')(p, element, isThrowing); - } + return p; + }, + 'bpmn:SubProcessCall': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) { - return renderer('bpmn:CompensateEventDefinition')(p, element, isThrowing); - } + var expandedPool = DiUtil.isExpanded(element); - if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) { - return renderer('bpmn:TerminateEventDefinition')(p, element, isThrowing); - } + if (expandedPool) { + drawLine(p, [{ + x: 20, + y: 0 + }, { + x: 20, + y: element.height + }]); - return null; - } + drawLine(p, [{ + x: element.width - 20, + y: 0 + }, { + x: element.width - 20, + y: element.height + }]); + + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - function renderLabel(p, label, options) { - return textUtil.createText(p, label || '', options).addClass('djs-label'); - } + /* + * var text = getSemantic(element).name; renderLaneLabel(p, + * text, element); + */ + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - function renderEmbeddedLabel(p, element, align) { - var semantic = getSemantic(element); - return renderLabel(p, semantic.name, { - box: element, - align: align, - padding: 5 - }); - } + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - function renderExternalLabel(p, element, align) { - var semantic = getSemantic(element); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - if (!semantic.name) { - element.hidden = true; - } + return lane; - return renderLabel(p, semantic.name, { - box: element, - align: align, - style: { - fontSize: '11px' - } - }); - } - function renderLaneLabel(p, text, element) { - var textBox = renderLabel(p, text, { - box: { - height: 30, - width: element.height - }, - align: 'center-middle' - }); + }, + 'bpmn:InitiateProcess': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - var top = -1 * element.height; - textBox.transform( - 'rotate(270) ' + - 'translate(' + top + ',' + 0 + ')' - ); - } + var expandedPool = DiUtil.isExpanded(element); + openDiagram(newDiagramXML); + if (expandedPool) { + drawLine(p, [{ + x: 0, + y: 20 + }, { + x: element.width, + y: 20 + }]); - function createPathFromConnection(connection) { - var waypoints = connection.waypoints; + drawLine(p, [{ + x: 20, + y: 0 + }, { + x: 20, + y: element.height + }]); + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y; - for (var i = 1; i < waypoints.length; i++) { - pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' '; - } - return pathData; - } + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - var handlers = { - 'bpmn:Event': function(p, element, attrs) { - return drawCircle(p, element.width, element.height, attrs); - }, - 'bpmn:StartEvent': function(p, element) { - var attrs = {}; - var semantic = getSemantic(element); - - if (!semantic.isInterrupting) { - attrs = { - strokeDasharray: '6', - strokeLinecap: 'round' - }; - } + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - var circle = renderer('bpmn:Event')(p, element, attrs); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - renderEventContent(element, p); + return lane; - return circle; - }, - - 'bpmn:MultiBranchConnector': function(p, element) { - var attrs = {}; - element.height=80; - element.width=80; - var semantic = getSemantic(element); - - if (!semantic.isInterrupting) { - attrs = { - strokeDasharray: '6', - strokeLinecap: 'round' - }; - } - var circle = renderer('bpmn:Event')(p, element, attrs); - var height = element.height/2; - var width = element.width/2; - var value=Math.round((height+width)/4); - drawLine(p, [{ - x: 0, - y: Math.round(element.height / 2) - }, { - x: element.width, - y: Math.round(element.height / 2) - }]); - drawLine(p, [{ - x: Math.round(element.width / 2), - y: 0 - }, { - x: Math.round(element.width / 2), - y: element.height - }]); - renderEventContent(element, p); - - return circle; - }, - 'bpmn:ParentReturn': function(p, element) { - var attrs = {}; - var semantic = getSemantic(element); - - if (!semantic.isInterrupting) { - attrs = { - strokeDasharray: '6', - strokeLinecap: 'round' - }; - } + }, + 'bpmn:Collector': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - // var circle = renderer('bpmn:Event')(p, element, attrs); - drawLine(p, [{ - x: 0, - y: 0 - }, { - x: 0, - y: element.height / 2 - }]); - drawLine(p, [{ - x: 0, - y: element.height / 2 - }, { - x: element.width / 2, - y: element.height - }]); - drawLine(p, [{ - x: 0, - y: 0 - }, { - x: element.width, - y: 0 - }]); - drawLine(p, [{ - x: element.width, - y: 0 - }, { - x: element.width, - y: element.height / 2 - }]); - drawLine(p, [ - - { - x: element.width, - y: element.height / 2 - }, { - x: element.width / 2, - y: element.height - } - ]); - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center' - }); - renderEventContent(element, p); + var expandedPool = DiUtil.isExpanded(element); - return p; - }, - 'bpmn:SubProcessCall': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + if (expandedPool) { + drawLine(p, [{ + x: element.width, + y: 80 + }, { + x: element.width, + y: 20 + }]); - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - drawLine(p, [{ - x: 20, - y: 0 - }, { - x: 20, - y: element.height - }]); - - drawLine(p, [{ - x: element.width - 20, - y: 0 - }, { - x: element.width - 20, - y: element.height - }]); - - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - - /* - * var text = getSemantic(element).name; renderLaneLabel(p, - * text, element); - */ - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + drawLine(p, [{ + x: 20, + y: 0 + }, { + x: 20, + y: element.height + }]); + var text2 = getSemantic(element).name; + if (text2 == undefined) { + text2 = 'Collector'; + } - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - return lane; + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - }, - 'bpmn:InitiateProcess': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + return lane; - var expandedPool = DiUtil.isExpanded(element); - openDiagram(newDiagramXML); - if (expandedPool) { - drawLine(p, [{ - x: 0, - y: 20 - }, { - x: element.width, - y: 20 - }]); - - drawLine(p, [{ - x: 20, - y: 0 - }, { - x: 20, - y: element.height - }]); - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + }, + 'bpmn:VesCollector': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + var expandedPool = DiUtil.isExpanded(element); - return lane; + if (expandedPool) { + drawLine(p, [{ + x: element.width, + y: 80 + }, { + x: element.width, + y: 20 + }]); + drawLine(p, [{ + x: 20, + y: 0 + }, { + x: 20, + y: element.height + }]); + + textUtil.createText(p, "V", { + align: 'left-top', + 'padding': { + top: 0, + left: 5, + right: element.width - 20, + bottom: 0 + } + }); + textUtil.createText(p, "E", { + align: 'left-top', + 'padding': { + top: 12, + left: 5, + right: element.width - 20, + bottom: 0 + } + }); + textUtil.createText(p, "S", { + align: 'left-top', + 'padding': { + top: 24, + left: 5, + right: element.width - 20, + bottom: 0 + } + }); - }, - 'bpmn:Collector': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + var text2 = getSemantic(element).name; + if (text2 == undefined) { + text2 = 'VesCollector'; + } - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - drawLine(p, [{ - x: element.width, - y: 80 - }, { - x: element.width, - y: 20 - }]); - - drawLine(p, [{ - x: 20, - y: 0 - }, { - x: 20, - y: element.height - }]); - var text2 = getSemantic(element).name; - if(text2 == undefined ) - { - text2 = 'Collector'; - } - - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - return lane; + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } + return lane; + }, - }, - 'bpmn:VesCollector': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + 'bpmn:Holmes': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - drawLine(p, [{ - x: element.width, - y: 80 - }, { - x: element.width, - y: 20 - }]); - - drawLine(p, [{ - x: 20, - y: 0 - }, { - x: 20, - y: element.height - }]); - - textUtil.createText(p, "V", { align: 'left-top', 'padding': {top:0, left:5, right:element.width - 20, bottom:0} }); - textUtil.createText(p, "E", { align: 'left-top', 'padding': {top:12, left:5, right:element.width - 20, bottom:0} }); - textUtil.createText(p, "S", { align: 'left-top', 'padding': {top:24, left:5, right:element.width - 20, bottom:0} }); - - var text2 = getSemantic(element).name; - if(text2 == undefined ) - { - text2 = 'VesCollector'; - } + var expandedPool = DiUtil.isExpanded(element); - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); + var instanceName = getSemantic(element).name; + if (expandedPool) { - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + if (instanceName == undefined) { + instanceName = 'Holmes'; + } - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + // add holmes 'icon' + var attrs = computeStyle({}, { + stroke: 'black', + strokeWidth: 1, + fill: 'white' + }); + p.circle(15, 15, 10).attr(attrs) + textUtil.createText(p, "H", { + align: 'left-top', + 'padding': { + top: 6, + left: 11 + } + }); + } - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + renderLabel(p, instanceName, { + box: element, + align: 'center-middle' + }); - return lane; - }, + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - 'bpmn:Holmes': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - var expandedPool = DiUtil.isExpanded(element); + return lane; + }, - var instanceName = getSemantic(element).name; - if (expandedPool) { - if (instanceName == undefined) { - instanceName = 'Holmes'; - } + 'bpmn:StringMatch': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - // add holmes 'icon' - var attrs = computeStyle({}, { - stroke: 'black', - strokeWidth: 1, - fill: 'white' - }); - p.circle(15, 15, 10).attr(attrs) - textUtil.createText(p, "H", { align: 'left-top', 'padding': { top:6, left:11 } }); - } + var expandedPool = DiUtil.isExpanded(element); - renderLabel(p, instanceName, { - box: element, - align: 'center-middle' - }); + if (expandedPool) { - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + drawLine(p, [{ + x: 0, + y: 20 + }, { + x: element.width, + y: 20 + }]); + var text2 = getSemantic(element).name; + if (text2 == undefined) { + text2 = 'StringMatch'; + } + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - return lane; - }, + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - 'bpmn:StringMatch': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + return lane; - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - - drawLine(p, [{ - x: 0, - y: 20 - }, { - x: element.width, - y: 20 - }]); - var text2 = getSemantic(element).name; - if(text2 == undefined ) - { - text2 = 'StringMatch'; - } - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + }, - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + 'bpmn:TCA': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + var expandedPool = DiUtil.isExpanded(element); - return lane; + if (expandedPool) { - }, + drawLine(p, [{ + x: 0, + y: element.height - 20 + }, { + x: element.width, + y: element.height - 20 + }]); + var text2 = getSemantic(element).name; + if (text2 == undefined) { + text2 = 'TCA'; + } + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - 'bpmn:TCA': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - - - drawLine(p, [{ - x: 0, - y: element.height - 20 - }, { - x: element.width, - y: element.height - 20 - }]); - var text2 = getSemantic(element).name; - if(text2 == undefined ) - { - text2 = 'TCA'; - } - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + return lane; - return lane; + }, + 'bpmn:GOC': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - }, - 'bpmn:GOC': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + var expandedPool = DiUtil.isExpanded(element); - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - - - - drawLine(p, [{ - x: element.width/2, - y: element.height - }, { - x: element.width, - y: element.height/2 - }]); - var text2 = getSemantic(element).name; - if(text2 == undefined ) - { - text2 = 'GOC'; - } - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + if (expandedPool) { - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } - return lane; + drawLine(p, [{ + x: element.width / 2, + y: element.height + }, { + x: element.width, + y: element.height / 2 + }]); + var text2 = getSemantic(element).name; + if (text2 == undefined) { + text2 = 'GOC'; + } + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - }, - 'bpmn:Policy': function(p, element) { - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - - - - drawLine(p, [{ - x: 0, - y: element.height/2 - }, { - x: element.width/2, - y: 0 - }]); - var text2 = getSemantic(element).name; - if(text2 == undefined ) - { - text2 = 'Policy'; - } - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + return lane; - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } - return lane; + }, + 'bpmn:Policy': function(p, element) { + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); + var expandedPool = DiUtil.isExpanded(element); - }, - 'bpmn:MessageEventDefinition': function(p, element, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_MESSAGE', { - xScaleFactor: 0.9, - yScaleFactor: 0.9, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.235, - my: 0.315 - } - }); + if (expandedPool) { - var fill = isThrowing ? 'black' : 'white'; - var stroke = isThrowing ? 'white' : 'black'; - var messagePath = drawPath(p, pathData, { - strokeWidth: 1, - fill: fill, - stroke: stroke - }); - return messagePath; - }, - 'bpmn:TimerEventDefinition': function(p, element) { + drawLine(p, [{ + x: 0, + y: element.height / 2 + }, { + x: element.width / 2, + y: 0 + }]); + var text2 = getSemantic(element).name; + if (text2 == undefined) { + text2 = 'Policy'; + } + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); - var circle = drawCircle(p, element.width, element.height, 0.2 * element.height, { - strokeWidth: 2 - }); + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', { - xScaleFactor: 0.75, - yScaleFactor: 0.75, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.5, - my: 0.5 - } - }); + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - drawPath(p, pathData, { - strokeWidth: 2, - strokeLinecap: 'square' - }); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - for (var i = 0; i < 12; i++) { + return lane; - var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', { - xScaleFactor: 0.75, - yScaleFactor: 0.75, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.5, - my: 0.5 - } - }); - var width = element.width / 2; - var height = element.height / 2; + }, + 'bpmn:MessageEventDefinition': function(p, element, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_MESSAGE', { + xScaleFactor: 0.9, + yScaleFactor: 0.9, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.235, + my: 0.315 + } + }); - drawPath(p, linePathData, { - strokeWidth: 1, - strokeLinecap: 'square', - transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')' - }); - } + var fill = isThrowing ? 'black' : 'white'; + var stroke = isThrowing ? 'white' : 'black'; - return circle; - }, - 'bpmn:EscalationEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_ESCALATION', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.5, - my: 0.555 - } - }); + var messagePath = drawPath(p, pathData, { + strokeWidth: 1, + fill: fill, + stroke: stroke + }); - var fill = isThrowing ? 'black' : 'none'; + return messagePath; + }, + 'bpmn:TimerEventDefinition': function(p, element) { - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }); - }, - 'bpmn:ConditionalEventDefinition': function(p, event) { - var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.5, - my: 0.222 - } - }); + var circle = drawCircle(p, element.width, element.height, 0.2 * element.height, { + strokeWidth: 2 + }); - return drawPath(p, pathData, { - strokeWidth: 1 - }); - }, - 'bpmn:LinkEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_LINK', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.57, - my: 0.263 - } - }); + var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', { + xScaleFactor: 0.75, + yScaleFactor: 0.75, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.5, + my: 0.5 + } + }); - var fill = isThrowing ? 'black' : 'none'; + drawPath(p, pathData, { + strokeWidth: 2, + strokeLinecap: 'square' + }); - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }); - }, - 'bpmn:ErrorEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_ERROR', { - xScaleFactor: 1.1, - yScaleFactor: 1.1, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.2, - my: 0.722 - } - }); + for (var i = 0; i < 12; i++) { - var fill = isThrowing ? 'black' : 'none'; + var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', { + xScaleFactor: 0.75, + yScaleFactor: 0.75, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.5, + my: 0.5 + } + }); - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }); - }, - 'bpmn:CancelEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', { - xScaleFactor: 1.0, - yScaleFactor: 1.0, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.638, - my: -0.055 - } - }); + var width = element.width / 2; + var height = element.height / 2; - var fill = isThrowing ? 'black' : 'none'; + drawPath(p, linePathData, { + strokeWidth: 1, + strokeLinecap: 'square', + transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')' + }); + } - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }).transform('rotate(45)'); - }, - 'bpmn:CompensateEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.201, - my: 0.472 - } - }); + return circle; + }, + 'bpmn:EscalationEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_ESCALATION', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.5, + my: 0.555 + } + }); - var fill = isThrowing ? 'black' : 'none'; + var fill = isThrowing ? 'black' : 'none'; - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }); - }, - 'bpmn:SignalEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_SIGNAL', { - xScaleFactor: 0.9, - yScaleFactor: 0.9, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.5, - my: 0.2 - } - }); + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }); + }, + 'bpmn:ConditionalEventDefinition': function(p, event) { + var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.5, + my: 0.222 + } + }); - var fill = isThrowing ? 'black' : 'none'; + return drawPath(p, pathData, { + strokeWidth: 1 + }); + }, + 'bpmn:LinkEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_LINK', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.57, + my: 0.263 + } + }); - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }); - }, - 'bpmn:MultipleEventDefinition': function(p, event, isThrowing) { - var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', { - xScaleFactor: 1.1, - yScaleFactor: 1.1, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.222, - my: 0.36 - } - }); + var fill = isThrowing ? 'black' : 'none'; - var fill = isThrowing ? 'black' : 'none'; + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }); + }, + 'bpmn:ErrorEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_ERROR', { + xScaleFactor: 1.1, + yScaleFactor: 1.1, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.2, + my: 0.722 + } + }); - return drawPath(p, pathData, { - strokeWidth: 1, - fill: fill - }); - }, - 'bpmn:ParallelMultipleEventDefinition': function(p, event) { - var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', { - xScaleFactor: 1.2, - yScaleFactor: 1.2, - containerWidth: event.width, - containerHeight: event.height, - position: { - mx: 0.458, - my: 0.194 - } - }); + var fill = isThrowing ? 'black' : 'none'; - return drawPath(p, pathData, { - strokeWidth: 1 - }); - }, - 'bpmn:EndEvent': function(p, element) { - var circle = renderer('bpmn:Event')(p, element, { - strokeWidth: 4 - }); + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }); + }, + 'bpmn:CancelEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', { + xScaleFactor: 1.0, + yScaleFactor: 1.0, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.638, + my: -0.055 + } + }); - renderEventContent(element, p, true); + var fill = isThrowing ? 'black' : 'none'; + + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }).transform('rotate(45)'); + }, + 'bpmn:CompensateEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.201, + my: 0.472 + } + }); - return circle; - }, - 'bpmn:TerminateEventDefinition': function(p, element) { - var circle = drawCircle(p, element.width, element.height, 8, { - strokeWidth: 4, - fill: 'black' - }); - - return circle; - }, - 'bpmn:IntermediateEvent': function(p, element) { - var outer = renderer('bpmn:Event')(p, element, { - strokeWidth: 1 - }); - /* inner */ - drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { - strokeWidth: 1, - fill: 'none' - }); + var fill = isThrowing ? 'black' : 'none'; - renderEventContent(element, p); + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }); + }, + 'bpmn:SignalEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_SIGNAL', { + xScaleFactor: 0.9, + yScaleFactor: 0.9, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.5, + my: 0.2 + } + }); - return outer; - }, - 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'), - 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'), + var fill = isThrowing ? 'black' : 'none'; - 'bpmn:Activity': function(p, element, attrs) { - return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, attrs); - }, + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }); + }, + 'bpmn:MultipleEventDefinition': function(p, event, isThrowing) { + var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', { + xScaleFactor: 1.1, + yScaleFactor: 1.1, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.222, + my: 0.36 + } + }); - 'bpmn:Task': function(p, element, attrs) { - var rect = renderer('bpmn:Activity')(p, element, attrs); - renderEmbeddedLabel(p, element, 'center-middle'); - attachTaskMarkers(p, element); - return rect; - }, - 'bpmn:ServiceTask': function(p, element) { - var task = renderer('bpmn:Task')(p, element); + var fill = isThrowing ? 'black' : 'none'; - var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', { - abspos: { - x: 12, - y: 18 - } - }); + return drawPath(p, pathData, { + strokeWidth: 1, + fill: fill + }); + }, + 'bpmn:ParallelMultipleEventDefinition': function(p, event) { + var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', { + xScaleFactor: 1.2, + yScaleFactor: 1.2, + containerWidth: event.width, + containerHeight: event.height, + position: { + mx: 0.458, + my: 0.194 + } + }); - /* service bg */ - drawPath(p, pathDataBG, { - strokeWidth: 1, - fill: 'none' - }); + return drawPath(p, pathData, { + strokeWidth: 1 + }); + }, + 'bpmn:EndEvent': function(p, element) { + var circle = renderer('bpmn:Event')(p, element, { + strokeWidth: 4 + }); - var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', { - abspos: { - x: 17.2, - y: 18 - } - }); + renderEventContent(element, p, true); - /* service fill */ - drawPath(p, fillPathData, { - strokeWidth: 0, - stroke: 'none', - fill: 'white' - }); + return circle; + }, + 'bpmn:TerminateEventDefinition': function(p, element) { + var circle = drawCircle(p, element.width, element.height, 8, { + strokeWidth: 4, + fill: 'black' + }); - var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', { - abspos: { - x: 17, - y: 22 - } - }); + return circle; + }, + 'bpmn:IntermediateEvent': function(p, element) { + var outer = renderer('bpmn:Event')(p, element, { + strokeWidth: 1 + }); + /* inner */ + drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { + strokeWidth: 1, + fill: 'none' + }); - /* service */ - drawPath(p, pathData, { - strokeWidth: 1, - fill: 'white' - }); + renderEventContent(element, p); - return task; - }, - 'bpmn:UserTask': function(p, element) { - var task = renderer('bpmn:Task')(p, element); + return outer; + }, + 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'), + 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'), - var x = 15; - var y = 12; + 'bpmn:Activity': function(p, element, attrs) { + return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, attrs); + }, - var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', { - abspos: { - x: x, - y: y - } - }); + 'bpmn:Task': function(p, element, attrs) { + var rect = renderer('bpmn:Activity')(p, element, attrs); + renderEmbeddedLabel(p, element, 'center-middle'); + attachTaskMarkers(p, element); + return rect; + }, + 'bpmn:ServiceTask': function(p, element) { + var task = renderer('bpmn:Task')(p, element); - /* user path */ - drawPath(p, pathData, { - strokeWidth: 0.5, - fill: 'none' - }); + var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', { + abspos: { + x: 12, + y: 18 + } + }); - var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', { - abspos: { - x: x, - y: y - } - }); + /* service bg */ + drawPath(p, pathDataBG, { + strokeWidth: 1, + fill: 'none' + }); - /* user2 path */ - drawPath(p, pathData2, { - strokeWidth: 0.5, - fill: 'none' - }); + var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', { + abspos: { + x: 17.2, + y: 18 + } + }); - var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', { - abspos: { - x: x, - y: y - } - }); + /* service fill */ + drawPath(p, fillPathData, { + strokeWidth: 0, + stroke: 'none', + fill: 'white' + }); - /* user3 path */ - drawPath(p, pathData3, { - strokeWidth: 0.5, - fill: 'black' - }); + var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', { + abspos: { + x: 17, + y: 22 + } + }); - return task; - }, - 'bpmn:ManualTask': function(p, element) { - var task = renderer('bpmn:Task')(p, element); + /* service */ + drawPath(p, pathData, { + strokeWidth: 1, + fill: 'white' + }); - var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', { - abspos: { - x: 17, - y: 15 - } - }); + return task; + }, + 'bpmn:UserTask': function(p, element) { + var task = renderer('bpmn:Task')(p, element); - /* manual path */ - drawPath(p, pathData, { - strokeWidth: 0.25, - fill: 'white', - stroke: 'black' - }); + var x = 15; + var y = 12; - return task; - }, - 'bpmn:SendTask': function(p, element) { - var task = renderer('bpmn:Task')(p, element); - - var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: 21, - containerHeight: 14, - position: { - mx: 0.285, - my: 0.357 - } - }); + var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', { + abspos: { + x: x, + y: y + } + }); - /* send path */ - drawPath(p, pathData, { - strokeWidth: 1, - fill: 'black', - stroke: 'white' - }); + /* user path */ + drawPath(p, pathData, { + strokeWidth: 0.5, + fill: 'none' + }); - return task; - }, - 'bpmn:ReceiveTask': function(p, element) { - var semantic = getSemantic(element); + var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', { + abspos: { + x: x, + y: y + } + }); - var task = renderer('bpmn:Task')(p, element); - var pathData; + /* user2 path */ + drawPath(p, pathData2, { + strokeWidth: 0.5, + fill: 'none' + }); - if (semantic.instantiate) { - drawCircle(p, 28, 28, 20 * 0.22, { - strokeWidth: 1 - }); + var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', { + abspos: { + x: x, + y: y + } + }); - pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', { - abspos: { - x: 7.77, - y: 9.52 - } - }); - } else { + /* user3 path */ + drawPath(p, pathData3, { + strokeWidth: 0.5, + fill: 'black' + }); - pathData = pathMap.getScaledPath('TASK_TYPE_SEND', { - xScaleFactor: 0.9, - yScaleFactor: 0.9, - containerWidth: 21, - containerHeight: 14, - position: { - mx: 0.3, - my: 0.4 - } - }); - } + return task; + }, + 'bpmn:ManualTask': function(p, element) { + var task = renderer('bpmn:Task')(p, element); - /* receive path */ - drawPath(p, pathData, { - strokeWidth: 1 - }); + var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', { + abspos: { + x: 17, + y: 15 + } + }); - return task; - }, - 'bpmn:ScriptTask': function(p, element) { - var task = renderer('bpmn:Task')(p, element); + /* manual path */ + drawPath(p, pathData, { + strokeWidth: 0.25, + fill: 'white', + stroke: 'black' + }); - var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', { - abspos: { - x: 15, - y: 20 - } - }); + return task; + }, + 'bpmn:SendTask': function(p, element) { + var task = renderer('bpmn:Task')(p, element); - /* script path */ - drawPath(p, pathData, { - strokeWidth: 1 - }); + var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: 21, + containerHeight: 14, + position: { + mx: 0.285, + my: 0.357 + } + }); - return task; - }, - 'bpmn:BusinessRuleTask': function(p, element) { - var task = renderer('bpmn:Task')(p, element); + /* send path */ + drawPath(p, pathData, { + strokeWidth: 1, + fill: 'black', + stroke: 'white' + }); - var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', { - abspos: { - x: 8, - y: 8 - } - }); + return task; + }, + 'bpmn:ReceiveTask': function(p, element) { + var semantic = getSemantic(element); - var businessHeaderPath = drawPath(p, headerPathData); - businessHeaderPath.attr({ - strokeWidth: 1, - fill: 'AAA' - }); + var task = renderer('bpmn:Task')(p, element); + var pathData; - var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', { - abspos: { - x: 8, - y: 8 - } - }); + if (semantic.instantiate) { + drawCircle(p, 28, 28, 20 * 0.22, { + strokeWidth: 1 + }); - var businessPath = drawPath(p, headerData); - businessPath.attr({ - strokeWidth: 1 - }); + pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', { + abspos: { + x: 7.77, + y: 9.52 + } + }); + } else { + + pathData = pathMap.getScaledPath('TASK_TYPE_SEND', { + xScaleFactor: 0.9, + yScaleFactor: 0.9, + containerWidth: 21, + containerHeight: 14, + position: { + mx: 0.3, + my: 0.4 + } + }); + } - return task; - }, - 'bpmn:SubProcess': function(p, element, attrs) { - var rect = renderer('bpmn:Activity')(p, element, attrs); + /* receive path */ + drawPath(p, pathData, { + strokeWidth: 1 + }); - var semantic = getSemantic(element); + return task; + }, + 'bpmn:ScriptTask': function(p, element) { + var task = renderer('bpmn:Task')(p, element); - var expanded = DiUtil.isExpanded(semantic); + var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', { + abspos: { + x: 15, + y: 20 + } + }); - var isEventSubProcess = !!semantic.triggeredByEvent; - if (isEventSubProcess) { - rect.attr({ - strokeDasharray: '1,2' - }); - } + /* script path */ + drawPath(p, pathData, { + strokeWidth: 1 + }); - renderEmbeddedLabel(p, element, expanded ? 'center-top' : 'center-middle'); + return task; + }, + 'bpmn:BusinessRuleTask': function(p, element) { + var task = renderer('bpmn:Task')(p, element); - if (expanded) { - attachTaskMarkers(p, element); - } else { - attachTaskMarkers(p, element, ['SubProcessMarker']); - } + var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', { + abspos: { + x: 8, + y: 8 + } + }); - return rect; - }, - 'bpmn:AdHocSubProcess': function(p, element) { - return renderer('bpmn:SubProcess')(p, element); - }, - 'bpmn:Transaction': function(p, element) { - var outer = renderer('bpmn:SubProcess')(p, element); + var businessHeaderPath = drawPath(p, headerPathData); + businessHeaderPath.attr({ + strokeWidth: 1, + fill: 'AAA' + }); - var innerAttrs = styles.style(['no-fill', 'no-events']); + var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', { + abspos: { + x: 8, + y: 8 + } + }); - /* inner path */ - drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs); + var businessPath = drawPath(p, headerData); + businessPath.attr({ + strokeWidth: 1 + }); - return outer; - }, - 'bpmn:CallActivity': function(p, element) { - return renderer('bpmn:Task')(p, element, { - strokeWidth: 5 - }); - }, - 'bpmn:Participant': function(p, element) { + return task; + }, + 'bpmn:SubProcess': function(p, element, attrs) { + var rect = renderer('bpmn:Activity')(p, element, attrs); - var lane = renderer('bpmn:Lane')(p, element, { - fill: 'White' - }); + var semantic = getSemantic(element); - var expandedPool = DiUtil.isExpanded(element); - - if (expandedPool) { - drawLine(p, [{ - x: 30, - y: 0 - }, { - x: 30, - y: element.height - }]); - var text = getSemantic(element).name; - renderLaneLabel(p, text, element); - } else { - // Collapsed pool draw text inline - var text2 = getSemantic(element).name; - renderLabel(p, text2, { - box: element, - align: 'center-middle' - }); - } + var expanded = DiUtil.isExpanded(semantic); - var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); + var isEventSubProcess = !!semantic.triggeredByEvent; + if (isEventSubProcess) { + rect.attr({ + strokeDasharray: '1,2' + }); + } - if (participantMultiplicity) { - renderer('ParticipantMultiplicityMarker')(p, element); - } + renderEmbeddedLabel(p, element, expanded ? 'center-top' : 'center-middle'); - return lane; - }, - 'bpmn:Lane': function(p, element, attrs) { - var rect = drawRect(p, element.width, element.height, 0, attrs || { - fill: 'none' - }); + if (expanded) { + attachTaskMarkers(p, element); + } else { + attachTaskMarkers(p, element, ['SubProcessMarker']); + } - var semantic = getSemantic(element); + return rect; + }, + 'bpmn:AdHocSubProcess': function(p, element) { + return renderer('bpmn:SubProcess')(p, element); + }, + 'bpmn:Transaction': function(p, element) { + var outer = renderer('bpmn:SubProcess')(p, element); - if (semantic.$type === 'bpmn:Lane') { - var text = semantic.name; - renderLaneLabel(p, text, element); - } + var innerAttrs = styles.style(['no-fill', 'no-events']); - return rect; - }, - 'bpmn:InclusiveGateway': function(p, element) { - var diamond = drawDiamond(p, element.width, element.height); + /* inner path */ + drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs); - /* circle path */ - drawCircle(p, element.width, element.height, element.height * 0.24, { - strokeWidth: 2.5, - fill: 'none' - }); + return outer; + }, + 'bpmn:CallActivity': function(p, element) { + return renderer('bpmn:Task')(p, element, { + strokeWidth: 5 + }); + }, + 'bpmn:Participant': function(p, element) { - return diamond; - }, - 'bpmn:ExclusiveGateway': function(p, element) { - var diamond = drawDiamond(p, element.width, element.height); - renderEmbeddedLabel(p, element, 'center-middle'); - - var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', { - xScaleFactor: 0.4, - yScaleFactor: 0.4, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.32, - my: 0.3 - } - }); + var lane = renderer('bpmn:Lane')(p, element, { + fill: 'White' + }); - if (!!(getDi(element).isMarkerVisible)) { - drawPath(p, pathData, { - strokeWidth: 1, - fill: 'black' - }); - } + var expandedPool = DiUtil.isExpanded(element); - return diamond; - }, - 'bpmn:ComplexGateway': function(p, element) { - var diamond = drawDiamond(p, element.width, element.height); - - var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', { - xScaleFactor: 0.5, - yScaleFactor: 0.5, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.46, - my: 0.26 - } - }); + if (expandedPool) { + drawLine(p, [{ + x: 30, + y: 0 + }, { + x: 30, + y: element.height + }]); + var text = getSemantic(element).name; + renderLaneLabel(p, text, element); + } else { + // Collapsed pool draw text inline + var text2 = getSemantic(element).name; + renderLabel(p, text2, { + box: element, + align: 'center-middle' + }); + } - /* complex path */ - drawPath(p, pathData, { - strokeWidth: 1, - fill: 'black' - }); + var participantMultiplicity = !!(getSemantic(element).participantMultiplicity); - return diamond; - }, - 'bpmn:ParallelGateway': function(p, element) { - var diamond = drawDiamond(p, element.width, element.height); - - var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', { - xScaleFactor: 0.6, - yScaleFactor: 0.6, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.46, - my: 0.2 - } - }); + if (participantMultiplicity) { + renderer('ParticipantMultiplicityMarker')(p, element); + } - /* parallel path */ - drawPath(p, pathData, { - strokeWidth: 1, - fill: 'black' - }); + return lane; + }, + 'bpmn:Lane': function(p, element, attrs) { + var rect = drawRect(p, element.width, element.height, 0, attrs || { + fill: 'none' + }); - return diamond; - }, - 'bpmn:EventBasedGateway': function(p, element) { + var semantic = getSemantic(element); - var semantic = getSemantic(element); + if (semantic.$type === 'bpmn:Lane') { + var text = semantic.name; + renderLaneLabel(p, text, element); + } - var diamond = drawDiamond(p, element.width, element.height); + return rect; + }, + 'bpmn:InclusiveGateway': function(p, element) { + var diamond = drawDiamond(p, element.width, element.height); - /* outer circle path */ - drawCircle(p, element.width, element.height, element.height * 0.20, { - strokeWidth: 1, - fill: 'none' - }); + /* circle path */ + drawCircle(p, element.width, element.height, element.height * 0.24, { + strokeWidth: 2.5, + fill: 'none' + }); - var type = semantic.eventGatewayType; - var instantiate = !!semantic.instantiate; + return diamond; + }, + 'bpmn:ExclusiveGateway': function(p, element) { + var diamond = drawDiamond(p, element.width, element.height); + renderEmbeddedLabel(p, element, 'center-middle'); + + var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', { + xScaleFactor: 0.4, + yScaleFactor: 0.4, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.32, + my: 0.3 + } + }); - function drawEvent() { + if (!!(getDi(element).isMarkerVisible)) { + drawPath(p, pathData, { + strokeWidth: 1, + fill: 'black' + }); + } - var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', { - xScaleFactor: 0.18, - yScaleFactor: 0.18, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.36, - my: 0.44 - } - }); + return diamond; + }, + 'bpmn:ComplexGateway': function(p, element) { + var diamond = drawDiamond(p, element.width, element.height); - /* event path */ - drawPath(p, pathData, { - strokeWidth: 2, - fill: 'none' - }); - } + var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', { + xScaleFactor: 0.5, + yScaleFactor: 0.5, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.46, + my: 0.26 + } + }); - if (type === 'Parallel') { + /* complex path */ + drawPath(p, pathData, { + strokeWidth: 1, + fill: 'black' + }); - var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', { - xScaleFactor: 0.4, - yScaleFactor: 0.4, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.474, - my: 0.296 - } - }); - - var parallelPath = drawPath(p, pathData); - parallelPath.attr({ - strokeWidth: 1, - fill: 'none' - }); - } else if (type === 'Exclusive') { - - if (!instantiate) { - var innerCircle = drawCircle(p, element.width, element.height, element.height * 0.26); - innerCircle.attr({ - strokeWidth: 1, - fill: 'none' - }); - } + return diamond; + }, + 'bpmn:ParallelGateway': function(p, element) { + var diamond = drawDiamond(p, element.width, element.height); - drawEvent(); - } + var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', { + xScaleFactor: 0.6, + yScaleFactor: 0.6, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.46, + my: 0.2 + } + }); + /* parallel path */ + drawPath(p, pathData, { + strokeWidth: 1, + fill: 'black' + }); - return diamond; - }, - 'bpmn:Gateway': function(p, element) { - var diamond = drawDiamond(p, element.width, element.height); - renderEmbeddedLabel(p, element, 'center-middle'); + return diamond; + }, + 'bpmn:EventBasedGateway': function(p, element) { - return diamond; - }, - 'bpmn:SequenceFlow': function(p, element) { - var pathData = createPathFromConnection(element); - var path = drawPath(p, pathData, { - strokeLinejoin: 'round', - markerEnd: marker('sequenceflow-end') - }); + var semantic = getSemantic(element); - var sequenceFlow = getSemantic(element); - var source = element.source.businessObject; + var diamond = drawDiamond(p, element.width, element.height); - // conditional flow marker - if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Task')) { - path.attr({ - markerStart: marker('conditional-flow-marker') - }); - } + /* outer circle path */ + drawCircle(p, element.width, element.height, element.height * 0.20, { + strokeWidth: 1, + fill: 'none' + }); - // default marker - if (source.default && source.$instanceOf('bpmn:Gateway') && source.default === sequenceFlow) { - path.attr({ - markerStart: marker('conditional-default-flow-marker') - }); - } + var type = semantic.eventGatewayType; + var instantiate = !!semantic.instantiate; - return path; - }, - 'bpmn:Association': function(p, element, attrs) { + function drawEvent() { - attrs = assign({ - strokeDasharray: '1,6', - strokeLinecap: 'round', - strokeLinejoin: 'round' - }, attrs || {}); + var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', { + xScaleFactor: 0.18, + yScaleFactor: 0.18, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.36, + my: 0.44 + } + }); - // TODO(nre): style according to directed state - return drawLine(p, element.waypoints, attrs); - }, - 'bpmn:DataInputAssociation': function(p, element) { - return renderer('bpmn:Association')(p, element, { - markerEnd: marker('data-association-end') - }); - }, - 'bpmn:DataOutputAssociation': function(p, element) { - return renderer('bpmn:Association')(p, element, { - markerEnd: marker('data-association-end') - }); - }, - 'bpmn:MessageFlow': function(p, element) { - - var semantic = getSemantic(element), - di = getDi(element); - - var pathData = createPathFromConnection(element); - var path = drawPath(p, pathData, { - markerEnd: marker('messageflow-end'), - markerStart: marker('messageflow-start'), - strokeDasharray: '10, 12', - strokeLinecap: 'round', - strokeLinejoin: 'round', - strokeWidth: '1.5px' - }); + /* event path */ + drawPath(p, pathData, { + strokeWidth: 2, + fill: 'none' + }); + } - if (semantic.messageRef) { - var midPoint = path.getPointAtLength(path.getTotalLength() / 2); + if (type === 'Parallel') { - var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', { - abspos: { - x: midPoint.x, - y: midPoint.y - } - }); - - var messageAttrs = { - strokeWidth: 1 - }; - - if (di.messageVisibleKind === 'initiating') { - messageAttrs.fill = 'white'; - messageAttrs.stroke = 'black'; - } else { - messageAttrs.fill = '#888'; - messageAttrs.stroke = 'white'; - } + var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', { + xScaleFactor: 0.4, + yScaleFactor: 0.4, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.474, + my: 0.296 + } + }); - drawPath(p, markerPathData, messageAttrs); - } + var parallelPath = drawPath(p, pathData); + parallelPath.attr({ + strokeWidth: 1, + fill: 'none' + }); + } else if (type === 'Exclusive') { - return path; - }, - 'bpmn:DataObject': function(p, element) { - var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.474, - my: 0.296 - } - }); + if (!instantiate) { + var innerCircle = drawCircle(p, element.width, element.height, element.height * 0.26); + innerCircle.attr({ + strokeWidth: 1, + fill: 'none' + }); + } - var elementObject = drawPath(p, pathData, { - fill: 'white' - }); + drawEvent(); + } - var semantic = getSemantic(element); - if (isCollection(semantic)) { - renderDataItemCollection(p, element); - } + return diamond; + }, + 'bpmn:Gateway': function(p, element) { + var diamond = drawDiamond(p, element.width, element.height); + renderEmbeddedLabel(p, element, 'center-middle'); - return elementObject; - }, - 'bpmn:DataObjectReference': as('bpmn:DataObject'), - 'bpmn:DataInput': function(p, element) { + return diamond; + }, + 'bpmn:SequenceFlow': function(p, element) { + var pathData = createPathFromConnection(element); + var path = drawPath(p, pathData, { + strokeLinejoin: 'round', + markerEnd: marker('sequenceflow-end') + }); - var arrowPathData = pathMap.getRawPath('DATA_ARROW'); + var sequenceFlow = getSemantic(element); + var source = element.source.businessObject; - // page - var elementObject = renderer('bpmn:DataObject')(p, element); + // conditional flow marker + if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Task')) { + path.attr({ + markerStart: marker('conditional-flow-marker') + }); + } - /* input arrow path */ - drawPath(p, arrowPathData, { - strokeWidth: 1 - }); + // default marker + if (source.default && source.$instanceOf('bpmn:Gateway') && source.default === sequenceFlow) { + path.attr({ + markerStart: marker('conditional-default-flow-marker') + }); + } - return elementObject; - }, - 'bpmn:DataOutput': function(p, element) { - var arrowPathData = pathMap.getRawPath('DATA_ARROW'); + return path; + }, + 'bpmn:Association': function(p, element, attrs) { + + attrs = assign({ + strokeDasharray: '1,6', + strokeLinecap: 'round', + strokeLinejoin: 'round' + }, attrs || {}); + + // TODO(nre): style according to directed state + return drawLine(p, element.waypoints, attrs); + }, + 'bpmn:DataInputAssociation': function(p, element) { + return renderer('bpmn:Association')(p, element, { + markerEnd: marker('data-association-end') + }); + }, + 'bpmn:DataOutputAssociation': function(p, element) { + return renderer('bpmn:Association')(p, element, { + markerEnd: marker('data-association-end') + }); + }, + 'bpmn:MessageFlow': function(p, element) { + + var semantic = getSemantic(element), + di = getDi(element); + + var pathData = createPathFromConnection(element); + var path = drawPath(p, pathData, { + markerEnd: marker('messageflow-end'), + markerStart: marker('messageflow-start'), + strokeDasharray: '10, 12', + strokeLinecap: 'round', + strokeLinejoin: 'round', + strokeWidth: '1.5px' + }); - // page - var elementObject = renderer('bpmn:DataObject')(p, element); + if (semantic.messageRef) { + var midPoint = path.getPointAtLength(path.getTotalLength() / 2); - /* output arrow path */ - drawPath(p, arrowPathData, { - strokeWidth: 1, - fill: 'black' - }); + var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', { + abspos: { + x: midPoint.x, + y: midPoint.y + } + }); - return elementObject; - }, - 'bpmn:DataStoreReference': function(p, element) { - var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0, - my: 0.133 - } - }); + var messageAttrs = { + strokeWidth: 1 + }; - var elementStore = drawPath(p, DATA_STORE_PATH, { - strokeWidth: 2, - fill: 'white' - }); + if (di.messageVisibleKind === 'initiating') { + messageAttrs.fill = 'white'; + messageAttrs.stroke = 'black'; + } else { + messageAttrs.fill = '#888'; + messageAttrs.stroke = 'white'; + } - return elementStore; - }, - 'bpmn:BoundaryEvent': function(p, element) { + drawPath(p, markerPathData, messageAttrs); + } - var semantic = getSemantic(element), - cancel = semantic.cancelActivity; + return path; + }, + 'bpmn:DataObject': function(p, element) { + var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.474, + my: 0.296 + } + }); - var attrs = { - strokeLinecap: 'round', - strokeWidth: 1 - }; + var elementObject = drawPath(p, pathData, { + fill: 'white' + }); - if (!cancel) { - attrs.strokeDasharray = '6'; - } + var semantic = getSemantic(element); - var outer = renderer('bpmn:Event')(p, element, attrs); - /* inner path */ - drawCircle(p, element.width, element.height, INNER_OUTER_DIST, attrs); + if (isCollection(semantic)) { + renderDataItemCollection(p, element); + } - renderEventContent(element, p); + return elementObject; + }, + 'bpmn:DataObjectReference': as('bpmn:DataObject'), + 'bpmn:DataInput': function(p, element) { - return outer; - }, - 'bpmn:Group': function(p, element) { - return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, { - strokeWidth: 1, - strokeDasharray: '8,3,1,3', - fill: 'none', - pointerEvents: 'none' - }); - }, - 'label': function(p, element) { - return renderExternalLabel(p, element, ''); - }, - 'bpmn:TextAnnotation': function(p, element) { - var style = { - 'fill': 'none', - 'stroke': 'none' - }; - var textElement = drawRect(p, element.width, element.height, 0, 0, style); - var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.0, - my: 0.0 - } - }); - drawPath(p, textPathData); + var arrowPathData = pathMap.getRawPath('DATA_ARROW'); - var text = getSemantic(element).text || ''; - renderLabel(p, text, { - box: element, - align: 'left-middle', - padding: 5 - }); + // page + var elementObject = renderer('bpmn:DataObject')(p, element); - return textElement; - }, - 'ParticipantMultiplicityMarker': function(p, element) { - var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: ((element.width / 2) / element.width), - my: (element.height - 15) / element.height - } - }); + /* input arrow path */ + drawPath(p, arrowPathData, { + strokeWidth: 1 + }); - drawPath(p, subProcessPath); - }, - 'SubProcessMarker': function(p, element) { - var markerRect = drawRect(p, 14, 14, 0, { - strokeWidth: 1 - }); + return elementObject; + }, + 'bpmn:DataOutput': function(p, element) { + var arrowPathData = pathMap.getRawPath('DATA_ARROW'); - // Process marker is placed in the middle of the box - // therefore fixed values can be used here - markerRect.transform('translate(' + (element.width / 2 - 7.5) + ',' + (element.height - 20) + ')'); - - var subProcessPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', { - xScaleFactor: 1.5, - yScaleFactor: 1.5, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: (element.width / 2 - 7.5) / element.width, - my: (element.height - 20) / element.height - } - }); + // page + var elementObject = renderer('bpmn:DataObject')(p, element); - drawPath(p, subProcessPath); - }, - 'ParallelMarker': function(p, element, position) { - var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: ((element.width / 2 + position.parallel) / element.width), - my: (element.height - 20) / element.height - } - }); - drawPath(p, subProcessPath); - }, - 'SequentialMarker': function(p, element, position) { - var sequentialPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: ((element.width / 2 + position.seq) / element.width), - my: (element.height - 19) / element.height - } - }); - drawPath(p, sequentialPath); - }, - 'CompensationMarker': function(p, element, position) { - var compensationPath = pathMap.getScaledPath('MARKER_COMPENSATION', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: ((element.width / 2 + position.compensation) / element.width), - my: (element.height - 13) / element.height - } - }); - drawPath(p, compensationPath, { - strokeWidth: 1 - }); - }, - 'LoopMarker': function(p, element, position) { - var loopPath = pathMap.getScaledPath('MARKER_LOOP', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: ((element.width / 2 + position.loop) / element.width), - my: (element.height - 7) / element.height - } - }); + /* output arrow path */ + drawPath(p, arrowPathData, { + strokeWidth: 1, + fill: 'black' + }); - drawPath(p, loopPath, { - strokeWidth: 1, - fill: 'none', - strokeLinecap: 'round', - strokeMiterlimit: 0.5 - }); - }, - 'AdhocMarker': function(p, element, position) { - var loopPath = pathMap.getScaledPath('MARKER_ADHOC', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: ((element.width / 2 + position.adhoc) / element.width), - my: (element.height - 15) / element.height - } - }); + return elementObject; + }, + 'bpmn:DataStoreReference': function(p, element) { + var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0, + my: 0.133 + } + }); - drawPath(p, loopPath, { - strokeWidth: 1, - fill: 'black' - }); - } - }; + var elementStore = drawPath(p, DATA_STORE_PATH, { + strokeWidth: 2, + fill: 'white' + }); - function attachTaskMarkers(p, element, taskMarkers) { - var obj = getSemantic(element); + return elementStore; + }, + 'bpmn:BoundaryEvent': function(p, element) { - var subprocess = includes(taskMarkers, 'SubProcessMarker'); - var position; + var semantic = getSemantic(element), + cancel = semantic.cancelActivity; - if (subprocess) { - position = { - seq: -21, - parallel: -22, - compensation: -42, - loop: -18, - adhoc: 10 - }; - } else { - position = { - seq: -3, - parallel: -6, - compensation: -27, - loop: 0, - adhoc: 10 - }; - } + var attrs = { + strokeLinecap: 'round', + strokeWidth: 1 + }; - forEach(taskMarkers, function(marker) { - renderer(marker)(p, element, position); - }); + if (!cancel) { + attrs.strokeDasharray = '6'; + } - if (obj.$type === 'bpmn:AdHocSubProcess') { - renderer('AdhocMarker')(p, element, position); - } - if (obj.loopCharacteristics && obj.loopCharacteristics.isSequential === undefined) { - renderer('LoopMarker')(p, element, position); - return; - } - if (obj.loopCharacteristics && - obj.loopCharacteristics.isSequential !== undefined && - !obj.loopCharacteristics.isSequential) { - renderer('ParallelMarker')(p, element, position); - } - if (obj.loopCharacteristics && !!obj.loopCharacteristics.isSequential) { - renderer('SequentialMarker')(p, element, position); - } - if (!!obj.isForCompensation) { - renderer('CompensationMarker')(p, element, position); - } - } + var outer = renderer('bpmn:Event')(p, element, attrs); + /* inner path */ + drawCircle(p, element.width, element.height, INNER_OUTER_DIST, attrs); - function drawShape(parent, element) { - var type = element.type; - var h = handlers[type]; + renderEventContent(element, p); - /* jshint -W040 */ - if (!h) { - return DefaultRenderer.prototype.drawShape.apply(this, [parent, element]); - } else { - return h(parent, element); - } + return outer; + }, + 'bpmn:Group': function(p, element) { + return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, { + strokeWidth: 1, + strokeDasharray: '8,3,1,3', + fill: 'none', + pointerEvents: 'none' + }); + }, + 'label': function(p, element) { + return renderExternalLabel(p, element, ''); + }, + 'bpmn:TextAnnotation': function(p, element) { + var style = { + 'fill': 'none', + 'stroke': 'none' + }; + var textElement = drawRect(p, element.width, element.height, 0, 0, style); + var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.0, + my: 0.0 } + }); + drawPath(p, textPathData); - function drawConnection(parent, element) { - var type = element.type; - var h = handlers[type]; + var text = getSemantic(element).text || ''; + renderLabel(p, text, { + box: element, + align: 'left-middle', + padding: 5 + }); - /* jshint -W040 */ - if (!h) { - return DefaultRenderer.prototype.drawConnection.apply(this, [parent, element]); - } else { - return h(parent, element); - } + return textElement; + }, + 'ParticipantMultiplicityMarker': function(p, element) { + var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: ((element.width / 2) / element.width), + my: (element.height - 15) / element.height } + }); - function renderDataItemCollection(p, element) { - - var yPosition = (element.height - 16) / element.height; + drawPath(p, subProcessPath); + }, + 'SubProcessMarker': function(p, element) { + var markerRect = drawRect(p, 14, 14, 0, { + strokeWidth: 1 + }); - var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', { - xScaleFactor: 1, - yScaleFactor: 1, - containerWidth: element.width, - containerHeight: element.height, - position: { - mx: 0.451, - my: yPosition - } - }); + // Process marker is placed in the middle of the box + // therefore fixed values can be used here + markerRect.transform('translate(' + (element.width / 2 - 7.5) + ',' + (element.height - 20) + ')'); - /* collection path */ - drawPath(p, pathData, { - strokeWidth: 2 - }); + var subProcessPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', { + xScaleFactor: 1.5, + yScaleFactor: 1.5, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: (element.width / 2 - 7.5) / element.width, + my: (element.height - 20) / element.height } + }); - function isCollection(element, filter) { - return element.isCollection || - (element.elementObjectRef && element.elementObjectRef.isCollection); + drawPath(p, subProcessPath); + }, + 'ParallelMarker': function(p, element, position) { + var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: ((element.width / 2 + position.parallel) / element.width), + my: (element.height - 20) / element.height } - - function getDi(element) { - return element.businessObject.di; + }); + drawPath(p, subProcessPath); + }, + 'SequentialMarker': function(p, element, position) { + var sequentialPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: ((element.width / 2 + position.seq) / element.width), + my: (element.height - 19) / element.height + } + }); + drawPath(p, sequentialPath); + }, + 'CompensationMarker': function(p, element, position) { + var compensationPath = pathMap.getScaledPath('MARKER_COMPENSATION', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: ((element.width / 2 + position.compensation) / element.width), + my: (element.height - 13) / element.height } + }); + drawPath(p, compensationPath, { + strokeWidth: 1 + }); + }, + 'LoopMarker': function(p, element, position) { + var loopPath = pathMap.getScaledPath('MARKER_LOOP', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: ((element.width / 2 + position.loop) / element.width), + my: (element.height - 7) / element.height + } + }); - function getSemantic(element) { - return element.businessObject; + drawPath(p, loopPath, { + strokeWidth: 1, + fill: 'none', + strokeLinecap: 'round', + strokeMiterlimit: 0.5 + }); + }, + 'AdhocMarker': function(p, element, position) { + var loopPath = pathMap.getScaledPath('MARKER_ADHOC', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: ((element.width / 2 + position.adhoc) / element.width), + my: (element.height - 15) / element.height } + }); - /** - * Checks if eventDefinition of the given element matches with semantic - * type. - * - * @return {boolean} true if element is of the given semantic type - */ - function isTypedEvent(event, eventDefinitionType, filter) { + drawPath(p, loopPath, { + strokeWidth: 1, + fill: 'black' + }); + } + }; - function matches(definition, filter) { - return every(filter, function(val, key) { + function attachTaskMarkers(p, element, taskMarkers) { + var obj = getSemantic(element); - // we want a == conversion here, to be able to catch - // undefined == false and friends - /* jshint -W116 */ - return definition[key] == val; - }); - } + var subprocess = includes(taskMarkers, 'SubProcessMarker'); + var position; - return some(event.eventDefinitions, function(definition) { - return definition.$type === eventDefinitionType && matches(event, filter); - }); - } + if (subprocess) { + position = { + seq: -21, + parallel: -22, + compensation: -42, + loop: -18, + adhoc: 10 + }; + } else { + position = { + seq: -3, + parallel: -6, + compensation: -27, + loop: 0, + adhoc: 10 + }; + } - function isThrowEvent(event) { - return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent'); - } + forEach(taskMarkers, function(marker) { + renderer(marker)(p, element, position); + }); + if (obj.$type === 'bpmn:AdHocSubProcess') { + renderer('AdhocMarker')(p, element, position); + } + if (obj.loopCharacteristics && obj.loopCharacteristics.isSequential === undefined) { + renderer('LoopMarker')(p, element, position); + return; + } + if (obj.loopCharacteristics && + obj.loopCharacteristics.isSequential !== undefined && + !obj.loopCharacteristics.isSequential) { + renderer('ParallelMarker')(p, element, position); + } + if (obj.loopCharacteristics && !!obj.loopCharacteristics.isSequential) { + renderer('SequentialMarker')(p, element, position); + } + if (!!obj.isForCompensation) { + renderer('CompensationMarker')(p, element, position); + } + } - // ///// cropping path customizations ///////////////////////// + function drawShape(parent, element) { + var type = element.type; + var h = handlers[type]; - function componentsToPath(elements) { - return elements.join(',').replace(/,?([A-z]),?/g, '$1'); - } + /* jshint -W040 */ + if (!h) { + return DefaultRenderer.prototype.drawShape.apply(this, [parent, element]); + } else { + return h(parent, element); + } + } - function getCirclePath(shape) { + function drawConnection(parent, element) { + var type = element.type; + var h = handlers[type]; - var cx = shape.x + shape.width / 2, - cy = shape.y + shape.height / 2, - radius = shape.width / 2; + /* jshint -W040 */ + if (!h) { + return DefaultRenderer.prototype.drawConnection.apply(this, [parent, element]); + } else { + return h(parent, element); + } + } - var circlePath = [ - ['M', cx, cy], - ['m', 0, -radius], - ['a', radius, radius, 0, 1, 1, 0, 2 * radius], - ['a', radius, radius, 0, 1, 1, 0, -2 * radius], - ['z'] - ]; + function renderDataItemCollection(p, element) { - return componentsToPath(circlePath); - } + var yPosition = (element.height - 16) / element.height; - function getRoundRectPath(shape) { + var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', { + xScaleFactor: 1, + yScaleFactor: 1, + containerWidth: element.width, + containerHeight: element.height, + position: { + mx: 0.451, + my: yPosition + } + }); - var radius = TASK_BORDER_RADIUS, - x = shape.x, - y = shape.y, - width = shape.width, - height = shape.height; + /* collection path */ + drawPath(p, pathData, { + strokeWidth: 2 + }); + } - var roundRectPath = [ - ['M', x + radius, y], - ['l', width - radius * 2, 0], - ['a', radius, radius, 0, 0, 1, radius, radius], - ['l', 0, height - radius * 2], - ['a', radius, radius, 0, 0, 1, -radius, radius], - ['l', radius * 2 - width, 0], - ['a', radius, radius, 0, 0, 1, -radius, -radius], - ['l', 0, radius * 2 - height], - ['a', radius, radius, 0, 0, 1, radius, -radius], - ['z'] - ]; + function isCollection(element, filter) { + return element.isCollection || + (element.elementObjectRef && element.elementObjectRef.isCollection); + } - return componentsToPath(roundRectPath); - } + function getDi(element) { + return element.businessObject.di; + } - function getDiamondPath(shape) { + function getSemantic(element) { + return element.businessObject; + } - var width = shape.width, - height = shape.height, - x = shape.x, - y = shape.y, - halfWidth = width / 2, - halfHeight = height / 2; + /** + * Checks if eventDefinition of the given element matches with semantic + * type. + * + * @return {boolean} true if element is of the given semantic type + */ + function isTypedEvent(event, eventDefinitionType, filter) { + + function matches(definition, filter) { + return every(filter, function(val, key) { + + // we want a == conversion here, to be able to catch + // undefined == false and friends + /* jshint -W116 */ + return definition[key] == val; + }); + } - var diamondPath = [ - ['M', x + halfWidth, y], - ['l', halfWidth, halfHeight], - ['l', -halfWidth, halfHeight], - ['l', -halfWidth, -halfHeight], - ['z'] - ]; + return some(event.eventDefinitions, function(definition) { + return definition.$type === eventDefinitionType && matches(event, filter); + }); + } - return componentsToPath(diamondPath); - } + function isThrowEvent(event) { + return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent'); + } - function getRectPath(shape) { - var x = shape.x, - y = shape.y, - width = shape.width, - height = shape.height; - var rectPath = [ - ['M', x, y], - ['l', width, 0], - ['l', 0, height], - ['l', -width, 0], - ['z'] - ]; + // ///// cropping path customizations ///////////////////////// - return componentsToPath(rectPath); - } + function componentsToPath(elements) { + return elements.join(',').replace(/,?([A-z]),?/g, '$1'); + } - function getShapePath(element) { - var obj = getSemantic(element); + function getCirclePath(shape) { - if (obj.$instanceOf('bpmn:Event')) { - return getCirclePath(element); - } + var cx = shape.x + shape.width / 2, + cy = shape.y + shape.height / 2, + radius = shape.width / 2; - if (obj.$instanceOf('bpmn:Activity')) { - return getRoundRectPath(element); - } + var circlePath = [ + ['M', cx, cy], + ['m', 0, -radius], + ['a', radius, radius, 0, 1, 1, 0, 2 * radius], + ['a', radius, radius, 0, 1, 1, 0, -2 * radius], + ['z'] + ]; - if (obj.$instanceOf('bpmn:Gateway')) { - return getDiamondPath(element); - } + return componentsToPath(circlePath); + } - return getRectPath(element); - } + function getRoundRectPath(shape) { + + var radius = TASK_BORDER_RADIUS, + x = shape.x, + y = shape.y, + width = shape.width, + height = shape.height; + + var roundRectPath = [ + ['M', x + radius, y], + ['l', width - radius * 2, 0], + ['a', radius, radius, 0, 0, 1, radius, radius], + ['l', 0, height - radius * 2], + ['a', radius, radius, 0, 0, 1, -radius, radius], + ['l', radius * 2 - width, 0], + ['a', radius, radius, 0, 0, 1, -radius, -radius], + ['l', 0, radius * 2 - height], + ['a', radius, radius, 0, 0, 1, radius, -radius], + ['z'] + ]; + return componentsToPath(roundRectPath); + } - // hook onto canvas init event to initialize - // connection start/end markers on svg - events.on('canvas.init', function(event) { - initMarkers(event.svg); - }); + function getDiamondPath(shape) { + + var width = shape.width, + height = shape.height, + x = shape.x, + y = shape.y, + halfWidth = width / 2, + halfHeight = height / 2; + + var diamondPath = [ + ['M', x + halfWidth, y], + ['l', halfWidth, halfHeight], + ['l', -halfWidth, halfHeight], + ['l', -halfWidth, -halfHeight], + ['z'] + ]; - this.drawShape = drawShape; - this.drawConnection = drawConnection; + return componentsToPath(diamondPath); + } + + function getRectPath(shape) { + var x = shape.x, + y = shape.y, + width = shape.width, + height = shape.height; + + var rectPath = [ + ['M', x, y], + ['l', width, 0], + ['l', 0, height], + ['l', -width, 0], + ['z'] + ]; + + return componentsToPath(rectPath); + } + + function getShapePath(element) { + var obj = getSemantic(element); - this.getShapePath = getShapePath; + if (obj.$instanceOf('bpmn:Event')) { + return getCirclePath(element); } - inherits(BpmnRenderer, DefaultRenderer); + if (obj.$instanceOf('bpmn:Activity')) { + return getRoundRectPath(element); + } + if (obj.$instanceOf('bpmn:Gateway')) { + return getDiamondPath(element); + } - BpmnRenderer.$inject = ['eventBus', 'styles', 'pathMap']; + return getRectPath(element); + } - module.exports = BpmnRenderer; - }, { - "../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", - "diagram-js/lib/draw/Renderer": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\draw\\Renderer.js", - "diagram-js/lib/util/Text": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Text.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/collection/every": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\every.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", - "lodash/collection/includes": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\includes.js", - "lodash/collection/some": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\some.js", - "lodash/lang/isArray": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isArray.js", - "lodash/lang/isObject": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isObject.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\PathMap.js": [function(require, module, exports) { - 'use strict'; + // hook onto canvas init event to initialize + // connection start/end markers on svg + events.on('canvas.init', function(event) { + initMarkers(event.svg); + }); - var Snap = require('diagram-js/vendor/snapsvg'); + this.drawShape = drawShape; + this.drawConnection = drawConnection; - /** - * Map containing SVG paths needed by BpmnRenderer. - */ + this.getShapePath = getShapePath; + } - function PathMap() { + inherits(BpmnRenderer, DefaultRenderer); + + + BpmnRenderer.$inject = ['eventBus', 'styles', 'pathMap']; + + module.exports = BpmnRenderer; + + }, { + "../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", + "diagram-js/lib/draw/Renderer": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\draw\\Renderer.js", + "diagram-js/lib/util/Text": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Text.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/collection/every": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\every.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "lodash/collection/includes": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\includes.js", + "lodash/collection/some": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\some.js", + "lodash/lang/isArray": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isArray.js", + "lodash/lang/isObject": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isObject.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\PathMap.js": [function(require, module, exports) { + 'use strict'; + + var Snap = require('diagram-js/vendor/snapsvg'); + + /** + * Map containing SVG paths needed by BpmnRenderer. + */ + + function PathMap() { + + /** + * Contains a map of path elements + * + *

Path definition

+ * A parameterized path is defined like this: + * + *
+       * 'GATEWAY_PARALLEL': {
+       *   d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
+       *           '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
+       *   height: 17.5,
+       *   width:  17.5,
+       *   heightElements: [2.5, 7.5],
+       *   widthElements: [2.5, 7.5]
+       * }
+       * 
+ * + *

+ * It's important to specify a correct height and width for the path + * as the scaling is based on the ratio between the specified height and + * width in this object and the height and width that is set as scale target + * (Note x,y coordinates will be scaled with individual ratios). + *

+ *

+ * The 'heightElements' and 'widthElements' array must + * contain the values that will be scaled. The scaling is based on the + * computed ratios. Coordinates on the y axis should be in the + * heightElement's array, they will be scaled using the computed + * ratio coefficient. In the parameterized path the scaled values can be + * accessed through the 'e' object in {} brackets. + *

    + *
  • The values for the y axis can be accessed in the path string using + * {e.y0}, {e.y1}, ....
  • + *
  • The values for the x axis can be accessed in the path string using + * {e.x0}, {e.x1}, ....
  • + *
+ * The numbers x0, x1 respectively y0, y1, ... map to the corresponding + * array index. + *

+ */ + this.pathMap = { + 'EVENT_MESSAGE': { + d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}', + height: 36, + width: 36, + heightElements: [6, 14], + widthElements: [10.5, 21] + }, + 'EVENT_SIGNAL': { + d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z', + height: 36, + width: 36, + heightElements: [18], + widthElements: [10, 20] + }, + 'EVENT_ESCALATION': { + d: 'm {mx},{my} c -{e.x1},{e.y0} -{e.x3},{e.y1} -{e.x5},{e.y4} {e.x1},-{e.y3} {e.x3},-{e.y5} {e.x5},-{e.y6} ' + + '{e.x0},{e.y3} {e.x2},{e.y5} {e.x4},{e.y6} -{e.x0},-{e.y0} -{e.x2},-{e.y1} -{e.x4},-{e.y4} z', + height: 36, + width: 36, + heightElements: [2.382, 4.764, 4.926, 6.589333, 7.146, 13.178667, 19.768], + widthElements: [2.463, 2.808, 4.926, 5.616, 7.389, 8.424] + }, + 'EVENT_CONDITIONAL': { + d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' + + 'M {e.x2},{e.y3} l {e.x0},0 ' + + 'M {e.x2},{e.y4} l {e.x0},0 ' + + 'M {e.x2},{e.y5} l {e.x0},0 ' + + 'M {e.x2},{e.y6} l {e.x0},0 ' + + 'M {e.x2},{e.y7} l {e.x0},0 ' + + 'M {e.x2},{e.y8} l {e.x0},0 ', + height: 36, + width: 36, + heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5], + widthElements: [10.5, 14.5, 12.5] + }, + 'EVENT_LINK': { + d: 'm {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z', + height: 36, + width: 36, + heightElements: [4.4375, 6.75, 7.8125], + widthElements: [9.84375, 13.5] + }, + 'EVENT_ERROR': { + d: 'm {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z', + height: 36, + width: 36, + heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714], + widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636] + }, + 'EVENT_CANCEL_45': { + d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' + + '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z', + height: 36, + width: 36, + heightElements: [4.75, 8.5], + widthElements: [4.75, 8.5] + }, + 'EVENT_COMPENSATION': { + d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x0},0 {e.x0},-{e.y0} 0,{e.y1} z', + height: 36, + width: 36, + heightElements: [5, 10], + widthElements: [10] + }, + 'EVENT_TIMER_WH': { + d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ', + height: 36, + width: 36, + heightElements: [10, 2], + widthElements: [3, 7] + }, + 'EVENT_TIMER_LINE': { + d: 'M {mx},{my} ' + + 'm {e.x0},{e.y0} l -{e.x1},{e.y1} ', + height: 36, + width: 36, + heightElements: [10, 3], + widthElements: [0, 0] + }, + 'EVENT_MULTIPLE': { + d: 'm {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z', + height: 36, + width: 36, + heightElements: [6.28099, 12.56199], + widthElements: [3.1405, 9.42149, 12.56198] + }, + 'EVENT_PARALLEL_MULTIPLE': { + d: 'm {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' + + '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z', + height: 36, + width: 36, + heightElements: [2.56228, 7.68683], + widthElements: [2.56228, 7.68683] + }, + 'GATEWAY_EXCLUSIVE': { + d: 'm {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' + + '{e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} ' + + '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z', + height: 17.5, + width: 17.5, + heightElements: [8.5, 6.5312, -6.5312, -8.5], + widthElements: [6.5, -6.5, 3, -3, 5, -5] + }, + 'GATEWAY_PARALLEL': { + d: 'm {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' + + '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z', + height: 30, + width: 30, + heightElements: [5, 12.5], + widthElements: [5, 12.5] + }, + 'GATEWAY_EVENT_BASED': { + d: 'm {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z', + height: 11, + width: 11, + heightElements: [-6, 6, 12, -12], + widthElements: [9, -3, -12] + }, + 'GATEWAY_COMPLEX': { + d: 'm {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} ' + + '{e.x2},0 -{e.x0},{e.y1} l {e.x1},{e.y2} {e.x0},-{e.y1} 0,{e.y0} {e.x3},0 0,-{e.y0} {e.x0},{e.y1} ' + + '{e.x1},-{e.y2} -{e.x0},-{e.y1} {e.x2},0 0,-{e.y3} -{e.x2},0 {e.x0},-{e.y1} -{e.x1},-{e.y2} ' + + '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z', + height: 17.125, + width: 17.125, + heightElements: [4.875, 3.4375, 2.125, 3], + widthElements: [3.4375, 2.125, 4.875, 3] + }, + 'DATA_OBJECT_PATH': { + d: 'm 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0', + height: 61, + width: 51, + heightElements: [10, 50, 60], + widthElements: [10, 40, 50, 60] + }, + 'DATA_OBJECT_COLLECTION_PATH': { + d: 'm {mx}, {my} ' + + 'm 0 15 l 0 -15 ' + + 'm 4 15 l 0 -15 ' + + 'm 4 15 l 0 -15 ', + height: 61, + width: 51, + heightElements: [12], + widthElements: [1, 6, 12, 15] + }, + 'DATA_ARROW': { + d: 'm 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z', + height: 61, + width: 51, + heightElements: [], + widthElements: [] + }, + 'DATA_STORE': { + d: 'm {mx},{my} ' + + 'l 0,{e.y2} ' + + 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' + + 'l 0,-{e.y2} ' + + 'c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0' + + 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' + + 'm -{e.x2},{e.y0}' + + 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0' + + 'm -{e.x2},{e.y0}' + + 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0', + height: 61, + width: 61, + heightElements: [7, 10, 45], + widthElements: [2, 58, 60] + }, + 'TEXT_ANNOTATION': { + d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0', + height: 30, + width: 10, + heightElements: [30], + widthElements: [10] + }, + 'MARKER_SUB_PROCESS': { + d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0', + height: 10, + width: 10, + heightElements: [], + widthElements: [] + }, + 'MARKER_PARALLEL': { + d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10', + height: 10, + width: 10, + heightElements: [], + widthElements: [] + }, + 'MARKER_SEQUENTIAL': { + d: 'm{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0', + height: 10, + width: 10, + heightElements: [], + widthElements: [] + }, + 'MARKER_COMPENSATION': { + d: 'm {mx},{my} 8,-5 0,10 z m 9,0 8,-5 0,10 z', + height: 10, + width: 21, + heightElements: [], + widthElements: [] + }, + 'MARKER_LOOP': { + d: 'm {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 ' + + '-6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 ' + + '0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 ' + + 'l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902', + height: 13.9, + width: 13.7, + heightElements: [], + widthElements: [] + }, + 'MARKER_ADHOC': { + d: 'm {mx},{my} m 0.84461,2.64411 c 1.05533,-1.23780996 2.64337,-2.07882 4.29653,-1.97997996 2.05163,0.0805 ' + + '3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 ' + + '1.2775,-0.64078 1.7542,-1.17511 0,0.56023 0,1.12046 0,1.6807 -0.98706,0.96237996 -2.29792,1.62393996 ' + + '-3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 ' + + '-2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z', + height: 4, + width: 15, + heightElements: [], + widthElements: [] + }, + 'TASK_TYPE_SEND': { + d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}', + height: 14, + width: 21, + heightElements: [6, 14], + widthElements: [10.5, 21] + }, + 'TASK_TYPE_SCRIPT': { + d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' + + 'c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z ' + + 'm -7,-12 l 5,0 ' + + 'm -4.5,3 l 4.5,0 ' + + 'm -3,3 l 5,0' + + 'm -4,3 l 5,0', + height: 15, + width: 12.6, + heightElements: [6, 14], + widthElements: [10.5, 21] + }, + 'TASK_TYPE_USER_1': { + d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' + + '-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' + + '0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' + + 'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' + + 'm -8,6 l 0,5.5 m 11,0 l 0,-5' + }, + 'TASK_TYPE_USER_2': { + d: 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' + + '-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 ' + }, + 'TASK_TYPE_USER_3': { + d: 'm {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 ' + + '4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' + + '-4.20799998,3.36699999 -4.20699998,4.34799999 z' + }, + 'TASK_TYPE_MANUAL': { + d: 'm {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 ' + + '-0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 ' + + '0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 ' + + '-1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 ' + + '0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 ' + + '-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' + + '2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' + + '-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' + + '-1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 ' + + '-0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 ' + + '0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 ' + + '-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z' + }, + 'TASK_TYPE_INSTANTIATING_SEND': { + d: 'm {mx},{my} l 0,8.4 l 12.6,0 l 0,-8.4 z l 6.3,3.6 l 6.3,-3.6' + }, + 'TASK_TYPE_SERVICE': { + d: 'm {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 ' + + '0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 ' + + '-1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 ' + + 'v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 ' + + '-0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 ' + + '-1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 ' + + 'h -2.241173 l 0.0042,1.63124 c -0.353763,0.0736 -0.705369,0.17977 -1.049785,0.32371 -0.344415,0.14437 ' + + '-0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 ' + + 'c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 ' + + 'l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 ' + + '0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 ' + + 'c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z ' + + 'm 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' + + '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' + + '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z' + }, + 'TASK_TYPE_SERVICE_FILL': { + d: 'm {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' + + '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' + + '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z' + }, + 'TASK_TYPE_BUSINESS_RULE_HEADER': { + d: 'm {mx},{my} 0,4 20,0 0,-4 z' + }, + 'TASK_TYPE_BUSINESS_RULE_MAIN': { + d: 'm {mx},{my} 0,12 20,0 0,-12 z' + + 'm 0,8 l 20,0 ' + + 'm -13,-4 l 0,8' + }, + 'MESSAGE_FLOW_MARKER': { + d: 'm {mx},{my} m -10.5 ,-7 l 0,14 l 21,0 l 0,-14 z l 10.5,6 l 10.5,-6' + } + }; + + this.getRawPath = function getRawPath(pathId) { + return this.pathMap[pathId].d; + }; + + /** + * Scales the path to the given height and width. + *

Use case

+ *

+ * Use case is to scale the content of elements (event, gateways) based on + * the element bounding box's size. + *

+ *

Why not transform

+ *

+ * Scaling a path with transform() will also scale the stroke and IE does + * not support the option 'non-scaling-stroke' to prevent this. Also there + * are use cases where only some parts of a path should be scaled. + *

+ * + * @param {String} + * pathId The ID of the path. + * @param {Object} + * param + *

+ * Example param object scales the path to 60% size of the + * container (data.width, data.height). + * + *

+       * {
+       *    xScaleFactor : 0.6,
+       *    yScaleFactor : 0.6,
+       *    containerWidth : data.width,
+       *    containerHeight : data.height,
+       *    position : {
+       *      mx : 0.46,
+       *      my : 0.2,
+       *    }
+       * }
+       * 
+ * + *
    + *
  • targetpathwidth = xScaleFactor * containerWidth
  • + *
  • targetpathheight = yScaleFactor * containerHeight
  • + *
  • Position is used to set the starting coordinate of the + * path. M is computed: + *
      + *
    • position.x * containerWidth
    • + *
    • position.y * containerHeight
    • + *
    + * Center of the container + * + *
    +       *  position: {
    +       *       mx: 0.5,
    +       *       my: 0.5,
    +       *     }
    +       * 
    + * + * Upper left corner of the container + * + *
    +       *  position: {
    +       *       mx: 0.0,
    +       *       my: 0.0,
    +       *     }
    +       * 
    + * + *
  • + *
+ *

+ * + */ + this.getScaledPath = function getScaledPath(pathId, param) { + var rawPath = this.pathMap[pathId]; + + // positioning + // compute the start point of the path + var mx, my; + + if (!!param.abspos) { + mx = param.abspos.x; + my = param.abspos.y; + } else { + mx = param.containerWidth * param.position.mx; + my = param.containerHeight * param.position.my; + } - /** - * Contains a map of path elements - * - *

Path definition

- * A parameterized path is defined like this: - * - *
-             * 'GATEWAY_PARALLEL': {
-             *   d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
-             *           '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
-             *   height: 17.5,
-             *   width:  17.5,
-             *   heightElements: [2.5, 7.5],
-             *   widthElements: [2.5, 7.5]
-             * }
-             * 
- * - *

- * It's important to specify a correct height and width for the path - * as the scaling is based on the ratio between the specified height and - * width in this object and the height and width that is set as scale target - * (Note x,y coordinates will be scaled with individual ratios). - *

- *

- * The 'heightElements' and 'widthElements' array must - * contain the values that will be scaled. The scaling is based on the - * computed ratios. Coordinates on the y axis should be in the - * heightElement's array, they will be scaled using the computed - * ratio coefficient. In the parameterized path the scaled values can be - * accessed through the 'e' object in {} brackets. - *

    - *
  • The values for the y axis can be accessed in the path string using - * {e.y0}, {e.y1}, ....
  • - *
  • The values for the x axis can be accessed in the path string using - * {e.x0}, {e.x1}, ....
  • - *
- * The numbers x0, x1 respectively y0, y1, ... map to the corresponding - * array index. - *

- */ - this.pathMap = { - 'EVENT_MESSAGE': { - d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}', - height: 36, - width: 36, - heightElements: [6, 14], - widthElements: [10.5, 21] - }, - 'EVENT_SIGNAL': { - d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z', - height: 36, - width: 36, - heightElements: [18], - widthElements: [10, 20] - }, - 'EVENT_ESCALATION': { - d: 'm {mx},{my} c -{e.x1},{e.y0} -{e.x3},{e.y1} -{e.x5},{e.y4} {e.x1},-{e.y3} {e.x3},-{e.y5} {e.x5},-{e.y6} ' + - '{e.x0},{e.y3} {e.x2},{e.y5} {e.x4},{e.y6} -{e.x0},-{e.y0} -{e.x2},-{e.y1} -{e.x4},-{e.y4} z', - height: 36, - width: 36, - heightElements: [2.382, 4.764, 4.926, 6.589333, 7.146, 13.178667, 19.768], - widthElements: [2.463, 2.808, 4.926, 5.616, 7.389, 8.424] - }, - 'EVENT_CONDITIONAL': { - d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' + - 'M {e.x2},{e.y3} l {e.x0},0 ' + - 'M {e.x2},{e.y4} l {e.x0},0 ' + - 'M {e.x2},{e.y5} l {e.x0},0 ' + - 'M {e.x2},{e.y6} l {e.x0},0 ' + - 'M {e.x2},{e.y7} l {e.x0},0 ' + - 'M {e.x2},{e.y8} l {e.x0},0 ', - height: 36, - width: 36, - heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5], - widthElements: [10.5, 14.5, 12.5] - }, - 'EVENT_LINK': { - d: 'm {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z', - height: 36, - width: 36, - heightElements: [4.4375, 6.75, 7.8125], - widthElements: [9.84375, 13.5] - }, - 'EVENT_ERROR': { - d: 'm {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z', - height: 36, - width: 36, - heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714], - widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636] - }, - 'EVENT_CANCEL_45': { - d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' + - '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z', - height: 36, - width: 36, - heightElements: [4.75, 8.5], - widthElements: [4.75, 8.5] - }, - 'EVENT_COMPENSATION': { - d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x0},0 {e.x0},-{e.y0} 0,{e.y1} z', - height: 36, - width: 36, - heightElements: [5, 10], - widthElements: [10] - }, - 'EVENT_TIMER_WH': { - d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ', - height: 36, - width: 36, - heightElements: [10, 2], - widthElements: [3, 7] - }, - 'EVENT_TIMER_LINE': { - d: 'M {mx},{my} ' + - 'm {e.x0},{e.y0} l -{e.x1},{e.y1} ', - height: 36, - width: 36, - heightElements: [10, 3], - widthElements: [0, 0] - }, - 'EVENT_MULTIPLE': { - d: 'm {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z', - height: 36, - width: 36, - heightElements: [6.28099, 12.56199], - widthElements: [3.1405, 9.42149, 12.56198] - }, - 'EVENT_PARALLEL_MULTIPLE': { - d: 'm {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' + - '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z', - height: 36, - width: 36, - heightElements: [2.56228, 7.68683], - widthElements: [2.56228, 7.68683] - }, - 'GATEWAY_EXCLUSIVE': { - d: 'm {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' + - '{e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} ' + - '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z', - height: 17.5, - width: 17.5, - heightElements: [8.5, 6.5312, -6.5312, -8.5], - widthElements: [6.5, -6.5, 3, -3, 5, -5] - }, - 'GATEWAY_PARALLEL': { - d: 'm {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' + - '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z', - height: 30, - width: 30, - heightElements: [5, 12.5], - widthElements: [5, 12.5] - }, - 'GATEWAY_EVENT_BASED': { - d: 'm {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z', - height: 11, - width: 11, - heightElements: [-6, 6, 12, -12], - widthElements: [9, -3, -12] - }, - 'GATEWAY_COMPLEX': { - d: 'm {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} ' + - '{e.x2},0 -{e.x0},{e.y1} l {e.x1},{e.y2} {e.x0},-{e.y1} 0,{e.y0} {e.x3},0 0,-{e.y0} {e.x0},{e.y1} ' + - '{e.x1},-{e.y2} -{e.x0},-{e.y1} {e.x2},0 0,-{e.y3} -{e.x2},0 {e.x0},-{e.y1} -{e.x1},-{e.y2} ' + - '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z', - height: 17.125, - width: 17.125, - heightElements: [4.875, 3.4375, 2.125, 3], - widthElements: [3.4375, 2.125, 4.875, 3] - }, - 'DATA_OBJECT_PATH': { - d: 'm 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0', - height: 61, - width: 51, - heightElements: [10, 50, 60], - widthElements: [10, 40, 50, 60] - }, - 'DATA_OBJECT_COLLECTION_PATH': { - d: 'm {mx}, {my} ' + - 'm 0 15 l 0 -15 ' + - 'm 4 15 l 0 -15 ' + - 'm 4 15 l 0 -15 ', - height: 61, - width: 51, - heightElements: [12], - widthElements: [1, 6, 12, 15] - }, - 'DATA_ARROW': { - d: 'm 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z', - height: 61, - width: 51, - heightElements: [], - widthElements: [] - }, - 'DATA_STORE': { - d: 'm {mx},{my} ' + - 'l 0,{e.y2} ' + - 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' + - 'l 0,-{e.y2} ' + - 'c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0' + - 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' + - 'm -{e.x2},{e.y0}' + - 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0' + - 'm -{e.x2},{e.y0}' + - 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0', - height: 61, - width: 61, - heightElements: [7, 10, 45], - widthElements: [2, 58, 60] - }, - 'TEXT_ANNOTATION': { - d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0', - height: 30, - width: 10, - heightElements: [30], - widthElements: [10] - }, - 'MARKER_SUB_PROCESS': { - d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0', - height: 10, - width: 10, - heightElements: [], - widthElements: [] - }, - 'MARKER_PARALLEL': { - d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10', - height: 10, - width: 10, - heightElements: [], - widthElements: [] - }, - 'MARKER_SEQUENTIAL': { - d: 'm{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0', - height: 10, - width: 10, - heightElements: [], - widthElements: [] - }, - 'MARKER_COMPENSATION': { - d: 'm {mx},{my} 8,-5 0,10 z m 9,0 8,-5 0,10 z', - height: 10, - width: 21, - heightElements: [], - widthElements: [] - }, - 'MARKER_LOOP': { - d: 'm {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 ' + - '-6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 ' + - '0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 ' + - 'l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902', - height: 13.9, - width: 13.7, - heightElements: [], - widthElements: [] - }, - 'MARKER_ADHOC': { - d: 'm {mx},{my} m 0.84461,2.64411 c 1.05533,-1.23780996 2.64337,-2.07882 4.29653,-1.97997996 2.05163,0.0805 ' + - '3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 ' + - '1.2775,-0.64078 1.7542,-1.17511 0,0.56023 0,1.12046 0,1.6807 -0.98706,0.96237996 -2.29792,1.62393996 ' + - '-3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 ' + - '-2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z', - height: 4, - width: 15, - heightElements: [], - widthElements: [] - }, - 'TASK_TYPE_SEND': { - d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}', - height: 14, - width: 21, - heightElements: [6, 14], - widthElements: [10.5, 21] - }, - 'TASK_TYPE_SCRIPT': { - d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' + - 'c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z ' + - 'm -7,-12 l 5,0 ' + - 'm -4.5,3 l 4.5,0 ' + - 'm -3,3 l 5,0' + - 'm -4,3 l 5,0', - height: 15, - width: 12.6, - heightElements: [6, 14], - widthElements: [10.5, 21] - }, - 'TASK_TYPE_USER_1': { - d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' + - '-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' + - '0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' + - 'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' + - 'm -8,6 l 0,5.5 m 11,0 l 0,-5' - }, - 'TASK_TYPE_USER_2': { - d: 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' + - '-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 ' - }, - 'TASK_TYPE_USER_3': { - d: 'm {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 ' + - '4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' + - '-4.20799998,3.36699999 -4.20699998,4.34799999 z' - }, - 'TASK_TYPE_MANUAL': { - d: 'm {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 ' + - '-0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 ' + - '0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 ' + - '-1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 ' + - '0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 ' + - '-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' + - '2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' + - '-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' + - '-1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 ' + - '-0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 ' + - '0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 ' + - '-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z' - }, - 'TASK_TYPE_INSTANTIATING_SEND': { - d: 'm {mx},{my} l 0,8.4 l 12.6,0 l 0,-8.4 z l 6.3,3.6 l 6.3,-3.6' - }, - 'TASK_TYPE_SERVICE': { - d: 'm {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 ' + - '0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 ' + - '-1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 ' + - 'v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 ' + - '-0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 ' + - '-1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 ' + - 'h -2.241173 l 0.0042,1.63124 c -0.353763,0.0736 -0.705369,0.17977 -1.049785,0.32371 -0.344415,0.14437 ' + - '-0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 ' + - 'c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 ' + - 'l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 ' + - '0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 ' + - 'c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z ' + - 'm 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' + - '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' + - '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z' - }, - 'TASK_TYPE_SERVICE_FILL': { - d: 'm {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' + - '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' + - '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z' - }, - 'TASK_TYPE_BUSINESS_RULE_HEADER': { - d: 'm {mx},{my} 0,4 20,0 0,-4 z' - }, - 'TASK_TYPE_BUSINESS_RULE_MAIN': { - d: 'm {mx},{my} 0,12 20,0 0,-12 z' + - 'm 0,8 l 20,0 ' + - 'm -13,-4 l 0,8' - }, - 'MESSAGE_FLOW_MARKER': { - d: 'm {mx},{my} m -10.5 ,-7 l 0,14 l 21,0 l 0,-14 z l 10.5,6 l 10.5,-6' - } - }; + var coordinates = {}; // map for the scaled coordinates + if (param.position) { - this.getRawPath = function getRawPath(pathId) { - return this.pathMap[pathId].d; - }; + // path + var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor; + var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor; - /** - * Scales the path to the given height and width. - *

Use case

- *

- * Use case is to scale the content of elements (event, gateways) based on - * the element bounding box's size. - *

- *

Why not transform

- *

- * Scaling a path with transform() will also scale the stroke and IE does - * not support the option 'non-scaling-stroke' to prevent this. Also there - * are use cases where only some parts of a path should be scaled. - *

- * - * @param {String} - * pathId The ID of the path. - * @param {Object} - * param - *

- * Example param object scales the path to 60% size of the - * container (data.width, data.height). - * - *

-             * {
-             * 	xScaleFactor : 0.6,
-             * 	yScaleFactor : 0.6,
-             * 	containerWidth : data.width,
-             * 	containerHeight : data.height,
-             * 	position : {
-             * 		mx : 0.46,
-             * 		my : 0.2,
-             * 	}
-             * }
-             * 
- * - *
    - *
  • targetpathwidth = xScaleFactor * containerWidth
  • - *
  • targetpathheight = yScaleFactor * containerHeight
  • - *
  • Position is used to set the starting coordinate of the - * path. M is computed: - *
      - *
    • position.x * containerWidth
    • - *
    • position.y * containerHeight
    • - *
    - * Center of the container - * - *
    -             *  position: {
    -             *       mx: 0.5,
    -             *       my: 0.5,
    -             *     }
    -             * 
    - * - * Upper left corner of the container - * - *
    -             *  position: {
    -             *       mx: 0.0,
    -             *       my: 0.0,
    -             *     }
    -             * 
    - * - *
  • - *
- *

- * - */ - this.getScaledPath = function getScaledPath(pathId, param) { - var rawPath = this.pathMap[pathId]; - // positioning - // compute the start point of the path - var mx, my; + // Apply height ratio + for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) { + coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio; + } - if (!!param.abspos) { - mx = param.abspos.x; - my = param.abspos.y; - } else { - mx = param.containerWidth * param.position.mx; - my = param.containerHeight * param.position.my; - } + // Apply width ratio + for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) { + coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio; + } + } - var coordinates = {}; // map for the scaled coordinates - if (param.position) { + // Apply value to raw path + var path = Snap.format( + rawPath.d, { + mx: mx, + my: my, + e: coordinates + } + ); + return path; + }; + } - // path - var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor; - var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor; + module.exports = PathMap; + }, { + "diagram-js/vendor/snapsvg": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\vendor\\snapsvg.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\index.js": [function(require, module, exports) { + module.exports = { + renderer: ['type', require('./BpmnRenderer')], + pathMap: ['type', require('./PathMap')] + }; + }, { + "./BpmnRenderer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\BpmnRenderer.js", + "./PathMap": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\PathMap.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\ContextPadProvider.js": [function(require, module, exports) { + 'use strict'; - // Apply height ratio - for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) { - coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio; - } - // Apply width ratio - for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) { - coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio; - } - } + var assign = require('lodash/object/assign'), + forEach = require('lodash/collection/forEach'); - // Apply value to raw path - var path = Snap.format( - rawPath.d, { - mx: mx, - my: my, - e: coordinates - } - ); - return path; - }; - } - module.exports = PathMap; + /** + * A provider for BPMN 2.0 elements context pad + */ + function ContextPadProvider(contextPad, modeling, elementFactory, + connect, create, bpmnReplace, + canvas) { - }, { - "diagram-js/vendor/snapsvg": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\vendor\\snapsvg.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\index.js": [function(require, module, exports) { - module.exports = { - renderer: ['type', require('./BpmnRenderer')], - pathMap: ['type', require('./PathMap')] - }; - }, { - "./BpmnRenderer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\BpmnRenderer.js", - "./PathMap": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\draw\\PathMap.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\ContextPadProvider.js": [function(require, module, exports) { - 'use strict'; + contextPad.registerProvider(this); + this._contextPad = contextPad; - var assign = require('lodash/object/assign'), - forEach = require('lodash/collection/forEach'); + this._modeling = modeling; + this._elementFactory = elementFactory; + this._connect = connect; + this._create = create; + this._bpmnReplace = bpmnReplace; + this._canvas = canvas; + } - /** - * A provider for BPMN 2.0 elements context pad - */ - function ContextPadProvider(contextPad, modeling, elementFactory, - connect, create, bpmnReplace, - canvas) { + ContextPadProvider.$inject = [ + 'contextPad', + 'modeling', + 'elementFactory', + 'connect', + 'create', + 'bpmnReplace', + 'canvas' + ]; + + ContextPadProvider.prototype.getContextPadEntries = function(element) { + + var contextPad = this._contextPad, + modeling = this._modeling, + + elementFactory = this._elementFactory, + connect = this._connect, + create = this._create, + bpmnReplace = this._bpmnReplace, + canvas = this._canvas; - contextPad.registerProvider(this); + var actions = {}; - this._contextPad = contextPad; + if (element.type === 'label') { + return actions; + } + + var bpmnElement = element.businessObject; + + function startConnect(event, element, autoActivate) { + connect.start(event, element, autoActivate); + } - this._modeling = modeling; + function removeElement(e) { + console.log(e); + if (element.waypoints) { + modeling.removeConnection(element); + } else { + modeling.removeShape(element); - this._elementFactory = elementFactory; - this._connect = connect; - this._create = create; - this._bpmnReplace = bpmnReplace; - this._canvas = canvas; } + if (element.id == selected_decison_element) { - ContextPadProvider.$inject = [ - 'contextPad', - 'modeling', - 'elementFactory', - 'connect', - 'create', - 'bpmnReplace', - 'canvas' - ]; + invisiblepropertyExplorer(); + } + } - ContextPadProvider.prototype.getContextPadEntries = function(element) { + function getReplaceMenuPosition(element) { - var contextPad = this._contextPad, - modeling = this._modeling, + var Y_OFFSET = 5; - elementFactory = this._elementFactory, - connect = this._connect, - create = this._create, - bpmnReplace = this._bpmnReplace, - canvas = this._canvas; + var diagramContainer = canvas.getContainer(), + pad = contextPad.getPad(element).html; - var actions = {}; + var diagramRect = diagramContainer.getBoundingClientRect(), + padRect = pad.getBoundingClientRect(); - if (element.type === 'label') { - return actions; - } + var top = padRect.top - diagramRect.top; + var left = padRect.left - diagramRect.left; - var bpmnElement = element.businessObject; + var pos = { + x: left, + y: top + padRect.height + Y_OFFSET + }; - function startConnect(event, element, autoActivate) { - connect.start(event, element, autoActivate); - } + return pos; + } - function removeElement(e) { - console.log(e); - if (element.waypoints) { - modeling.removeConnection(element); - } else { - modeling.removeShape(element); - - } - if(element.id == selected_decison_element) - { - - invisiblepropertyExplorer(); - } - } - function getReplaceMenuPosition(element) { + var change_color = function(par1, par2) { + if (isImportSchema == true) { - var Y_OFFSET = 5; + return par2 /*'define-schema'*/ ; + } else { + return par1 /*'define-modify-schema'*/ ; + } + } - var diagramContainer = canvas.getContainer(), - pad = contextPad.getPad(element).html; + function appendAction(type, className, options) { - var diagramRect = diagramContainer.getBoundingClientRect(), - padRect = pad.getBoundingClientRect(); + function appendListener(event, element) { - var top = padRect.top - diagramRect.top; - var left = padRect.left - diagramRect.left; + var shape = elementFactory.createShape(assign({ + type: type + }, options)); + create.start(event, shape, element); + } - var pos = { - x: left, - y: top + padRect.height + Y_OFFSET - }; + var shortType = type.replace(/^bpmn\:/, ''); - return pos; - } + return { + group: 'model', + className: className, + title: 'Append ' + shortType, + action: { + dragstart: appendListener, + click: appendListener + } + }; + } - - var change_color = function(par1,par2) - { - if(isImportSchema == true){ - return par2/*'define-schema'*/; - } - else - { - return par1/*'define-modify-schema'*/; - } - } - function appendAction(type, className, options) { + if (bpmnElement.$instanceOf('bpmn:Gateway') || bpmnElement.$instanceOf('bpmn:MultiBranchConnector')) { + assign(actions, { + 'define-path': { + group: 'DefinePath', + className: 'define-path', + title: 'Define/View Path', + action: { + click: function(event) { - function appendListener(event, element) { + if (bpmnElement.name) { + var bpmnElementID = bpmnElement.id; + selected_decison_element = bpmnElementID; + var bpmnElementName = bpmnElement.name; + selected_element_name = bpmnElementName; + var pathIdentifiers = []; - var shape = elementFactory.createShape(assign({ - type: type - }, options)); - create.start(event, shape, element); - } + if (bpmnElement.outgoing) { - var shortType = type.replace(/^bpmn\:/, ''); + var check_outgoing_names = true; + forEach(bpmnElement.outgoing, function(og) { - return { - group: 'model', - className: className, - title: 'Append ' + shortType, - action: { - dragstart: appendListener, - click: appendListener - } - }; - } + if (og.name && og.name.length != 0) { + pathIdentifiers.push(og.name); - if (bpmnElement.$instanceOf('bpmn:Gateway') || bpmnElement.$instanceOf('bpmn:MultiBranchConnector')) { - assign(actions, { - 'define-path': { - group: 'DefinePath', - className: 'define-path', - title: 'Define/View Path', - action: { - click: function(event) { - - if(bpmnElement.name){ - var bpmnElementID = bpmnElement.id; - selected_decison_element = bpmnElementID; - var bpmnElementName = bpmnElement.name; - selected_element_name = bpmnElementName; - var pathIdentifiers = []; - - if (bpmnElement.outgoing) { - - var check_outgoing_names = true; - forEach(bpmnElement.outgoing, function(og) { - - if(og.name && og.name.length !=0) - { - - pathIdentifiers.push(og.name); - - } - else - { - - errorProperty(bpmnElement.name+" out going path name was not entered"); - check_outgoing_names=false; - } - - }); - if(check_outgoing_names) - { - - pathDetails(bpmnElementID,bpmnElementName,pathIdentifiers); - } - - - - } - else - { - errorProperty(bpmnElement.name+' should atleast one output path was required'); - } - - } - else - { - errorProperty('Enter Valid Decision Name'); - } - } - } + } else { + + errorProperty(bpmnElement.name + " out going path name was not entered"); + check_outgoing_names = false; + } + + }); + if (check_outgoing_names) { + + pathDetails(bpmnElementID, bpmnElementName, pathIdentifiers); } - }); - } - - if (bpmnElement.$instanceOf('bpmn:InitiateProcess')) { + + } else { + errorProperty(bpmnElement.name + ' should atleast one output path was required'); + } + + } else { + errorProperty('Enter Valid Decision Name'); + } + } } + } + }); + } - if (bpmnElement.$instanceOf('bpmn:StartEvent')) { + + + if (bpmnElement.$instanceOf('bpmn:InitiateProcess')) {} + + if (bpmnElement.$instanceOf('bpmn:StartEvent')) {} + if (bpmnElement.$instanceOf('bpmn:Collector')) { + assign(actions, { + 'Properties': { + group: 'clds', + label: 'Edit Properties', + className: 'clds-edit-properties', + title: 'Properties', + action: { + click: function(event) { + lastElementSelected = bpmnElement.id + CollectorsWindow(bpmnElement); + } } - if (bpmnElement.$instanceOf('bpmn:Collector')) { - assign(actions, { - 'Properties': { - group: 'clds', - label: 'Edit Properties', - className: 'clds-edit-properties', - title: 'Properties', - action: { - click: function(event) { - lastElementSelected=bpmnElement.id - CollectorsWindow(bpmnElement); - } - } - } - }); - - } - if (bpmnElement.$instanceOf('bpmn:StringMatch')) { - assign(actions, { - 'Properties': { - group: 'clds', - label: 'Edit Properties', - className: 'clds-edit-properties', - title: 'Properties', - action: { - click: function(event) { - lastElementSelected=bpmnElement.id - StringMatchWindow(bpmnElement); - } - } - } - }); + } + }); + } - if (bpmnElement.$instanceOf('bpmn:Holmes')) { - assign(actions, { - 'Properties': { - group: 'clds', - label: 'Edit Properties', - className: 'clds-edit-properties', - title: 'Properties', - action: { - click: function(event) { - lastElementSelected=bpmnElement.id - HolmesWindow(bpmnElement); - } - } - } - }); + if (bpmnElement.$instanceOf('bpmn:StringMatch')) { + assign(actions, { + 'Properties': { + group: 'clds', + label: 'Edit Properties', + className: 'clds-edit-properties', + title: 'Properties', + action: { + click: function(event) { + lastElementSelected = bpmnElement.id + StringMatchWindow(bpmnElement); + } + } + } + }); } - if (bpmnElement.$instanceOf('bpmn:TCA')) { - assign(actions, { - 'Properties': { - group: 'clds', - label: 'Edit Properties', - className: 'clds-edit-properties', - title: 'Properties', - action: { - click: function(event) { - console.log(event); - lastElementSelected=bpmnElement.id - } - } - } - }); + if (bpmnElement.$instanceOf('bpmn:Holmes')) { + assign(actions, { + 'Properties': { + group: 'clds', + label: 'Edit Properties', + className: 'clds-edit-properties', + title: 'Properties', + action: { + click: function(event) { + lastElementSelected = bpmnElement.id + HolmesWindow(bpmnElement); + } } - if (bpmnElement.$instanceOf('bpmn:GOC')) { - assign(actions, { - 'Properties': { - group: 'clds', - label: 'Edit Properties', - className: 'clds-edit-properties', - title: 'Properties', - action: { - click: function(event) { - lastElementSelected=bpmnElement.id - GOCWindow(); - } - } - } - }); + } + }); + } + if (bpmnElement.$instanceOf('bpmn:TCA')) { + assign(actions, { + 'Properties': { + group: 'clds', + label: 'Edit Properties', + className: 'clds-edit-properties', + title: 'Properties', + action: { + click: function(event) { + console.log(event); + lastElementSelected = bpmnElement.id + } } - if (bpmnElement.$instanceOf('bpmn:Policy')) { - assign(actions, { - 'Properties': { - group: 'clds', - label: 'Edit Properties', - className: 'clds-edit-properties', - title: 'Properties', - action: { - click: function(event) { - lastElementSelected=bpmnElement.id - PolicyWindow(bpmnElement); - } - } - } - }); + } + }); + } + if (bpmnElement.$instanceOf('bpmn:GOC')) { + assign(actions, { + 'Properties': { + group: 'clds', + label: 'Edit Properties', + className: 'clds-edit-properties', + title: 'Properties', + action: { + click: function(event) { + lastElementSelected = bpmnElement.id + GOCWindow(); + } + } + } + }); + } + if (bpmnElement.$instanceOf('bpmn:Policy')) { + assign(actions, { + 'Properties': { + group: 'clds', + label: 'Edit Properties', + className: 'clds-edit-properties', + title: 'Properties', + action: { + click: function(event) { + lastElementSelected = bpmnElement.id + PolicyWindow(bpmnElement); + } } + } + }); + } - if (bpmnElement.$instanceOf('bpmn:FlowNode') || - bpmnElement.$instanceOf('bpmn:InteractionNode')) { + if (bpmnElement.$instanceOf('bpmn:FlowNode') || + bpmnElement.$instanceOf('bpmn:InteractionNode')) { - assign(actions, { - 'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation'), + assign(actions, { + 'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation'), - 'connect': { - group: 'connect', - className: 'icon-connection', - title: 'Connector', - action: { - click: startConnect, - dragstart: startConnect - } - } - }); + 'connect': { + group: 'connect', + className: 'icon-connection', + title: 'Connector', + action: { + click: startConnect, + dragstart: startConnect } - - // Delete Element Entry - assign(actions, { - 'delete': { - group: 'edits', - className: 'icon-trash', - title: 'Remove', - action: { - click: removeElement, - dragstart: removeElement - } - } + } + }); + } + // Delete Element Entry + assign(actions, { + 'delete': { + group: 'edits', + className: 'icon-trash', + title: 'Remove', + action: { + click: removeElement, + dragstart: removeElement + } + } - }); - return actions; - }; + }); - function isEventType(eventBo, type, definition) { + return actions; + }; - var isType = eventBo.$instanceOf(type); - var isDefinition = false; + function isEventType(eventBo, type, definition) { - var definitions = eventBo.eventDefinitions || []; - forEach(definitions, function(def) { - if (def.$type === definition) { - isDefinition = true; - } - }); + var isType = eventBo.$instanceOf(type); + var isDefinition = false; - return isType && isDefinition; + var definitions = eventBo.eventDefinitions || []; + forEach(definitions, function(def) { + if (def.$type === definition) { + isDefinition = true; } + }); + return isType && isDefinition; + } - module.exports = ContextPadProvider; - }, { - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('diagram-js-direct-editing'), - require('diagram-js/lib/features/context-pad'), - require('diagram-js/lib/features/selection'), - require('diagram-js/lib/features/connect'), - require('diagram-js/lib/features/create'), - require('../replace') - ], - __init__: ['contextPadProvider'], - contextPadProvider: ['type', require('./ContextPadProvider')] - }; - }, { - "../replace": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\index.js", - "./ContextPadProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\ContextPadProvider.js", - "diagram-js-direct-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\diagram-js-direct-editing\\index.js", - "diagram-js/lib/features/connect": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\connect\\index.js", - "diagram-js/lib/features/context-pad": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\context-pad\\index.js", - "diagram-js/lib/features/create": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\create\\index.js", - "diagram-js/lib/features/selection": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\selection\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\BpmnKeyBindings.js": [function(require, module, exports) { - 'use strict'; + module.exports = ContextPadProvider; + + }, { + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('diagram-js-direct-editing'), + require('diagram-js/lib/features/context-pad'), + require('diagram-js/lib/features/selection'), + require('diagram-js/lib/features/connect'), + require('diagram-js/lib/features/create'), + require('../replace') + ], + __init__: ['contextPadProvider'], + contextPadProvider: ['type', require('./ContextPadProvider')] + }; + }, { + "../replace": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\index.js", + "./ContextPadProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\context-pad\\ContextPadProvider.js", + "diagram-js-direct-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\diagram-js-direct-editing\\index.js", + "diagram-js/lib/features/connect": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\connect\\index.js", + "diagram-js/lib/features/context-pad": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\context-pad\\index.js", + "diagram-js/lib/features/create": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\create\\index.js", + "diagram-js/lib/features/selection": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\selection\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\BpmnKeyBindings.js": [function(require, module, exports) { + 'use strict'; + + + function BpmnKeyBindings(keyboard, spaceTool, lassoTool, directEditing, selection) { + + keyboard.addListener(function(key, modifiers) { + + if (keyboard.hasModifier(modifiers)) { + return; + } + // S -> activate space tool + if (key === 83) { + spaceTool.activateSelection(); - function BpmnKeyBindings(keyboard, spaceTool, lassoTool, directEditing, selection) { - - keyboard.addListener(function(key, modifiers) { - - if (keyboard.hasModifier(modifiers)) { - return; - } + return true; + } - // S -> activate space tool - if (key === 83) { - spaceTool.activateSelection(); + // L -> activate lasso tool + if (key === 108) { + lassoTool.activateSelection(); - return true; - } + return true; + } - // L -> activate lasso tool - if (key === 108) { - lassoTool.activateSelection(); + var currentSelection = selection.get(); - return true; - } + // E -> activate direct editing + if (key === 69) { + if (currentSelection.length) { + directEditing.activate(currentSelection[0]); + } - var currentSelection = selection.get(); + return true; + } + }); + } - // E -> activate direct editing - if (key === 69) { - if (currentSelection.length) { - directEditing.activate(currentSelection[0]); - } + BpmnKeyBindings.$inject = ['keyboard', 'spaceTool', 'lassoTool', 'directEditing', 'selection']; - return true; - } - }); - } + module.exports = BpmnKeyBindings; + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('diagram-js/lib/features/keyboard') + ], + __init__: ['bpmnKeyBindings'], + bpmnKeyBindings: ['type', require('./BpmnKeyBindings')] + }; + }, { + "./BpmnKeyBindings": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\BpmnKeyBindings.js", + "diagram-js/lib/features/keyboard": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\keyboard\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelEditingProvider.js": [function(require, module, exports) { + 'use strict'; - BpmnKeyBindings.$inject = ['keyboard', 'spaceTool', 'lassoTool', 'directEditing', 'selection']; + var UpdateLabelHandler = require('./cmd/UpdateLabelHandler'); - module.exports = BpmnKeyBindings; - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('diagram-js/lib/features/keyboard') - ], - __init__: ['bpmnKeyBindings'], - bpmnKeyBindings: ['type', require('./BpmnKeyBindings')] - }; - }, { - "./BpmnKeyBindings": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\keyboard\\BpmnKeyBindings.js", - "diagram-js/lib/features/keyboard": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\keyboard\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelEditingProvider.js": [function(require, module, exports) { - 'use strict'; + var LabelUtil = require('./LabelUtil'); - var UpdateLabelHandler = require('./cmd/UpdateLabelHandler'); + var is = require('../../util/ModelUtil').is, + isExpanded = require('../../util/DiUtil').isExpanded; - var LabelUtil = require('./LabelUtil'); + var daOriginalLabel = ''; - var is = require('../../util/ModelUtil').is, - isExpanded = require('../../util/DiUtil').isExpanded; + var MIN_BOUNDS = { + width: 150, + height: 50 + }; - var daOriginalLabel = ''; - var MIN_BOUNDS = { - width: 150, - height: 50 - }; + function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, injector) { + directEditing.registerProvider(this); + commandStack.registerHandler('element.updateLabel', UpdateLabelHandler); - function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, injector) { + // listen to dblclick on non-root elements + eventBus.on('element.dblclick', function(event) { - directEditing.registerProvider(this); - commandStack.registerHandler('element.updateLabel', UpdateLabelHandler); + directEditing.activate(event.element); + }); - // listen to dblclick on non-root elements - eventBus.on('element.dblclick', function(event) { - - directEditing.activate(event.element); - }); - - // complete on followup canvas operation - eventBus.on(['element.mousedown', 'drag.activate', 'canvas.viewbox.changed'], function(event) { - directEditing.complete(); - }); + // complete on followup canvas operation + eventBus.on(['element.mousedown', 'drag.activate', 'canvas.viewbox.changed'], function(event) { + directEditing.complete(); + }); - // cancel on command stack changes - eventBus.on(['commandStack.changed'], function() { - directEditing.cancel(); - }); + // cancel on command stack changes + eventBus.on(['commandStack.changed'], function() { + directEditing.cancel(); + }); - // activate direct editing for activities and text annotations + // activate direct editing for activities and text annotations - if ('ontouchstart' in document.documentElement) { - // we deactivate automatic label editing on mobile devices - // as it breaks the user interaction workflow + if ('ontouchstart' in document.documentElement) { + // we deactivate automatic label editing on mobile devices + // as it breaks the user interaction workflow - // TODO(nre): we should temporarily focus the edited element here - // and release the focused viewport after the direct edit operation is - // finished - } else { - eventBus.on('create.end', 500, function(e) { + // TODO(nre): we should temporarily focus the edited element here + // and release the focused viewport after the direct edit operation is + // finished + } else { + eventBus.on('create.end', 500, function(e) { - var element = e.shape, - canExecute = e.context.canExecute; + var element = e.shape, + canExecute = e.context.canExecute; - if (!canExecute) { - return; - } + if (!canExecute) { + return; + } - if (is(element, 'bpmn:Task') || is(element, 'bpmn:TextAnnotation') || - (is(element, 'bpmn:SubProcess') && !isExpanded(element))) { + if (is(element, 'bpmn:Task') || is(element, 'bpmn:TextAnnotation') || + (is(element, 'bpmn:SubProcess') && !isExpanded(element))) { - directEditing.activate(element); - } - }); - } + directEditing.activate(element); + } + }); + } - this._canvas = canvas; - this._commandStack = commandStack; - } + this._canvas = canvas; + this._commandStack = commandStack; + } - LabelEditingProvider.$inject = ['eventBus', 'canvas', 'directEditing', 'commandStack', 'injector']; + LabelEditingProvider.$inject = ['eventBus', 'canvas', 'directEditing', 'commandStack', 'injector']; - module.exports = LabelEditingProvider; + module.exports = LabelEditingProvider; - LabelEditingProvider.prototype.activate = function(element) { + LabelEditingProvider.prototype.activate = function(element) { - var text = LabelUtil.getLabel(element); + var text = LabelUtil.getLabel(element); - if (text === undefined) { - return; - } + if (text === undefined) { + return; + } - daOriginalLabel = text; - - var bbox = this.getEditingBBox(element); + daOriginalLabel = text; - // adjust for expanded pools AND lanes - if ((is(element, 'bpmn:Participant') && isExpanded(element)) || is(element, 'bpmn:Lane')) { + var bbox = this.getEditingBBox(element); - bbox.width = MIN_BOUNDS.width; - bbox.height = MIN_BOUNDS.height; + // adjust for expanded pools AND lanes + if ((is(element, 'bpmn:Participant') && isExpanded(element)) || is(element, 'bpmn:Lane')) { - bbox.x = bbox.x + 10 - bbox.width / 2; - bbox.y = bbox.mid.y - bbox.height / 2; - } + bbox.width = MIN_BOUNDS.width; + bbox.height = MIN_BOUNDS.height; - // adjust for expanded sub processes - if (is(element, 'bpmn:SubProcess') && isExpanded(element)) { + bbox.x = bbox.x + 10 - bbox.width / 2; + bbox.y = bbox.mid.y - bbox.height / 2; + } - bbox.height = MIN_BOUNDS.height; + // adjust for expanded sub processes + if (is(element, 'bpmn:SubProcess') && isExpanded(element)) { - bbox.x = bbox.mid.x - bbox.width / 2; - bbox.y = bbox.y + 10 - bbox.height / 2; - } + bbox.height = MIN_BOUNDS.height; - return { - bounds: bbox, - text: text - }; - }; + bbox.x = bbox.mid.x - bbox.width / 2; + bbox.y = bbox.y + 10 - bbox.height / 2; + } + return { + bounds: bbox, + text: text + }; + }; - LabelEditingProvider.prototype.getEditingBBox = function(element, maxBounds) { - var target = element.label || element; + LabelEditingProvider.prototype.getEditingBBox = function(element, maxBounds) { - var bbox = this._canvas.getAbsoluteBBox(target); + var target = element.label || element; - var mid = { - x: bbox.x + bbox.width / 2, - y: bbox.y + bbox.height / 2 - }; + var bbox = this._canvas.getAbsoluteBBox(target); - // external label - if (target.labelTarget) { - bbox.width = Math.max(bbox.width, MIN_BOUNDS.width); - bbox.height = Math.max(bbox.height, MIN_BOUNDS.height); + var mid = { + x: bbox.x + bbox.width / 2, + y: bbox.y + bbox.height / 2 + }; - bbox.x = mid.x - bbox.width / 2; - } + // external label + if (target.labelTarget) { + bbox.width = Math.max(bbox.width, MIN_BOUNDS.width); + bbox.height = Math.max(bbox.height, MIN_BOUNDS.height); - bbox.mid = mid; + bbox.x = mid.x - bbox.width / 2; + } - return bbox; - }; + bbox.mid = mid; + return bbox; + }; - LabelEditingProvider.prototype.update = function(element, newLabel) { - //update conditional node - if (is(element, 'bpmn:ExclusiveGateway') || is(element, 'bpmn:MultiBranchConnector')){ - updateDecisionLabel(daOriginalLabel, newLabel); - } - - this._commandStack.execute('element.updateLabel', { - element: element, - newLabel: newLabel - }); - }; - }, { - "../../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", - "../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "./LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelUtil.js", - "./cmd/UpdateLabelHandler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\cmd\\UpdateLabelHandler.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelUtil.js": [function(require, module, exports) { - 'use strict'; - function getLabelAttr(semantic) { - if (semantic.$instanceOf('bpmn:FlowElement') || - semantic.$instanceOf('bpmn:Participant') || - semantic.$instanceOf('bpmn:Lane') || - semantic.$instanceOf('bpmn:SequenceFlow') || - semantic.$instanceOf('bpmn:MessageFlow')) { - return 'name'; - } + LabelEditingProvider.prototype.update = function(element, newLabel) { + //update conditional node + if (is(element, 'bpmn:ExclusiveGateway') || is(element, 'bpmn:MultiBranchConnector')) { + updateDecisionLabel(daOriginalLabel, newLabel); + } - if (semantic.$instanceOf('bpmn:TextAnnotation')) { - return 'text'; - } - } + this._commandStack.execute('element.updateLabel', { + element: element, + newLabel: newLabel + }); + }; + }, { + "../../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", + "../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "./LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelUtil.js", + "./cmd/UpdateLabelHandler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\cmd\\UpdateLabelHandler.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelUtil.js": [function(require, module, exports) { + 'use strict'; + + function getLabelAttr(semantic) { + if (semantic.$instanceOf('bpmn:FlowElement') || + semantic.$instanceOf('bpmn:Participant') || + semantic.$instanceOf('bpmn:Lane') || + semantic.$instanceOf('bpmn:SequenceFlow') || + semantic.$instanceOf('bpmn:MessageFlow')) { + return 'name'; + } - module.exports.getLabel = function(element) { - var semantic = element.businessObject, - attr = getLabelAttr(semantic); + if (semantic.$instanceOf('bpmn:TextAnnotation')) { + return 'text'; + } + } - if (attr) { - return semantic[attr] || ''; - } - }; + module.exports.getLabel = function(element) { + var semantic = element.businessObject, + attr = getLabelAttr(semantic); + if (attr) { + return semantic[attr] || ''; + } + }; - module.exports.setLabel = function(element, text) { - var semantic = element.businessObject, - attr = getLabelAttr(semantic); - if (attr) { - semantic[attr] = text; - } + module.exports.setLabel = function(element, text) { + var semantic = element.businessObject, + attr = getLabelAttr(semantic); - var label = element.label || element; + if (attr) { + semantic[attr] = text; + } - // show label - label.hidden = false; + var label = element.label || element; - return label; - }; - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\cmd\\UpdateLabelHandler.js": [function(require, module, exports) { - 'use strict'; + // show label + label.hidden = false; - var LabelUtil = require('../LabelUtil'); + return label; + }; + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\cmd\\UpdateLabelHandler.js": [function(require, module, exports) { + 'use strict'; + var LabelUtil = require('../LabelUtil'); - /** - * A handler that updates the text of a BPMN element. - * - * @param {EventBus} - * eventBus - */ - function UpdateTextHandler(eventBus) { - function setText(element, text) { - var label = LabelUtil.setLabel(element, text); + /** + * A handler that updates the text of a BPMN element. + * + * @param {EventBus} + * eventBus + */ + function UpdateTextHandler(eventBus) { - eventBus.fire('element.changed', { - element: label - }); - } + function setText(element, text) { + var label = LabelUtil.setLabel(element, text); - function execute(ctx) { - ctx.oldLabel = LabelUtil.getLabel(ctx.element); - return setText(ctx.element, ctx.newLabel); - } + eventBus.fire('element.changed', { + element: label + }); + } - function revert(ctx) { - return setText(ctx.element, ctx.oldLabel); - } + function execute(ctx) { + ctx.oldLabel = LabelUtil.getLabel(ctx.element); + return setText(ctx.element, ctx.newLabel); + } + function revert(ctx) { + return setText(ctx.element, ctx.oldLabel); + } - function canExecute(ctx) { - return true; - } - // API + function canExecute(ctx) { + return true; + } - this.execute = execute; - this.revert = revert; + // API - this.canExecute = canExecute; - } + this.execute = execute; + this.revert = revert; + this.canExecute = canExecute; + } - UpdateTextHandler.$inject = ['eventBus']; - module.exports = UpdateTextHandler; - }, { - "../LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelUtil.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('diagram-js/lib/command'), - require('diagram-js/lib/features/change-support'), - require('diagram-js-direct-editing') - ], - __init__: ['labelEditingProvider'], - labelEditingProvider: ['type', require('./LabelEditingProvider')] - }; - }, { - "./LabelEditingProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelEditingProvider.js", - "diagram-js-direct-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\diagram-js-direct-editing\\index.js", - "diagram-js/lib/command": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\index.js", - "diagram-js/lib/features/change-support": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\change-support\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnFactory.js": [function(require, module, exports) { - 'use strict'; + UpdateTextHandler.$inject = ['eventBus']; + + module.exports = UpdateTextHandler; + }, { + "../LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelUtil.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('diagram-js/lib/command'), + require('diagram-js/lib/features/change-support'), + require('diagram-js-direct-editing') + ], + __init__: ['labelEditingProvider'], + labelEditingProvider: ['type', require('./LabelEditingProvider')] + }; + }, { + "./LabelEditingProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\LabelEditingProvider.js", + "diagram-js-direct-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\diagram-js-direct-editing\\index.js", + "diagram-js/lib/command": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\index.js", + "diagram-js/lib/features/change-support": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\change-support\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnFactory.js": [function(require, module, exports) { + 'use strict'; + + var map = require('lodash/collection/map'), + assign = require('lodash/object/assign'), + pick = require('lodash/object/pick'); + + + function BpmnFactory(moddle) { + this._model = moddle; + } - var map = require('lodash/collection/map'), - assign = require('lodash/object/assign'), - pick = require('lodash/object/pick'); + BpmnFactory.$inject = ['moddle']; - function BpmnFactory(moddle) { - this._model = moddle; - } + BpmnFactory.prototype._needsId = function(element) { + return element.$instanceOf('bpmn:RootElement') || + element.$instanceOf('bpmn:FlowElement') || + element.$instanceOf('bpmn:MessageFlow') || + element.$instanceOf('bpmn:Artifact') || + element.$instanceOf('bpmn:Participant') || + element.$instanceOf('bpmn:Process') || + element.$instanceOf('bpmn:Collaboration') || + element.$instanceOf('bpmndi:BPMNShape') || + element.$instanceOf('bpmndi:BPMNEdge') || + element.$instanceOf('bpmndi:BPMNDiagram') || + element.$instanceOf('bpmndi:BPMNPlane'); + }; - BpmnFactory.$inject = ['moddle']; + BpmnFactory.prototype._ensureId = function(element) { + // generate semantic ids for elements + // bpmn:SequenceFlow -> SequenceFlow_ID + var prefix = (element.$type || '').replace(/^[^:]*:/g, '') + '_'; - BpmnFactory.prototype._needsId = function(element) { - return element.$instanceOf('bpmn:RootElement') || - element.$instanceOf('bpmn:FlowElement') || - element.$instanceOf('bpmn:MessageFlow') || - element.$instanceOf('bpmn:Artifact') || - element.$instanceOf('bpmn:Participant') || - element.$instanceOf('bpmn:Process') || - element.$instanceOf('bpmn:Collaboration') || - element.$instanceOf('bpmndi:BPMNShape') || - element.$instanceOf('bpmndi:BPMNEdge') || - element.$instanceOf('bpmndi:BPMNDiagram') || - element.$instanceOf('bpmndi:BPMNPlane'); - }; + if (!element.id && this._needsId(element)) { + element.id = this._model.ids.nextPrefixed(prefix, element); + } + }; - BpmnFactory.prototype._ensureId = function(element) { - // generate semantic ids for elements - // bpmn:SequenceFlow -> SequenceFlow_ID - var prefix = (element.$type || '').replace(/^[^:]*:/g, '') + '_'; + BpmnFactory.prototype.create = function(type, attrs) { + var element = this._model.create(type, attrs || {}); - if (!element.id && this._needsId(element)) { - element.id = this._model.ids.nextPrefixed(prefix, element); - } - }; + this._ensureId(element); + return element; + }; - BpmnFactory.prototype.create = function(type, attrs) { - var element = this._model.create(type, attrs || {}); - this._ensureId(element); + BpmnFactory.prototype.createDiLabel = function() { + return this.create('bpmndi:BPMNLabel', { + bounds: this.createDiBounds() + }); + }; - return element; - }; + BpmnFactory.prototype.createDiShape = function(semantic, bounds, attrs) { - BpmnFactory.prototype.createDiLabel = function() { - return this.create('bpmndi:BPMNLabel', { - bounds: this.createDiBounds() - }); - }; + return this.create('bpmndi:BPMNShape', assign({ + bpmnElement: semantic, + bounds: this.createDiBounds(bounds) + }, attrs)); + }; - BpmnFactory.prototype.createDiShape = function(semantic, bounds, attrs) { + BpmnFactory.prototype.createDiBounds = function(bounds) { + return this.create('dc:Bounds', bounds); + }; - return this.create('bpmndi:BPMNShape', assign({ - bpmnElement: semantic, - bounds: this.createDiBounds(bounds) - }, attrs)); - }; + BpmnFactory.prototype.createDiWaypoints = function(waypoints) { + return map(waypoints, function(pos) { + return this.createDiWaypoint(pos); + }, this); + }; - BpmnFactory.prototype.createDiBounds = function(bounds) { - return this.create('dc:Bounds', bounds); - }; + BpmnFactory.prototype.createDiWaypoint = function(point) { + return this.create('dc:Point', pick(point, ['x', 'y'])); + }; - BpmnFactory.prototype.createDiWaypoints = function(waypoints) { - return map(waypoints, function(pos) { - return this.createDiWaypoint(pos); - }, this); - }; + BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) { + return this.create('bpmndi:BPMNEdge', assign({ + bpmnElement: semantic + }, attrs)); + }; - BpmnFactory.prototype.createDiWaypoint = function(point) { - return this.create('dc:Point', pick(point, ['x', 'y'])); - }; + BpmnFactory.prototype.createDiPlane = function(semantic) { + return this.create('bpmndi:BPMNPlane', { + bpmnElement: semantic + }); + }; + module.exports = BpmnFactory; - BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) { - return this.create('bpmndi:BPMNEdge', assign({ - bpmnElement: semantic - }, attrs)); - }; + }, { + "lodash/collection/map": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\map.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", + "lodash/object/pick": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\pick.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnLayouter.js": [function(require, module, exports) { + 'use strict'; - BpmnFactory.prototype.createDiPlane = function(semantic) { - return this.create('bpmndi:BPMNPlane', { - bpmnElement: semantic - }); - }; + var inherits = require('inherits'); - module.exports = BpmnFactory; + var assign = require('lodash/object/assign'); - }, { - "lodash/collection/map": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\map.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", - "lodash/object/pick": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\pick.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnLayouter.js": [function(require, module, exports) { - 'use strict'; + var BaseLayouter = require('diagram-js/lib/layout/BaseLayouter'), + LayoutUtil = require('diagram-js/lib/layout/LayoutUtil'), + ManhattanLayout = require('diagram-js/lib/layout/ManhattanLayout'); - var inherits = require('inherits'); + var is = require('../../util/ModelUtil').is; - var assign = require('lodash/object/assign'); - var BaseLayouter = require('diagram-js/lib/layout/BaseLayouter'), - LayoutUtil = require('diagram-js/lib/layout/LayoutUtil'), - ManhattanLayout = require('diagram-js/lib/layout/ManhattanLayout'); + function BpmnLayouter() {} - var is = require('../../util/ModelUtil').is; + inherits(BpmnLayouter, BaseLayouter); + module.exports = BpmnLayouter; - function BpmnLayouter() {} - inherits(BpmnLayouter, BaseLayouter); + function getAttachment(waypoints, idx, shape) { + var point = waypoints && waypoints[idx]; - module.exports = BpmnLayouter; + return point ? (point.original || point) : LayoutUtil.getMidPoint(shape); + } - function getAttachment(waypoints, idx, shape) { - var point = waypoints && waypoints[idx]; + BpmnLayouter.prototype.layoutConnection = function(connection, hints) { + var source = connection.source, + target = connection.target, + waypoints = connection.waypoints, + start, + end; - return point ? (point.original || point) : LayoutUtil.getMidPoint(shape); - } + var layoutManhattan, + updatedWaypoints; + start = getAttachment(waypoints, 0, source); + end = getAttachment(waypoints, waypoints && waypoints.length - 1, target); - BpmnLayouter.prototype.layoutConnection = function(connection, hints) { - var source = connection.source, - target = connection.target, - waypoints = connection.waypoints, - start, - end; + // manhattan layout sequence / message flows + if (is(connection, 'bpmn:MessageFlow')) { + layoutManhattan = { + preferStraight: true, + preferVertical: true + }; + } - var layoutManhattan, - updatedWaypoints; + if (is(connection, 'bpmn:SequenceFlow')) { + layoutManhattan = {}; + } - start = getAttachment(waypoints, 0, source); - end = getAttachment(waypoints, waypoints && waypoints.length - 1, target); + if (layoutManhattan) { - // manhattan layout sequence / message flows - if (is(connection, 'bpmn:MessageFlow')) { - layoutManhattan = { - preferStraight: true, - preferVertical: true - }; - } + layoutManhattan = assign(layoutManhattan, hints); - if (is(connection, 'bpmn:SequenceFlow')) { - layoutManhattan = {}; - } + updatedWaypoints = + ManhattanLayout.repairConnection( + source, target, start, end, + waypoints, + layoutManhattan); + } - if (layoutManhattan) { + return updatedWaypoints || [start, end]; + }; + }, { + "../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "diagram-js/lib/layout/BaseLayouter": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\BaseLayouter.js", + "diagram-js/lib/layout/LayoutUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\LayoutUtil.js", + "diagram-js/lib/layout/ManhattanLayout": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\ManhattanLayout.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnUpdater.js": [function(require, module, exports) { + 'use strict'; - layoutManhattan = assign(layoutManhattan, hints); + var assign = require('lodash/object/assign'), + forEach = require('lodash/collection/forEach'), + inherits = require('inherits'); - updatedWaypoints = - ManhattanLayout.repairConnection( - source, target, start, end, - waypoints, - layoutManhattan); - } + var Collections = require('diagram-js/lib/util/Collections'), + Model = require('diagram-js/lib/model'); - return updatedWaypoints || [start, end]; - }; - }, { - "../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "diagram-js/lib/layout/BaseLayouter": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\BaseLayouter.js", - "diagram-js/lib/layout/LayoutUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\LayoutUtil.js", - "diagram-js/lib/layout/ManhattanLayout": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\ManhattanLayout.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnUpdater.js": [function(require, module, exports) { - 'use strict'; + var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); - var assign = require('lodash/object/assign'), - forEach = require('lodash/collection/forEach'), - inherits = require('inherits'); - var Collections = require('diagram-js/lib/util/Collections'), - Model = require('diagram-js/lib/model'); + /** + * A handler responsible for updating the underlying BPMN 2.0 XML + DI once + * changes on the diagram happen + */ + function BpmnUpdater(eventBus, bpmnFactory, connectionDocking) { - var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); + CommandInterceptor.call(this, eventBus); + this._bpmnFactory = bpmnFactory; - /** - * A handler responsible for updating the underlying BPMN 2.0 XML + DI once - * changes on the diagram happen - */ - function BpmnUpdater(eventBus, bpmnFactory, connectionDocking) { + var self = this; - CommandInterceptor.call(this, eventBus); - this._bpmnFactory = bpmnFactory; - var self = this; + // //// connection cropping ///////////////////////// + // crop connection ends during create/update + function cropConnection(e) { + var context = e.context, + connection; + if (!context.cropped) { + connection = context.connection; + connection.waypoints = connectionDocking.getCroppedWaypoints(connection); + context.cropped = true; + } + } - // //// connection cropping ///////////////////////// + this.executed([ + 'connection.layout', + 'connection.create', + 'connection.reconnectEnd', + 'connection.reconnectStart' + ], cropConnection); - // crop connection ends during create/update - function cropConnection(e) { - var context = e.context, - connection; + this.reverted(['connection.layout'], function(e) { + delete e.context.cropped; + }); - if (!context.cropped) { - connection = context.connection; - connection.waypoints = connectionDocking.getCroppedWaypoints(connection); - context.cropped = true; - } - } - this.executed([ - 'connection.layout', - 'connection.create', - 'connection.reconnectEnd', - 'connection.reconnectStart' - ], cropConnection); - this.reverted(['connection.layout'], function(e) { - delete e.context.cropped; - }); + // //// BPMN + DI update ///////////////////////// + // update parent + function updateParent(e) { + self.updateParent(e.context.shape || e.context.connection); + } - // //// BPMN + DI update ///////////////////////// + this.executed(['shape.move', + 'shape.create', + 'shape.delete', + 'connection.create', + 'connection.move', + 'connection.delete' + ], updateParent); + this.reverted(['shape.move', + 'shape.create', + 'shape.delete', + 'connection.create', + 'connection.move', + 'connection.delete' + ], updateParent); + + /* + * ## Updating Parent + * + * When morphing a Process into a Collaboration or vice-versa, make sure + * that both the *semantic* and *di* parent of each element is updated. + * + */ + function updateRoot(event) { + var context = event.context, + oldRoot = context.oldRoot, + children = oldRoot.children; + + forEach(children, function(child) { + self.updateParent(child); + }); + } + this.executed(['canvas.updateRoot'], updateRoot); + this.reverted(['canvas.updateRoot'], updateRoot); - // update parent - function updateParent(e) { - self.updateParent(e.context.shape || e.context.connection); - } - this.executed(['shape.move', - 'shape.create', - 'shape.delete', - 'connection.create', - 'connection.move', - 'connection.delete' - ], updateParent); - this.reverted(['shape.move', - 'shape.create', - 'shape.delete', - 'connection.create', - 'connection.move', - 'connection.delete' - ], updateParent); + // update bounds + function updateBounds(e) { + self.updateBounds(e.context.shape); + } - /* - * ## Updating Parent - * - * When morphing a Process into a Collaboration or vice-versa, make sure - * that both the *semantic* and *di* parent of each element is updated. - * - */ - function updateRoot(event) { - var context = event.context, - oldRoot = context.oldRoot, - children = oldRoot.children; + this.executed(['shape.move', 'shape.create', 'shape.resize'], updateBounds); + this.reverted(['shape.move', 'shape.create', 'shape.resize'], updateBounds); - forEach(children, function(child) { - self.updateParent(child); - }); - } - this.executed(['canvas.updateRoot'], updateRoot); - this.reverted(['canvas.updateRoot'], updateRoot); + // attach / detach connection + function updateConnection(e) { + self.updateConnection(e.context.connection); + } + this.executed([ + 'connection.create', + 'connection.move', + 'connection.delete', + 'connection.reconnectEnd', + 'connection.reconnectStart' + ], updateConnection); + + this.reverted([ + 'connection.create', + 'connection.move', + 'connection.delete', + 'connection.reconnectEnd', + 'connection.reconnectStart' + ], updateConnection); + + + // update waypoints + function updateConnectionWaypoints(e) { + self.updateConnectionWaypoints(e.context.connection); + } - // update bounds - function updateBounds(e) { - self.updateBounds(e.context.shape); - } + this.executed([ + 'connection.layout', + 'connection.move', + 'connection.updateWaypoints', + 'connection.reconnectEnd', + 'connection.reconnectStart' + ], updateConnectionWaypoints); + + this.reverted([ + 'connection.layout', + 'connection.move', + 'connection.updateWaypoints', + 'connection.reconnectEnd', + 'connection.reconnectStart' + ], updateConnectionWaypoints); + } - this.executed(['shape.move', 'shape.create', 'shape.resize'], updateBounds); - this.reverted(['shape.move', 'shape.create', 'shape.resize'], updateBounds); + inherits(BpmnUpdater, CommandInterceptor); + module.exports = BpmnUpdater; - // attach / detach connection - function updateConnection(e) { - self.updateConnection(e.context.connection); - } + BpmnUpdater.$inject = ['eventBus', 'bpmnFactory', 'connectionDocking']; - this.executed([ - 'connection.create', - 'connection.move', - 'connection.delete', - 'connection.reconnectEnd', - 'connection.reconnectStart' - ], updateConnection); - this.reverted([ - 'connection.create', - 'connection.move', - 'connection.delete', - 'connection.reconnectEnd', - 'connection.reconnectStart' - ], updateConnection); + // ///// implementation ////////////////////////////////// - // update waypoints - function updateConnectionWaypoints(e) { - self.updateConnectionWaypoints(e.context.connection); - } + BpmnUpdater.prototype.updateParent = function(element) { + + // do not update BPMN 2.0 label parent + if (element instanceof Model.Label) { + return; + } - this.executed([ - 'connection.layout', - 'connection.move', - 'connection.updateWaypoints', - 'connection.reconnectEnd', - 'connection.reconnectStart' - ], updateConnectionWaypoints); + var parentShape = element.parent; - this.reverted([ - 'connection.layout', - 'connection.move', - 'connection.updateWaypoints', - 'connection.reconnectEnd', - 'connection.reconnectStart' - ], updateConnectionWaypoints); - } + var businessObject = element.businessObject, + parentBusinessObject = parentShape && parentShape.businessObject, + parentDi = parentBusinessObject && parentBusinessObject.di; - inherits(BpmnUpdater, CommandInterceptor); + this.updateSemanticParent(businessObject, parentBusinessObject); - module.exports = BpmnUpdater; + this.updateDiParent(businessObject.di, parentDi); + }; - BpmnUpdater.$inject = ['eventBus', 'bpmnFactory', 'connectionDocking']; + BpmnUpdater.prototype.updateBounds = function(shape) { - // ///// implementation ////////////////////////////////// + var di = shape.businessObject.di; + var bounds = (shape instanceof Model.Label) ? this._getLabel(di).bounds : di.bounds; - BpmnUpdater.prototype.updateParent = function(element) { + assign(bounds, { + x: shape.x, + y: shape.y, + width: shape.width, + height: shape.height + }); + }; - // do not update BPMN 2.0 label parent - if (element instanceof Model.Label) { - return; - } - var parentShape = element.parent; + BpmnUpdater.prototype.updateDiParent = function(di, parentDi) { - var businessObject = element.businessObject, - parentBusinessObject = parentShape && parentShape.businessObject, - parentDi = parentBusinessObject && parentBusinessObject.di; + if (parentDi && !parentDi.$instanceOf('bpmndi:BPMNPlane')) { + parentDi = parentDi.$parent; + } - this.updateSemanticParent(businessObject, parentBusinessObject); + if (di.$parent === parentDi) { + return; + } - this.updateDiParent(businessObject.di, parentDi); - }; + var planeElements = (parentDi || di.$parent).get('planeElement'); + if (parentDi) { + planeElements.push(di); + di.$parent = parentDi; + } else { + Collections.remove(planeElements, di); + di.$parent = null; + } + }; - BpmnUpdater.prototype.updateBounds = function(shape) { + function getDefinitions(element) { + while (element && !element.$instanceOf('bpmn:Definitions')) { + element = element.$parent; + } - var di = shape.businessObject.di; + return element; + } - var bounds = (shape instanceof Model.Label) ? this._getLabel(di).bounds : di.bounds; + BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent) { - assign(bounds, { - x: shape.x, - y: shape.y, - width: shape.width, - height: shape.height - }); - }; + var containment; + if (businessObject.$parent === newParent) { + return; + } - BpmnUpdater.prototype.updateDiParent = function(di, parentDi) { + if (businessObject.$instanceOf('bpmn:FlowElement')) { - if (parentDi && !parentDi.$instanceOf('bpmndi:BPMNPlane')) { - parentDi = parentDi.$parent; - } + if (newParent && newParent.$instanceOf('bpmn:Participant')) { + newParent = newParent.processRef; + } - if (di.$parent === parentDi) { - return; - } + containment = 'flowElements'; - var planeElements = (parentDi || di.$parent).get('planeElement'); + } else - if (parentDi) { - planeElements.push(di); - di.$parent = parentDi; - } else { - Collections.remove(planeElements, di); - di.$parent = null; - } - }; + if (businessObject.$instanceOf('bpmn:Artifact')) { - function getDefinitions(element) { - while (element && !element.$instanceOf('bpmn:Definitions')) { - element = element.$parent; - } + while (newParent && + !newParent.$instanceOf('bpmn:Process') && + !newParent.$instanceOf('bpmn:SubProcess') && + !newParent.$instanceOf('bpmn:Collaboration')) { - return element; + if (newParent.$instanceOf('bpmn:Participant')) { + newParent = newParent.processRef; + break; + } else { + newParent = newParent.$parent; + } } - BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent) { + containment = 'artifacts'; + } else - var containment; + if (businessObject.$instanceOf('bpmn:MessageFlow')) { + containment = 'messageFlows'; - if (businessObject.$parent === newParent) { - return; - } + } else - if (businessObject.$instanceOf('bpmn:FlowElement')) { + if (businessObject.$instanceOf('bpmn:Participant')) { + containment = 'participants'; - if (newParent && newParent.$instanceOf('bpmn:Participant')) { - newParent = newParent.processRef; - } + // make sure the participants process is properly attached / detached + // from the XML document - containment = 'flowElements'; + var process = businessObject.processRef, + definitions; - } else + if (process) { + definitions = getDefinitions(businessObject.$parent || newParent); - if (businessObject.$instanceOf('bpmn:Artifact')) { + if (businessObject.$parent) { + Collections.remove(definitions.get('rootElements'), process); + process.$parent = null; + } - while (newParent && - !newParent.$instanceOf('bpmn:Process') && - !newParent.$instanceOf('bpmn:SubProcess') && - !newParent.$instanceOf('bpmn:Collaboration')) { + if (newParent) { + Collections.add(definitions.get('rootElements'), process); + process.$parent = definitions; + } + } + } - if (newParent.$instanceOf('bpmn:Participant')) { - newParent = newParent.processRef; - break; - } else { - newParent = newParent.$parent; - } - } + if (!containment) { + throw new Error('no parent for ', businessObject, newParent); + } - containment = 'artifacts'; - } else + var children; - if (businessObject.$instanceOf('bpmn:MessageFlow')) { - containment = 'messageFlows'; + if (businessObject.$parent) { + // remove from old parent + children = businessObject.$parent.get(containment); + Collections.remove(children, businessObject); + } - } else + if (!newParent) { + businessObject.$parent = null; + } else { + // add to new parent + children = newParent.get(containment); + children.push(businessObject); + businessObject.$parent = newParent; + } + }; - if (businessObject.$instanceOf('bpmn:Participant')) { - containment = 'participants'; - // make sure the participants process is properly attached / detached - // from the XML document + BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) { - var process = businessObject.processRef, - definitions; + connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints)); + }; - if (process) { - definitions = getDefinitions(businessObject.$parent || newParent); - if (businessObject.$parent) { - Collections.remove(definitions.get('rootElements'), process); - process.$parent = null; - } + BpmnUpdater.prototype.updateConnection = function(connection) { - if (newParent) { - Collections.add(definitions.get('rootElements'), process); - process.$parent = definitions; - } - } - } + var businessObject = connection.businessObject, + newSource = connection.source && connection.source.businessObject, + newTarget = connection.target && connection.target.businessObject; - if (!containment) { - throw new Error('no parent for ', businessObject, newParent); - } + var inverseSet = businessObject.$instanceOf('bpmn:SequenceFlow'); - var children; + if (businessObject.sourceRef !== newSource) { + if (inverseSet) { + Collections.remove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject); - if (businessObject.$parent) { - // remove from old parent - children = businessObject.$parent.get(containment); - Collections.remove(children, businessObject); - } + if (newSource) { + newSource.get('outgoing').push(businessObject); + } + } - if (!newParent) { - businessObject.$parent = null; - } else { - // add to new parent - children = newParent.get(containment); - children.push(businessObject); - businessObject.$parent = newParent; - } - }; + businessObject.sourceRef = newSource; + } + if (businessObject.targetRef !== newTarget) { + if (inverseSet) { + Collections.remove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject); + if (newTarget) { + newTarget.get('incoming').push(businessObject); + } + } - BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) { + businessObject.targetRef = newTarget; + } - connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints)); - }; + businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints)); + }; - BpmnUpdater.prototype.updateConnection = function(connection) { + // ///// helpers ///////////////////////////////////////// - var businessObject = connection.businessObject, - newSource = connection.source && connection.source.businessObject, - newTarget = connection.target && connection.target.businessObject; + BpmnUpdater.prototype._getLabel = function(di) { + if (!di.label) { + di.label = this._bpmnFactory.createDiLabel(); + } - var inverseSet = businessObject.$instanceOf('bpmn:SequenceFlow'); + return di.label; + }; + }, { + "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", + "diagram-js/lib/model": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\model\\index.js", + "diagram-js/lib/util/Collections": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Collections.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ElementFactory.js": [function(require, module, exports) { + 'use strict'; + + var assign = require('lodash/object/assign'), + inherits = require('inherits'); + + var BaseElementFactory = require('diagram-js/lib/core/ElementFactory'), + LabelUtil = require('../../util/LabelUtil'); + + + /** + * A bpmn-aware factory for diagram-js shapes + */ + function ElementFactory(bpmnFactory, moddle) { + BaseElementFactory.call(this); + + this._bpmnFactory = bpmnFactory; + this._moddle = moddle; + } - if (businessObject.sourceRef !== newSource) { - if (inverseSet) { - Collections.remove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject); + inherits(ElementFactory, BaseElementFactory); - if (newSource) { - newSource.get('outgoing').push(businessObject); - } - } - businessObject.sourceRef = newSource; - } - if (businessObject.targetRef !== newTarget) { - if (inverseSet) { - Collections.remove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject); - - if (newTarget) { - newTarget.get('incoming').push(businessObject); - } - } - - businessObject.targetRef = newTarget; - } - - businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints)); - }; + ElementFactory.$inject = ['bpmnFactory', 'moddle']; + module.exports = ElementFactory; - // ///// helpers ///////////////////////////////////////// + ElementFactory.prototype.baseCreate = BaseElementFactory.prototype.create; - BpmnUpdater.prototype._getLabel = function(di) { - if (!di.label) { - di.label = this._bpmnFactory.createDiLabel(); - } + ElementFactory.prototype.create = function(elementType, attrs) { - return di.label; - }; - }, { - "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", - "diagram-js/lib/model": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\model\\index.js", - "diagram-js/lib/util/Collections": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Collections.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ElementFactory.js": [function(require, module, exports) { - 'use strict'; + // no special magic for labels, + // we assume their businessObjects have already been created + // and wired via attrs + if (elementType === 'label') { + return this.baseCreate(elementType, assign({ + type: 'label' + }, LabelUtil.DEFAULT_LABEL_SIZE, attrs)); + } - var assign = require('lodash/object/assign'), - inherits = require('inherits'); + attrs = attrs || {}; - var BaseElementFactory = require('diagram-js/lib/core/ElementFactory'), - LabelUtil = require('../../util/LabelUtil'); + var businessObject = attrs.businessObject, + size; + if (!businessObject) { + if (!attrs.type) { + throw new Error('no shape type specified'); + } - /** - * A bpmn-aware factory for diagram-js shapes - */ - function ElementFactory(bpmnFactory, moddle) { - BaseElementFactory.call(this); + businessObject = this._bpmnFactory.create(attrs.type); + } - this._bpmnFactory = bpmnFactory; - this._moddle = moddle; + if (!businessObject.di) { + if (elementType === 'root') { + businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], { + id: businessObject.id + '_di' + }); + } else + if (elementType === 'connection') { + businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], { + id: businessObject.id + '_di' + }); + } else { + businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, { + id: businessObject.id + '_di' + }); } + } - inherits(ElementFactory, BaseElementFactory); + if (!!attrs.isExpanded) { + businessObject.di.isExpanded = attrs.isExpanded; + } + /* + * if (businessObject.$instanceOf('bpmn:ExclusiveGateway')) { + * businessObject.di.isMarkerVisible = true; } + */ - ElementFactory.$inject = ['bpmnFactory', 'moddle']; + if (attrs._eventDefinitionType) { + var eventDefinitions = businessObject.get('eventDefinitions') || [], + newEventDefinition = this._moddle.create(attrs._eventDefinitionType); - module.exports = ElementFactory; + eventDefinitions.push(newEventDefinition); + businessObject.eventDefinitions = eventDefinitions; + } - ElementFactory.prototype.baseCreate = BaseElementFactory.prototype.create; + size = this._getDefaultSize(businessObject); - ElementFactory.prototype.create = function(elementType, attrs) { + attrs = assign({ + businessObject: businessObject, + id: businessObject.id + }, size, attrs); - // no special magic for labels, - // we assume their businessObjects have already been created - // and wired via attrs - if (elementType === 'label') { - return this.baseCreate(elementType, assign({ - type: 'label' - }, LabelUtil.DEFAULT_LABEL_SIZE, attrs)); - } + return this.baseCreate(elementType, attrs); + }; - attrs = attrs || {}; - var businessObject = attrs.businessObject, - size; + ElementFactory.prototype._getDefaultSize = function(semantic) { - if (!businessObject) { - if (!attrs.type) { - throw new Error('no shape type specified'); - } + if (semantic.$instanceOf('bpmn:SubProcess')) { + var isExpanded = semantic.di.isExpanded === true; - businessObject = this._bpmnFactory.create(attrs.type); - } + if (isExpanded) { + return { + width: 350, + height: 200 + }; + } else { + return { + width: 100, + height: 80 + }; + } + } - if (!businessObject.di) { - if (elementType === 'root') { - businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], { - id: businessObject.id + '_di' - }); - } else - if (elementType === 'connection') { - businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], { - id: businessObject.id + '_di' - }); - } else { - businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, { - id: businessObject.id + '_di' - }); - } - } + if (semantic.$instanceOf('bpmn:InitiateProcess')) { + return { + width: 120, + height: 80 + }; + } + if (semantic.$instanceOf('bpmn:Collector')) { + return { + width: 120, + height: 80 + }; + } - if (!!attrs.isExpanded) { - businessObject.di.isExpanded = attrs.isExpanded; - } + if (semantic.$instanceOf('bpmn:StringMatch')) { + return { + width: 120, + height: 80 + }; + } + if (semantic.$instanceOf('bpmn:VesCollector')) { + return { + width: 120, + height: 80 + }; + } + if (semantic.$instanceOf('bpmn:Holmes')) { + return { + width: 120, + height: 80 + }; + } + if (semantic.$instanceOf('bpmn:TCA')) { + return { + width: 120, + height: 80 + }; + } - /* - * if (businessObject.$instanceOf('bpmn:ExclusiveGateway')) { - * businessObject.di.isMarkerVisible = true; } - */ + if (semantic.$instanceOf('bpmn:Policy')) { + return { + width: 120, + height: 80 + }; + } - if (attrs._eventDefinitionType) { - var eventDefinitions = businessObject.get('eventDefinitions') || [], - newEventDefinition = this._moddle.create(attrs._eventDefinitionType); + if (semantic.$instanceOf('bpmn:GOC')) { + return { + width: 120, + height: 80 + }; + } + if (semantic.$instanceOf('bpmn:ParentReturn')) { + return { + width: 100, + height: 80 + }; + } + if (semantic.$instanceOf('bpmn:SubProcessCall')) { + return { + width: 100, + height: 80 + }; + } - eventDefinitions.push(newEventDefinition); - businessObject.eventDefinitions = eventDefinitions; - } + if (semantic.$instanceOf('bpmn:ExclusiveGateway')) { + return { + width: 100, + height: 80 + }; + } - size = this._getDefaultSize(businessObject); + if (semantic.$instanceOf('bpmn:Task')) { + return { + width: 100, + height: 80 + }; + } - attrs = assign({ - businessObject: businessObject, - id: businessObject.id - }, size, attrs); + if (semantic.$instanceOf('bpmn:Gateway')) { + return { + width: 100, + height: 100 + }; + } - return this.baseCreate(elementType, attrs); + if (semantic.$instanceOf('bpmn:Event')) { + return { + width: 36, + height: 36 }; + } + if (semantic.$instanceOf('bpmn:Participant')) { + return { + width: 100, + height: 80 + }; + } - ElementFactory.prototype._getDefaultSize = function(semantic) { + return { + width: 100, + height: 80 + }; + }; - if (semantic.$instanceOf('bpmn:SubProcess')) { - var isExpanded = semantic.di.isExpanded === true; - if (isExpanded) { - return { - width: 350, - height: 200 - }; - } else { - return { - width: 100, - height: 80 - }; - } - } + ElementFactory.prototype.createParticipantShape = function(collapsed) { + // alert("entering createParticipantShape"); + var participantShape = this.createShape({ + type: 'bpmn:Participant' + }); - if (semantic.$instanceOf('bpmn:InitiateProcess')) { - return { - width: 120, - height: 80 - }; - } - if (semantic.$instanceOf('bpmn:Collector')) { - return { - width: 120, - height: 80 - }; - } - - if (semantic.$instanceOf('bpmn:StringMatch')) { - return { - width: 120, - height: 80 - }; + if (!collapsed) { + participantShape.businessObject.processRef = this._bpmnFactory.create('bpmn:Process'); } - if (semantic.$instanceOf('bpmn:VesCollector')) { - return { - width: 120, - height: 80 - }; - } - if (semantic.$instanceOf('bpmn:Holmes')) { - return { - width: 120, - height: 80 - }; - } - if (semantic.$instanceOf('bpmn:TCA')) { - return { - width: 120, - height: 80 - }; - } - - if (semantic.$instanceOf('bpmn:Policy')) { - return { - width: 120, - height: 80 - }; - } - - if (semantic.$instanceOf('bpmn:GOC')) { - return { - width: 120, - height: 80 - }; - } - if (semantic.$instanceOf('bpmn:ParentReturn')) { - return { - width: 100, - height: 80 - }; - } - if (semantic.$instanceOf('bpmn:SubProcessCall')) { - return { - width: 100, - height: 80 - }; - } - if (semantic.$instanceOf('bpmn:ExclusiveGateway')) { - return { - width: 100, - height: 80 - }; - } + return participantShape; + }; + }, { + "../../util/LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js", + "diagram-js/lib/core/ElementFactory": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\core\\ElementFactory.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\LabelSupport.js": [function(require, module, exports) { + 'use strict'; - if (semantic.$instanceOf('bpmn:Task')) { - return { - width: 100, - height: 80 - }; - } + var assign = require('lodash/object/assign'), + forEach = require('lodash/collection/forEach'); - if (semantic.$instanceOf('bpmn:Gateway')) { - return { - width: 100, - height: 100 - }; - } + var LabelUtil = require('../../util/LabelUtil'); - if (semantic.$instanceOf('bpmn:Event')) { - return { - width: 36, - height: 36 - }; - } + var hasExternalLabel = LabelUtil.hasExternalLabel, + getExternalLabelMid = LabelUtil.getExternalLabelMid; - if (semantic.$instanceOf('bpmn:Participant')) { - return { - width: 100, - height: 80 - }; - } - return { - width: 100, - height: 80 - }; - }; + function LabelSupport(eventBus, modeling, bpmnFactory) { + // create external labels on shape creation - ElementFactory.prototype.createParticipantShape = function(collapsed) { - // alert("entering createParticipantShape"); - var participantShape = this.createShape({ - type: 'bpmn:Participant' - }); + eventBus.on([ + 'commandStack.shape.create.postExecute', + 'commandStack.connection.create.postExecute' + ], function(e) { + var context = e.context; - if (!collapsed) { - participantShape.businessObject.processRef = this._bpmnFactory.create('bpmn:Process'); - } + var element = context.shape || context.connection, + businessObject = element.businessObject; - return participantShape; - }; - }, { - "../../util/LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js", - "diagram-js/lib/core/ElementFactory": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\core\\ElementFactory.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\LabelSupport.js": [function(require, module, exports) { - 'use strict'; + var position; - var assign = require('lodash/object/assign'), - forEach = require('lodash/collection/forEach'); + if (hasExternalLabel(businessObject)) { + position = getExternalLabelMid(element); + modeling.createLabel(element, position, { + id: businessObject.id + '_label', + businessObject: businessObject + }); + } + }); - var LabelUtil = require('../../util/LabelUtil'); - var hasExternalLabel = LabelUtil.hasExternalLabel, - getExternalLabelMid = LabelUtil.getExternalLabelMid; + //move label when connection/shape is being moved + //if shape is being moved, get connection as element + eventBus.on(['commandStack.connection.create.postExecute', + 'commandStack.connection.move.postExecute', + //'commandStack.connection.delete.postExecute', + 'commandStack.connection.reconnectEnd.postExecute', + 'commandStack.connection.reconnectStart.postExecute', + 'commandStack.connection.updateWaypoints.postExecute', + 'shape.move.end' + ], function(e) { - function LabelSupport(eventBus, modeling, bpmnFactory) { + var context = e.context; + var element; - // create external labels on shape creation + if (context.allDraggedElements != null) { + if (context.allDraggedElements.length > 0) { + element = context.allDraggedElements[1]; + } + } else { + element = context.connection; + } - eventBus.on([ - 'commandStack.shape.create.postExecute', - 'commandStack.connection.create.postExecute' - ], function(e) { - var context = e.context; + if (element == null) { + return; + } - var element = context.shape || context.connection, - businessObject = element.businessObject; + var businessObject = element.businessObject; - var position; + if (businessObject.$type != 'bpmn:SequenceFlow') { + return; + } - if (hasExternalLabel(businessObject)) { - position = getExternalLabelMid(element); - modeling.createLabel(element, position, { - id: businessObject.id + '_label', - businessObject: businessObject - }); - } - }); + var position; + if (hasExternalLabel(businessObject)) { + position = getExternalLabelMid(element); + modeling.removeShape(element.label); + modeling.createLabel(element, position, { + id: businessObject.id + '_label', + businessObject: businessObject + }); + } - //move label when connection/shape is being moved - //if shape is being moved, get connection as element - - eventBus.on(['commandStack.connection.create.postExecute', - 'commandStack.connection.move.postExecute', - //'commandStack.connection.delete.postExecute', - 'commandStack.connection.reconnectEnd.postExecute', - 'commandStack.connection.reconnectStart.postExecute', - 'commandStack.connection.updateWaypoints.postExecute', - 'shape.move.end' - ],function(e){ - - var context = e.context; - var element; - - if(context.allDraggedElements != null){ - if(context.allDraggedElements.length > 0){ - element = context.allDraggedElements[1]; - } - }else{ - element = context.connection; - } - - if(element==null){ - return; - } - - var businessObject = element.businessObject; - - if(businessObject.$type != 'bpmn:SequenceFlow'){ - return; - } - - var position; - - if (hasExternalLabel(businessObject)) { - position = getExternalLabelMid(element); - modeling.removeShape(element.label); - modeling.createLabel(element, position, { - id: businessObject.id + '_label', - businessObject: businessObject - }); - } - - }); - - - // indicate label is dragged during move + }); - // we need to add labels to the list of selected - // shapes before the visuals get drawn. - // - // Hence this awesome magic number. - // - eventBus.on('shape.move.start', function(e) { - var context = e.context, - shapes = context.shapes; + // indicate label is dragged during move - var labels = []; + // we need to add labels to the list of selected + // shapes before the visuals get drawn. + // + // Hence this awesome magic number. + // + eventBus.on('shape.move.start', function(e) { - forEach(shapes, function(element) { - var label = element.label; + var context = e.context, + shapes = context.shapes; - if (label && !label.hidden && context.shapes.indexOf(label) === -1) { - labels.push(label); - } - }); + var labels = []; - forEach(labels, function(label) { - shapes.push(label); - }); - }); + forEach(shapes, function(element) { + var label = element.label; + if (label && !label.hidden && context.shapes.indexOf(label) === -1) { + labels.push(label); + } + }); - // move labels with shapes + forEach(labels, function(label) { + shapes.push(label); + }); + }); - eventBus.on([ - 'commandStack.shapes.move.postExecute' - ], function(e) { - var context = e.context, - closure = context.closure, - enclosedElements = closure.enclosedElements; + // move labels with shapes - // ensure we move all labels with their respective elements - // if they have not been moved already + eventBus.on([ + 'commandStack.shapes.move.postExecute' + ], function(e) { - forEach(enclosedElements, function(e) { - if (e.label && !enclosedElements[e.label.id]) { - modeling.moveShape(e.label, context.delta, e.parent); - } - }); - }); + var context = e.context, + closure = context.closure, + enclosedElements = closure.enclosedElements; + // ensure we move all labels with their respective elements + // if they have not been moved already - // update di information on label movement and creation + forEach(enclosedElements, function(e) { + if (e.label && !enclosedElements[e.label.id]) { + modeling.moveShape(e.label, context.delta, e.parent); + } + }); + }); - eventBus.on([ - 'commandStack.label.create.executed', - 'commandStack.shape.moved.executed' - ], function(e) { - var element = e.context.shape, - businessObject = element.businessObject, - di = businessObject.di; + // update di information on label movement and creation - // we want to trigger on real labels only - if (!element.labelTarget) { - return; - } + eventBus.on([ + 'commandStack.label.create.executed', + 'commandStack.shape.moved.executed' + ], function(e) { - if (!di.label) { - di.label = bpmnFactory.create('bpmndi:BPMNLabel', { - bounds: bpmnFactory.create('dc:Bounds') - }); - } + var element = e.context.shape, + businessObject = element.businessObject, + di = businessObject.di; - assign(di.label.bounds, { - x: element.x, - y: element.y, - width: element.width, - height: element.height - }); - }); + // we want to trigger on real labels only + if (!element.labelTarget) { + return; } - LabelSupport.$inject = ['eventBus', 'modeling', 'bpmnFactory']; + if (!di.label) { + di.label = bpmnFactory.create('bpmndi:BPMNLabel', { + bounds: bpmnFactory.create('dc:Bounds') + }); + } - module.exports = LabelSupport; + assign(di.label.bounds, { + x: element.x, + y: element.y, + width: element.width, + height: element.height + }); + }); + } - }, { - "../../util/LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\Modeling.js": [function(require, module, exports) { - 'use strict'; + LabelSupport.$inject = ['eventBus', 'modeling', 'bpmnFactory']; - var inherits = require('inherits'); + module.exports = LabelSupport; - var BaseModeling = require('diagram-js/lib/features/modeling/Modeling'); + }, { + "../../util/LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\Modeling.js": [function(require, module, exports) { + 'use strict'; - var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler'), - UpdateCanvasRootHandler = require('./cmd/UpdateCanvasRootHandler'); + var inherits = require('inherits'); + var BaseModeling = require('diagram-js/lib/features/modeling/Modeling'); - /** - * BPMN 2.0 modeling features activator - * - * @param {EventBus} - * eventBus - * @param {ElementFactory} - * elementFactory - * @param {CommandStack} - * commandStack - * @param {BpmnRules} - * bpmnRules - */ - function Modeling(eventBus, elementFactory, commandStack, bpmnRules) { - BaseModeling.call(this, eventBus, elementFactory, commandStack); + var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler'), + UpdateCanvasRootHandler = require('./cmd/UpdateCanvasRootHandler'); - this._bpmnRules = bpmnRules; - } - inherits(Modeling, BaseModeling); + /** + * BPMN 2.0 modeling features activator + * + * @param {EventBus} + * eventBus + * @param {ElementFactory} + * elementFactory + * @param {CommandStack} + * commandStack + * @param {BpmnRules} + * bpmnRules + */ + function Modeling(eventBus, elementFactory, commandStack, bpmnRules) { + BaseModeling.call(this, eventBus, elementFactory, commandStack); - Modeling.$inject = ['eventBus', 'elementFactory', 'commandStack', 'bpmnRules']; + this._bpmnRules = bpmnRules; + } - module.exports = Modeling; + inherits(Modeling, BaseModeling); + Modeling.$inject = ['eventBus', 'elementFactory', 'commandStack', 'bpmnRules']; - Modeling.prototype.getHandlers = function() { - var handlers = BaseModeling.prototype.getHandlers.call(this); + module.exports = Modeling; - handlers['element.updateProperties'] = UpdatePropertiesHandler; - handlers['canvas.updateRoot'] = UpdateCanvasRootHandler; - return handlers; - }; + Modeling.prototype.getHandlers = function() { + var handlers = BaseModeling.prototype.getHandlers.call(this); + handlers['element.updateProperties'] = UpdatePropertiesHandler; + handlers['canvas.updateRoot'] = UpdateCanvasRootHandler; - Modeling.prototype.updateLabel = function(element, newLabel) { - this._commandStack.execute('element.updateLabel', { - element: element, - newLabel: newLabel - }); - }; + return handlers; + }; - var getSharedParent = require('./ModelingUtil').getSharedParent; + Modeling.prototype.updateLabel = function(element, newLabel) { + this._commandStack.execute('element.updateLabel', { + element: element, + newLabel: newLabel + }); + }; - Modeling.prototype.connect = function(source, target, attrs) { - var bpmnRules = this._bpmnRules; + var getSharedParent = require('./ModelingUtil').getSharedParent; - if (!attrs) { - if (bpmnRules.canConnectMessageFlow(source, target)) { - attrs = { - type: 'bpmn:MessageFlow' - }; - } else - if (bpmnRules.canConnectSequenceFlow(source, target)) { - attrs = { - type: 'bpmn:SequenceFlow' - }; - } else { - attrs = { - type: 'bpmn:Association' - }; - } - } + Modeling.prototype.connect = function(source, target, attrs) { - return this.createConnection(source, target, attrs, getSharedParent(source, target)); - }; + var bpmnRules = this._bpmnRules; + if (!attrs) { + if (bpmnRules.canConnectMessageFlow(source, target)) { + attrs = { + type: 'bpmn:MessageFlow' + }; + } else + if (bpmnRules.canConnectSequenceFlow(source, target)) { + attrs = { + type: 'bpmn:SequenceFlow' + }; + } else { + attrs = { + type: 'bpmn:Association' + }; + } + } - Modeling.prototype.updateProperties = function(element, properties) { - this._commandStack.execute('element.updateProperties', { - element: element, - properties: properties - }); - }; + return this.createConnection(source, target, attrs, getSharedParent(source, target)); + }; - /** - * Transform the current diagram into a collaboration. - * - * @return {djs.model.Root} the new root element - */ - Modeling.prototype.makeCollaboration = function() { + Modeling.prototype.updateProperties = function(element, properties) { + this._commandStack.execute('element.updateProperties', { + element: element, + properties: properties + }); + }; - var collaborationElement = this._create('root', { - type: 'bpmn:Collaboration' - }); - var context = { - newRoot: collaborationElement - }; + /** + * Transform the current diagram into a collaboration. + * + * @return {djs.model.Root} the new root element + */ + Modeling.prototype.makeCollaboration = function() { - this._commandStack.execute('canvas.updateRoot', context); + var collaborationElement = this._create('root', { + type: 'bpmn:Collaboration' + }); - return collaborationElement; - }; + var context = { + newRoot: collaborationElement + }; - /** - * Transform the current diagram into a process. - * - * @return {djs.model.Root} the new root element - */ - Modeling.prototype.makeProcess = function() { + this._commandStack.execute('canvas.updateRoot', context); - var processElement = this._create('root', { - type: 'bpmn:Process' - }); + return collaborationElement; + }; - var context = { - newRoot: processElement - }; + /** + * Transform the current diagram into a process. + * + * @return {djs.model.Root} the new root element + */ + Modeling.prototype.makeProcess = function() { - this._commandStack.execute('canvas.updateRoot', context); - }; - }, { - "./ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", - "./cmd/UpdateCanvasRootHandler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdateCanvasRootHandler.js", - "./cmd/UpdatePropertiesHandler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdatePropertiesHandler.js", - "diagram-js/lib/features/modeling/Modeling": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\modeling\\Modeling.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js": [function(require, module, exports) { - 'use strict'; + var processElement = this._create('root', { + type: 'bpmn:Process' + }); - var find = require('lodash/collection/find'); + var context = { + newRoot: processElement + }; + this._commandStack.execute('canvas.updateRoot', context); + }; + }, { + "./ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", + "./cmd/UpdateCanvasRootHandler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdateCanvasRootHandler.js", + "./cmd/UpdatePropertiesHandler": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdatePropertiesHandler.js", + "diagram-js/lib/features/modeling/Modeling": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\modeling\\Modeling.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js": [function(require, module, exports) { + 'use strict'; - function getParents(element) { + var find = require('lodash/collection/find'); - var parents = []; - while (element) { - element = element.parent; + function getParents(element) { - if (element) { - parents.push(element); - } - } + var parents = []; + + while (element) { + element = element.parent; - return parents; + if (element) { + parents.push(element); } + } + + return parents; + } - module.exports.getParents = getParents; + module.exports.getParents = getParents; - function getSharedParent(a, b) { + function getSharedParent(a, b) { - var parentsA = getParents(a), - parentsB = getParents(b); + var parentsA = getParents(a), + parentsB = getParents(b); - return find(parentsA, function(parent) { - return parentsB.indexOf(parent) !== -1; - }); - } + return find(parentsA, function(parent) { + return parentsB.indexOf(parent) !== -1; + }); + } - module.exports.getSharedParent = getSharedParent; - }, { - "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\AppendBehavior.js": [function(require, module, exports) { - 'use strict'; + module.exports.getSharedParent = getSharedParent; + }, { + "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\AppendBehavior.js": [function(require, module, exports) { + 'use strict'; - var inherits = require('inherits'); + var inherits = require('inherits'); - var is = require('../../../util/ModelUtil').is; + var is = require('../../../util/ModelUtil').is; - var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); + var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); - function AppendBehavior(eventBus, elementFactory, bpmnRules) { + function AppendBehavior(eventBus, elementFactory, bpmnRules) { - CommandInterceptor.call(this, eventBus); + CommandInterceptor.call(this, eventBus); - // assign correct shape position unless already set + // assign correct shape position unless already set - this.preExecute('shape.append', function(context) { + this.preExecute('shape.append', function(context) { - var source = context.source, - shape = context.shape; + var source = context.source, + shape = context.shape; - if (!context.position) { + if (!context.position) { - if (is(shape, 'bpmn:TextAnnotation')) { - context.position = { - x: source.x + source.width / 2 + 75, - y: source.y - (50) - shape.height / 2 - }; - } else { - context.position = { - x: source.x + source.width + 80 + shape.width / 2, - y: source.y + source.height / 2 - }; - } - } - }, true); + if (is(shape, 'bpmn:TextAnnotation')) { + context.position = { + x: source.x + source.width / 2 + 75, + y: source.y - (50) - shape.height / 2 + }; + } else { + context.position = { + x: source.x + source.width + 80 + shape.width / 2, + y: source.y + source.height / 2 + }; + } } + }, true); + } - AppendBehavior.$inject = ['eventBus', 'elementFactory', 'bpmnRules']; + AppendBehavior.$inject = ['eventBus', 'elementFactory', 'bpmnRules']; - inherits(AppendBehavior, CommandInterceptor); + inherits(AppendBehavior, CommandInterceptor); - module.exports = AppendBehavior; - }, { - "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\CreateBehavior.js": [function(require, module, exports) { - 'use strict'; + module.exports = AppendBehavior; + }, { + "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\CreateBehavior.js": [function(require, module, exports) { + 'use strict'; - var inherits = require('inherits'); + var inherits = require('inherits'); - var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); + var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); - var is = require('../../../util/ModelUtil').is; + var is = require('../../../util/ModelUtil').is; - /** - * BPMN specific create behavior - */ - function CreateBehavior(eventBus, modeling) { + /** + * BPMN specific create behavior + */ + function CreateBehavior(eventBus, modeling) { - CommandInterceptor.call(this, eventBus); + CommandInterceptor.call(this, eventBus); - /** - * morph process into collaboration before adding participant onto - * collaboration - */ + /** + * morph process into collaboration before adding participant onto + * collaboration + */ - this.preExecute('shape.create', function(context) { + this.preExecute('shape.create', function(context) { - var parent = context.parent, - shape = context.shape, - position = context.position; + var parent = context.parent, + shape = context.shape, + position = context.position; - if (is(parent, 'bpmn:Process') && is(shape, 'bpmn:Participant')) { + if (is(parent, 'bpmn:Process') && is(shape, 'bpmn:Participant')) { - // this is going to detach the process root - // and set the returned collaboration element - // as the new root element - var collaborationElement = modeling.makeCollaboration(); + // this is going to detach the process root + // and set the returned collaboration element + // as the new root element + var collaborationElement = modeling.makeCollaboration(); - // monkey patch the create context - // so that the participant is being dropped - // onto the new collaboration root instead - context.position = position; - context.parent = collaborationElement; + // monkey patch the create context + // so that the participant is being dropped + // onto the new collaboration root instead + context.position = position; + context.parent = collaborationElement; - context.processRoot = parent; - } - }, true); + context.processRoot = parent; + } + }, true); - this.execute('shape.create', function(context) { + this.execute('shape.create', function(context) { - var processRoot = context.processRoot, - shape = context.shape; + var processRoot = context.processRoot, + shape = context.shape; - if (processRoot) { - context.oldProcessRef = shape.businessObject.processRef; + if (processRoot) { + context.oldProcessRef = shape.businessObject.processRef; - // assign the participant processRef - shape.businessObject.processRef = processRoot.businessObject; - } - }, true); + // assign the participant processRef + shape.businessObject.processRef = processRoot.businessObject; + } + }, true); - this.revert('shape.create', function(context) { - var processRoot = context.processRoot, - shape = context.shape; + this.revert('shape.create', function(context) { + var processRoot = context.processRoot, + shape = context.shape; - if (processRoot) { - // assign the participant processRef - shape.businessObject.processRef = context.oldProcessRef; - } - }, true); - - this.postExecute('shape.create', function(context) { - - var processRoot = context.processRoot, - shape = context.shape; - - if (processRoot) { - // process root is already detached at this point - var processChildren = processRoot.children.slice(); - modeling.moveShapes(processChildren, { - x: 0, - y: 0 - }, shape); - } - //console.log(context.shape.id); - //newElementProcessor(context.shape.id); - //console.log(context) - }, true); - + if (processRoot) { + // assign the participant processRef + shape.businessObject.processRef = context.oldProcessRef; } + }, true); - CreateBehavior.$inject = ['eventBus', 'modeling']; + this.postExecute('shape.create', function(context) { - inherits(CreateBehavior, CommandInterceptor); + var processRoot = context.processRoot, + shape = context.shape; - module.exports = CreateBehavior; - }, { - "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\DropBehavior.js": [function(require, module, exports) { - 'use strict'; + if (processRoot) { + // process root is already detached at this point + var processChildren = processRoot.children.slice(); + modeling.moveShapes(processChildren, { + x: 0, + y: 0 + }, shape); + } + //console.log(context.shape.id); + //newElementProcessor(context.shape.id); + //console.log(context) + }, true); - var forEach = require('lodash/collection/forEach'), - inherits = require('inherits'); + } - var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); + CreateBehavior.$inject = ['eventBus', 'modeling']; - var is = require('../../../util/ModelUtil').is, - getSharedParent = require('../ModelingUtil').getSharedParent; + inherits(CreateBehavior, CommandInterceptor); + module.exports = CreateBehavior; + }, { + "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\DropBehavior.js": [function(require, module, exports) { + 'use strict'; - function DropBehavior(eventBus, modeling, bpmnRules) { + var forEach = require('lodash/collection/forEach'), + inherits = require('inherits'); - CommandInterceptor.call(this, eventBus); + var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); - // remove sequence flows that should not be allowed - // after a move operation + var is = require('../../../util/ModelUtil').is, + getSharedParent = require('../ModelingUtil').getSharedParent; - this.postExecute('shapes.move', function(context) { - var closure = context.closure, - allConnections = closure.allConnections; + function DropBehavior(eventBus, modeling, bpmnRules) { - forEach(allConnections, function(c) { + CommandInterceptor.call(this, eventBus); - var source = c.source, - target = c.target; + // remove sequence flows that should not be allowed + // after a move operation - var replacementType, - remove; + this.postExecute('shapes.move', function(context) { - /** - * Check if incoming or outgoing connections can stay or could be - * substituted with an appropriate replacement. - * - * This holds true for SequenceFlow <> MessageFlow. - */ + var closure = context.closure, + allConnections = closure.allConnections; - if (is(c, 'bpmn:SequenceFlow')) { - if (!bpmnRules.canConnectSequenceFlow(source, target)) { - remove = true; - } + forEach(allConnections, function(c) { - if (bpmnRules.canConnectMessageFlow(source, target)) { - replacementType = 'bpmn:MessageFlow'; - } - } + var source = c.source, + target = c.target; - // transform message flows into sequence flows, if possible + var replacementType, + remove; - if (is(c, 'bpmn:MessageFlow')) { + /** + * Check if incoming or outgoing connections can stay or could be + * substituted with an appropriate replacement. + * + * This holds true for SequenceFlow <> MessageFlow. + */ - if (!bpmnRules.canConnectMessageFlow(source, target)) { - remove = true; - } + if (is(c, 'bpmn:SequenceFlow')) { + if (!bpmnRules.canConnectSequenceFlow(source, target)) { + remove = true; + } - if (bpmnRules.canConnectSequenceFlow(source, target)) { - replacementType = 'bpmn:SequenceFlow'; - } - } + if (bpmnRules.canConnectMessageFlow(source, target)) { + replacementType = 'bpmn:MessageFlow'; + } + } - if (is(c, 'bpmn:Association') && !bpmnRules.canConnectAssociation(source, target)) { - remove = true; - } + // transform message flows into sequence flows, if possible + if (is(c, 'bpmn:MessageFlow')) { - // remove invalid connection - if (remove) { - modeling.removeConnection(c); - } + if (!bpmnRules.canConnectMessageFlow(source, target)) { + remove = true; + } - // replace SequenceFlow <> MessageFlow + if (bpmnRules.canConnectSequenceFlow(source, target)) { + replacementType = 'bpmn:SequenceFlow'; + } + } - if (replacementType) { - modeling.createConnection(source, target, { - type: replacementType, - waypoints: c.waypoints.slice() - }, getSharedParent(source, target)); - } - }); - }, true); - } + if (is(c, 'bpmn:Association') && !bpmnRules.canConnectAssociation(source, target)) { + remove = true; + } - inherits(DropBehavior, CommandInterceptor); - DropBehavior.$inject = ['eventBus', 'modeling', 'bpmnRules']; + // remove invalid connection + if (remove) { + modeling.removeConnection(c); + } - module.exports = DropBehavior; - }, { - "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "../ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", - "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\ModelingFeedback.js": [function(require, module, exports) { - 'use strict'; + // replace SequenceFlow <> MessageFlow - var is = require('../../../util/ModelUtil').is; + if (replacementType) { + modeling.createConnection(source, target, { + type: replacementType, + waypoints: c.waypoints.slice() + }, getSharedParent(source, target)); + } + }); + }, true); + } + inherits(DropBehavior, CommandInterceptor); - function ModelingFeedback(eventBus, tooltips) { + DropBehavior.$inject = ['eventBus', 'modeling', 'bpmnRules']; - function showError(position, message) { - tooltips.add({ - position: { - x: position.x + 5, - y: position.y + 5 - }, - type: 'error', - timeout: 2000, - html: '
' + message + '
' - }); - } + module.exports = DropBehavior; + }, { + "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "../ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", + "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\ModelingFeedback.js": [function(require, module, exports) { + 'use strict'; - eventBus.on(['shape.move.rejected', 'create.rejected'], function(event) { + var is = require('../../../util/ModelUtil').is; - var context = event.context, - shape = context.shape, - target = context.target; - if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) { - showError(event, 'flow elements must be children of pools/participants'); - } - }); + function ModelingFeedback(eventBus, tooltips) { - } + function showError(position, message) { + tooltips.add({ + position: { + x: position.x + 5, + y: position.y + 5 + }, + type: 'error', + timeout: 2000, + html: '
' + message + '
' + }); + } + eventBus.on(['shape.move.rejected', 'create.rejected'], function(event) { - ModelingFeedback.$inject = ['eventBus', 'tooltips']; + var context = event.context, + shape = context.shape, + target = context.target; - module.exports = ModelingFeedback; - }, { - "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\RemoveBehavior.js": [function(require, module, exports) { - 'use strict'; + if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) { + showError(event, 'flow elements must be children of pools/participants'); + } + }); - var inherits = require('inherits'); + } - var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); - var is = require('../../../util/ModelUtil').is; + ModelingFeedback.$inject = ['eventBus', 'tooltips']; + module.exports = ModelingFeedback; + }, { + "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\RemoveBehavior.js": [function(require, module, exports) { + 'use strict'; - /** - * BPMN specific remove behavior - */ - function RemoveBehavior(eventBus, modeling) { + var inherits = require('inherits'); - CommandInterceptor.call(this, eventBus); + var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor'); + var is = require('../../../util/ModelUtil').is; - /** - * morph collaboration diagram into process diagram after the last - * participant has been removed - */ - this.preExecute('shape.delete', function(context) { - //delete elementMap[context.shape.id]; - //console.log(context.shape.id); - var shape = context.shape, - parent = shape.parent; + /** + * BPMN specific remove behavior + */ + function RemoveBehavior(eventBus, modeling) { - // activate the behavior if the shape to be removed - // is a participant - if (is(shape, 'bpmn:Participant')) { - context.collaborationRoot = parent; - } - }, true); + CommandInterceptor.call(this, eventBus); - this.postExecute('shape.delete', function(context) { - var collaborationRoot = context.collaborationRoot; + /** + * morph collaboration diagram into process diagram after the last + * participant has been removed + */ - if (collaborationRoot && !collaborationRoot.businessObject.participants.length) { - // replace empty collaboration with process diagram - modeling.makeProcess(); - } - }, true); + this.preExecute('shape.delete', function(context) { + //delete elementMap[context.shape.id]; + //console.log(context.shape.id); + var shape = context.shape, + parent = shape.parent; + // activate the behavior if the shape to be removed + // is a participant + if (is(shape, 'bpmn:Participant')) { + context.collaborationRoot = parent; } + }, true); - RemoveBehavior.$inject = ['eventBus', 'modeling']; - - inherits(RemoveBehavior, CommandInterceptor); - - module.exports = RemoveBehavior; - }, { - "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\index.js": [function(require, module, exports) { - module.exports = { - __init__: [ - 'appendBehavior', - 'createBehavior', - 'dropBehavior', - 'removeBehavior', - 'modelingFeedback' - ], - appendBehavior: ['type', require('./AppendBehavior')], - dropBehavior: ['type', require('./DropBehavior')], - createBehavior: ['type', require('./CreateBehavior')], - removeBehavior: ['type', require('./RemoveBehavior')], - modelingFeedback: ['type', require('./ModelingFeedback')] - }; - }, { - "./AppendBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\AppendBehavior.js", - "./CreateBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\CreateBehavior.js", - "./DropBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\DropBehavior.js", - "./ModelingFeedback": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\ModelingFeedback.js", - "./RemoveBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\RemoveBehavior.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdateCanvasRootHandler.js": [function(require, module, exports) { - 'use strict'; - - var Collections = require('diagram-js/lib/util/Collections'); + this.postExecute('shape.delete', function(context) { + var collaborationRoot = context.collaborationRoot; - function UpdateCanvasRootHandler(canvas, modeling) { - this._canvas = canvas; - this._modeling = modeling; + if (collaborationRoot && !collaborationRoot.businessObject.participants.length) { + // replace empty collaboration with process diagram + modeling.makeProcess(); } + }, true); - UpdateCanvasRootHandler.$inject = ['canvas', 'modeling']; + } - module.exports = UpdateCanvasRootHandler; + RemoveBehavior.$inject = ['eventBus', 'modeling']; + + inherits(RemoveBehavior, CommandInterceptor); + + module.exports = RemoveBehavior; + }, { + "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "diagram-js/lib/command/CommandInterceptor": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\CommandInterceptor.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\index.js": [function(require, module, exports) { + module.exports = { + __init__: [ + 'appendBehavior', + 'createBehavior', + 'dropBehavior', + 'removeBehavior', + 'modelingFeedback' + ], + appendBehavior: ['type', require('./AppendBehavior')], + dropBehavior: ['type', require('./DropBehavior')], + createBehavior: ['type', require('./CreateBehavior')], + removeBehavior: ['type', require('./RemoveBehavior')], + modelingFeedback: ['type', require('./ModelingFeedback')] + }; + }, { + "./AppendBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\AppendBehavior.js", + "./CreateBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\CreateBehavior.js", + "./DropBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\DropBehavior.js", + "./ModelingFeedback": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\ModelingFeedback.js", + "./RemoveBehavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\RemoveBehavior.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdateCanvasRootHandler.js": [function(require, module, exports) { + 'use strict'; + + var Collections = require('diagram-js/lib/util/Collections'); + + + function UpdateCanvasRootHandler(canvas, modeling) { + this._canvas = canvas; + this._modeling = modeling; + } + UpdateCanvasRootHandler.$inject = ['canvas', 'modeling']; - UpdateCanvasRootHandler.prototype.execute = function(context) { + module.exports = UpdateCanvasRootHandler; - var canvas = this._canvas; - var newRoot = context.newRoot, - newRootBusinessObject = newRoot.businessObject, - oldRoot = canvas.getRootElement(), - oldRootBusinessObject = oldRoot.businessObject, - bpmnDefinitions = oldRootBusinessObject.$parent, - diPlane = oldRootBusinessObject.di; + UpdateCanvasRootHandler.prototype.execute = function(context) { - // (1) replace process old <> new root - canvas.setRootElement(newRoot, true); + var canvas = this._canvas; - // (2) update root elements - Collections.add(bpmnDefinitions.rootElements, newRootBusinessObject); - newRootBusinessObject.$parent = bpmnDefinitions; + var newRoot = context.newRoot, + newRootBusinessObject = newRoot.businessObject, + oldRoot = canvas.getRootElement(), + oldRootBusinessObject = oldRoot.businessObject, + bpmnDefinitions = oldRootBusinessObject.$parent, + diPlane = oldRootBusinessObject.di; - Collections.remove(bpmnDefinitions.rootElements, oldRootBusinessObject); - oldRootBusinessObject.$parent = null; + // (1) replace process old <> new root + canvas.setRootElement(newRoot, true); - // (3) wire di - oldRootBusinessObject.di = null; + // (2) update root elements + Collections.add(bpmnDefinitions.rootElements, newRootBusinessObject); + newRootBusinessObject.$parent = bpmnDefinitions; - diPlane.bpmnElement = newRootBusinessObject; - newRootBusinessObject.di = diPlane; + Collections.remove(bpmnDefinitions.rootElements, oldRootBusinessObject); + oldRootBusinessObject.$parent = null; - context.oldRoot = oldRoot; - }; + // (3) wire di + oldRootBusinessObject.di = null; + diPlane.bpmnElement = newRootBusinessObject; + newRootBusinessObject.di = diPlane; - UpdateCanvasRootHandler.prototype.revert = function(context) { + context.oldRoot = oldRoot; + }; - var canvas = this._canvas; - var newRoot = context.newRoot, - newRootBusinessObject = newRoot.businessObject, - oldRoot = context.oldRoot, - oldRootBusinessObject = oldRoot.businessObject, - bpmnDefinitions = newRootBusinessObject.$parent, - diPlane = newRootBusinessObject.di; + UpdateCanvasRootHandler.prototype.revert = function(context) { - // (1) replace process old <> new root - canvas.setRootElement(oldRoot, true); + var canvas = this._canvas; - // (2) update root elements - Collections.remove(bpmnDefinitions.rootElements, newRootBusinessObject); - newRootBusinessObject.$parent = null; + var newRoot = context.newRoot, + newRootBusinessObject = newRoot.businessObject, + oldRoot = context.oldRoot, + oldRootBusinessObject = oldRoot.businessObject, + bpmnDefinitions = newRootBusinessObject.$parent, + diPlane = newRootBusinessObject.di; - Collections.add(bpmnDefinitions.rootElements, oldRootBusinessObject); - oldRootBusinessObject.$parent = bpmnDefinitions; + // (1) replace process old <> new root + canvas.setRootElement(oldRoot, true); - // (3) wire di - newRootBusinessObject.di = null; + // (2) update root elements + Collections.remove(bpmnDefinitions.rootElements, newRootBusinessObject); + newRootBusinessObject.$parent = null; - diPlane.bpmnElement = oldRootBusinessObject; - oldRootBusinessObject.di = diPlane; - }; - }, { - "diagram-js/lib/util/Collections": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Collections.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdatePropertiesHandler.js": [function(require, module, exports) { - 'use strict'; + Collections.add(bpmnDefinitions.rootElements, oldRootBusinessObject); + oldRootBusinessObject.$parent = bpmnDefinitions; - var assign = require('lodash/object/assign'), - pick = require('lodash/object/pick'), - keys = require('lodash/object/keys'); + // (3) wire di + newRootBusinessObject.di = null; - var DEFAULT_FLOW = 'default', - NAME = 'name', - ID = 'id'; + diPlane.bpmnElement = oldRootBusinessObject; + oldRootBusinessObject.di = diPlane; + }; + }, { + "diagram-js/lib/util/Collections": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Collections.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\cmd\\UpdatePropertiesHandler.js": [function(require, module, exports) { + 'use strict'; + var assign = require('lodash/object/assign'), + pick = require('lodash/object/pick'), + keys = require('lodash/object/keys'); - /** - * A handler that implements a BPMN 2.0 property update. - * - * This should be used to set simple properties on elements with an underlying - * BPMN business object. - * - * Use respective diagram-js provided handlers if you would like to perform - * automated modeling. - */ - function UpdatePropertiesHandler(elementRegistry) { - this._elementRegistry = elementRegistry; - } + var DEFAULT_FLOW = 'default', + NAME = 'name', + ID = 'id'; - UpdatePropertiesHandler.$inject = ['elementRegistry']; - module.exports = UpdatePropertiesHandler; + /** + * A handler that implements a BPMN 2.0 property update. + * + * This should be used to set simple properties on elements with an underlying + * BPMN business object. + * + * Use respective diagram-js provided handlers if you would like to perform + * automated modeling. + */ + function UpdatePropertiesHandler(elementRegistry) { + this._elementRegistry = elementRegistry; + } + UpdatePropertiesHandler.$inject = ['elementRegistry']; - // //// api ///////////////////////////////////////////// + module.exports = UpdatePropertiesHandler; - /** - * Updates a BPMN element with a list of new properties - * - * @param {Object} - * context - * @param {djs.model.Base} - * context.element the element to update - * @param {Object} - * context.properties a list of properties to set on the element's - * businessObject (the BPMN model element) - * - * @return {Array} the updated element - */ - UpdatePropertiesHandler.prototype.execute = function(context) { - var element = context.element, - changed = [element]; + // //// api ///////////////////////////////////////////// - if (!element) { - throw new Error('element required'); - } + /** + * Updates a BPMN element with a list of new properties + * + * @param {Object} + * context + * @param {djs.model.Base} + * context.element the element to update + * @param {Object} + * context.properties a list of properties to set on the element's + * businessObject (the BPMN model element) + * + * @return {Array} the updated element + */ + UpdatePropertiesHandler.prototype.execute = function(context) { - var elementRegistry = this._elementRegistry; + var element = context.element, + changed = [element]; - var businessObject = element.businessObject, - properties = context.properties, - oldProperties = context.oldProperties || pick(businessObject, keys(properties)); + if (!element) { + throw new Error('element required'); + } - if (ID in properties) { - elementRegistry.updateId(element, properties[ID]); - } + var elementRegistry = this._elementRegistry; - // correctly indicate visual changes on default flow updates - if (DEFAULT_FLOW in properties) { + var businessObject = element.businessObject, + properties = context.properties, + oldProperties = context.oldProperties || pick(businessObject, keys(properties)); - if (properties[DEFAULT_FLOW]) { - changed.push(elementRegistry.get(properties[DEFAULT_FLOW].id)); - } + if (ID in properties) { + elementRegistry.updateId(element, properties[ID]); + } - if (businessObject[DEFAULT_FLOW]) { - changed.push(elementRegistry.get(businessObject[DEFAULT_FLOW].id)); - } - } + // correctly indicate visual changes on default flow updates + if (DEFAULT_FLOW in properties) { - if (NAME in properties && element.label) { - changed.push(element.label); - } + if (properties[DEFAULT_FLOW]) { + changed.push(elementRegistry.get(properties[DEFAULT_FLOW].id)); + } - // update properties - assign(businessObject, properties); + if (businessObject[DEFAULT_FLOW]) { + changed.push(elementRegistry.get(businessObject[DEFAULT_FLOW].id)); + } + } + if (NAME in properties && element.label) { + changed.push(element.label); + } - // store old values - context.oldProperties = oldProperties; - context.changed = changed; + // update properties + assign(businessObject, properties); - // indicate changed on objects affected by the update - return changed; - }; - /** - * Reverts the update on a BPMN elements properties. - * - * @param {Object} - * context - * - * @return {djs.mode.Base} the updated element - */ - UpdatePropertiesHandler.prototype.revert = function(context) { + // store old values + context.oldProperties = oldProperties; + context.changed = changed; - var element = context.element, - oldProperties = context.oldProperties, - businessObject = element.businessObject, - elementRegistry = this._elementRegistry; + // indicate changed on objects affected by the update + return changed; + }; - assign(businessObject, context.oldProperties); + /** + * Reverts the update on a BPMN elements properties. + * + * @param {Object} + * context + * + * @return {djs.mode.Base} the updated element + */ + UpdatePropertiesHandler.prototype.revert = function(context) { - if (ID in oldProperties) { - elementRegistry.updateId(element, oldProperties[ID]); - } + var element = context.element, + oldProperties = context.oldProperties, + businessObject = element.businessObject, + elementRegistry = this._elementRegistry; - return context.changed; - }; - }, { - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", - "lodash/object/keys": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\keys.js", - "lodash/object/pick": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\pick.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\index.js": [function(require, module, exports) { - module.exports = { - __init__: ['modeling', 'bpmnUpdater', 'labelSupport'], - __depends__: [ - require('../label-editing'), - require('./rules'), - require('./behavior'), - require('diagram-js/lib/command'), - require('diagram-js/lib/features/tooltips'), - require('diagram-js/lib/features/change-support') - ], - bpmnFactory: ['type', require('./BpmnFactory')], - bpmnUpdater: ['type', require('./BpmnUpdater')], - elementFactory: ['type', require('./ElementFactory')], - modeling: ['type', require('./Modeling')], - labelSupport: ['type', require('./LabelSupport')], - layouter: ['type', require('./BpmnLayouter')], - connectionDocking: ['type', require('diagram-js/lib/layout/CroppingConnectionDocking')] - }; + assign(businessObject, context.oldProperties); - }, { - "../label-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\index.js", - "./BpmnFactory": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnFactory.js", - "./BpmnLayouter": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnLayouter.js", - "./BpmnUpdater": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnUpdater.js", - "./ElementFactory": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ElementFactory.js", - "./LabelSupport": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\LabelSupport.js", - "./Modeling": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\Modeling.js", - "./behavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\index.js", - "./rules": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\index.js", - "diagram-js/lib/command": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\index.js", - "diagram-js/lib/features/change-support": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\change-support\\index.js", - "diagram-js/lib/features/tooltips": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\tooltips\\index.js", - "diagram-js/lib/layout/CroppingConnectionDocking": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\CroppingConnectionDocking.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\BpmnRules.js": [function(require, module, exports) { - 'use strict'; + if (ID in oldProperties) { + elementRegistry.updateId(element, oldProperties[ID]); + } - var groupBy = require('lodash/collection/groupBy'), - size = require('lodash/collection/size'), - find = require('lodash/collection/find'), - inherits = require('inherits'); + return context.changed; + }; + }, { + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", + "lodash/object/keys": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\keys.js", + "lodash/object/pick": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\pick.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\index.js": [function(require, module, exports) { + module.exports = { + __init__: ['modeling', 'bpmnUpdater', 'labelSupport'], + __depends__: [ + require('../label-editing'), + require('./rules'), + require('./behavior'), + require('diagram-js/lib/command'), + require('diagram-js/lib/features/tooltips'), + require('diagram-js/lib/features/change-support') + ], + bpmnFactory: ['type', require('./BpmnFactory')], + bpmnUpdater: ['type', require('./BpmnUpdater')], + elementFactory: ['type', require('./ElementFactory')], + modeling: ['type', require('./Modeling')], + labelSupport: ['type', require('./LabelSupport')], + layouter: ['type', require('./BpmnLayouter')], + connectionDocking: ['type', require('diagram-js/lib/layout/CroppingConnectionDocking')] + }; + + }, { + "../label-editing": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\label-editing\\index.js", + "./BpmnFactory": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnFactory.js", + "./BpmnLayouter": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnLayouter.js", + "./BpmnUpdater": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\BpmnUpdater.js", + "./ElementFactory": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ElementFactory.js", + "./LabelSupport": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\LabelSupport.js", + "./Modeling": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\Modeling.js", + "./behavior": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\behavior\\index.js", + "./rules": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\index.js", + "diagram-js/lib/command": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\command\\index.js", + "diagram-js/lib/features/change-support": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\change-support\\index.js", + "diagram-js/lib/features/tooltips": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\tooltips\\index.js", + "diagram-js/lib/layout/CroppingConnectionDocking": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\layout\\CroppingConnectionDocking.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\BpmnRules.js": [function(require, module, exports) { + 'use strict'; + + var groupBy = require('lodash/collection/groupBy'), + size = require('lodash/collection/size'), + find = require('lodash/collection/find'), + inherits = require('inherits'); + + var getParents = require('../ModelingUtil').getParents, + is = require('../../../util/ModelUtil').is, + getBusinessObject = require('../../../util/ModelUtil').getBusinessObject, + isExpanded = require('../../../util/DiUtil').isExpanded; + + + var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider'); + + /** + * BPMN specific modeling rule + */ + function BpmnRules(eventBus) { + RuleProvider.call(this, eventBus); + } - var getParents = require('../ModelingUtil').getParents, - is = require('../../../util/ModelUtil').is, - getBusinessObject = require('../../../util/ModelUtil').getBusinessObject, - isExpanded = require('../../../util/DiUtil').isExpanded; + inherits(BpmnRules, RuleProvider); + BpmnRules.$inject = ['eventBus']; - var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider'); + module.exports = BpmnRules; - /** - * BPMN specific modeling rule - */ - function BpmnRules(eventBus) { - RuleProvider.call(this, eventBus); - } + BpmnRules.prototype.init = function() { - inherits(BpmnRules, RuleProvider); + this.addRule('connection.create', function(context) { + var source = context.source, + target = context.target; - BpmnRules.$inject = ['eventBus']; + return canConnect(source, target); + }); - module.exports = BpmnRules; + this.addRule('connection.reconnectStart', function(context) { - BpmnRules.prototype.init = function() { + var connection = context.connection, + source = context.hover || context.source, + target = connection.target; - this.addRule('connection.create', function(context) { - var source = context.source, - target = context.target; + return canConnect(source, target, connection); + }); - return canConnect(source, target); - }); + this.addRule('connection.reconnectEnd', function(context) { - this.addRule('connection.reconnectStart', function(context) { + var connection = context.connection, + source = connection.source, + target = context.hover || context.target; - var connection = context.connection, - source = context.hover || context.source, - target = connection.target; + return canConnect(source, target, connection); + }); - return canConnect(source, target, connection); - }); + this.addRule('connection.updateWaypoints', function(context) { + // OK! but visually ignore + return null; + }); - this.addRule('connection.reconnectEnd', function(context) { + this.addRule('shape.resize', function(context) { - var connection = context.connection, - source = connection.source, - target = context.hover || context.target; + var shape = context.shape, + newBounds = context.newBounds; - return canConnect(source, target, connection); - }); + return canResize(shape, newBounds); + }); - this.addRule('connection.updateWaypoints', function(context) { - // OK! but visually ignore - return null; - }); + this.addRule('shapes.move', function(context) { - this.addRule('shape.resize', function(context) { + var target = context.newParent, + shapes = context.shapes; - var shape = context.shape, - newBounds = context.newBounds; + return canMove(shapes, target); + }); - return canResize(shape, newBounds); - }); + this.addRule(['shape.create', 'shape.append'], function(context) { + var target = context.parent, + shape = context.shape, + source = context.source; - this.addRule('shapes.move', function(context) { + return canCreate(shape, target, source); + }); - var target = context.newParent, - shapes = context.shapes; + }; - return canMove(shapes, target); - }); + BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow; - this.addRule(['shape.create', 'shape.append'], function(context) { - var target = context.parent, - shape = context.shape, - source = context.source; + BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow; - return canCreate(shape, target, source); - }); + BpmnRules.prototype.canConnectAssociation = canConnectAssociation; - }; + BpmnRules.prototype.canMove = canMove; - BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow; + BpmnRules.prototype.canDrop = canDrop; - BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow; + BpmnRules.prototype.canCreate = canCreate; - BpmnRules.prototype.canConnectAssociation = canConnectAssociation; + BpmnRules.prototype.canConnect = canConnect; - BpmnRules.prototype.canMove = canMove; + BpmnRules.prototype.canResize = canResize; - BpmnRules.prototype.canDrop = canDrop; + /** + * Utility functions for rule checking + */ - BpmnRules.prototype.canCreate = canCreate; + function nonExistantOrLabel(element) { + return !element || isLabel(element); + } - BpmnRules.prototype.canConnect = canConnect; + function isSame(a, b) { + return a === b; + } - BpmnRules.prototype.canResize = canResize; + function getOrganizationalParent(element) { - /** - * Utility functions for rule checking - */ + var bo = getBusinessObject(element); - function nonExistantOrLabel(element) { - return !element || isLabel(element); + while (bo && !is(bo, 'bpmn:Process')) { + if (is(bo, 'bpmn:Participant')) { + return bo.processRef || bo; } - function isSame(a, b) { - return a === b; - } + bo = bo.$parent; + } - function getOrganizationalParent(element) { + return bo; + } - var bo = getBusinessObject(element); + function isSameOrganization(a, b) { + var parentA = getOrganizationalParent(a), + parentB = getOrganizationalParent(b); - while (bo && !is(bo, 'bpmn:Process')) { - if (is(bo, 'bpmn:Participant')) { - return bo.processRef || bo; - } + return parentA === parentB; + } - bo = bo.$parent; - } + function isMessageFlowSource(element) { + return is(element, 'bpmn:InteractionNode') && (!is(element, 'bpmn:Event') || ( + is(element, 'bpmn:ThrowEvent') && + hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition') + )); + } - return bo; - } + function isMessageFlowTarget(element) { + return is(element, 'bpmn:InteractionNode') && (!is(element, 'bpmn:Event') || ( + is(element, 'bpmn:CatchEvent') && + hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition') + )); + } - function isSameOrganization(a, b) { - var parentA = getOrganizationalParent(a), - parentB = getOrganizationalParent(b); + function getScopeParent(element) { - return parentA === parentB; - } + var bo = getBusinessObject(element); - function isMessageFlowSource(element) { - return is(element, 'bpmn:InteractionNode') && (!is(element, 'bpmn:Event') || ( - is(element, 'bpmn:ThrowEvent') && - hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition') - )); - } + if (is(bo, 'bpmn:Participant')) { + return null; + } - function isMessageFlowTarget(element) { - return is(element, 'bpmn:InteractionNode') && (!is(element, 'bpmn:Event') || ( - is(element, 'bpmn:CatchEvent') && - hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition') - )); - } + while (bo) { + bo = bo.$parent; - function getScopeParent(element) { + if (is(bo, 'bpmn:FlowElementsContainer')) { + return bo; + } + } - var bo = getBusinessObject(element); + return bo; + } - if (is(bo, 'bpmn:Participant')) { - return null; - } + function isSameScope(a, b) { + var scopeParentA = getScopeParent(a), + scopeParentB = getScopeParent(b); - while (bo) { - bo = bo.$parent; + return scopeParentA && (scopeParentA === scopeParentB); + } - if (is(bo, 'bpmn:FlowElementsContainer')) { - return bo; - } - } + function hasEventDefinition(element, eventDefinition) { + var bo = getBusinessObject(element); - return bo; - } + return !!find(bo.eventDefinitions || [], function(definition) { + return is(definition, eventDefinition); + }); + } - function isSameScope(a, b) { - var scopeParentA = getScopeParent(a), - scopeParentB = getScopeParent(b); + function hasEventDefinitionOrNone(element, eventDefinition) { + var bo = getBusinessObject(element); - return scopeParentA && (scopeParentA === scopeParentB); - } + return (bo.eventDefinitions || []).every(function(definition) { + return is(definition, eventDefinition); + }); + } - function hasEventDefinition(element, eventDefinition) { - var bo = getBusinessObject(element); + function isSequenceFlowSource(element) { + return is(element, 'bpmn:FlowNode') && !is(element, 'bpmn:EndEvent') && !( + is(element, 'bpmn:IntermediateThrowEvent') && + hasEventDefinition(element, 'bpmn:LinkEventDefinition') + ); + } - return !!find(bo.eventDefinitions || [], function(definition) { - return is(definition, eventDefinition); - }); - } + function isSequenceFlowTarget(element) { + return is(element, 'bpmn:FlowNode') && !is(element, 'bpmn:StartEvent') && !( + is(element, 'bpmn:IntermediateCatchEvent') && + hasEventDefinition(element, 'bpmn:LinkEventDefinition') + ); + } - function hasEventDefinitionOrNone(element, eventDefinition) { - var bo = getBusinessObject(element); + function isEventBasedTarget(element) { + return is(element, 'bpmn:ReceiveTask') || ( + is(element, 'bpmn:IntermediateCatchEvent') && ( + hasEventDefinition(element, 'bpmn:MessageEventDefinition') || + hasEventDefinition(element, 'bpmn:TimerEventDefinition') || + hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') || + hasEventDefinition(element, 'bpmn:SignalEventDefinition') + ) + ); + } - return (bo.eventDefinitions || []).every(function(definition) { - return is(definition, eventDefinition); - }); - } + function isLabel(element) { + return element.labelTarget; + } - function isSequenceFlowSource(element) { - return is(element, 'bpmn:FlowNode') && !is(element, 'bpmn:EndEvent') && !( - is(element, 'bpmn:IntermediateThrowEvent') && - hasEventDefinition(element, 'bpmn:LinkEventDefinition') - ); - } + function isConnection(element) { + return element.waypoints; + } - function isSequenceFlowTarget(element) { - return is(element, 'bpmn:FlowNode') && !is(element, 'bpmn:StartEvent') && !( - is(element, 'bpmn:IntermediateCatchEvent') && - hasEventDefinition(element, 'bpmn:LinkEventDefinition') - ); - } + function isParent(possibleParent, element) { + var allParents = getParents(element); + return allParents.indexOf(possibleParent) !== -1; + } - function isEventBasedTarget(element) { - return is(element, 'bpmn:ReceiveTask') || ( - is(element, 'bpmn:IntermediateCatchEvent') && ( - hasEventDefinition(element, 'bpmn:MessageEventDefinition') || - hasEventDefinition(element, 'bpmn:TimerEventDefinition') || - hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') || - hasEventDefinition(element, 'bpmn:SignalEventDefinition') - ) - ); - } + function canConnect(source, target, connection) { - function isLabel(element) { - return element.labelTarget; - } + if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) { + return null; + } - function isConnection(element) { - return element.waypoints; - } + // See https://github.com/bpmn-io/bpmn-js/issues/178 + // as a workround we disallow connections with same + // target and source element. + // This rule must be removed if a auto layout for this + // connections is implemented. + if (isSame(source, target)) { + return false; + } - function isParent(possibleParent, element) { - var allParents = getParents(element); - return allParents.indexOf(possibleParent) !== -1; - } + if (canConnectMessageFlow(source, target) || + canConnectSequenceFlow(source, target)) { - function canConnect(source, target, connection) { + return true; + } - if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) { - return null; - } + if (is(connection, 'bpmn:Association')) { + return canConnectAssociation(source, target); + } - // See https://github.com/bpmn-io/bpmn-js/issues/178 - // as a workround we disallow connections with same - // target and source element. - // This rule must be removed if a auto layout for this - // connections is implemented. - if (isSame(source, target)) { - return false; - } + return false; + } - if (canConnectMessageFlow(source, target) || - canConnectSequenceFlow(source, target)) { + /** + * Can an element be dropped into the target element + * + * @return {Boolean} + */ + function canDrop(element, target) { - return true; - } + // can move labels everywhere + if (isLabel(element) && !isConnection(target)) { + return true; + } - if (is(connection, 'bpmn:Association')) { - return canConnectAssociation(source, target); - } + // allow to create new participants on + // on existing collaboration and process diagrams + if (is(element, 'bpmn:Participant')) { + return is(target, 'bpmn:Process') || is(target, 'bpmn:Collaboration'); + } - return false; + // drop flow elements onto flow element containers + // and participants + if (is(element, 'bpmn:FlowElement')) { + if (is(target, 'bpmn:FlowElementsContainer')) { + return isExpanded(target) !== false; } - /** - * Can an element be dropped into the target element - * - * @return {Boolean} - */ - function canDrop(element, target) { + return is(target, 'bpmn:Participant'); + } - // can move labels everywhere - if (isLabel(element) && !isConnection(target)) { - return true; - } + if (is(element, 'bpmn:Artifact')) { + return is(target, 'bpmn:Collaboration') || + is(target, 'bpmn:Participant') || + is(target, 'bpmn:Process'); + } - // allow to create new participants on - // on existing collaboration and process diagrams - if (is(element, 'bpmn:Participant')) { - return is(target, 'bpmn:Process') || is(target, 'bpmn:Collaboration'); - } + if (is(element, 'bpmn:MessageFlow')) { + return is(target, 'bpmn:Collaboration'); + } - // drop flow elements onto flow element containers - // and participants - if (is(element, 'bpmn:FlowElement')) { - if (is(target, 'bpmn:FlowElementsContainer')) { - return isExpanded(target) !== false; - } + return false; + } - return is(target, 'bpmn:Participant'); - } + function canMove(elements, target) { - if (is(element, 'bpmn:Artifact')) { - return is(target, 'bpmn:Collaboration') || - is(target, 'bpmn:Participant') || - is(target, 'bpmn:Process'); - } + // only move if they have the same parent + var sameParent = size(groupBy(elements, function(s) { + return s.parent && s.parent.id; + })) === 1; - if (is(element, 'bpmn:MessageFlow')) { - return is(target, 'bpmn:Collaboration'); - } + if (!sameParent) { + return false; + } - return false; - } + if (!target) { + return true; + } - function canMove(elements, target) { + return elements.every(function(element) { + return canDrop(element, target); + }); + } - // only move if they have the same parent - var sameParent = size(groupBy(elements, function(s) { - return s.parent && s.parent.id; - })) === 1; + function canCreate(shape, target, source) { - if (!sameParent) { - return false; - } + if (!target) { + return false; + } - if (!target) { - return true; - } + if (isLabel(target)) { + return null; + } - return elements.every(function(element) { - return canDrop(element, target); - }); - } + if (isSame(source, target)) { + return false; + } - function canCreate(shape, target, source) { + // ensure we do not drop the element + // into source + if (source && isParent(source, target)) { + return false; + } - if (!target) { - return false; - } + return canDrop(shape, target); + } - if (isLabel(target)) { - return null; - } + function canResize(shape, newBounds) { + if (is(shape, 'bpmn:SubProcess')) { + return isExpanded(shape) && (!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)); + } - if (isSame(source, target)) { - return false; - } + if (is(shape, 'bpmn:Participant')) { + return !newBounds || (newBounds.width >= 100 && newBounds.height >= 80); + } - // ensure we do not drop the element - // into source - if (source && isParent(source, target)) { - return false; - } + if (is(shape, 'bpmn:TextAnnotation')) { + return true; + } + if (is(shape, 'bpmn:MultiBranchConnector')) { + return false; + } - return canDrop(shape, target); - } + return true; + } - function canResize(shape, newBounds) { - if (is(shape, 'bpmn:SubProcess')) { - return isExpanded(shape) && (!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)); - } + function canConnectAssociation(source, target) { - if (is(shape, 'bpmn:Participant')) { - return !newBounds || (newBounds.width >= 100 && newBounds.height >= 80); - } + // do not connect connections + if (isConnection(source) || isConnection(target)) { + return false; + } - if (is(shape, 'bpmn:TextAnnotation')) { - return true; - } - if (is(shape, 'bpmn:MultiBranchConnector')) { - return false; - } + // connect if different parent + return !isParent(target, source) && + !isParent(source, target); + } - return true; - } + function canConnectMessageFlow(source, target) { - function canConnectAssociation(source, target) { + return isMessageFlowSource(source) && + isMessageFlowTarget(target) && + !isSameOrganization(source, target); + } - // do not connect connections - if (isConnection(source) || isConnection(target)) { - return false; - } + function canConnectSequenceFlow(source, target) { - // connect if different parent - return !isParent(target, source) && - !isParent(source, target); - } + return isSequenceFlowSource(source) && + isSequenceFlowTarget(target) && + isSameScope(source, target) && + !(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target)); + } + }, { + "../../../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", + "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "../ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", + "diagram-js/lib/features/rules/RuleProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\rules\\RuleProvider.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js", + "lodash/collection/groupBy": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\groupBy.js", + "lodash/collection/size": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\size.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('diagram-js/lib/features/rules') + ], + __init__: ['bpmnRules'], + bpmnRules: ['type', require('./BpmnRules')] + }; + + }, { + "./BpmnRules": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\BpmnRules.js", + "diagram-js/lib/features/rules": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\rules\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\PaletteProvider.js": [function(require, module, exports) { + 'use strict'; + + var assign = require('lodash/object/assign'); + + /** + * A palette provider for BPMN 2.0 elements. + */ + function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool) { + + this._create = create; + this._elementFactory = elementFactory; + this._spaceTool = spaceTool; + this._lassoTool = lassoTool; + + palette.registerProvider(this); + } - function canConnectMessageFlow(source, target) { + module.exports = PaletteProvider; - return isMessageFlowSource(source) && - isMessageFlowTarget(target) && - !isSameOrganization(source, target); - } + PaletteProvider.$inject = ['palette', 'create', 'elementFactory', 'spaceTool', 'lassoTool']; - function canConnectSequenceFlow(source, target) { - return isSequenceFlowSource(source) && - isSequenceFlowTarget(target) && - isSameScope(source, target) && - !(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target)); - } - }, { - "../../../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", - "../../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "../ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", - "diagram-js/lib/features/rules/RuleProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\rules\\RuleProvider.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js", - "lodash/collection/groupBy": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\groupBy.js", - "lodash/collection/size": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\size.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('diagram-js/lib/features/rules') - ], - __init__: ['bpmnRules'], - bpmnRules: ['type', require('./BpmnRules')] - }; + PaletteProvider.prototype.getPaletteEntries = function(element) { - }, { - "./BpmnRules": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\rules\\BpmnRules.js", - "diagram-js/lib/features/rules": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\rules\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\PaletteProvider.js": [function(require, module, exports) { - 'use strict'; + var actions = {}, + create = this._create, + elementFactory = this._elementFactory, + spaceTool = this._spaceTool, + lassoTool = this._lassoTool; - var assign = require('lodash/object/assign'); - /** - * A palette provider for BPMN 2.0 elements. - */ - function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool) { + function createAction(type, group, className, title, options) { + function createListener(event) { + var shape = elementFactory.createShape(assign({ + type: type + }, options)); - this._create = create; - this._elementFactory = elementFactory; - this._spaceTool = spaceTool; - this._lassoTool = lassoTool; + if (options) { + shape.businessObject.di.isExpanded = options.isExpanded; + } - palette.registerProvider(this); + create.start(event, shape); } - module.exports = PaletteProvider; - - PaletteProvider.$inject = ['palette', 'create', 'elementFactory', 'spaceTool', 'lassoTool']; + var shortType = type.replace(/^bpmn\:/, ''); + return { + group: group, + className: className, + title: title || 'Create ' + shortType, + action: { + dragstart: createListener, + click: createListener + } + }; + } - PaletteProvider.prototype.getPaletteEntries = function(element) { + function createParticipant(event, collapsed) { + create.start(event, elementFactory.createParticipantShape(collapsed)); + } - var actions = {}, - create = this._create, - elementFactory = this._elementFactory, - spaceTool = this._spaceTool, - lassoTool = this._lassoTool; + assign(actions, { + 'create.start-event': createAction( + 'bpmn:StartEvent', 'event', 'icon-start-event-none', "Start" + ), + 'create.collector': createAction( + 'bpmn:Collector', 'event', 'icon-collector-node', 'Collector' + ), + 'create.String-Match': createAction( + 'bpmn:StringMatch', 'event', 'icon-stringmatch-node', 'String Match' + ), + 'create.ves-collector': createAction( + 'bpmn:VesCollector', 'event', 'icon-ves-collector-node', 'Ves Collector' + ), + 'create.holmes': createAction( + 'bpmn:Holmes', 'event', 'icon-holmes-node', 'Holmes' + ), + + + 'create.TCA': createAction( + 'bpmn:TCA', 'event', 'icon-tca-node', 'TCA' + ), + 'create.Aand-AI': createAction( + 'bpmn:Policy', 'event', 'icon-policy-node', 'Policy' + ), + 'create.end-event': createAction( + 'bpmn:EndEvent', 'event', 'icon-end-event-none', "End" + ) + }); + + return actions; + }; + + }, { + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('diagram-js/lib/features/palette'), + require('diagram-js/lib/features/create') + ], + __init__: ['paletteProvider'], + paletteProvider: ['type', require('./PaletteProvider')] + }; + + }, { + "./PaletteProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\PaletteProvider.js", + "diagram-js/lib/features/create": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\create\\index.js", + "diagram-js/lib/features/palette": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\palette\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\BpmnReplace.js": [function(require, module, exports) { + 'use strict'; + + var forEach = require('lodash/collection/forEach'), + filter = require('lodash/collection/filter'); + + var REPLACE_OPTIONS = require('./ReplaceOptions'); + + var startEventReplace = REPLACE_OPTIONS.START_EVENT, + intermediateEventReplace = REPLACE_OPTIONS.INTERMEDIATE_EVENT, + endEventReplace = REPLACE_OPTIONS.END_EVENT, + gatewayReplace = REPLACE_OPTIONS.GATEWAY, + taskReplace = REPLACE_OPTIONS.TASK; + + + /** + * A replace menu provider that gives users the controls to choose and replace + * BPMN elements with each other. + * + * @param {BpmnFactory} + * bpmnFactory + * @param {Moddle} + * moddle + * @param {PopupMenu} + * popupMenu + * @param {Replace} + * replace + */ + function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection) { + + /** + * Prepares a new business object for the replacement element and triggers + * the replace operation. + * + * @param {djs.model.Base} + * element + * @param {Object} + * target + * @return {djs.model.Base} the newly created element + */ + function replaceElement(element, target) { + + var type = target.type, + oldBusinessObject = element.businessObject, + businessObject = bpmnFactory.create(type); + + var newElement = { + type: type, + businessObject: businessObject + }; + + // initialize custom BPMN extensions + + if (target.eventDefinition) { + var eventDefinitions = businessObject.get('eventDefinitions'), + eventDefinition = moddle.create(target.eventDefinition); + + eventDefinitions.push(eventDefinition); + } + if (target.instantiate !== undefined) { + businessObject.instantiate = target.instantiate; + } - function createAction(type, group, className, title, options) { - function createListener(event) { - var shape = elementFactory.createShape(assign({ - type: type - }, options)); + if (target.eventGatewayType !== undefined) { + businessObject.eventGatewayType = target.eventGatewayType; + } - if (options) { - shape.businessObject.di.isExpanded = options.isExpanded; - } + // copy size (for activities only) + if (oldBusinessObject.$instanceOf('bpmn:Activity')) { - create.start(event, shape); - } + // TODO: need also to respect min/max Size - var shortType = type.replace(/^bpmn\:/, ''); + newElement.width = element.width; + newElement.height = element.height; + } - return { - group: group, - className: className, - title: title || 'Create ' + shortType, - action: { - dragstart: createListener, - click: createListener - } - }; - } + // TODO: copy other elligable properties from old business object + businessObject.name = oldBusinessObject.name; - function createParticipant(event, collapsed) { - create.start(event, elementFactory.createParticipantShape(collapsed)); - } - - assign(actions, { - 'create.start-event': createAction( - 'bpmn:StartEvent', 'event', 'icon-start-event-none', "Start" - ), - 'create.collector': createAction( - 'bpmn:Collector', 'event', 'icon-collector-node', 'Collector' - ), - 'create.String-Match': createAction( - 'bpmn:StringMatch', 'event', 'icon-stringmatch-node', 'String Match' - ), - 'create.ves-collector': createAction( - 'bpmn:VesCollector', 'event', 'icon-ves-collector-node', 'Ves Collector' - ), - 'create.holmes': createAction( - 'bpmn:Holmes', 'event', 'icon-holmes-node', 'Holmes' - ), - - - 'create.TCA': createAction( - 'bpmn:TCA', 'event', 'icon-tca-node', 'TCA' - ), - 'create.Aand-AI': createAction( - 'bpmn:Policy', 'event', 'icon-policy-node', 'Policy' - ), - 'create.end-event': createAction( - 'bpmn:EndEvent', 'event', 'icon-end-event-none', "End" - ) - }); + newElement = replace.replaceElement(element, newElement); - return actions; - }; + selection.select(newElement); - }, { - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('diagram-js/lib/features/palette'), - require('diagram-js/lib/features/create') - ], - __init__: ['paletteProvider'], - paletteProvider: ['type', require('./PaletteProvider')] - }; + return newElement; + } - }, { - "./PaletteProvider": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\palette\\PaletteProvider.js", - "diagram-js/lib/features/create": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\create\\index.js", - "diagram-js/lib/features/palette": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\palette\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\BpmnReplace.js": [function(require, module, exports) { - 'use strict'; - var forEach = require('lodash/collection/forEach'), - filter = require('lodash/collection/filter'); + function getReplaceOptions(element) { - var REPLACE_OPTIONS = require('./ReplaceOptions'); + var menuEntries = []; + var businessObject = element.businessObject; - var startEventReplace = REPLACE_OPTIONS.START_EVENT, - intermediateEventReplace = REPLACE_OPTIONS.INTERMEDIATE_EVENT, - endEventReplace = REPLACE_OPTIONS.END_EVENT, - gatewayReplace = REPLACE_OPTIONS.GATEWAY, - taskReplace = REPLACE_OPTIONS.TASK; + if (businessObject.$instanceOf('bpmn:StartEvent')) { + addEntries(startEventReplace, filterEvents); + } else + if (businessObject.$instanceOf('bpmn:IntermediateCatchEvent') || + businessObject.$instanceOf('bpmn:IntermediateThrowEvent')) { - /** - * A replace menu provider that gives users the controls to choose and replace - * BPMN elements with each other. - * - * @param {BpmnFactory} - * bpmnFactory - * @param {Moddle} - * moddle - * @param {PopupMenu} - * popupMenu - * @param {Replace} - * replace - */ - function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection) { + addEntries(intermediateEventReplace, filterEvents); + } else - /** - * Prepares a new business object for the replacement element and triggers - * the replace operation. - * - * @param {djs.model.Base} - * element - * @param {Object} - * target - * @return {djs.model.Base} the newly created element - */ - function replaceElement(element, target) { + if (businessObject.$instanceOf('bpmn:EndEvent')) { - var type = target.type, - oldBusinessObject = element.businessObject, - businessObject = bpmnFactory.create(type); + addEntries(endEventReplace, filterEvents); + } else - var newElement = { - type: type, - businessObject: businessObject - }; + if (businessObject.$instanceOf('bpmn:Gateway')) { - // initialize custom BPMN extensions + addEntries(gatewayReplace, function(entry) { - if (target.eventDefinition) { - var eventDefinitions = businessObject.get('eventDefinitions'), - eventDefinition = moddle.create(target.eventDefinition); + return entry.target.type !== businessObject.$type; + }); + } else - eventDefinitions.push(eventDefinition); - } + if (businessObject.$instanceOf('bpmn:FlowNode')) { + addEntries(taskReplace, function(entry) { + return entry.target.type !== businessObject.$type; + }); + } - if (target.instantiate !== undefined) { - businessObject.instantiate = target.instantiate; - } + function filterEvents(entry) { - if (target.eventGatewayType !== undefined) { - businessObject.eventGatewayType = target.eventGatewayType; - } + var target = entry.target; - // copy size (for activities only) - if (oldBusinessObject.$instanceOf('bpmn:Activity')) { + var eventDefinition = businessObject.eventDefinitions && businessObject.eventDefinitions[0].$type; + var isEventDefinitionEqual = target.eventDefinition == eventDefinition; + var isEventTypeEqual = businessObject.$type == target.type; - // TODO: need also to respect min/max Size + return ((!isEventDefinitionEqual && isEventTypeEqual) || + !isEventTypeEqual) || + !(isEventDefinitionEqual && isEventTypeEqual); + } - newElement.width = element.width; - newElement.height = element.height; - } + function addEntries(entries, filterFun) { + // Filter selected type from the array + var filteredEntries = filter(entries, filterFun); - // TODO: copy other elligable properties from old business object - businessObject.name = oldBusinessObject.name; + // Add entries to replace menu + forEach(filteredEntries, function(definition) { - newElement = replace.replaceElement(element, newElement); + var entry = addMenuEntry(definition); + menuEntries.push(entry); + }); + } - selection.select(newElement); + function addMenuEntry(definition) { - return newElement; + return { + label: definition.label, + className: definition.className, + action: { + name: definition.actionName, + handler: function() { + replaceElement(element, definition.target); + } } + }; + } + return menuEntries; + } - function getReplaceOptions(element) { - - var menuEntries = []; - var businessObject = element.businessObject; - - if (businessObject.$instanceOf('bpmn:StartEvent')) { - addEntries(startEventReplace, filterEvents); - } else - - if (businessObject.$instanceOf('bpmn:IntermediateCatchEvent') || - businessObject.$instanceOf('bpmn:IntermediateThrowEvent')) { - - addEntries(intermediateEventReplace, filterEvents); - } else - - if (businessObject.$instanceOf('bpmn:EndEvent')) { - - addEntries(endEventReplace, filterEvents); - } else - - if (businessObject.$instanceOf('bpmn:Gateway')) { - - addEntries(gatewayReplace, function(entry) { - return entry.target.type !== businessObject.$type; - }); - } else + // API - if (businessObject.$instanceOf('bpmn:FlowNode')) { - addEntries(taskReplace, function(entry) { - return entry.target.type !== businessObject.$type; - }); - } + this.openChooser = function(position, element) { + var entries = this.getReplaceOptions(element); - function filterEvents(entry) { + popupMenu.open('replace-menu', position, entries); + }; - var target = entry.target; + this.getReplaceOptions = getReplaceOptions; - var eventDefinition = businessObject.eventDefinitions && businessObject.eventDefinitions[0].$type; - var isEventDefinitionEqual = target.eventDefinition == eventDefinition; - var isEventTypeEqual = businessObject.$type == target.type; + this.replaceElement = replaceElement; + } - return ((!isEventDefinitionEqual && isEventTypeEqual) || - !isEventTypeEqual) || - !(isEventDefinitionEqual && isEventTypeEqual); - } - - function addEntries(entries, filterFun) { - // Filter selected type from the array - var filteredEntries = filter(entries, filterFun); + BpmnReplace.$inject = ['bpmnFactory', 'moddle', 'popupMenu', 'replace', 'selection']; + + module.exports = BpmnReplace; + }, { + "./ReplaceOptions": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\ReplaceOptions.js", + "lodash/collection/filter": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\filter.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\ReplaceOptions.js": [function(require, module, exports) { + 'use strict'; + + module.exports.START_EVENT = [{ + label: 'Start Event', + actionName: 'replace-with-none-start', + className: 'icon-start-event-none', + target: { + type: 'bpmn:StartEvent' + } + }, { + label: 'Intermediate Throw Event', + actionName: 'replace-with-intermediate-throwing', + className: 'icon-intermediate-event-none', + target: { + type: 'bpmn:IntermediateThrowEvent' + } + }, { + label: 'End Event', + actionName: 'replace-with-message-end', + className: 'icon-end-event-none', + target: { + type: 'bpmn:EndEvent' + } + }, { + label: 'Message Start Event', + actionName: 'replace-with-message-start', + className: 'icon-start-event-message', + target: { + type: 'bpmn:StartEvent', + eventDefinition: 'bpmn:MessageEventDefinition' + } + }, { + label: 'Timer Start Event', + actionName: 'replace-with-timer-start', + className: 'icon-start-event-timer', + target: { + type: 'bpmn:StartEvent', + eventDefinition: 'bpmn:TimerEventDefinition' + } + }, { + label: 'Conditional Start Event', + actionName: 'replace-with-conditional-start', + className: 'icon-start-event-condition', + target: { + type: 'bpmn:StartEvent', + eventDefinition: 'bpmn:ConditionalEventDefinition' + } + }, { + label: 'Signal Start Event', + actionName: 'replace-with-signal-start', + className: 'icon-start-event-signal', + target: { + type: 'bpmn:StartEvent', + eventDefinition: 'bpmn:SignalEventDefinition' + } + }]; + + module.exports.INTERMEDIATE_EVENT = [{ + label: 'Start Event', + actionName: 'replace-with-none-start', + className: 'icon-start-event-none', + target: { + type: 'bpmn:StartEvent' + } + }, { + label: 'Intermediate Throw Event', + actionName: 'replace-with-message-intermediate-throw', + className: 'icon-intermediate-event-none', + target: { + type: 'bpmn:IntermediateThrowEvent' + } + }, { + label: 'End Event', + actionName: 'replace-with-message-end', + className: 'icon-end-event-none', + target: { + type: 'bpmn:EndEvent' + } + }, { + label: 'Message Intermediate Catch Event', + actionName: 'replace-with-intermediate-catch', + className: 'icon-intermediate-event-catch-message', + target: { + type: 'bpmn:IntermediateCatchEvent', + eventDefinition: 'bpmn:MessageEventDefinition' + } + }, { + label: 'Message Intermediate Throw Event', + actionName: 'replace-with-intermediate-throw', + className: 'icon-intermediate-event-throw-message', + target: { + type: 'bpmn:IntermediateThrowEvent', + eventDefinition: 'bpmn:MessageEventDefinition' + } + }, { + label: 'Timer Intermediate Catch Event', + actionName: 'replace-with-timer-intermediate-catch', + className: 'icon-intermediate-event-catch-timer', + target: { + type: 'bpmn:IntermediateCatchEvent', + eventDefinition: 'bpmn:TimerEventDefinition' + } + }, { + label: 'Escalation Intermediate Catch Event', + actionName: 'replace-with-escalation-catch', + className: 'icon-intermediate-event-catch-escalation', + target: { + type: 'bpmn:IntermediateCatchEvent', + eventDefinition: 'bpmn:EscalationEventDefinition' + } + }, { + label: 'Conditional Intermediate Catch Event', + actionName: 'replace-with-conditional-intermediate-catch', + className: 'icon-intermediate-event-catch-condition', + target: { + type: 'bpmn:IntermediateCatchEvent', + eventDefinition: 'bpmn:ConditionalEventDefinition' + } + }, { + label: 'Link Intermediate Catch Event', + actionName: 'replace-with-link-intermediate-catch', + className: 'icon-intermediate-event-catch-link', + target: { + type: 'bpmn:IntermediateCatchEvent', + eventDefinition: 'bpmn:LinkEventDefinition' + } + }, { + label: 'Link Intermediate Throw Event', + actionName: 'replace-with-link-intermediate-throw', + className: 'icon-intermediate-event-throw-link', + target: { + type: 'bpmn:IntermediateThrowEvent', + eventDefinition: 'bpmn:LinkEventDefinition' + } + }, { + label: 'Compensation Intermediate Throw Event', + actionName: 'replace-with-compensation-intermediate-throw', + className: 'icon-intermediate-event-throw-compensation', + target: { + type: 'bpmn:IntermediateThrowEvent', + eventDefinition: 'bpmn:CompensateEventDefinition' + } + }, { + label: 'Signal Throw Catch Event', + actionName: 'replace-with-throw-intermediate-catch', + className: 'icon-intermediate-event-catch-signal', + target: { + type: 'bpmn:IntermediateCatchEvent', + eventDefinition: 'bpmn:SignalEventDefinition' + } + }, { + label: 'Signal Intermediate Throw Event', + actionName: 'replace-with-signal-intermediate-throw', + className: 'icon-intermediate-event-throw-signal', + target: { + type: 'bpmn:IntermediateThrowEvent', + eventDefinition: 'bpmn:SignalEventDefinition' + } + }]; + + module.exports.END_EVENT = [{ + label: 'Start Event', + actionName: 'replace-with-none-start', + className: 'icon-start-event-none', + target: { + type: 'bpmn:StartEvent' + } + }, { + label: 'Intermediate Throw Event', + actionName: 'replace-with-message-intermediate-throw', + className: 'icon-intermediate-event-none', + target: { + type: 'bpmn:IntermediateThrowEvent' + } + }, { + label: 'End Event', + actionName: 'replace-with-none-end', + className: 'icon-end-event-none', + target: { + type: 'bpmn:EndEvent' + } + }, { + label: 'Message End Event', + actionName: 'replace-with-message-end', + className: 'icon-end-event-message', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:MessageEventDefinition' + } + }, { + label: 'Escalation End Event', + actionName: 'replace-with-escalation-end', + className: 'icon-end-event-escalation', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:EscalationEventDefinition' + } + }, { + label: 'Error End Event', + actionName: 'replace-with-error-end', + className: 'icon-end-event-error', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:ErrorEventDefinition' + } + }, { + label: 'Cancel End Event', + actionName: 'replace-with-cancel-end', + className: 'icon-end-event-cancel', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:CancelEventDefinition' + } + }, { + label: 'Compensation End Event', + actionName: 'replace-with-compensation-end', + className: 'icon-end-event-compensation', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:CompensateEventDefinition' + } + }, { + label: 'Signal End Event', + actionName: 'replace-with-signal-end', + className: 'icon-end-event-signal', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:SignalEventDefinition' + } + }, { + label: 'Terminate End Event', + actionName: 'replace-with-terminate-end', + className: 'icon-end-event-terminate', + target: { + type: 'bpmn:EndEvent', + eventDefinition: 'bpmn:TerminateEventDefinition' + } + }]; + + module.exports.GATEWAY = [{ + label: 'Exclusive Gateway', + actionName: 'replace-with-exclusive-gateway', + className: 'icon-gateway-xor', + target: { + type: 'bpmn:ExclusiveGateway' + } + }, { + label: 'Parallel Gateway', + actionName: 'replace-with-parallel-gateway', + className: 'icon-gateway-parallel', + target: { + type: 'bpmn:ParallelGateway' + } + }, { + label: 'Inclusive Gateway', + actionName: 'replace-with-inclusive-gateway', + className: 'icon-gateway-or', + target: { + type: 'bpmn:InclusiveGateway' + } + }, { + label: 'Complex Gateway', + actionName: 'replace-with-complex-gateway', + className: 'icon-gateway-complex', + target: { + type: 'bpmn:ComplexGateway' + } + }, { + label: 'Event based Gateway', + actionName: 'replace-with-event-based-gateway', + className: 'icon-gateway-eventbased', + target: { + type: 'bpmn:EventBasedGateway', + instantiate: false, + eventGatewayType: 'Exclusive' + } + } + // Gateways deactivated until https://github.com/bpmn-io/bpmn-js/issues/194 + // { + // label: 'Event based instantiating Gateway', + // actionName: 'replace-with-exclusive-event-based-gateway', + // className: 'icon-exclusive-event-based', + // target: { + // type: 'bpmn:EventBasedGateway' + // }, + // options: { + // businessObject: { instantiate: true, eventGatewayType: 'Exclusive' } + // } + // }, + // { + // label: 'Parallel Event based instantiating Gateway', + // actionName: 'replace-with-parallel-event-based-instantiate-gateway', + // className: 'icon-parallel-event-based-instantiate-gateway', + // target: { + // type: 'bpmn:EventBasedGateway' + // }, + // options: { + // businessObject: { instantiate: true, eventGatewayType: 'Parallel' } + // } + // } + ]; + + + module.exports.TASK = [{ + label: 'Task', + actionName: 'replace-with-task', + className: 'icon-task', + target: { + type: 'bpmn:Task' + } + }, { + label: 'Send Task', + actionName: 'replace-with-send-task', + className: 'icon-send', + target: { + type: 'bpmn:SendTask' + } + }, { + label: 'Receive Task', + actionName: 'replace-with-receive-task', + className: 'icon-receive', + target: { + type: 'bpmn:ReceiveTask' + } + }, { + label: 'User Task', + actionName: 'replace-with-user-task', + className: 'icon-user', + target: { + type: 'bpmn:UserTask' + } + }, { + label: 'Manual Task', + actionName: 'replace-with-manual-task', + className: 'icon-manual', + target: { + type: 'bpmn:ManualTask' + } + }, { + label: 'Business Rule Task', + actionName: 'replace-with-rule-task', + className: 'icon-business-rule', + target: { + type: 'bpmn:BusinessRuleTask' + } + }, { + label: 'Service Task', + actionName: 'replace-with-service-task', + className: 'icon-service', + target: { + type: 'bpmn:ServiceTask' + } + }, { + label: 'Script Task', + actionName: 'replace-with-script-task', + className: 'icon-script', + target: { + type: 'bpmn:ScriptTask' + } + }]; + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\index.js": [function(require, module, exports) { + module.exports = { + __depends__: [ + require('diagram-js/lib/features/popup-menu'), + require('diagram-js/lib/features/replace'), + require('diagram-js/lib/features/selection') + ], + bpmnReplace: ['type', require('./BpmnReplace')] + }; + }, { + "./BpmnReplace": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\BpmnReplace.js", + "diagram-js/lib/features/popup-menu": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\popup-menu\\index.js", + "diagram-js/lib/features/replace": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\replace\\index.js", + "diagram-js/lib/features/selection": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\selection\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\BpmnSnapping.js": [function(require, module, exports) { + 'use strict'; + + var inherits = require('inherits'); + + var forEach = require('lodash/collection/forEach'); + + var getBoundingBox = require('diagram-js/lib/util/Elements').getBBox; + var is = require('../modeling/ModelingUtil').is; + + var Snapping = require('diagram-js/lib/features/snapping/Snapping'), + SnapUtil = require('diagram-js/lib/features/snapping/SnapUtil'); + + var is = require('../../util/ModelUtil').is; + + var mid = SnapUtil.mid, + topLeft = SnapUtil.topLeft, + bottomRight = SnapUtil.bottomRight; + + var round = Math.round; + + + /** + * BPMN specific snapping functionality + * * snap on process elements if a pool is created inside a process diagram + * + * @param {EventBus} + * eventBus + * @param {Canvas} + * canvas + */ + function BpmnSnapping(eventBus, canvas) { + + // instantiate super + Snapping.call(this, eventBus, canvas); + + + /** + * Drop participant on process <> process elements snapping + */ + + function initParticipantSnapping(context, shape, elements) { + + if (!elements.length) { + return; + } - // Add entries to replace menu - forEach(filteredEntries, function(definition) { + var snapBox = getBoundingBox(elements.filter(function(e) { + return !e.labelTarget && !e.waypoints; + })); - var entry = addMenuEntry(definition); - menuEntries.push(entry); - }); - } + snapBox.x -= 50; + snapBox.y -= 20; + snapBox.width += 70; + snapBox.height += 40; - function addMenuEntry(definition) { + // adjust shape height to include bounding box + shape.width = Math.max(shape.width, snapBox.width); + shape.height = Math.max(shape.height, snapBox.height); - return { - label: definition.label, - className: definition.className, - action: { - name: definition.actionName, - handler: function() { - replaceElement(element, definition.target); - } - } - }; - } + context.participantSnapBox = snapBox; + } - return menuEntries; - } + function snapParticipant(snapBox, shape, event) { + var shapeHalfWidth = shape.width / 2 - 30, + shapeHalfHeight = shape.height / 2; - // API + var currentTopLeft = { + x: event.x - shapeHalfWidth - 30, + y: event.y - shapeHalfHeight + }; - this.openChooser = function(position, element) { - var entries = this.getReplaceOptions(element); + var currentBottomRight = { + x: event.x + shapeHalfWidth + 30, + y: event.y + shapeHalfHeight + }; - popupMenu.open('replace-menu', position, entries); - }; + var snapTopLeft = snapBox, + snapBottomRight = bottomRight(snapBox); - this.getReplaceOptions = getReplaceOptions; + if (currentTopLeft.x >= snapTopLeft.x) { + event.x = snapTopLeft.x + 30 + shapeHalfWidth; + event.snapped = true; + } else + if (currentBottomRight.x <= snapBottomRight.x) { + event.x = snapBottomRight.x - 30 - shapeHalfWidth; + event.snapped = true; + } - this.replaceElement = replaceElement; + if (currentTopLeft.y >= snapTopLeft.y) { + event.y = snapTopLeft.y + shapeHalfHeight; + event.snapped = true; + } else + if (currentBottomRight.y <= snapBottomRight.y) { + event.y = snapBottomRight.y - shapeHalfHeight; + event.snapped = true; } + } - BpmnReplace.$inject = ['bpmnFactory', 'moddle', 'popupMenu', 'replace', 'selection']; + eventBus.on('create.start', function(event) { - module.exports = BpmnReplace; - }, { - "./ReplaceOptions": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\ReplaceOptions.js", - "lodash/collection/filter": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\filter.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\ReplaceOptions.js": [function(require, module, exports) { - 'use strict'; + var context = event.context, + shape = context.shape, + rootElement = canvas.getRootElement(); - module.exports.START_EVENT = [{ - label: 'Start Event', - actionName: 'replace-with-none-start', - className: 'icon-start-event-none', - target: { - type: 'bpmn:StartEvent' - } - }, { - label: 'Intermediate Throw Event', - actionName: 'replace-with-intermediate-throwing', - className: 'icon-intermediate-event-none', - target: { - type: 'bpmn:IntermediateThrowEvent' - } - }, { - label: 'End Event', - actionName: 'replace-with-message-end', - className: 'icon-end-event-none', - target: { - type: 'bpmn:EndEvent' - } - }, { - label: 'Message Start Event', - actionName: 'replace-with-message-start', - className: 'icon-start-event-message', - target: { - type: 'bpmn:StartEvent', - eventDefinition: 'bpmn:MessageEventDefinition' - } - }, { - label: 'Timer Start Event', - actionName: 'replace-with-timer-start', - className: 'icon-start-event-timer', - target: { - type: 'bpmn:StartEvent', - eventDefinition: 'bpmn:TimerEventDefinition' - } - }, { - label: 'Conditional Start Event', - actionName: 'replace-with-conditional-start', - className: 'icon-start-event-condition', - target: { - type: 'bpmn:StartEvent', - eventDefinition: 'bpmn:ConditionalEventDefinition' - } - }, { - label: 'Signal Start Event', - actionName: 'replace-with-signal-start', - className: 'icon-start-event-signal', - target: { - type: 'bpmn:StartEvent', - eventDefinition: 'bpmn:SignalEventDefinition' - } - }]; + // snap participant around existing elements (if any) + if (is(shape, 'bpmn:Participant') && is(rootElement, 'bpmn:Process')) { - module.exports.INTERMEDIATE_EVENT = [{ - label: 'Start Event', - actionName: 'replace-with-none-start', - className: 'icon-start-event-none', - target: { - type: 'bpmn:StartEvent' - } - }, { - label: 'Intermediate Throw Event', - actionName: 'replace-with-message-intermediate-throw', - className: 'icon-intermediate-event-none', - target: { - type: 'bpmn:IntermediateThrowEvent' - } - }, { - label: 'End Event', - actionName: 'replace-with-message-end', - className: 'icon-end-event-none', - target: { - type: 'bpmn:EndEvent' - } - }, { - label: 'Message Intermediate Catch Event', - actionName: 'replace-with-intermediate-catch', - className: 'icon-intermediate-event-catch-message', - target: { - type: 'bpmn:IntermediateCatchEvent', - eventDefinition: 'bpmn:MessageEventDefinition' - } - }, { - label: 'Message Intermediate Throw Event', - actionName: 'replace-with-intermediate-throw', - className: 'icon-intermediate-event-throw-message', - target: { - type: 'bpmn:IntermediateThrowEvent', - eventDefinition: 'bpmn:MessageEventDefinition' - } - }, { - label: 'Timer Intermediate Catch Event', - actionName: 'replace-with-timer-intermediate-catch', - className: 'icon-intermediate-event-catch-timer', - target: { - type: 'bpmn:IntermediateCatchEvent', - eventDefinition: 'bpmn:TimerEventDefinition' - } - }, { - label: 'Escalation Intermediate Catch Event', - actionName: 'replace-with-escalation-catch', - className: 'icon-intermediate-event-catch-escalation', - target: { - type: 'bpmn:IntermediateCatchEvent', - eventDefinition: 'bpmn:EscalationEventDefinition' - } - }, { - label: 'Conditional Intermediate Catch Event', - actionName: 'replace-with-conditional-intermediate-catch', - className: 'icon-intermediate-event-catch-condition', - target: { - type: 'bpmn:IntermediateCatchEvent', - eventDefinition: 'bpmn:ConditionalEventDefinition' - } - }, { - label: 'Link Intermediate Catch Event', - actionName: 'replace-with-link-intermediate-catch', - className: 'icon-intermediate-event-catch-link', - target: { - type: 'bpmn:IntermediateCatchEvent', - eventDefinition: 'bpmn:LinkEventDefinition' - } - }, { - label: 'Link Intermediate Throw Event', - actionName: 'replace-with-link-intermediate-throw', - className: 'icon-intermediate-event-throw-link', - target: { - type: 'bpmn:IntermediateThrowEvent', - eventDefinition: 'bpmn:LinkEventDefinition' - } - }, { - label: 'Compensation Intermediate Throw Event', - actionName: 'replace-with-compensation-intermediate-throw', - className: 'icon-intermediate-event-throw-compensation', - target: { - type: 'bpmn:IntermediateThrowEvent', - eventDefinition: 'bpmn:CompensateEventDefinition' - } - }, { - label: 'Signal Throw Catch Event', - actionName: 'replace-with-throw-intermediate-catch', - className: 'icon-intermediate-event-catch-signal', - target: { - type: 'bpmn:IntermediateCatchEvent', - eventDefinition: 'bpmn:SignalEventDefinition' - } - }, { - label: 'Signal Intermediate Throw Event', - actionName: 'replace-with-signal-intermediate-throw', - className: 'icon-intermediate-event-throw-signal', - target: { - type: 'bpmn:IntermediateThrowEvent', - eventDefinition: 'bpmn:SignalEventDefinition' - } - }]; + initParticipantSnapping(context, shape, rootElement.children); + } + }); - module.exports.END_EVENT = [{ - label: 'Start Event', - actionName: 'replace-with-none-start', - className: 'icon-start-event-none', - target: { - type: 'bpmn:StartEvent' - } - }, { - label: 'Intermediate Throw Event', - actionName: 'replace-with-message-intermediate-throw', - className: 'icon-intermediate-event-none', - target: { - type: 'bpmn:IntermediateThrowEvent' - } - }, { - label: 'End Event', - actionName: 'replace-with-none-end', - className: 'icon-end-event-none', - target: { - type: 'bpmn:EndEvent' - } - }, { - label: 'Message End Event', - actionName: 'replace-with-message-end', - className: 'icon-end-event-message', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:MessageEventDefinition' - } - }, { - label: 'Escalation End Event', - actionName: 'replace-with-escalation-end', - className: 'icon-end-event-escalation', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:EscalationEventDefinition' - } - }, { - label: 'Error End Event', - actionName: 'replace-with-error-end', - className: 'icon-end-event-error', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:ErrorEventDefinition' - } - }, { - label: 'Cancel End Event', - actionName: 'replace-with-cancel-end', - className: 'icon-end-event-cancel', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:CancelEventDefinition' - } - }, { - label: 'Compensation End Event', - actionName: 'replace-with-compensation-end', - className: 'icon-end-event-compensation', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:CompensateEventDefinition' - } - }, { - label: 'Signal End Event', - actionName: 'replace-with-signal-end', - className: 'icon-end-event-signal', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:SignalEventDefinition' - } - }, { - label: 'Terminate End Event', - actionName: 'replace-with-terminate-end', - className: 'icon-end-event-terminate', - target: { - type: 'bpmn:EndEvent', - eventDefinition: 'bpmn:TerminateEventDefinition' - } - }]; + eventBus.on(['create.move', 'create.end'], 1500, function(event) { - module.exports.GATEWAY = [{ - label: 'Exclusive Gateway', - actionName: 'replace-with-exclusive-gateway', - className: 'icon-gateway-xor', - target: { - type: 'bpmn:ExclusiveGateway' - } - }, { - label: 'Parallel Gateway', - actionName: 'replace-with-parallel-gateway', - className: 'icon-gateway-parallel', - target: { - type: 'bpmn:ParallelGateway' - } - }, { - label: 'Inclusive Gateway', - actionName: 'replace-with-inclusive-gateway', - className: 'icon-gateway-or', - target: { - type: 'bpmn:InclusiveGateway' - } - }, { - label: 'Complex Gateway', - actionName: 'replace-with-complex-gateway', - className: 'icon-gateway-complex', - target: { - type: 'bpmn:ComplexGateway' - } - }, { - label: 'Event based Gateway', - actionName: 'replace-with-event-based-gateway', - className: 'icon-gateway-eventbased', - target: { - type: 'bpmn:EventBasedGateway', - instantiate: false, - eventGatewayType: 'Exclusive' - } - } - // Gateways deactivated until https://github.com/bpmn-io/bpmn-js/issues/194 - // { - // label: 'Event based instantiating Gateway', - // actionName: 'replace-with-exclusive-event-based-gateway', - // className: 'icon-exclusive-event-based', - // target: { - // type: 'bpmn:EventBasedGateway' - // }, - // options: { - // businessObject: { instantiate: true, eventGatewayType: 'Exclusive' } - // } - // }, - // { - // label: 'Parallel Event based instantiating Gateway', - // actionName: 'replace-with-parallel-event-based-instantiate-gateway', - // className: 'icon-parallel-event-based-instantiate-gateway', - // target: { - // type: 'bpmn:EventBasedGateway' - // }, - // options: { - // businessObject: { instantiate: true, eventGatewayType: 'Parallel' } - // } - // } - ]; + var context = event.context, + shape = context.shape, + participantSnapBox = context.participantSnapBox; + if (!event.snapped && participantSnapBox) { + snapParticipant(participantSnapBox, shape, event); + } + }); - module.exports.TASK = [{ - label: 'Task', - actionName: 'replace-with-task', - className: 'icon-task', - target: { - type: 'bpmn:Task' - } - }, { - label: 'Send Task', - actionName: 'replace-with-send-task', - className: 'icon-send', - target: { - type: 'bpmn:SendTask' - } - }, { - label: 'Receive Task', - actionName: 'replace-with-receive-task', - className: 'icon-receive', - target: { - type: 'bpmn:ReceiveTask' - } - }, { - label: 'User Task', - actionName: 'replace-with-user-task', - className: 'icon-user', - target: { - type: 'bpmn:UserTask' - } - }, { - label: 'Manual Task', - actionName: 'replace-with-manual-task', - className: 'icon-manual', - target: { - type: 'bpmn:ManualTask' - } - }, { - label: 'Business Rule Task', - actionName: 'replace-with-rule-task', - className: 'icon-business-rule', - target: { - type: 'bpmn:BusinessRuleTask' - } - }, { - label: 'Service Task', - actionName: 'replace-with-service-task', - className: 'icon-service', - target: { - type: 'bpmn:ServiceTask' - } - }, { - label: 'Script Task', - actionName: 'replace-with-script-task', - className: 'icon-script', - target: { - type: 'bpmn:ScriptTask' - } - }]; - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\index.js": [function(require, module, exports) { - module.exports = { - __depends__: [ - require('diagram-js/lib/features/popup-menu'), - require('diagram-js/lib/features/replace'), - require('diagram-js/lib/features/selection') - ], - bpmnReplace: ['type', require('./BpmnReplace')] - }; - }, { - "./BpmnReplace": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\replace\\BpmnReplace.js", - "diagram-js/lib/features/popup-menu": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\popup-menu\\index.js", - "diagram-js/lib/features/replace": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\replace\\index.js", - "diagram-js/lib/features/selection": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\selection\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\BpmnSnapping.js": [function(require, module, exports) { - 'use strict'; + eventBus.on('resize.start', 1500, function(event) { + var context = event.context, + shape = context.shape; + + if (is(shape, 'bpmn:SubProcess')) { + context.minDimensions = { + width: 140, + height: 120 + }; + } - var inherits = require('inherits'); + if (is(shape, 'bpmn:Participant')) { + context.minDimensions = { + width: 400, + height: 200 + }; + } - var forEach = require('lodash/collection/forEach'); + if (is(shape, 'bpmn:TextAnnotation')) { + context.minDimensions = { + width: 50, + height: 50 + }; + } + }); - var getBoundingBox = require('diagram-js/lib/util/Elements').getBBox; - var is = require('../modeling/ModelingUtil').is; + } - var Snapping = require('diagram-js/lib/features/snapping/Snapping'), - SnapUtil = require('diagram-js/lib/features/snapping/SnapUtil'); + inherits(BpmnSnapping, Snapping); - var is = require('../../util/ModelUtil').is; + BpmnSnapping.$inject = ['eventBus', 'canvas']; - var mid = SnapUtil.mid, - topLeft = SnapUtil.topLeft, - bottomRight = SnapUtil.bottomRight; + module.exports = BpmnSnapping; - var round = Math.round; + BpmnSnapping.prototype.initSnap = function(event) { - /** - * BPMN specific snapping functionality - * * snap on process elements if a pool is created inside a process diagram - * - * @param {EventBus} - * eventBus - * @param {Canvas} - * canvas - */ - function BpmnSnapping(eventBus, canvas) { + var context = event.context, + shape = context.shape, + shapeMid, + shapeBounds, + shapeTopLeft, + shapeBottomRight, + snapContext; - // instantiate super - Snapping.call(this, eventBus, canvas); + snapContext = Snapping.prototype.initSnap.call(this, event); - /** - * Drop participant on process <> process elements snapping - */ + if (is(shape, 'bpmn:Participant')) { + // assign higher priority for outer snaps on participants + snapContext.setSnapLocations(['top-left', 'bottom-right', 'mid']); + } - function initParticipantSnapping(context, shape, elements) { - if (!elements.length) { - return; - } + if (shape) { - var snapBox = getBoundingBox(elements.filter(function(e) { - return !e.labelTarget && !e.waypoints; - })); + shapeMid = mid(shape, event); - snapBox.x -= 50; - snapBox.y -= 20; - snapBox.width += 70; - snapBox.height += 40; + shapeBounds = { + width: shape.width, + height: shape.height, + x: isNaN(shape.x) ? round(shapeMid.x - shape.width / 2) : shape.x, + y: isNaN(shape.y) ? round(shapeMid.y - shape.height / 2) : shape.y, + }; - // adjust shape height to include bounding box - shape.width = Math.max(shape.width, snapBox.width); - shape.height = Math.max(shape.height, snapBox.height); + shapeTopLeft = topLeft(shapeBounds); + shapeBottomRight = bottomRight(shapeBounds); - context.participantSnapBox = snapBox; - } + snapContext.setSnapOrigin('top-left', { + x: shapeTopLeft.x - event.x, + y: shapeTopLeft.y - event.y + }); - function snapParticipant(snapBox, shape, event) { + snapContext.setSnapOrigin('bottom-right', { + x: shapeBottomRight.x - event.x, + y: shapeBottomRight.y - event.y + }); - var shapeHalfWidth = shape.width / 2 - 30, - shapeHalfHeight = shape.height / 2; - var currentTopLeft = { - x: event.x - shapeHalfWidth - 30, - y: event.y - shapeHalfHeight - }; + forEach(shape.outgoing, function(c) { + var docking = c.waypoints[0]; - var currentBottomRight = { - x: event.x + shapeHalfWidth + 30, - y: event.y + shapeHalfHeight - }; + docking = docking.original || docking; - var snapTopLeft = snapBox, - snapBottomRight = bottomRight(snapBox); + snapContext.setSnapOrigin(c.id + '-docking', { + x: docking.x - event.x, + y: docking.y - event.y + }); + }); - if (currentTopLeft.x >= snapTopLeft.x) { - event.x = snapTopLeft.x + 30 + shapeHalfWidth; - event.snapped = true; - } else - if (currentBottomRight.x <= snapBottomRight.x) { - event.x = snapBottomRight.x - 30 - shapeHalfWidth; - event.snapped = true; - } + forEach(shape.incoming, function(c) { + var docking = c.waypoints[c.waypoints.length - 1]; - if (currentTopLeft.y >= snapTopLeft.y) { - event.y = snapTopLeft.y + shapeHalfHeight; - event.snapped = true; - } else - if (currentBottomRight.y <= snapBottomRight.y) { - event.y = snapBottomRight.y - shapeHalfHeight; - event.snapped = true; - } - } + docking = docking.original || docking; - eventBus.on('create.start', function(event) { + snapContext.setSnapOrigin(c.id + '-docking', { + x: docking.x - event.x, + y: docking.y - event.y + }); + }); - var context = event.context, - shape = context.shape, - rootElement = canvas.getRootElement(); + } - // snap participant around existing elements (if any) - if (is(shape, 'bpmn:Participant') && is(rootElement, 'bpmn:Process')) { + var source = context.source; - initParticipantSnapping(context, shape, rootElement.children); - } - }); + if (source) { + snapContext.addDefaultSnap('mid', mid(source)); + } + }; - eventBus.on(['create.move', 'create.end'], 1500, function(event) { - var context = event.context, - shape = context.shape, - participantSnapBox = context.participantSnapBox; + BpmnSnapping.prototype.addTargetSnaps = function(snapPoints, shape, target) { - if (!event.snapped && participantSnapBox) { - snapParticipant(participantSnapBox, shape, event); - } - }); + var siblings = this.getSiblings(shape, target); - eventBus.on('resize.start', 1500, function(event) { - var context = event.context, - shape = context.shape; - if (is(shape, 'bpmn:SubProcess')) { - context.minDimensions = { - width: 140, - height: 120 - }; - } + forEach(siblings, function(s) { + snapPoints.add('mid', mid(s)); - if (is(shape, 'bpmn:Participant')) { - context.minDimensions = { - width: 400, - height: 200 - }; - } + if (is(s, 'bpmn:Participant')) { + snapPoints.add('top-left', topLeft(s)); + snapPoints.add('bottom-right', bottomRight(s)); + } + }); - if (is(shape, 'bpmn:TextAnnotation')) { - context.minDimensions = { - width: 50, - height: 50 - }; - } - }); + forEach(shape.incoming, function(c) { + + if (siblings.indexOf(c.source) === -1) { + snapPoints.add('mid', mid(c.source)); + var docking = c.waypoints[0]; + snapPoints.add(c.id + '-docking', docking.original || docking); } + }); - inherits(BpmnSnapping, Snapping); - BpmnSnapping.$inject = ['eventBus', 'canvas']; + forEach(shape.outgoing, function(c) { - module.exports = BpmnSnapping; + if (siblings.indexOf(c.target) === -1) { + snapPoints.add('mid', mid(c.target)); + var docking = c.waypoints[c.waypoints.length - 1]; + snapPoints.add(c.id + '-docking', docking.original || docking); + } + }); + + }; + }, { + "../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", + "../modeling/ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", + "diagram-js/lib/features/snapping/SnapUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\snapping\\SnapUtil.js", + "diagram-js/lib/features/snapping/Snapping": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\snapping\\Snapping.js", + "diagram-js/lib/util/Elements": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Elements.js", + "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\index.js": [function(require, module, exports) { + module.exports = { + __init__: ['snapping'], + snapping: ['type', require('./BpmnSnapping')] + }; + }, { + "./BpmnSnapping": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\BpmnSnapping.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnImporter.js": [function(require, module, exports) { + 'use strict'; + + var assign = require('lodash/object/assign'), + map = require('lodash/collection/map'); + + var LabelUtil = require('../util/LabelUtil'); + + var hasExternalLabel = LabelUtil.hasExternalLabel, + getExternalLabelBounds = LabelUtil.getExternalLabelBounds, + isExpanded = require('../util/DiUtil').isExpanded, + elementToString = require('./Util').elementToString; + + + function elementData(semantic, attrs) { + return assign({ + id: semantic.id, + type: semantic.$type, + businessObject: semantic + }, attrs); + } - BpmnSnapping.prototype.initSnap = function(event) { + function collectWaypoints(waypoints) { + return map(waypoints, function(p) { + return { + x: p.x, + y: p.y + }; + }); + } - var context = event.context, - shape = context.shape, - shapeMid, - shapeBounds, - shapeTopLeft, - shapeBottomRight, - snapContext; + /** + * An importer that adds bpmn elements to the canvas + * + * @param {EventBus} + * eventBus + * @param {Canvas} + * canvas + * @param {ElementFactory} + * elementFactory + * @param {ElementRegistry} + * elementRegistry + */ + function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry) { + this._eventBus = eventBus; + this._canvas = canvas; + + this._elementFactory = elementFactory; + this._elementRegistry = elementRegistry; + } - snapContext = Snapping.prototype.initSnap.call(this, event); + BpmnImporter.$inject = ['eventBus', 'canvas', 'elementFactory', 'elementRegistry']; - if (is(shape, 'bpmn:Participant')) { - // assign higher priority for outer snaps on participants - snapContext.setSnapLocations(['top-left', 'bottom-right', 'mid']); - } + module.exports = BpmnImporter; - if (shape) { + /** + * Add bpmn element (semantic) to the canvas onto the specified parent shape. + */ + BpmnImporter.prototype.add = function(semantic, parentElement) { - shapeMid = mid(shape, event); + var di = semantic.di, + element; - shapeBounds = { - width: shape.width, - height: shape.height, - x: isNaN(shape.x) ? round(shapeMid.x - shape.width / 2) : shape.x, - y: isNaN(shape.y) ? round(shapeMid.y - shape.height / 2) : shape.y, - }; + // ROOT ELEMENT + // handle the special case that we deal with a + // invisible root element (process or collaboration) + if (di.$instanceOf('bpmndi:BPMNPlane')) { - shapeTopLeft = topLeft(shapeBounds); - shapeBottomRight = bottomRight(shapeBounds); + // add a virtual element (not being drawn) + element = this._elementFactory.createRoot(elementData(semantic)); - snapContext.setSnapOrigin('top-left', { - x: shapeTopLeft.x - event.x, - y: shapeTopLeft.y - event.y - }); + this._canvas.setRootElement(element); + } - snapContext.setSnapOrigin('bottom-right', { - x: shapeBottomRight.x - event.x, - y: shapeBottomRight.y - event.y - }); + // SHAPE + else if (di.$instanceOf('bpmndi:BPMNShape')) { + var collapsed = !isExpanded(semantic); + var hidden = parentElement && (parentElement.hidden || parentElement.collapsed); - forEach(shape.outgoing, function(c) { - var docking = c.waypoints[0]; + var bounds = semantic.di.bounds; - docking = docking.original || docking; + element = this._elementFactory.createShape(elementData(semantic, { + collapsed: collapsed, + hidden: hidden, + x: Math.round(bounds.x), + y: Math.round(bounds.y), + width: Math.round(bounds.width), + height: Math.round(bounds.height) + })); - snapContext.setSnapOrigin(c.id + '-docking', { - x: docking.x - event.x, - y: docking.y - event.y - }); - }); + this._canvas.addShape(element, parentElement); + } - forEach(shape.incoming, function(c) { - var docking = c.waypoints[c.waypoints.length - 1]; + // CONNECTION + else if (di.$instanceOf('bpmndi:BPMNEdge')) { - docking = docking.original || docking; + var source = this._getSource(semantic), + target = this._getTarget(semantic); - snapContext.setSnapOrigin(c.id + '-docking', { - x: docking.x - event.x, - y: docking.y - event.y - }); - }); + element = this._elementFactory.createConnection(elementData(semantic, { + source: source, + target: target, + waypoints: collectWaypoints(semantic.di.waypoint) + })); - } + this._canvas.addConnection(element, parentElement); + } else { + throw new Error('unknown di ' + elementToString(di) + ' for element ' + elementToString(semantic)); + } - var source = context.source; + // (optional) LABEL + if (hasExternalLabel(semantic)) { + this.addLabel(semantic, element); + } - if (source) { - snapContext.addDefaultSnap('mid', mid(source)); - } - }; + this._eventBus.fire('bpmnElement.added', { + element: element + }); - BpmnSnapping.prototype.addTargetSnaps = function(snapPoints, shape, target) { + return element; + }; - var siblings = this.getSiblings(shape, target); + /** + * add label for an element + */ + BpmnImporter.prototype.addLabel = function(semantic, element) { + var bounds = getExternalLabelBounds(semantic, element); - forEach(siblings, function(s) { - snapPoints.add('mid', mid(s)); + var label = this._elementFactory.createLabel(elementData(semantic, { + id: semantic.id + '_label', + labelTarget: element, + type: 'label', + hidden: element.hidden, + x: Math.round(bounds.x), + y: Math.round(bounds.y), + width: Math.round(bounds.width), + height: Math.round(bounds.height) + })); - if (is(s, 'bpmn:Participant')) { - snapPoints.add('top-left', topLeft(s)); - snapPoints.add('bottom-right', bottomRight(s)); - } - }); + return this._canvas.addShape(label, element.parent); + }; - forEach(shape.incoming, function(c) { + /** + * Return the drawn connection end based on the given side. + * + * @throws {Error} + * if the end is not yet drawn + */ + BpmnImporter.prototype._getEnd = function(semantic, side) { - if (siblings.indexOf(c.source) === -1) { - snapPoints.add('mid', mid(c.source)); + var element, + refSemantic, + type = semantic.$type; - var docking = c.waypoints[0]; - snapPoints.add(c.id + '-docking', docking.original || docking); - } - }); + refSemantic = semantic[side + 'Ref']; + // handle mysterious isMany DataAssociation#sourceRef + if (side === 'source' && type === 'bpmn:DataInputAssociation') { + refSemantic = refSemantic && refSemantic[0]; + } - forEach(shape.outgoing, function(c) { + // fix source / target for DataInputAssociation / DataOutputAssociation + if (side === 'source' && type === 'bpmn:DataOutputAssociation' || + side === 'target' && type === 'bpmn:DataInputAssociation') { - if (siblings.indexOf(c.target) === -1) { - snapPoints.add('mid', mid(c.target)); + refSemantic = semantic.$parent; + } - var docking = c.waypoints[c.waypoints.length - 1]; - snapPoints.add(c.id + '-docking', docking.original || docking); - } - }); + element = refSemantic && this._getElement(refSemantic); - }; - }, { - "../../util/ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js", - "../modeling/ModelingUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\modeling\\ModelingUtil.js", - "diagram-js/lib/features/snapping/SnapUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\snapping\\SnapUtil.js", - "diagram-js/lib/features/snapping/Snapping": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\features\\snapping\\Snapping.js", - "diagram-js/lib/util/Elements": "\\bpmn-js-examples-master\\modeler\\node_modules\\diagram-js\\lib\\util\\Elements.js", - "inherits": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\inherits\\inherits_browser.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\index.js": [function(require, module, exports) { - module.exports = { - __init__: ['snapping'], - snapping: ['type', require('./BpmnSnapping')] - }; - }, { - "./BpmnSnapping": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\features\\snapping\\BpmnSnapping.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnImporter.js": [function(require, module, exports) { - 'use strict'; + if (element) { + return element; + } - var assign = require('lodash/object/assign'), - map = require('lodash/collection/map'); + if (refSemantic) { + throw new Error( + 'element ' + elementToString(refSemantic) + ' referenced by ' + + elementToString(semantic) + '#' + side + 'Ref not yet drawn'); + } else { + throw new Error(elementToString(semantic) + '#' + side + 'Ref not specified'); + } + }; - var LabelUtil = require('../util/LabelUtil'); + BpmnImporter.prototype._getSource = function(semantic) { + return this._getEnd(semantic, 'source'); + }; - var hasExternalLabel = LabelUtil.hasExternalLabel, - getExternalLabelBounds = LabelUtil.getExternalLabelBounds, - isExpanded = require('../util/DiUtil').isExpanded, - elementToString = require('./Util').elementToString; + BpmnImporter.prototype._getTarget = function(semantic) { + return this._getEnd(semantic, 'target'); + }; - function elementData(semantic, attrs) { - return assign({ - id: semantic.id, - type: semantic.$type, - businessObject: semantic - }, attrs); - } + BpmnImporter.prototype._getElement = function(semantic) { + return this._elementRegistry.get(semantic.id); + }; - function collectWaypoints(waypoints) { - return map(waypoints, function(p) { - return { - x: p.x, - y: p.y - }; - }); - } + }, { + "../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", + "../util/LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js", + "./Util": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Util.js", + "lodash/collection/map": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\map.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnTreeWalker.js": [function(require, module, exports) { + 'use strict'; + var filter = require('lodash/collection/filter'), + find = require('lodash/collection/find'), + forEach = require('lodash/collection/forEach'); - /** - * An importer that adds bpmn elements to the canvas - * - * @param {EventBus} - * eventBus - * @param {Canvas} - * canvas - * @param {ElementFactory} - * elementFactory - * @param {ElementRegistry} - * elementRegistry - */ - function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry) { - this._eventBus = eventBus; - this._canvas = canvas; + var Refs = require('object-refs'); - this._elementFactory = elementFactory; - this._elementRegistry = elementRegistry; - } + var elementToString = require('./Util').elementToString; - BpmnImporter.$inject = ['eventBus', 'canvas', 'elementFactory', 'elementRegistry']; + var diRefs = new Refs({ + name: 'bpmnElement', + enumerable: true + }, { + name: 'di' + }); + + /** + * Returns true if an element has the given meta-model type + * + * @param {ModdleElement} + * element + * @param {String} + * type + * + * @return {Boolean} + */ + function is(element, type) { + return element.$instanceOf(type); + } - module.exports = BpmnImporter; + /** + * Find a suitable display candidate for definitions where the DI does not + * correctly specify one. + */ + function findDisplayCandidate(definitions) { + return find(definitions.rootElements, function(e) { + return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration'); + }); + } - /** - * Add bpmn element (semantic) to the canvas onto the specified parent shape. - */ - BpmnImporter.prototype.add = function(semantic, parentElement) { - var di = semantic.di, - element; + function BpmnTreeWalker(handler) { - // ROOT ELEMENT - // handle the special case that we deal with a - // invisible root element (process or collaboration) - if (di.$instanceOf('bpmndi:BPMNPlane')) { + // list of containers already walked + var handledProcesses = []; - // add a virtual element (not being drawn) - element = this._elementFactory.createRoot(elementData(semantic)); + // list of elements to handle deferred to ensure + // prerequisites are drawn + var deferred = []; - this._canvas.setRootElement(element); - } + // /// Helpers ///////////////////////////////// - // SHAPE - else if (di.$instanceOf('bpmndi:BPMNShape')) { + function contextual(fn, ctx) { + return function(e) { + fn(e, ctx); + }; + } - var collapsed = !isExpanded(semantic); - var hidden = parentElement && (parentElement.hidden || parentElement.collapsed); + function visit(element, ctx) { - var bounds = semantic.di.bounds; + var gfx = element.gfx; - element = this._elementFactory.createShape(elementData(semantic, { - collapsed: collapsed, - hidden: hidden, - x: Math.round(bounds.x), - y: Math.round(bounds.y), - width: Math.round(bounds.width), - height: Math.round(bounds.height) - })); + // avoid multiple rendering of elements + if (gfx) { + throw new Error('already rendered ' + elementToString(element)); + } - this._canvas.addShape(element, parentElement); - } + // call handler + return handler.element(element, ctx); + } - // CONNECTION - else if (di.$instanceOf('bpmndi:BPMNEdge')) { + function visitRoot(element, diagram) { + return handler.root(element, diagram); + } - var source = this._getSource(semantic), - target = this._getTarget(semantic); + function visitIfDi(element, ctx) { + try { + return element.di && visit(element, ctx); + } catch (e) { + logError(e.message, { + element: element, + error: e + }); - element = this._elementFactory.createConnection(elementData(semantic, { - source: source, - target: target, - waypoints: collectWaypoints(semantic.di.waypoint) - })); + console.error('failed to import ' + elementToString(element)); + console.error(e); + } + } - this._canvas.addConnection(element, parentElement); - } else { - throw new Error('unknown di ' + elementToString(di) + ' for element ' + elementToString(semantic)); - } + function logError(message, context) { + handler.error(message, context); + } - // (optional) LABEL - if (hasExternalLabel(semantic)) { - this.addLabel(semantic, element); - } + // //// DI handling //////////////////////////// + function registerDi(di) { + var bpmnElement = di.bpmnElement; - this._eventBus.fire('bpmnElement.added', { - element: element + if (bpmnElement) { + if (bpmnElement.di) { + logError('multiple DI elements defined for ' + elementToString(bpmnElement), { + element: bpmnElement }); + } else { + diRefs.bind(bpmnElement, 'di'); + bpmnElement.di = di; + } + } else { + logError('no bpmnElement referenced in ' + elementToString(di), { + element: di + }); + } + } - return element; - }; + function handleDiagram(diagram) { + handlePlane(diagram.plane); + } + function handlePlane(plane) { + registerDi(plane); - /** - * add label for an element - */ - BpmnImporter.prototype.addLabel = function(semantic, element) { - var bounds = getExternalLabelBounds(semantic, element); - - var label = this._elementFactory.createLabel(elementData(semantic, { - id: semantic.id + '_label', - labelTarget: element, - type: 'label', - hidden: element.hidden, - x: Math.round(bounds.x), - y: Math.round(bounds.y), - width: Math.round(bounds.width), - height: Math.round(bounds.height) - })); + forEach(plane.planeElement, handlePlaneElement); + } - return this._canvas.addShape(label, element.parent); - }; + function handlePlaneElement(planeElement) { + registerDi(planeElement); + } - /** - * Return the drawn connection end based on the given side. - * - * @throws {Error} - * if the end is not yet drawn - */ - BpmnImporter.prototype._getEnd = function(semantic, side) { - var element, - refSemantic, - type = semantic.$type; + // //// Semantic handling ////////////////////// - refSemantic = semantic[side + 'Ref']; + function handleDefinitions(definitions, diagram) { + // make sure we walk the correct bpmnElement - // handle mysterious isMany DataAssociation#sourceRef - if (side === 'source' && type === 'bpmn:DataInputAssociation') { - refSemantic = refSemantic && refSemantic[0]; - } + var diagrams = definitions.diagrams; - // fix source / target for DataInputAssociation / DataOutputAssociation - if (side === 'source' && type === 'bpmn:DataOutputAssociation' || - side === 'target' && type === 'bpmn:DataInputAssociation') { + if (diagram && diagrams.indexOf(diagram) === -1) { + throw new Error('diagram not part of bpmn:Definitions'); + } - refSemantic = semantic.$parent; - } + if (!diagram && diagrams && diagrams.length) { + diagram = diagrams[0]; + } - element = refSemantic && this._getElement(refSemantic); + // no diagram -> nothing to import + if (!diagram) { + return; + } - if (element) { - return element; - } + // load DI from selected diagram only + handleDiagram(diagram); - if (refSemantic) { - throw new Error( - 'element ' + elementToString(refSemantic) + ' referenced by ' + - elementToString(semantic) + '#' + side + 'Ref not yet drawn'); - } else { - throw new Error(elementToString(semantic) + '#' + side + 'Ref not specified'); - } - }; - BpmnImporter.prototype._getSource = function(semantic) { - return this._getEnd(semantic, 'source'); - }; + var plane = diagram.plane; - BpmnImporter.prototype._getTarget = function(semantic) { - return this._getEnd(semantic, 'target'); - }; + if (!plane) { + throw new Error('no plane for ' + elementToString(diagram)); + } - BpmnImporter.prototype._getElement = function(semantic) { - return this._elementRegistry.get(semantic.id); - }; + var rootElement = plane.bpmnElement; - }, { - "../util/DiUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js", - "../util/LabelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js", - "./Util": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Util.js", - "lodash/collection/map": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\map.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnTreeWalker.js": [function(require, module, exports) { - 'use strict'; + // ensure we default to a suitable display candidate (process or + // collaboration), + // even if non is specified in DI + if (!rootElement) { + rootElement = findDisplayCandidate(definitions); - var filter = require('lodash/collection/filter'), - find = require('lodash/collection/find'), - forEach = require('lodash/collection/forEach'); + if (!rootElement) { + return logError('no process or collaboration present to display'); + } else { - var Refs = require('object-refs'); + logError('correcting missing bpmnElement on ' + elementToString(plane) + ' to ' + elementToString(rootElement)); - var elementToString = require('./Util').elementToString; + // correct DI on the fly + plane.bpmnElement = rootElement; + registerDi(plane); + } + } - var diRefs = new Refs({ - name: 'bpmnElement', - enumerable: true - }, { - name: 'di' - }); - /** - * Returns true if an element has the given meta-model type - * - * @param {ModdleElement} - * element - * @param {String} - * type - * - * @return {Boolean} - */ - function is(element, type) { - return element.$instanceOf(type); - } + var ctx = visitRoot(rootElement, plane); + if (is(rootElement, 'bpmn:Process')) { + handleProcess(rootElement, ctx); + } else if (is(rootElement, 'bpmn:Collaboration')) { + handleCollaboration(rootElement, ctx); - /** - * Find a suitable display candidate for definitions where the DI does not - * correctly specify one. - */ - function findDisplayCandidate(definitions) { - return find(definitions.rootElements, function(e) { - return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration'); - }); + // force drawing of everything not yet drawn that is part of the target + // DI + handleUnhandledProcesses(definitions.rootElements, ctx); + } else { + throw new Error('unsupported bpmnElement for ' + elementToString(plane) + ' : ' + elementToString(rootElement)); } + // handle all deferred elements + handleDeferred(deferred); + } - function BpmnTreeWalker(handler) { + function handleDeferred(deferred) { + forEach(deferred, function(d) { + d(); + }); + } - // list of containers already walked - var handledProcesses = []; + function handleProcess(process, context) { + handleFlowElementsContainer(process, context); + handleIoSpecification(process.ioSpecification, context); - // list of elements to handle deferred to ensure - // prerequisites are drawn - var deferred = []; + handleArtifacts(process.artifacts, context); - // /// Helpers ///////////////////////////////// + // log process handled + handledProcesses.push(process); + } - function contextual(fn, ctx) { - return function(e) { - fn(e, ctx); - }; - } + function handleUnhandledProcesses(rootElements) { - function visit(element, ctx) { + // walk through all processes that have not yet been drawn and draw them + // if they contain lanes with DI information. + // we do this to pass the free-floating lane test cases in the MIWG test + // suite + var processes = filter(rootElements, function(e) { + return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1; + }); - var gfx = element.gfx; + processes.forEach(contextual(handleProcess)); + } - // avoid multiple rendering of elements - if (gfx) { - throw new Error('already rendered ' + elementToString(element)); - } + function handleMessageFlow(messageFlow, context) { + visitIfDi(messageFlow, context); + } - // call handler - return handler.element(element, ctx); - } + function handleMessageFlows(messageFlows, context) { + forEach(messageFlows, contextual(handleMessageFlow, context)); + } - function visitRoot(element, diagram) { - return handler.root(element, diagram); - } + function handleDataAssociation(association, context) { + visitIfDi(association, context); + } - function visitIfDi(element, ctx) { - try { - return element.di && visit(element, ctx); - } catch (e) { - logError(e.message, { - element: element, - error: e - }); + function handleDataInput(dataInput, context) { + visitIfDi(dataInput, context); + } - console.error('failed to import ' + elementToString(element)); - console.error(e); - } - } + function handleDataOutput(dataOutput, context) { + visitIfDi(dataOutput, context); + } - function logError(message, context) { - handler.error(message, context); - } + function handleArtifact(artifact, context) { - // //// DI handling //////////////////////////// + // bpmn:TextAnnotation + // bpmn:Group + // bpmn:Association - function registerDi(di) { - var bpmnElement = di.bpmnElement; + visitIfDi(artifact, context); + } - if (bpmnElement) { - if (bpmnElement.di) { - logError('multiple DI elements defined for ' + elementToString(bpmnElement), { - element: bpmnElement - }); - } else { - diRefs.bind(bpmnElement, 'di'); - bpmnElement.di = di; - } - } else { - logError('no bpmnElement referenced in ' + elementToString(di), { - element: di - }); - } - } + function handleArtifacts(artifacts, context) { - function handleDiagram(diagram) { - handlePlane(diagram.plane); - } + forEach(artifacts, function(e) { + if (is(e, 'bpmn:Association')) { + deferred.push(function() { + handleArtifact(e, context); + }); + } else { + handleArtifact(e, context); + } + }); + } - function handlePlane(plane) { - registerDi(plane); + function handleIoSpecification(ioSpecification, context) { - forEach(plane.planeElement, handlePlaneElement); - } + if (!ioSpecification) { + return; + } - function handlePlaneElement(planeElement) { - registerDi(planeElement); - } + forEach(ioSpecification.dataInputs, contextual(handleDataInput, context)); + forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context)); + } + function handleSubProcess(subProcess, context) { + handleFlowElementsContainer(subProcess, context); + handleArtifacts(subProcess.artifacts, context); + } - // //// Semantic handling ////////////////////// + function handleFlowNode(flowNode, context) { + var childCtx = visitIfDi(flowNode, context); - function handleDefinitions(definitions, diagram) { - // make sure we walk the correct bpmnElement + if (is(flowNode, 'bpmn:SubProcess')) { + handleSubProcess(flowNode, childCtx || context); + } + } - var diagrams = definitions.diagrams; + function handleSequenceFlow(sequenceFlow, context) { + visitIfDi(sequenceFlow, context); + } - if (diagram && diagrams.indexOf(diagram) === -1) { - throw new Error('diagram not part of bpmn:Definitions'); - } + function handleDataElement(dataObject, context) { + visitIfDi(dataObject, context); + } - if (!diagram && diagrams && diagrams.length) { - diagram = diagrams[0]; - } + function handleBoundaryEvent(dataObject, context) { + visitIfDi(dataObject, context); + } - // no diagram -> nothing to import - if (!diagram) { - return; - } + function handleLane(lane, context) { + var newContext = visitIfDi(lane, context); - // load DI from selected diagram only - handleDiagram(diagram); + if (lane.childLaneSet) { + handleLaneSet(lane.childLaneSet, newContext || context); + } else { + var filterList = filter(lane.flowNodeRef, function(e) { + return e.$type !== 'bpmn:BoundaryEvent'; + }); + handleFlowElements(filterList, newContext || context); + } + } + function handleLaneSet(laneSet, context) { + forEach(laneSet.lanes, contextual(handleLane, context)); + } - var plane = diagram.plane; + function handleLaneSets(laneSets, context) { + forEach(laneSets, contextual(handleLaneSet, context)); + } - if (!plane) { - throw new Error('no plane for ' + elementToString(diagram)); - } + function handleFlowElementsContainer(container, context) { + if (container.laneSets) { + handleLaneSets(container.laneSets, context); + handleNonFlowNodes(container.flowElements); + } else { + handleFlowElements(container.flowElements, context); + } + } - var rootElement = plane.bpmnElement; + function handleNonFlowNodes(flowElements, context) { + forEach(flowElements, function(e) { + if (is(e, 'bpmn:SequenceFlow')) { + deferred.push(function() { + handleSequenceFlow(e, context); + }); + } else if (is(e, 'bpmn:BoundaryEvent')) { + deferred.unshift(function() { + handleBoundaryEvent(e, context); + }); + } else if (is(e, 'bpmn:DataObject')) { + // SKIP (assume correct referencing via DataObjectReference) + } else if (is(e, 'bpmn:DataStoreReference')) { + handleDataElement(e, context); + } else if (is(e, 'bpmn:DataObjectReference')) { + handleDataElement(e, context); + } + }); + } - // ensure we default to a suitable display candidate (process or - // collaboration), - // even if non is specified in DI - if (!rootElement) { - rootElement = findDisplayCandidate(definitions); + function handleFlowElements(flowElements, context) { + forEach(flowElements, function(e) { + if (is(e, 'bpmn:SequenceFlow')) { + deferred.push(function() { + handleSequenceFlow(e, context); + }); + } else if (is(e, 'bpmn:BoundaryEvent')) { + deferred.unshift(function() { + handleBoundaryEvent(e, context); + }); + } else if (is(e, 'bpmn:FlowNode')) { + handleFlowNode(e, context); - if (!rootElement) { - return logError('no process or collaboration present to display'); - } else { + if (is(e, 'bpmn:Activity')) { - logError('correcting missing bpmnElement on ' + elementToString(plane) + ' to ' + elementToString(rootElement)); + handleIoSpecification(e.ioSpecification, context); - // correct DI on the fly - plane.bpmnElement = rootElement; - registerDi(plane); - } - } + // defer handling of associations + deferred.push(function() { + forEach(e.dataInputAssociations, contextual(handleDataAssociation, context)); + forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context)); + }); + } + } else if (is(e, 'bpmn:DataObject')) { + // SKIP (assume correct referencing via DataObjectReference) + } else if (is(e, 'bpmn:DataStoreReference')) { + handleDataElement(e, context); + } else if (is(e, 'bpmn:DataObjectReference')) { + handleDataElement(e, context); + } else { + logError( + 'unrecognized flowElement ' + elementToString(e) + ' in context ' + + (context ? elementToString(context.businessObject) : null), { + element: e, + context: context + }); + } + }); + } + function handleParticipant(participant, context) { + var newCtx = visitIfDi(participant, context); - var ctx = visitRoot(rootElement, plane); + var process = participant.processRef; + if (process) { + handleProcess(process, newCtx || context); + } + } - if (is(rootElement, 'bpmn:Process')) { - handleProcess(rootElement, ctx); - } else if (is(rootElement, 'bpmn:Collaboration')) { - handleCollaboration(rootElement, ctx); + function handleCollaboration(collaboration) { - // force drawing of everything not yet drawn that is part of the target - // DI - handleUnhandledProcesses(definitions.rootElements, ctx); - } else { - throw new Error('unsupported bpmnElement for ' + elementToString(plane) + ' : ' + elementToString(rootElement)); - } + forEach(collaboration.participants, contextual(handleParticipant)); - // handle all deferred elements - handleDeferred(deferred); - } + handleArtifacts(collaboration.artifacts); - function handleDeferred(deferred) { - forEach(deferred, function(d) { - d(); - }); - } + // handle message flows latest in the process + deferred.push(function() { + handleMessageFlows(collaboration.messageFlows); + }); + } - function handleProcess(process, context) { - handleFlowElementsContainer(process, context); - handleIoSpecification(process.ioSpecification, context); - handleArtifacts(process.artifacts, context); + // /// API //////////////////////////////// - // log process handled - handledProcesses.push(process); - } + return { + handleDefinitions: handleDefinitions + }; + } - function handleUnhandledProcesses(rootElements) { + module.exports = BpmnTreeWalker; + }, { + "./Util": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Util.js", + "lodash/collection/filter": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\filter.js", + "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "object-refs": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\object-refs\\index.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Importer.js": [function(require, module, exports) { + 'use strict'; + + var BpmnTreeWalker = require('./BpmnTreeWalker'); + + + /** + * Import the definitions into a diagram. + * + * Errors and warnings are reported through the specified callback. + * + * @param {Diagram} + * diagram + * @param {ModdleElement} + * definitions + * @param {Function} + * done the callback, invoked with (err, [ warning ]) once the import + * is done + */ + function importBpmnDiagram(diagram, definitions, done) { + + var importer = diagram.get('bpmnImporter'), + eventBus = diagram.get('eventBus'); + + var error, + warnings = []; + + function parse(definitions) { + + var visitor = { + + root: function(element) { + return importer.add(element); + }, + + element: function(element, parentShape) { + return importer.add(element, parentShape); + }, + + error: function(message, context) { + warnings.push({ + message: message, + context: context + }); + } + }; - // walk through all processes that have not yet been drawn and draw them - // if they contain lanes with DI information. - // we do this to pass the free-floating lane test cases in the MIWG test - // suite - var processes = filter(rootElements, function(e) { - return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1; - }); + var walker = new BpmnTreeWalker(visitor); - processes.forEach(contextual(handleProcess)); - } + // import + walker.handleDefinitions(definitions); + } - function handleMessageFlow(messageFlow, context) { - visitIfDi(messageFlow, context); - } + eventBus.fire('import.start'); - function handleMessageFlows(messageFlows, context) { - forEach(messageFlows, contextual(handleMessageFlow, context)); - } + try { + parse(definitions); + } catch (e) { + error = e; + } - function handleDataAssociation(association, context) { - visitIfDi(association, context); - } + eventBus.fire(error ? 'import.error' : 'import.success', { + error: error, + warnings: warnings + }); + done(error, warnings); + } - function handleDataInput(dataInput, context) { - visitIfDi(dataInput, context); - } + module.exports.importBpmnDiagram = importBpmnDiagram; + }, { + "./BpmnTreeWalker": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnTreeWalker.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Util.js": [function(require, module, exports) { + 'use strict'; - function handleDataOutput(dataOutput, context) { - visitIfDi(dataOutput, context); - } + module.exports.elementToString = function(e) { + if (!e) { + return ''; + } - function handleArtifact(artifact, context) { + return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />'; + }; + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\index.js": [function(require, module, exports) { + module.exports = { + bpmnImporter: ['type', require('./BpmnImporter')] + }; + }, { + "./BpmnImporter": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnImporter.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js": [function(require, module, exports) { + 'use strict'; + + var is = require('./ModelUtil').is, + getBusinessObject = require('./ModelUtil').getBusinessObject; + + module.exports.isExpanded = function(element) { + + if (is(element, 'bpmn:CallActivity')) { + return false; + } - // bpmn:TextAnnotation - // bpmn:Group - // bpmn:Association + if (is(element, 'bpmn:SubProcess')) { + return getBusinessObject(element).di.isExpanded; + } - visitIfDi(artifact, context); - } + if (is(element, 'bpmn:Participant')) { + return !!getBusinessObject(element).processRef; + } - function handleArtifacts(artifacts, context) { + return true; + }; - forEach(artifacts, function(e) { - if (is(e, 'bpmn:Association')) { - deferred.push(function() { - handleArtifact(e, context); - }); - } else { - handleArtifact(e, context); - } - }); - } + }, { + "./ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js": [function(require, module, exports) { + 'use strict'; - function handleIoSpecification(ioSpecification, context) { + var assign = require('lodash/object/assign'); - if (!ioSpecification) { - return; - } - forEach(ioSpecification.dataInputs, contextual(handleDataInput, context)); - forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context)); - } + var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = { + width: 90, + height: 20 + }; - function handleSubProcess(subProcess, context) { - handleFlowElementsContainer(subProcess, context); - handleArtifacts(subProcess.artifacts, context); - } - function handleFlowNode(flowNode, context) { - var childCtx = visitIfDi(flowNode, context); + /** + * Returns true if the given semantic has an external label + * + * @param {BpmnElement} + * semantic + * @return {Boolean} true if has label + */ + module.exports.hasExternalLabel = function(semantic) { - if (is(flowNode, 'bpmn:SubProcess')) { - handleSubProcess(flowNode, childCtx || context); - } - } + return semantic.$instanceOf('bpmn:Event') || + // semantic.$instanceOf('bpmn:Gateway') || + semantic.$instanceOf('bpmn:DataStoreReference') || + semantic.$instanceOf('bpmn:DataObjectReference') || + semantic.$instanceOf('bpmn:SequenceFlow') || + semantic.$instanceOf('bpmn:MessageFlow'); + }; - function handleSequenceFlow(sequenceFlow, context) { - visitIfDi(sequenceFlow, context); - } - function handleDataElement(dataObject, context) { - visitIfDi(dataObject, context); - } + /** + * Get the middle of a number of waypoints + * + * @param {Array + * } waypoints + * @return {Point} the mid point + */ + var getWaypointsMid = module.exports.getWaypointsMid = function(waypoints) { - function handleBoundaryEvent(dataObject, context) { - visitIfDi(dataObject, context); - } + var mid = waypoints.length / 2 - 1; - function handleLane(lane, context) { - var newContext = visitIfDi(lane, context); + var first = waypoints[Math.floor(mid)]; + var second = waypoints[Math.ceil(mid + 0.01)]; - if (lane.childLaneSet) { - handleLaneSet(lane.childLaneSet, newContext || context); - } else { - var filterList = filter(lane.flowNodeRef, function(e) { - return e.$type !== 'bpmn:BoundaryEvent'; - }); - handleFlowElements(filterList, newContext || context); - } - } + return { + x: first.x + (second.x - first.x) / 2, + y: first.y + (second.y - first.y) / 2 + }; + }; - function handleLaneSet(laneSet, context) { - forEach(laneSet.lanes, contextual(handleLane, context)); - } - function handleLaneSets(laneSets, context) { - forEach(laneSets, contextual(handleLaneSet, context)); - } + var getExternalLabelMid = module.exports.getExternalLabelMid = function(element) { - function handleFlowElementsContainer(container, context) { + if (element.waypoints) { + return getWaypointsMid(element.waypoints); + } else { + return { + x: element.x + element.width / 2, + y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2 + }; + } + }; - if (container.laneSets) { - handleLaneSets(container.laneSets, context); - handleNonFlowNodes(container.flowElements); - } else { - handleFlowElements(container.flowElements, context); - } - } + /** + * Returns the bounds of an elements label, parsed from the elements DI or + * generated from its bounds. + * + * @param {BpmnElement} + * semantic + * @param {djs.model.Base} + * element + */ + module.exports.getExternalLabelBounds = function(semantic, element) { - function handleNonFlowNodes(flowElements, context) { - forEach(flowElements, function(e) { - if (is(e, 'bpmn:SequenceFlow')) { - deferred.push(function() { - handleSequenceFlow(e, context); - }); - } else if (is(e, 'bpmn:BoundaryEvent')) { - deferred.unshift(function() { - handleBoundaryEvent(e, context); - }); - } else if (is(e, 'bpmn:DataObject')) { - // SKIP (assume correct referencing via DataObjectReference) - } else if (is(e, 'bpmn:DataStoreReference')) { - handleDataElement(e, context); - } else if (is(e, 'bpmn:DataObjectReference')) { - handleDataElement(e, context); - } - }); - } + var mid, + size, + bounds, + di = semantic.di, + label = di.label; - function handleFlowElements(flowElements, context) { - forEach(flowElements, function(e) { - if (is(e, 'bpmn:SequenceFlow')) { - deferred.push(function() { - handleSequenceFlow(e, context); - }); - } else if (is(e, 'bpmn:BoundaryEvent')) { - deferred.unshift(function() { - handleBoundaryEvent(e, context); - }); - } else if (is(e, 'bpmn:FlowNode')) { - handleFlowNode(e, context); - - if (is(e, 'bpmn:Activity')) { - - handleIoSpecification(e.ioSpecification, context); - - // defer handling of associations - deferred.push(function() { - forEach(e.dataInputAssociations, contextual(handleDataAssociation, context)); - forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context)); - }); - } - } else if (is(e, 'bpmn:DataObject')) { - // SKIP (assume correct referencing via DataObjectReference) - } else if (is(e, 'bpmn:DataStoreReference')) { - handleDataElement(e, context); - } else if (is(e, 'bpmn:DataObjectReference')) { - handleDataElement(e, context); - } else { - logError( - 'unrecognized flowElement ' + elementToString(e) + ' in context ' + - (context ? elementToString(context.businessObject) : null), { - element: e, - context: context - }); - } - }); - } + if (label && label.bounds) { + bounds = label.bounds; - function handleParticipant(participant, context) { - var newCtx = visitIfDi(participant, context); + size = { + width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width), + height: bounds.height + }; - var process = participant.processRef; - if (process) { - handleProcess(process, newCtx || context); - } - } + mid = { + x: bounds.x + bounds.width / 2, + y: bounds.y + bounds.height / 2 + }; + } else { - function handleCollaboration(collaboration) { + mid = getExternalLabelMid(element); - forEach(collaboration.participants, contextual(handleParticipant)); + size = DEFAULT_LABEL_SIZE; + } - handleArtifacts(collaboration.artifacts); + return assign({ + x: mid.x - size.width / 2, + y: mid.y - size.height / 2 + }, size); + }; + }, { + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js": [function(require, module, exports) { + 'use strict'; + + /** + * Is an element of the given BPMN type? + * + * @param {djs.model.Base|ModdleElement} + * element + * @param {String} + * type + * + * @return {Boolean} + */ + function is(element, type) { + var bo = getBusinessObject(element); + + return bo && bo.$instanceOf(type); + } - // handle message flows latest in the process - deferred.push(function() { - handleMessageFlows(collaboration.messageFlows); - }); - } + module.exports.is = is; - // /// API //////////////////////////////// + /** + * Return the business object for a given element. + * + * @param {djs.model.Base|ModdleElement} + * element + * + * @return {ModdleElement} + */ + function getBusinessObject(element) { + return (element && element.businessObject) || element; + } - return { - handleDefinitions: handleDefinitions - }; - } + module.exports.getBusinessObject = getBusinessObject; + + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\index.js": [function(require, module, exports) { + module.exports = require('./lib/simple'); + }, { + "./lib/simple": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\simple.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\bpmn-moddle.js": [function(require, module, exports) { + 'use strict'; + + var isString = require('lodash/lang/isString'), + isFunction = require('lodash/lang/isFunction'), + assign = require('lodash/object/assign'); + + var Moddle = require('moddle'), + XmlReader = require('moddle-xml/lib/reader'), + XmlWriter = require('moddle-xml/lib/writer'); + + /** + * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 + * xml files. + * + * @class BpmnModdle + * @extends Moddle + * + * @param {Object|Array} + * packages to use for instantiating the model + * @param {Object} + * [options] additional options to pass over + */ + function BpmnModdle(packages, options) { + Moddle.call(this, packages, options); + } - module.exports = BpmnTreeWalker; - }, { - "./Util": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Util.js", - "lodash/collection/filter": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\filter.js", - "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", - "object-refs": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\object-refs\\index.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Importer.js": [function(require, module, exports) { - 'use strict'; + BpmnModdle.prototype = Object.create(Moddle.prototype); + + module.exports = BpmnModdle; + + + /** + * Instantiates a BPMN model tree from a given xml string. + * + * @param {String} + * xmlStr + * @param {String} + * [typeName='bpmn:Definitions'] name of the root element + * @param {Object} + * [options] options to pass to the underlying reader + * @param {Function} + * done callback that is invoked with (err, result, parseContext) + * once the import completes + */ + BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) { + + if (!isString(typeName)) { + done = options; + options = typeName; + typeName = 'bpmn:Definitions'; + } - var BpmnTreeWalker = require('./BpmnTreeWalker'); + if (isFunction(options)) { + done = options; + options = {}; + } + var reader = new XmlReader(assign({ + model: this, + lax: true + }, options)); + var rootHandler = reader.handler(typeName); - /** - * Import the definitions into a diagram. - * - * Errors and warnings are reported through the specified callback. - * - * @param {Diagram} - * diagram - * @param {ModdleElement} - * definitions - * @param {Function} - * done the callback, invoked with (err, [ warning ]) once the import - * is done - */ - function importBpmnDiagram(diagram, definitions, done) { + reader.fromXML(xmlStr, rootHandler, done); + }; - var importer = diagram.get('bpmnImporter'), - eventBus = diagram.get('eventBus'); - var error, - warnings = []; + /** + * Serializes a BPMN 2.0 object tree to XML. + * + * @param {String} + * element the root element, typically an instance of + * `bpmn:Definitions` + * @param {Object} + * [options] to pass to the underlying writer + * @param {Function} + * done callback invoked with (err, xmlStr) once the import completes + */ - function parse(definitions) { - var visitor = { - root: function(element) { - return importer.add(element); - }, - element: function(element, parentShape) { - return importer.add(element, parentShape); - }, + BpmnModdle.prototype.toXML = function(element, options, done) { - error: function(message, context) { - warnings.push({ - message: message, - context: context - }); - } - }; + if (isFunction(options)) { + done = options; + options = {}; + } - var walker = new BpmnTreeWalker(visitor); + var writer = new XmlWriter(options); + try { + var result = writer.toXML(element); + modelXML = result; + list_models[selected_model] = result; + done(null, result); + } catch (e) { + done(e); + } + }; + + }, { + "lodash/lang/isFunction": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isFunction.js", + "lodash/lang/isString": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isString.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", + "moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\index.js", + "moddle-xml/lib/reader": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\reader.js", + "moddle-xml/lib/writer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\writer.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\id-support.js": [function(require, module, exports) { + 'use strict'; + + var ID_PATTERN = /^(.*:)?id$/; + + /** + * Extends the bpmn instance with id support. + * + * @example + * + * var moddle, ids; + * + * require('id-support').extend(moddle, ids); + * + * moddle.ids.next(); // create a next id moddle.ids; // ids instance + * // claims id as used moddle.create('foo:Bar', { id: 'fooobar1' }); + * + * + * @param {Moddle} + * model + * @param {Ids} + * ids + * + * @return {Moddle} the extended moddle instance + */ + module.exports.extend = function(model, ids) { + + var set = model.properties.set; + + // do not reinitialize setter + // unless it is already initialized + if (!model.ids) { + + model.properties.set = function(target, property, value) { + + // ensure we log used ids once they are assigned + // to model elements + if (ID_PATTERN.test(property)) { + + var assigned = model.ids.assigned(value); + if (assigned && assigned !== target) { + throw new Error('id <' + value + '> already used'); + } + + model.ids.claim(value, target); + } - // import - walker.handleDefinitions(definitions); - } + set.call(this, target, property, value); + }; + } - eventBus.fire('import.start'); + model.ids = ids; + + return model; + }; + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\simple.js": [function(require, module, exports) { + 'use strict'; + + var assign = require('lodash/object/assign'); + + var BpmnModdle = require('./bpmn-moddle'); + + var packages = { + bpmn: require('../resources/bpmn/json/bpmn.json'), + bpmndi: require('../resources/bpmn/json/bpmndi.json'), + dc: require('../resources/bpmn/json/dc.json'), + di: require('../resources/bpmn/json/di.json') + }; + + module.exports = function(additionalPackages, options) { + return new BpmnModdle(assign({}, packages, additionalPackages), options); + }; + }, { + "../resources/bpmn/json/bpmn.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\bpmn.json", + "../resources/bpmn/json/bpmndi.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\bpmndi.json", + "../resources/bpmn/json/dc.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\dc.json", + "../resources/bpmn/json/di.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\di.json", + "./bpmn-moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\bpmn-moddle.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\common.js": [function(require, module, exports) { + 'use strict'; + + function capitalize(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } - try { - parse(definitions); - } catch (e) { - error = e; - } + function lower(string) { + return string.charAt(0).toLowerCase() + string.slice(1); + } - eventBus.fire(error ? 'import.error' : 'import.success', { - error: error, - warnings: warnings - }); - done(error, warnings); - } + function hasLowerCaseAlias(pkg) { + return pkg.xml && pkg.xml.tagAlias === 'lowerCase'; + } - module.exports.importBpmnDiagram = importBpmnDiagram; - }, { - "./BpmnTreeWalker": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnTreeWalker.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\Util.js": [function(require, module, exports) { - 'use strict'; - module.exports.elementToString = function(e) { - if (!e) { - return ''; - } + module.exports.aliasToName = function(alias, pkg) { + if (hasLowerCaseAlias(pkg)) { + return capitalize(alias); + } else { + return alias; + } + }; - return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />'; - }; - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\index.js": [function(require, module, exports) { - module.exports = { - bpmnImporter: ['type', require('./BpmnImporter')] - }; - }, { - "./BpmnImporter": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\import\\BpmnImporter.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\DiUtil.js": [function(require, module, exports) { - 'use strict'; + module.exports.nameToAlias = function(name, pkg) { + if (hasLowerCaseAlias(pkg)) { + return lower(name); + } else { + return name; + } + }; + + module.exports.DEFAULT_NS_MAP = { + 'xsi': 'http://www.w3.org/2001/XMLSchema-instance' + }; + + module.exports.XSI_TYPE = 'xsi:type'; + }, {}], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\reader.js": [function(require, module, exports) { + 'use strict'; + + var reduce = require('lodash/collection/reduce'), + forEach = require('lodash/collection/forEach'), + find = require('lodash/collection/find'), + assign = require('lodash/object/assign'), + defer = require('lodash/function/defer'); + + var Stack = require('tiny-stack'), + SaxParser = require('sax').parser, + Moddle = require('moddle'), + parseNameNs = require('moddle/lib/ns').parseName, + Types = require('moddle/lib/types'), + coerceType = Types.coerceType, + isSimpleType = Types.isSimple, + common = require('./common'), + XSI_TYPE = common.XSI_TYPE, + XSI_URI = common.DEFAULT_NS_MAP.xsi, + aliasToName = common.aliasToName; + + function parseNodeAttributes(node) { + var nodeAttrs = node.attributes; + + return reduce(nodeAttrs, function(result, v, k) { + var name, ns; + + if (!v.local) { + name = v.prefix; + } else { + ns = parseNameNs(v.name, v.prefix); + name = ns.name; + } - var is = require('./ModelUtil').is, - getBusinessObject = require('./ModelUtil').getBusinessObject; + result[name] = v.value; + return result; + }, {}); + } - module.exports.isExpanded = function(element) { + function normalizeType(node, attr, model) { + var nameNs = parseNameNs(attr.value); - if (is(element, 'bpmn:CallActivity')) { - return false; - } + var uri = node.ns[nameNs.prefix || ''], + localName = nameNs.localName, + pkg = uri && model.getPackage(uri), + typePrefix; - if (is(element, 'bpmn:SubProcess')) { - return getBusinessObject(element).di.isExpanded; - } + if (pkg) { + typePrefix = pkg.xml && pkg.xml.typePrefix; - if (is(element, 'bpmn:Participant')) { - return !!getBusinessObject(element).processRef; - } + if (typePrefix && localName.indexOf(typePrefix) === 0) { + localName = localName.slice(typePrefix.length); + } - return true; - }; + attr.value = pkg.prefix + ':' + localName; + } + } - }, { - "./ModelUtil": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\LabelUtil.js": [function(require, module, exports) { - 'use strict'; + /** + * Normalizes namespaces for a node given an optional default namespace and a + * number of mappings from uris to default prefixes. + * + * @param {XmlNode} + * node + * @param {Model} + * model the model containing all registered namespaces + * @param {Uri} + * defaultNsUri + */ + function normalizeNamespaces(node, model, defaultNsUri) { + var uri, prefix; + + uri = node.uri || defaultNsUri; + + if (uri) { + var pkg = model.getPackage(uri); + + if (pkg) { + prefix = pkg.prefix; + } else { + prefix = node.prefix; + } - var assign = require('lodash/object/assign'); + node.prefix = prefix; + node.uri = uri; + } + forEach(node.attributes, function(attr) { - var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = { - width: 90, - height: 20 - }; + // normalize xsi:type attributes because the + // assigned type may or may not be namespace prefixed + if (attr.uri === XSI_URI && attr.local === 'type') { + normalizeType(node, attr, model); + } + normalizeNamespaces(attr, model, null); + }); + } - /** - * Returns true if the given semantic has an external label - * - * @param {BpmnElement} - * semantic - * @return {Boolean} true if has label - */ - module.exports.hasExternalLabel = function(semantic) { - - return semantic.$instanceOf('bpmn:Event') || - // semantic.$instanceOf('bpmn:Gateway') || - semantic.$instanceOf('bpmn:DataStoreReference') || - semantic.$instanceOf('bpmn:DataObjectReference') || - semantic.$instanceOf('bpmn:SequenceFlow') || - semantic.$instanceOf('bpmn:MessageFlow'); - }; + /** + * A parse context. + * + * @class + * + * @param {Object} + * options + * @param {ElementHandler} + * options.parseRoot the root handler for parsing a document + * @param {boolean} + * [options.lax=false] whether or not to ignore invalid elements + */ + function Context(options) { - /** - * Get the middle of a number of waypoints - * - * @param {Array - * } waypoints - * @return {Point} the mid point - */ - var getWaypointsMid = module.exports.getWaypointsMid = function(waypoints) { + /** + * @property {ElementHandler} parseRoot + */ - var mid = waypoints.length / 2 - 1; + /** + * @property {Boolean} lax + */ - var first = waypoints[Math.floor(mid)]; - var second = waypoints[Math.ceil(mid + 0.01)]; + assign(this, options); - return { - x: first.x + (second.x - first.x) / 2, - y: first.y + (second.y - first.y) / 2 - }; - }; + var elementsById = this.elementsById = {}; + var references = this.references = []; + var warnings = this.warnings = []; + this.addReference = function(reference) { + references.push(reference); + }; - var getExternalLabelMid = module.exports.getExternalLabelMid = function(element) { + this.addElement = function(id, element) { - if (element.waypoints) { - return getWaypointsMid(element.waypoints); - } else { - return { - x: element.x + element.width / 2, - y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2 - }; - } - }; + if (!id || !element) { + throw new Error('[xml-reader] id or ctx must not be null'); + } - /** - * Returns the bounds of an elements label, parsed from the elements DI or - * generated from its bounds. - * - * @param {BpmnElement} - * semantic - * @param {djs.model.Base} - * element - */ - module.exports.getExternalLabelBounds = function(semantic, element) { + elementsById[id] = element; + }; - var mid, - size, - bounds, - di = semantic.di, - label = di.label; + this.addWarning = function(w) { + warnings.push(w); + }; + } - if (label && label.bounds) { - bounds = label.bounds; + function BaseHandler() {} - size = { - width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width), - height: bounds.height - }; + BaseHandler.prototype.handleEnd = function() {}; + BaseHandler.prototype.handleText = function() {}; + BaseHandler.prototype.handleNode = function() {}; - mid = { - x: bounds.x + bounds.width / 2, - y: bounds.y + bounds.height / 2 - }; - } else { - mid = getExternalLabelMid(element); + /** + * A simple pass through handler that does nothing except for ignoring all input + * it receives. + * + * This is used to ignore unknown elements and attributes. + */ + function NoopHandler() {} - size = DEFAULT_LABEL_SIZE; - } + NoopHandler.prototype = new BaseHandler(); - return assign({ - x: mid.x - size.width / 2, - y: mid.y - size.height / 2 - }, size); - }; - }, { - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\lib\\util\\ModelUtil.js": [function(require, module, exports) { - 'use strict'; + NoopHandler.prototype.handleNode = function() { + return this; + }; - /** - * Is an element of the given BPMN type? - * - * @param {djs.model.Base|ModdleElement} - * element - * @param {String} - * type - * - * @return {Boolean} - */ - function is(element, type) { - var bo = getBusinessObject(element); + function BodyHandler() {} - return bo && bo.$instanceOf(type); - } + BodyHandler.prototype = new BaseHandler(); - module.exports.is = is; + BodyHandler.prototype.handleText = function(text) { + this.body = (this.body || '') + text; + }; + function ReferenceHandler(property, context) { + this.property = property; + this.context = context; + } - /** - * Return the business object for a given element. - * - * @param {djs.model.Base|ModdleElement} - * element - * - * @return {ModdleElement} - */ - function getBusinessObject(element) { - return (element && element.businessObject) || element; - } + ReferenceHandler.prototype = new BodyHandler(); - module.exports.getBusinessObject = getBusinessObject; + ReferenceHandler.prototype.handleNode = function(node) { - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\index.js": [function(require, module, exports) { - module.exports = require('./lib/simple'); - }, { - "./lib/simple": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\simple.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\bpmn-moddle.js": [function(require, module, exports) { - 'use strict'; + if (this.element) { + throw new Error('expected no sub nodes'); + } else { + this.element = this.createReference(node); + } - var isString = require('lodash/lang/isString'), - isFunction = require('lodash/lang/isFunction'), - assign = require('lodash/object/assign'); + return this; + }; - var Moddle = require('moddle'), - XmlReader = require('moddle-xml/lib/reader'), - XmlWriter = require('moddle-xml/lib/writer'); + ReferenceHandler.prototype.handleEnd = function() { + this.element.id = this.body; + }; - /** - * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 - * xml files. - * - * @class BpmnModdle - * @extends Moddle - * - * @param {Object|Array} - * packages to use for instantiating the model - * @param {Object} - * [options] additional options to pass over - */ - function BpmnModdle(packages, options) { - Moddle.call(this, packages, options); - } + ReferenceHandler.prototype.createReference = function() { + return { + property: this.property.ns.name, + id: '' + }; + }; - BpmnModdle.prototype = Object.create(Moddle.prototype); + function ValueHandler(propertyDesc, element) { + this.element = element; + this.propertyDesc = propertyDesc; + } - module.exports = BpmnModdle; + ValueHandler.prototype = new BodyHandler(); + ValueHandler.prototype.handleEnd = function() { - /** - * Instantiates a BPMN model tree from a given xml string. - * - * @param {String} - * xmlStr - * @param {String} - * [typeName='bpmn:Definitions'] name of the root element - * @param {Object} - * [options] options to pass to the underlying reader - * @param {Function} - * done callback that is invoked with (err, result, parseContext) - * once the import completes - */ - BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) { + var value = this.body, + element = this.element, + propertyDesc = this.propertyDesc; - if (!isString(typeName)) { - done = options; - options = typeName; - typeName = 'bpmn:Definitions'; - } + value = coerceType(propertyDesc.type, value); - if (isFunction(options)) { - done = options; - options = {}; - } + if (propertyDesc.isMany) { + element.get(propertyDesc.name).push(value); + } else { + element.set(propertyDesc.name, value); + } + }; - var reader = new XmlReader(assign({ - model: this, - lax: true - }, options)); - var rootHandler = reader.handler(typeName); - reader.fromXML(xmlStr, rootHandler, done); - }; + function BaseElementHandler() {} + BaseElementHandler.prototype = Object.create(BodyHandler.prototype); - /** - * Serializes a BPMN 2.0 object tree to XML. - * - * @param {String} - * element the root element, typically an instance of - * `bpmn:Definitions` - * @param {Object} - * [options] to pass to the underlying writer - * @param {Function} - * done callback invoked with (err, xmlStr) once the import completes - */ - - - - - BpmnModdle.prototype.toXML = function(element, options, done) { + BaseElementHandler.prototype.handleNode = function(node) { + var parser = this, + element = this.element, + id; - if (isFunction(options)) { - done = options; - options = {}; - } + if (!element) { + element = this.element = this.createElement(node); + id = element.id; - var writer = new XmlWriter(options); - try { - var result = writer.toXML(element); - modelXML = result; - list_models[selected_model]=result; - done(null, result); - } catch (e) { - done(e); - } - }; + if (id) { + this.context.addElement(id, element); + } + } else { + parser = this.handleChild(node); + } - }, { - "lodash/lang/isFunction": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isFunction.js", - "lodash/lang/isString": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isString.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", - "moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\index.js", - "moddle-xml/lib/reader": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\reader.js", - "moddle-xml/lib/writer": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\writer.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\id-support.js": [function(require, module, exports) { - 'use strict'; + return parser; + }; + + /** + * @class XMLReader.ElementHandler + * + */ + function ElementHandler(model, type, context) { + this.model = model; + this.type = model.getType(type); + this.context = context; + } - var ID_PATTERN = /^(.*:)?id$/; + ElementHandler.prototype = new BaseElementHandler(); - /** - * Extends the bpmn instance with id support. - * - * @example - * - * var moddle, ids; - * - * require('id-support').extend(moddle, ids); - * - * moddle.ids.next(); // create a next id moddle.ids; // ids instance - * // claims id as used moddle.create('foo:Bar', { id: 'fooobar1' }); - * - * - * @param {Moddle} - * model - * @param {Ids} - * ids - * - * @return {Moddle} the extended moddle instance - */ - module.exports.extend = function(model, ids) { + ElementHandler.prototype.addReference = function(reference) { + this.context.addReference(reference); + }; - var set = model.properties.set; + ElementHandler.prototype.handleEnd = function() { - // do not reinitialize setter - // unless it is already initialized - if (!model.ids) { + var value = this.body, + element = this.element, + descriptor = element.$descriptor, + bodyProperty = descriptor.bodyProperty; - model.properties.set = function(target, property, value) { + if (bodyProperty && value !== undefined) { + value = coerceType(bodyProperty.type, value); + element.set(bodyProperty.name, value); + } + }; + + /** + * Create an instance of the model from the given node. + * + * @param {Element} + * node the xml node + */ + ElementHandler.prototype.createElement = function(node) { + var attributes = parseNodeAttributes(node), + Type = this.type, + descriptor = Type.$descriptor, + context = this.context, + instance = new Type({}); + + forEach(attributes, function(value, name) { + + var prop = descriptor.propertiesByName[name]; + + if (prop && prop.isReference) { + context.addReference({ + element: instance, + property: prop.ns.name, + id: value + }); + } else { + if (prop) { + value = coerceType(prop.type, value); + } - // ensure we log used ids once they are assigned - // to model elements - if (ID_PATTERN.test(property)) { + instance.set(name, value); + } + }); - var assigned = model.ids.assigned(value); - if (assigned && assigned !== target) { - throw new Error('id <' + value + '> already used'); - } + return instance; + }; - model.ids.claim(value, target); - } + ElementHandler.prototype.getPropertyForNode = function(node) { - set.call(this, target, property, value); - }; - } + var nameNs = parseNameNs(node.local, node.prefix); - model.ids = ids; + var type = this.type, + model = this.model, + descriptor = type.$descriptor; - return model; - }; - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\simple.js": [function(require, module, exports) { - 'use strict'; + var propertyName = nameNs.name, + property = descriptor.propertiesByName[propertyName], + elementTypeName, + elementType, + typeAnnotation; - var assign = require('lodash/object/assign'); + // search for properties by name first - var BpmnModdle = require('./bpmn-moddle'); + if (property) { - var packages = { - bpmn: require('../resources/bpmn/json/bpmn.json'), - bpmndi: require('../resources/bpmn/json/bpmndi.json'), - dc: require('../resources/bpmn/json/dc.json'), - di: require('../resources/bpmn/json/di.json') - }; + if (property.serialize === XSI_TYPE) { + typeAnnotation = node.attributes[XSI_TYPE]; - module.exports = function(additionalPackages, options) { - return new BpmnModdle(assign({}, packages, additionalPackages), options); - }; - }, { - "../resources/bpmn/json/bpmn.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\bpmn.json", - "../resources/bpmn/json/bpmndi.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\bpmndi.json", - "../resources/bpmn/json/dc.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\dc.json", - "../resources/bpmn/json/di.json": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\resources\\bpmn\\json\\di.json", - "./bpmn-moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\lib\\bpmn-moddle.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\common.js": [function(require, module, exports) { - 'use strict'; + // xsi type is optional, if it does not exists the + // default type is assumed + if (typeAnnotation) { - function capitalize(string) { - return string.charAt(0).toUpperCase() + string.slice(1); - } + elementTypeName = typeAnnotation.value; - function lower(string) { - return string.charAt(0).toLowerCase() + string.slice(1); - } + // TODO: extract real name from attribute + elementType = model.getType(elementTypeName); - function hasLowerCaseAlias(pkg) { - return pkg.xml && pkg.xml.tagAlias === 'lowerCase'; + return assign({}, property, { + effectiveType: elementType.$descriptor.name + }); + } } + // search for properties by name first + return property; + } - module.exports.aliasToName = function(alias, pkg) { - if (hasLowerCaseAlias(pkg)) { - return capitalize(alias); - } else { - return alias; - } - }; - module.exports.nameToAlias = function(name, pkg) { - if (hasLowerCaseAlias(pkg)) { - return lower(name); - } else { - return name; - } - }; + var pkg = model.getPackage(nameNs.prefix); - module.exports.DEFAULT_NS_MAP = { - 'xsi': 'http://www.w3.org/2001/XMLSchema-instance' - }; + if (pkg) { + elementTypeName = nameNs.prefix + ':' + aliasToName(nameNs.localName, descriptor.$pkg); + elementType = model.getType(elementTypeName); - module.exports.XSI_TYPE = 'xsi:type'; - }, {}], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\reader.js": [function(require, module, exports) { - 'use strict'; - - var reduce = require('lodash/collection/reduce'), - forEach = require('lodash/collection/forEach'), - find = require('lodash/collection/find'), - assign = require('lodash/object/assign'), - defer = require('lodash/function/defer'); - - var Stack = require('tiny-stack'), - SaxParser = require('sax').parser, - Moddle = require('moddle'), - parseNameNs = require('moddle/lib/ns').parseName, - Types = require('moddle/lib/types'), - coerceType = Types.coerceType, - isSimpleType = Types.isSimple, - common = require('./common'), - XSI_TYPE = common.XSI_TYPE, - XSI_URI = common.DEFAULT_NS_MAP.xsi, - aliasToName = common.aliasToName; - - function parseNodeAttributes(node) { - var nodeAttrs = node.attributes; - - return reduce(nodeAttrs, function(result, v, k) { - var name, ns; - - if (!v.local) { - name = v.prefix; - } else { - ns = parseNameNs(v.name, v.prefix); - name = ns.name; - } + // search for collection members later + property = find(descriptor.properties, function(p) { + return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type); + }); - result[name] = v.value; - return result; - }, {}); + if (property) { + return assign({}, property, { + effectiveType: elementType.$descriptor.name + }); } + } else { + // parse unknown element (maybe extension) + property = find(descriptor.properties, function(p) { + return !p.isReference && !p.isAttribute && p.type === 'Element'; + }); - function normalizeType(node, attr, model) { - var nameNs = parseNameNs(attr.value); + if (property) { + return property; + } + } - var uri = node.ns[nameNs.prefix || ''], - localName = nameNs.localName, - pkg = uri && model.getPackage(uri), - typePrefix; + throw new Error('unrecognized element <' + nameNs.name + '>'); + }; - if (pkg) { - typePrefix = pkg.xml && pkg.xml.typePrefix; + ElementHandler.prototype.toString = function() { + return 'ElementDescriptor[' + this.type.$descriptor.name + ']'; + }; - if (typePrefix && localName.indexOf(typePrefix) === 0) { - localName = localName.slice(typePrefix.length); - } + ElementHandler.prototype.valueHandler = function(propertyDesc, element) { + return new ValueHandler(propertyDesc, element); + }; - attr.value = pkg.prefix + ':' + localName; - } - } + ElementHandler.prototype.referenceHandler = function(propertyDesc) { + return new ReferenceHandler(propertyDesc, this.context); + }; - /** - * Normalizes namespaces for a node given an optional default namespace and a - * number of mappings from uris to default prefixes. - * - * @param {XmlNode} - * node - * @param {Model} - * model the model containing all registered namespaces - * @param {Uri} - * defaultNsUri - */ - function normalizeNamespaces(node, model, defaultNsUri) { - var uri, prefix; + ElementHandler.prototype.handler = function(type) { + if (type === 'Element') { + return new GenericElementHandler(this.model, type, this.context); + } else { + return new ElementHandler(this.model, type, this.context); + } + }; - uri = node.uri || defaultNsUri; + /** + * Handle the child element parsing + * + * @param {Element} + * node the xml node + */ + ElementHandler.prototype.handleChild = function(node) { + var propertyDesc, type, element, childHandler; - if (uri) { - var pkg = model.getPackage(uri); + propertyDesc = this.getPropertyForNode(node); + element = this.element; - if (pkg) { - prefix = pkg.prefix; - } else { - prefix = node.prefix; - } + type = propertyDesc.effectiveType || propertyDesc.type; - node.prefix = prefix; - node.uri = uri; - } + if (isSimpleType(type)) { + return this.valueHandler(propertyDesc, element); + } - forEach(node.attributes, function(attr) { + if (propertyDesc.isReference) { + childHandler = this.referenceHandler(propertyDesc).handleNode(node); + } else { + childHandler = this.handler(type).handleNode(node); + } - // normalize xsi:type attributes because the - // assigned type may or may not be namespace prefixed - if (attr.uri === XSI_URI && attr.local === 'type') { - normalizeType(node, attr, model); - } + var newElement = childHandler.element; - normalizeNamespaces(attr, model, null); - }); + // child handles may decide to skip elements + // by not returning anything + if (newElement !== undefined) { + + if (propertyDesc.isMany) { + element.get(propertyDesc.name).push(newElement); + } else { + element.set(propertyDesc.name, newElement); } + if (propertyDesc.isReference) { + assign(newElement, { + element: element + }); - /** - * A parse context. - * - * @class - * - * @param {Object} - * options - * @param {ElementHandler} - * options.parseRoot the root handler for parsing a document - * @param {boolean} - * [options.lax=false] whether or not to ignore invalid elements - */ - function Context(options) { + this.context.addReference(newElement); + } else { + // establish child -> parent relationship + newElement.$parent = element; + } + } - /** - * @property {ElementHandler} parseRoot - */ + return childHandler; + }; - /** - * @property {Boolean} lax - */ - assign(this, options); + function GenericElementHandler(model, type, context) { + this.model = model; + this.context = context; + } - var elementsById = this.elementsById = {}; - var references = this.references = []; - var warnings = this.warnings = []; + GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype); - this.addReference = function(reference) { - references.push(reference); - }; + GenericElementHandler.prototype.createElement = function(node) { - this.addElement = function(id, element) { + var name = node.name, + prefix = node.prefix, + uri = node.ns[prefix], + attributes = node.attributes; - if (!id || !element) { - throw new Error('[xml-reader] id or ctx must not be null'); - } + return this.model.createAny(name, uri, attributes); + }; - elementsById[id] = element; - }; + GenericElementHandler.prototype.handleChild = function(node) { - this.addWarning = function(w) { - warnings.push(w); - }; - } + var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node), + element = this.element; - function BaseHandler() {} + var newElement = handler.element, + children; - BaseHandler.prototype.handleEnd = function() {}; - BaseHandler.prototype.handleText = function() {}; - BaseHandler.prototype.handleNode = function() {}; + if (newElement !== undefined) { + children = element.$children = element.$children || []; + children.push(newElement); + // establish child -> parent relationship + newElement.$parent = element; + } - /** - * A simple pass through handler that does nothing except for ignoring all input - * it receives. - * - * This is used to ignore unknown elements and attributes. - */ - function NoopHandler() {} + return handler; + }; - NoopHandler.prototype = new BaseHandler(); + GenericElementHandler.prototype.handleText = function(text) { + this.body = this.body || '' + text; + }; - NoopHandler.prototype.handleNode = function() { - return this; + GenericElementHandler.prototype.handleEnd = function() { + if (this.body) { + this.element.$body = this.body; + } + }; + + /** + * A reader for a meta-model + * + * @param {Object} + * options + * @param {Model} + * options.model used to read xml files + * @param {Boolean} + * options.lax whether to make parse errors warnings + */ + function XMLReader(options) { + + if (options instanceof Moddle) { + options = { + model: options }; + } - function BodyHandler() {} - - BodyHandler.prototype = new BaseHandler(); + assign(this, { + lax: false + }, options); + } - BodyHandler.prototype.handleText = function(text) { - this.body = (this.body || '') + text; - }; - function ReferenceHandler(property, context) { - this.property = property; - this.context = context; - } + XMLReader.prototype.fromXML = function(xml, rootHandler, done) { - ReferenceHandler.prototype = new BodyHandler(); + var model = this.model, + lax = this.lax, + context = new Context({ + parseRoot: rootHandler + }); - ReferenceHandler.prototype.handleNode = function(node) { + var parser = new SaxParser(true, { + xmlns: true, + trim: true + }), + stack = new Stack(); - if (this.element) { - throw new Error('expected no sub nodes'); - } else { - this.element = this.createReference(node); - } + rootHandler.context = context; - return this; - }; + // push root handler + stack.push(rootHandler); - ReferenceHandler.prototype.handleEnd = function() { - this.element.id = this.body; - }; - ReferenceHandler.prototype.createReference = function() { - return { - property: this.property.ns.name, - id: '' - }; - }; + function resolveReferences() { - function ValueHandler(propertyDesc, element) { - this.element = element; - this.propertyDesc = propertyDesc; - } + var elementsById = context.elementsById; + var references = context.references; - ValueHandler.prototype = new BodyHandler(); + var i, r; - ValueHandler.prototype.handleEnd = function() { + for (i = 0; !!(r = references[i]); i++) { + var element = r.element; + var reference = elementsById[r.id]; + var property = element.$descriptor.propertiesByName[r.property]; - var value = this.body, - element = this.element, - propertyDesc = this.propertyDesc; + if (!reference) { + context.addWarning({ + message: 'unresolved reference <' + r.id + '>', + element: r.element, + property: r.property, + value: r.id + }); + } - value = coerceType(propertyDesc.type, value); + if (property.isMany) { + var collection = element.get(property.name), + idx = collection.indexOf(r); - if (propertyDesc.isMany) { - element.get(propertyDesc.name).push(value); + if (!reference) { + // remove unresolvable reference + collection.splice(idx, 1); } else { - element.set(propertyDesc.name, value); + // update reference + collection[idx] = reference; } - }; + } else { + element.set(property.name, reference); + } + } + } + function handleClose(tagName) { + stack.pop().handleEnd(); + } - function BaseElementHandler() {} + function handleOpen(node) { + var handler = stack.peek(); - BaseElementHandler.prototype = Object.create(BodyHandler.prototype); + normalizeNamespaces(node, model); - BaseElementHandler.prototype.handleNode = function(node) { - var parser = this, - element = this.element, - id; + try { + stack.push(handler.handleNode(node)); + } catch (e) { - if (!element) { - element = this.element = this.createElement(node); - id = element.id; + var line = this.line, + column = this.column; - if (id) { - this.context.addElement(id, element); - } - } else { - parser = this.handleChild(node); - } + var message = + 'unparsable content <' + node.name + '> detected\n\t' + + 'line: ' + line + '\n\t' + + 'column: ' + column + '\n\t' + + 'nested error: ' + e.message; - return parser; - }; + if (lax) { + context.addWarning({ + message: message, + error: e + }); - /** - * @class XMLReader.ElementHandler - * - */ - function ElementHandler(model, type, context) { - this.model = model; - this.type = model.getType(type); - this.context = context; + console.warn('could not parse node'); + console.warn(e); + + stack.push(new NoopHandler()); + } else { + console.error('could not parse document'); + console.error(e); + + throw new Error(message); + } } + } - ElementHandler.prototype = new BaseElementHandler(); + function handleText(text) { + stack.peek().handleText(text); + } - ElementHandler.prototype.addReference = function(reference) { - this.context.addReference(reference); - }; + parser.onopentag = handleOpen; + parser.oncdata = parser.ontext = handleText; + parser.onclosetag = handleClose; + parser.onend = resolveReferences; + + // deferred parse XML to make loading really ascnchronous + // this ensures the execution environment (node or browser) + // is kept responsive and that certain optimization strategies + // can kick in + defer(function() { + var error; + + try { + parser.write(xml).close(); + } catch (e) { + error = e; + } - ElementHandler.prototype.handleEnd = function() { + done(error, error ? undefined : rootHandler.element, context); + }); + }; + + XMLReader.prototype.handler = function(name) { + return new ElementHandler(this.model, name); + }; + + module.exports = XMLReader; + module.exports.ElementHandler = ElementHandler; + }, { + "./common": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\common.js", + "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "lodash/collection/reduce": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\reduce.js", + "lodash/function/defer": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\function\\defer.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", + "moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\index.js", + "moddle/lib/ns": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\lib\\ns.js", + "moddle/lib/types": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\lib\\types.js", + "sax": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\node_modules\\sax\\lib\\sax.js", + "tiny-stack": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\node_modules\\tiny-stack\\lib\\tiny-stack.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\writer.js": [function(require, module, exports) { + 'use strict'; + + var map = require('lodash/collection/map'), + forEach = require('lodash/collection/forEach'), + isString = require('lodash/lang/isString'), + filter = require('lodash/collection/filter'), + assign = require('lodash/object/assign'); + + var Types = require('moddle/lib/types'), + parseNameNs = require('moddle/lib/ns').parseName, + common = require('./common'), + nameToAlias = common.nameToAlias; + + var XML_PREAMBLE = '\n', + ESCAPE_CHARS = /(<|>|'|"|&|\n\r|\n)/g, + DEFAULT_NS_MAP = common.DEFAULT_NS_MAP, + XSI_TYPE = common.XSI_TYPE; + + + function nsName(ns) { + if (isString(ns)) { + return ns; + } else { + return (ns.prefix ? ns.prefix + ':' : '') + ns.localName; + } + } - var value = this.body, - element = this.element, - descriptor = element.$descriptor, - bodyProperty = descriptor.bodyProperty; + function getElementNs(ns, descriptor) { + if (descriptor.isGeneric) { + return descriptor.name; + } else { + return assign({ + localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) + }, ns); + } + } - if (bodyProperty && value !== undefined) { - value = coerceType(bodyProperty.type, value); - element.set(bodyProperty.name, value); - } - }; + function getPropertyNs(ns, descriptor) { + return assign({ + localName: descriptor.ns.localName + }, ns); + } - /** - * Create an instance of the model from the given node. - * - * @param {Element} - * node the xml node - */ - ElementHandler.prototype.createElement = function(node) { - var attributes = parseNodeAttributes(node), - Type = this.type, - descriptor = Type.$descriptor, - context = this.context, - instance = new Type({}); - - forEach(attributes, function(value, name) { - - var prop = descriptor.propertiesByName[name]; - - if (prop && prop.isReference) { - context.addReference({ - element: instance, - property: prop.ns.name, - id: value - }); - } else { - if (prop) { - value = coerceType(prop.type, value); - } + function getSerializableProperties(element) { + var descriptor = element.$descriptor; - instance.set(name, value); - } - }); + return filter(descriptor.properties, function(p) { + var name = p.name; - return instance; - }; + // do not serialize defaults + if (!element.hasOwnProperty(name)) { + return false; + } - ElementHandler.prototype.getPropertyForNode = function(node) { + var value = element[name]; - var nameNs = parseNameNs(node.local, node.prefix); + // do not serialize default equals + if (value === p.default) { + return false; + } - var type = this.type, - model = this.model, - descriptor = type.$descriptor; + return p.isMany ? value.length : true; + }); + } - var propertyName = nameNs.name, - property = descriptor.propertiesByName[propertyName], - elementTypeName, - elementType, - typeAnnotation; + var ESCAPE_MAP = { + '\n': '10', + '\n\r': '10', + '"': '34', + '\'': '39', + '<': '60', + '>': '62', + '&': '38' + }; + + /** + * Escape a string attribute to not contain any bad values (line breaks, '"', + * ...) + * + * @param {String} + * str the string to escape + * @return {String} the escaped string + */ + function escapeAttr(str) { + + // ensure we are handling strings here + str = isString(str) ? str : '' + str; + + return str.replace(ESCAPE_CHARS, function(str) { + return '&#' + ESCAPE_MAP[str] + ';'; + }); + } - // search for properties by name first + function filterAttributes(props) { + return filter(props, function(p) { + return p.isAttr; + }); + } - if (property) { + function filterContained(props) { + return filter(props, function(p) { + return !p.isAttr; + }); + } - if (property.serialize === XSI_TYPE) { - typeAnnotation = node.attributes[XSI_TYPE]; - // xsi type is optional, if it does not exists the - // default type is assumed - if (typeAnnotation) { + function ReferenceSerializer(parent, ns) { + this.ns = ns; + } - elementTypeName = typeAnnotation.value; + ReferenceSerializer.prototype.build = function(element) { + this.element = element; + return this; + }; - // TODO: extract real name from attribute - elementType = model.getType(elementTypeName); + ReferenceSerializer.prototype.serializeTo = function(writer) { + writer + .appendIndent() + .append('<' + nsName(this.ns) + '>' + this.element.id + '') + .appendNewLine(); + }; - return assign({}, property, { - effectiveType: elementType.$descriptor.name - }); - } - } + function BodySerializer() {} - // search for properties by name first - return property; - } + BodySerializer.prototype.serializeValue = BodySerializer.prototype.serializeTo = function(writer) { + var escape = this.escape; + if (escape) { + writer.append(''); + } + }; - // search for collection members later - property = find(descriptor.properties, function(p) { - return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type); - }); + BodySerializer.prototype.build = function(prop, value) { + this.value = value; - if (property) { - return assign({}, property, { - effectiveType: elementType.$descriptor.name - }); - } - } else { - // parse unknown element (maybe extension) - property = find(descriptor.properties, function(p) { - return !p.isReference && !p.isAttribute && p.type === 'Element'; - }); + if (prop.type === 'String' && ESCAPE_CHARS.test(value)) { + this.escape = true; + } - if (property) { - return property; - } - } + return this; + }; - throw new Error('unrecognized element <' + nameNs.name + '>'); - }; + function ValueSerializer(ns) { + this.ns = ns; + } - ElementHandler.prototype.toString = function() { - return 'ElementDescriptor[' + this.type.$descriptor.name + ']'; - }; + ValueSerializer.prototype = new BodySerializer(); - ElementHandler.prototype.valueHandler = function(propertyDesc, element) { - return new ValueHandler(propertyDesc, element); - }; + ValueSerializer.prototype.serializeTo = function(writer) { - ElementHandler.prototype.referenceHandler = function(propertyDesc) { - return new ReferenceHandler(propertyDesc, this.context); - }; + writer + .appendIndent() + .append('<' + nsName(this.ns) + '>'); - ElementHandler.prototype.handler = function(type) { - if (type === 'Element') { - return new GenericElementHandler(this.model, type, this.context); - } else { - return new ElementHandler(this.model, type, this.context); - } - }; + this.serializeValue(writer); - /** - * Handle the child element parsing - * - * @param {Element} - * node the xml node - */ - ElementHandler.prototype.handleChild = function(node) { - var propertyDesc, type, element, childHandler; + writer + .append('') + .appendNewLine(); + }; - propertyDesc = this.getPropertyForNode(node); - element = this.element; + function ElementSerializer(parent, ns) { + this.body = []; + this.attrs = []; - type = propertyDesc.effectiveType || propertyDesc.type; + this.parent = parent; + this.ns = ns; + } - if (isSimpleType(type)) { - return this.valueHandler(propertyDesc, element); - } + ElementSerializer.prototype.build = function(element) { + this.element = element; - if (propertyDesc.isReference) { - childHandler = this.referenceHandler(propertyDesc).handleNode(node); - } else { - childHandler = this.handler(type).handleNode(node); - } + var otherAttrs = this.parseNsAttributes(element); - var newElement = childHandler.element; + if (!this.ns) { + this.ns = this.nsTagName(element.$descriptor); + } - // child handles may decide to skip elements - // by not returning anything - if (newElement !== undefined) { + if (element.$descriptor.isGeneric) { + this.parseGeneric(element); + } else { + var properties = getSerializableProperties(element); - if (propertyDesc.isMany) { - element.get(propertyDesc.name).push(newElement); - } else { - element.set(propertyDesc.name, newElement); - } + this.parseAttributes(filterAttributes(properties)); + this.parseContainments(filterContained(properties)); - if (propertyDesc.isReference) { - assign(newElement, { - element: element - }); + this.parseGenericAttributes(element, otherAttrs); + } - this.context.addReference(newElement); - } else { - // establish child -> parent relationship - newElement.$parent = element; - } - } - - return childHandler; - }; - - - function GenericElementHandler(model, type, context) { - this.model = model; - this.context = context; - } + return this; + }; - GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype); + ElementSerializer.prototype.nsTagName = function(descriptor) { + var effectiveNs = this.logNamespaceUsed(descriptor.ns); + return getElementNs(effectiveNs, descriptor); + }; - GenericElementHandler.prototype.createElement = function(node) { + ElementSerializer.prototype.nsPropertyTagName = function(descriptor) { + var effectiveNs = this.logNamespaceUsed(descriptor.ns); + return getPropertyNs(effectiveNs, descriptor); + }; - var name = node.name, - prefix = node.prefix, - uri = node.ns[prefix], - attributes = node.attributes; + ElementSerializer.prototype.isLocalNs = function(ns) { + return ns.uri === this.ns.uri; + }; - return this.model.createAny(name, uri, attributes); - }; - - GenericElementHandler.prototype.handleChild = function(node) { - - var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node), - element = this.element; - - var newElement = handler.element, - children; + ElementSerializer.prototype.nsAttributeName = function(element) { - if (newElement !== undefined) { - children = element.$children = element.$children || []; - children.push(newElement); + var ns; - // establish child -> parent relationship - newElement.$parent = element; - } + if (isString(element)) { + ns = parseNameNs(element); + } else + if (element.ns) { + ns = element.ns; + } - return handler; - }; + var effectiveNs = this.logNamespaceUsed(ns); - GenericElementHandler.prototype.handleText = function(text) { - this.body = this.body || '' + text; + // strip prefix if same namespace like parent + if (this.isLocalNs(effectiveNs)) { + return { + localName: ns.localName }; + } else { + return assign({ + localName: ns.localName + }, effectiveNs); + } + }; - GenericElementHandler.prototype.handleEnd = function() { - if (this.body) { - this.element.$body = this.body; - } - }; + ElementSerializer.prototype.parseGeneric = function(element) { - /** - * A reader for a meta-model - * - * @param {Object} - * options - * @param {Model} - * options.model used to read xml files - * @param {Boolean} - * options.lax whether to make parse errors warnings - */ - function XMLReader(options) { + var self = this, + body = this.body, + attrs = this.attrs; - if (options instanceof Moddle) { - options = { - model: options - }; - } + forEach(element, function(val, key) { - assign(this, { - lax: false - }, options); + if (key === '$body') { + body.push(new BodySerializer().build({ + type: 'String' + }, val)); + } else + if (key === '$children') { + forEach(val, function(child) { + body.push(new ElementSerializer(self).build(child)); + }); + } else + if (key.indexOf('$') !== 0) { + attrs.push({ + name: key, + value: escapeAttr(val) + }); } + }); + }; + + /** + * Parse namespaces and return a list of left over generic attributes + * + * @param {Object} + * element + * @return {Array} + */ + ElementSerializer.prototype.parseNsAttributes = function(element) { + var self = this; + + var genericAttrs = element.$attrs; + + var attributes = []; + + // parse namespace attributes first + // and log them. push non namespace attributes to a list + // and process them later + forEach(genericAttrs, function(value, name) { + var nameNs = parseNameNs(name); + + if (nameNs.prefix === 'xmlns') { + self.logNamespace({ + prefix: nameNs.localName, + uri: value + }); + } else + if (!nameNs.prefix && nameNs.localName === 'xmlns') { + self.logNamespace({ + uri: value + }); + } else { + attributes.push({ + name: name, + value: value + }); + } + }); + return attributes; + }; - XMLReader.prototype.fromXML = function(xml, rootHandler, done) { - - var model = this.model, - lax = this.lax, - context = new Context({ - parseRoot: rootHandler - }); + ElementSerializer.prototype.parseGenericAttributes = function(element, attributes) { - var parser = new SaxParser(true, { - xmlns: true, - trim: true - }), - stack = new Stack(); + var self = this; - rootHandler.context = context; + forEach(attributes, function(attr) { - // push root handler - stack.push(rootHandler); + // do not serialize xsi:type attribute + // it is set manually based on the actual implementation type + if (attr.name === XSI_TYPE) { + return; + } + try { + self.addAttribute(self.nsAttributeName(attr.name), attr.value); + } catch (e) { + console.warn('[writer] missing namespace information for ', attr.name, '=', attr.value, 'on', element, e); + } + }); + }; - function resolveReferences() { + ElementSerializer.prototype.parseContainments = function(properties) { - var elementsById = context.elementsById; - var references = context.references; + var self = this, + body = this.body, + element = this.element; - var i, r; + forEach(properties, function(p) { + var value = element.get(p.name), + isReference = p.isReference, + isMany = p.isMany; - for (i = 0; !!(r = references[i]); i++) { - var element = r.element; - var reference = elementsById[r.id]; - var property = element.$descriptor.propertiesByName[r.property]; + var ns = self.nsPropertyTagName(p); - if (!reference) { - context.addWarning({ - message: 'unresolved reference <' + r.id + '>', - element: r.element, - property: r.property, - value: r.id - }); - } + if (!isMany) { + value = [value]; + } - if (property.isMany) { - var collection = element.get(property.name), - idx = collection.indexOf(r); + if (p.isBody) { + body.push(new BodySerializer().build(p, value[0])); + } else + if (Types.isSimple(p.type)) { + forEach(value, function(v) { + body.push(new ValueSerializer(ns).build(p, v)); + }); + } else + if (isReference) { + forEach(value, function(v) { + body.push(new ReferenceSerializer(self, ns).build(v)); + }); + } else { + // allow serialization via type + // rather than element name + var asType = p.serialize === XSI_TYPE; - if (!reference) { - // remove unresolvable reference - collection.splice(idx, 1); - } else { - // update reference - collection[idx] = reference; - } - } else { - element.set(property.name, reference); - } - } - } + forEach(value, function(v) { + var serializer; - function handleClose(tagName) { - stack.pop().handleEnd(); + if (asType) { + serializer = new TypeSerializer(self, ns); + } else { + serializer = new ElementSerializer(self); } - function handleOpen(node) { - var handler = stack.peek(); - - normalizeNamespaces(node, model); - - try { - stack.push(handler.handleNode(node)); - } catch (e) { + body.push(serializer.build(v)); + }); + } + }); + }; + + ElementSerializer.prototype.getNamespaces = function() { + if (!this.parent) { + if (!this.namespaces) { + this.namespaces = { + prefixMap: {}, + uriMap: {}, + used: {} + }; + } + } else { + this.namespaces = this.parent.getNamespaces(); + } - var line = this.line, - column = this.column; + return this.namespaces; + }; - var message = - 'unparsable content <' + node.name + '> detected\n\t' + - 'line: ' + line + '\n\t' + - 'column: ' + column + '\n\t' + - 'nested error: ' + e.message; + ElementSerializer.prototype.logNamespace = function(ns) { + var namespaces = this.getNamespaces(); - if (lax) { - context.addWarning({ - message: message, - error: e - }); + var existing = namespaces.uriMap[ns.uri]; - console.warn('could not parse node'); - console.warn(e); + if (!existing) { + namespaces.uriMap[ns.uri] = ns; + } - stack.push(new NoopHandler()); - } else { - console.error('could not parse document'); - console.error(e); + namespaces.prefixMap[ns.prefix] = ns.uri; - throw new Error(message); - } - } - } + return ns; + }; - function handleText(text) { - stack.peek().handleText(text); - } + ElementSerializer.prototype.logNamespaceUsed = function(ns) { + var element = this.element, + model = element.$model, + namespaces = this.getNamespaces(); - parser.onopentag = handleOpen; - parser.oncdata = parser.ontext = handleText; - parser.onclosetag = handleClose; - parser.onend = resolveReferences; + // ns may be + // + // * prefix only + // * prefix:uri - // deferred parse XML to make loading really ascnchronous - // this ensures the execution environment (node or browser) - // is kept responsive and that certain optimization strategies - // can kick in - defer(function() { - var error; + var prefix = ns.prefix; + var uri = ns.uri || DEFAULT_NS_MAP[prefix] || + namespaces.prefixMap[prefix] || (model ? (model.getPackage(prefix) || {}).uri : null); - try { - parser.write(xml).close(); - } catch (e) { - error = e; - } + if (!uri) { + throw new Error('no namespace uri given for prefix <' + ns.prefix + '>'); + } - done(error, error ? undefined : rootHandler.element, context); - }); - }; + ns = namespaces.uriMap[uri]; - XMLReader.prototype.handler = function(name) { - return new ElementHandler(this.model, name); - }; + if (!ns) { + ns = this.logNamespace({ + prefix: prefix, + uri: uri + }); + } - module.exports = XMLReader; - module.exports.ElementHandler = ElementHandler; - }, { - "./common": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\common.js", - "lodash/collection/find": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\find.js", - "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", - "lodash/collection/reduce": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\reduce.js", - "lodash/function/defer": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\function\\defer.js", - "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", - "moddle": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\index.js", - "moddle/lib/ns": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\lib\\ns.js", - "moddle/lib/types": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\lib\\types.js", - "sax": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\node_modules\\sax\\lib\\sax.js", - "tiny-stack": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\node_modules\\tiny-stack\\lib\\tiny-stack.js" - }], - "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\writer.js": [function(require, module, exports) { - 'use strict'; + if (!namespaces.used[ns.uri]) { + namespaces.used[ns.uri] = ns; + } - var map = require('lodash/collection/map'), - forEach = require('lodash/collection/forEach'), - isString = require('lodash/lang/isString'), - filter = require('lodash/collection/filter'), - assign = require('lodash/object/assign'); + return ns; + }; - var Types = require('moddle/lib/types'), - parseNameNs = require('moddle/lib/ns').parseName, - common = require('./common'), - nameToAlias = common.nameToAlias; + ElementSerializer.prototype.parseAttributes = function(properties) { + var self = this, + element = this.element; - var XML_PREAMBLE = '\n', - ESCAPE_CHARS = /(<|>|'|"|&|\n\r|\n)/g, - DEFAULT_NS_MAP = common.DEFAULT_NS_MAP, - XSI_TYPE = common.XSI_TYPE; + forEach(properties, function(p) { + self.logNamespaceUsed(p.ns); + var value = element.get(p.name); - function nsName(ns) { - if (isString(ns)) { - return ns; - } else { - return (ns.prefix ? ns.prefix + ':' : '') + ns.localName; - } + if (p.isReference) { + value = value.id; } - function getElementNs(ns, descriptor) { - if (descriptor.isGeneric) { - return descriptor.name; - } else { - return assign({ - localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) - }, ns); - } - } + self.addAttribute(self.nsAttributeName(p), value); + }); + }; - function getPropertyNs(ns, descriptor) { - return assign({ - localName: descriptor.ns.localName - }, ns); - } + ElementSerializer.prototype.addAttribute = function(name, value) { + var attrs = this.attrs; - function getSerializableProperties(element) { - var descriptor = element.$descriptor; + if (isString(value)) { + value = escapeAttr(value); + } - return filter(descriptor.properties, function(p) { - var name = p.name; + attrs.push({ + name: name, + value: value + }); + }; + + ElementSerializer.prototype.serializeAttributes = function(writer) { + var attrs = this.attrs, + root = !this.parent, + namespaces = this.namespaces; + + function collectNsAttrs() { + return map(namespaces.used, function(ns) { + var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : ''); + return { + name: name, + value: ns.uri + }; + }); + } - // do not serialize defaults - if (!element.hasOwnProperty(name)) { - return false; - } + if (root) { + attrs = collectNsAttrs().concat(attrs); + } - var value = element[name]; + forEach(attrs, function(a) { + writer + .append(' ') + .append(nsName(a.name)).append('="').append(a.value).append('"'); + }); + }; - // do not serialize default equals - if (value === p.default) { - return false; - } + ElementSerializer.prototype.serializeTo = function(writer) { + var hasBody = this.body.length, + indent = !(this.body.length === 1 && this.body[0] instanceof BodySerializer); - return p.isMany ? value.length : true; - }); - } + writer + .appendIndent() + .append('<' + nsName(this.ns)); - var ESCAPE_MAP = { - '\n': '10', - '\n\r': '10', - '"': '34', - '\'': '39', - '<': '60', - '>': '62', - '&': '38' - }; + this.serializeAttributes(writer); - /** - * Escape a string attribute to not contain any bad values (line breaks, '"', - * ...) - * - * @param {String} - * str the string to escape - * @return {String} the escaped string - */ - function escapeAttr(str) { + writer.append(hasBody ? '>' : ' />'); - // ensure we are handling strings here - str = isString(str) ? str : '' + str; + if (hasBody) { - return str.replace(ESCAPE_CHARS, function(str) { - return '&#' + ESCAPE_MAP[str] + ';'; - }); + if (indent) { + writer + .appendNewLine() + .indent(); } - function filterAttributes(props) { - return filter(props, function(p) { - return p.isAttr; - }); - } + forEach(this.body, function(b) { + b.serializeTo(writer); + }); - function filterContained(props) { - return filter(props, function(p) { - return !p.isAttr; - }); + if (indent) { + writer + .unindent() + .appendIndent(); } + writer.append(''); + } - function ReferenceSerializer(parent, ns) { - this.ns = ns; - } - - ReferenceSerializer.prototype.build = function(element) { - this.element = element; - return this; - }; + writer.appendNewLine(); + }; - ReferenceSerializer.prototype.serializeTo = function(writer) { - writer - .appendIndent() - .append('<' + nsName(this.ns) + '>' + this.element.id + '') - .appendNewLine(); - }; + /** + * A serializer for types that handles serialization of data types + */ + function TypeSerializer(parent, ns) { + ElementSerializer.call(this, parent, ns); + } - function BodySerializer() {} + TypeSerializer.prototype = new ElementSerializer(); - BodySerializer.prototype.serializeValue = BodySerializer.prototype.serializeTo = function(writer) { - var escape = this.escape; + TypeSerializer.prototype.build = function(element) { + var descriptor = element.$descriptor; - if (escape) { - writer.append(''); - } - }; + // add xsi:type attribute to represent the elements + // actual type - BodySerializer.prototype.build = function(prop, value) { - this.value = value; + var typeNs = this.typeNs, + pkg = element.$model.getPackage(typeNs.uri), + typePrefix = (pkg.xml && pkg.xml.typePrefix) || ''; - if (prop.type === 'String' && ESCAPE_CHARS.test(value)) { - this.escape = true; - } + this.addAttribute(this.nsAttributeName(XSI_TYPE), (typeNs.prefix ? typeNs.prefix + ':' : '') + + typePrefix + descriptor.ns.localName); - return this; - }; + // do the usual stuff + return ElementSerializer.prototype.build.call(this, element); + }; - function ValueSerializer(ns) { - this.ns = ns; - } + TypeSerializer.prototype.isLocalNs = function(ns) { + return ns.uri === this.typeNs.uri; + }; - ValueSerializer.prototype = new BodySerializer(); + function SavingWriter() { + this.value = ''; - ValueSerializer.prototype.serializeTo = function(writer) { + this.write = function(str) { + this.value += str; + }; + } - writer - .appendIndent() - .append('<' + nsName(this.ns) + '>'); + function FormatingWriter(out, format) { - this.serializeValue(writer); + var indent = ['']; - writer - .append('') - .appendNewLine(); - }; + this.append = function(str) { + out.write(str); - function ElementSerializer(parent, ns) { - this.body = []; - this.attrs = []; + return this; + }; - this.parent = parent; - this.ns = ns; + this.appendNewLine = function() { + if (format) { + out.write('\n'); } - ElementSerializer.prototype.build = function(element) { - this.element = element; + return this; + }; - var otherAttrs = this.parseNsAttributes(element); + this.appendIndent = function() { + if (format) { + out.write(indent.join(' ')); + } - if (!this.ns) { - this.ns = this.nsTagName(element.$descriptor); - } + return this; + }; - if (element.$descriptor.isGeneric) { - this.parseGeneric(element); - } else { - var properties = getSerializableProperties(element); + this.indent = function() { + indent.push(''); + return this; + }; - this.parseAttributes(filterAttributes(properties)); - this.parseContainments(filterContained(properties)); + this.unindent = function() { + indent.pop(); + return this; + }; + } - this.parseGenericAttributes(element, otherAttrs); - } + /** + * A writer for meta-model backed document trees + * + * @param {Object} + * options output options to pass into the writer + */ + function XMLWriter(options) { + + options = assign({ + format: false, + preamble: true + }, options || {}); + + function toXML(tree, writer) { + var internalWriter = writer || new SavingWriter(); + var formatingWriter = new FormatingWriter(internalWriter, options.format); + + if (options.preamble) { + formatingWriter.append(XML_PREAMBLE); + } - return this; - }; + new ElementSerializer().build(tree).serializeTo(formatingWriter); - ElementSerializer.prototype.nsTagName = function(descriptor) { - var effectiveNs = this.logNamespaceUsed(descriptor.ns); - return getElementNs(effectiveNs, descriptor); - }; + if (!writer) { + return internalWriter.value; + } + } - ElementSerializer.prototype.nsPropertyTagName = function(descriptor) { - var effectiveNs = this.logNamespaceUsed(descriptor.ns); - return getPropertyNs(effectiveNs, descriptor); - }; + return { + toXML: toXML + }; + } - ElementSerializer.prototype.isLocalNs = function(ns) { - return ns.uri === this.ns.uri; - }; + module.exports = XMLWriter; + }, { + "./common": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\lib\\common.js", + "lodash/collection/filter": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\filter.js", + "lodash/collection/forEach": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\forEach.js", + "lodash/collection/map": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\collection\\map.js", + "lodash/lang/isString": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\lang\\isString.js", + "lodash/object/assign": "\\bpmn-js-examples-master\\modeler\\node_modules\\lodash\\object\\assign.js", + "moddle/lib/ns": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\lib\\ns.js", + "moddle/lib/types": "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle\\lib\\types.js" + }], + "\\bpmn-js-examples-master\\modeler\\node_modules\\bpmn-js\\node_modules\\bpmn-moddle\\node_modules\\moddle-xml\\node_modules\\sax\\lib\\sax.js": [function(require, module, exports) { + (function(Buffer) { + // wrapper for non-node envs + ; + (function(sax) { + + sax.parser = function(strict, opt) { + return new SAXParser(strict, opt) + } + sax.SAXParser = SAXParser + sax.SAXStream = SAXStream + sax.createStream = createStream + + // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer + // overruns. + // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer + // lengths)), + // since that's the earliest that a buffer overrun could occur. This way, checks + // are + // as rare as required, but as often as necessary to ensure never crossing this + // bound. + // Furthermore, buffers are only tested at most once per write(), so passing a + // very + // large string into write() might have undesirable effects, but this is + // manageable by + // the caller, so it is assumed to be safe. Thus, a call to write() may, in the + // extreme + // edge case, result in creating at most one complete copy of the string passed + // in. + // Set to Infinity to have unlimited buffers. + sax.MAX_BUFFER_LENGTH = 64 * 1024 + + var buffers = [ + "comment", "sgmlDecl", "textNode", "tagName", "doctype", + "procInstName", "procInstBody", "entity", "attribName", + "attribValue", "cdata", "script" + ] + + sax.EVENTS = // for discoverability. + ["text", "processinginstruction", "sgmldeclaration", "doctype", "comment", "attribute", "opentag", "closetag", "opencdata", "cdata", "closecdata", "error", "end", "ready", "script", "opennamespace", "closenamespace"] + + function SAXParser(strict, opt) { + if (!(this instanceof SAXParser)) return new SAXParser(strict, opt) + + var parser = this + clearBuffers(parser) + parser.q = parser.c = "" + parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH + parser.opt = opt || {} + parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags + parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase" + parser.tags = [] + parser.closed = parser.closedRoot = parser.sawRoot = false + parser.tag = parser.error = null + parser.strict = !!strict + parser.noscript = !!(strict || parser.opt.noscript) + parser.state = S.BEGIN + parser.ENTITIES = Object.create(sax.ENTITIES) + parser.attribList = [] + + // namespaces form a prototype chain. + // it always points at the current tag, + // which protos to its parent tag. + if (parser.opt.xmlns) parser.ns = Object.create(rootNS) + + // mostly just for error reporting + parser.trackPosition = parser.opt.position !== false + if (parser.trackPosition) { + parser.position = parser.line = parser.column = 0 + } + emit(parser, "onready") + } - ElementSerializer.prototype.nsAttributeName = function(element) { + if (!Object.create) Object.create = function(o) { + function f() { + this.__proto__ = o + } + f.prototype = o + return new f + } - var ns; + if (!Object.getPrototypeOf) Object.getPrototypeOf = function(o) { + return o.__proto__ + } - if (isString(element)) { - ns = parseNameNs(element); - } else - if (element.ns) { - ns = element.ns; - } + if (!Object.keys) Object.keys = function(o) { + var a = [] + for (var i in o) + if (o.hasOwnProperty(i)) a.push(i) + return a + } - var effectiveNs = this.logNamespaceUsed(ns); + function checkBufferLength(parser) { + var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10), + maxActual = 0 + for (var i = 0, l = buffers.length; i < l; i++) { + var len = parser[buffers[i]].length + if (len > maxAllowed) { + // Text/cdata nodes can get big, and since they're buffered, + // we can get here under normal conditions. + // Avoid issues by emitting the text node now, + // so at least it won't get any bigger. + switch (buffers[i]) { + case "textNode": + closeText(parser) + break + + case "cdata": + emitNode(parser, "oncdata", parser.cdata) + parser.cdata = "" + break + + case "script": + emitNode(parser, "onscript", parser.script) + parser.script = "" + break - // strip prefix if same namespace like parent - if (this.isLocalNs(effectiveNs)) { - return { - localName: ns.localName - }; - } else { - return assign({ - localName: ns.localName - }, effectiveNs); + default: + error(parser, "Max buffer length exceeded: " + buffers[i]) + } } - }; - - ElementSerializer.prototype.parseGeneric = function(element) { - - var self = this, - body = this.body, - attrs = this.attrs; - - forEach(element, function(val, key) { + maxActual = Math.max(maxActual, len) + } + // schedule the next check for the earliest possible buffer overrun. + parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual) + parser.position + } - if (key === '$body') { - body.push(new BodySerializer().build({ - type: 'String' - }, val)); - } else - if (key === '$children') { - forEach(val, function(child) { - body.push(new ElementSerializer(self).build(child)); - }); - } else - if (key.indexOf('$') !== 0) { - attrs.push({ - name: key, - value: escapeAttr(val) - }); - } - }); - }; + function clearBuffers(parser) { + for (var i = 0, l = buffers.length; i < l; i++) { + parser[buffers[i]] = "" + } + } - /** - * Parse namespaces and return a list of left over generic attributes - * - * @param {Object} - * element - * @return {Array} - */ - ElementSerializer.prototype.parseNsAttributes = function(element) { - var self = this; + function flushBuffers(parser) { + closeText(parser) + if (parser.cdata !== "") { + emitNode(parser, "oncdata", parser.cdata) + parser.cdata = "" + } + if (parser.script !== "") { + emitNode(parser, "onscript", parser.script) + parser.script = "" + } + } - var genericAttrs = element.$attrs; + SAXParser.prototype = { + end: function() { + end(this) + }, + write: write, + resume: function() { + this.error = null; + return this + }, + close: function() { + return this.write(null) + }, + flush: function() { + flushBuffers(this) + } + } - var attributes = []; + try { + var Stream = require("stream").Stream + } catch (ex) { + var Stream = function() {} + } - // parse namespace attributes first - // and log them. push non namespace attributes to a list - // and process them later - forEach(genericAttrs, function(value, name) { - var nameNs = parseNameNs(name); - if (nameNs.prefix === 'xmlns') { - self.logNamespace({ - prefix: nameNs.localName, - uri: value - }); - } else - if (!nameNs.prefix && nameNs.localName === 'xmlns') { - self.logNamespace({ - uri: value - }); - } else { - attributes.push({ - name: name, - value: value - }); - } - }); + var streamWraps = sax.EVENTS.filter(function(ev) { + return ev !== "error" && ev !== "end" + }) - return attributes; - }; + function createStream(strict, opt) { + return new SAXStream(strict, opt) + } - ElementSerializer.prototype.parseGenericAttributes = function(element, attributes) { + function SAXStream(strict, opt) { + if (!(this instanceof SAXStream)) return new SAXStream(strict, opt) - var self = this; + Stream.apply(this) - forEach(attributes, function(attr) { + this._parser = new SAXParser(strict, opt) + this.writable = true + this.readable = true - // do not serialize xsi:type attribute - // it is set manually based on the actual implementation type - if (attr.name === XSI_TYPE) { - return; - } - try { - self.addAttribute(self.nsAttributeName(attr.name), attr.value); - } catch (e) { - console.warn('[writer] missing namespace information for ', attr.name, '=', attr.value, 'on', element, e); - } - }); - }; + var me = this - ElementSerializer.prototype.parseContainments = function(properties) { + this._parser.onend = function() { + me.emit("end") + } - var self = this, - body = this.body, - element = this.element; + this._parser.onerror = function(er) { + me.emit("error", er) - forEach(properties, function(p) { - var value = element.get(p.name), - isReference = p.isReference, - isMany = p.isMany; + // if didn't throw, then means error was handled. + // go ahead and clear error, so we can write again. + me._parser.error = null + } - var ns = self.nsPropertyTagName(p); + this._decoder = null; - if (!isMany) { - value = [value]; - } + streamWraps.forEach(function(ev) { + Object.defineProperty(me, "on" + ev, { + get: function() { + return me._parser["on" + ev] + }, + set: function(h) { + if (!h) { + me.removeAllListeners(ev) + return me._parser["on" + ev] = h + } + me.on(ev, h) + }, + enumerable: true, + configurable: false + }) + }) + } - if (p.isBody) { - body.push(new BodySerializer().build(p, value[0])); - } else - if (Types.isSimple(p.type)) { - forEach(value, function(v) { - body.push(new ValueSerializer(ns).build(p, v)); - }); - } else - if (isReference) { - forEach(value, function(v) { - body.push(new ReferenceSerializer(self, ns).build(v)); - }); - } else { - // allow serialization via type - // rather than element name - var asType = p.serialize === XSI_TYPE; + SAXStream.prototype = Object.create(Stream.prototype, { + constructor: { + value: SAXStream + } + }) - forEach(value, function(v) { - var serializer; + SAXStream.prototype.write = function(data) { + if (typeof Buffer === 'function' && + typeof Buffer.isBuffer === 'function' && + Buffer.isBuffer(data)) { + if (!this._decoder) { + var SD = require('string_decoder').StringDecoder + this._decoder = new SD('utf8') + } + data = this._decoder.write(data); + } - if (asType) { - serializer = new TypeSerializer(self, ns); - } else { - serializer = new ElementSerializer(self); - } + this._parser.write(data.toString()) + this.emit("data", data) + return true + } - body.push(serializer.build(v)); - }); - } - }); - }; + SAXStream.prototype.end = function(chunk) { + if (chunk && chunk.length) this.write(chunk) + this._parser.end() + return true + } - ElementSerializer.prototype.getNamespaces = function() { - if (!this.parent) { - if (!this.namespaces) { - this.namespaces = { - prefixMap: {}, - uriMap: {}, - used: {} - }; - } - } else { - this.namespaces = this.parent.getNamespaces(); + SAXStream.prototype.on = function(ev, handler) { + var me = this + if (!me._parser["on" + ev] && streamWraps.indexOf(ev) !== -1) { + me._parser["on" + ev] = function() { + var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments) + args.splice(0, 0, ev) + me.emit.apply(me, args) } + } - return this.namespaces; - }; + return Stream.prototype.on.call(me, ev, handler) + } - ElementSerializer.prototype.logNamespace = function(ns) { - var namespaces = this.getNamespaces(); - var existing = namespaces.uriMap[ns.uri]; - if (!existing) { - namespaces.uriMap[ns.uri] = ns; - } + // character classes and tokens + var whitespace = "\r\n\t " + // this really needs to be replaced with character classes. + // XML allows all manner of ridiculous numbers and digits. + , + number = "0124356789", + letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + // (Letter | "_" | ":") + , + quote = "'\"", + entity = number + letter + "#", + attribEnd = whitespace + ">", + CDATA = "[CDATA[", + DOCTYPE = "DOCTYPE", + XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace", + XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/", + rootNS = { + xml: XML_NAMESPACE, + xmlns: XMLNS_NAMESPACE + } - namespaces.prefixMap[ns.prefix] = ns.uri; + // turn all the string character sets into character class objects. + whitespace = charClass(whitespace) + number = charClass(number) + letter = charClass(letter) + + // http://www.w3.org/TR/REC-xml/#NT-NameStartChar + // This implementation works on strings, a single character at a time + // as such, it cannot ever support astral-plane characters (10000-EFFFF) + // without a significant breaking change to either this parser, or the + // JavaScript language. Implementation of an emoji-capable xml parser + // is left as an exercise for the reader. + var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ + + var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/ + + quote = charClass(quote) + entity = charClass(entity) + attribEnd = charClass(attribEnd) + + function charClass(str) { + return str.split("").reduce(function(s, c) { + s[c] = true + return s + }, {}) + } - return ns; - }; + function isRegExp(c) { + return Object.prototype.toString.call(c) === '[object RegExp]' + } - ElementSerializer.prototype.logNamespaceUsed = function(ns) { - var element = this.element, - model = element.$model, - namespaces = this.getNamespaces(); + function is(charclass, c) { + return isRegExp(charclass) ? !!c.match(charclass) : charclass[c] + } - // ns may be - // - // * prefix only - // * prefix:uri + function not(charclass, c) { + return !is(charclass, c) + } - var prefix = ns.prefix; - var uri = ns.uri || DEFAULT_NS_MAP[prefix] || - namespaces.prefixMap[prefix] || (model ? (model.getPackage(prefix) || {}).uri : null); + var S = 0 + sax.STATE = { + BEGIN: S++, + TEXT: S++ // general stuff + , + TEXT_ENTITY: S++ // & and such. + , + OPEN_WAKA: S++ // < + , + SGML_DECL: S++ // + , + SCRIPT: S++ //