1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | (function (global, factory) {
|
14 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
15 | typeof define === 'function' && define.amd ? define(factory) :
|
16 | (global.BpmnJS = factory());
|
17 | }(this, (function () { 'use strict';
|
18 |
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | var nativeToString = Object.prototype.toString;
|
28 | var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
|
29 |
|
30 | function isUndefined(obj) {
|
31 | return obj === undefined;
|
32 | }
|
33 |
|
34 | function isDefined(obj) {
|
35 | return obj !== undefined;
|
36 | }
|
37 |
|
38 | function isArray(obj) {
|
39 | return nativeToString.call(obj) === '[object Array]';
|
40 | }
|
41 |
|
42 | function isObject(obj) {
|
43 | return nativeToString.call(obj) === '[object Object]';
|
44 | }
|
45 |
|
46 | function isNumber(obj) {
|
47 | return nativeToString.call(obj) === '[object Number]';
|
48 | }
|
49 |
|
50 | function isFunction(obj) {
|
51 | return nativeToString.call(obj) === '[object Function]';
|
52 | }
|
53 |
|
54 | function isString(obj) {
|
55 | return nativeToString.call(obj) === '[object String]';
|
56 | }
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | function has(target, key) {
|
67 | return nativeHasOwnProperty.call(target, key);
|
68 | }
|
69 |
|
70 | |
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | function find(collection, matcher) {
|
79 |
|
80 | matcher = toMatcher(matcher);
|
81 |
|
82 | var match;
|
83 |
|
84 | forEach(collection, function (val, key) {
|
85 | if (matcher(val, key)) {
|
86 | match = val;
|
87 |
|
88 | return false;
|
89 | }
|
90 | });
|
91 |
|
92 | return match;
|
93 | }
|
94 |
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | function filter(collection, matcher) {
|
104 |
|
105 | var result = [];
|
106 |
|
107 | forEach(collection, function (val, key) {
|
108 | if (matcher(val, key)) {
|
109 | result.push(val);
|
110 | }
|
111 | });
|
112 |
|
113 | return result;
|
114 | }
|
115 |
|
116 | |
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 | function forEach(collection, iterator) {
|
126 |
|
127 | if (isUndefined(collection)) {
|
128 | return;
|
129 | }
|
130 |
|
131 | var convertKey = isArray(collection) ? toNum : identity;
|
132 |
|
133 | for (var key in collection) {
|
134 |
|
135 | if (has(collection, key)) {
|
136 | var val = collection[key];
|
137 |
|
138 | var result = iterator(val, convertKey(key));
|
139 |
|
140 | if (result === false) {
|
141 | return;
|
142 | }
|
143 | }
|
144 | }
|
145 | }
|
146 |
|
147 | |
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | function reduce(collection, iterator, result) {
|
157 |
|
158 | forEach(collection, function (value, idx) {
|
159 | result = iterator(result, value, idx);
|
160 | });
|
161 |
|
162 | return result;
|
163 | }
|
164 |
|
165 | |
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 | function every(collection, matcher) {
|
175 |
|
176 | return reduce(collection, function (matches, val, key) {
|
177 | return matches && matcher(val, key);
|
178 | }, true);
|
179 | }
|
180 |
|
181 | |
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | function some(collection, matcher) {
|
191 |
|
192 | return !!find(collection, matcher);
|
193 | }
|
194 |
|
195 | |
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 | function map(collection, fn) {
|
205 |
|
206 | var result = [];
|
207 |
|
208 | forEach(collection, function (val, key) {
|
209 | result.push(fn(val, key));
|
210 | });
|
211 |
|
212 | return result;
|
213 | }
|
214 |
|
215 | |
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 | function matchPattern(pattern) {
|
229 |
|
230 | return function (el) {
|
231 |
|
232 | return every(pattern, function (val, key) {
|
233 | return el[key] === val;
|
234 | });
|
235 | };
|
236 | }
|
237 |
|
238 | function toMatcher(matcher) {
|
239 | return isFunction(matcher) ? matcher : function (e) {
|
240 | return e === matcher;
|
241 | };
|
242 | }
|
243 |
|
244 | function identity(arg) {
|
245 | return arg;
|
246 | }
|
247 |
|
248 | function toNum(arg) {
|
249 | return Number(arg);
|
250 | }
|
251 |
|
252 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
253 |
|
254 | var slice = Array.prototype.slice;
|
255 |
|
256 | |
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | function debounce(fn, timeout) {
|
266 |
|
267 | var timer;
|
268 |
|
269 | return function () {
|
270 |
|
271 | var args = slice.call(arguments);
|
272 |
|
273 | if (timer) {
|
274 | clearTimeout(timer);
|
275 | }
|
276 |
|
277 | timer = setTimeout(function () {
|
278 | fn.apply(undefined, _toConsumableArray(args));
|
279 | }, timeout);
|
280 | };
|
281 | }
|
282 |
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 | function bind(fn, target) {
|
292 | return fn.bind(target);
|
293 | }
|
294 |
|
295 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
296 |
|
297 | |
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | function assign(target) {
|
306 | for (var _len = arguments.length, others = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
307 | others[_key - 1] = arguments[_key];
|
308 | }
|
309 |
|
310 | return _extends.apply(undefined, [target].concat(others));
|
311 | }
|
312 |
|
313 | |
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 | function pick(target, properties) {
|
322 |
|
323 | var result = {};
|
324 |
|
325 | var obj = Object(target);
|
326 |
|
327 | forEach(properties, function (prop) {
|
328 |
|
329 | if (prop in obj) {
|
330 | result[prop] = target[prop];
|
331 | }
|
332 | });
|
333 |
|
334 | return result;
|
335 | }
|
336 |
|
337 | |
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | function omit(target, properties) {
|
346 |
|
347 | var result = {};
|
348 |
|
349 | var obj = Object(target);
|
350 |
|
351 | forEach(obj, function (prop, key) {
|
352 |
|
353 | if (properties.indexOf(key) === -1) {
|
354 | result[key] = prop;
|
355 | }
|
356 | });
|
357 |
|
358 | return result;
|
359 | }
|
360 |
|
361 | |
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 | function attr(el, name, val) {
|
370 |
|
371 | if (arguments.length == 2) {
|
372 | return el.getAttribute(name);
|
373 | }
|
374 |
|
375 |
|
376 | if (val === null) {
|
377 | return el.removeAttribute(name);
|
378 | }
|
379 |
|
380 |
|
381 | el.setAttribute(name, val);
|
382 |
|
383 | return el;
|
384 | }
|
385 |
|
386 | var indexOf = [].indexOf;
|
387 |
|
388 | var indexof = function(arr, obj){
|
389 | if (indexOf) return arr.indexOf(obj);
|
390 | for (var i = 0; i < arr.length; ++i) {
|
391 | if (arr[i] === obj) return i;
|
392 | }
|
393 | return -1;
|
394 | };
|
395 |
|
396 | |
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 | |
403 |
|
404 |
|
405 |
|
406 | var re = /\s+/;
|
407 |
|
408 | |
409 |
|
410 |
|
411 |
|
412 | var toString = Object.prototype.toString;
|
413 |
|
414 | |
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | function classes(el) {
|
423 | return new ClassList(el);
|
424 | }
|
425 |
|
426 | |
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 | function ClassList(el) {
|
434 | if (!el || !el.nodeType) {
|
435 | throw new Error('A DOM element reference is required');
|
436 | }
|
437 | this.el = el;
|
438 | this.list = el.classList;
|
439 | }
|
440 |
|
441 | |
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 | ClassList.prototype.add = function (name) {
|
450 |
|
451 | if (this.list) {
|
452 | this.list.add(name);
|
453 | return this;
|
454 | }
|
455 |
|
456 |
|
457 | var arr = this.array();
|
458 | var i = indexof(arr, name);
|
459 | if (!~i) arr.push(name);
|
460 | this.el.className = arr.join(' ');
|
461 | return this;
|
462 | };
|
463 |
|
464 | |
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 | ClassList.prototype.remove = function (name) {
|
475 | if ('[object RegExp]' == toString.call(name)) {
|
476 | return this.removeMatching(name);
|
477 | }
|
478 |
|
479 |
|
480 | if (this.list) {
|
481 | this.list.remove(name);
|
482 | return this;
|
483 | }
|
484 |
|
485 |
|
486 | var arr = this.array();
|
487 | var i = indexof(arr, name);
|
488 | if (~i) arr.splice(i, 1);
|
489 | this.el.className = arr.join(' ');
|
490 | return this;
|
491 | };
|
492 |
|
493 | |
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 | ClassList.prototype.removeMatching = function (re) {
|
502 | var arr = this.array();
|
503 | for (var i = 0; i < arr.length; i++) {
|
504 | if (re.test(arr[i])) {
|
505 | this.remove(arr[i]);
|
506 | }
|
507 | }
|
508 | return this;
|
509 | };
|
510 |
|
511 | |
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 | ClassList.prototype.toggle = function (name, force) {
|
524 |
|
525 | if (this.list) {
|
526 | if ('undefined' !== typeof force) {
|
527 | if (force !== this.list.toggle(name, force)) {
|
528 | this.list.toggle(name);
|
529 | }
|
530 | } else {
|
531 | this.list.toggle(name);
|
532 | }
|
533 | return this;
|
534 | }
|
535 |
|
536 |
|
537 | if ('undefined' !== typeof force) {
|
538 | if (!force) {
|
539 | this.remove(name);
|
540 | } else {
|
541 | this.add(name);
|
542 | }
|
543 | } else {
|
544 | if (this.has(name)) {
|
545 | this.remove(name);
|
546 | } else {
|
547 | this.add(name);
|
548 | }
|
549 | }
|
550 |
|
551 | return this;
|
552 | };
|
553 |
|
554 | |
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 | ClassList.prototype.array = function () {
|
562 | var className = this.el.getAttribute('class') || '';
|
563 | var str = className.replace(/^\s+|\s+$/g, '');
|
564 | var arr = str.split(re);
|
565 | if ('' === arr[0]) arr.shift();
|
566 | return arr;
|
567 | };
|
568 |
|
569 | |
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 | ClassList.prototype.has = ClassList.prototype.contains = function (name) {
|
578 | return this.list ? this.list.contains(name) : !!~indexof(this.array(), name);
|
579 | };
|
580 |
|
581 | |
582 |
|
583 |
|
584 | function clear(el) {
|
585 |
|
586 | var c;
|
587 |
|
588 | while (el.childNodes.length) {
|
589 | c = el.childNodes[0];
|
590 | el.removeChild(c);
|
591 | }
|
592 |
|
593 | return el;
|
594 | }
|
595 |
|
596 | |
597 |
|
598 |
|
599 |
|
600 | var proto = Element.prototype;
|
601 |
|
602 | |
603 |
|
604 |
|
605 |
|
606 | var vendor = proto.matchesSelector
|
607 | || proto.webkitMatchesSelector
|
608 | || proto.mozMatchesSelector
|
609 | || proto.msMatchesSelector
|
610 | || proto.oMatchesSelector;
|
611 |
|
612 | |
613 |
|
614 |
|
615 |
|
616 | var matchesSelector = match;
|
617 |
|
618 | |
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 | function match(el, selector) {
|
628 | if (vendor) return vendor.call(el, selector);
|
629 | var nodes = el.parentNode.querySelectorAll(selector);
|
630 | for (var i = 0; i < nodes.length; ++i) {
|
631 | if (nodes[i] == el) return true;
|
632 | }
|
633 | return false;
|
634 | }
|
635 |
|
636 | var closest = function (element, selector, checkYoSelf) {
|
637 | var parent = checkYoSelf ? element : element.parentNode;
|
638 |
|
639 | while (parent && parent !== document) {
|
640 | if (matchesSelector(parent, selector)) return parent;
|
641 | parent = parent.parentNode;
|
642 | }
|
643 | };
|
644 |
|
645 | var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent',
|
646 | unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
|
647 | prefix = bind$1 !== 'addEventListener' ? 'on' : '';
|
648 |
|
649 | |
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 | var bind_1 = function(el, type, fn, capture){
|
661 | el[bind$1](prefix + type, fn, capture || false);
|
662 | return fn;
|
663 | };
|
664 |
|
665 | |
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 | var unbind_1 = function(el, type, fn, capture){
|
677 | el[unbind](prefix + type, fn, capture || false);
|
678 | return fn;
|
679 | };
|
680 |
|
681 | var componentEvent = {
|
682 | bind: bind_1,
|
683 | unbind: unbind_1
|
684 | };
|
685 |
|
686 | |
687 |
|
688 |
|
689 |
|
690 |
|
691 |
|
692 | |
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 | var forceCaptureEvents = ['focus', 'blur'];
|
709 |
|
710 | var bind$1$1 = function(el, selector, type, fn, capture){
|
711 | if (forceCaptureEvents.indexOf(type) !== -1) capture = true;
|
712 |
|
713 | return componentEvent.bind(el, type, function(e){
|
714 | var target = e.target || e.srcElement;
|
715 | e.delegateTarget = closest(target, selector, true, el);
|
716 | if (e.delegateTarget) fn.call(el, e);
|
717 | }, capture);
|
718 | };
|
719 |
|
720 | |
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 | var unbind$1 = function(el, type, fn, capture){
|
731 | if (forceCaptureEvents.indexOf(type) !== -1) capture = true;
|
732 |
|
733 | componentEvent.unbind(el, type, fn, capture);
|
734 | };
|
735 |
|
736 | var delegateEvents = {
|
737 | bind: bind$1$1,
|
738 | unbind: unbind$1
|
739 | };
|
740 |
|
741 | |
742 |
|
743 |
|
744 |
|
745 | var domify = parse;
|
746 |
|
747 | |
748 |
|
749 |
|
750 |
|
751 | var innerHTMLBug = false;
|
752 | var bugTestDiv;
|
753 | if (typeof document !== 'undefined') {
|
754 | bugTestDiv = document.createElement('div');
|
755 |
|
756 | bugTestDiv.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>';
|
757 |
|
758 |
|
759 | innerHTMLBug = !bugTestDiv.getElementsByTagName('link').length;
|
760 | bugTestDiv = undefined;
|
761 | }
|
762 |
|
763 | |
764 |
|
765 |
|
766 |
|
767 | var map$1 = {
|
768 | legend: [1, '<fieldset>', '</fieldset>'],
|
769 | tr: [2, '<table><tbody>', '</tbody></table>'],
|
770 | col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
|
771 |
|
772 |
|
773 | _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', '']
|
774 | };
|
775 |
|
776 | map$1.td =
|
777 | map$1.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
|
778 |
|
779 | map$1.option =
|
780 | map$1.optgroup = [1, '<select multiple="multiple">', '</select>'];
|
781 |
|
782 | map$1.thead =
|
783 | map$1.tbody =
|
784 | map$1.colgroup =
|
785 | map$1.caption =
|
786 | map$1.tfoot = [1, '<table>', '</table>'];
|
787 |
|
788 | map$1.polyline =
|
789 | map$1.ellipse =
|
790 | map$1.polygon =
|
791 | map$1.circle =
|
792 | map$1.text =
|
793 | map$1.line =
|
794 | map$1.path =
|
795 | map$1.rect =
|
796 | map$1.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>'];
|
797 |
|
798 | |
799 |
|
800 |
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 | function parse(html, doc) {
|
810 | if ('string' != typeof html) throw new TypeError('String expected');
|
811 |
|
812 |
|
813 | if (!doc) doc = document;
|
814 |
|
815 |
|
816 | var m = /<([\w:]+)/.exec(html);
|
817 | if (!m) return doc.createTextNode(html);
|
818 |
|
819 | html = html.replace(/^\s+|\s+$/g, '');
|
820 |
|
821 | var tag = m[1];
|
822 |
|
823 |
|
824 | if (tag == 'body') {
|
825 | var el = doc.createElement('html');
|
826 | el.innerHTML = html;
|
827 | return el.removeChild(el.lastChild);
|
828 | }
|
829 |
|
830 |
|
831 | var wrap = map$1[tag] || map$1._default;
|
832 | var depth = wrap[0];
|
833 | var prefix = wrap[1];
|
834 | var suffix = wrap[2];
|
835 | var el = doc.createElement('div');
|
836 | el.innerHTML = prefix + html + suffix;
|
837 | while (depth--) el = el.lastChild;
|
838 |
|
839 |
|
840 | if (el.firstChild == el.lastChild) {
|
841 | return el.removeChild(el.firstChild);
|
842 | }
|
843 |
|
844 |
|
845 | var fragment = doc.createDocumentFragment();
|
846 | while (el.firstChild) {
|
847 | fragment.appendChild(el.removeChild(el.firstChild));
|
848 | }
|
849 |
|
850 | return fragment;
|
851 | }
|
852 |
|
853 | var proto$1 = typeof Element !== 'undefined' ? Element.prototype : {};
|
854 | var vendor$1 = proto$1.matches
|
855 | || proto$1.matchesSelector
|
856 | || proto$1.webkitMatchesSelector
|
857 | || proto$1.mozMatchesSelector
|
858 | || proto$1.msMatchesSelector
|
859 | || proto$1.oMatchesSelector;
|
860 |
|
861 | function query(selector, el) {
|
862 | el = el || document;
|
863 |
|
864 | return el.querySelector(selector);
|
865 | }
|
866 |
|
867 | function remove(el) {
|
868 | el.parentNode && el.parentNode.removeChild(el);
|
869 | }
|
870 |
|
871 | function ensureImported(element, target) {
|
872 |
|
873 | if (element.ownerDocument !== target.ownerDocument) {
|
874 | try {
|
875 |
|
876 | return target.ownerDocument.importNode(element, true);
|
877 | } catch (e) {
|
878 |
|
879 | }
|
880 | }
|
881 |
|
882 | return element;
|
883 | }
|
884 |
|
885 | |
886 |
|
887 |
|
888 |
|
889 | |
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 | function appendTo(element, target) {
|
898 | return target.appendChild(ensureImported(element, target));
|
899 | }
|
900 |
|
901 | |
902 |
|
903 |
|
904 |
|
905 | |
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 | function append(target, node) {
|
914 | appendTo(node, target);
|
915 | return target;
|
916 | }
|
917 |
|
918 | |
919 |
|
920 |
|
921 |
|
922 | var LENGTH_ATTR = 2;
|
923 |
|
924 | var CSS_PROPERTIES = {
|
925 | 'alignment-baseline': 1,
|
926 | 'baseline-shift': 1,
|
927 | 'clip': 1,
|
928 | 'clip-path': 1,
|
929 | 'clip-rule': 1,
|
930 | 'color': 1,
|
931 | 'color-interpolation': 1,
|
932 | 'color-interpolation-filters': 1,
|
933 | 'color-profile': 1,
|
934 | 'color-rendering': 1,
|
935 | 'cursor': 1,
|
936 | 'direction': 1,
|
937 | 'display': 1,
|
938 | 'dominant-baseline': 1,
|
939 | 'enable-background': 1,
|
940 | 'fill': 1,
|
941 | 'fill-opacity': 1,
|
942 | 'fill-rule': 1,
|
943 | 'filter': 1,
|
944 | 'flood-color': 1,
|
945 | 'flood-opacity': 1,
|
946 | 'font': 1,
|
947 | 'font-family': 1,
|
948 | 'font-size': LENGTH_ATTR,
|
949 | 'font-size-adjust': 1,
|
950 | 'font-stretch': 1,
|
951 | 'font-style': 1,
|
952 | 'font-variant': 1,
|
953 | 'font-weight': 1,
|
954 | 'glyph-orientation-horizontal': 1,
|
955 | 'glyph-orientation-vertical': 1,
|
956 | 'image-rendering': 1,
|
957 | 'kerning': 1,
|
958 | 'letter-spacing': 1,
|
959 | 'lighting-color': 1,
|
960 | 'marker': 1,
|
961 | 'marker-end': 1,
|
962 | 'marker-mid': 1,
|
963 | 'marker-start': 1,
|
964 | 'mask': 1,
|
965 | 'opacity': 1,
|
966 | 'overflow': 1,
|
967 | 'pointer-events': 1,
|
968 | 'shape-rendering': 1,
|
969 | 'stop-color': 1,
|
970 | 'stop-opacity': 1,
|
971 | 'stroke': 1,
|
972 | 'stroke-dasharray': 1,
|
973 | 'stroke-dashoffset': 1,
|
974 | 'stroke-linecap': 1,
|
975 | 'stroke-linejoin': 1,
|
976 | 'stroke-miterlimit': 1,
|
977 | 'stroke-opacity': 1,
|
978 | 'stroke-width': LENGTH_ATTR,
|
979 | 'text-anchor': 1,
|
980 | 'text-decoration': 1,
|
981 | 'text-rendering': 1,
|
982 | 'unicode-bidi': 1,
|
983 | 'visibility': 1,
|
984 | 'word-spacing': 1,
|
985 | 'writing-mode': 1
|
986 | };
|
987 |
|
988 |
|
989 | function getAttribute(node, name) {
|
990 | if (CSS_PROPERTIES[name]) {
|
991 | return node.style[name];
|
992 | } else {
|
993 | return node.getAttributeNS(null, name);
|
994 | }
|
995 | }
|
996 |
|
997 | function setAttribute(node, name, value) {
|
998 | var hyphenated = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
999 |
|
1000 | var type = CSS_PROPERTIES[hyphenated];
|
1001 |
|
1002 | if (type) {
|
1003 |
|
1004 | if (type === LENGTH_ATTR && typeof value === 'number') {
|
1005 | value = String(value) + 'px';
|
1006 | }
|
1007 |
|
1008 | node.style[hyphenated] = value;
|
1009 | } else {
|
1010 | node.setAttributeNS(null, name, value);
|
1011 | }
|
1012 | }
|
1013 |
|
1014 | function setAttributes(node, attrs) {
|
1015 |
|
1016 | var names = Object.keys(attrs), i, name;
|
1017 |
|
1018 | for (i = 0, name; (name = names[i]); i++) {
|
1019 | setAttribute(node, name, attrs[name]);
|
1020 | }
|
1021 | }
|
1022 |
|
1023 | |
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 | function attr$1(node, name, value) {
|
1034 | if (typeof name === 'string') {
|
1035 | if (value !== undefined) {
|
1036 | setAttribute(node, name, value);
|
1037 | } else {
|
1038 | return getAttribute(node, name);
|
1039 | }
|
1040 | } else {
|
1041 | setAttributes(node, name);
|
1042 | }
|
1043 |
|
1044 | return node;
|
1045 | }
|
1046 |
|
1047 | |
1048 |
|
1049 |
|
1050 | function index(arr, obj) {
|
1051 | if (arr.indexOf) {
|
1052 | return arr.indexOf(obj);
|
1053 | }
|
1054 |
|
1055 |
|
1056 | for (var i = 0; i < arr.length; ++i) {
|
1057 | if (arr[i] === obj) {
|
1058 | return i;
|
1059 | }
|
1060 | }
|
1061 |
|
1062 | return -1;
|
1063 | }
|
1064 |
|
1065 | var re$1 = /\s+/;
|
1066 |
|
1067 | var toString$1 = Object.prototype.toString;
|
1068 |
|
1069 | function defined(o) {
|
1070 | return typeof o !== 'undefined';
|
1071 | }
|
1072 |
|
1073 | |
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 | function classes$1(el) {
|
1082 | return new ClassList$1(el);
|
1083 | }
|
1084 |
|
1085 | function ClassList$1(el) {
|
1086 | if (!el || !el.nodeType) {
|
1087 | throw new Error('A DOM element reference is required');
|
1088 | }
|
1089 | this.el = el;
|
1090 | this.list = el.classList;
|
1091 | }
|
1092 |
|
1093 | |
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 | ClassList$1.prototype.add = function(name) {
|
1102 |
|
1103 |
|
1104 | if (this.list) {
|
1105 | this.list.add(name);
|
1106 | return this;
|
1107 | }
|
1108 |
|
1109 |
|
1110 | var arr = this.array();
|
1111 | var i = index(arr, name);
|
1112 | if (!~i) {
|
1113 | arr.push(name);
|
1114 | }
|
1115 |
|
1116 | if (defined(this.el.className.baseVal)) {
|
1117 | this.el.className.baseVal = arr.join(' ');
|
1118 | } else {
|
1119 | this.el.className = arr.join(' ');
|
1120 | }
|
1121 |
|
1122 | return this;
|
1123 | };
|
1124 |
|
1125 | |
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 | ClassList$1.prototype.remove = function(name) {
|
1136 | if ('[object RegExp]' === toString$1.call(name)) {
|
1137 | return this.removeMatching(name);
|
1138 | }
|
1139 |
|
1140 |
|
1141 | if (this.list) {
|
1142 | this.list.remove(name);
|
1143 | return this;
|
1144 | }
|
1145 |
|
1146 |
|
1147 | var arr = this.array();
|
1148 | var i = index(arr, name);
|
1149 | if (~i) {
|
1150 | arr.splice(i, 1);
|
1151 | }
|
1152 | this.el.className.baseVal = arr.join(' ');
|
1153 | return this;
|
1154 | };
|
1155 |
|
1156 | |
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 | ClassList$1.prototype.removeMatching = function(re) {
|
1165 | var arr = this.array();
|
1166 | for (var i = 0; i < arr.length; i++) {
|
1167 | if (re.test(arr[i])) {
|
1168 | this.remove(arr[i]);
|
1169 | }
|
1170 | }
|
1171 | return this;
|
1172 | };
|
1173 |
|
1174 | |
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 | ClassList$1.prototype.toggle = function(name, force) {
|
1187 |
|
1188 | if (this.list) {
|
1189 | if (defined(force)) {
|
1190 | if (force !== this.list.toggle(name, force)) {
|
1191 | this.list.toggle(name);
|
1192 | }
|
1193 | } else {
|
1194 | this.list.toggle(name);
|
1195 | }
|
1196 | return this;
|
1197 | }
|
1198 |
|
1199 |
|
1200 | if (defined(force)) {
|
1201 | if (!force) {
|
1202 | this.remove(name);
|
1203 | } else {
|
1204 | this.add(name);
|
1205 | }
|
1206 | } else {
|
1207 | if (this.has(name)) {
|
1208 | this.remove(name);
|
1209 | } else {
|
1210 | this.add(name);
|
1211 | }
|
1212 | }
|
1213 |
|
1214 | return this;
|
1215 | };
|
1216 |
|
1217 | |
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 | ClassList$1.prototype.array = function() {
|
1225 | var className = this.el.getAttribute('class') || '';
|
1226 | var str = className.replace(/^\s+|\s+$/g, '');
|
1227 | var arr = str.split(re$1);
|
1228 | if ('' === arr[0]) {
|
1229 | arr.shift();
|
1230 | }
|
1231 | return arr;
|
1232 | };
|
1233 |
|
1234 | |
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 | ClassList$1.prototype.has =
|
1243 | ClassList$1.prototype.contains = function(name) {
|
1244 | return (
|
1245 | this.list ?
|
1246 | this.list.contains(name) :
|
1247 | !! ~index(this.array(), name)
|
1248 | );
|
1249 | };
|
1250 |
|
1251 | function remove$1(element) {
|
1252 | var parent = element.parentNode;
|
1253 |
|
1254 | if (parent) {
|
1255 | parent.removeChild(element);
|
1256 | }
|
1257 |
|
1258 | return element;
|
1259 | }
|
1260 |
|
1261 | |
1262 |
|
1263 |
|
1264 |
|
1265 | |
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | function clear$1(element) {
|
1272 | var child;
|
1273 |
|
1274 | while ((child = element.firstChild)) {
|
1275 | remove$1(child);
|
1276 | }
|
1277 |
|
1278 | return element;
|
1279 | }
|
1280 |
|
1281 | var ns = {
|
1282 | svg: 'http://www.w3.org/2000/svg'
|
1283 | };
|
1284 |
|
1285 | |
1286 |
|
1287 |
|
1288 |
|
1289 | var SVG_START = '<svg xmlns="' + ns.svg + '"';
|
1290 |
|
1291 | function parse$1(svg) {
|
1292 |
|
1293 | var unwrap = false;
|
1294 |
|
1295 |
|
1296 | if (svg.substring(0, 4) === '<svg') {
|
1297 | if (svg.indexOf(ns.svg) === -1) {
|
1298 | svg = SVG_START + svg.substring(4);
|
1299 | }
|
1300 | } else {
|
1301 |
|
1302 | svg = SVG_START + '>' + svg + '</svg>';
|
1303 | unwrap = true;
|
1304 | }
|
1305 |
|
1306 | var parsed = parseDocument(svg);
|
1307 |
|
1308 | if (!unwrap) {
|
1309 | return parsed;
|
1310 | }
|
1311 |
|
1312 | var fragment = document.createDocumentFragment();
|
1313 |
|
1314 | var parent = parsed.firstChild;
|
1315 |
|
1316 | while (parent.firstChild) {
|
1317 | fragment.appendChild(parent.firstChild);
|
1318 | }
|
1319 |
|
1320 | return fragment;
|
1321 | }
|
1322 |
|
1323 | function parseDocument(svg) {
|
1324 |
|
1325 | var parser;
|
1326 |
|
1327 |
|
1328 | parser = new DOMParser();
|
1329 | parser.async = false;
|
1330 |
|
1331 | return parser.parseFromString(svg, 'text/xml');
|
1332 | }
|
1333 |
|
1334 | |
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 | |
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 | function create(name, attrs) {
|
1348 | var element;
|
1349 |
|
1350 | if (name.charAt(0) === '<') {
|
1351 | element = parse$1(name).firstChild;
|
1352 | element = document.importNode(element, true);
|
1353 | } else {
|
1354 | element = document.createElementNS(ns.svg, name);
|
1355 | }
|
1356 |
|
1357 | if (attrs) {
|
1358 | attr$1(element, attrs);
|
1359 | }
|
1360 |
|
1361 | return element;
|
1362 | }
|
1363 |
|
1364 | |
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 | var node = create('svg');
|
1370 |
|
1371 | function extend(object, props) {
|
1372 | var i, k, keys = Object.keys(props);
|
1373 |
|
1374 | for (i = 0; (k = keys[i]); i++) {
|
1375 | object[k] = props[k];
|
1376 | }
|
1377 |
|
1378 | return object;
|
1379 | }
|
1380 |
|
1381 | function createMatrix(a, b, c, d, e, f) {
|
1382 | var matrix = node.createSVGMatrix();
|
1383 |
|
1384 | switch (arguments.length) {
|
1385 | case 0:
|
1386 | return matrix;
|
1387 | case 6:
|
1388 | a = {
|
1389 | a: a,
|
1390 | b: b,
|
1391 | c: c,
|
1392 | d: d,
|
1393 | e: e,
|
1394 | f: f
|
1395 | };
|
1396 | break;
|
1397 | }
|
1398 |
|
1399 | return extend(matrix, a);
|
1400 | }
|
1401 |
|
1402 | function createTransform(matrix) {
|
1403 | if (matrix) {
|
1404 | return node.createSVGTransformFromMatrix(matrix);
|
1405 | } else {
|
1406 | return node.createSVGTransform();
|
1407 | }
|
1408 | }
|
1409 |
|
1410 | |
1411 |
|
1412 |
|
1413 |
|
1414 | var TEXT_ENTITIES = /([&<>]{1})/g;
|
1415 | var ATTR_ENTITIES = /([\n\r"]{1})/g;
|
1416 |
|
1417 | var ENTITY_REPLACEMENT = {
|
1418 | '&': '&',
|
1419 | '<': '<',
|
1420 | '>': '>',
|
1421 | '"': '\''
|
1422 | };
|
1423 |
|
1424 | function escape(str, pattern) {
|
1425 |
|
1426 | function replaceFn(match, entity) {
|
1427 | return ENTITY_REPLACEMENT[entity] || entity;
|
1428 | }
|
1429 |
|
1430 | return str.replace(pattern, replaceFn);
|
1431 | }
|
1432 |
|
1433 | function serialize(node, output) {
|
1434 |
|
1435 | var i, len, attrMap, attrNode, childNodes;
|
1436 |
|
1437 | switch (node.nodeType) {
|
1438 |
|
1439 | case 3:
|
1440 |
|
1441 | output.push(escape(node.textContent, TEXT_ENTITIES));
|
1442 | break;
|
1443 |
|
1444 |
|
1445 | case 1:
|
1446 | output.push('<', node.tagName);
|
1447 |
|
1448 | if (node.hasAttributes()) {
|
1449 | attrMap = node.attributes;
|
1450 | for (i = 0, len = attrMap.length; i < len; ++i) {
|
1451 | attrNode = attrMap.item(i);
|
1452 | output.push(' ', attrNode.name, '="', escape(attrNode.value, ATTR_ENTITIES), '"');
|
1453 | }
|
1454 | }
|
1455 |
|
1456 | if (node.hasChildNodes()) {
|
1457 | output.push('>');
|
1458 | childNodes = node.childNodes;
|
1459 | for (i = 0, len = childNodes.length; i < len; ++i) {
|
1460 | serialize(childNodes.item(i), output);
|
1461 | }
|
1462 | output.push('</', node.tagName, '>');
|
1463 | } else {
|
1464 | output.push('/>');
|
1465 | }
|
1466 | break;
|
1467 |
|
1468 |
|
1469 | case 8:
|
1470 | output.push('<!--', escape(node.nodeValue, TEXT_ENTITIES), '-->');
|
1471 | break;
|
1472 |
|
1473 |
|
1474 | case 4:
|
1475 | output.push('<![CDATA[', node.nodeValue, ']]>');
|
1476 | break;
|
1477 |
|
1478 | default:
|
1479 | throw new Error('unable to handle node ' + node.nodeType);
|
1480 | }
|
1481 |
|
1482 | return output;
|
1483 | }
|
1484 |
|
1485 | |
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 | function set(element, svg) {
|
1492 |
|
1493 | var parsed = parse$1(svg);
|
1494 |
|
1495 |
|
1496 | clear$1(element);
|
1497 |
|
1498 | if (!svg) {
|
1499 | return;
|
1500 | }
|
1501 |
|
1502 | if (!isFragment(parsed)) {
|
1503 |
|
1504 | parsed = parsed.documentElement;
|
1505 | }
|
1506 |
|
1507 | var nodes = slice$1(parsed.childNodes);
|
1508 |
|
1509 |
|
1510 | for (var i = 0; i < nodes.length; i++) {
|
1511 | appendTo(nodes[i], element);
|
1512 | }
|
1513 |
|
1514 | }
|
1515 |
|
1516 | function get(element) {
|
1517 | var child = element.firstChild,
|
1518 | output = [];
|
1519 |
|
1520 | while (child) {
|
1521 | serialize(child, output);
|
1522 | child = child.nextSibling;
|
1523 | }
|
1524 |
|
1525 | return output.join('');
|
1526 | }
|
1527 |
|
1528 | function isFragment(node) {
|
1529 | return node.nodeName === '#document-fragment';
|
1530 | }
|
1531 |
|
1532 | function innerSVG(element, svg) {
|
1533 |
|
1534 | if (svg !== undefined) {
|
1535 |
|
1536 | try {
|
1537 | set(element, svg);
|
1538 | } catch (e) {
|
1539 | throw new Error('error parsing SVG: ' + e.message);
|
1540 | }
|
1541 |
|
1542 | return element;
|
1543 | } else {
|
1544 | return get(element);
|
1545 | }
|
1546 | }
|
1547 |
|
1548 |
|
1549 | function slice$1(arr) {
|
1550 | return Array.prototype.slice.call(arr);
|
1551 | }
|
1552 |
|
1553 | |
1554 |
|
1555 |
|
1556 |
|
1557 | function wrapMatrix(transformList, transform) {
|
1558 | if (transform instanceof SVGMatrix) {
|
1559 | return transformList.createSVGTransformFromMatrix(transform);
|
1560 | } else {
|
1561 | return transform;
|
1562 | }
|
1563 | }
|
1564 |
|
1565 | function setTransforms(transformList, transforms) {
|
1566 | var i, t;
|
1567 |
|
1568 | transformList.clear();
|
1569 |
|
1570 | for (i = 0; (t = transforms[i]); i++) {
|
1571 | transformList.appendItem(wrapMatrix(transformList, t));
|
1572 | }
|
1573 |
|
1574 | transformList.consolidate();
|
1575 | }
|
1576 |
|
1577 | function transform(node, transforms) {
|
1578 | var transformList = node.transform.baseVal;
|
1579 |
|
1580 | if (arguments.length === 1) {
|
1581 | return transformList.consolidate();
|
1582 | } else {
|
1583 | if (transforms.length) {
|
1584 | setTransforms(transformList, transforms);
|
1585 | } else {
|
1586 | transformList.initialize(wrapMatrix(transformList, transforms));
|
1587 | }
|
1588 | }
|
1589 | }
|
1590 |
|
1591 | var CLASS_PATTERN = /^class /;
|
1592 |
|
1593 | function isClass(fn) {
|
1594 | return CLASS_PATTERN.test(fn.toString());
|
1595 | }
|
1596 |
|
1597 | function isArray$1(obj) {
|
1598 | return Object.prototype.toString.call(obj) === '[object Array]';
|
1599 | }
|
1600 |
|
1601 | function annotate() {
|
1602 | var args = Array.prototype.slice.call(arguments);
|
1603 |
|
1604 | if (args.length === 1 && isArray$1(args[0])) {
|
1605 | args = args[0];
|
1606 | }
|
1607 |
|
1608 | var fn = args.pop();
|
1609 |
|
1610 | fn.$inject = args;
|
1611 |
|
1612 | return fn;
|
1613 | }
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 | var CONSTRUCTOR_ARGS = /constructor\s*[^(]*\(\s*([^)]*)\)/m;
|
1629 | var FN_ARGS = /^function\s*[^(]*\(\s*([^)]*)\)/m;
|
1630 | var FN_ARG = /\/\*([^*]*)\*\//m;
|
1631 |
|
1632 | function parse$2(fn) {
|
1633 |
|
1634 | if (typeof fn !== 'function') {
|
1635 | throw new Error('Cannot annotate "' + fn + '". Expected a function!');
|
1636 | }
|
1637 |
|
1638 | var match = fn.toString().match(isClass(fn) ? CONSTRUCTOR_ARGS : FN_ARGS);
|
1639 |
|
1640 |
|
1641 | if (!match) {
|
1642 | return [];
|
1643 | }
|
1644 |
|
1645 | return match[1] && match[1].split(',').map(function (arg) {
|
1646 | match = arg.match(FN_ARG);
|
1647 | return match ? match[1].trim() : arg.trim();
|
1648 | }) || [];
|
1649 | }
|
1650 |
|
1651 | function Module() {
|
1652 | var providers = [];
|
1653 |
|
1654 | this.factory = function (name, factory) {
|
1655 | providers.push([name, 'factory', factory]);
|
1656 | return this;
|
1657 | };
|
1658 |
|
1659 | this.value = function (name, value) {
|
1660 | providers.push([name, 'value', value]);
|
1661 | return this;
|
1662 | };
|
1663 |
|
1664 | this.type = function (name, type) {
|
1665 | providers.push([name, 'type', type]);
|
1666 | return this;
|
1667 | };
|
1668 |
|
1669 | this.forEach = function (iterator) {
|
1670 | providers.forEach(iterator);
|
1671 | };
|
1672 | }
|
1673 |
|
1674 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
1675 |
|
1676 | function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
1677 |
|
1678 | function Injector(modules, parent) {
|
1679 | parent = parent || {
|
1680 | get: function get(name, strict) {
|
1681 | currentlyResolving.push(name);
|
1682 |
|
1683 | if (strict === false) {
|
1684 | return null;
|
1685 | } else {
|
1686 | throw error('No provider for "' + name + '"!');
|
1687 | }
|
1688 | }
|
1689 | };
|
1690 |
|
1691 | var currentlyResolving = [];
|
1692 | var providers = this._providers = Object.create(parent._providers || null);
|
1693 | var instances = this._instances = Object.create(null);
|
1694 |
|
1695 | var self = instances.injector = this;
|
1696 |
|
1697 | var error = function error(msg) {
|
1698 | var stack = currentlyResolving.join(' -> ');
|
1699 | currentlyResolving.length = 0;
|
1700 | return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
|
1701 | };
|
1702 |
|
1703 | |
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 | var get = function get(name, strict) {
|
1712 | if (!providers[name] && name.indexOf('.') !== -1) {
|
1713 | var parts = name.split('.');
|
1714 | var pivot = get(parts.shift());
|
1715 |
|
1716 | while (parts.length) {
|
1717 | pivot = pivot[parts.shift()];
|
1718 | }
|
1719 |
|
1720 | return pivot;
|
1721 | }
|
1722 |
|
1723 | if (hasProp(instances, name)) {
|
1724 | return instances[name];
|
1725 | }
|
1726 |
|
1727 | if (hasProp(providers, name)) {
|
1728 | if (currentlyResolving.indexOf(name) !== -1) {
|
1729 | currentlyResolving.push(name);
|
1730 | throw error('Cannot resolve circular dependency!');
|
1731 | }
|
1732 |
|
1733 | currentlyResolving.push(name);
|
1734 | instances[name] = providers[name][0](providers[name][1]);
|
1735 | currentlyResolving.pop();
|
1736 |
|
1737 | return instances[name];
|
1738 | }
|
1739 |
|
1740 | return parent.get(name, strict);
|
1741 | };
|
1742 |
|
1743 | var fnDef = function fnDef(fn) {
|
1744 | var locals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1745 |
|
1746 | if (typeof fn !== 'function') {
|
1747 | if (isArray$1(fn)) {
|
1748 | fn = annotate(fn.slice());
|
1749 | } else {
|
1750 | throw new Error('Cannot invoke "' + fn + '". Expected a function!');
|
1751 | }
|
1752 | }
|
1753 |
|
1754 | var inject = fn.$inject || parse$2(fn);
|
1755 | var dependencies = inject.map(function (dep) {
|
1756 | if (hasProp(locals, dep)) {
|
1757 | return locals[dep];
|
1758 | } else {
|
1759 | return get(dep);
|
1760 | }
|
1761 | });
|
1762 |
|
1763 | return {
|
1764 | fn: fn,
|
1765 | dependencies: dependencies
|
1766 | };
|
1767 | };
|
1768 |
|
1769 | var instantiate = function instantiate(Type) {
|
1770 | var _fnDef = fnDef(Type),
|
1771 | dependencies = _fnDef.dependencies,
|
1772 | fn = _fnDef.fn;
|
1773 |
|
1774 | return new (Function.prototype.bind.apply(fn, [null].concat(_toConsumableArray$1(dependencies))))();
|
1775 | };
|
1776 |
|
1777 | var invoke = function invoke(func, context, locals) {
|
1778 | var _fnDef2 = fnDef(func, locals),
|
1779 | dependencies = _fnDef2.dependencies,
|
1780 | fn = _fnDef2.fn;
|
1781 |
|
1782 | return fn.call.apply(fn, [context].concat(_toConsumableArray$1(dependencies)));
|
1783 | };
|
1784 |
|
1785 | var createPrivateInjectorFactory = function createPrivateInjectorFactory(privateChildInjector) {
|
1786 | return annotate(function (key) {
|
1787 | return privateChildInjector.get(key);
|
1788 | });
|
1789 | };
|
1790 |
|
1791 | var createChild = function createChild(modules, forceNewInstances) {
|
1792 | if (forceNewInstances && forceNewInstances.length) {
|
1793 | var fromParentModule = Object.create(null);
|
1794 | var matchedScopes = Object.create(null);
|
1795 |
|
1796 | var privateInjectorsCache = [];
|
1797 | var privateChildInjectors = [];
|
1798 | var privateChildFactories = [];
|
1799 |
|
1800 | var provider;
|
1801 | var cacheIdx;
|
1802 | var privateChildInjector;
|
1803 | var privateChildInjectorFactory;
|
1804 | for (var name in providers) {
|
1805 | provider = providers[name];
|
1806 |
|
1807 | if (forceNewInstances.indexOf(name) !== -1) {
|
1808 | if (provider[2] === 'private') {
|
1809 | cacheIdx = privateInjectorsCache.indexOf(provider[3]);
|
1810 | if (cacheIdx === -1) {
|
1811 | privateChildInjector = provider[3].createChild([], forceNewInstances);
|
1812 | privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector);
|
1813 | privateInjectorsCache.push(provider[3]);
|
1814 | privateChildInjectors.push(privateChildInjector);
|
1815 | privateChildFactories.push(privateChildInjectorFactory);
|
1816 | fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector];
|
1817 | } else {
|
1818 | fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]];
|
1819 | }
|
1820 | } else {
|
1821 | fromParentModule[name] = [provider[2], provider[1]];
|
1822 | }
|
1823 | matchedScopes[name] = true;
|
1824 | }
|
1825 |
|
1826 | if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) {
|
1827 |
|
1828 | forceNewInstances.forEach(function (scope) {
|
1829 | if (provider[1].$scope.indexOf(scope) !== -1) {
|
1830 | fromParentModule[name] = [provider[2], provider[1]];
|
1831 | matchedScopes[scope] = true;
|
1832 | }
|
1833 | });
|
1834 | }
|
1835 | }
|
1836 |
|
1837 | forceNewInstances.forEach(function (scope) {
|
1838 | if (!matchedScopes[scope]) {
|
1839 | throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!');
|
1840 | }
|
1841 | });
|
1842 |
|
1843 | modules.unshift(fromParentModule);
|
1844 | }
|
1845 |
|
1846 | return new Injector(modules, self);
|
1847 | };
|
1848 |
|
1849 | var factoryMap = {
|
1850 | factory: invoke,
|
1851 | type: instantiate,
|
1852 | value: function value(_value) {
|
1853 | return _value;
|
1854 | }
|
1855 | };
|
1856 |
|
1857 | modules.forEach(function (module) {
|
1858 |
|
1859 | function arrayUnwrap(type, value) {
|
1860 | if (type !== 'value' && isArray$1(value)) {
|
1861 | value = annotate(value.slice());
|
1862 | }
|
1863 |
|
1864 | return value;
|
1865 | }
|
1866 |
|
1867 |
|
1868 | if (module instanceof Module) {
|
1869 | module.forEach(function (provider) {
|
1870 | var name = provider[0];
|
1871 | var type = provider[1];
|
1872 | var value = provider[2];
|
1873 |
|
1874 | providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
|
1875 | });
|
1876 | } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') {
|
1877 | if (module.__exports__) {
|
1878 | var clonedModule = Object.keys(module).reduce(function (m, key) {
|
1879 | if (key.substring(0, 2) !== '__') {
|
1880 | m[key] = module[key];
|
1881 | }
|
1882 | return m;
|
1883 | }, Object.create(null));
|
1884 |
|
1885 | var privateInjector = new Injector((module.__modules__ || []).concat([clonedModule]), self);
|
1886 | var getFromPrivateInjector = annotate(function (key) {
|
1887 | return privateInjector.get(key);
|
1888 | });
|
1889 | module.__exports__.forEach(function (key) {
|
1890 | providers[key] = [getFromPrivateInjector, key, 'private', privateInjector];
|
1891 | });
|
1892 | } else {
|
1893 | Object.keys(module).forEach(function (name) {
|
1894 | if (module[name][2] === 'private') {
|
1895 | providers[name] = module[name];
|
1896 | return;
|
1897 | }
|
1898 |
|
1899 | var type = module[name][0];
|
1900 | var value = module[name][1];
|
1901 |
|
1902 | providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
|
1903 | });
|
1904 | }
|
1905 | }
|
1906 | });
|
1907 |
|
1908 |
|
1909 | this.get = get;
|
1910 | this.invoke = invoke;
|
1911 | this.instantiate = instantiate;
|
1912 | this.createChild = createChild;
|
1913 | }
|
1914 |
|
1915 | // helpers /////////////////
|
1916 |
|
1917 | function hasProp(obj, prop) {
|
1918 | return Object.hasOwnProperty.call(obj, prop);
|
1919 | }
|
1920 |
|
1921 | var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
1922 |
|
1923 | function createCommonjsModule(fn, module) {
|
1924 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
1925 | }
|
1926 |
|
1927 | var inherits_browser = createCommonjsModule(function (module) {
|
1928 | if (typeof Object.create === 'function') {
|
1929 |
|
1930 | module.exports = function inherits(ctor, superCtor) {
|
1931 | ctor.super_ = superCtor;
|
1932 | ctor.prototype = Object.create(superCtor.prototype, {
|
1933 | constructor: {
|
1934 | value: ctor,
|
1935 | enumerable: false,
|
1936 | writable: true,
|
1937 | configurable: true
|
1938 | }
|
1939 | });
|
1940 | };
|
1941 | } else {
|
1942 |
|
1943 | module.exports = function inherits(ctor, superCtor) {
|
1944 | ctor.super_ = superCtor;
|
1945 | var TempCtor = function () {};
|
1946 | TempCtor.prototype = superCtor.prototype;
|
1947 | ctor.prototype = new TempCtor();
|
1948 | ctor.prototype.constructor = ctor;
|
1949 | };
|
1950 | }
|
1951 | });
|
1952 |
|
1953 | var DEFAULT_RENDER_PRIORITY = 1000;
|
1954 |
|
1955 | |
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 |
|
1961 | function BaseRenderer(eventBus, renderPriority) {
|
1962 | var self = this;
|
1963 |
|
1964 | renderPriority = renderPriority || DEFAULT_RENDER_PRIORITY;
|
1965 |
|
1966 | eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
|
1967 | var type = evt.type,
|
1968 | element = context.element,
|
1969 | visuals = context.gfx;
|
1970 |
|
1971 | if (self.canRender(element)) {
|
1972 | if (type === 'render.shape') {
|
1973 | return self.drawShape(visuals, element);
|
1974 | } else {
|
1975 | return self.drawConnection(visuals, element);
|
1976 | }
|
1977 | }
|
1978 | });
|
1979 |
|
1980 | eventBus.on([ 'render.getShapePath', 'render.getConnectionPath'], renderPriority, function(evt, element) {
|
1981 | if (self.canRender(element)) {
|
1982 | if (evt.type === 'render.getShapePath') {
|
1983 | return self.getShapePath(element);
|
1984 | } else {
|
1985 | return self.getConnectionPath(element);
|
1986 | }
|
1987 | }
|
1988 | });
|
1989 | }
|
1990 |
|
1991 | |
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 | BaseRenderer.prototype.canRender = function() {};
|
2000 |
|
2001 | |
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 | BaseRenderer.prototype.drawShape = function() {};
|
2010 |
|
2011 | |
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 | BaseRenderer.prototype.drawConnection = function() {};
|
2020 |
|
2021 | |
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 | BaseRenderer.prototype.getShapePath = function() {};
|
2029 |
|
2030 | |
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 | BaseRenderer.prototype.getConnectionPath = function() {};
|
2038 |
|
2039 | function componentsToPath(elements) {
|
2040 | return elements.join(',').replace(/,?([A-z]),?/g, '$1');
|
2041 | }
|
2042 |
|
2043 | function toSVGPoints(points) {
|
2044 | var result = '';
|
2045 |
|
2046 | for (var i = 0, p; (p = points[i]); i++) {
|
2047 | result += p.x + ',' + p.y + ' ';
|
2048 | }
|
2049 |
|
2050 | return result;
|
2051 | }
|
2052 |
|
2053 | function createLine(points, attrs) {
|
2054 |
|
2055 | var line = create('polyline');
|
2056 | attr$1(line, { points: toSVGPoints(points) });
|
2057 |
|
2058 | if (attrs) {
|
2059 | attr$1(line, attrs);
|
2060 | }
|
2061 |
|
2062 | return line;
|
2063 | }
|
2064 |
|
2065 | function updateLine(gfx, points) {
|
2066 | attr$1(gfx, { points: toSVGPoints(points) });
|
2067 |
|
2068 | return gfx;
|
2069 | }
|
2070 |
|
2071 |
|
2072 |
|
2073 | var DEFAULT_RENDER_PRIORITY$1 = 1;
|
2074 |
|
2075 | |
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 | function DefaultRenderer(eventBus, styles) {
|
2082 |
|
2083 | BaseRenderer.call(this, eventBus, DEFAULT_RENDER_PRIORITY$1);
|
2084 |
|
2085 | this.CONNECTION_STYLE = styles.style([ 'no-fill' ], { strokeWidth: 5, stroke: 'fuchsia' });
|
2086 | this.SHAPE_STYLE = styles.style({ fill: 'white', stroke: 'fuchsia', strokeWidth: 2 });
|
2087 | }
|
2088 |
|
2089 | inherits_browser(DefaultRenderer, BaseRenderer);
|
2090 |
|
2091 |
|
2092 | DefaultRenderer.prototype.canRender = function() {
|
2093 | return true;
|
2094 | };
|
2095 |
|
2096 | DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
|
2097 |
|
2098 | var rect = create('rect');
|
2099 | attr$1(rect, {
|
2100 | x: 0,
|
2101 | y: 0,
|
2102 | width: element.width || 0,
|
2103 | height: element.height || 0
|
2104 | });
|
2105 | attr$1(rect, this.SHAPE_STYLE);
|
2106 |
|
2107 | append(visuals, rect);
|
2108 |
|
2109 | return rect;
|
2110 | };
|
2111 |
|
2112 | DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
|
2113 |
|
2114 | var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
|
2115 | append(visuals, line);
|
2116 |
|
2117 | return line;
|
2118 | };
|
2119 |
|
2120 | DefaultRenderer.prototype.getShapePath = function getShapePath(shape) {
|
2121 |
|
2122 | var x = shape.x,
|
2123 | y = shape.y,
|
2124 | width = shape.width,
|
2125 | height = shape.height;
|
2126 |
|
2127 | var shapePath = [
|
2128 | ['M', x, y],
|
2129 | ['l', width, 0],
|
2130 | ['l', 0, height],
|
2131 | ['l', -width, 0],
|
2132 | ['z']
|
2133 | ];
|
2134 |
|
2135 | return componentsToPath(shapePath);
|
2136 | };
|
2137 |
|
2138 | DefaultRenderer.prototype.getConnectionPath = function getConnectionPath(connection) {
|
2139 | var waypoints = connection.waypoints;
|
2140 |
|
2141 | var idx, point, connectionPath = [];
|
2142 |
|
2143 | for (idx = 0; (point = waypoints[idx]); idx++) {
|
2144 |
|
2145 |
|
2146 |
|
2147 | point = point.original || point;
|
2148 |
|
2149 | connectionPath.push([ idx === 0 ? 'M' : 'L', point.x, point.y ]);
|
2150 | }
|
2151 |
|
2152 | return componentsToPath(connectionPath);
|
2153 | };
|
2154 |
|
2155 |
|
2156 | DefaultRenderer.$inject = [ 'eventBus', 'styles' ];
|
2157 |
|
2158 | |
2159 |
|
2160 |
|
2161 | function Styles() {
|
2162 |
|
2163 | var defaultTraits = {
|
2164 |
|
2165 | 'no-fill': {
|
2166 | fill: 'none'
|
2167 | },
|
2168 | 'no-border': {
|
2169 | strokeOpacity: 0.0
|
2170 | },
|
2171 | 'no-events': {
|
2172 | pointerEvents: 'none'
|
2173 | }
|
2174 | };
|
2175 |
|
2176 | var self = this;
|
2177 |
|
2178 | |
2179 |
|
2180 |
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 |
|
2187 | this.cls = function(className, traits, additionalAttrs) {
|
2188 | var attrs = this.style(traits, additionalAttrs);
|
2189 |
|
2190 | return assign(attrs, { 'class': className });
|
2191 | };
|
2192 |
|
2193 | |
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 | this.style = function(traits, additionalAttrs) {
|
2202 |
|
2203 | if (!isArray(traits) && !additionalAttrs) {
|
2204 | additionalAttrs = traits;
|
2205 | traits = [];
|
2206 | }
|
2207 |
|
2208 | var attrs = reduce(traits, function(attrs, t) {
|
2209 | return assign(attrs, defaultTraits[t] || {});
|
2210 | }, {});
|
2211 |
|
2212 | return additionalAttrs ? assign(attrs, additionalAttrs) : attrs;
|
2213 | };
|
2214 |
|
2215 | this.computeStyle = function(custom, traits, defaultStyles) {
|
2216 | if (!isArray(traits)) {
|
2217 | defaultStyles = traits;
|
2218 | traits = [];
|
2219 | }
|
2220 |
|
2221 | return self.style(traits || [], assign({}, defaultStyles, custom || {}));
|
2222 | };
|
2223 | }
|
2224 |
|
2225 | var DrawModule = {
|
2226 | __init__: [ 'defaultRenderer' ],
|
2227 | defaultRenderer: [ 'type', DefaultRenderer ],
|
2228 | styles: [ 'type', Styles ]
|
2229 | };
|
2230 |
|
2231 | |
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 | function remove$2(collection, element) {
|
2240 |
|
2241 | if (!collection || !element) {
|
2242 | return -1;
|
2243 | }
|
2244 |
|
2245 | var idx = collection.indexOf(element);
|
2246 |
|
2247 | if (idx !== -1) {
|
2248 | collection.splice(idx, 1);
|
2249 | }
|
2250 |
|
2251 | return idx;
|
2252 | }
|
2253 |
|
2254 | |
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 | function add(collection, element, idx) {
|
2263 |
|
2264 | if (!collection || !element) {
|
2265 | return;
|
2266 | }
|
2267 |
|
2268 | if (typeof idx !== 'number') {
|
2269 | idx = -1;
|
2270 | }
|
2271 |
|
2272 | var currentIdx = collection.indexOf(element);
|
2273 |
|
2274 | if (currentIdx !== -1) {
|
2275 |
|
2276 | if (currentIdx === idx) {
|
2277 |
|
2278 | return;
|
2279 | } else {
|
2280 |
|
2281 | if (idx !== -1) {
|
2282 |
|
2283 | collection.splice(currentIdx, 1);
|
2284 | } else {
|
2285 |
|
2286 | return;
|
2287 | }
|
2288 | }
|
2289 | }
|
2290 |
|
2291 | if (idx !== -1) {
|
2292 |
|
2293 | collection.splice(idx, 0, element);
|
2294 | } else {
|
2295 |
|
2296 | collection.push(element);
|
2297 | }
|
2298 | }
|
2299 |
|
2300 | |
2301 |
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 |
|
2307 | function getBBox(elements, stopRecursion) {
|
2308 |
|
2309 | stopRecursion = !!stopRecursion;
|
2310 | if (!isArray(elements)) {
|
2311 | elements = [elements];
|
2312 | }
|
2313 |
|
2314 | var minX,
|
2315 | minY,
|
2316 | maxX,
|
2317 | maxY;
|
2318 |
|
2319 | forEach(elements, function(element) {
|
2320 |
|
2321 |
|
2322 | var bbox = element;
|
2323 | if (element.waypoints && !stopRecursion) {
|
2324 | bbox = getBBox(element.waypoints, true);
|
2325 | }
|
2326 |
|
2327 | var x = bbox.x,
|
2328 | y = bbox.y,
|
2329 | height = bbox.height || 0,
|
2330 | width = bbox.width || 0;
|
2331 |
|
2332 | if (x < minX || minX === undefined) {
|
2333 | minX = x;
|
2334 | }
|
2335 | if (y < minY || minY === undefined) {
|
2336 | minY = y;
|
2337 | }
|
2338 |
|
2339 | if ((x + width) > maxX || maxX === undefined) {
|
2340 | maxX = x + width;
|
2341 | }
|
2342 | if ((y + height) > maxY || maxY === undefined) {
|
2343 | maxY = y + height;
|
2344 | }
|
2345 | });
|
2346 |
|
2347 | return {
|
2348 | x: minX,
|
2349 | y: minY,
|
2350 | height: maxY - minY,
|
2351 | width: maxX - minX
|
2352 | };
|
2353 | }
|
2354 |
|
2355 |
|
2356 | function getType(element) {
|
2357 |
|
2358 | if ('waypoints' in element) {
|
2359 | return 'connection';
|
2360 | }
|
2361 |
|
2362 | if ('x' in element) {
|
2363 | return 'shape';
|
2364 | }
|
2365 |
|
2366 | return 'root';
|
2367 | }
|
2368 |
|
2369 | function round(number, resolution) {
|
2370 | return Math.round(number * resolution) / resolution;
|
2371 | }
|
2372 |
|
2373 | function ensurePx(number) {
|
2374 | return isNumber(number) ? number + 'px' : number;
|
2375 | }
|
2376 |
|
2377 | |
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 | function createContainer(options) {
|
2385 |
|
2386 | options = assign({}, { width: '100%', height: '100%' }, options);
|
2387 |
|
2388 | var container = options.container || document.body;
|
2389 |
|
2390 |
|
2391 |
|
2392 |
|
2393 | var parent = document.createElement('div');
|
2394 | parent.setAttribute('class', 'djs-container');
|
2395 |
|
2396 | assign(parent.style, {
|
2397 | position: 'relative',
|
2398 | overflow: 'hidden',
|
2399 | width: ensurePx(options.width),
|
2400 | height: ensurePx(options.height)
|
2401 | });
|
2402 |
|
2403 | container.appendChild(parent);
|
2404 |
|
2405 | return parent;
|
2406 | }
|
2407 |
|
2408 | function createGroup(parent, cls, childIndex) {
|
2409 | var group = create('g');
|
2410 | classes$1(group).add(cls);
|
2411 |
|
2412 | var index = childIndex !== undefined ? childIndex : parent.childNodes.length - 1;
|
2413 |
|
2414 |
|
2415 |
|
2416 | parent.insertBefore(group, parent.childNodes[index] || null);
|
2417 |
|
2418 | return group;
|
2419 | }
|
2420 |
|
2421 | var BASE_LAYER = 'base';
|
2422 |
|
2423 |
|
2424 | var REQUIRED_MODEL_ATTRS = {
|
2425 | shape: [ 'x', 'y', 'width', 'height' ],
|
2426 | connection: [ 'waypoints' ]
|
2427 | };
|
2428 |
|
2429 | |
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 |
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 | function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
2443 |
|
2444 | this._eventBus = eventBus;
|
2445 | this._elementRegistry = elementRegistry;
|
2446 | this._graphicsFactory = graphicsFactory;
|
2447 |
|
2448 | this._init(config || {});
|
2449 | }
|
2450 |
|
2451 | Canvas.$inject = [
|
2452 | 'config.canvas',
|
2453 | 'eventBus',
|
2454 | 'graphicsFactory',
|
2455 | 'elementRegistry'
|
2456 | ];
|
2457 |
|
2458 |
|
2459 | Canvas.prototype._init = function(config) {
|
2460 |
|
2461 | var eventBus = this._eventBus;
|
2462 |
|
2463 |
|
2464 |
|
2465 |
|
2466 |
|
2467 |
|
2468 |
|
2469 |
|
2470 |
|
2471 |
|
2472 |
|
2473 |
|
2474 |
|
2475 |
|
2476 | var container = this._container = createContainer(config);
|
2477 |
|
2478 | var svg = this._svg = create('svg');
|
2479 | attr$1(svg, { width: '100%', height: '100%' });
|
2480 |
|
2481 | append(container, svg);
|
2482 |
|
2483 | var viewport = this._viewport = createGroup(svg, 'viewport');
|
2484 |
|
2485 | this._layers = {};
|
2486 |
|
2487 |
|
2488 |
|
2489 | if (config.deferUpdate !== false) {
|
2490 | this._viewboxChanged = debounce(bind(this._viewboxChanged, this), 300);
|
2491 | }
|
2492 |
|
2493 | eventBus.on('diagram.init', function() {
|
2494 |
|
2495 | |
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 | eventBus.fire('canvas.init', {
|
2507 | svg: svg,
|
2508 | viewport: viewport
|
2509 | });
|
2510 |
|
2511 | }, this);
|
2512 |
|
2513 |
|
2514 |
|
2515 | eventBus.on([
|
2516 | 'shape.added',
|
2517 | 'connection.added',
|
2518 | 'shape.removed',
|
2519 | 'connection.removed',
|
2520 | 'elements.changed'
|
2521 | ], function() {
|
2522 | delete this._cachedViewbox;
|
2523 | }, this);
|
2524 |
|
2525 | eventBus.on('diagram.destroy', 500, this._destroy, this);
|
2526 | eventBus.on('diagram.clear', 500, this._clear, this);
|
2527 | };
|
2528 |
|
2529 | Canvas.prototype._destroy = function(emit) {
|
2530 | this._eventBus.fire('canvas.destroy', {
|
2531 | svg: this._svg,
|
2532 | viewport: this._viewport
|
2533 | });
|
2534 |
|
2535 | var parent = this._container.parentNode;
|
2536 |
|
2537 | if (parent) {
|
2538 | parent.removeChild(this._container);
|
2539 | }
|
2540 |
|
2541 | delete this._svg;
|
2542 | delete this._container;
|
2543 | delete this._layers;
|
2544 | delete this._rootElement;
|
2545 | delete this._viewport;
|
2546 | };
|
2547 |
|
2548 | Canvas.prototype._clear = function() {
|
2549 |
|
2550 | var self = this;
|
2551 |
|
2552 | var allElements = this._elementRegistry.getAll();
|
2553 |
|
2554 |
|
2555 | allElements.forEach(function(element) {
|
2556 | var type = getType(element);
|
2557 |
|
2558 | if (type === 'root') {
|
2559 | self.setRootElement(null, true);
|
2560 | } else {
|
2561 | self._removeElement(element, type);
|
2562 | }
|
2563 | });
|
2564 |
|
2565 |
|
2566 | delete this._cachedViewbox;
|
2567 | };
|
2568 |
|
2569 | |
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 | Canvas.prototype.getDefaultLayer = function() {
|
2576 | return this.getLayer(BASE_LAYER, 0);
|
2577 | };
|
2578 |
|
2579 | |
2580 |
|
2581 |
|
2582 |
|
2583 |
|
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 |
|
2591 |
|
2592 |
|
2593 |
|
2594 | Canvas.prototype.getLayer = function(name, index) {
|
2595 |
|
2596 | if (!name) {
|
2597 | throw new Error('must specify a name');
|
2598 | }
|
2599 |
|
2600 | var layer = this._layers[name];
|
2601 |
|
2602 | if (!layer) {
|
2603 | layer = this._layers[name] = this._createLayer(name, index);
|
2604 | }
|
2605 |
|
2606 |
|
2607 |
|
2608 | if (typeof index !== 'undefined' && layer.index !== index) {
|
2609 | throw new Error('layer <' + name + '> already created at index <' + index + '>');
|
2610 | }
|
2611 |
|
2612 | return layer.group;
|
2613 | };
|
2614 |
|
2615 | |
2616 |
|
2617 |
|
2618 |
|
2619 |
|
2620 |
|
2621 |
|
2622 |
|
2623 | Canvas.prototype._createLayer = function(name, index) {
|
2624 |
|
2625 | if (!index) {
|
2626 | index = 0;
|
2627 | }
|
2628 |
|
2629 | var childIndex = reduce(this._layers, function(childIndex, layer) {
|
2630 | if (index >= layer.index) {
|
2631 | childIndex++;
|
2632 | }
|
2633 |
|
2634 | return childIndex;
|
2635 | }, 0);
|
2636 |
|
2637 | return {
|
2638 | group: createGroup(this._viewport, 'layer-' + name, childIndex),
|
2639 | index: index
|
2640 | };
|
2641 |
|
2642 | };
|
2643 |
|
2644 | |
2645 |
|
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 | Canvas.prototype.getContainer = function() {
|
2651 | return this._container;
|
2652 | };
|
2653 |
|
2654 |
|
2655 |
|
2656 |
|
2657 | Canvas.prototype._updateMarker = function(element, marker, add$$1) {
|
2658 | var container;
|
2659 |
|
2660 | if (!element.id) {
|
2661 | element = this._elementRegistry.get(element);
|
2662 | }
|
2663 |
|
2664 |
|
2665 | container = this._elementRegistry._elements[element.id];
|
2666 |
|
2667 | if (!container) {
|
2668 | return;
|
2669 | }
|
2670 |
|
2671 | forEach([ container.gfx, container.secondaryGfx ], function(gfx) {
|
2672 | if (gfx) {
|
2673 |
|
2674 | if (add$$1) {
|
2675 | classes$1(gfx).add(marker);
|
2676 | } else {
|
2677 | classes$1(gfx).remove(marker);
|
2678 | }
|
2679 | }
|
2680 | });
|
2681 |
|
2682 | |
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 |
|
2691 |
|
2692 | this._eventBus.fire('element.marker.update', { element: element, gfx: container.gfx, marker: marker, add: !!add$$1 });
|
2693 | };
|
2694 |
|
2695 |
|
2696 | |
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 |
|
2702 |
|
2703 |
|
2704 |
|
2705 |
|
2706 |
|
2707 |
|
2708 |
|
2709 |
|
2710 |
|
2711 |
|
2712 | Canvas.prototype.addMarker = function(element, marker) {
|
2713 | this._updateMarker(element, marker, true);
|
2714 | };
|
2715 |
|
2716 |
|
2717 | |
2718 |
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 | Canvas.prototype.removeMarker = function(element, marker) {
|
2727 | this._updateMarker(element, marker, false);
|
2728 | };
|
2729 |
|
2730 | |
2731 |
|
2732 |
|
2733 |
|
2734 |
|
2735 |
|
2736 | Canvas.prototype.hasMarker = function(element, marker) {
|
2737 | if (!element.id) {
|
2738 | element = this._elementRegistry.get(element);
|
2739 | }
|
2740 |
|
2741 | var gfx = this.getGraphics(element);
|
2742 |
|
2743 | return classes$1(gfx).has(marker);
|
2744 | };
|
2745 |
|
2746 | |
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 | Canvas.prototype.toggleMarker = function(element, marker) {
|
2756 | if (this.hasMarker(element, marker)) {
|
2757 | this.removeMarker(element, marker);
|
2758 | } else {
|
2759 | this.addMarker(element, marker);
|
2760 | }
|
2761 | };
|
2762 |
|
2763 | Canvas.prototype.getRootElement = function() {
|
2764 | if (!this._rootElement) {
|
2765 | this.setRootElement({ id: '__implicitroot', children: [] });
|
2766 | }
|
2767 |
|
2768 | return this._rootElement;
|
2769 | };
|
2770 |
|
2771 |
|
2772 |
|
2773 |
|
2774 |
|
2775 | |
2776 |
|
2777 |
|
2778 |
|
2779 |
|
2780 |
|
2781 |
|
2782 |
|
2783 |
|
2784 | Canvas.prototype.setRootElement = function(element, override) {
|
2785 |
|
2786 | if (element) {
|
2787 | this._ensureValid('root', element);
|
2788 | }
|
2789 |
|
2790 | var currentRoot = this._rootElement,
|
2791 | elementRegistry = this._elementRegistry,
|
2792 | eventBus = this._eventBus;
|
2793 |
|
2794 | if (currentRoot) {
|
2795 | if (!override) {
|
2796 | throw new Error('rootElement already set, need to specify override');
|
2797 | }
|
2798 |
|
2799 |
|
2800 | eventBus.fire('root.remove', { element: currentRoot });
|
2801 | eventBus.fire('root.removed', { element: currentRoot });
|
2802 |
|
2803 | elementRegistry.remove(currentRoot);
|
2804 | }
|
2805 |
|
2806 | if (element) {
|
2807 | var gfx = this.getDefaultLayer();
|
2808 |
|
2809 |
|
2810 | eventBus.fire('root.add', { element: element });
|
2811 |
|
2812 | elementRegistry.add(element, gfx, this._svg);
|
2813 |
|
2814 | eventBus.fire('root.added', { element: element, gfx: gfx });
|
2815 | }
|
2816 |
|
2817 | this._rootElement = element;
|
2818 |
|
2819 | return element;
|
2820 | };
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 | Canvas.prototype._ensureValid = function(type, element) {
|
2827 | if (!element.id) {
|
2828 | throw new Error('element must have an id');
|
2829 | }
|
2830 |
|
2831 | if (this._elementRegistry.get(element.id)) {
|
2832 | throw new Error('element with id ' + element.id + ' already exists');
|
2833 | }
|
2834 |
|
2835 | var requiredAttrs = REQUIRED_MODEL_ATTRS[type];
|
2836 |
|
2837 | var valid = every(requiredAttrs, function(attr$$1) {
|
2838 | return typeof element[attr$$1] !== 'undefined';
|
2839 | });
|
2840 |
|
2841 | if (!valid) {
|
2842 | throw new Error(
|
2843 | 'must supply { ' + requiredAttrs.join(', ') + ' } with ' + type);
|
2844 | }
|
2845 | };
|
2846 |
|
2847 | Canvas.prototype._setParent = function(element, parent, parentIndex) {
|
2848 | add(parent.children, element, parentIndex);
|
2849 | element.parent = parent;
|
2850 | };
|
2851 |
|
2852 | |
2853 |
|
2854 |
|
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 |
|
2869 |
|
2870 |
|
2871 |
|
2872 | Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
2873 |
|
2874 | parent = parent || this.getRootElement();
|
2875 |
|
2876 | var eventBus = this._eventBus,
|
2877 | graphicsFactory = this._graphicsFactory;
|
2878 |
|
2879 | this._ensureValid(type, element);
|
2880 |
|
2881 | eventBus.fire(type + '.add', { element: element, parent: parent });
|
2882 |
|
2883 | this._setParent(element, parent, parentIndex);
|
2884 |
|
2885 |
|
2886 | var gfx = graphicsFactory.create(type, element, parentIndex);
|
2887 |
|
2888 | this._elementRegistry.add(element, gfx);
|
2889 |
|
2890 |
|
2891 | graphicsFactory.update(type, element, gfx);
|
2892 |
|
2893 | eventBus.fire(type + '.added', { element: element, gfx: gfx });
|
2894 |
|
2895 | return element;
|
2896 | };
|
2897 |
|
2898 | |
2899 |
|
2900 |
|
2901 |
|
2902 |
|
2903 |
|
2904 |
|
2905 |
|
2906 |
|
2907 | Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
2908 | return this._addElement('shape', shape, parent, parentIndex);
|
2909 | };
|
2910 |
|
2911 | |
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 | Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
2921 | return this._addElement('connection', connection, parent, parentIndex);
|
2922 | };
|
2923 |
|
2924 |
|
2925 | |
2926 |
|
2927 |
|
2928 | Canvas.prototype._removeElement = function(element, type) {
|
2929 |
|
2930 | var elementRegistry = this._elementRegistry,
|
2931 | graphicsFactory = this._graphicsFactory,
|
2932 | eventBus = this._eventBus;
|
2933 |
|
2934 | element = elementRegistry.get(element.id || element);
|
2935 |
|
2936 | if (!element) {
|
2937 |
|
2938 | return;
|
2939 | }
|
2940 |
|
2941 | eventBus.fire(type + '.remove', { element: element });
|
2942 |
|
2943 | graphicsFactory.remove(element);
|
2944 |
|
2945 |
|
2946 | remove$2(element.parent && element.parent.children, element);
|
2947 | element.parent = null;
|
2948 |
|
2949 | eventBus.fire(type + '.removed', { element: element });
|
2950 |
|
2951 | elementRegistry.remove(element);
|
2952 |
|
2953 | return element;
|
2954 | };
|
2955 |
|
2956 |
|
2957 | |
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 | Canvas.prototype.removeShape = function(shape) {
|
2965 |
|
2966 | |
2967 |
|
2968 |
|
2969 |
|
2970 |
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 |
|
2977 | |
2978 |
|
2979 |
|
2980 |
|
2981 |
|
2982 |
|
2983 |
|
2984 |
|
2985 |
|
2986 |
|
2987 | return this._removeElement(shape, 'shape');
|
2988 | };
|
2989 |
|
2990 |
|
2991 | |
2992 |
|
2993 |
|
2994 |
|
2995 |
|
2996 |
|
2997 |
|
2998 | Canvas.prototype.removeConnection = function(connection) {
|
2999 |
|
3000 | |
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 |
|
3006 |
|
3007 |
|
3008 |
|
3009 |
|
3010 |
|
3011 | |
3012 |
|
3013 |
|
3014 |
|
3015 |
|
3016 |
|
3017 |
|
3018 |
|
3019 |
|
3020 |
|
3021 | return this._removeElement(connection, 'connection');
|
3022 | };
|
3023 |
|
3024 |
|
3025 | |
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 | Canvas.prototype.getGraphics = function(element, secondary) {
|
3034 | return this._elementRegistry.getGraphics(element, secondary);
|
3035 | };
|
3036 |
|
3037 |
|
3038 | |
3039 |
|
3040 |
|
3041 |
|
3042 |
|
3043 | Canvas.prototype._changeViewbox = function(changeFn) {
|
3044 |
|
3045 |
|
3046 | this._eventBus.fire('canvas.viewbox.changing');
|
3047 |
|
3048 |
|
3049 | changeFn.apply(this);
|
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 | this._cachedViewbox = null;
|
3055 |
|
3056 |
|
3057 |
|
3058 | this._viewboxChanged();
|
3059 | };
|
3060 |
|
3061 | Canvas.prototype._viewboxChanged = function() {
|
3062 | this._eventBus.fire('canvas.viewbox.changed', { viewbox: this.viewbox() });
|
3063 | };
|
3064 |
|
3065 |
|
3066 | |
3067 |
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 | Canvas.prototype.viewbox = function(box) {
|
3112 |
|
3113 | if (box === undefined && this._cachedViewbox) {
|
3114 | return this._cachedViewbox;
|
3115 | }
|
3116 |
|
3117 | var viewport = this._viewport,
|
3118 | innerBox,
|
3119 | outerBox = this.getSize(),
|
3120 | matrix,
|
3121 | transform$$1,
|
3122 | scale,
|
3123 | x, y;
|
3124 |
|
3125 | if (!box) {
|
3126 |
|
3127 |
|
3128 |
|
3129 | innerBox = this.getDefaultLayer().getBBox();
|
3130 |
|
3131 | transform$$1 = transform(viewport);
|
3132 | matrix = transform$$1 ? transform$$1.matrix : createMatrix();
|
3133 | scale = round(matrix.a, 1000);
|
3134 |
|
3135 | x = round(-matrix.e || 0, 1000);
|
3136 | y = round(-matrix.f || 0, 1000);
|
3137 |
|
3138 | box = this._cachedViewbox = {
|
3139 | x: x ? x / scale : 0,
|
3140 | y: y ? y / scale : 0,
|
3141 | width: outerBox.width / scale,
|
3142 | height: outerBox.height / scale,
|
3143 | scale: scale,
|
3144 | inner: {
|
3145 | width: innerBox.width,
|
3146 | height: innerBox.height,
|
3147 | x: innerBox.x,
|
3148 | y: innerBox.y
|
3149 | },
|
3150 | outer: outerBox
|
3151 | };
|
3152 |
|
3153 | return box;
|
3154 | } else {
|
3155 |
|
3156 | this._changeViewbox(function() {
|
3157 | scale = Math.min(outerBox.width / box.width, outerBox.height / box.height);
|
3158 |
|
3159 | var matrix = this._svg.createSVGMatrix()
|
3160 | .scale(scale)
|
3161 | .translate(-box.x, -box.y);
|
3162 |
|
3163 | transform(viewport, matrix);
|
3164 | });
|
3165 | }
|
3166 |
|
3167 | return box;
|
3168 | };
|
3169 |
|
3170 |
|
3171 | |
3172 |
|
3173 |
|
3174 |
|
3175 |
|
3176 |
|
3177 |
|
3178 |
|
3179 | Canvas.prototype.scroll = function(delta) {
|
3180 |
|
3181 | var node = this._viewport;
|
3182 | var matrix = node.getCTM();
|
3183 |
|
3184 | if (delta) {
|
3185 | this._changeViewbox(function() {
|
3186 | delta = assign({ dx: 0, dy: 0 }, delta || {});
|
3187 |
|
3188 | matrix = this._svg.createSVGMatrix().translate(delta.dx, delta.dy).multiply(matrix);
|
3189 |
|
3190 | setCTM(node, matrix);
|
3191 | });
|
3192 | }
|
3193 |
|
3194 | return { x: matrix.e, y: matrix.f };
|
3195 | };
|
3196 |
|
3197 |
|
3198 | |
3199 |
|
3200 |
|
3201 |
|
3202 |
|
3203 |
|
3204 |
|
3205 |
|
3206 |
|
3207 |
|
3208 |
|
3209 |
|
3210 |
|
3211 | Canvas.prototype.zoom = function(newScale, center) {
|
3212 |
|
3213 | if (!newScale) {
|
3214 | return this.viewbox(newScale).scale;
|
3215 | }
|
3216 |
|
3217 | if (newScale === 'fit-viewport') {
|
3218 | return this._fitViewport(center);
|
3219 | }
|
3220 |
|
3221 | var outer,
|
3222 | matrix;
|
3223 |
|
3224 | this._changeViewbox(function() {
|
3225 |
|
3226 | if (typeof center !== 'object') {
|
3227 | outer = this.viewbox().outer;
|
3228 |
|
3229 | center = {
|
3230 | x: outer.width / 2,
|
3231 | y: outer.height / 2
|
3232 | };
|
3233 | }
|
3234 |
|
3235 | matrix = this._setZoom(newScale, center);
|
3236 | });
|
3237 |
|
3238 | return round(matrix.a, 1000);
|
3239 | };
|
3240 |
|
3241 | function setCTM(node, m) {
|
3242 | var mstr = 'matrix(' + m.a + ',' + m.b + ',' + m.c + ',' + m.d + ',' + m.e + ',' + m.f + ')';
|
3243 | node.setAttribute('transform', mstr);
|
3244 | }
|
3245 |
|
3246 | Canvas.prototype._fitViewport = function(center) {
|
3247 |
|
3248 | var vbox = this.viewbox(),
|
3249 | outer = vbox.outer,
|
3250 | inner = vbox.inner,
|
3251 | newScale,
|
3252 | newViewbox;
|
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 | if (inner.x >= 0 &&
|
3262 | inner.y >= 0 &&
|
3263 | inner.x + inner.width <= outer.width &&
|
3264 | inner.y + inner.height <= outer.height &&
|
3265 | !center) {
|
3266 |
|
3267 | newViewbox = {
|
3268 | x: 0,
|
3269 | y: 0,
|
3270 | width: Math.max(inner.width + inner.x, outer.width),
|
3271 | height: Math.max(inner.height + inner.y, outer.height)
|
3272 | };
|
3273 | } else {
|
3274 |
|
3275 | newScale = Math.min(1, outer.width / inner.width, outer.height / inner.height);
|
3276 | newViewbox = {
|
3277 | x: inner.x + (center ? inner.width / 2 - outer.width / newScale / 2 : 0),
|
3278 | y: inner.y + (center ? inner.height / 2 - outer.height / newScale / 2 : 0),
|
3279 | width: outer.width / newScale,
|
3280 | height: outer.height / newScale
|
3281 | };
|
3282 | }
|
3283 |
|
3284 | this.viewbox(newViewbox);
|
3285 |
|
3286 | return this.viewbox(false).scale;
|
3287 | };
|
3288 |
|
3289 |
|
3290 | Canvas.prototype._setZoom = function(scale, center) {
|
3291 |
|
3292 | var svg = this._svg,
|
3293 | viewport = this._viewport;
|
3294 |
|
3295 | var matrix = svg.createSVGMatrix();
|
3296 | var point = svg.createSVGPoint();
|
3297 |
|
3298 | var centerPoint,
|
3299 | originalPoint,
|
3300 | currentMatrix,
|
3301 | scaleMatrix,
|
3302 | newMatrix;
|
3303 |
|
3304 | currentMatrix = viewport.getCTM();
|
3305 |
|
3306 | var currentScale = currentMatrix.a;
|
3307 |
|
3308 | if (center) {
|
3309 | centerPoint = assign(point, center);
|
3310 |
|
3311 |
|
3312 | originalPoint = centerPoint.matrixTransform(currentMatrix.inverse());
|
3313 |
|
3314 |
|
3315 | scaleMatrix = matrix
|
3316 | .translate(originalPoint.x, originalPoint.y)
|
3317 | .scale(1 / currentScale * scale)
|
3318 | .translate(-originalPoint.x, -originalPoint.y);
|
3319 |
|
3320 | newMatrix = currentMatrix.multiply(scaleMatrix);
|
3321 | } else {
|
3322 | newMatrix = matrix.scale(scale);
|
3323 | }
|
3324 |
|
3325 | setCTM(this._viewport, newMatrix);
|
3326 |
|
3327 | return newMatrix;
|
3328 | };
|
3329 |
|
3330 |
|
3331 | |
3332 |
|
3333 |
|
3334 |
|
3335 |
|
3336 | Canvas.prototype.getSize = function() {
|
3337 | return {
|
3338 | width: this._container.clientWidth,
|
3339 | height: this._container.clientHeight
|
3340 | };
|
3341 | };
|
3342 |
|
3343 |
|
3344 | |
3345 |
|
3346 |
|
3347 |
|
3348 |
|
3349 |
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 | Canvas.prototype.getAbsoluteBBox = function(element) {
|
3355 | var vbox = this.viewbox();
|
3356 | var bbox;
|
3357 |
|
3358 |
|
3359 |
|
3360 | if (element.waypoints) {
|
3361 | var gfx = this.getGraphics(element);
|
3362 |
|
3363 | bbox = gfx.getBBox();
|
3364 | }
|
3365 |
|
3366 |
|
3367 | else {
|
3368 | bbox = element;
|
3369 | }
|
3370 |
|
3371 | var x = bbox.x * vbox.scale - vbox.x * vbox.scale;
|
3372 | var y = bbox.y * vbox.scale - vbox.y * vbox.scale;
|
3373 |
|
3374 | var width = bbox.width * vbox.scale;
|
3375 | var height = bbox.height * vbox.scale;
|
3376 |
|
3377 | return {
|
3378 | x: x,
|
3379 | y: y,
|
3380 | width: width,
|
3381 | height: height
|
3382 | };
|
3383 | };
|
3384 |
|
3385 | |
3386 |
|
3387 |
|
3388 |
|
3389 | Canvas.prototype.resized = function() {
|
3390 |
|
3391 |
|
3392 | delete this._cachedViewbox;
|
3393 |
|
3394 | this._eventBus.fire('canvas.resized');
|
3395 | };
|
3396 |
|
3397 | var ELEMENT_ID = 'data-element-id';
|
3398 |
|
3399 |
|
3400 | |
3401 |
|
3402 |
|
3403 |
|
3404 |
|
3405 | function ElementRegistry(eventBus) {
|
3406 | this._elements = {};
|
3407 |
|
3408 | this._eventBus = eventBus;
|
3409 | }
|
3410 |
|
3411 | ElementRegistry.$inject = [ 'eventBus' ];
|
3412 |
|
3413 | |
3414 |
|
3415 |
|
3416 |
|
3417 |
|
3418 |
|
3419 |
|
3420 | ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
3421 |
|
3422 | var id = element.id;
|
3423 |
|
3424 | this._validateId(id);
|
3425 |
|
3426 |
|
3427 | attr$1(gfx, ELEMENT_ID, id);
|
3428 |
|
3429 | if (secondaryGfx) {
|
3430 | attr$1(secondaryGfx, ELEMENT_ID, id);
|
3431 | }
|
3432 |
|
3433 | this._elements[id] = { element: element, gfx: gfx, secondaryGfx: secondaryGfx };
|
3434 | };
|
3435 |
|
3436 | |
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 | ElementRegistry.prototype.remove = function(element) {
|
3442 | var elements = this._elements,
|
3443 | id = element.id || element,
|
3444 | container = id && elements[id];
|
3445 |
|
3446 | if (container) {
|
3447 |
|
3448 |
|
3449 | attr$1(container.gfx, ELEMENT_ID, '');
|
3450 |
|
3451 | if (container.secondaryGfx) {
|
3452 | attr$1(container.secondaryGfx, ELEMENT_ID, '');
|
3453 | }
|
3454 |
|
3455 | delete elements[id];
|
3456 | }
|
3457 | };
|
3458 |
|
3459 | |
3460 |
|
3461 |
|
3462 |
|
3463 |
|
3464 |
|
3465 | ElementRegistry.prototype.updateId = function(element, newId) {
|
3466 |
|
3467 | this._validateId(newId);
|
3468 |
|
3469 | if (typeof element === 'string') {
|
3470 | element = this.get(element);
|
3471 | }
|
3472 |
|
3473 | this._eventBus.fire('element.updateId', {
|
3474 | element: element,
|
3475 | newId: newId
|
3476 | });
|
3477 |
|
3478 | var gfx = this.getGraphics(element),
|
3479 | secondaryGfx = this.getGraphics(element, true);
|
3480 |
|
3481 | this.remove(element);
|
3482 |
|
3483 | element.id = newId;
|
3484 |
|
3485 | this.add(element, gfx, secondaryGfx);
|
3486 | };
|
3487 |
|
3488 | |
3489 |
|
3490 |
|
3491 |
|
3492 |
|
3493 |
|
3494 |
|
3495 |
|
3496 |
|
3497 |
|
3498 |
|
3499 |
|
3500 |
|
3501 | ElementRegistry.prototype.get = function(filter) {
|
3502 | var id;
|
3503 |
|
3504 | if (typeof filter === 'string') {
|
3505 | id = filter;
|
3506 | } else {
|
3507 | id = filter && attr$1(filter, ELEMENT_ID);
|
3508 | }
|
3509 |
|
3510 | var container = this._elements[id];
|
3511 | return container && container.element;
|
3512 | };
|
3513 |
|
3514 | |
3515 |
|
3516 |
|
3517 |
|
3518 |
|
3519 |
|
3520 |
|
3521 | ElementRegistry.prototype.filter = function(fn) {
|
3522 |
|
3523 | var filtered = [];
|
3524 |
|
3525 | this.forEach(function(element, gfx) {
|
3526 | if (fn(element, gfx)) {
|
3527 | filtered.push(element);
|
3528 | }
|
3529 | });
|
3530 |
|
3531 | return filtered;
|
3532 | };
|
3533 |
|
3534 | |
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 | ElementRegistry.prototype.getAll = function() {
|
3540 | return this.filter(function(e) { return e; });
|
3541 | };
|
3542 |
|
3543 | |
3544 |
|
3545 |
|
3546 |
|
3547 |
|
3548 | ElementRegistry.prototype.forEach = function(fn) {
|
3549 |
|
3550 | var map = this._elements;
|
3551 |
|
3552 | Object.keys(map).forEach(function(id) {
|
3553 | var container = map[id],
|
3554 | element = container.element,
|
3555 | gfx = container.gfx;
|
3556 |
|
3557 | return fn(element, gfx);
|
3558 | });
|
3559 | };
|
3560 |
|
3561 | |
3562 |
|
3563 |
|
3564 |
|
3565 |
|
3566 |
|
3567 |
|
3568 |
|
3569 |
|
3570 |
|
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 |
|
3576 | ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
3577 | var id = filter.id || filter;
|
3578 |
|
3579 | var container = this._elements[id];
|
3580 | return container && (secondary ? container.secondaryGfx : container.gfx);
|
3581 | };
|
3582 |
|
3583 | |
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 | ElementRegistry.prototype._validateId = function(id) {
|
3592 | if (!id) {
|
3593 | throw new Error('element must have an id');
|
3594 | }
|
3595 |
|
3596 | if (this._elements[id]) {
|
3597 | throw new Error('element with id ' + id + ' already added');
|
3598 | }
|
3599 | };
|
3600 |
|
3601 | |
3602 |
|
3603 |
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 | |
3609 |
|
3610 |
|
3611 |
|
3612 |
|
3613 |
|
3614 |
|
3615 |
|
3616 |
|
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 | function extend$1(collection, refs, property, target) {
|
3622 |
|
3623 | var inverseProperty = property.inverse;
|
3624 |
|
3625 | |
3626 |
|
3627 |
|
3628 |
|
3629 |
|
3630 |
|
3631 |
|
3632 | Object.defineProperty(collection, 'remove', {
|
3633 | value: function(element) {
|
3634 | var idx = this.indexOf(element);
|
3635 | if (idx !== -1) {
|
3636 | this.splice(idx, 1);
|
3637 |
|
3638 |
|
3639 | refs.unset(element, inverseProperty, target);
|
3640 | }
|
3641 |
|
3642 | return element;
|
3643 | }
|
3644 | });
|
3645 |
|
3646 | |
3647 |
|
3648 |
|
3649 |
|
3650 |
|
3651 |
|
3652 |
|
3653 | Object.defineProperty(collection, 'contains', {
|
3654 | value: function(element) {
|
3655 | return this.indexOf(element) !== -1;
|
3656 | }
|
3657 | });
|
3658 |
|
3659 | |
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 |
|
3668 | Object.defineProperty(collection, 'add', {
|
3669 | value: function(element, idx) {
|
3670 |
|
3671 | var currentIdx = this.indexOf(element);
|
3672 |
|
3673 | if (typeof idx === 'undefined') {
|
3674 |
|
3675 | if (currentIdx !== -1) {
|
3676 |
|
3677 | return;
|
3678 | }
|
3679 |
|
3680 |
|
3681 | idx = this.length;
|
3682 | }
|
3683 |
|
3684 |
|
3685 | if (currentIdx !== -1) {
|
3686 |
|
3687 |
|
3688 | this.splice(currentIdx, 1);
|
3689 | }
|
3690 |
|
3691 |
|
3692 | this.splice(idx, 0, element);
|
3693 |
|
3694 | if (currentIdx === -1) {
|
3695 |
|
3696 |
|
3697 | refs.set(element, inverseProperty, target);
|
3698 | }
|
3699 | }
|
3700 | });
|
3701 |
|
3702 |
|
3703 |
|
3704 | Object.defineProperty(collection, '__refs_collection', {
|
3705 | value: true
|
3706 | });
|
3707 |
|
3708 | return collection;
|
3709 | }
|
3710 |
|
3711 |
|
3712 | function isExtended(collection) {
|
3713 | return collection.__refs_collection === true;
|
3714 | }
|
3715 |
|
3716 | var extend_1 = extend$1;
|
3717 |
|
3718 | var isExtended_1 = isExtended;
|
3719 |
|
3720 | var collection = {
|
3721 | extend: extend_1,
|
3722 | isExtended: isExtended_1
|
3723 | };
|
3724 |
|
3725 | function hasOwnProperty(e, property) {
|
3726 | return Object.prototype.hasOwnProperty.call(e, property.name || property);
|
3727 | }
|
3728 |
|
3729 | function defineCollectionProperty(ref, property, target) {
|
3730 |
|
3731 | var collection$$1 = collection.extend(target[property.name] || [], ref, property, target);
|
3732 |
|
3733 | Object.defineProperty(target, property.name, {
|
3734 | enumerable: property.enumerable,
|
3735 | value: collection$$1
|
3736 | });
|
3737 |
|
3738 | if (collection$$1.length) {
|
3739 |
|
3740 | collection$$1.forEach(function(o) {
|
3741 | ref.set(o, property.inverse, target);
|
3742 | });
|
3743 | }
|
3744 | }
|
3745 |
|
3746 |
|
3747 | function defineProperty(ref, property, target) {
|
3748 |
|
3749 | var inverseProperty = property.inverse;
|
3750 |
|
3751 | var _value = target[property.name];
|
3752 |
|
3753 | Object.defineProperty(target, property.name, {
|
3754 | configurable: property.configurable,
|
3755 | enumerable: property.enumerable,
|
3756 |
|
3757 | get: function() {
|
3758 | return _value;
|
3759 | },
|
3760 |
|
3761 | set: function(value) {
|
3762 |
|
3763 |
|
3764 | if (value === _value) {
|
3765 | return;
|
3766 | }
|
3767 |
|
3768 | var old = _value;
|
3769 |
|
3770 |
|
3771 | _value = null;
|
3772 |
|
3773 | if (old) {
|
3774 | ref.unset(old, inverseProperty, target);
|
3775 | }
|
3776 |
|
3777 |
|
3778 | _value = value;
|
3779 |
|
3780 |
|
3781 | ref.set(_value, inverseProperty, target);
|
3782 | }
|
3783 | });
|
3784 |
|
3785 | }
|
3786 |
|
3787 | |
3788 |
|
3789 |
|
3790 |
|
3791 |
|
3792 |
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 |
|
3803 |
|
3804 |
|
3805 |
|
3806 |
|
3807 |
|
3808 |
|
3809 |
|
3810 |
|
3811 |
|
3812 |
|
3813 |
|
3814 |
|
3815 |
|
3816 |
|
3817 |
|
3818 |
|
3819 |
|
3820 |
|
3821 |
|
3822 |
|
3823 |
|
3824 |
|
3825 |
|
3826 |
|
3827 |
|
3828 |
|
3829 |
|
3830 | function Refs(a, b) {
|
3831 |
|
3832 | if (!(this instanceof Refs)) {
|
3833 | return new Refs(a, b);
|
3834 | }
|
3835 |
|
3836 |
|
3837 | a.inverse = b;
|
3838 | b.inverse = a;
|
3839 |
|
3840 | this.props = {};
|
3841 | this.props[a.name] = a;
|
3842 | this.props[b.name] = b;
|
3843 | }
|
3844 |
|
3845 | |
3846 |
|
3847 |
|
3848 |
|
3849 |
|
3850 |
|
3851 |
|
3852 |
|
3853 |
|
3854 | Refs.prototype.bind = function(target, property) {
|
3855 | if (typeof property === 'string') {
|
3856 | if (!this.props[property]) {
|
3857 | throw new Error('no property <' + property + '> in ref');
|
3858 | }
|
3859 | property = this.props[property];
|
3860 | }
|
3861 |
|
3862 | if (property.collection) {
|
3863 | defineCollectionProperty(this, property, target);
|
3864 | } else {
|
3865 | defineProperty(this, property, target);
|
3866 | }
|
3867 | };
|
3868 |
|
3869 | Refs.prototype.ensureRefsCollection = function(target, property) {
|
3870 |
|
3871 | var collection$$1 = target[property.name];
|
3872 |
|
3873 | if (!collection.isExtended(collection$$1)) {
|
3874 | defineCollectionProperty(this, property, target);
|
3875 | }
|
3876 |
|
3877 | return collection$$1;
|
3878 | };
|
3879 |
|
3880 | Refs.prototype.ensureBound = function(target, property) {
|
3881 | if (!hasOwnProperty(target, property)) {
|
3882 | this.bind(target, property);
|
3883 | }
|
3884 | };
|
3885 |
|
3886 | Refs.prototype.unset = function(target, property, value) {
|
3887 |
|
3888 | if (target) {
|
3889 | this.ensureBound(target, property);
|
3890 |
|
3891 | if (property.collection) {
|
3892 | this.ensureRefsCollection(target, property).remove(value);
|
3893 | } else {
|
3894 | target[property.name] = undefined;
|
3895 | }
|
3896 | }
|
3897 | };
|
3898 |
|
3899 | Refs.prototype.set = function(target, property, value) {
|
3900 |
|
3901 | if (target) {
|
3902 | this.ensureBound(target, property);
|
3903 |
|
3904 | if (property.collection) {
|
3905 | this.ensureRefsCollection(target, property).add(value);
|
3906 | } else {
|
3907 | target[property.name] = value;
|
3908 | }
|
3909 | }
|
3910 | };
|
3911 |
|
3912 | var refs = Refs;
|
3913 |
|
3914 | var objectRefs = refs;
|
3915 |
|
3916 | var Collection = collection;
|
3917 | objectRefs.Collection = Collection;
|
3918 |
|
3919 | var parentRefs = new objectRefs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
|
3920 | labelRefs = new objectRefs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
|
3921 | attacherRefs = new objectRefs({ name: 'attachers', collection: true }, { name: 'host' }),
|
3922 | outgoingRefs = new objectRefs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
3923 | incomingRefs = new objectRefs({ name: 'incoming', collection: true }, { name: 'target' });
|
3924 |
|
3925 | |
3926 |
|
3927 |
|
3928 |
|
3929 | |
3930 |
|
3931 |
|
3932 |
|
3933 | |
3934 |
|
3935 |
|
3936 |
|
3937 |
|
3938 |
|
3939 |
|
3940 | function Base() {
|
3941 |
|
3942 | |
3943 |
|
3944 |
|
3945 |
|
3946 |
|
3947 |
|
3948 | Object.defineProperty(this, 'businessObject', {
|
3949 | writable: true
|
3950 | });
|
3951 |
|
3952 |
|
3953 | |
3954 |
|
3955 |
|
3956 |
|
3957 |
|
3958 |
|
3959 | Object.defineProperty(this, 'label', {
|
3960 | get: function() {
|
3961 | return this.labels[0];
|
3962 | },
|
3963 | set: function(newLabel) {
|
3964 |
|
3965 | var label = this.label,
|
3966 | labels = this.labels;
|
3967 |
|
3968 | if (!newLabel && label) {
|
3969 | labels.remove(label);
|
3970 | } else {
|
3971 | labels.add(newLabel, 0);
|
3972 | }
|
3973 | }
|
3974 | });
|
3975 |
|
3976 | |
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 | parentRefs.bind(this, 'parent');
|
3983 |
|
3984 | |
3985 |
|
3986 |
|
3987 |
|
3988 |
|
3989 |
|
3990 | labelRefs.bind(this, 'labels');
|
3991 |
|
3992 | |
3993 |
|
3994 |
|
3995 |
|
3996 |
|
3997 |
|
3998 | outgoingRefs.bind(this, 'outgoing');
|
3999 |
|
4000 | |
4001 |
|
4002 |
|
4003 |
|
4004 |
|
4005 |
|
4006 | incomingRefs.bind(this, 'incoming');
|
4007 | }
|
4008 |
|
4009 |
|
4010 | |
4011 |
|
4012 |
|
4013 |
|
4014 |
|
4015 |
|
4016 |
|
4017 |
|
4018 | function Shape() {
|
4019 | Base.call(this);
|
4020 |
|
4021 | |
4022 |
|
4023 |
|
4024 |
|
4025 |
|
4026 |
|
4027 | parentRefs.bind(this, 'children');
|
4028 |
|
4029 | |
4030 |
|
4031 |
|
4032 |
|
4033 | attacherRefs.bind(this, 'host');
|
4034 |
|
4035 | |
4036 |
|
4037 |
|
4038 |
|
4039 | attacherRefs.bind(this, 'attachers');
|
4040 | }
|
4041 |
|
4042 | inherits_browser(Shape, Base);
|
4043 |
|
4044 |
|
4045 | |
4046 |
|
4047 |
|
4048 |
|
4049 |
|
4050 |
|
4051 |
|
4052 |
|
4053 | function Root() {
|
4054 | Shape.call(this);
|
4055 | }
|
4056 |
|
4057 | inherits_browser(Root, Shape);
|
4058 |
|
4059 |
|
4060 | |
4061 |
|
4062 |
|
4063 |
|
4064 |
|
4065 |
|
4066 |
|
4067 |
|
4068 | function Label() {
|
4069 | Shape.call(this);
|
4070 |
|
4071 | |
4072 |
|
4073 |
|
4074 |
|
4075 |
|
4076 |
|
4077 | labelRefs.bind(this, 'labelTarget');
|
4078 | }
|
4079 |
|
4080 | inherits_browser(Label, Shape);
|
4081 |
|
4082 |
|
4083 | |
4084 |
|
4085 |
|
4086 |
|
4087 |
|
4088 |
|
4089 |
|
4090 |
|
4091 | function Connection() {
|
4092 | Base.call(this);
|
4093 |
|
4094 | |
4095 |
|
4096 |
|
4097 |
|
4098 |
|
4099 |
|
4100 | outgoingRefs.bind(this, 'source');
|
4101 |
|
4102 | |
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 |
|
4108 | incomingRefs.bind(this, 'target');
|
4109 | }
|
4110 |
|
4111 | inherits_browser(Connection, Base);
|
4112 |
|
4113 |
|
4114 | var types = {
|
4115 | connection: Connection,
|
4116 | shape: Shape,
|
4117 | label: Label,
|
4118 | root: Root
|
4119 | };
|
4120 |
|
4121 | |
4122 |
|
4123 |
|
4124 |
|
4125 |
|
4126 |
|
4127 |
|
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 |
|
4133 |
|
4134 |
|
4135 |
|
4136 |
|
4137 |
|
4138 | function create$1(type, attrs) {
|
4139 | var Type = types[type];
|
4140 | if (!Type) {
|
4141 | throw new Error('unknown type: <' + type + '>');
|
4142 | }
|
4143 | return assign(new Type(), attrs);
|
4144 | }
|
4145 |
|
4146 | |
4147 |
|
4148 |
|
4149 | function ElementFactory() {
|
4150 | this._uid = 12;
|
4151 | }
|
4152 |
|
4153 |
|
4154 | ElementFactory.prototype.createRoot = function(attrs) {
|
4155 | return this.create('root', attrs);
|
4156 | };
|
4157 |
|
4158 | ElementFactory.prototype.createLabel = function(attrs) {
|
4159 | return this.create('label', attrs);
|
4160 | };
|
4161 |
|
4162 | ElementFactory.prototype.createShape = function(attrs) {
|
4163 | return this.create('shape', attrs);
|
4164 | };
|
4165 |
|
4166 | ElementFactory.prototype.createConnection = function(attrs) {
|
4167 | return this.create('connection', attrs);
|
4168 | };
|
4169 |
|
4170 | |
4171 |
|
4172 |
|
4173 |
|
4174 |
|
4175 |
|
4176 |
|
4177 |
|
4178 | ElementFactory.prototype.create = function(type, attrs) {
|
4179 |
|
4180 | attrs = assign({}, attrs || {});
|
4181 |
|
4182 | if (!attrs.id) {
|
4183 | attrs.id = type + '_' + (this._uid++);
|
4184 | }
|
4185 |
|
4186 | return create$1(type, attrs);
|
4187 | };
|
4188 |
|
4189 | var FN_REF = '__fn';
|
4190 |
|
4191 | var DEFAULT_PRIORITY = 1000;
|
4192 |
|
4193 | var slice$2 = Array.prototype.slice;
|
4194 |
|
4195 | |
4196 |
|
4197 |
|
4198 |
|
4199 |
|
4200 |
|
4201 |
|
4202 |
|
4203 |
|
4204 |
|
4205 |
|
4206 |
|
4207 |
|
4208 |
|
4209 |
|
4210 |
|
4211 |
|
4212 |
|
4213 |
|
4214 |
|
4215 |
|
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 |
|
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 |
|
4237 |
|
4238 |
|
4239 |
|
4240 |
|
4241 |
|
4242 |
|
4243 |
|
4244 |
|
4245 |
|
4246 |
|
4247 |
|
4248 |
|
4249 |
|
4250 |
|
4251 |
|
4252 |
|
4253 |
|
4254 |
|
4255 |
|
4256 |
|
4257 |
|
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 |
|
4269 |
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 |
|
4278 | function EventBus() {
|
4279 | this._listeners = {};
|
4280 |
|
4281 |
|
4282 |
|
4283 | this.on('diagram.destroy', 1, this._destroy, this);
|
4284 | }
|
4285 |
|
4286 |
|
4287 | |
4288 |
|
4289 |
|
4290 |
|
4291 |
|
4292 |
|
4293 |
|
4294 |
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 | EventBus.prototype.on = function(events, priority, callback, that) {
|
4305 |
|
4306 | events = isArray(events) ? events : [ events ];
|
4307 |
|
4308 | if (isFunction(priority)) {
|
4309 | that = callback;
|
4310 | callback = priority;
|
4311 | priority = DEFAULT_PRIORITY;
|
4312 | }
|
4313 |
|
4314 | if (!isNumber(priority)) {
|
4315 | throw new Error('priority must be a number');
|
4316 | }
|
4317 |
|
4318 | var actualCallback = callback;
|
4319 |
|
4320 | if (that) {
|
4321 | actualCallback = bind(callback, that);
|
4322 |
|
4323 |
|
4324 |
|
4325 |
|
4326 | actualCallback[FN_REF] = callback[FN_REF] || callback;
|
4327 | }
|
4328 |
|
4329 | var self = this,
|
4330 | listener = { priority: priority, callback: actualCallback };
|
4331 |
|
4332 | events.forEach(function(e) {
|
4333 | self._addListener(e, listener);
|
4334 | });
|
4335 | };
|
4336 |
|
4337 |
|
4338 | |
4339 |
|
4340 |
|
4341 |
|
4342 |
|
4343 |
|
4344 |
|
4345 | EventBus.prototype.once = function(event, priority, callback, that) {
|
4346 | var self = this;
|
4347 |
|
4348 | if (isFunction(priority)) {
|
4349 | that = callback;
|
4350 | callback = priority;
|
4351 | priority = DEFAULT_PRIORITY;
|
4352 | }
|
4353 |
|
4354 | if (!isNumber(priority)) {
|
4355 | throw new Error('priority must be a number');
|
4356 | }
|
4357 |
|
4358 | function wrappedCallback() {
|
4359 | self.off(event, wrappedCallback);
|
4360 | return callback.apply(that, arguments);
|
4361 | }
|
4362 |
|
4363 |
|
4364 |
|
4365 |
|
4366 | wrappedCallback[FN_REF] = callback;
|
4367 |
|
4368 | this.on(event, priority, wrappedCallback);
|
4369 | };
|
4370 |
|
4371 |
|
4372 | |
4373 |
|
4374 |
|
4375 |
|
4376 |
|
4377 |
|
4378 |
|
4379 |
|
4380 | EventBus.prototype.off = function(events, callback) {
|
4381 |
|
4382 | events = isArray(events) ? events : [ events ];
|
4383 |
|
4384 | var self = this;
|
4385 |
|
4386 | events.forEach(function(event) {
|
4387 | self._removeListener(event, callback);
|
4388 | });
|
4389 |
|
4390 | };
|
4391 |
|
4392 |
|
4393 | |
4394 |
|
4395 |
|
4396 |
|
4397 |
|
4398 |
|
4399 |
|
4400 | EventBus.prototype.createEvent = function(data) {
|
4401 | var event = new InternalEvent();
|
4402 |
|
4403 | event.init(data);
|
4404 |
|
4405 | return event;
|
4406 | };
|
4407 |
|
4408 |
|
4409 | |
4410 |
|
4411 |
|
4412 |
|
4413 |
|
4414 |
|
4415 |
|
4416 |
|
4417 |
|
4418 |
|
4419 |
|
4420 |
|
4421 |
|
4422 |
|
4423 |
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 |
|
4439 | EventBus.prototype.fire = function(type, data) {
|
4440 |
|
4441 | var event,
|
4442 | listeners,
|
4443 | returnValue,
|
4444 | args;
|
4445 |
|
4446 | args = slice$2.call(arguments);
|
4447 |
|
4448 | if (typeof type === 'object') {
|
4449 | event = type;
|
4450 | type = event.type;
|
4451 | }
|
4452 |
|
4453 | if (!type) {
|
4454 | throw new Error('no event type specified');
|
4455 | }
|
4456 |
|
4457 | listeners = this._listeners[type];
|
4458 |
|
4459 | if (!listeners) {
|
4460 | return;
|
4461 | }
|
4462 |
|
4463 |
|
4464 |
|
4465 | if (data instanceof InternalEvent) {
|
4466 |
|
4467 | event = data;
|
4468 | } else {
|
4469 | event = this.createEvent(data);
|
4470 | }
|
4471 |
|
4472 |
|
4473 | args[0] = event;
|
4474 |
|
4475 |
|
4476 | var originalType = event.type;
|
4477 |
|
4478 |
|
4479 | if (type !== originalType) {
|
4480 | event.type = type;
|
4481 | }
|
4482 |
|
4483 | try {
|
4484 | returnValue = this._invokeListeners(event, args, listeners);
|
4485 | } finally {
|
4486 |
|
4487 | if (type !== originalType) {
|
4488 | event.type = originalType;
|
4489 | }
|
4490 | }
|
4491 |
|
4492 |
|
4493 |
|
4494 | if (returnValue === undefined && event.defaultPrevented) {
|
4495 | returnValue = false;
|
4496 | }
|
4497 |
|
4498 | return returnValue;
|
4499 | };
|
4500 |
|
4501 |
|
4502 | EventBus.prototype.handleError = function(error) {
|
4503 | return this.fire('error', { error: error }) === false;
|
4504 | };
|
4505 |
|
4506 |
|
4507 | EventBus.prototype._destroy = function() {
|
4508 | this._listeners = {};
|
4509 | };
|
4510 |
|
4511 | EventBus.prototype._invokeListeners = function(event, args, listeners) {
|
4512 |
|
4513 | var idx,
|
4514 | listener,
|
4515 | returnValue;
|
4516 |
|
4517 | for (idx = 0; (listener = listeners[idx]); idx++) {
|
4518 |
|
4519 |
|
4520 | if (event.cancelBubble) {
|
4521 | break;
|
4522 | }
|
4523 |
|
4524 | returnValue = this._invokeListener(event, args, listener);
|
4525 | }
|
4526 |
|
4527 | return returnValue;
|
4528 | };
|
4529 |
|
4530 | EventBus.prototype._invokeListener = function(event, args, listener) {
|
4531 |
|
4532 | var returnValue;
|
4533 |
|
4534 | try {
|
4535 |
|
4536 | returnValue = invokeFunction(listener.callback, args);
|
4537 |
|
4538 |
|
4539 | if (returnValue !== undefined) {
|
4540 | event.returnValue = returnValue;
|
4541 | event.stopPropagation();
|
4542 | }
|
4543 |
|
4544 |
|
4545 | if (returnValue === false) {
|
4546 | event.preventDefault();
|
4547 | }
|
4548 | } catch (e) {
|
4549 | if (!this.handleError(e)) {
|
4550 | console.error('unhandled error in event listener');
|
4551 | console.error(e.stack);
|
4552 |
|
4553 | throw e;
|
4554 | }
|
4555 | }
|
4556 |
|
4557 | return returnValue;
|
4558 | };
|
4559 |
|
4560 | |
4561 |
|
4562 |
|
4563 |
|
4564 |
|
4565 |
|
4566 |
|
4567 |
|
4568 |
|
4569 |
|
4570 |
|
4571 |
|
4572 |
|
4573 |
|
4574 |
|
4575 |
|
4576 | EventBus.prototype._addListener = function(event, newListener) {
|
4577 |
|
4578 | var listeners = this._getListeners(event),
|
4579 | existingListener,
|
4580 | idx;
|
4581 |
|
4582 |
|
4583 |
|
4584 | for (idx = 0; (existingListener = listeners[idx]); idx++) {
|
4585 | if (existingListener.priority < newListener.priority) {
|
4586 |
|
4587 |
|
4588 | listeners.splice(idx, 0, newListener);
|
4589 | return;
|
4590 | }
|
4591 | }
|
4592 |
|
4593 | listeners.push(newListener);
|
4594 | };
|
4595 |
|
4596 |
|
4597 | EventBus.prototype._getListeners = function(name) {
|
4598 | var listeners = this._listeners[name];
|
4599 |
|
4600 | if (!listeners) {
|
4601 | this._listeners[name] = listeners = [];
|
4602 | }
|
4603 |
|
4604 | return listeners;
|
4605 | };
|
4606 |
|
4607 |
|
4608 | EventBus.prototype._removeListener = function(event, callback) {
|
4609 |
|
4610 | var listeners = this._getListeners(event),
|
4611 | listener,
|
4612 | listenerCallback,
|
4613 | idx;
|
4614 |
|
4615 | if (callback) {
|
4616 |
|
4617 |
|
4618 |
|
4619 | for (idx = listeners.length - 1; (listener = listeners[idx]); idx--) {
|
4620 | listenerCallback = listener.callback;
|
4621 |
|
4622 | if (listenerCallback === callback || listenerCallback[FN_REF] === callback) {
|
4623 | listeners.splice(idx, 1);
|
4624 | }
|
4625 | }
|
4626 | } else {
|
4627 |
|
4628 | listeners.length = 0;
|
4629 | }
|
4630 | };
|
4631 |
|
4632 |
|
4633 | |
4634 |
|
4635 |
|
4636 | function InternalEvent() { }
|
4637 |
|
4638 | InternalEvent.prototype.stopPropagation = function() {
|
4639 | this.cancelBubble = true;
|
4640 | };
|
4641 |
|
4642 | InternalEvent.prototype.preventDefault = function() {
|
4643 | this.defaultPrevented = true;
|
4644 | };
|
4645 |
|
4646 | InternalEvent.prototype.init = function(data) {
|
4647 | assign(this, data || {});
|
4648 | };
|
4649 |
|
4650 |
|
4651 | |
4652 |
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 |
|
4659 | function invokeFunction(fn, args) {
|
4660 | return fn.apply(null, args);
|
4661 | }
|
4662 |
|
4663 | |
4664 |
|
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 |
|
4670 | |
4671 |
|
4672 |
|
4673 |
|
4674 |
|
4675 |
|
4676 |
|
4677 | function getVisual(gfx) {
|
4678 | return query('.djs-visual', gfx);
|
4679 | }
|
4680 |
|
4681 | |
4682 |
|
4683 |
|
4684 |
|
4685 |
|
4686 |
|
4687 | function getChildren(gfx) {
|
4688 | return gfx.parentNode.childNodes[1];
|
4689 | }
|
4690 |
|
4691 | |
4692 |
|
4693 |
|
4694 |
|
4695 |
|
4696 |
|
4697 |
|
4698 | function transform$1(gfx, x, y, angle, amount) {
|
4699 | var translate = createTransform();
|
4700 | translate.setTranslate(x, y);
|
4701 |
|
4702 | var rotate = createTransform();
|
4703 | rotate.setRotate(angle, 0, 0);
|
4704 |
|
4705 | var scale = createTransform();
|
4706 | scale.setScale(amount || 1, amount || 1);
|
4707 |
|
4708 | transform(gfx, [ translate, rotate, scale ]);
|
4709 | }
|
4710 |
|
4711 |
|
4712 | |
4713 |
|
4714 |
|
4715 |
|
4716 |
|
4717 | function translate(gfx, x, y) {
|
4718 | var translate = createTransform();
|
4719 | translate.setTranslate(x, y);
|
4720 |
|
4721 | transform(gfx, translate);
|
4722 | }
|
4723 |
|
4724 |
|
4725 | |
4726 |
|
4727 |
|
4728 |
|
4729 | function rotate(gfx, angle) {
|
4730 | var rotate = createTransform();
|
4731 | rotate.setRotate(angle, 0, 0);
|
4732 |
|
4733 | transform(gfx, rotate);
|
4734 | }
|
4735 |
|
4736 | |
4737 |
|
4738 |
|
4739 |
|
4740 |
|
4741 |
|
4742 | function GraphicsFactory(eventBus, elementRegistry) {
|
4743 | this._eventBus = eventBus;
|
4744 | this._elementRegistry = elementRegistry;
|
4745 | }
|
4746 |
|
4747 | GraphicsFactory.$inject = [ 'eventBus' , 'elementRegistry' ];
|
4748 |
|
4749 |
|
4750 | GraphicsFactory.prototype._getChildren = function(element) {
|
4751 |
|
4752 | var gfx = this._elementRegistry.getGraphics(element);
|
4753 |
|
4754 | var childrenGfx;
|
4755 |
|
4756 |
|
4757 | if (!element.parent) {
|
4758 | childrenGfx = gfx;
|
4759 | } else {
|
4760 | childrenGfx = getChildren(gfx);
|
4761 | if (!childrenGfx) {
|
4762 | childrenGfx = create('g');
|
4763 | classes$1(childrenGfx).add('djs-children');
|
4764 |
|
4765 | append(gfx.parentNode, childrenGfx);
|
4766 | }
|
4767 | }
|
4768 |
|
4769 | return childrenGfx;
|
4770 | };
|
4771 |
|
4772 | |
4773 |
|
4774 |
|
4775 |
|
4776 | GraphicsFactory.prototype._clear = function(gfx) {
|
4777 | var visual = getVisual(gfx);
|
4778 |
|
4779 | clear(visual);
|
4780 |
|
4781 | return visual;
|
4782 | };
|
4783 |
|
4784 | |
4785 |
|
4786 |
|
4787 |
|
4788 |
|
4789 |
|
4790 |
|
4791 |
|
4792 |
|
4793 |
|
4794 |
|
4795 |
|
4796 |
|
4797 |
|
4798 |
|
4799 |
|
4800 |
|
4801 |
|
4802 |
|
4803 |
|
4804 |
|
4805 |
|
4806 |
|
4807 |
|
4808 | GraphicsFactory.prototype._createContainer = function(type, childrenGfx, parentIndex) {
|
4809 | var outerGfx = create('g');
|
4810 | classes$1(outerGfx).add('djs-group');
|
4811 |
|
4812 |
|
4813 | if (typeof parentIndex !== 'undefined') {
|
4814 | prependTo$1(outerGfx, childrenGfx, childrenGfx.childNodes[parentIndex]);
|
4815 | } else {
|
4816 | append(childrenGfx, outerGfx);
|
4817 | }
|
4818 |
|
4819 | var gfx = create('g');
|
4820 | classes$1(gfx).add('djs-element');
|
4821 | classes$1(gfx).add('djs-' + type);
|
4822 |
|
4823 | append(outerGfx, gfx);
|
4824 |
|
4825 |
|
4826 | var visual = create('g');
|
4827 | classes$1(visual).add('djs-visual');
|
4828 |
|
4829 | append(gfx, visual);
|
4830 |
|
4831 | return gfx;
|
4832 | };
|
4833 |
|
4834 | GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
4835 | var childrenGfx = this._getChildren(element.parent);
|
4836 | return this._createContainer(type, childrenGfx, parentIndex);
|
4837 | };
|
4838 |
|
4839 | GraphicsFactory.prototype.updateContainments = function(elements) {
|
4840 |
|
4841 | var self = this,
|
4842 | elementRegistry = this._elementRegistry,
|
4843 | parents;
|
4844 |
|
4845 | parents = reduce(elements, function(map$$1, e) {
|
4846 |
|
4847 | if (e.parent) {
|
4848 | map$$1[e.parent.id] = e.parent;
|
4849 | }
|
4850 |
|
4851 | return map$$1;
|
4852 | }, {});
|
4853 |
|
4854 |
|
4855 |
|
4856 | forEach(parents, function(parent) {
|
4857 |
|
4858 | var children = parent.children;
|
4859 |
|
4860 | if (!children) {
|
4861 | return;
|
4862 | }
|
4863 |
|
4864 | var childGfx = self._getChildren(parent);
|
4865 |
|
4866 | forEach(children.slice().reverse(), function(c) {
|
4867 | var gfx = elementRegistry.getGraphics(c);
|
4868 |
|
4869 | prependTo$1(gfx.parentNode, childGfx);
|
4870 | });
|
4871 | });
|
4872 | };
|
4873 |
|
4874 | GraphicsFactory.prototype.drawShape = function(visual, element) {
|
4875 | var eventBus = this._eventBus;
|
4876 |
|
4877 | return eventBus.fire('render.shape', { gfx: visual, element: element });
|
4878 | };
|
4879 |
|
4880 | GraphicsFactory.prototype.getShapePath = function(element) {
|
4881 | var eventBus = this._eventBus;
|
4882 |
|
4883 | return eventBus.fire('render.getShapePath', element);
|
4884 | };
|
4885 |
|
4886 | GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
4887 | var eventBus = this._eventBus;
|
4888 |
|
4889 | return eventBus.fire('render.connection', { gfx: visual, element: element });
|
4890 | };
|
4891 |
|
4892 | GraphicsFactory.prototype.getConnectionPath = function(waypoints) {
|
4893 | var eventBus = this._eventBus;
|
4894 |
|
4895 | return eventBus.fire('render.getConnectionPath', waypoints);
|
4896 | };
|
4897 |
|
4898 | GraphicsFactory.prototype.update = function(type, element, gfx) {
|
4899 |
|
4900 | if (!element.parent) {
|
4901 | return;
|
4902 | }
|
4903 |
|
4904 | var visual = this._clear(gfx);
|
4905 |
|
4906 |
|
4907 | if (type === 'shape') {
|
4908 | this.drawShape(visual, element);
|
4909 |
|
4910 |
|
4911 | translate(gfx, element.x, element.y);
|
4912 | } else
|
4913 | if (type === 'connection') {
|
4914 | this.drawConnection(visual, element);
|
4915 | } else {
|
4916 | throw new Error('unknown type: ' + type);
|
4917 | }
|
4918 |
|
4919 | if (element.hidden) {
|
4920 | attr$1(gfx, 'display', 'none');
|
4921 | } else {
|
4922 | attr$1(gfx, 'display', 'block');
|
4923 | }
|
4924 | };
|
4925 |
|
4926 | GraphicsFactory.prototype.remove = function(element) {
|
4927 | var gfx = this._elementRegistry.getGraphics(element);
|
4928 |
|
4929 |
|
4930 | remove$1(gfx.parentNode);
|
4931 | };
|
4932 |
|
4933 |
|
4934 |
|
4935 |
|
4936 | function prependTo$1(newNode, parentNode, siblingNode) {
|
4937 | parentNode.insertBefore(newNode, siblingNode || parentNode.firstChild);
|
4938 | }
|
4939 |
|
4940 | var CoreModule = {
|
4941 | __depends__: [ DrawModule ],
|
4942 | __init__: [ 'canvas' ],
|
4943 | canvas: [ 'type', Canvas ],
|
4944 | elementRegistry: [ 'type', ElementRegistry ],
|
4945 | elementFactory: [ 'type', ElementFactory ],
|
4946 | eventBus: [ 'type', EventBus ],
|
4947 | graphicsFactory: [ 'type', GraphicsFactory ]
|
4948 | };
|
4949 |
|
4950 | |
4951 |
|
4952 |
|
4953 |
|
4954 |
|
4955 |
|
4956 |
|
4957 |
|
4958 | function bootstrap(bootstrapModules) {
|
4959 |
|
4960 | var modules = [],
|
4961 | components = [];
|
4962 |
|
4963 | function hasModule(m) {
|
4964 | return modules.indexOf(m) >= 0;
|
4965 | }
|
4966 |
|
4967 | function addModule(m) {
|
4968 | modules.push(m);
|
4969 | }
|
4970 |
|
4971 | function visit(m) {
|
4972 | if (hasModule(m)) {
|
4973 | return;
|
4974 | }
|
4975 |
|
4976 | (m.__depends__ || []).forEach(visit);
|
4977 |
|
4978 | if (hasModule(m)) {
|
4979 | return;
|
4980 | }
|
4981 |
|
4982 | addModule(m);
|
4983 |
|
4984 | (m.__init__ || []).forEach(function(c) {
|
4985 | components.push(c);
|
4986 | });
|
4987 | }
|
4988 |
|
4989 | bootstrapModules.forEach(visit);
|
4990 |
|
4991 | var injector = new Injector(modules);
|
4992 |
|
4993 | components.forEach(function(c) {
|
4994 |
|
4995 | try {
|
4996 |
|
4997 | injector[typeof c === 'string' ? 'get' : 'invoke'](c);
|
4998 | } catch (e) {
|
4999 | console.error('Failed to instantiate component');
|
5000 | console.error(e.stack);
|
5001 |
|
5002 | throw e;
|
5003 | }
|
5004 | });
|
5005 |
|
5006 | return injector;
|
5007 | }
|
5008 |
|
5009 | |
5010 |
|
5011 |
|
5012 |
|
5013 |
|
5014 |
|
5015 |
|
5016 | function createInjector(options) {
|
5017 |
|
5018 | options = options || {};
|
5019 |
|
5020 | var configModule = {
|
5021 | 'config': ['value', options]
|
5022 | };
|
5023 |
|
5024 | var modules = [ configModule, CoreModule ].concat(options.modules || []);
|
5025 |
|
5026 | return bootstrap(modules);
|
5027 | }
|
5028 |
|
5029 |
|
5030 | |
5031 |
|
5032 |
|
5033 |
|
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 |
|
5041 |
|
5042 |
|
5043 |
|
5044 |
|
5045 |
|
5046 |
|
5047 |
|
5048 |
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 |
|
5058 |
|
5059 |
|
5060 |
|
5061 |
|
5062 |
|
5063 |
|
5064 |
|
5065 |
|
5066 |
|
5067 |
|
5068 |
|
5069 |
|
5070 |
|
5071 |
|
5072 |
|
5073 |
|
5074 |
|
5075 |
|
5076 |
|
5077 |
|
5078 |
|
5079 | function Diagram(options, injector) {
|
5080 |
|
5081 |
|
5082 | this.injector = injector = injector || createInjector(options);
|
5083 |
|
5084 |
|
5085 |
|
5086 | |
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 |
|
5094 | this.get = injector.get;
|
5095 |
|
5096 | |
5097 |
|
5098 |
|
5099 |
|
5100 |
|
5101 |
|
5102 |
|
5103 |
|
5104 | this.invoke = injector.invoke;
|
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 |
|
5110 |
|
5111 | |
5112 |
|
5113 |
|
5114 |
|
5115 |
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 |
|
5121 |
|
5122 |
|
5123 |
|
5124 |
|
5125 |
|
5126 |
|
5127 |
|
5128 | this.get('eventBus').fire('diagram.init');
|
5129 | }
|
5130 |
|
5131 |
|
5132 | |
5133 |
|
5134 |
|
5135 |
|
5136 |
|
5137 | Diagram.prototype.destroy = function() {
|
5138 | this.get('eventBus').fire('diagram.destroy');
|
5139 | };
|
5140 |
|
5141 | |
5142 |
|
5143 |
|
5144 | Diagram.prototype.clear = function() {
|
5145 | this.get('eventBus').fire('diagram.clear');
|
5146 | };
|
5147 |
|
5148 | var diagramJs = Diagram;
|
5149 |
|
5150 | |
5151 |
|
5152 |
|
5153 | function Base$1() { }
|
5154 |
|
5155 | Base$1.prototype.get = function(name) {
|
5156 | return this.$model.properties.get(this, name);
|
5157 | };
|
5158 |
|
5159 | Base$1.prototype.set = function(name, value) {
|
5160 | this.$model.properties.set(this, name, value);
|
5161 | };
|
5162 |
|
5163 | |
5164 |
|
5165 |
|
5166 |
|
5167 |
|
5168 |
|
5169 | function Factory(model, properties) {
|
5170 | this.model = model;
|
5171 | this.properties = properties;
|
5172 | }
|
5173 |
|
5174 |
|
5175 | Factory.prototype.createType = function(descriptor) {
|
5176 |
|
5177 | var model = this.model;
|
5178 |
|
5179 | var props = this.properties,
|
5180 | prototype = Object.create(Base$1.prototype);
|
5181 |
|
5182 |
|
5183 | forEach(descriptor.properties, function(p) {
|
5184 | if (!p.isMany && p.default !== undefined) {
|
5185 | prototype[p.name] = p.default;
|
5186 | }
|
5187 | });
|
5188 |
|
5189 | props.defineModel(prototype, model);
|
5190 | props.defineDescriptor(prototype, descriptor);
|
5191 |
|
5192 | var name = descriptor.ns.name;
|
5193 |
|
5194 | |
5195 |
|
5196 |
|
5197 | function ModdleElement(attrs) {
|
5198 | props.define(this, '$type', { value: name, enumerable: true });
|
5199 | props.define(this, '$attrs', { value: {} });
|
5200 | props.define(this, '$parent', { writable: true });
|
5201 |
|
5202 | forEach(attrs, bind(function(val, key) {
|
5203 | this.set(key, val);
|
5204 | }, this));
|
5205 | }
|
5206 |
|
5207 | ModdleElement.prototype = prototype;
|
5208 |
|
5209 | ModdleElement.hasType = prototype.$instanceOf = this.model.hasType;
|
5210 |
|
5211 |
|
5212 | props.defineModel(ModdleElement, model);
|
5213 | props.defineDescriptor(ModdleElement, descriptor);
|
5214 |
|
5215 | return ModdleElement;
|
5216 | };
|
5217 |
|
5218 | |
5219 |
|
5220 |
|
5221 | var BUILTINS = {
|
5222 | String: true,
|
5223 | Boolean: true,
|
5224 | Integer: true,
|
5225 | Real: true,
|
5226 | Element: true
|
5227 | };
|
5228 |
|
5229 | |
5230 |
|
5231 |
|
5232 | var TYPE_CONVERTERS = {
|
5233 | String: function(s) { return s; },
|
5234 | Boolean: function(s) { return s === 'true'; },
|
5235 | Integer: function(s) { return parseInt(s, 10); },
|
5236 | Real: function(s) { return parseFloat(s, 10); }
|
5237 | };
|
5238 |
|
5239 | |
5240 |
|
5241 |
|
5242 | function coerceType(type, value) {
|
5243 |
|
5244 | var converter = TYPE_CONVERTERS[type];
|
5245 |
|
5246 | if (converter) {
|
5247 | return converter(value);
|
5248 | } else {
|
5249 | return value;
|
5250 | }
|
5251 | }
|
5252 |
|
5253 | |
5254 |
|
5255 |
|
5256 | function isBuiltIn(type) {
|
5257 | return !!BUILTINS[type];
|
5258 | }
|
5259 |
|
5260 | |
5261 |
|
5262 |
|
5263 | function isSimple(type) {
|
5264 | return !!TYPE_CONVERTERS[type];
|
5265 | }
|
5266 |
|
5267 | |
5268 |
|
5269 |
|
5270 |
|
5271 |
|
5272 |
|
5273 |
|
5274 |
|
5275 |
|
5276 | function parseName(name, defaultPrefix) {
|
5277 | var parts = name.split(/:/),
|
5278 | localName, prefix;
|
5279 |
|
5280 |
|
5281 | if (parts.length === 1) {
|
5282 | localName = name;
|
5283 | prefix = defaultPrefix;
|
5284 | } else
|
5285 |
|
5286 | if (parts.length === 2) {
|
5287 | localName = parts[1];
|
5288 | prefix = parts[0];
|
5289 | } else {
|
5290 | throw new Error('expected <prefix:localName> or <localName>, got ' + name);
|
5291 | }
|
5292 |
|
5293 | name = (prefix ? prefix + ':' : '') + localName;
|
5294 |
|
5295 | return {
|
5296 | name: name,
|
5297 | prefix: prefix,
|
5298 | localName: localName
|
5299 | };
|
5300 | }
|
5301 |
|
5302 | |
5303 |
|
5304 |
|
5305 | function DescriptorBuilder(nameNs) {
|
5306 | this.ns = nameNs;
|
5307 | this.name = nameNs.name;
|
5308 | this.allTypes = [];
|
5309 | this.allTypesByName = {};
|
5310 | this.properties = [];
|
5311 | this.propertiesByName = {};
|
5312 | }
|
5313 |
|
5314 |
|
5315 | DescriptorBuilder.prototype.build = function() {
|
5316 | return pick(this, [
|
5317 | 'ns',
|
5318 | 'name',
|
5319 | 'allTypes',
|
5320 | 'allTypesByName',
|
5321 | 'properties',
|
5322 | 'propertiesByName',
|
5323 | 'bodyProperty',
|
5324 | 'idProperty'
|
5325 | ]);
|
5326 | };
|
5327 |
|
5328 | |
5329 |
|
5330 |
|
5331 |
|
5332 |
|
5333 |
|
5334 |
|
5335 | DescriptorBuilder.prototype.addProperty = function(p, idx, validate) {
|
5336 |
|
5337 | if (typeof idx === 'boolean') {
|
5338 | validate = idx;
|
5339 | idx = undefined;
|
5340 | }
|
5341 |
|
5342 | this.addNamedProperty(p, validate !== false);
|
5343 |
|
5344 | var properties = this.properties;
|
5345 |
|
5346 | if (idx !== undefined) {
|
5347 | properties.splice(idx, 0, p);
|
5348 | } else {
|
5349 | properties.push(p);
|
5350 | }
|
5351 | };
|
5352 |
|
5353 |
|
5354 | DescriptorBuilder.prototype.replaceProperty = function(oldProperty, newProperty, replace) {
|
5355 | var oldNameNs = oldProperty.ns;
|
5356 |
|
5357 | var props = this.properties,
|
5358 | propertiesByName = this.propertiesByName,
|
5359 | rename = oldProperty.name !== newProperty.name;
|
5360 |
|
5361 | if (oldProperty.isId) {
|
5362 | if (!newProperty.isId) {
|
5363 | throw new Error(
|
5364 | 'property <' + newProperty.ns.name + '> must be id property ' +
|
5365 | 'to refine <' + oldProperty.ns.name + '>');
|
5366 | }
|
5367 |
|
5368 | this.setIdProperty(newProperty, false);
|
5369 | }
|
5370 |
|
5371 | if (oldProperty.isBody) {
|
5372 |
|
5373 | if (!newProperty.isBody) {
|
5374 | throw new Error(
|
5375 | 'property <' + newProperty.ns.name + '> must be body property ' +
|
5376 | 'to refine <' + oldProperty.ns.name + '>');
|
5377 | }
|
5378 |
|
5379 |
|
5380 | this.setBodyProperty(newProperty, false);
|
5381 | }
|
5382 |
|
5383 |
|
5384 | var idx = props.indexOf(oldProperty);
|
5385 | if (idx === -1) {
|
5386 | throw new Error('property <' + oldNameNs.name + '> not found in property list');
|
5387 | }
|
5388 |
|
5389 |
|
5390 | props.splice(idx, 1);
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 | this.addProperty(newProperty, replace ? undefined : idx, rename);
|
5398 |
|
5399 |
|
5400 | propertiesByName[oldNameNs.name] = propertiesByName[oldNameNs.localName] = newProperty;
|
5401 | };
|
5402 |
|
5403 |
|
5404 | DescriptorBuilder.prototype.redefineProperty = function(p, targetPropertyName, replace) {
|
5405 |
|
5406 | var nsPrefix = p.ns.prefix;
|
5407 | var parts = targetPropertyName.split('#');
|
5408 |
|
5409 | var name = parseName(parts[0], nsPrefix);
|
5410 | var attrName = parseName(parts[1], name.prefix).name;
|
5411 |
|
5412 | var redefinedProperty = this.propertiesByName[attrName];
|
5413 | if (!redefinedProperty) {
|
5414 | throw new Error('refined property <' + attrName + '> not found');
|
5415 | } else {
|
5416 | this.replaceProperty(redefinedProperty, p, replace);
|
5417 | }
|
5418 |
|
5419 | delete p.redefines;
|
5420 | };
|
5421 |
|
5422 | DescriptorBuilder.prototype.addNamedProperty = function(p, validate) {
|
5423 | var ns = p.ns,
|
5424 | propsByName = this.propertiesByName;
|
5425 |
|
5426 | if (validate) {
|
5427 | this.assertNotDefined(p, ns.name);
|
5428 | this.assertNotDefined(p, ns.localName);
|
5429 | }
|
5430 |
|
5431 | propsByName[ns.name] = propsByName[ns.localName] = p;
|
5432 | };
|
5433 |
|
5434 | DescriptorBuilder.prototype.removeNamedProperty = function(p) {
|
5435 | var ns = p.ns,
|
5436 | propsByName = this.propertiesByName;
|
5437 |
|
5438 | delete propsByName[ns.name];
|
5439 | delete propsByName[ns.localName];
|
5440 | };
|
5441 |
|
5442 | DescriptorBuilder.prototype.setBodyProperty = function(p, validate) {
|
5443 |
|
5444 | if (validate && this.bodyProperty) {
|
5445 | throw new Error(
|
5446 | 'body property defined multiple times ' +
|
5447 | '(<' + this.bodyProperty.ns.name + '>, <' + p.ns.name + '>)');
|
5448 | }
|
5449 |
|
5450 | this.bodyProperty = p;
|
5451 | };
|
5452 |
|
5453 | DescriptorBuilder.prototype.setIdProperty = function(p, validate) {
|
5454 |
|
5455 | if (validate && this.idProperty) {
|
5456 | throw new Error(
|
5457 | 'id property defined multiple times ' +
|
5458 | '(<' + this.idProperty.ns.name + '>, <' + p.ns.name + '>)');
|
5459 | }
|
5460 |
|
5461 | this.idProperty = p;
|
5462 | };
|
5463 |
|
5464 | DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
|
5465 | var propertyName = p.name,
|
5466 | definedProperty = this.propertiesByName[propertyName];
|
5467 |
|
5468 | if (definedProperty) {
|
5469 | throw new Error(
|
5470 | 'property <' + propertyName + '> already defined; ' +
|
5471 | 'override of <' + definedProperty.definedBy.ns.name + '#' + definedProperty.ns.name + '> by ' +
|
5472 | '<' + p.definedBy.ns.name + '#' + p.ns.name + '> not allowed without redefines');
|
5473 | }
|
5474 | };
|
5475 |
|
5476 | DescriptorBuilder.prototype.hasProperty = function(name) {
|
5477 | return this.propertiesByName[name];
|
5478 | };
|
5479 |
|
5480 | DescriptorBuilder.prototype.addTrait = function(t, inherited) {
|
5481 |
|
5482 | var typesByName = this.allTypesByName,
|
5483 | types = this.allTypes;
|
5484 |
|
5485 | var typeName = t.name;
|
5486 |
|
5487 | if (typeName in typesByName) {
|
5488 | return;
|
5489 | }
|
5490 |
|
5491 | forEach(t.properties, bind(function(p) {
|
5492 |
|
5493 |
|
5494 | p = assign({}, p, {
|
5495 | name: p.ns.localName,
|
5496 | inherited: inherited
|
5497 | });
|
5498 |
|
5499 | Object.defineProperty(p, 'definedBy', {
|
5500 | value: t
|
5501 | });
|
5502 |
|
5503 | var replaces = p.replaces,
|
5504 | redefines = p.redefines;
|
5505 |
|
5506 |
|
5507 | if (replaces || redefines) {
|
5508 | this.redefineProperty(p, replaces || redefines, replaces);
|
5509 | } else {
|
5510 | if (p.isBody) {
|
5511 | this.setBodyProperty(p);
|
5512 | }
|
5513 | if (p.isId) {
|
5514 | this.setIdProperty(p);
|
5515 | }
|
5516 | this.addProperty(p);
|
5517 | }
|
5518 | }, this));
|
5519 |
|
5520 | types.push(t);
|
5521 | typesByName[typeName] = t;
|
5522 | };
|
5523 |
|
5524 | |
5525 |
|
5526 |
|
5527 |
|
5528 |
|
5529 |
|
5530 | function Registry(packages, properties) {
|
5531 | this.packageMap = {};
|
5532 | this.typeMap = {};
|
5533 |
|
5534 | this.packages = [];
|
5535 |
|
5536 | this.properties = properties;
|
5537 |
|
5538 | forEach(packages, bind(this.registerPackage, this));
|
5539 | }
|
5540 |
|
5541 |
|
5542 | Registry.prototype.getPackage = function(uriOrPrefix) {
|
5543 | return this.packageMap[uriOrPrefix];
|
5544 | };
|
5545 |
|
5546 | Registry.prototype.getPackages = function() {
|
5547 | return this.packages;
|
5548 | };
|
5549 |
|
5550 |
|
5551 | Registry.prototype.registerPackage = function(pkg) {
|
5552 |
|
5553 |
|
5554 | pkg = assign({}, pkg);
|
5555 |
|
5556 | var pkgMap = this.packageMap;
|
5557 |
|
5558 | ensureAvailable(pkgMap, pkg, 'prefix');
|
5559 | ensureAvailable(pkgMap, pkg, 'uri');
|
5560 |
|
5561 |
|
5562 | forEach(pkg.types, bind(function(descriptor) {
|
5563 | this.registerType(descriptor, pkg);
|
5564 | }, this));
|
5565 |
|
5566 | pkgMap[pkg.uri] = pkgMap[pkg.prefix] = pkg;
|
5567 | this.packages.push(pkg);
|
5568 | };
|
5569 |
|
5570 |
|
5571 | |
5572 |
|
5573 |
|
5574 | Registry.prototype.registerType = function(type, pkg) {
|
5575 |
|
5576 | type = assign({}, type, {
|
5577 | superClass: (type.superClass || []).slice(),
|
5578 | extends: (type.extends || []).slice(),
|
5579 | properties: (type.properties || []).slice(),
|
5580 | meta: assign((type.meta || {}))
|
5581 | });
|
5582 |
|
5583 | var ns = parseName(type.name, pkg.prefix),
|
5584 | name = ns.name,
|
5585 | propertiesByName = {};
|
5586 |
|
5587 |
|
5588 | forEach(type.properties, bind(function(p) {
|
5589 |
|
5590 |
|
5591 | var propertyNs = parseName(p.name, ns.prefix),
|
5592 | propertyName = propertyNs.name;
|
5593 |
|
5594 |
|
5595 | if (!isBuiltIn(p.type)) {
|
5596 | p.type = parseName(p.type, propertyNs.prefix).name;
|
5597 | }
|
5598 |
|
5599 | assign(p, {
|
5600 | ns: propertyNs,
|
5601 | name: propertyName
|
5602 | });
|
5603 |
|
5604 | propertiesByName[propertyName] = p;
|
5605 | }, this));
|
5606 |
|
5607 |
|
5608 | assign(type, {
|
5609 | ns: ns,
|
5610 | name: name,
|
5611 | propertiesByName: propertiesByName
|
5612 | });
|
5613 |
|
5614 | forEach(type.extends, bind(function(extendsName) {
|
5615 | var extended = this.typeMap[extendsName];
|
5616 |
|
5617 | extended.traits = extended.traits || [];
|
5618 | extended.traits.push(name);
|
5619 | }, this));
|
5620 |
|
5621 |
|
5622 | this.definePackage(type, pkg);
|
5623 |
|
5624 |
|
5625 | this.typeMap[name] = type;
|
5626 | };
|
5627 |
|
5628 |
|
5629 | |
5630 |
|
5631 |
|
5632 |
|
5633 |
|
5634 |
|
5635 |
|
5636 |
|
5637 |
|
5638 | Registry.prototype.mapTypes = function(nsName, iterator, trait) {
|
5639 |
|
5640 | var type = isBuiltIn(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];
|
5641 |
|
5642 | var self = this;
|
5643 |
|
5644 | |
5645 |
|
5646 |
|
5647 |
|
5648 |
|
5649 | function traverseTrait(cls) {
|
5650 | return traverseSuper(cls, true);
|
5651 | }
|
5652 |
|
5653 | |
5654 |
|
5655 |
|
5656 |
|
5657 |
|
5658 |
|
5659 | function traverseSuper(cls, trait) {
|
5660 | var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
|
5661 | self.mapTypes(parentNs, iterator, trait);
|
5662 | }
|
5663 |
|
5664 | if (!type) {
|
5665 | throw new Error('unknown type <' + nsName.name + '>');
|
5666 | }
|
5667 |
|
5668 | forEach(type.superClass, trait ? traverseTrait : traverseSuper);
|
5669 |
|
5670 |
|
5671 | iterator(type, !trait);
|
5672 |
|
5673 | forEach(type.traits, traverseTrait);
|
5674 | };
|
5675 |
|
5676 |
|
5677 | |
5678 |
|
5679 |
|
5680 |
|
5681 |
|
5682 |
|
5683 |
|
5684 | Registry.prototype.getEffectiveDescriptor = function(name) {
|
5685 |
|
5686 | var nsName = parseName(name);
|
5687 |
|
5688 | var builder = new DescriptorBuilder(nsName);
|
5689 |
|
5690 | this.mapTypes(nsName, function(type, inherited) {
|
5691 | builder.addTrait(type, inherited);
|
5692 | });
|
5693 |
|
5694 | var descriptor = builder.build();
|
5695 |
|
5696 |
|
5697 | this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
|
5698 |
|
5699 | return descriptor;
|
5700 | };
|
5701 |
|
5702 |
|
5703 | Registry.prototype.definePackage = function(target, pkg) {
|
5704 | this.properties.define(target, '$pkg', { value: pkg });
|
5705 | };
|
5706 |
|
5707 |
|
5708 |
|
5709 |
|
5710 |
|
5711 | function ensureAvailable(packageMap, pkg, identifierKey) {
|
5712 |
|
5713 | var value = pkg[identifierKey];
|
5714 |
|
5715 | if (value in packageMap) {
|
5716 | throw new Error('package with ' + identifierKey + ' <' + value + '> already defined');
|
5717 | }
|
5718 | }
|
5719 |
|
5720 | |
5721 |
|
5722 |
|
5723 |
|
5724 |
|
5725 | function Properties(model) {
|
5726 | this.model = model;
|
5727 | }
|
5728 |
|
5729 |
|
5730 | |
5731 |
|
5732 |
|
5733 |
|
5734 |
|
5735 |
|
5736 |
|
5737 |
|
5738 | Properties.prototype.set = function(target, name, value) {
|
5739 |
|
5740 | var property = this.model.getPropertyDescriptor(target, name);
|
5741 |
|
5742 | var propertyName = property && property.name;
|
5743 |
|
5744 | if (isUndefined$1(value)) {
|
5745 |
|
5746 |
|
5747 | if (property) {
|
5748 | delete target[propertyName];
|
5749 | } else {
|
5750 | delete target.$attrs[name];
|
5751 | }
|
5752 | } else {
|
5753 |
|
5754 |
|
5755 | if (property) {
|
5756 | if (propertyName in target) {
|
5757 | target[propertyName] = value;
|
5758 | } else {
|
5759 | defineProperty$1(target, property, value);
|
5760 | }
|
5761 | } else {
|
5762 | target.$attrs[name] = value;
|
5763 | }
|
5764 | }
|
5765 | };
|
5766 |
|
5767 | |
5768 |
|
5769 |
|
5770 |
|
5771 |
|
5772 |
|
5773 |
|
5774 |
|
5775 | Properties.prototype.get = function(target, name) {
|
5776 |
|
5777 | var property = this.model.getPropertyDescriptor(target, name);
|
5778 |
|
5779 | if (!property) {
|
5780 | return target.$attrs[name];
|
5781 | }
|
5782 |
|
5783 | var propertyName = property.name;
|
5784 |
|
5785 |
|
5786 | if (!target[propertyName] && property.isMany) {
|
5787 | defineProperty$1(target, property, []);
|
5788 | }
|
5789 |
|
5790 | return target[propertyName];
|
5791 | };
|
5792 |
|
5793 |
|
5794 | |
5795 |
|
5796 |
|
5797 |
|
5798 |
|
5799 |
|
5800 |
|
5801 | Properties.prototype.define = function(target, name, options) {
|
5802 | Object.defineProperty(target, name, options);
|
5803 | };
|
5804 |
|
5805 |
|
5806 | |
5807 |
|
5808 |
|
5809 | Properties.prototype.defineDescriptor = function(target, descriptor) {
|
5810 | this.define(target, '$descriptor', { value: descriptor });
|
5811 | };
|
5812 |
|
5813 | |
5814 |
|
5815 |
|
5816 | Properties.prototype.defineModel = function(target, model) {
|
5817 | this.define(target, '$model', { value: model });
|
5818 | };
|
5819 |
|
5820 |
|
5821 | function isUndefined$1(val) {
|
5822 | return typeof val === 'undefined';
|
5823 | }
|
5824 |
|
5825 | function defineProperty$1(target, property, value) {
|
5826 | Object.defineProperty(target, property.name, {
|
5827 | enumerable: !property.isReference,
|
5828 | writable: true,
|
5829 | value: value,
|
5830 | configurable: true
|
5831 | });
|
5832 | }
|
5833 |
|
5834 |
|
5835 |
|
5836 | |
5837 |
|
5838 |
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 |
|
5849 |
|
5850 |
|
5851 |
|
5852 |
|
5853 |
|
5854 |
|
5855 |
|
5856 |
|
5857 | function Moddle(packages) {
|
5858 |
|
5859 | this.properties = new Properties(this);
|
5860 |
|
5861 | this.factory = new Factory(this, this.properties);
|
5862 | this.registry = new Registry(packages, this.properties);
|
5863 |
|
5864 | this.typeCache = {};
|
5865 | }
|
5866 |
|
5867 |
|
5868 | |
5869 |
|
5870 |
|
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 |
|
5876 |
|
5877 |
|
5878 |
|
5879 |
|
5880 |
|
5881 |
|
5882 | Moddle.prototype.create = function(descriptor, attrs) {
|
5883 | var Type = this.getType(descriptor);
|
5884 |
|
5885 | if (!Type) {
|
5886 | throw new Error('unknown type <' + descriptor + '>');
|
5887 | }
|
5888 |
|
5889 | return new Type(attrs);
|
5890 | };
|
5891 |
|
5892 |
|
5893 | |
5894 |
|
5895 |
|
5896 |
|
5897 |
|
5898 |
|
5899 |
|
5900 |
|
5901 |
|
5902 |
|
5903 |
|
5904 |
|
5905 |
|
5906 | Moddle.prototype.getType = function(descriptor) {
|
5907 |
|
5908 | var cache = this.typeCache;
|
5909 |
|
5910 | var name = isString(descriptor) ? descriptor : descriptor.ns.name;
|
5911 |
|
5912 | var type = cache[name];
|
5913 |
|
5914 | if (!type) {
|
5915 | descriptor = this.registry.getEffectiveDescriptor(name);
|
5916 | type = cache[name] = this.factory.createType(descriptor);
|
5917 | }
|
5918 |
|
5919 | return type;
|
5920 | };
|
5921 |
|
5922 |
|
5923 | |
5924 |
|
5925 |
|
5926 |
|
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 |
|
5932 |
|
5933 |
|
5934 |
|
5935 |
|
5936 |
|
5937 |
|
5938 |
|
5939 |
|
5940 |
|
5941 |
|
5942 |
|
5943 |
|
5944 |
|
5945 |
|
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 | Moddle.prototype.createAny = function(name, nsUri, properties) {
|
5951 |
|
5952 | var nameNs = parseName(name);
|
5953 |
|
5954 | var element = {
|
5955 | $type: name,
|
5956 | $instanceOf: function(type) {
|
5957 | return type === this.$type;
|
5958 | }
|
5959 | };
|
5960 |
|
5961 | var descriptor = {
|
5962 | name: name,
|
5963 | isGeneric: true,
|
5964 | ns: {
|
5965 | prefix: nameNs.prefix,
|
5966 | localName: nameNs.localName,
|
5967 | uri: nsUri
|
5968 | }
|
5969 | };
|
5970 |
|
5971 | this.properties.defineDescriptor(element, descriptor);
|
5972 | this.properties.defineModel(element, this);
|
5973 | this.properties.define(element, '$parent', { enumerable: false, writable: true });
|
5974 |
|
5975 | forEach(properties, function(a, key) {
|
5976 | if (isObject(a) && a.value !== undefined) {
|
5977 | element[a.name] = a.value;
|
5978 | } else {
|
5979 | element[key] = a;
|
5980 | }
|
5981 | });
|
5982 |
|
5983 | return element;
|
5984 | };
|
5985 |
|
5986 | |
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 | Moddle.prototype.getPackage = function(uriOrPrefix) {
|
5992 | return this.registry.getPackage(uriOrPrefix);
|
5993 | };
|
5994 |
|
5995 | |
5996 |
|
5997 |
|
5998 |
|
5999 |
|
6000 | Moddle.prototype.getPackages = function() {
|
6001 | return this.registry.getPackages();
|
6002 | };
|
6003 |
|
6004 | |
6005 |
|
6006 |
|
6007 | Moddle.prototype.getElementDescriptor = function(element) {
|
6008 | return element.$descriptor;
|
6009 | };
|
6010 |
|
6011 | |
6012 |
|
6013 |
|
6014 |
|
6015 |
|
6016 |
|
6017 | Moddle.prototype.hasType = function(element, type) {
|
6018 | if (type === undefined) {
|
6019 | type = element;
|
6020 | element = this;
|
6021 | }
|
6022 |
|
6023 | var descriptor = element.$model.getElementDescriptor(element);
|
6024 |
|
6025 | return (type in descriptor.allTypesByName);
|
6026 | };
|
6027 |
|
6028 | |
6029 |
|
6030 |
|
6031 | Moddle.prototype.getPropertyDescriptor = function(element, property) {
|
6032 | return this.getElementDescriptor(element).propertiesByName[property];
|
6033 | };
|
6034 |
|
6035 | |
6036 |
|
6037 |
|
6038 | Moddle.prototype.getTypeDescriptor = function(type) {
|
6039 | return this.registry.typeMap[type];
|
6040 | };
|
6041 |
|
6042 | var tinyStack = createCommonjsModule(function (module, exports) {
|
6043 |
|
6044 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
6045 |
|
6046 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6047 |
|
6048 | |
6049 |
|
6050 |
|
6051 |
|
6052 |
|
6053 |
|
6054 |
|
6055 |
|
6056 |
|
6057 | (function (global) {
|
6058 |
|
6059 | var TinyStack = function () {
|
6060 | function TinyStack() {
|
6061 | _classCallCheck(this, TinyStack);
|
6062 |
|
6063 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
6064 | args[_key] = arguments[_key];
|
6065 | }
|
6066 |
|
6067 | this.data = [null].concat(args);
|
6068 | this.top = this.data.length - 1;
|
6069 | }
|
6070 |
|
6071 | _createClass(TinyStack, [{
|
6072 | key: "clear",
|
6073 | value: function clear() {
|
6074 | this.data.length = 1;
|
6075 | this.top = 0;
|
6076 |
|
6077 | return this;
|
6078 | }
|
6079 | }, {
|
6080 | key: "empty",
|
6081 | value: function empty() {
|
6082 | return this.top === 0;
|
6083 | }
|
6084 | }, {
|
6085 | key: "length",
|
6086 | value: function length() {
|
6087 | return this.top;
|
6088 | }
|
6089 | }, {
|
6090 | key: "peek",
|
6091 | value: function peek() {
|
6092 | return this.data[this.top];
|
6093 | }
|
6094 | }, {
|
6095 | key: "pop",
|
6096 | value: function pop() {
|
6097 | var result = void 0;
|
6098 |
|
6099 | if (this.top > 0) {
|
6100 | result = this.data.pop();
|
6101 | this.top--;
|
6102 | }
|
6103 |
|
6104 | return result;
|
6105 | }
|
6106 | }, {
|
6107 | key: "push",
|
6108 | value: function push(arg) {
|
6109 | this.data[++this.top] = arg;
|
6110 |
|
6111 | return this;
|
6112 | }
|
6113 | }, {
|
6114 | key: "search",
|
6115 | value: function search(arg) {
|
6116 | var index = this.data.indexOf(arg);
|
6117 |
|
6118 | return index === -1 ? -1 : this.data.length - index;
|
6119 | }
|
6120 | }]);
|
6121 |
|
6122 | return TinyStack;
|
6123 | }();
|
6124 |
|
6125 | function factory() {
|
6126 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
6127 | args[_key2] = arguments[_key2];
|
6128 | }
|
6129 |
|
6130 | return new (Function.prototype.bind.apply(TinyStack, [null].concat(args)))();
|
6131 | }
|
6132 |
|
6133 |
|
6134 | {
|
6135 | module.exports = factory;
|
6136 | }
|
6137 | })(typeof window !== "undefined" ? window : commonjsGlobal);
|
6138 | });
|
6139 |
|
6140 | var fromCharCode = String.fromCharCode;
|
6141 |
|
6142 | var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
6143 |
|
6144 | var ENTITY_PATTERN = /&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig;
|
6145 |
|
6146 | var ENTITY_MAPPING = {
|
6147 | 'amp': '&',
|
6148 | 'apos': '\'',
|
6149 | 'gt': '>',
|
6150 | 'lt': '<',
|
6151 | 'quot': '"'
|
6152 | };
|
6153 |
|
6154 |
|
6155 | Object.keys(ENTITY_MAPPING).forEach(function(k) {
|
6156 | ENTITY_MAPPING[k.toUpperCase()] = ENTITY_MAPPING[k];
|
6157 | });
|
6158 |
|
6159 |
|
6160 | function replaceEntities(_, d, x, z) {
|
6161 |
|
6162 |
|
6163 | if (z) {
|
6164 | if (hasOwnProperty$1.call(ENTITY_MAPPING, z)) {
|
6165 | return ENTITY_MAPPING[z];
|
6166 | } else {
|
6167 |
|
6168 | return '&' + z + ';';
|
6169 | }
|
6170 | }
|
6171 |
|
6172 |
|
6173 | if (d) {
|
6174 | return fromCharCode(d);
|
6175 | }
|
6176 |
|
6177 |
|
6178 | return fromCharCode(parseInt(x, 16));
|
6179 | }
|
6180 |
|
6181 |
|
6182 | |
6183 |
|
6184 |
|
6185 |
|
6186 |
|
6187 |
|
6188 |
|
6189 |
|
6190 |
|
6191 | function decodeEntities(s) {
|
6192 | if (s.length > 3 && s.indexOf('&') !== -1) {
|
6193 | return s.replace(ENTITY_PATTERN, replaceEntities);
|
6194 | }
|
6195 |
|
6196 | return s;
|
6197 | }
|
6198 |
|
6199 | var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
|
6200 | var XSI_PREFIX = 'xsi';
|
6201 | var XSI_TYPE = 'xsi:type';
|
6202 |
|
6203 | var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
|
6204 |
|
6205 | function error(msg) {
|
6206 | return new Error(msg);
|
6207 | }
|
6208 |
|
6209 | function missingNamespaceForPrefix(prefix) {
|
6210 | return 'missing namespace for prefix <' + prefix + '>';
|
6211 | }
|
6212 |
|
6213 | function getter(getFn) {
|
6214 | return {
|
6215 | 'get': getFn,
|
6216 | 'enumerable': true
|
6217 | };
|
6218 | }
|
6219 |
|
6220 | function cloneNsMatrix(nsMatrix) {
|
6221 | var clone = {}, key;
|
6222 | for (key in nsMatrix) {
|
6223 | clone[key] = nsMatrix[key];
|
6224 | }
|
6225 | return clone;
|
6226 | }
|
6227 |
|
6228 | function uriPrefix(prefix) {
|
6229 | return prefix + '$uri';
|
6230 | }
|
6231 |
|
6232 | function buildNsMatrix(nsUriToPrefix) {
|
6233 | var nsMatrix = {},
|
6234 | uri,
|
6235 | prefix;
|
6236 |
|
6237 | for (uri in nsUriToPrefix) {
|
6238 | prefix = nsUriToPrefix[uri];
|
6239 | nsMatrix[prefix] = prefix;
|
6240 | nsMatrix[uriPrefix(prefix)] = uri;
|
6241 | }
|
6242 |
|
6243 | return nsMatrix;
|
6244 | }
|
6245 |
|
6246 | function noopGetContext() {
|
6247 | return { 'line': 0, 'column': 0 };
|
6248 | }
|
6249 |
|
6250 | function throwFunc(err) {
|
6251 | throw err;
|
6252 | }
|
6253 |
|
6254 | |
6255 |
|
6256 |
|
6257 |
|
6258 |
|
6259 |
|
6260 |
|
6261 | function Parser(options) {
|
6262 |
|
6263 | if (!this) {
|
6264 | return new Parser(options);
|
6265 | }
|
6266 |
|
6267 | var proxy = options && options['proxy'];
|
6268 |
|
6269 | var onText,
|
6270 | onOpenTag,
|
6271 | onCloseTag,
|
6272 | onCDATA,
|
6273 | onError = throwFunc,
|
6274 | onWarning,
|
6275 | onComment,
|
6276 | onQuestion,
|
6277 | onAttention;
|
6278 |
|
6279 | var getContext = noopGetContext;
|
6280 |
|
6281 | |
6282 |
|
6283 |
|
6284 |
|
6285 |
|
6286 | var maybeNS = false;
|
6287 |
|
6288 | |
6289 |
|
6290 |
|
6291 |
|
6292 |
|
6293 | var isNamespace = false;
|
6294 |
|
6295 | |
6296 |
|
6297 |
|
6298 |
|
6299 |
|
6300 | var returnError = null;
|
6301 |
|
6302 | |
6303 |
|
6304 |
|
6305 |
|
6306 |
|
6307 | var parseStop = false;
|
6308 |
|
6309 | |
6310 |
|
6311 |
|
6312 |
|
6313 |
|
6314 |
|
6315 |
|
6316 |
|
6317 | var nsUriToPrefix;
|
6318 |
|
6319 | |
6320 |
|
6321 |
|
6322 |
|
6323 |
|
6324 | function handleError(err) {
|
6325 | if (!(err instanceof Error)) {
|
6326 | err = error(err);
|
6327 | }
|
6328 |
|
6329 | returnError = err;
|
6330 |
|
6331 | onError(err, getContext);
|
6332 | }
|
6333 |
|
6334 | |
6335 |
|
6336 |
|
6337 |
|
6338 |
|
6339 | function handleWarning(err) {
|
6340 |
|
6341 | if (!onWarning) {
|
6342 | return;
|
6343 | }
|
6344 |
|
6345 | if (!(err instanceof Error)) {
|
6346 | err = error(err);
|
6347 | }
|
6348 |
|
6349 | onWarning(err, getContext);
|
6350 | }
|
6351 |
|
6352 | |
6353 |
|
6354 |
|
6355 |
|
6356 |
|
6357 |
|
6358 |
|
6359 |
|
6360 | this['on'] = function(name, cb) {
|
6361 |
|
6362 | if (typeof cb !== 'function') {
|
6363 | throw error('required args <name, cb>');
|
6364 | }
|
6365 |
|
6366 | switch (name) {
|
6367 | case 'openTag': onOpenTag = cb; break;
|
6368 | case 'text': onText = cb; break;
|
6369 | case 'closeTag': onCloseTag = cb; break;
|
6370 | case 'error': onError = cb; break;
|
6371 | case 'warn': onWarning = cb; break;
|
6372 | case 'cdata': onCDATA = cb; break;
|
6373 | case 'attention': onAttention = cb; break;
|
6374 | case 'question': onQuestion = cb; break;
|
6375 | case 'comment': onComment = cb; break;
|
6376 | default:
|
6377 | throw error('unsupported event: ' + name);
|
6378 | }
|
6379 |
|
6380 | return this;
|
6381 | };
|
6382 |
|
6383 | |
6384 |
|
6385 |
|
6386 |
|
6387 |
|
6388 |
|
6389 |
|
6390 |
|
6391 |
|
6392 |
|
6393 |
|
6394 |
|
6395 |
|
6396 |
|
6397 | this['ns'] = function(nsMap) {
|
6398 |
|
6399 | if (typeof nsMap === 'undefined') {
|
6400 | nsMap = {};
|
6401 | }
|
6402 |
|
6403 | if (typeof nsMap !== 'object') {
|
6404 | throw error('required args <nsMap={}>');
|
6405 | }
|
6406 |
|
6407 | var _nsUriToPrefix = {}, k;
|
6408 |
|
6409 | for (k in nsMap) {
|
6410 | _nsUriToPrefix[k] = nsMap[k];
|
6411 | }
|
6412 |
|
6413 |
|
6414 | _nsUriToPrefix[XSI_URI] = XSI_PREFIX;
|
6415 |
|
6416 | isNamespace = true;
|
6417 | nsUriToPrefix = _nsUriToPrefix;
|
6418 |
|
6419 | return this;
|
6420 | };
|
6421 |
|
6422 | |
6423 |
|
6424 |
|
6425 |
|
6426 |
|
6427 |
|
6428 |
|
6429 | this['parse'] = function(xml) {
|
6430 | if (typeof xml !== 'string') {
|
6431 | throw error('required args <xml=string>');
|
6432 | }
|
6433 |
|
6434 | returnError = null;
|
6435 |
|
6436 | parse(xml);
|
6437 |
|
6438 | getContext = noopGetContext;
|
6439 | parseStop = false;
|
6440 |
|
6441 | return returnError;
|
6442 | };
|
6443 |
|
6444 | |
6445 |
|
6446 |
|
6447 | this['stop'] = function() {
|
6448 | parseStop = true;
|
6449 | };
|
6450 |
|
6451 | |
6452 |
|
6453 |
|
6454 |
|
6455 |
|
6456 | function parse(xml) {
|
6457 | var nsMatrixStack = isNamespace ? [] : null,
|
6458 | nsMatrix = isNamespace ? buildNsMatrix(nsUriToPrefix) : null,
|
6459 | _nsMatrix,
|
6460 | nodeStack = [],
|
6461 | anonymousNsCount = 0,
|
6462 | tagStart = false,
|
6463 | tagEnd = false,
|
6464 | i = 0, j = 0,
|
6465 | x, y, q, w,
|
6466 | xmlns,
|
6467 | elementName,
|
6468 | _elementName,
|
6469 | elementProxy
|
6470 | ;
|
6471 |
|
6472 | var attrsString = '',
|
6473 | attrsStart = 0,
|
6474 | cachedAttrs
|
6475 | ;
|
6476 |
|
6477 | |
6478 |
|
6479 |
|
6480 |
|
6481 |
|
6482 |
|
6483 |
|
6484 |
|
6485 | function getAttrs() {
|
6486 | if (cachedAttrs !== null) {
|
6487 | return cachedAttrs;
|
6488 | }
|
6489 |
|
6490 | var nsUri,
|
6491 | nsUriPrefix,
|
6492 | nsName,
|
6493 | defaultAlias = isNamespace && nsMatrix['xmlns'],
|
6494 | attrList = isNamespace && maybeNS ? [] : null,
|
6495 | i = attrsStart,
|
6496 | s = attrsString,
|
6497 | l = s.length,
|
6498 | hasNewMatrix,
|
6499 | newalias,
|
6500 | value,
|
6501 | alias,
|
6502 | name,
|
6503 | attrs = {},
|
6504 | seenAttrs = {},
|
6505 | skipAttr,
|
6506 | w,
|
6507 | j;
|
6508 |
|
6509 | parseAttr:
|
6510 | for (; i < l; i++) {
|
6511 | skipAttr = false;
|
6512 | w = s.charCodeAt(i);
|
6513 |
|
6514 | if (w === 32 || (w < 14 && w > 8)) {
|
6515 | continue;
|
6516 | }
|
6517 |
|
6518 |
|
6519 | if (w < 65 || w > 122 || (w > 90 && w < 97)) {
|
6520 | if (w !== 95 && w !== 58) {
|
6521 | handleWarning('illegal first char attribute name');
|
6522 | skipAttr = true;
|
6523 | }
|
6524 | }
|
6525 |
|
6526 |
|
6527 | for (j = i + 1; j < l; j++) {
|
6528 | w = s.charCodeAt(j);
|
6529 |
|
6530 | if (
|
6531 | w > 96 && w < 123 ||
|
6532 | w > 64 && w < 91 ||
|
6533 | w > 47 && w < 59 ||
|
6534 | w === 46 ||
|
6535 | w === 45 ||
|
6536 | w === 95
|
6537 | ) {
|
6538 | continue;
|
6539 | }
|
6540 |
|
6541 |
|
6542 | if (w === 32 || (w < 14 && w > 8)) {
|
6543 | handleWarning('missing attribute value');
|
6544 | i = j;
|
6545 |
|
6546 | continue parseAttr;
|
6547 | }
|
6548 |
|
6549 |
|
6550 | if (w === 61) {
|
6551 | break;
|
6552 | }
|
6553 |
|
6554 | handleWarning('illegal attribute name char');
|
6555 | skipAttr = true;
|
6556 | }
|
6557 |
|
6558 | name = s.substring(i, j);
|
6559 |
|
6560 | if (name === 'xmlns:xmlns') {
|
6561 | handleWarning('illegal declaration of xmlns');
|
6562 | skipAttr = true;
|
6563 | }
|
6564 |
|
6565 | w = s.charCodeAt(j + 1);
|
6566 |
|
6567 | if (w === 34) {
|
6568 | j = s.indexOf('"', i = j + 2);
|
6569 |
|
6570 | if (j === -1) {
|
6571 | j = s.indexOf('\'', i);
|
6572 |
|
6573 | if (j !== -1) {
|
6574 | handleWarning('attribute value quote missmatch');
|
6575 | skipAttr = true;
|
6576 | }
|
6577 | }
|
6578 |
|
6579 | } else if (w === 39) {
|
6580 | j = s.indexOf('\'', i = j + 2);
|
6581 |
|
6582 | if (j === -1) {
|
6583 | j = s.indexOf('"', i);
|
6584 |
|
6585 | if (j !== -1) {
|
6586 | handleWarning('attribute value quote missmatch');
|
6587 | skipAttr = true;
|
6588 | }
|
6589 | }
|
6590 |
|
6591 | } else {
|
6592 | handleWarning('missing attribute value quotes');
|
6593 | skipAttr = true;
|
6594 |
|
6595 |
|
6596 | for (j = j + 1; j < l; j++) {
|
6597 | w = s.charCodeAt(j + 1);
|
6598 |
|
6599 | if (w === 32 || (w < 14 && w > 8)) {
|
6600 | break;
|
6601 | }
|
6602 | }
|
6603 |
|
6604 | }
|
6605 |
|
6606 | if (j === -1) {
|
6607 | handleWarning('missing closing quotes');
|
6608 |
|
6609 | j = l;
|
6610 | skipAttr = true;
|
6611 | }
|
6612 |
|
6613 | if (!skipAttr) {
|
6614 | value = s.substring(i, j);
|
6615 | }
|
6616 |
|
6617 | i = j;
|
6618 |
|
6619 |
|
6620 |
|
6621 |
|
6622 | for (; j + 1 < l; j++) {
|
6623 | w = s.charCodeAt(j + 1);
|
6624 |
|
6625 | if (w === 32 || (w < 14 && w > 8)) {
|
6626 | break;
|
6627 | }
|
6628 |
|
6629 |
|
6630 | if (i === j) {
|
6631 | handleWarning('illegal character after attribute end');
|
6632 | skipAttr = true;
|
6633 | }
|
6634 | }
|
6635 |
|
6636 |
|
6637 | i = j + 1;
|
6638 |
|
6639 | if (skipAttr) {
|
6640 | continue parseAttr;
|
6641 | }
|
6642 |
|
6643 |
|
6644 | if (name in seenAttrs) {
|
6645 | handleWarning('attribute <' + name + '> already defined');
|
6646 | continue;
|
6647 | }
|
6648 |
|
6649 | seenAttrs[name] = true;
|
6650 |
|
6651 | if (!isNamespace) {
|
6652 | attrs[name] = value;
|
6653 | continue;
|
6654 | }
|
6655 |
|
6656 |
|
6657 | if (maybeNS) {
|
6658 | newalias = (
|
6659 | name === 'xmlns'
|
6660 | ? 'xmlns'
|
6661 | : (name.charCodeAt(0) === 120 && name.substr(0, 6) === 'xmlns:')
|
6662 | ? name.substr(6)
|
6663 | : null
|
6664 | );
|
6665 |
|
6666 |
|
6667 | if (newalias !== null) {
|
6668 | nsUri = decodeEntities(value);
|
6669 | nsUriPrefix = uriPrefix(newalias);
|
6670 |
|
6671 | alias = nsUriToPrefix[nsUri];
|
6672 |
|
6673 | if (!alias) {
|
6674 |
|
6675 | if (
|
6676 | (newalias === 'xmlns') ||
|
6677 | (nsUriPrefix in nsMatrix && nsMatrix[nsUriPrefix] !== nsUri)
|
6678 | ) {
|
6679 |
|
6680 | do {
|
6681 | alias = 'ns' + (anonymousNsCount++);
|
6682 | } while (typeof nsMatrix[alias] !== 'undefined');
|
6683 | } else {
|
6684 | alias = newalias;
|
6685 | }
|
6686 |
|
6687 | nsUriToPrefix[nsUri] = alias;
|
6688 | }
|
6689 |
|
6690 | if (nsMatrix[newalias] !== alias) {
|
6691 | if (!hasNewMatrix) {
|
6692 | nsMatrix = cloneNsMatrix(nsMatrix);
|
6693 | hasNewMatrix = true;
|
6694 | }
|
6695 |
|
6696 | nsMatrix[newalias] = alias;
|
6697 | if (newalias === 'xmlns') {
|
6698 | nsMatrix[uriPrefix(alias)] = nsUri;
|
6699 | defaultAlias = alias;
|
6700 | }
|
6701 |
|
6702 | nsMatrix[nsUriPrefix] = nsUri;
|
6703 | }
|
6704 |
|
6705 |
|
6706 | attrs[name] = value;
|
6707 | continue;
|
6708 | }
|
6709 |
|
6710 |
|
6711 |
|
6712 | attrList.push(name, value);
|
6713 | continue;
|
6714 |
|
6715 | }
|
6716 |
|
6717 |
|
6718 |
|
6719 | w = name.indexOf(':');
|
6720 | if (w === -1) {
|
6721 | attrs[name] = value;
|
6722 | continue;
|
6723 | }
|
6724 |
|
6725 |
|
6726 | if (!(nsName = nsMatrix[name.substring(0, w)])) {
|
6727 | handleWarning(missingNamespaceForPrefix(name.substring(0, w)));
|
6728 | continue;
|
6729 | }
|
6730 |
|
6731 | name = defaultAlias === nsName
|
6732 | ? name.substr(w + 1)
|
6733 | : nsName + name.substr(w);
|
6734 |
|
6735 |
|
6736 |
|
6737 | if (name === XSI_TYPE) {
|
6738 | w = value.indexOf(':');
|
6739 |
|
6740 | if (w !== -1) {
|
6741 | nsName = value.substring(0, w);
|
6742 |
|
6743 | nsName = nsMatrix[nsName] || nsName;
|
6744 | value = nsName + value.substring(w);
|
6745 | } else {
|
6746 | value = defaultAlias + ':' + value;
|
6747 | }
|
6748 | }
|
6749 |
|
6750 |
|
6751 | attrs[name] = value;
|
6752 | }
|
6753 |
|
6754 |
|
6755 |
|
6756 | if (maybeNS) {
|
6757 |
|
6758 |
|
6759 | for (i = 0, l = attrList.length; i < l; i++) {
|
6760 |
|
6761 | name = attrList[i++];
|
6762 | value = attrList[i];
|
6763 |
|
6764 | w = name.indexOf(':');
|
6765 |
|
6766 | if (w !== -1) {
|
6767 |
|
6768 | if (!(nsName = nsMatrix[name.substring(0, w)])) {
|
6769 | handleWarning(missingNamespaceForPrefix(name.substring(0, w)));
|
6770 | continue;
|
6771 | }
|
6772 |
|
6773 | name = defaultAlias === nsName
|
6774 | ? name.substr(w + 1)
|
6775 | : nsName + name.substr(w);
|
6776 |
|
6777 |
|
6778 |
|
6779 | if (name === XSI_TYPE) {
|
6780 | w = value.indexOf(':');
|
6781 |
|
6782 | if (w !== -1) {
|
6783 | nsName = value.substring(0, w);
|
6784 |
|
6785 | nsName = nsMatrix[nsName] || nsName;
|
6786 | value = nsName + value.substring(w);
|
6787 | } else {
|
6788 | value = defaultAlias + ':' + value;
|
6789 | }
|
6790 | }
|
6791 |
|
6792 | }
|
6793 |
|
6794 | attrs[name] = value;
|
6795 | }
|
6796 |
|
6797 | }
|
6798 |
|
6799 | return cachedAttrs = attrs;
|
6800 | }
|
6801 |
|
6802 | |
6803 |
|
6804 |
|
6805 |
|
6806 |
|
6807 |
|
6808 | function getParseContext() {
|
6809 | var splitsRe = /(\r\n|\r|\n)/g;
|
6810 |
|
6811 | var line = 0;
|
6812 | var column = 0;
|
6813 | var startOfLine = 0;
|
6814 | var endOfLine = j;
|
6815 | var match;
|
6816 | var data;
|
6817 |
|
6818 | while (i >= startOfLine) {
|
6819 |
|
6820 | match = splitsRe.exec(xml);
|
6821 |
|
6822 | if (!match) {
|
6823 | break;
|
6824 | }
|
6825 |
|
6826 |
|
6827 | endOfLine = match[0].length + match.index;
|
6828 |
|
6829 | if (endOfLine > i) {
|
6830 | break;
|
6831 | }
|
6832 |
|
6833 |
|
6834 | line += 1;
|
6835 |
|
6836 | startOfLine = endOfLine;
|
6837 | }
|
6838 |
|
6839 |
|
6840 | if (i == -1) {
|
6841 | column = endOfLine;
|
6842 | data = xml.substring(j);
|
6843 | } else
|
6844 |
|
6845 | if (j === 0) {
|
6846 | console.log(i - startOfLine);
|
6847 | data = xml.substring(j, i);
|
6848 | }
|
6849 |
|
6850 | else {
|
6851 | column = i - startOfLine;
|
6852 | data = (j == -1 ? xml.substring(i) : xml.substring(i, j + 1));
|
6853 | }
|
6854 |
|
6855 | return {
|
6856 | 'data': data,
|
6857 | 'line': line,
|
6858 | 'column': column
|
6859 | };
|
6860 | }
|
6861 |
|
6862 | getContext = getParseContext;
|
6863 |
|
6864 |
|
6865 | if (proxy) {
|
6866 | elementProxy = Object.create({}, {
|
6867 | 'name': getter(function() {
|
6868 | return elementName;
|
6869 | }),
|
6870 | 'originalName': getter(function() {
|
6871 | return _elementName;
|
6872 | }),
|
6873 | 'attrs': getter(getAttrs),
|
6874 | 'ns': getter(function() {
|
6875 | return nsMatrix;
|
6876 | })
|
6877 | });
|
6878 | }
|
6879 |
|
6880 |
|
6881 | while (j !== -1) {
|
6882 |
|
6883 | if (xml.charCodeAt(j) === 60) {
|
6884 | i = j;
|
6885 | } else {
|
6886 | i = xml.indexOf('<', j);
|
6887 | }
|
6888 |
|
6889 |
|
6890 | if (i === -1) {
|
6891 | if (nodeStack.length) {
|
6892 | return handleError('unexpected end of file');
|
6893 | }
|
6894 |
|
6895 | if (j === 0) {
|
6896 | return handleError('missing start tag');
|
6897 | }
|
6898 |
|
6899 | if (j < xml.length) {
|
6900 | if (xml.substring(j).trim()) {
|
6901 | handleWarning(NON_WHITESPACE_OUTSIDE_ROOT_NODE);
|
6902 | }
|
6903 | }
|
6904 |
|
6905 | return;
|
6906 | }
|
6907 |
|
6908 |
|
6909 | if (j !== i) {
|
6910 |
|
6911 | if (nodeStack.length) {
|
6912 | if (onText) {
|
6913 | onText(xml.substring(j, i), decodeEntities, getContext);
|
6914 |
|
6915 | if (parseStop) {
|
6916 | return;
|
6917 | }
|
6918 | }
|
6919 | } else {
|
6920 | if (xml.substring(j, i).trim()) {
|
6921 | handleWarning(NON_WHITESPACE_OUTSIDE_ROOT_NODE);
|
6922 |
|
6923 | if (parseStop) {
|
6924 | return;
|
6925 | }
|
6926 | }
|
6927 | }
|
6928 | }
|
6929 |
|
6930 | w = xml.charCodeAt(i+1);
|
6931 |
|
6932 |
|
6933 | if (w === 33) {
|
6934 | w = xml.charCodeAt(i+2);
|
6935 | if (w === 91 && xml.substr(i + 3, 6) === 'CDATA[') {
|
6936 | j = xml.indexOf(']]>', i);
|
6937 | if (j === -1) {
|
6938 | return handleError('unclosed cdata');
|
6939 | }
|
6940 |
|
6941 | if (onCDATA) {
|
6942 | onCDATA(xml.substring(i + 9, j), getContext);
|
6943 | if (parseStop) {
|
6944 | return;
|
6945 | }
|
6946 | }
|
6947 |
|
6948 | j += 3;
|
6949 | continue;
|
6950 | }
|
6951 |
|
6952 |
|
6953 | if (w === 45 && xml.charCodeAt(i + 3) === 45) {
|
6954 | j = xml.indexOf('-->', i);
|
6955 | if (j === -1) {
|
6956 | return handleError('unclosed comment');
|
6957 | }
|
6958 |
|
6959 |
|
6960 | if (onComment) {
|
6961 | onComment(xml.substring(i + 4, j), decodeEntities, getContext);
|
6962 | if (parseStop) {
|
6963 | return;
|
6964 | }
|
6965 | }
|
6966 |
|
6967 | j += 3;
|
6968 | continue;
|
6969 | }
|
6970 |
|
6971 | j = xml.indexOf('>', i + 1);
|
6972 | if (j === -1) {
|
6973 | return handleError('unclosed tag');
|
6974 | }
|
6975 |
|
6976 | if (onAttention) {
|
6977 | onAttention(xml.substring(i, j + 1), decodeEntities, getContext);
|
6978 | if (parseStop) {
|
6979 | return;
|
6980 | }
|
6981 | }
|
6982 |
|
6983 | j += 1;
|
6984 | continue;
|
6985 | }
|
6986 |
|
6987 | if (w === 63) {
|
6988 | j = xml.indexOf('?>', i);
|
6989 | if (j === -1) {
|
6990 | return handleError('unclosed question');
|
6991 | }
|
6992 |
|
6993 | if (onQuestion) {
|
6994 | onQuestion(xml.substring(i, j + 2), getContext);
|
6995 | if (parseStop) {
|
6996 | return;
|
6997 | }
|
6998 | }
|
6999 |
|
7000 | j += 2;
|
7001 | continue;
|
7002 | }
|
7003 |
|
7004 | j = xml.indexOf('>', i + 1);
|
7005 |
|
7006 | if (j == -1) {
|
7007 | return handleError('unclosed tag');
|
7008 | }
|
7009 |
|
7010 |
|
7011 |
|
7012 | cachedAttrs = {};
|
7013 |
|
7014 |
|
7015 | if (w === 47) {
|
7016 | tagStart = false;
|
7017 | tagEnd = true;
|
7018 |
|
7019 | if (!nodeStack.length) {
|
7020 | return handleError('missing open tag');
|
7021 | }
|
7022 |
|
7023 |
|
7024 | x = elementName = nodeStack.pop();
|
7025 | q = i + 2 + x.length;
|
7026 |
|
7027 | if (xml.substring(i + 2, q) !== x) {
|
7028 | return handleError('closing tag mismatch');
|
7029 | }
|
7030 |
|
7031 |
|
7032 | for (; q < j; q++) {
|
7033 | w = xml.charCodeAt(q);
|
7034 |
|
7035 | if (w === 32 || (w > 8 && w < 14)) {
|
7036 | continue;
|
7037 | }
|
7038 |
|
7039 | return handleError('close tag');
|
7040 | }
|
7041 |
|
7042 | } else {
|
7043 | if (xml.charCodeAt(j - 1) === 47) {
|
7044 | x = elementName = xml.substring(i + 1, j - 1);
|
7045 |
|
7046 | tagStart = true;
|
7047 | tagEnd = true;
|
7048 |
|
7049 | } else {
|
7050 | x = elementName = xml.substring(i + 1, j);
|
7051 |
|
7052 | tagStart = true;
|
7053 | tagEnd = false;
|
7054 | }
|
7055 |
|
7056 | if (!(w > 96 && w < 123 || w > 64 && w < 91 || w === 95 || w === 58)) {
|
7057 | return handleError('illegal first char nodeName');
|
7058 | }
|
7059 |
|
7060 | for (q = 1, y = x.length; q < y; q++) {
|
7061 | w = x.charCodeAt(q);
|
7062 |
|
7063 | if (w > 96 && w < 123 || w > 64 && w < 91 || w > 47 && w < 59 || w === 45 || w === 95 || w == 46) {
|
7064 | continue;
|
7065 | }
|
7066 |
|
7067 | if (w === 32 || (w < 14 && w > 8)) {
|
7068 | elementName = x.substring(0, q);
|
7069 |
|
7070 | cachedAttrs = null;
|
7071 | break;
|
7072 | }
|
7073 |
|
7074 | return handleError('invalid nodeName');
|
7075 | }
|
7076 |
|
7077 | if (!tagEnd) {
|
7078 | nodeStack.push(elementName);
|
7079 | }
|
7080 | }
|
7081 |
|
7082 | if (isNamespace) {
|
7083 |
|
7084 | _nsMatrix = nsMatrix;
|
7085 |
|
7086 | if (tagStart) {
|
7087 |
|
7088 |
|
7089 | if (!tagEnd) {
|
7090 | nsMatrixStack.push(_nsMatrix);
|
7091 | }
|
7092 |
|
7093 | if (cachedAttrs === null) {
|
7094 |
|
7095 |
|
7096 |
|
7097 | if ((maybeNS = x.indexOf('xmlns', q) !== -1)) {
|
7098 | attrsStart = q;
|
7099 | attrsString = x;
|
7100 |
|
7101 | getAttrs();
|
7102 |
|
7103 | maybeNS = false;
|
7104 | }
|
7105 | }
|
7106 | }
|
7107 |
|
7108 | _elementName = elementName;
|
7109 |
|
7110 | w = elementName.indexOf(':');
|
7111 | if (w !== -1) {
|
7112 | xmlns = nsMatrix[elementName.substring(0, w)];
|
7113 |
|
7114 |
|
7115 | if (!xmlns) {
|
7116 | return handleError('missing namespace on <' + _elementName + '>');
|
7117 | }
|
7118 |
|
7119 | elementName = elementName.substr(w + 1);
|
7120 | } else {
|
7121 | xmlns = nsMatrix['xmlns'];
|
7122 |
|
7123 |
|
7124 |
|
7125 |
|
7126 |
|
7127 |
|
7128 |
|
7129 | }
|
7130 |
|
7131 |
|
7132 | if (xmlns) {
|
7133 | elementName = xmlns + ':' + elementName;
|
7134 | }
|
7135 |
|
7136 | }
|
7137 |
|
7138 | if (tagStart) {
|
7139 | attrsStart = q;
|
7140 | attrsString = x;
|
7141 |
|
7142 | if (onOpenTag) {
|
7143 | if (proxy) {
|
7144 | onOpenTag(elementProxy, decodeEntities, tagEnd, getContext);
|
7145 | } else {
|
7146 | onOpenTag(elementName, getAttrs, decodeEntities, tagEnd, getContext);
|
7147 | }
|
7148 |
|
7149 | if (parseStop) {
|
7150 | return;
|
7151 | }
|
7152 | }
|
7153 |
|
7154 | }
|
7155 |
|
7156 | if (tagEnd) {
|
7157 |
|
7158 | if (onCloseTag) {
|
7159 | onCloseTag(proxy ? elementProxy : elementName, decodeEntities, tagStart, getContext);
|
7160 |
|
7161 | if (parseStop) {
|
7162 | return;
|
7163 | }
|
7164 | }
|
7165 |
|
7166 |
|
7167 | if (isNamespace) {
|
7168 | if (!tagStart) {
|
7169 | nsMatrix = nsMatrixStack.pop();
|
7170 | } else {
|
7171 | nsMatrix = _nsMatrix;
|
7172 | }
|
7173 | }
|
7174 | }
|
7175 |
|
7176 | j += 1;
|
7177 | }
|
7178 | }
|
7179 |
|
7180 | }
|
7181 |
|
7182 | function hasLowerCaseAlias(pkg) {
|
7183 | return pkg.xml && pkg.xml.tagAlias === 'lowerCase';
|
7184 | }
|
7185 |
|
7186 | var DEFAULT_NS_MAP = {
|
7187 | 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'
|
7188 | };
|
7189 |
|
7190 | var XSI_TYPE$1 = 'xsi:type';
|
7191 |
|
7192 | function serializeFormat(element) {
|
7193 | return element.xml && element.xml.serialize;
|
7194 | }
|
7195 |
|
7196 | function serializeAsType(element) {
|
7197 | return serializeFormat(element) === XSI_TYPE$1;
|
7198 | }
|
7199 |
|
7200 | function serializeAsProperty(element) {
|
7201 | return serializeFormat(element) === 'property';
|
7202 | }
|
7203 |
|
7204 | function capitalize(str) {
|
7205 | return str.charAt(0).toUpperCase() + str.slice(1);
|
7206 | }
|
7207 |
|
7208 | function aliasToName(aliasNs, pkg) {
|
7209 |
|
7210 | if (!hasLowerCaseAlias(pkg)) {
|
7211 | return aliasNs.name;
|
7212 | }
|
7213 |
|
7214 | return aliasNs.prefix + ':' + capitalize(aliasNs.localName);
|
7215 | }
|
7216 |
|
7217 | function prefixedToName(nameNs, pkg) {
|
7218 |
|
7219 | var name = nameNs.name,
|
7220 | localName = nameNs.localName;
|
7221 |
|
7222 | var typePrefix = pkg.xml && pkg.xml.typePrefix;
|
7223 |
|
7224 | if (typePrefix && localName.indexOf(typePrefix) === 0) {
|
7225 | return nameNs.prefix + ':' + localName.slice(typePrefix.length);
|
7226 | } else {
|
7227 | return name;
|
7228 | }
|
7229 | }
|
7230 |
|
7231 | function normalizeXsiTypeName(name, model) {
|
7232 |
|
7233 | var nameNs = parseName(name);
|
7234 | var pkg = model.getPackage(nameNs.prefix);
|
7235 |
|
7236 | return prefixedToName(nameNs, pkg);
|
7237 | }
|
7238 |
|
7239 | function error$1(message) {
|
7240 | return new Error(message);
|
7241 | }
|
7242 |
|
7243 | |
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 |
|
7249 |
|
7250 | function getModdleDescriptor(element) {
|
7251 | return element.$descriptor;
|
7252 | }
|
7253 |
|
7254 | function defer(fn) {
|
7255 | setTimeout(fn, 0);
|
7256 | }
|
7257 |
|
7258 | |
7259 |
|
7260 |
|
7261 |
|
7262 |
|
7263 |
|
7264 |
|
7265 |
|
7266 |
|
7267 | function Context(options) {
|
7268 |
|
7269 | |
7270 |
|
7271 |
|
7272 |
|
7273 | |
7274 |
|
7275 |
|
7276 |
|
7277 | assign(this, options);
|
7278 |
|
7279 | this.elementsById = {};
|
7280 | this.references = [];
|
7281 | this.warnings = [];
|
7282 |
|
7283 | |
7284 |
|
7285 |
|
7286 |
|
7287 |
|
7288 | this.addReference = function(reference) {
|
7289 | this.references.push(reference);
|
7290 | };
|
7291 |
|
7292 | |
7293 |
|
7294 |
|
7295 |
|
7296 |
|
7297 | this.addElement = function(element) {
|
7298 |
|
7299 | if (!element) {
|
7300 | throw error$1('expected element');
|
7301 | }
|
7302 |
|
7303 | var elementsById = this.elementsById;
|
7304 |
|
7305 | var descriptor = getModdleDescriptor(element);
|
7306 |
|
7307 | var idProperty = descriptor.idProperty,
|
7308 | id;
|
7309 |
|
7310 | if (idProperty) {
|
7311 | id = element.get(idProperty.name);
|
7312 |
|
7313 | if (id) {
|
7314 |
|
7315 | if (elementsById[id]) {
|
7316 | throw error$1('duplicate ID <' + id + '>');
|
7317 | }
|
7318 |
|
7319 | elementsById[id] = element;
|
7320 | }
|
7321 | }
|
7322 | };
|
7323 |
|
7324 | |
7325 |
|
7326 |
|
7327 |
|
7328 |
|
7329 |
|
7330 |
|
7331 | this.addWarning = function(warning) {
|
7332 | this.warnings.push(warning);
|
7333 | };
|
7334 | }
|
7335 |
|
7336 | function BaseHandler() {}
|
7337 |
|
7338 | BaseHandler.prototype.handleEnd = function() {};
|
7339 | BaseHandler.prototype.handleText = function() {};
|
7340 | BaseHandler.prototype.handleNode = function() {};
|
7341 |
|
7342 |
|
7343 | |
7344 |
|
7345 |
|
7346 |
|
7347 |
|
7348 |
|
7349 |
|
7350 | function NoopHandler() { }
|
7351 |
|
7352 | NoopHandler.prototype = Object.create(BaseHandler.prototype);
|
7353 |
|
7354 | NoopHandler.prototype.handleNode = function() {
|
7355 | return this;
|
7356 | };
|
7357 |
|
7358 | function BodyHandler() {}
|
7359 |
|
7360 | BodyHandler.prototype = Object.create(BaseHandler.prototype);
|
7361 |
|
7362 | BodyHandler.prototype.handleText = function(text) {
|
7363 | this.body = (this.body || '') + text;
|
7364 | };
|
7365 |
|
7366 | function ReferenceHandler(property, context) {
|
7367 | this.property = property;
|
7368 | this.context = context;
|
7369 | }
|
7370 |
|
7371 | ReferenceHandler.prototype = Object.create(BodyHandler.prototype);
|
7372 |
|
7373 | ReferenceHandler.prototype.handleNode = function(node) {
|
7374 |
|
7375 | if (this.element) {
|
7376 | throw error$1('expected no sub nodes');
|
7377 | } else {
|
7378 | this.element = this.createReference(node);
|
7379 | }
|
7380 |
|
7381 | return this;
|
7382 | };
|
7383 |
|
7384 | ReferenceHandler.prototype.handleEnd = function() {
|
7385 | this.element.id = this.body;
|
7386 | };
|
7387 |
|
7388 | ReferenceHandler.prototype.createReference = function(node) {
|
7389 | return {
|
7390 | property: this.property.ns.name,
|
7391 | id: ''
|
7392 | };
|
7393 | };
|
7394 |
|
7395 | function ValueHandler(propertyDesc, element) {
|
7396 | this.element = element;
|
7397 | this.propertyDesc = propertyDesc;
|
7398 | }
|
7399 |
|
7400 | ValueHandler.prototype = Object.create(BodyHandler.prototype);
|
7401 |
|
7402 | ValueHandler.prototype.handleEnd = function() {
|
7403 |
|
7404 | var value = this.body || '',
|
7405 | element = this.element,
|
7406 | propertyDesc = this.propertyDesc;
|
7407 |
|
7408 | value = coerceType(propertyDesc.type, value);
|
7409 |
|
7410 | if (propertyDesc.isMany) {
|
7411 | element.get(propertyDesc.name).push(value);
|
7412 | } else {
|
7413 | element.set(propertyDesc.name, value);
|
7414 | }
|
7415 | };
|
7416 |
|
7417 |
|
7418 | function BaseElementHandler() {}
|
7419 |
|
7420 | BaseElementHandler.prototype = Object.create(BodyHandler.prototype);
|
7421 |
|
7422 | BaseElementHandler.prototype.handleNode = function(node) {
|
7423 | var parser = this,
|
7424 | element = this.element;
|
7425 |
|
7426 | if (!element) {
|
7427 | element = this.element = this.createElement(node);
|
7428 |
|
7429 | this.context.addElement(element);
|
7430 | } else {
|
7431 | parser = this.handleChild(node);
|
7432 | }
|
7433 |
|
7434 | return parser;
|
7435 | };
|
7436 |
|
7437 | |
7438 |
|
7439 |
|
7440 |
|
7441 | function ElementHandler(model, typeName, context) {
|
7442 | this.model = model;
|
7443 | this.type = model.getType(typeName);
|
7444 | this.context = context;
|
7445 | }
|
7446 |
|
7447 | ElementHandler.prototype = Object.create(BaseElementHandler.prototype);
|
7448 |
|
7449 | ElementHandler.prototype.addReference = function(reference) {
|
7450 | this.context.addReference(reference);
|
7451 | };
|
7452 |
|
7453 | ElementHandler.prototype.handleEnd = function() {
|
7454 |
|
7455 | var value = this.body,
|
7456 | element = this.element,
|
7457 | descriptor = getModdleDescriptor(element),
|
7458 | bodyProperty = descriptor.bodyProperty;
|
7459 |
|
7460 | if (bodyProperty && value !== undefined) {
|
7461 | value = coerceType(bodyProperty.type, value);
|
7462 | element.set(bodyProperty.name, value);
|
7463 | }
|
7464 | };
|
7465 |
|
7466 | |
7467 |
|
7468 |
|
7469 |
|
7470 |
|
7471 | ElementHandler.prototype.createElement = function(node) {
|
7472 | var attributes = node.attributes,
|
7473 | Type = this.type,
|
7474 | descriptor = getModdleDescriptor(Type),
|
7475 | context = this.context,
|
7476 | instance = new Type({}),
|
7477 | model = this.model,
|
7478 | propNameNs;
|
7479 |
|
7480 | forEach(attributes, function(value, name) {
|
7481 |
|
7482 | var prop = descriptor.propertiesByName[name],
|
7483 | values$$1;
|
7484 |
|
7485 | if (prop && prop.isReference) {
|
7486 |
|
7487 | if (!prop.isMany) {
|
7488 | context.addReference({
|
7489 | element: instance,
|
7490 | property: prop.ns.name,
|
7491 | id: value
|
7492 | });
|
7493 | } else {
|
7494 |
|
7495 | values$$1 = value.split(' ');
|
7496 |
|
7497 | forEach(values$$1, function(v) {
|
7498 | context.addReference({
|
7499 | element: instance,
|
7500 | property: prop.ns.name,
|
7501 | id: v
|
7502 | });
|
7503 | });
|
7504 | }
|
7505 |
|
7506 | } else {
|
7507 | if (prop) {
|
7508 | value = coerceType(prop.type, value);
|
7509 | } else
|
7510 | if (name !== 'xmlns') {
|
7511 | propNameNs = parseName(name, descriptor.ns.prefix);
|
7512 |
|
7513 |
|
7514 |
|
7515 | if (model.getPackage(propNameNs.prefix)) {
|
7516 |
|
7517 | context.addWarning({
|
7518 | message: 'unknown attribute <' + name + '>',
|
7519 | element: instance,
|
7520 | property: name,
|
7521 | value: value
|
7522 | });
|
7523 | }
|
7524 | }
|
7525 |
|
7526 | instance.set(name, value);
|
7527 | }
|
7528 | });
|
7529 |
|
7530 | return instance;
|
7531 | };
|
7532 |
|
7533 | ElementHandler.prototype.getPropertyForNode = function(node) {
|
7534 |
|
7535 | var name = node.name;
|
7536 | var nameNs = parseName(name);
|
7537 |
|
7538 | var type = this.type,
|
7539 | model = this.model,
|
7540 | descriptor = getModdleDescriptor(type);
|
7541 |
|
7542 | var propertyName = nameNs.name,
|
7543 | property = descriptor.propertiesByName[propertyName],
|
7544 | elementTypeName,
|
7545 | elementType;
|
7546 |
|
7547 |
|
7548 |
|
7549 | if (property) {
|
7550 |
|
7551 | if (serializeAsType(property)) {
|
7552 | elementTypeName = node.attributes[XSI_TYPE$1];
|
7553 |
|
7554 |
|
7555 |
|
7556 | if (elementTypeName) {
|
7557 |
|
7558 |
|
7559 |
|
7560 | elementTypeName = normalizeXsiTypeName(elementTypeName, model);
|
7561 |
|
7562 | elementType = model.getType(elementTypeName);
|
7563 |
|
7564 | return assign({}, property, {
|
7565 | effectiveType: getModdleDescriptor(elementType).name
|
7566 | });
|
7567 | }
|
7568 | }
|
7569 |
|
7570 |
|
7571 | return property;
|
7572 | }
|
7573 |
|
7574 | var pkg = model.getPackage(nameNs.prefix);
|
7575 |
|
7576 | if (pkg) {
|
7577 | elementTypeName = aliasToName(nameNs, pkg);
|
7578 | elementType = model.getType(elementTypeName);
|
7579 |
|
7580 |
|
7581 | property = find(descriptor.properties, function(p) {
|
7582 | return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type);
|
7583 | });
|
7584 |
|
7585 | if (property) {
|
7586 | return assign({}, property, {
|
7587 | effectiveType: getModdleDescriptor(elementType).name
|
7588 | });
|
7589 | }
|
7590 | } else {
|
7591 |
|
7592 | property = find(descriptor.properties, function(p) {
|
7593 | return !p.isReference && !p.isAttribute && p.type === 'Element';
|
7594 | });
|
7595 |
|
7596 | if (property) {
|
7597 | return property;
|
7598 | }
|
7599 | }
|
7600 |
|
7601 | throw error$1('unrecognized element <' + nameNs.name + '>');
|
7602 | };
|
7603 |
|
7604 | ElementHandler.prototype.toString = function() {
|
7605 | return 'ElementDescriptor[' + getModdleDescriptor(this.type).name + ']';
|
7606 | };
|
7607 |
|
7608 | ElementHandler.prototype.valueHandler = function(propertyDesc, element) {
|
7609 | return new ValueHandler(propertyDesc, element);
|
7610 | };
|
7611 |
|
7612 | ElementHandler.prototype.referenceHandler = function(propertyDesc) {
|
7613 | return new ReferenceHandler(propertyDesc, this.context);
|
7614 | };
|
7615 |
|
7616 | ElementHandler.prototype.handler = function(type) {
|
7617 | if (type === 'Element') {
|
7618 | return new GenericElementHandler(this.model, type, this.context);
|
7619 | } else {
|
7620 | return new ElementHandler(this.model, type, this.context);
|
7621 | }
|
7622 | };
|
7623 |
|
7624 | |
7625 |
|
7626 |
|
7627 |
|
7628 |
|
7629 | ElementHandler.prototype.handleChild = function(node) {
|
7630 | var propertyDesc, type, element, childHandler;
|
7631 |
|
7632 | propertyDesc = this.getPropertyForNode(node);
|
7633 | element = this.element;
|
7634 |
|
7635 | type = propertyDesc.effectiveType || propertyDesc.type;
|
7636 |
|
7637 | if (isSimple(type)) {
|
7638 | return this.valueHandler(propertyDesc, element);
|
7639 | }
|
7640 |
|
7641 | if (propertyDesc.isReference) {
|
7642 | childHandler = this.referenceHandler(propertyDesc).handleNode(node);
|
7643 | } else {
|
7644 | childHandler = this.handler(type).handleNode(node);
|
7645 | }
|
7646 |
|
7647 | var newElement = childHandler.element;
|
7648 |
|
7649 |
|
7650 |
|
7651 | if (newElement !== undefined) {
|
7652 |
|
7653 | if (propertyDesc.isMany) {
|
7654 | element.get(propertyDesc.name).push(newElement);
|
7655 | } else {
|
7656 | element.set(propertyDesc.name, newElement);
|
7657 | }
|
7658 |
|
7659 | if (propertyDesc.isReference) {
|
7660 | assign(newElement, {
|
7661 | element: element
|
7662 | });
|
7663 |
|
7664 | this.context.addReference(newElement);
|
7665 | } else {
|
7666 |
|
7667 | newElement.$parent = element;
|
7668 | }
|
7669 | }
|
7670 |
|
7671 | return childHandler;
|
7672 | };
|
7673 |
|
7674 | |
7675 |
|
7676 |
|
7677 |
|
7678 |
|
7679 |
|
7680 |
|
7681 |
|
7682 |
|
7683 | function RootElementHandler(model, typeName, context) {
|
7684 | ElementHandler.call(this, model, typeName, context);
|
7685 | }
|
7686 |
|
7687 | RootElementHandler.prototype = Object.create(ElementHandler.prototype);
|
7688 |
|
7689 | RootElementHandler.prototype.createElement = function(node) {
|
7690 |
|
7691 | var name = node.name,
|
7692 | nameNs = parseName(name),
|
7693 | model = this.model,
|
7694 | type = this.type,
|
7695 | pkg = model.getPackage(nameNs.prefix),
|
7696 | typeName = pkg && aliasToName(nameNs, pkg) || name;
|
7697 |
|
7698 |
|
7699 |
|
7700 |
|
7701 |
|
7702 | if (!type.hasType(typeName)) {
|
7703 | throw error$1('unexpected element <' + node.originalName + '>');
|
7704 | }
|
7705 |
|
7706 | return ElementHandler.prototype.createElement.call(this, node);
|
7707 | };
|
7708 |
|
7709 |
|
7710 | function GenericElementHandler(model, typeName, context) {
|
7711 | this.model = model;
|
7712 | this.context = context;
|
7713 | }
|
7714 |
|
7715 | GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype);
|
7716 |
|
7717 | GenericElementHandler.prototype.createElement = function(node) {
|
7718 |
|
7719 | var name = node.name,
|
7720 | ns = parseName(name),
|
7721 | prefix = ns.prefix,
|
7722 | uri = node.ns[prefix + '$uri'],
|
7723 | attributes = node.attributes;
|
7724 |
|
7725 | return this.model.createAny(name, uri, attributes);
|
7726 | };
|
7727 |
|
7728 | GenericElementHandler.prototype.handleChild = function(node) {
|
7729 |
|
7730 | var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node),
|
7731 | element = this.element;
|
7732 |
|
7733 | var newElement = handler.element,
|
7734 | children;
|
7735 |
|
7736 | if (newElement !== undefined) {
|
7737 | children = element.$children = element.$children || [];
|
7738 | children.push(newElement);
|
7739 |
|
7740 |
|
7741 | newElement.$parent = element;
|
7742 | }
|
7743 |
|
7744 | return handler;
|
7745 | };
|
7746 |
|
7747 | GenericElementHandler.prototype.handleText = function(text) {
|
7748 | this.body = this.body || '' + text;
|
7749 | };
|
7750 |
|
7751 | GenericElementHandler.prototype.handleEnd = function() {
|
7752 | if (this.body) {
|
7753 | this.element.$body = this.body;
|
7754 | }
|
7755 | };
|
7756 |
|
7757 | |
7758 |
|
7759 |
|
7760 |
|
7761 |
|
7762 |
|
7763 |
|
7764 | function Reader(options) {
|
7765 |
|
7766 | if (options instanceof Moddle) {
|
7767 | options = {
|
7768 | model: options
|
7769 | };
|
7770 | }
|
7771 |
|
7772 | assign(this, { lax: false }, options);
|
7773 | }
|
7774 |
|
7775 |
|
7776 | |
7777 |
|
7778 |
|
7779 |
|
7780 |
|
7781 |
|
7782 |
|
7783 | Reader.prototype.fromXML = function(xml, options, done) {
|
7784 |
|
7785 | var rootHandler = options.rootHandler;
|
7786 |
|
7787 | if (options instanceof ElementHandler) {
|
7788 |
|
7789 | rootHandler = options;
|
7790 | options = {};
|
7791 | } else {
|
7792 | if (typeof options === 'string') {
|
7793 |
|
7794 | rootHandler = this.handler(options);
|
7795 | options = {};
|
7796 | } else if (typeof rootHandler === 'string') {
|
7797 |
|
7798 | rootHandler = this.handler(rootHandler);
|
7799 | }
|
7800 | }
|
7801 |
|
7802 | var model = this.model,
|
7803 | lax = this.lax;
|
7804 |
|
7805 | var context = new Context(assign({}, options, { rootHandler: rootHandler })),
|
7806 | parser = new Parser({ proxy: true }),
|
7807 | stack = new tinyStack();
|
7808 |
|
7809 | rootHandler.context = context;
|
7810 |
|
7811 |
|
7812 | stack.push(rootHandler);
|
7813 |
|
7814 |
|
7815 | |
7816 |
|
7817 |
|
7818 |
|
7819 |
|
7820 |
|
7821 |
|
7822 |
|
7823 |
|
7824 | function handleError(err, getContext, lax) {
|
7825 |
|
7826 | var ctx = getContext();
|
7827 |
|
7828 | var line = ctx.line,
|
7829 | column = ctx.column,
|
7830 | data = ctx.data;
|
7831 |
|
7832 |
|
7833 |
|
7834 |
|
7835 | if (data.charAt(0) === '<' && data.indexOf(' ') !== -1) {
|
7836 | data = data.slice(0, data.indexOf(' ')) + '>';
|
7837 | }
|
7838 |
|
7839 | var message =
|
7840 | 'unparsable content ' + (data ? data + ' ' : '') + 'detected\n\t' +
|
7841 | 'line: ' + line + '\n\t' +
|
7842 | 'column: ' + column + '\n\t' +
|
7843 | 'nested error: ' + err.message;
|
7844 |
|
7845 | if (lax) {
|
7846 | context.addWarning({
|
7847 | message: message,
|
7848 | error: err
|
7849 | });
|
7850 |
|
7851 | console.warn('could not parse node');
|
7852 | console.warn(err);
|
7853 |
|
7854 | return true;
|
7855 | } else {
|
7856 | console.error('could not parse document');
|
7857 | console.error(err);
|
7858 |
|
7859 | throw error$1(message);
|
7860 | }
|
7861 | }
|
7862 |
|
7863 | function handleWarning(err, getContext) {
|
7864 |
|
7865 | return handleError(err, getContext, true);
|
7866 | }
|
7867 |
|
7868 | |
7869 |
|
7870 |
|
7871 | function resolveReferences() {
|
7872 |
|
7873 | var elementsById = context.elementsById;
|
7874 | var references = context.references;
|
7875 |
|
7876 | var i, r;
|
7877 |
|
7878 | for (i = 0; (r = references[i]); i++) {
|
7879 | var element = r.element;
|
7880 | var reference = elementsById[r.id];
|
7881 | var property = getModdleDescriptor(element).propertiesByName[r.property];
|
7882 |
|
7883 | if (!reference) {
|
7884 | context.addWarning({
|
7885 | message: 'unresolved reference <' + r.id + '>',
|
7886 | element: r.element,
|
7887 | property: r.property,
|
7888 | value: r.id
|
7889 | });
|
7890 | }
|
7891 |
|
7892 | if (property.isMany) {
|
7893 | var collection = element.get(property.name),
|
7894 | idx = collection.indexOf(r);
|
7895 |
|
7896 |
|
7897 |
|
7898 | if (idx === -1) {
|
7899 | idx = collection.length;
|
7900 | }
|
7901 |
|
7902 | if (!reference) {
|
7903 |
|
7904 | collection.splice(idx, 1);
|
7905 | } else {
|
7906 |
|
7907 | collection[idx] = reference;
|
7908 | }
|
7909 | } else {
|
7910 | element.set(property.name, reference);
|
7911 | }
|
7912 | }
|
7913 | }
|
7914 |
|
7915 | function handleClose() {
|
7916 | stack.pop().handleEnd();
|
7917 | }
|
7918 |
|
7919 | var PREAMBLE_START_PATTERN = /^<\?xml /i;
|
7920 |
|
7921 | var ENCODING_PATTERN = / encoding="([^"]+)"/i;
|
7922 |
|
7923 | var UTF_8_PATTERN = /^utf-8$/i;
|
7924 |
|
7925 | function handleQuestion(question) {
|
7926 |
|
7927 | if (!PREAMBLE_START_PATTERN.test(question)) {
|
7928 | return;
|
7929 | }
|
7930 |
|
7931 | var match = ENCODING_PATTERN.exec(question);
|
7932 | var encoding = match && match[1];
|
7933 |
|
7934 | if (!encoding || UTF_8_PATTERN.test(encoding)) {
|
7935 | return;
|
7936 | }
|
7937 |
|
7938 | context.addWarning({
|
7939 | message:
|
7940 | 'unsupported document encoding <' + encoding + '>, ' +
|
7941 | 'falling back to UTF-8'
|
7942 | });
|
7943 | }
|
7944 |
|
7945 | function handleOpen(node, getContext) {
|
7946 | var handler = stack.peek();
|
7947 |
|
7948 | try {
|
7949 | stack.push(handler.handleNode(node));
|
7950 | } catch (err) {
|
7951 |
|
7952 | if (handleError(err, getContext, lax)) {
|
7953 | stack.push(new NoopHandler());
|
7954 | }
|
7955 | }
|
7956 | }
|
7957 |
|
7958 | function handleCData(text) {
|
7959 | stack.peek().handleText(text);
|
7960 | }
|
7961 |
|
7962 | function handleText(text) {
|
7963 |
|
7964 |
|
7965 | text = text.trim();
|
7966 |
|
7967 | if (!text) {
|
7968 | return;
|
7969 | }
|
7970 |
|
7971 | stack.peek().handleText(text);
|
7972 | }
|
7973 |
|
7974 | var uriMap = model.getPackages().reduce(function(uriMap, p) {
|
7975 | uriMap[p.uri] = p.prefix;
|
7976 |
|
7977 | return uriMap;
|
7978 | }, {});
|
7979 |
|
7980 | parser
|
7981 | .ns(uriMap)
|
7982 | .on('openTag', function(obj, decodeStr, selfClosing, getContext) {
|
7983 |
|
7984 |
|
7985 | var attrs = obj.attrs || {};
|
7986 |
|
7987 | var decodedAttrs = Object.keys(attrs).reduce(function(d, key) {
|
7988 | var value = decodeStr(attrs[key]);
|
7989 |
|
7990 | d[key] = value;
|
7991 |
|
7992 | return d;
|
7993 | }, {});
|
7994 |
|
7995 | var node = {
|
7996 | name: obj.name,
|
7997 | originalName: obj.originalName,
|
7998 | attributes: decodedAttrs,
|
7999 | ns: obj.ns
|
8000 | };
|
8001 |
|
8002 | handleOpen(node, getContext);
|
8003 | })
|
8004 | .on('question', handleQuestion)
|
8005 | .on('closeTag', handleClose)
|
8006 | .on('cdata', handleCData)
|
8007 | .on('text', function(text, decodeEntities$$1) {
|
8008 | handleText(decodeEntities$$1(text));
|
8009 | })
|
8010 | .on('error', handleError)
|
8011 | .on('warn', handleWarning);
|
8012 |
|
8013 |
|
8014 |
|
8015 |
|
8016 |
|
8017 | defer(function() {
|
8018 | var err;
|
8019 |
|
8020 | try {
|
8021 | parser.parse(xml);
|
8022 |
|
8023 | resolveReferences();
|
8024 | } catch (e) {
|
8025 | err = e;
|
8026 | }
|
8027 |
|
8028 | var element = rootHandler.element;
|
8029 |
|
8030 |
|
8031 |
|
8032 | if (!err && !element) {
|
8033 | err = error$1('failed to parse document as <' + rootHandler.type.$descriptor.name + '>');
|
8034 | }
|
8035 |
|
8036 | done(err, err ? undefined : element, context);
|
8037 | });
|
8038 | };
|
8039 |
|
8040 | Reader.prototype.handler = function(name) {
|
8041 | return new RootElementHandler(this.model, name);
|
8042 | };
|
8043 |
|
8044 | var XML_PREAMBLE = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
8045 |
|
8046 | var ESCAPE_ATTR_CHARS = /<|>|'|"|&|\n\r|\n/g;
|
8047 | var ESCAPE_CHARS = /<|>|&/g;
|
8048 |
|
8049 |
|
8050 | function Namespaces(parent) {
|
8051 |
|
8052 | var prefixMap = {};
|
8053 | var uriMap = {};
|
8054 | var used = {};
|
8055 |
|
8056 | var wellknown = [];
|
8057 | var custom = [];
|
8058 |
|
8059 |
|
8060 |
|
8061 | this.byUri = function(uri) {
|
8062 | return uriMap[uri] || (
|
8063 | parent && parent.byUri(uri)
|
8064 | );
|
8065 | };
|
8066 |
|
8067 | this.add = function(ns, isWellknown) {
|
8068 |
|
8069 | uriMap[ns.uri] = ns;
|
8070 |
|
8071 | if (isWellknown) {
|
8072 | wellknown.push(ns);
|
8073 | } else {
|
8074 | custom.push(ns);
|
8075 | }
|
8076 |
|
8077 | this.mapPrefix(ns.prefix, ns.uri);
|
8078 | };
|
8079 |
|
8080 | this.uriByPrefix = function(prefix) {
|
8081 | return prefixMap[prefix || 'xmlns'];
|
8082 | };
|
8083 |
|
8084 | this.mapPrefix = function(prefix, uri) {
|
8085 | prefixMap[prefix || 'xmlns'] = uri;
|
8086 | };
|
8087 |
|
8088 | this.logUsed = function(ns) {
|
8089 | var uri = ns.uri;
|
8090 |
|
8091 | used[uri] = this.byUri(uri);
|
8092 | };
|
8093 |
|
8094 | this.getUsed = function(ns) {
|
8095 |
|
8096 | function isUsed(ns) {
|
8097 | return used[ns.uri];
|
8098 | }
|
8099 |
|
8100 | var allNs = [].concat(wellknown, custom);
|
8101 |
|
8102 | return allNs.filter(isUsed);
|
8103 | };
|
8104 |
|
8105 | }
|
8106 |
|
8107 | function lower(string) {
|
8108 | return string.charAt(0).toLowerCase() + string.slice(1);
|
8109 | }
|
8110 |
|
8111 | function nameToAlias(name, pkg) {
|
8112 | if (hasLowerCaseAlias(pkg)) {
|
8113 | return lower(name);
|
8114 | } else {
|
8115 | return name;
|
8116 | }
|
8117 | }
|
8118 |
|
8119 | function inherits(ctor, superCtor) {
|
8120 | ctor.super_ = superCtor;
|
8121 | ctor.prototype = Object.create(superCtor.prototype, {
|
8122 | constructor: {
|
8123 | value: ctor,
|
8124 | enumerable: false,
|
8125 | writable: true,
|
8126 | configurable: true
|
8127 | }
|
8128 | });
|
8129 | }
|
8130 |
|
8131 | function nsName(ns) {
|
8132 | if (isString(ns)) {
|
8133 | return ns;
|
8134 | } else {
|
8135 | return (ns.prefix ? ns.prefix + ':' : '') + ns.localName;
|
8136 | }
|
8137 | }
|
8138 |
|
8139 | function getNsAttrs(namespaces) {
|
8140 |
|
8141 | return map(namespaces.getUsed(), function(ns) {
|
8142 | var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : '');
|
8143 | return { name: name, value: ns.uri };
|
8144 | });
|
8145 |
|
8146 | }
|
8147 |
|
8148 | function getElementNs(ns, descriptor) {
|
8149 | if (descriptor.isGeneric) {
|
8150 | return assign({ localName: descriptor.ns.localName }, ns);
|
8151 | } else {
|
8152 | return assign({ localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) }, ns);
|
8153 | }
|
8154 | }
|
8155 |
|
8156 | function getPropertyNs(ns, descriptor) {
|
8157 | return assign({ localName: descriptor.ns.localName }, ns);
|
8158 | }
|
8159 |
|
8160 | function getSerializableProperties(element) {
|
8161 | var descriptor = element.$descriptor;
|
8162 |
|
8163 | return filter(descriptor.properties, function(p) {
|
8164 | var name = p.name;
|
8165 |
|
8166 | if (p.isVirtual) {
|
8167 | return false;
|
8168 | }
|
8169 |
|
8170 |
|
8171 | if (!element.hasOwnProperty(name)) {
|
8172 | return false;
|
8173 | }
|
8174 |
|
8175 | var value = element[name];
|
8176 |
|
8177 |
|
8178 | if (value === p.default) {
|
8179 | return false;
|
8180 | }
|
8181 |
|
8182 |
|
8183 | if (value === null) {
|
8184 | return false;
|
8185 | }
|
8186 |
|
8187 | return p.isMany ? value.length : true;
|
8188 | });
|
8189 | }
|
8190 |
|
8191 | var ESCAPE_ATTR_MAP = {
|
8192 | '\n': '#10',
|
8193 | '\n\r': '#10',
|
8194 | '"': '#34',
|
8195 | '\'': '#39',
|
8196 | '<': '#60',
|
8197 | '>': '#62',
|
8198 | '&': '#38'
|
8199 | };
|
8200 |
|
8201 | var ESCAPE_MAP = {
|
8202 | '<': 'lt',
|
8203 | '>': 'gt',
|
8204 | '&': 'amp'
|
8205 | };
|
8206 |
|
8207 | function escape$1(str, charPattern, replaceMap) {
|
8208 |
|
8209 |
|
8210 | str = isString(str) ? str : '' + str;
|
8211 |
|
8212 | return str.replace(charPattern, function(s) {
|
8213 | return '&' + replaceMap[s] + ';';
|
8214 | });
|
8215 | }
|
8216 |
|
8217 | |
8218 |
|
8219 |
|
8220 |
|
8221 |
|
8222 |
|
8223 | function escapeAttr(str) {
|
8224 | return escape$1(str, ESCAPE_ATTR_CHARS, ESCAPE_ATTR_MAP);
|
8225 | }
|
8226 |
|
8227 | function escapeBody(str) {
|
8228 | return escape$1(str, ESCAPE_CHARS, ESCAPE_MAP);
|
8229 | }
|
8230 |
|
8231 | function filterAttributes(props) {
|
8232 | return filter(props, function(p) { return p.isAttr; });
|
8233 | }
|
8234 |
|
8235 | function filterContained(props) {
|
8236 | return filter(props, function(p) { return !p.isAttr; });
|
8237 | }
|
8238 |
|
8239 |
|
8240 | function ReferenceSerializer(tagName) {
|
8241 | this.tagName = tagName;
|
8242 | }
|
8243 |
|
8244 | ReferenceSerializer.prototype.build = function(element) {
|
8245 | this.element = element;
|
8246 | return this;
|
8247 | };
|
8248 |
|
8249 | ReferenceSerializer.prototype.serializeTo = function(writer) {
|
8250 | writer
|
8251 | .appendIndent()
|
8252 | .append('<' + this.tagName + '>' + this.element.id + '</' + this.tagName + '>')
|
8253 | .appendNewLine();
|
8254 | };
|
8255 |
|
8256 | function BodySerializer() {}
|
8257 |
|
8258 | BodySerializer.prototype.serializeValue =
|
8259 | BodySerializer.prototype.serializeTo = function(writer) {
|
8260 | writer.append(
|
8261 | this.escape
|
8262 | ? escapeBody(this.value)
|
8263 | : this.value
|
8264 | );
|
8265 | };
|
8266 |
|
8267 | BodySerializer.prototype.build = function(prop, value) {
|
8268 | this.value = value;
|
8269 |
|
8270 | if (prop.type === 'String' && value.search(ESCAPE_CHARS) !== -1) {
|
8271 | this.escape = true;
|
8272 | }
|
8273 |
|
8274 | return this;
|
8275 | };
|
8276 |
|
8277 | function ValueSerializer(tagName) {
|
8278 | this.tagName = tagName;
|
8279 | }
|
8280 |
|
8281 | inherits(ValueSerializer, BodySerializer);
|
8282 |
|
8283 | ValueSerializer.prototype.serializeTo = function(writer) {
|
8284 |
|
8285 | writer
|
8286 | .appendIndent()
|
8287 | .append('<' + this.tagName + '>');
|
8288 |
|
8289 | this.serializeValue(writer);
|
8290 |
|
8291 | writer
|
8292 | .append('</' + this.tagName + '>')
|
8293 | .appendNewLine();
|
8294 | };
|
8295 |
|
8296 | function ElementSerializer(parent, propertyDescriptor) {
|
8297 | this.body = [];
|
8298 | this.attrs = [];
|
8299 |
|
8300 | this.parent = parent;
|
8301 | this.propertyDescriptor = propertyDescriptor;
|
8302 | }
|
8303 |
|
8304 | ElementSerializer.prototype.build = function(element) {
|
8305 | this.element = element;
|
8306 |
|
8307 | var elementDescriptor = element.$descriptor,
|
8308 | propertyDescriptor = this.propertyDescriptor;
|
8309 |
|
8310 | var otherAttrs,
|
8311 | properties;
|
8312 |
|
8313 | var isGeneric = elementDescriptor.isGeneric;
|
8314 |
|
8315 | if (isGeneric) {
|
8316 | otherAttrs = this.parseGeneric(element);
|
8317 | } else {
|
8318 | otherAttrs = this.parseNsAttributes(element);
|
8319 | }
|
8320 |
|
8321 | if (propertyDescriptor) {
|
8322 | this.ns = this.nsPropertyTagName(propertyDescriptor);
|
8323 | } else {
|
8324 | this.ns = this.nsTagName(elementDescriptor);
|
8325 | }
|
8326 |
|
8327 |
|
8328 | this.tagName = this.addTagName(this.ns);
|
8329 |
|
8330 | if (!isGeneric) {
|
8331 | properties = getSerializableProperties(element);
|
8332 |
|
8333 | this.parseAttributes(filterAttributes(properties));
|
8334 | this.parseContainments(filterContained(properties));
|
8335 | }
|
8336 |
|
8337 | this.parseGenericAttributes(element, otherAttrs);
|
8338 |
|
8339 | return this;
|
8340 | };
|
8341 |
|
8342 | ElementSerializer.prototype.nsTagName = function(descriptor) {
|
8343 | var effectiveNs = this.logNamespaceUsed(descriptor.ns);
|
8344 | return getElementNs(effectiveNs, descriptor);
|
8345 | };
|
8346 |
|
8347 | ElementSerializer.prototype.nsPropertyTagName = function(descriptor) {
|
8348 | var effectiveNs = this.logNamespaceUsed(descriptor.ns);
|
8349 | return getPropertyNs(effectiveNs, descriptor);
|
8350 | };
|
8351 |
|
8352 | ElementSerializer.prototype.isLocalNs = function(ns) {
|
8353 | return ns.uri === this.ns.uri;
|
8354 | };
|
8355 |
|
8356 | |
8357 |
|
8358 |
|
8359 |
|
8360 |
|
8361 |
|
8362 |
|
8363 |
|
8364 | ElementSerializer.prototype.nsAttributeName = function(element) {
|
8365 |
|
8366 | var ns;
|
8367 |
|
8368 | if (isString(element)) {
|
8369 | ns = parseName(element);
|
8370 | } else {
|
8371 | ns = element.ns;
|
8372 | }
|
8373 |
|
8374 |
|
8375 | if (element.inherited) {
|
8376 | return { localName: ns.localName };
|
8377 | }
|
8378 |
|
8379 |
|
8380 | var effectiveNs = this.logNamespaceUsed(ns);
|
8381 |
|
8382 |
|
8383 | this.getNamespaces().logUsed(effectiveNs);
|
8384 |
|
8385 |
|
8386 | if (this.isLocalNs(effectiveNs)) {
|
8387 | return { localName: ns.localName };
|
8388 | } else {
|
8389 | return assign({ localName: ns.localName }, effectiveNs);
|
8390 | }
|
8391 | };
|
8392 |
|
8393 | ElementSerializer.prototype.parseGeneric = function(element) {
|
8394 |
|
8395 | var self = this,
|
8396 | body = this.body;
|
8397 |
|
8398 | var attributes = [];
|
8399 |
|
8400 | forEach(element, function(val, key) {
|
8401 |
|
8402 | var nonNsAttr;
|
8403 |
|
8404 | if (key === '$body') {
|
8405 | body.push(new BodySerializer().build({ type: 'String' }, val));
|
8406 | } else
|
8407 | if (key === '$children') {
|
8408 | forEach(val, function(child) {
|
8409 | body.push(new ElementSerializer(self).build(child));
|
8410 | });
|
8411 | } else
|
8412 | if (key.indexOf('$') !== 0) {
|
8413 | nonNsAttr = self.parseNsAttribute(element, key, val);
|
8414 |
|
8415 | if (nonNsAttr) {
|
8416 | attributes.push({ name: key, value: val });
|
8417 | }
|
8418 | }
|
8419 | });
|
8420 |
|
8421 | return attributes;
|
8422 | };
|
8423 |
|
8424 | ElementSerializer.prototype.parseNsAttribute = function(element, name, value) {
|
8425 | var model = element.$model;
|
8426 |
|
8427 | var nameNs = parseName(name);
|
8428 |
|
8429 | var ns;
|
8430 |
|
8431 |
|
8432 | if (nameNs.prefix === 'xmlns') {
|
8433 | ns = { prefix: nameNs.localName, uri: value };
|
8434 | }
|
8435 |
|
8436 |
|
8437 | if (!nameNs.prefix && nameNs.localName === 'xmlns') {
|
8438 | ns = { uri: value };
|
8439 | }
|
8440 |
|
8441 | if (!ns) {
|
8442 | return {
|
8443 | name: name,
|
8444 | value: value
|
8445 | };
|
8446 | }
|
8447 |
|
8448 | if (model && model.getPackage(value)) {
|
8449 |
|
8450 | this.logNamespace(ns, true, true);
|
8451 | } else {
|
8452 |
|
8453 | var actualNs = this.logNamespaceUsed(ns, true);
|
8454 |
|
8455 | this.getNamespaces().logUsed(actualNs);
|
8456 | }
|
8457 | };
|
8458 |
|
8459 |
|
8460 | |
8461 |
|
8462 |
|
8463 |
|
8464 |
|
8465 |
|
8466 | ElementSerializer.prototype.parseNsAttributes = function(element, attrs) {
|
8467 | var self = this;
|
8468 |
|
8469 | var genericAttrs = element.$attrs;
|
8470 |
|
8471 | var attributes = [];
|
8472 |
|
8473 |
|
8474 |
|
8475 |
|
8476 | forEach(genericAttrs, function(value, name) {
|
8477 |
|
8478 | var nonNsAttr = self.parseNsAttribute(element, name, value);
|
8479 |
|
8480 | if (nonNsAttr) {
|
8481 | attributes.push(nonNsAttr);
|
8482 | }
|
8483 | });
|
8484 |
|
8485 | return attributes;
|
8486 | };
|
8487 |
|
8488 | ElementSerializer.prototype.parseGenericAttributes = function(element, attributes) {
|
8489 |
|
8490 | var self = this;
|
8491 |
|
8492 | forEach(attributes, function(attr) {
|
8493 |
|
8494 |
|
8495 |
|
8496 | if (attr.name === XSI_TYPE$1) {
|
8497 | return;
|
8498 | }
|
8499 |
|
8500 | try {
|
8501 | self.addAttribute(self.nsAttributeName(attr.name), attr.value);
|
8502 | } catch (e) {
|
8503 | console.warn(
|
8504 | 'missing namespace information for ',
|
8505 | attr.name, '=', attr.value, 'on', element,
|
8506 | e);
|
8507 | }
|
8508 | });
|
8509 | };
|
8510 |
|
8511 | ElementSerializer.prototype.parseContainments = function(properties) {
|
8512 |
|
8513 | var self = this,
|
8514 | body = this.body,
|
8515 | element = this.element;
|
8516 |
|
8517 | forEach(properties, function(p) {
|
8518 | var value = element.get(p.name),
|
8519 | isReference = p.isReference,
|
8520 | isMany = p.isMany;
|
8521 |
|
8522 | if (!isMany) {
|
8523 | value = [ value ];
|
8524 | }
|
8525 |
|
8526 | if (p.isBody) {
|
8527 | body.push(new BodySerializer().build(p, value[0]));
|
8528 | } else
|
8529 | if (isSimple(p.type)) {
|
8530 | forEach(value, function(v) {
|
8531 | body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
|
8532 | });
|
8533 | } else
|
8534 | if (isReference) {
|
8535 | forEach(value, function(v) {
|
8536 | body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
|
8537 | });
|
8538 | } else {
|
8539 |
|
8540 |
|
8541 | var asType = serializeAsType(p),
|
8542 | asProperty = serializeAsProperty(p);
|
8543 |
|
8544 | forEach(value, function(v) {
|
8545 | var serializer;
|
8546 |
|
8547 | if (asType) {
|
8548 | serializer = new TypeSerializer(self, p);
|
8549 | } else
|
8550 | if (asProperty) {
|
8551 | serializer = new ElementSerializer(self, p);
|
8552 | } else {
|
8553 | serializer = new ElementSerializer(self);
|
8554 | }
|
8555 |
|
8556 | body.push(serializer.build(v));
|
8557 | });
|
8558 | }
|
8559 | });
|
8560 | };
|
8561 |
|
8562 | ElementSerializer.prototype.getNamespaces = function(local) {
|
8563 |
|
8564 | var namespaces = this.namespaces,
|
8565 | parent = this.parent,
|
8566 | parentNamespaces;
|
8567 |
|
8568 | if (!namespaces) {
|
8569 | parentNamespaces = parent && parent.getNamespaces();
|
8570 |
|
8571 | if (local || !parentNamespaces) {
|
8572 | this.namespaces = namespaces = new Namespaces(parentNamespaces);
|
8573 | } else {
|
8574 | namespaces = parentNamespaces;
|
8575 | }
|
8576 | }
|
8577 |
|
8578 | return namespaces;
|
8579 | };
|
8580 |
|
8581 | ElementSerializer.prototype.logNamespace = function(ns, wellknown, local) {
|
8582 | var namespaces = this.getNamespaces(local);
|
8583 |
|
8584 | var nsUri = ns.uri,
|
8585 | nsPrefix = ns.prefix;
|
8586 |
|
8587 | var existing = namespaces.byUri(nsUri);
|
8588 |
|
8589 | if (!existing) {
|
8590 | namespaces.add(ns, wellknown);
|
8591 | }
|
8592 |
|
8593 | namespaces.mapPrefix(nsPrefix, nsUri);
|
8594 |
|
8595 | return ns;
|
8596 | };
|
8597 |
|
8598 | ElementSerializer.prototype.logNamespaceUsed = function(ns, local) {
|
8599 | var element = this.element,
|
8600 | model = element.$model,
|
8601 | namespaces = this.getNamespaces(local);
|
8602 |
|
8603 |
|
8604 |
|
8605 |
|
8606 |
|
8607 |
|
8608 |
|
8609 | var prefix = ns.prefix,
|
8610 | uri = ns.uri,
|
8611 | newPrefix, idx,
|
8612 | wellknownUri;
|
8613 |
|
8614 |
|
8615 | if (!prefix && !uri) {
|
8616 | return { localName: ns.localName };
|
8617 | }
|
8618 |
|
8619 | wellknownUri = DEFAULT_NS_MAP[prefix] || model && (model.getPackage(prefix) || {}).uri;
|
8620 |
|
8621 | uri = uri || wellknownUri || namespaces.uriByPrefix(prefix);
|
8622 |
|
8623 | if (!uri) {
|
8624 | throw new Error('no namespace uri given for prefix <' + prefix + '>');
|
8625 | }
|
8626 |
|
8627 | ns = namespaces.byUri(uri);
|
8628 |
|
8629 | if (!ns) {
|
8630 | newPrefix = prefix;
|
8631 | idx = 1;
|
8632 |
|
8633 |
|
8634 | while (namespaces.uriByPrefix(newPrefix)) {
|
8635 | newPrefix = prefix + '_' + idx++;
|
8636 | }
|
8637 |
|
8638 | ns = this.logNamespace({ prefix: newPrefix, uri: uri }, wellknownUri === uri);
|
8639 | }
|
8640 |
|
8641 | if (prefix) {
|
8642 | namespaces.mapPrefix(prefix, uri);
|
8643 | }
|
8644 |
|
8645 | return ns;
|
8646 | };
|
8647 |
|
8648 | ElementSerializer.prototype.parseAttributes = function(properties) {
|
8649 | var self = this,
|
8650 | element = this.element;
|
8651 |
|
8652 | forEach(properties, function(p) {
|
8653 |
|
8654 | var value = element.get(p.name);
|
8655 |
|
8656 | if (p.isReference) {
|
8657 |
|
8658 | if (!p.isMany) {
|
8659 | value = value.id;
|
8660 | }
|
8661 | else {
|
8662 | var values$$1 = [];
|
8663 | forEach(value, function(v) {
|
8664 | values$$1.push(v.id);
|
8665 | });
|
8666 |
|
8667 | value = values$$1.join(' ');
|
8668 | }
|
8669 |
|
8670 | }
|
8671 |
|
8672 | self.addAttribute(self.nsAttributeName(p), value);
|
8673 | });
|
8674 | };
|
8675 |
|
8676 | ElementSerializer.prototype.addTagName = function(nsTagName) {
|
8677 | var actualNs = this.logNamespaceUsed(nsTagName);
|
8678 |
|
8679 | this.getNamespaces().logUsed(actualNs);
|
8680 |
|
8681 | return nsName(nsTagName);
|
8682 | };
|
8683 |
|
8684 | ElementSerializer.prototype.addAttribute = function(name, value) {
|
8685 | var attrs = this.attrs;
|
8686 |
|
8687 | if (isString(value)) {
|
8688 | value = escapeAttr(value);
|
8689 | }
|
8690 |
|
8691 | attrs.push({ name: name, value: value });
|
8692 | };
|
8693 |
|
8694 | ElementSerializer.prototype.serializeAttributes = function(writer) {
|
8695 | var attrs = this.attrs,
|
8696 | namespaces = this.namespaces;
|
8697 |
|
8698 | if (namespaces) {
|
8699 | attrs = getNsAttrs(namespaces).concat(attrs);
|
8700 | }
|
8701 |
|
8702 | forEach(attrs, function(a) {
|
8703 | writer
|
8704 | .append(' ')
|
8705 | .append(nsName(a.name)).append('="').append(a.value).append('"');
|
8706 | });
|
8707 | };
|
8708 |
|
8709 | ElementSerializer.prototype.serializeTo = function(writer) {
|
8710 | var firstBody = this.body[0],
|
8711 | indent = firstBody && firstBody.constructor !== BodySerializer;
|
8712 |
|
8713 | writer
|
8714 | .appendIndent()
|
8715 | .append('<' + this.tagName);
|
8716 |
|
8717 | this.serializeAttributes(writer);
|
8718 |
|
8719 | writer.append(firstBody ? '>' : ' />');
|
8720 |
|
8721 | if (firstBody) {
|
8722 |
|
8723 | if (indent) {
|
8724 | writer
|
8725 | .appendNewLine()
|
8726 | .indent();
|
8727 | }
|
8728 |
|
8729 | forEach(this.body, function(b) {
|
8730 | b.serializeTo(writer);
|
8731 | });
|
8732 |
|
8733 | if (indent) {
|
8734 | writer
|
8735 | .unindent()
|
8736 | .appendIndent();
|
8737 | }
|
8738 |
|
8739 | writer.append('</' + this.tagName + '>');
|
8740 | }
|
8741 |
|
8742 | writer.appendNewLine();
|
8743 | };
|
8744 |
|
8745 | |
8746 |
|
8747 |
|
8748 | function TypeSerializer(parent, propertyDescriptor) {
|
8749 | ElementSerializer.call(this, parent, propertyDescriptor);
|
8750 | }
|
8751 |
|
8752 | inherits(TypeSerializer, ElementSerializer);
|
8753 |
|
8754 | TypeSerializer.prototype.parseNsAttributes = function(element) {
|
8755 |
|
8756 |
|
8757 | var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element);
|
8758 |
|
8759 | var descriptor = element.$descriptor;
|
8760 |
|
8761 |
|
8762 | if (descriptor.name === this.propertyDescriptor.type) {
|
8763 | return attributes;
|
8764 | }
|
8765 |
|
8766 | var typeNs = this.typeNs = this.nsTagName(descriptor);
|
8767 | this.getNamespaces().logUsed(this.typeNs);
|
8768 |
|
8769 |
|
8770 |
|
8771 |
|
8772 | var pkg = element.$model.getPackage(typeNs.uri),
|
8773 | typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
|
8774 |
|
8775 | this.addAttribute(
|
8776 | this.nsAttributeName(XSI_TYPE$1),
|
8777 | (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName
|
8778 | );
|
8779 |
|
8780 | return attributes;
|
8781 | };
|
8782 |
|
8783 | TypeSerializer.prototype.isLocalNs = function(ns) {
|
8784 | return ns.uri === (this.typeNs || this.ns).uri;
|
8785 | };
|
8786 |
|
8787 | function SavingWriter() {
|
8788 | this.value = '';
|
8789 |
|
8790 | this.write = function(str) {
|
8791 | this.value += str;
|
8792 | };
|
8793 | }
|
8794 |
|
8795 | function FormatingWriter(out, format) {
|
8796 |
|
8797 | var indent = [''];
|
8798 |
|
8799 | this.append = function(str) {
|
8800 | out.write(str);
|
8801 |
|
8802 | return this;
|
8803 | };
|
8804 |
|
8805 | this.appendNewLine = function() {
|
8806 | if (format) {
|
8807 | out.write('\n');
|
8808 | }
|
8809 |
|
8810 | return this;
|
8811 | };
|
8812 |
|
8813 | this.appendIndent = function() {
|
8814 | if (format) {
|
8815 | out.write(indent.join(' '));
|
8816 | }
|
8817 |
|
8818 | return this;
|
8819 | };
|
8820 |
|
8821 | this.indent = function() {
|
8822 | indent.push('');
|
8823 | return this;
|
8824 | };
|
8825 |
|
8826 | this.unindent = function() {
|
8827 | indent.pop();
|
8828 | return this;
|
8829 | };
|
8830 | }
|
8831 |
|
8832 | |
8833 |
|
8834 |
|
8835 |
|
8836 |
|
8837 | function Writer(options) {
|
8838 |
|
8839 | options = assign({ format: false, preamble: true }, options || {});
|
8840 |
|
8841 | function toXML(tree, writer) {
|
8842 | var internalWriter = writer || new SavingWriter();
|
8843 | var formatingWriter = new FormatingWriter(internalWriter, options.format);
|
8844 |
|
8845 | if (options.preamble) {
|
8846 | formatingWriter.append(XML_PREAMBLE);
|
8847 | }
|
8848 |
|
8849 | new ElementSerializer().build(tree).serializeTo(formatingWriter);
|
8850 |
|
8851 | if (!writer) {
|
8852 | return internalWriter.value;
|
8853 | }
|
8854 | }
|
8855 |
|
8856 | return {
|
8857 | toXML: toXML
|
8858 | };
|
8859 | }
|
8860 |
|
8861 | |
8862 |
|
8863 |
|
8864 |
|
8865 |
|
8866 |
|
8867 |
|
8868 |
|
8869 |
|
8870 | function BpmnModdle(packages, options) {
|
8871 | Moddle.call(this, packages, options);
|
8872 | }
|
8873 |
|
8874 | BpmnModdle.prototype = Object.create(Moddle.prototype);
|
8875 |
|
8876 |
|
8877 | |
8878 |
|
8879 |
|
8880 |
|
8881 |
|
8882 |
|
8883 |
|
8884 |
|
8885 |
|
8886 | BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {
|
8887 |
|
8888 | if (!isString(typeName)) {
|
8889 | done = options;
|
8890 | options = typeName;
|
8891 | typeName = 'bpmn:Definitions';
|
8892 | }
|
8893 |
|
8894 | if (isFunction(options)) {
|
8895 | done = options;
|
8896 | options = {};
|
8897 | }
|
8898 |
|
8899 | var reader = new Reader(assign({ model: this, lax: true }, options));
|
8900 | var rootHandler = reader.handler(typeName);
|
8901 |
|
8902 | reader.fromXML(xmlStr, rootHandler, done);
|
8903 | };
|
8904 |
|
8905 |
|
8906 | |
8907 |
|
8908 |
|
8909 |
|
8910 |
|
8911 |
|
8912 |
|
8913 | BpmnModdle.prototype.toXML = function(element, options, done) {
|
8914 |
|
8915 | if (isFunction(options)) {
|
8916 | done = options;
|
8917 | options = {};
|
8918 | }
|
8919 |
|
8920 | var writer = new Writer(options);
|
8921 |
|
8922 | var result;
|
8923 | var err;
|
8924 |
|
8925 | try {
|
8926 | result = writer.toXML(element);
|
8927 | } catch (e) {
|
8928 | err = e;
|
8929 | }
|
8930 |
|
8931 | return done(err, result);
|
8932 | };
|
8933 |
|
8934 | var name = "BPMN20";
|
8935 | var uri = "http://www.omg.org/spec/BPMN/20100524/MODEL";
|
8936 | var associations = [
|
8937 | ];
|
8938 | var types$1 = [
|
8939 | {
|
8940 | name: "Interface",
|
8941 | superClass: [
|
8942 | "RootElement"
|
8943 | ],
|
8944 | properties: [
|
8945 | {
|
8946 | name: "name",
|
8947 | isAttr: true,
|
8948 | type: "String"
|
8949 | },
|
8950 | {
|
8951 | name: "operations",
|
8952 | type: "Operation",
|
8953 | isMany: true
|
8954 | },
|
8955 | {
|
8956 | name: "implementationRef",
|
8957 | type: "String",
|
8958 | isAttr: true
|
8959 | }
|
8960 | ]
|
8961 | },
|
8962 | {
|
8963 | name: "Operation",
|
8964 | superClass: [
|
8965 | "BaseElement"
|
8966 | ],
|
8967 | properties: [
|
8968 | {
|
8969 | name: "name",
|
8970 | isAttr: true,
|
8971 | type: "String"
|
8972 | },
|
8973 | {
|
8974 | name: "inMessageRef",
|
8975 | type: "Message",
|
8976 | isReference: true
|
8977 | },
|
8978 | {
|
8979 | name: "outMessageRef",
|
8980 | type: "Message",
|
8981 | isReference: true
|
8982 | },
|
8983 | {
|
8984 | name: "errorRef",
|
8985 | type: "Error",
|
8986 | isMany: true,
|
8987 | isReference: true
|
8988 | },
|
8989 | {
|
8990 | name: "implementationRef",
|
8991 | type: "String",
|
8992 | isAttr: true
|
8993 | }
|
8994 | ]
|
8995 | },
|
8996 | {
|
8997 | name: "EndPoint",
|
8998 | superClass: [
|
8999 | "RootElement"
|
9000 | ]
|
9001 | },
|
9002 | {
|
9003 | name: "Auditing",
|
9004 | superClass: [
|
9005 | "BaseElement"
|
9006 | ]
|
9007 | },
|
9008 | {
|
9009 | name: "GlobalTask",
|
9010 | superClass: [
|
9011 | "CallableElement"
|
9012 | ],
|
9013 | properties: [
|
9014 | {
|
9015 | name: "resources",
|
9016 | type: "ResourceRole",
|
9017 | isMany: true
|
9018 | }
|
9019 | ]
|
9020 | },
|
9021 | {
|
9022 | name: "Monitoring",
|
9023 | superClass: [
|
9024 | "BaseElement"
|
9025 | ]
|
9026 | },
|
9027 | {
|
9028 | name: "Performer",
|
9029 | superClass: [
|
9030 | "ResourceRole"
|
9031 | ]
|
9032 | },
|
9033 | {
|
9034 | name: "Process",
|
9035 | superClass: [
|
9036 | "FlowElementsContainer",
|
9037 | "CallableElement"
|
9038 | ],
|
9039 | properties: [
|
9040 | {
|
9041 | name: "processType",
|
9042 | type: "ProcessType",
|
9043 | isAttr: true
|
9044 | },
|
9045 | {
|
9046 | name: "isClosed",
|
9047 | isAttr: true,
|
9048 | type: "Boolean"
|
9049 | },
|
9050 | {
|
9051 | name: "auditing",
|
9052 | type: "Auditing"
|
9053 | },
|
9054 | {
|
9055 | name: "monitoring",
|
9056 | type: "Monitoring"
|
9057 | },
|
9058 | {
|
9059 | name: "properties",
|
9060 | type: "Property",
|
9061 | isMany: true
|
9062 | },
|
9063 | {
|
9064 | name: "laneSets",
|
9065 | type: "LaneSet",
|
9066 | isMany: true,
|
9067 | replaces: "FlowElementsContainer#laneSets"
|
9068 | },
|
9069 | {
|
9070 | name: "flowElements",
|
9071 | type: "FlowElement",
|
9072 | isMany: true,
|
9073 | replaces: "FlowElementsContainer#flowElements"
|
9074 | },
|
9075 | {
|
9076 | name: "artifacts",
|
9077 | type: "Artifact",
|
9078 | isMany: true
|
9079 | },
|
9080 | {
|
9081 | name: "resources",
|
9082 | type: "ResourceRole",
|
9083 | isMany: true
|
9084 | },
|
9085 | {
|
9086 | name: "correlationSubscriptions",
|
9087 | type: "CorrelationSubscription",
|
9088 | isMany: true
|
9089 | },
|
9090 | {
|
9091 | name: "supports",
|
9092 | type: "Process",
|
9093 | isMany: true,
|
9094 | isReference: true
|
9095 | },
|
9096 | {
|
9097 | name: "definitionalCollaborationRef",
|
9098 | type: "Collaboration",
|
9099 | isAttr: true,
|
9100 | isReference: true
|
9101 | },
|
9102 | {
|
9103 | name: "isExecutable",
|
9104 | isAttr: true,
|
9105 | type: "Boolean"
|
9106 | }
|
9107 | ]
|
9108 | },
|
9109 | {
|
9110 | name: "LaneSet",
|
9111 | superClass: [
|
9112 | "BaseElement"
|
9113 | ],
|
9114 | properties: [
|
9115 | {
|
9116 | name: "lanes",
|
9117 | type: "Lane",
|
9118 | isMany: true
|
9119 | },
|
9120 | {
|
9121 | name: "name",
|
9122 | isAttr: true,
|
9123 | type: "String"
|
9124 | }
|
9125 | ]
|
9126 | },
|
9127 | {
|
9128 | name: "Lane",
|
9129 | superClass: [
|
9130 | "BaseElement"
|
9131 | ],
|
9132 | properties: [
|
9133 | {
|
9134 | name: "name",
|
9135 | isAttr: true,
|
9136 | type: "String"
|
9137 | },
|
9138 | {
|
9139 | name: "partitionElementRef",
|
9140 | type: "BaseElement",
|
9141 | isAttr: true,
|
9142 | isReference: true
|
9143 | },
|
9144 | {
|
9145 | name: "partitionElement",
|
9146 | type: "BaseElement"
|
9147 | },
|
9148 | {
|
9149 | name: "flowNodeRef",
|
9150 | type: "FlowNode",
|
9151 | isMany: true,
|
9152 | isReference: true
|
9153 | },
|
9154 | {
|
9155 | name: "childLaneSet",
|
9156 | type: "LaneSet",
|
9157 | xml: {
|
9158 | serialize: "xsi:type"
|
9159 | }
|
9160 | }
|
9161 | ]
|
9162 | },
|
9163 | {
|
9164 | name: "GlobalManualTask",
|
9165 | superClass: [
|
9166 | "GlobalTask"
|
9167 | ]
|
9168 | },
|
9169 | {
|
9170 | name: "ManualTask",
|
9171 | superClass: [
|
9172 | "Task"
|
9173 | ]
|
9174 | },
|
9175 | {
|
9176 | name: "UserTask",
|
9177 | superClass: [
|
9178 | "Task"
|
9179 | ],
|
9180 | properties: [
|
9181 | {
|
9182 | name: "renderings",
|
9183 | type: "Rendering",
|
9184 | isMany: true
|
9185 | },
|
9186 | {
|
9187 | name: "implementation",
|
9188 | isAttr: true,
|
9189 | type: "String"
|
9190 | }
|
9191 | ]
|
9192 | },
|
9193 | {
|
9194 | name: "Rendering",
|
9195 | superClass: [
|
9196 | "BaseElement"
|
9197 | ]
|
9198 | },
|
9199 | {
|
9200 | name: "HumanPerformer",
|
9201 | superClass: [
|
9202 | "Performer"
|
9203 | ]
|
9204 | },
|
9205 | {
|
9206 | name: "PotentialOwner",
|
9207 | superClass: [
|
9208 | "HumanPerformer"
|
9209 | ]
|
9210 | },
|
9211 | {
|
9212 | name: "GlobalUserTask",
|
9213 | superClass: [
|
9214 | "GlobalTask"
|
9215 | ],
|
9216 | properties: [
|
9217 | {
|
9218 | name: "implementation",
|
9219 | isAttr: true,
|
9220 | type: "String"
|
9221 | },
|
9222 | {
|
9223 | name: "renderings",
|
9224 | type: "Rendering",
|
9225 | isMany: true
|
9226 | }
|
9227 | ]
|
9228 | },
|
9229 | {
|
9230 | name: "Gateway",
|
9231 | isAbstract: true,
|
9232 | superClass: [
|
9233 | "FlowNode"
|
9234 | ],
|
9235 | properties: [
|
9236 | {
|
9237 | name: "gatewayDirection",
|
9238 | type: "GatewayDirection",
|
9239 | "default": "Unspecified",
|
9240 | isAttr: true
|
9241 | }
|
9242 | ]
|
9243 | },
|
9244 | {
|
9245 | name: "EventBasedGateway",
|
9246 | superClass: [
|
9247 | "Gateway"
|
9248 | ],
|
9249 | properties: [
|
9250 | {
|
9251 | name: "instantiate",
|
9252 | "default": false,
|
9253 | isAttr: true,
|
9254 | type: "Boolean"
|
9255 | },
|
9256 | {
|
9257 | name: "eventGatewayType",
|
9258 | type: "EventBasedGatewayType",
|
9259 | isAttr: true,
|
9260 | "default": "Exclusive"
|
9261 | }
|
9262 | ]
|
9263 | },
|
9264 | {
|
9265 | name: "ComplexGateway",
|
9266 | superClass: [
|
9267 | "Gateway"
|
9268 | ],
|
9269 | properties: [
|
9270 | {
|
9271 | name: "activationCondition",
|
9272 | type: "Expression",
|
9273 | xml: {
|
9274 | serialize: "xsi:type"
|
9275 | }
|
9276 | },
|
9277 | {
|
9278 | name: "default",
|
9279 | type: "SequenceFlow",
|
9280 | isAttr: true,
|
9281 | isReference: true
|
9282 | }
|
9283 | ]
|
9284 | },
|
9285 | {
|
9286 | name: "ExclusiveGateway",
|
9287 | superClass: [
|
9288 | "Gateway"
|
9289 | ],
|
9290 | properties: [
|
9291 | {
|
9292 | name: "default",
|
9293 | type: "SequenceFlow",
|
9294 | isAttr: true,
|
9295 | isReference: true
|
9296 | }
|
9297 | ]
|
9298 | },
|
9299 | {
|
9300 | name: "InclusiveGateway",
|
9301 | superClass: [
|
9302 | "Gateway"
|
9303 | ],
|
9304 | properties: [
|
9305 | {
|
9306 | name: "default",
|
9307 | type: "SequenceFlow",
|
9308 | isAttr: true,
|
9309 | isReference: true
|
9310 | }
|
9311 | ]
|
9312 | },
|
9313 | {
|
9314 | name: "ParallelGateway",
|
9315 | superClass: [
|
9316 | "Gateway"
|
9317 | ]
|
9318 | },
|
9319 | {
|
9320 | name: "RootElement",
|
9321 | isAbstract: true,
|
9322 | superClass: [
|
9323 | "BaseElement"
|
9324 | ]
|
9325 | },
|
9326 | {
|
9327 | name: "Relationship",
|
9328 | superClass: [
|
9329 | "BaseElement"
|
9330 | ],
|
9331 | properties: [
|
9332 | {
|
9333 | name: "type",
|
9334 | isAttr: true,
|
9335 | type: "String"
|
9336 | },
|
9337 | {
|
9338 | name: "direction",
|
9339 | type: "RelationshipDirection",
|
9340 | isAttr: true
|
9341 | },
|
9342 | {
|
9343 | name: "source",
|
9344 | isMany: true,
|
9345 | isReference: true,
|
9346 | type: "Element"
|
9347 | },
|
9348 | {
|
9349 | name: "target",
|
9350 | isMany: true,
|
9351 | isReference: true,
|
9352 | type: "Element"
|
9353 | }
|
9354 | ]
|
9355 | },
|
9356 | {
|
9357 | name: "BaseElement",
|
9358 | isAbstract: true,
|
9359 | properties: [
|
9360 | {
|
9361 | name: "id",
|
9362 | isAttr: true,
|
9363 | type: "String",
|
9364 | isId: true
|
9365 | },
|
9366 | {
|
9367 | name: "documentation",
|
9368 | type: "Documentation",
|
9369 | isMany: true
|
9370 | },
|
9371 | {
|
9372 | name: "extensionDefinitions",
|
9373 | type: "ExtensionDefinition",
|
9374 | isMany: true,
|
9375 | isReference: true
|
9376 | },
|
9377 | {
|
9378 | name: "extensionElements",
|
9379 | type: "ExtensionElements"
|
9380 | }
|
9381 | ]
|
9382 | },
|
9383 | {
|
9384 | name: "Extension",
|
9385 | properties: [
|
9386 | {
|
9387 | name: "mustUnderstand",
|
9388 | "default": false,
|
9389 | isAttr: true,
|
9390 | type: "Boolean"
|
9391 | },
|
9392 | {
|
9393 | name: "definition",
|
9394 | type: "ExtensionDefinition",
|
9395 | isAttr: true,
|
9396 | isReference: true
|
9397 | }
|
9398 | ]
|
9399 | },
|
9400 | {
|
9401 | name: "ExtensionDefinition",
|
9402 | properties: [
|
9403 | {
|
9404 | name: "name",
|
9405 | isAttr: true,
|
9406 | type: "String"
|
9407 | },
|
9408 | {
|
9409 | name: "extensionAttributeDefinitions",
|
9410 | type: "ExtensionAttributeDefinition",
|
9411 | isMany: true
|
9412 | }
|
9413 | ]
|
9414 | },
|
9415 | {
|
9416 | name: "ExtensionAttributeDefinition",
|
9417 | properties: [
|
9418 | {
|
9419 | name: "name",
|
9420 | isAttr: true,
|
9421 | type: "String"
|
9422 | },
|
9423 | {
|
9424 | name: "type",
|
9425 | isAttr: true,
|
9426 | type: "String"
|
9427 | },
|
9428 | {
|
9429 | name: "isReference",
|
9430 | "default": false,
|
9431 | isAttr: true,
|
9432 | type: "Boolean"
|
9433 | },
|
9434 | {
|
9435 | name: "extensionDefinition",
|
9436 | type: "ExtensionDefinition",
|
9437 | isAttr: true,
|
9438 | isReference: true
|
9439 | }
|
9440 | ]
|
9441 | },
|
9442 | {
|
9443 | name: "ExtensionElements",
|
9444 | properties: [
|
9445 | {
|
9446 | name: "valueRef",
|
9447 | isAttr: true,
|
9448 | isReference: true,
|
9449 | type: "Element"
|
9450 | },
|
9451 | {
|
9452 | name: "values",
|
9453 | type: "Element",
|
9454 | isMany: true
|
9455 | },
|
9456 | {
|
9457 | name: "extensionAttributeDefinition",
|
9458 | type: "ExtensionAttributeDefinition",
|
9459 | isAttr: true,
|
9460 | isReference: true
|
9461 | }
|
9462 | ]
|
9463 | },
|
9464 | {
|
9465 | name: "Documentation",
|
9466 | superClass: [
|
9467 | "BaseElement"
|
9468 | ],
|
9469 | properties: [
|
9470 | {
|
9471 | name: "text",
|
9472 | type: "String",
|
9473 | isBody: true
|
9474 | },
|
9475 | {
|
9476 | name: "textFormat",
|
9477 | "default": "text/plain",
|
9478 | isAttr: true,
|
9479 | type: "String"
|
9480 | }
|
9481 | ]
|
9482 | },
|
9483 | {
|
9484 | name: "Event",
|
9485 | isAbstract: true,
|
9486 | superClass: [
|
9487 | "FlowNode",
|
9488 | "InteractionNode"
|
9489 | ],
|
9490 | properties: [
|
9491 | {
|
9492 | name: "properties",
|
9493 | type: "Property",
|
9494 | isMany: true
|
9495 | }
|
9496 | ]
|
9497 | },
|
9498 | {
|
9499 | name: "IntermediateCatchEvent",
|
9500 | superClass: [
|
9501 | "CatchEvent"
|
9502 | ]
|
9503 | },
|
9504 | {
|
9505 | name: "IntermediateThrowEvent",
|
9506 | superClass: [
|
9507 | "ThrowEvent"
|
9508 | ]
|
9509 | },
|
9510 | {
|
9511 | name: "EndEvent",
|
9512 | superClass: [
|
9513 | "ThrowEvent"
|
9514 | ]
|
9515 | },
|
9516 | {
|
9517 | name: "StartEvent",
|
9518 | superClass: [
|
9519 | "CatchEvent"
|
9520 | ],
|
9521 | properties: [
|
9522 | {
|
9523 | name: "isInterrupting",
|
9524 | "default": true,
|
9525 | isAttr: true,
|
9526 | type: "Boolean"
|
9527 | }
|
9528 | ]
|
9529 | },
|
9530 | {
|
9531 | name: "ThrowEvent",
|
9532 | isAbstract: true,
|
9533 | superClass: [
|
9534 | "Event"
|
9535 | ],
|
9536 | properties: [
|
9537 | {
|
9538 | name: "dataInputs",
|
9539 | type: "DataInput",
|
9540 | isMany: true
|
9541 | },
|
9542 | {
|
9543 | name: "dataInputAssociations",
|
9544 | type: "DataInputAssociation",
|
9545 | isMany: true
|
9546 | },
|
9547 | {
|
9548 | name: "inputSet",
|
9549 | type: "InputSet"
|
9550 | },
|
9551 | {
|
9552 | name: "eventDefinitions",
|
9553 | type: "EventDefinition",
|
9554 | isMany: true
|
9555 | },
|
9556 | {
|
9557 | name: "eventDefinitionRef",
|
9558 | type: "EventDefinition",
|
9559 | isMany: true,
|
9560 | isReference: true
|
9561 | }
|
9562 | ]
|
9563 | },
|
9564 | {
|
9565 | name: "CatchEvent",
|
9566 | isAbstract: true,
|
9567 | superClass: [
|
9568 | "Event"
|
9569 | ],
|
9570 | properties: [
|
9571 | {
|
9572 | name: "parallelMultiple",
|
9573 | isAttr: true,
|
9574 | type: "Boolean",
|
9575 | "default": false
|
9576 | },
|
9577 | {
|
9578 | name: "dataOutputs",
|
9579 | type: "DataOutput",
|
9580 | isMany: true
|
9581 | },
|
9582 | {
|
9583 | name: "dataOutputAssociations",
|
9584 | type: "DataOutputAssociation",
|
9585 | isMany: true
|
9586 | },
|
9587 | {
|
9588 | name: "outputSet",
|
9589 | type: "OutputSet"
|
9590 | },
|
9591 | {
|
9592 | name: "eventDefinitions",
|
9593 | type: "EventDefinition",
|
9594 | isMany: true
|
9595 | },
|
9596 | {
|
9597 | name: "eventDefinitionRef",
|
9598 | type: "EventDefinition",
|
9599 | isMany: true,
|
9600 | isReference: true
|
9601 | }
|
9602 | ]
|
9603 | },
|
9604 | {
|
9605 | name: "BoundaryEvent",
|
9606 | superClass: [
|
9607 | "CatchEvent"
|
9608 | ],
|
9609 | properties: [
|
9610 | {
|
9611 | name: "cancelActivity",
|
9612 | "default": true,
|
9613 | isAttr: true,
|
9614 | type: "Boolean"
|
9615 | },
|
9616 | {
|
9617 | name: "attachedToRef",
|
9618 | type: "Activity",
|
9619 | isAttr: true,
|
9620 | isReference: true
|
9621 | }
|
9622 | ]
|
9623 | },
|
9624 | {
|
9625 | name: "EventDefinition",
|
9626 | isAbstract: true,
|
9627 | superClass: [
|
9628 | "RootElement"
|
9629 | ]
|
9630 | },
|
9631 | {
|
9632 | name: "CancelEventDefinition",
|
9633 | superClass: [
|
9634 | "EventDefinition"
|
9635 | ]
|
9636 | },
|
9637 | {
|
9638 | name: "ErrorEventDefinition",
|
9639 | superClass: [
|
9640 | "EventDefinition"
|
9641 | ],
|
9642 | properties: [
|
9643 | {
|
9644 | name: "errorRef",
|
9645 | type: "Error",
|
9646 | isAttr: true,
|
9647 | isReference: true
|
9648 | }
|
9649 | ]
|
9650 | },
|
9651 | {
|
9652 | name: "TerminateEventDefinition",
|
9653 | superClass: [
|
9654 | "EventDefinition"
|
9655 | ]
|
9656 | },
|
9657 | {
|
9658 | name: "EscalationEventDefinition",
|
9659 | superClass: [
|
9660 | "EventDefinition"
|
9661 | ],
|
9662 | properties: [
|
9663 | {
|
9664 | name: "escalationRef",
|
9665 | type: "Escalation",
|
9666 | isAttr: true,
|
9667 | isReference: true
|
9668 | }
|
9669 | ]
|
9670 | },
|
9671 | {
|
9672 | name: "Escalation",
|
9673 | properties: [
|
9674 | {
|
9675 | name: "structureRef",
|
9676 | type: "ItemDefinition",
|
9677 | isAttr: true,
|
9678 | isReference: true
|
9679 | },
|
9680 | {
|
9681 | name: "name",
|
9682 | isAttr: true,
|
9683 | type: "String"
|
9684 | },
|
9685 | {
|
9686 | name: "escalationCode",
|
9687 | isAttr: true,
|
9688 | type: "String"
|
9689 | }
|
9690 | ],
|
9691 | superClass: [
|
9692 | "RootElement"
|
9693 | ]
|
9694 | },
|
9695 | {
|
9696 | name: "CompensateEventDefinition",
|
9697 | superClass: [
|
9698 | "EventDefinition"
|
9699 | ],
|
9700 | properties: [
|
9701 | {
|
9702 | name: "waitForCompletion",
|
9703 | isAttr: true,
|
9704 | type: "Boolean",
|
9705 | "default": true
|
9706 | },
|
9707 | {
|
9708 | name: "activityRef",
|
9709 | type: "Activity",
|
9710 | isAttr: true,
|
9711 | isReference: true
|
9712 | }
|
9713 | ]
|
9714 | },
|
9715 | {
|
9716 | name: "TimerEventDefinition",
|
9717 | superClass: [
|
9718 | "EventDefinition"
|
9719 | ],
|
9720 | properties: [
|
9721 | {
|
9722 | name: "timeDate",
|
9723 | type: "Expression",
|
9724 | xml: {
|
9725 | serialize: "xsi:type"
|
9726 | }
|
9727 | },
|
9728 | {
|
9729 | name: "timeCycle",
|
9730 | type: "Expression",
|
9731 | xml: {
|
9732 | serialize: "xsi:type"
|
9733 | }
|
9734 | },
|
9735 | {
|
9736 | name: "timeDuration",
|
9737 | type: "Expression",
|
9738 | xml: {
|
9739 | serialize: "xsi:type"
|
9740 | }
|
9741 | }
|
9742 | ]
|
9743 | },
|
9744 | {
|
9745 | name: "LinkEventDefinition",
|
9746 | superClass: [
|
9747 | "EventDefinition"
|
9748 | ],
|
9749 | properties: [
|
9750 | {
|
9751 | name: "name",
|
9752 | isAttr: true,
|
9753 | type: "String"
|
9754 | },
|
9755 | {
|
9756 | name: "target",
|
9757 | type: "LinkEventDefinition",
|
9758 | isAttr: true,
|
9759 | isReference: true
|
9760 | },
|
9761 | {
|
9762 | name: "source",
|
9763 | type: "LinkEventDefinition",
|
9764 | isMany: true,
|
9765 | isReference: true
|
9766 | }
|
9767 | ]
|
9768 | },
|
9769 | {
|
9770 | name: "MessageEventDefinition",
|
9771 | superClass: [
|
9772 | "EventDefinition"
|
9773 | ],
|
9774 | properties: [
|
9775 | {
|
9776 | name: "messageRef",
|
9777 | type: "Message",
|
9778 | isAttr: true,
|
9779 | isReference: true
|
9780 | },
|
9781 | {
|
9782 | name: "operationRef",
|
9783 | type: "Operation",
|
9784 | isAttr: true,
|
9785 | isReference: true
|
9786 | }
|
9787 | ]
|
9788 | },
|
9789 | {
|
9790 | name: "ConditionalEventDefinition",
|
9791 | superClass: [
|
9792 | "EventDefinition"
|
9793 | ],
|
9794 | properties: [
|
9795 | {
|
9796 | name: "condition",
|
9797 | type: "Expression",
|
9798 | xml: {
|
9799 | serialize: "xsi:type"
|
9800 | }
|
9801 | }
|
9802 | ]
|
9803 | },
|
9804 | {
|
9805 | name: "SignalEventDefinition",
|
9806 | superClass: [
|
9807 | "EventDefinition"
|
9808 | ],
|
9809 | properties: [
|
9810 | {
|
9811 | name: "signalRef",
|
9812 | type: "Signal",
|
9813 | isAttr: true,
|
9814 | isReference: true
|
9815 | }
|
9816 | ]
|
9817 | },
|
9818 | {
|
9819 | name: "Signal",
|
9820 | superClass: [
|
9821 | "RootElement"
|
9822 | ],
|
9823 | properties: [
|
9824 | {
|
9825 | name: "structureRef",
|
9826 | type: "ItemDefinition",
|
9827 | isAttr: true,
|
9828 | isReference: true
|
9829 | },
|
9830 | {
|
9831 | name: "name",
|
9832 | isAttr: true,
|
9833 | type: "String"
|
9834 | }
|
9835 | ]
|
9836 | },
|
9837 | {
|
9838 | name: "ImplicitThrowEvent",
|
9839 | superClass: [
|
9840 | "ThrowEvent"
|
9841 | ]
|
9842 | },
|
9843 | {
|
9844 | name: "DataState",
|
9845 | superClass: [
|
9846 | "BaseElement"
|
9847 | ],
|
9848 | properties: [
|
9849 | {
|
9850 | name: "name",
|
9851 | isAttr: true,
|
9852 | type: "String"
|
9853 | }
|
9854 | ]
|
9855 | },
|
9856 | {
|
9857 | name: "ItemAwareElement",
|
9858 | superClass: [
|
9859 | "BaseElement"
|
9860 | ],
|
9861 | properties: [
|
9862 | {
|
9863 | name: "itemSubjectRef",
|
9864 | type: "ItemDefinition",
|
9865 | isAttr: true,
|
9866 | isReference: true
|
9867 | },
|
9868 | {
|
9869 | name: "dataState",
|
9870 | type: "DataState"
|
9871 | }
|
9872 | ]
|
9873 | },
|
9874 | {
|
9875 | name: "DataAssociation",
|
9876 | superClass: [
|
9877 | "BaseElement"
|
9878 | ],
|
9879 | properties: [
|
9880 | {
|
9881 | name: "assignment",
|
9882 | type: "Assignment",
|
9883 | isMany: true
|
9884 | },
|
9885 | {
|
9886 | name: "sourceRef",
|
9887 | type: "ItemAwareElement",
|
9888 | isMany: true,
|
9889 | isReference: true
|
9890 | },
|
9891 | {
|
9892 | name: "targetRef",
|
9893 | type: "ItemAwareElement",
|
9894 | isReference: true
|
9895 | },
|
9896 | {
|
9897 | name: "transformation",
|
9898 | type: "FormalExpression",
|
9899 | xml: {
|
9900 | serialize: "property"
|
9901 | }
|
9902 | }
|
9903 | ]
|
9904 | },
|
9905 | {
|
9906 | name: "DataInput",
|
9907 | superClass: [
|
9908 | "ItemAwareElement"
|
9909 | ],
|
9910 | properties: [
|
9911 | {
|
9912 | name: "name",
|
9913 | isAttr: true,
|
9914 | type: "String"
|
9915 | },
|
9916 | {
|
9917 | name: "isCollection",
|
9918 | "default": false,
|
9919 | isAttr: true,
|
9920 | type: "Boolean"
|
9921 | },
|
9922 | {
|
9923 | name: "inputSetRef",
|
9924 | type: "InputSet",
|
9925 | isVirtual: true,
|
9926 | isMany: true,
|
9927 | isReference: true
|
9928 | },
|
9929 | {
|
9930 | name: "inputSetWithOptional",
|
9931 | type: "InputSet",
|
9932 | isVirtual: true,
|
9933 | isMany: true,
|
9934 | isReference: true
|
9935 | },
|
9936 | {
|
9937 | name: "inputSetWithWhileExecuting",
|
9938 | type: "InputSet",
|
9939 | isVirtual: true,
|
9940 | isMany: true,
|
9941 | isReference: true
|
9942 | }
|
9943 | ]
|
9944 | },
|
9945 | {
|
9946 | name: "DataOutput",
|
9947 | superClass: [
|
9948 | "ItemAwareElement"
|
9949 | ],
|
9950 | properties: [
|
9951 | {
|
9952 | name: "name",
|
9953 | isAttr: true,
|
9954 | type: "String"
|
9955 | },
|
9956 | {
|
9957 | name: "isCollection",
|
9958 | "default": false,
|
9959 | isAttr: true,
|
9960 | type: "Boolean"
|
9961 | },
|
9962 | {
|
9963 | name: "outputSetRef",
|
9964 | type: "OutputSet",
|
9965 | isVirtual: true,
|
9966 | isMany: true,
|
9967 | isReference: true
|
9968 | },
|
9969 | {
|
9970 | name: "outputSetWithOptional",
|
9971 | type: "OutputSet",
|
9972 | isVirtual: true,
|
9973 | isMany: true,
|
9974 | isReference: true
|
9975 | },
|
9976 | {
|
9977 | name: "outputSetWithWhileExecuting",
|
9978 | type: "OutputSet",
|
9979 | isVirtual: true,
|
9980 | isMany: true,
|
9981 | isReference: true
|
9982 | }
|
9983 | ]
|
9984 | },
|
9985 | {
|
9986 | name: "InputSet",
|
9987 | superClass: [
|
9988 | "BaseElement"
|
9989 | ],
|
9990 | properties: [
|
9991 | {
|
9992 | name: "name",
|
9993 | isAttr: true,
|
9994 | type: "String"
|
9995 | },
|
9996 | {
|
9997 | name: "dataInputRefs",
|
9998 | type: "DataInput",
|
9999 | isMany: true,
|
10000 | isReference: true
|
10001 | },
|
10002 | {
|
10003 | name: "optionalInputRefs",
|
10004 | type: "DataInput",
|
10005 | isMany: true,
|
10006 | isReference: true
|
10007 | },
|
10008 | {
|
10009 | name: "whileExecutingInputRefs",
|
10010 | type: "DataInput",
|
10011 | isMany: true,
|
10012 | isReference: true
|
10013 | },
|
10014 | {
|
10015 | name: "outputSetRefs",
|
10016 | type: "OutputSet",
|
10017 | isMany: true,
|
10018 | isReference: true
|
10019 | }
|
10020 | ]
|
10021 | },
|
10022 | {
|
10023 | name: "OutputSet",
|
10024 | superClass: [
|
10025 | "BaseElement"
|
10026 | ],
|
10027 | properties: [
|
10028 | {
|
10029 | name: "dataOutputRefs",
|
10030 | type: "DataOutput",
|
10031 | isMany: true,
|
10032 | isReference: true
|
10033 | },
|
10034 | {
|
10035 | name: "name",
|
10036 | isAttr: true,
|
10037 | type: "String"
|
10038 | },
|
10039 | {
|
10040 | name: "inputSetRefs",
|
10041 | type: "InputSet",
|
10042 | isMany: true,
|
10043 | isReference: true
|
10044 | },
|
10045 | {
|
10046 | name: "optionalOutputRefs",
|
10047 | type: "DataOutput",
|
10048 | isMany: true,
|
10049 | isReference: true
|
10050 | },
|
10051 | {
|
10052 | name: "whileExecutingOutputRefs",
|
10053 | type: "DataOutput",
|
10054 | isMany: true,
|
10055 | isReference: true
|
10056 | }
|
10057 | ]
|
10058 | },
|
10059 | {
|
10060 | name: "Property",
|
10061 | superClass: [
|
10062 | "ItemAwareElement"
|
10063 | ],
|
10064 | properties: [
|
10065 | {
|
10066 | name: "name",
|
10067 | isAttr: true,
|
10068 | type: "String"
|
10069 | }
|
10070 | ]
|
10071 | },
|
10072 | {
|
10073 | name: "DataInputAssociation",
|
10074 | superClass: [
|
10075 | "DataAssociation"
|
10076 | ]
|
10077 | },
|
10078 | {
|
10079 | name: "DataOutputAssociation",
|
10080 | superClass: [
|
10081 | "DataAssociation"
|
10082 | ]
|
10083 | },
|
10084 | {
|
10085 | name: "InputOutputSpecification",
|
10086 | superClass: [
|
10087 | "BaseElement"
|
10088 | ],
|
10089 | properties: [
|
10090 | {
|
10091 | name: "dataInputs",
|
10092 | type: "DataInput",
|
10093 | isMany: true
|
10094 | },
|
10095 | {
|
10096 | name: "dataOutputs",
|
10097 | type: "DataOutput",
|
10098 | isMany: true
|
10099 | },
|
10100 | {
|
10101 | name: "inputSets",
|
10102 | type: "InputSet",
|
10103 | isMany: true
|
10104 | },
|
10105 | {
|
10106 | name: "outputSets",
|
10107 | type: "OutputSet",
|
10108 | isMany: true
|
10109 | }
|
10110 | ]
|
10111 | },
|
10112 | {
|
10113 | name: "DataObject",
|
10114 | superClass: [
|
10115 | "FlowElement",
|
10116 | "ItemAwareElement"
|
10117 | ],
|
10118 | properties: [
|
10119 | {
|
10120 | name: "isCollection",
|
10121 | "default": false,
|
10122 | isAttr: true,
|
10123 | type: "Boolean"
|
10124 | }
|
10125 | ]
|
10126 | },
|
10127 | {
|
10128 | name: "InputOutputBinding",
|
10129 | properties: [
|
10130 | {
|
10131 | name: "inputDataRef",
|
10132 | type: "InputSet",
|
10133 | isAttr: true,
|
10134 | isReference: true
|
10135 | },
|
10136 | {
|
10137 | name: "outputDataRef",
|
10138 | type: "OutputSet",
|
10139 | isAttr: true,
|
10140 | isReference: true
|
10141 | },
|
10142 | {
|
10143 | name: "operationRef",
|
10144 | type: "Operation",
|
10145 | isAttr: true,
|
10146 | isReference: true
|
10147 | }
|
10148 | ]
|
10149 | },
|
10150 | {
|
10151 | name: "Assignment",
|
10152 | superClass: [
|
10153 | "BaseElement"
|
10154 | ],
|
10155 | properties: [
|
10156 | {
|
10157 | name: "from",
|
10158 | type: "Expression",
|
10159 | xml: {
|
10160 | serialize: "xsi:type"
|
10161 | }
|
10162 | },
|
10163 | {
|
10164 | name: "to",
|
10165 | type: "Expression",
|
10166 | xml: {
|
10167 | serialize: "xsi:type"
|
10168 | }
|
10169 | }
|
10170 | ]
|
10171 | },
|
10172 | {
|
10173 | name: "DataStore",
|
10174 | superClass: [
|
10175 | "RootElement",
|
10176 | "ItemAwareElement"
|
10177 | ],
|
10178 | properties: [
|
10179 | {
|
10180 | name: "name",
|
10181 | isAttr: true,
|
10182 | type: "String"
|
10183 | },
|
10184 | {
|
10185 | name: "capacity",
|
10186 | isAttr: true,
|
10187 | type: "Integer"
|
10188 | },
|
10189 | {
|
10190 | name: "isUnlimited",
|
10191 | "default": true,
|
10192 | isAttr: true,
|
10193 | type: "Boolean"
|
10194 | }
|
10195 | ]
|
10196 | },
|
10197 | {
|
10198 | name: "DataStoreReference",
|
10199 | superClass: [
|
10200 | "ItemAwareElement",
|
10201 | "FlowElement"
|
10202 | ],
|
10203 | properties: [
|
10204 | {
|
10205 | name: "dataStoreRef",
|
10206 | type: "DataStore",
|
10207 | isAttr: true,
|
10208 | isReference: true
|
10209 | }
|
10210 | ]
|
10211 | },
|
10212 | {
|
10213 | name: "DataObjectReference",
|
10214 | superClass: [
|
10215 | "ItemAwareElement",
|
10216 | "FlowElement"
|
10217 | ],
|
10218 | properties: [
|
10219 | {
|
10220 | name: "dataObjectRef",
|
10221 | type: "DataObject",
|
10222 | isAttr: true,
|
10223 | isReference: true
|
10224 | }
|
10225 | ]
|
10226 | },
|
10227 | {
|
10228 | name: "ConversationLink",
|
10229 | superClass: [
|
10230 | "BaseElement"
|
10231 | ],
|
10232 | properties: [
|
10233 | {
|
10234 | name: "sourceRef",
|
10235 | type: "InteractionNode",
|
10236 | isAttr: true,
|
10237 | isReference: true
|
10238 | },
|
10239 | {
|
10240 | name: "targetRef",
|
10241 | type: "InteractionNode",
|
10242 | isAttr: true,
|
10243 | isReference: true
|
10244 | },
|
10245 | {
|
10246 | name: "name",
|
10247 | isAttr: true,
|
10248 | type: "String"
|
10249 | }
|
10250 | ]
|
10251 | },
|
10252 | {
|
10253 | name: "ConversationAssociation",
|
10254 | superClass: [
|
10255 | "BaseElement"
|
10256 | ],
|
10257 | properties: [
|
10258 | {
|
10259 | name: "innerConversationNodeRef",
|
10260 | type: "ConversationNode",
|
10261 | isAttr: true,
|
10262 | isReference: true
|
10263 | },
|
10264 | {
|
10265 | name: "outerConversationNodeRef",
|
10266 | type: "ConversationNode",
|
10267 | isAttr: true,
|
10268 | isReference: true
|
10269 | }
|
10270 | ]
|
10271 | },
|
10272 | {
|
10273 | name: "CallConversation",
|
10274 | superClass: [
|
10275 | "ConversationNode"
|
10276 | ],
|
10277 | properties: [
|
10278 | {
|
10279 | name: "calledCollaborationRef",
|
10280 | type: "Collaboration",
|
10281 | isAttr: true,
|
10282 | isReference: true
|
10283 | },
|
10284 | {
|
10285 | name: "participantAssociations",
|
10286 | type: "ParticipantAssociation",
|
10287 | isMany: true
|
10288 | }
|
10289 | ]
|
10290 | },
|
10291 | {
|
10292 | name: "Conversation",
|
10293 | superClass: [
|
10294 | "ConversationNode"
|
10295 | ]
|
10296 | },
|
10297 | {
|
10298 | name: "SubConversation",
|
10299 | superClass: [
|
10300 | "ConversationNode"
|
10301 | ],
|
10302 | properties: [
|
10303 | {
|
10304 | name: "conversationNodes",
|
10305 | type: "ConversationNode",
|
10306 | isMany: true
|
10307 | }
|
10308 | ]
|
10309 | },
|
10310 | {
|
10311 | name: "ConversationNode",
|
10312 | isAbstract: true,
|
10313 | superClass: [
|
10314 | "InteractionNode",
|
10315 | "BaseElement"
|
10316 | ],
|
10317 | properties: [
|
10318 | {
|
10319 | name: "name",
|
10320 | isAttr: true,
|
10321 | type: "String"
|
10322 | },
|
10323 | {
|
10324 | name: "participantRef",
|
10325 | type: "Participant",
|
10326 | isMany: true,
|
10327 | isReference: true
|
10328 | },
|
10329 | {
|
10330 | name: "messageFlowRefs",
|
10331 | type: "MessageFlow",
|
10332 | isMany: true,
|
10333 | isReference: true
|
10334 | },
|
10335 | {
|
10336 | name: "correlationKeys",
|
10337 | type: "CorrelationKey",
|
10338 | isMany: true
|
10339 | }
|
10340 | ]
|
10341 | },
|
10342 | {
|
10343 | name: "GlobalConversation",
|
10344 | superClass: [
|
10345 | "Collaboration"
|
10346 | ]
|
10347 | },
|
10348 | {
|
10349 | name: "PartnerEntity",
|
10350 | superClass: [
|
10351 | "RootElement"
|
10352 | ],
|
10353 | properties: [
|
10354 | {
|
10355 | name: "name",
|
10356 | isAttr: true,
|
10357 | type: "String"
|
10358 | },
|
10359 | {
|
10360 | name: "participantRef",
|
10361 | type: "Participant",
|
10362 | isMany: true,
|
10363 | isReference: true
|
10364 | }
|
10365 | ]
|
10366 | },
|
10367 | {
|
10368 | name: "PartnerRole",
|
10369 | superClass: [
|
10370 | "RootElement"
|
10371 | ],
|
10372 | properties: [
|
10373 | {
|
10374 | name: "name",
|
10375 | isAttr: true,
|
10376 | type: "String"
|
10377 | },
|
10378 | {
|
10379 | name: "participantRef",
|
10380 | type: "Participant",
|
10381 | isMany: true,
|
10382 | isReference: true
|
10383 | }
|
10384 | ]
|
10385 | },
|
10386 | {
|
10387 | name: "CorrelationProperty",
|
10388 | superClass: [
|
10389 | "RootElement"
|
10390 | ],
|
10391 | properties: [
|
10392 | {
|
10393 | name: "correlationPropertyRetrievalExpression",
|
10394 | type: "CorrelationPropertyRetrievalExpression",
|
10395 | isMany: true
|
10396 | },
|
10397 | {
|
10398 | name: "name",
|
10399 | isAttr: true,
|
10400 | type: "String"
|
10401 | },
|
10402 | {
|
10403 | name: "type",
|
10404 | type: "ItemDefinition",
|
10405 | isAttr: true,
|
10406 | isReference: true
|
10407 | }
|
10408 | ]
|
10409 | },
|
10410 | {
|
10411 | name: "Error",
|
10412 | superClass: [
|
10413 | "RootElement"
|
10414 | ],
|
10415 | properties: [
|
10416 | {
|
10417 | name: "structureRef",
|
10418 | type: "ItemDefinition",
|
10419 | isAttr: true,
|
10420 | isReference: true
|
10421 | },
|
10422 | {
|
10423 | name: "name",
|
10424 | isAttr: true,
|
10425 | type: "String"
|
10426 | },
|
10427 | {
|
10428 | name: "errorCode",
|
10429 | isAttr: true,
|
10430 | type: "String"
|
10431 | }
|
10432 | ]
|
10433 | },
|
10434 | {
|
10435 | name: "CorrelationKey",
|
10436 | superClass: [
|
10437 | "BaseElement"
|
10438 | ],
|
10439 | properties: [
|
10440 | {
|
10441 | name: "correlationPropertyRef",
|
10442 | type: "CorrelationProperty",
|
10443 | isMany: true,
|
10444 | isReference: true
|
10445 | },
|
10446 | {
|
10447 | name: "name",
|
10448 | isAttr: true,
|
10449 | type: "String"
|
10450 | }
|
10451 | ]
|
10452 | },
|
10453 | {
|
10454 | name: "Expression",
|
10455 | superClass: [
|
10456 | "BaseElement"
|
10457 | ],
|
10458 | isAbstract: false,
|
10459 | properties: [
|
10460 | {
|
10461 | name: "body",
|
10462 | type: "String",
|
10463 | isBody: true
|
10464 | }
|
10465 | ]
|
10466 | },
|
10467 | {
|
10468 | name: "FormalExpression",
|
10469 | superClass: [
|
10470 | "Expression"
|
10471 | ],
|
10472 | properties: [
|
10473 | {
|
10474 | name: "language",
|
10475 | isAttr: true,
|
10476 | type: "String"
|
10477 | },
|
10478 | {
|
10479 | name: "evaluatesToTypeRef",
|
10480 | type: "ItemDefinition",
|
10481 | isAttr: true,
|
10482 | isReference: true
|
10483 | }
|
10484 | ]
|
10485 | },
|
10486 | {
|
10487 | name: "Message",
|
10488 | superClass: [
|
10489 | "RootElement"
|
10490 | ],
|
10491 | properties: [
|
10492 | {
|
10493 | name: "name",
|
10494 | isAttr: true,
|
10495 | type: "String"
|
10496 | },
|
10497 | {
|
10498 | name: "itemRef",
|
10499 | type: "ItemDefinition",
|
10500 | isAttr: true,
|
10501 | isReference: true
|
10502 | }
|
10503 | ]
|
10504 | },
|
10505 | {
|
10506 | name: "ItemDefinition",
|
10507 | superClass: [
|
10508 | "RootElement"
|
10509 | ],
|
10510 | properties: [
|
10511 | {
|
10512 | name: "itemKind",
|
10513 | type: "ItemKind",
|
10514 | isAttr: true
|
10515 | },
|
10516 | {
|
10517 | name: "structureRef",
|
10518 | type: "String",
|
10519 | isAttr: true
|
10520 | },
|
10521 | {
|
10522 | name: "isCollection",
|
10523 | "default": false,
|
10524 | isAttr: true,
|
10525 | type: "Boolean"
|
10526 | },
|
10527 | {
|
10528 | name: "import",
|
10529 | type: "Import",
|
10530 | isAttr: true,
|
10531 | isReference: true
|
10532 | }
|
10533 | ]
|
10534 | },
|
10535 | {
|
10536 | name: "FlowElement",
|
10537 | isAbstract: true,
|
10538 | superClass: [
|
10539 | "BaseElement"
|
10540 | ],
|
10541 | properties: [
|
10542 | {
|
10543 | name: "name",
|
10544 | isAttr: true,
|
10545 | type: "String"
|
10546 | },
|
10547 | {
|
10548 | name: "auditing",
|
10549 | type: "Auditing"
|
10550 | },
|
10551 | {
|
10552 | name: "monitoring",
|
10553 | type: "Monitoring"
|
10554 | },
|
10555 | {
|
10556 | name: "categoryValueRef",
|
10557 | type: "CategoryValue",
|
10558 | isMany: true,
|
10559 | isReference: true
|
10560 | }
|
10561 | ]
|
10562 | },
|
10563 | {
|
10564 | name: "SequenceFlow",
|
10565 | superClass: [
|
10566 | "FlowElement"
|
10567 | ],
|
10568 | properties: [
|
10569 | {
|
10570 | name: "isImmediate",
|
10571 | isAttr: true,
|
10572 | type: "Boolean"
|
10573 | },
|
10574 | {
|
10575 | name: "conditionExpression",
|
10576 | type: "Expression",
|
10577 | xml: {
|
10578 | serialize: "xsi:type"
|
10579 | }
|
10580 | },
|
10581 | {
|
10582 | name: "sourceRef",
|
10583 | type: "FlowNode",
|
10584 | isAttr: true,
|
10585 | isReference: true
|
10586 | },
|
10587 | {
|
10588 | name: "targetRef",
|
10589 | type: "FlowNode",
|
10590 | isAttr: true,
|
10591 | isReference: true
|
10592 | }
|
10593 | ]
|
10594 | },
|
10595 | {
|
10596 | name: "FlowElementsContainer",
|
10597 | isAbstract: true,
|
10598 | superClass: [
|
10599 | "BaseElement"
|
10600 | ],
|
10601 | properties: [
|
10602 | {
|
10603 | name: "laneSets",
|
10604 | type: "LaneSet",
|
10605 | isMany: true
|
10606 | },
|
10607 | {
|
10608 | name: "flowElements",
|
10609 | type: "FlowElement",
|
10610 | isMany: true
|
10611 | }
|
10612 | ]
|
10613 | },
|
10614 | {
|
10615 | name: "CallableElement",
|
10616 | isAbstract: true,
|
10617 | superClass: [
|
10618 | "RootElement"
|
10619 | ],
|
10620 | properties: [
|
10621 | {
|
10622 | name: "name",
|
10623 | isAttr: true,
|
10624 | type: "String"
|
10625 | },
|
10626 | {
|
10627 | name: "ioSpecification",
|
10628 | type: "InputOutputSpecification",
|
10629 | xml: {
|
10630 | serialize: "property"
|
10631 | }
|
10632 | },
|
10633 | {
|
10634 | name: "supportedInterfaceRef",
|
10635 | type: "Interface",
|
10636 | isMany: true,
|
10637 | isReference: true
|
10638 | },
|
10639 | {
|
10640 | name: "ioBinding",
|
10641 | type: "InputOutputBinding",
|
10642 | isMany: true,
|
10643 | xml: {
|
10644 | serialize: "property"
|
10645 | }
|
10646 | }
|
10647 | ]
|
10648 | },
|
10649 | {
|
10650 | name: "FlowNode",
|
10651 | isAbstract: true,
|
10652 | superClass: [
|
10653 | "FlowElement"
|
10654 | ],
|
10655 | properties: [
|
10656 | {
|
10657 | name: "incoming",
|
10658 | type: "SequenceFlow",
|
10659 | isMany: true,
|
10660 | isReference: true
|
10661 | },
|
10662 | {
|
10663 | name: "outgoing",
|
10664 | type: "SequenceFlow",
|
10665 | isMany: true,
|
10666 | isReference: true
|
10667 | },
|
10668 | {
|
10669 | name: "lanes",
|
10670 | type: "Lane",
|
10671 | isVirtual: true,
|
10672 | isMany: true,
|
10673 | isReference: true
|
10674 | }
|
10675 | ]
|
10676 | },
|
10677 | {
|
10678 | name: "CorrelationPropertyRetrievalExpression",
|
10679 | superClass: [
|
10680 | "BaseElement"
|
10681 | ],
|
10682 | properties: [
|
10683 | {
|
10684 | name: "messagePath",
|
10685 | type: "FormalExpression"
|
10686 | },
|
10687 | {
|
10688 | name: "messageRef",
|
10689 | type: "Message",
|
10690 | isAttr: true,
|
10691 | isReference: true
|
10692 | }
|
10693 | ]
|
10694 | },
|
10695 | {
|
10696 | name: "CorrelationPropertyBinding",
|
10697 | superClass: [
|
10698 | "BaseElement"
|
10699 | ],
|
10700 | properties: [
|
10701 | {
|
10702 | name: "dataPath",
|
10703 | type: "FormalExpression"
|
10704 | },
|
10705 | {
|
10706 | name: "correlationPropertyRef",
|
10707 | type: "CorrelationProperty",
|
10708 | isAttr: true,
|
10709 | isReference: true
|
10710 | }
|
10711 | ]
|
10712 | },
|
10713 | {
|
10714 | name: "Resource",
|
10715 | superClass: [
|
10716 | "RootElement"
|
10717 | ],
|
10718 | properties: [
|
10719 | {
|
10720 | name: "name",
|
10721 | isAttr: true,
|
10722 | type: "String"
|
10723 | },
|
10724 | {
|
10725 | name: "resourceParameters",
|
10726 | type: "ResourceParameter",
|
10727 | isMany: true
|
10728 | }
|
10729 | ]
|
10730 | },
|
10731 | {
|
10732 | name: "ResourceParameter",
|
10733 | superClass: [
|
10734 | "BaseElement"
|
10735 | ],
|
10736 | properties: [
|
10737 | {
|
10738 | name: "name",
|
10739 | isAttr: true,
|
10740 | type: "String"
|
10741 | },
|
10742 | {
|
10743 | name: "isRequired",
|
10744 | isAttr: true,
|
10745 | type: "Boolean"
|
10746 | },
|
10747 | {
|
10748 | name: "type",
|
10749 | type: "ItemDefinition",
|
10750 | isAttr: true,
|
10751 | isReference: true
|
10752 | }
|
10753 | ]
|
10754 | },
|
10755 | {
|
10756 | name: "CorrelationSubscription",
|
10757 | superClass: [
|
10758 | "BaseElement"
|
10759 | ],
|
10760 | properties: [
|
10761 | {
|
10762 | name: "correlationKeyRef",
|
10763 | type: "CorrelationKey",
|
10764 | isAttr: true,
|
10765 | isReference: true
|
10766 | },
|
10767 | {
|
10768 | name: "correlationPropertyBinding",
|
10769 | type: "CorrelationPropertyBinding",
|
10770 | isMany: true
|
10771 | }
|
10772 | ]
|
10773 | },
|
10774 | {
|
10775 | name: "MessageFlow",
|
10776 | superClass: [
|
10777 | "BaseElement"
|
10778 | ],
|
10779 | properties: [
|
10780 | {
|
10781 | name: "name",
|
10782 | isAttr: true,
|
10783 | type: "String"
|
10784 | },
|
10785 | {
|
10786 | name: "sourceRef",
|
10787 | type: "InteractionNode",
|
10788 | isAttr: true,
|
10789 | isReference: true
|
10790 | },
|
10791 | {
|
10792 | name: "targetRef",
|
10793 | type: "InteractionNode",
|
10794 | isAttr: true,
|
10795 | isReference: true
|
10796 | },
|
10797 | {
|
10798 | name: "messageRef",
|
10799 | type: "Message",
|
10800 | isAttr: true,
|
10801 | isReference: true
|
10802 | }
|
10803 | ]
|
10804 | },
|
10805 | {
|
10806 | name: "MessageFlowAssociation",
|
10807 | superClass: [
|
10808 | "BaseElement"
|
10809 | ],
|
10810 | properties: [
|
10811 | {
|
10812 | name: "innerMessageFlowRef",
|
10813 | type: "MessageFlow",
|
10814 | isAttr: true,
|
10815 | isReference: true
|
10816 | },
|
10817 | {
|
10818 | name: "outerMessageFlowRef",
|
10819 | type: "MessageFlow",
|
10820 | isAttr: true,
|
10821 | isReference: true
|
10822 | }
|
10823 | ]
|
10824 | },
|
10825 | {
|
10826 | name: "InteractionNode",
|
10827 | isAbstract: true,
|
10828 | properties: [
|
10829 | {
|
10830 | name: "incomingConversationLinks",
|
10831 | type: "ConversationLink",
|
10832 | isVirtual: true,
|
10833 | isMany: true,
|
10834 | isReference: true
|
10835 | },
|
10836 | {
|
10837 | name: "outgoingConversationLinks",
|
10838 | type: "ConversationLink",
|
10839 | isVirtual: true,
|
10840 | isMany: true,
|
10841 | isReference: true
|
10842 | }
|
10843 | ]
|
10844 | },
|
10845 | {
|
10846 | name: "Participant",
|
10847 | superClass: [
|
10848 | "InteractionNode",
|
10849 | "BaseElement"
|
10850 | ],
|
10851 | properties: [
|
10852 | {
|
10853 | name: "name",
|
10854 | isAttr: true,
|
10855 | type: "String"
|
10856 | },
|
10857 | {
|
10858 | name: "interfaceRef",
|
10859 | type: "Interface",
|
10860 | isMany: true,
|
10861 | isReference: true
|
10862 | },
|
10863 | {
|
10864 | name: "participantMultiplicity",
|
10865 | type: "ParticipantMultiplicity"
|
10866 | },
|
10867 | {
|
10868 | name: "endPointRefs",
|
10869 | type: "EndPoint",
|
10870 | isMany: true,
|
10871 | isReference: true
|
10872 | },
|
10873 | {
|
10874 | name: "processRef",
|
10875 | type: "Process",
|
10876 | isAttr: true,
|
10877 | isReference: true
|
10878 | }
|
10879 | ]
|
10880 | },
|
10881 | {
|
10882 | name: "ParticipantAssociation",
|
10883 | superClass: [
|
10884 | "BaseElement"
|
10885 | ],
|
10886 | properties: [
|
10887 | {
|
10888 | name: "innerParticipantRef",
|
10889 | type: "Participant",
|
10890 | isAttr: true,
|
10891 | isReference: true
|
10892 | },
|
10893 | {
|
10894 | name: "outerParticipantRef",
|
10895 | type: "Participant",
|
10896 | isAttr: true,
|
10897 | isReference: true
|
10898 | }
|
10899 | ]
|
10900 | },
|
10901 | {
|
10902 | name: "ParticipantMultiplicity",
|
10903 | properties: [
|
10904 | {
|
10905 | name: "minimum",
|
10906 | "default": 0,
|
10907 | isAttr: true,
|
10908 | type: "Integer"
|
10909 | },
|
10910 | {
|
10911 | name: "maximum",
|
10912 | "default": 1,
|
10913 | isAttr: true,
|
10914 | type: "Integer"
|
10915 | }
|
10916 | ],
|
10917 | superClass: [
|
10918 | "BaseElement"
|
10919 | ]
|
10920 | },
|
10921 | {
|
10922 | name: "Collaboration",
|
10923 | superClass: [
|
10924 | "RootElement"
|
10925 | ],
|
10926 | properties: [
|
10927 | {
|
10928 | name: "name",
|
10929 | isAttr: true,
|
10930 | type: "String"
|
10931 | },
|
10932 | {
|
10933 | name: "isClosed",
|
10934 | isAttr: true,
|
10935 | type: "Boolean"
|
10936 | },
|
10937 | {
|
10938 | name: "participants",
|
10939 | type: "Participant",
|
10940 | isMany: true
|
10941 | },
|
10942 | {
|
10943 | name: "messageFlows",
|
10944 | type: "MessageFlow",
|
10945 | isMany: true
|
10946 | },
|
10947 | {
|
10948 | name: "artifacts",
|
10949 | type: "Artifact",
|
10950 | isMany: true
|
10951 | },
|
10952 | {
|
10953 | name: "conversations",
|
10954 | type: "ConversationNode",
|
10955 | isMany: true
|
10956 | },
|
10957 | {
|
10958 | name: "conversationAssociations",
|
10959 | type: "ConversationAssociation"
|
10960 | },
|
10961 | {
|
10962 | name: "participantAssociations",
|
10963 | type: "ParticipantAssociation",
|
10964 | isMany: true
|
10965 | },
|
10966 | {
|
10967 | name: "messageFlowAssociations",
|
10968 | type: "MessageFlowAssociation",
|
10969 | isMany: true
|
10970 | },
|
10971 | {
|
10972 | name: "correlationKeys",
|
10973 | type: "CorrelationKey",
|
10974 | isMany: true
|
10975 | },
|
10976 | {
|
10977 | name: "choreographyRef",
|
10978 | type: "Choreography",
|
10979 | isMany: true,
|
10980 | isReference: true
|
10981 | },
|
10982 | {
|
10983 | name: "conversationLinks",
|
10984 | type: "ConversationLink",
|
10985 | isMany: true
|
10986 | }
|
10987 | ]
|
10988 | },
|
10989 | {
|
10990 | name: "ChoreographyActivity",
|
10991 | isAbstract: true,
|
10992 | superClass: [
|
10993 | "FlowNode"
|
10994 | ],
|
10995 | properties: [
|
10996 | {
|
10997 | name: "participantRef",
|
10998 | type: "Participant",
|
10999 | isMany: true,
|
11000 | isReference: true
|
11001 | },
|
11002 | {
|
11003 | name: "initiatingParticipantRef",
|
11004 | type: "Participant",
|
11005 | isAttr: true,
|
11006 | isReference: true
|
11007 | },
|
11008 | {
|
11009 | name: "correlationKeys",
|
11010 | type: "CorrelationKey",
|
11011 | isMany: true
|
11012 | },
|
11013 | {
|
11014 | name: "loopType",
|
11015 | type: "ChoreographyLoopType",
|
11016 | "default": "None",
|
11017 | isAttr: true
|
11018 | }
|
11019 | ]
|
11020 | },
|
11021 | {
|
11022 | name: "CallChoreography",
|
11023 | superClass: [
|
11024 | "ChoreographyActivity"
|
11025 | ],
|
11026 | properties: [
|
11027 | {
|
11028 | name: "calledChoreographyRef",
|
11029 | type: "Choreography",
|
11030 | isAttr: true,
|
11031 | isReference: true
|
11032 | },
|
11033 | {
|
11034 | name: "participantAssociations",
|
11035 | type: "ParticipantAssociation",
|
11036 | isMany: true
|
11037 | }
|
11038 | ]
|
11039 | },
|
11040 | {
|
11041 | name: "SubChoreography",
|
11042 | superClass: [
|
11043 | "ChoreographyActivity",
|
11044 | "FlowElementsContainer"
|
11045 | ],
|
11046 | properties: [
|
11047 | {
|
11048 | name: "artifacts",
|
11049 | type: "Artifact",
|
11050 | isMany: true
|
11051 | }
|
11052 | ]
|
11053 | },
|
11054 | {
|
11055 | name: "ChoreographyTask",
|
11056 | superClass: [
|
11057 | "ChoreographyActivity"
|
11058 | ],
|
11059 | properties: [
|
11060 | {
|
11061 | name: "messageFlowRef",
|
11062 | type: "MessageFlow",
|
11063 | isMany: true,
|
11064 | isReference: true
|
11065 | }
|
11066 | ]
|
11067 | },
|
11068 | {
|
11069 | name: "Choreography",
|
11070 | superClass: [
|
11071 | "Collaboration",
|
11072 | "FlowElementsContainer"
|
11073 | ]
|
11074 | },
|
11075 | {
|
11076 | name: "GlobalChoreographyTask",
|
11077 | superClass: [
|
11078 | "Choreography"
|
11079 | ],
|
11080 | properties: [
|
11081 | {
|
11082 | name: "initiatingParticipantRef",
|
11083 | type: "Participant",
|
11084 | isAttr: true,
|
11085 | isReference: true
|
11086 | }
|
11087 | ]
|
11088 | },
|
11089 | {
|
11090 | name: "TextAnnotation",
|
11091 | superClass: [
|
11092 | "Artifact"
|
11093 | ],
|
11094 | properties: [
|
11095 | {
|
11096 | name: "text",
|
11097 | type: "String"
|
11098 | },
|
11099 | {
|
11100 | name: "textFormat",
|
11101 | "default": "text/plain",
|
11102 | isAttr: true,
|
11103 | type: "String"
|
11104 | }
|
11105 | ]
|
11106 | },
|
11107 | {
|
11108 | name: "Group",
|
11109 | superClass: [
|
11110 | "Artifact"
|
11111 | ],
|
11112 | properties: [
|
11113 | {
|
11114 | name: "categoryValueRef",
|
11115 | type: "CategoryValue",
|
11116 | isAttr: true,
|
11117 | isReference: true
|
11118 | }
|
11119 | ]
|
11120 | },
|
11121 | {
|
11122 | name: "Association",
|
11123 | superClass: [
|
11124 | "Artifact"
|
11125 | ],
|
11126 | properties: [
|
11127 | {
|
11128 | name: "associationDirection",
|
11129 | type: "AssociationDirection",
|
11130 | isAttr: true
|
11131 | },
|
11132 | {
|
11133 | name: "sourceRef",
|
11134 | type: "BaseElement",
|
11135 | isAttr: true,
|
11136 | isReference: true
|
11137 | },
|
11138 | {
|
11139 | name: "targetRef",
|
11140 | type: "BaseElement",
|
11141 | isAttr: true,
|
11142 | isReference: true
|
11143 | }
|
11144 | ]
|
11145 | },
|
11146 | {
|
11147 | name: "Category",
|
11148 | superClass: [
|
11149 | "RootElement"
|
11150 | ],
|
11151 | properties: [
|
11152 | {
|
11153 | name: "categoryValue",
|
11154 | type: "CategoryValue",
|
11155 | isMany: true
|
11156 | },
|
11157 | {
|
11158 | name: "name",
|
11159 | isAttr: true,
|
11160 | type: "String"
|
11161 | }
|
11162 | ]
|
11163 | },
|
11164 | {
|
11165 | name: "Artifact",
|
11166 | isAbstract: true,
|
11167 | superClass: [
|
11168 | "BaseElement"
|
11169 | ]
|
11170 | },
|
11171 | {
|
11172 | name: "CategoryValue",
|
11173 | superClass: [
|
11174 | "BaseElement"
|
11175 | ],
|
11176 | properties: [
|
11177 | {
|
11178 | name: "categorizedFlowElements",
|
11179 | type: "FlowElement",
|
11180 | isVirtual: true,
|
11181 | isMany: true,
|
11182 | isReference: true
|
11183 | },
|
11184 | {
|
11185 | name: "value",
|
11186 | isAttr: true,
|
11187 | type: "String"
|
11188 | }
|
11189 | ]
|
11190 | },
|
11191 | {
|
11192 | name: "Activity",
|
11193 | isAbstract: true,
|
11194 | superClass: [
|
11195 | "FlowNode"
|
11196 | ],
|
11197 | properties: [
|
11198 | {
|
11199 | name: "isForCompensation",
|
11200 | "default": false,
|
11201 | isAttr: true,
|
11202 | type: "Boolean"
|
11203 | },
|
11204 | {
|
11205 | name: "default",
|
11206 | type: "SequenceFlow",
|
11207 | isAttr: true,
|
11208 | isReference: true
|
11209 | },
|
11210 | {
|
11211 | name: "ioSpecification",
|
11212 | type: "InputOutputSpecification",
|
11213 | xml: {
|
11214 | serialize: "property"
|
11215 | }
|
11216 | },
|
11217 | {
|
11218 | name: "boundaryEventRefs",
|
11219 | type: "BoundaryEvent",
|
11220 | isMany: true,
|
11221 | isReference: true
|
11222 | },
|
11223 | {
|
11224 | name: "properties",
|
11225 | type: "Property",
|
11226 | isMany: true
|
11227 | },
|
11228 | {
|
11229 | name: "dataInputAssociations",
|
11230 | type: "DataInputAssociation",
|
11231 | isMany: true
|
11232 | },
|
11233 | {
|
11234 | name: "dataOutputAssociations",
|
11235 | type: "DataOutputAssociation",
|
11236 | isMany: true
|
11237 | },
|
11238 | {
|
11239 | name: "startQuantity",
|
11240 | "default": 1,
|
11241 | isAttr: true,
|
11242 | type: "Integer"
|
11243 | },
|
11244 | {
|
11245 | name: "resources",
|
11246 | type: "ResourceRole",
|
11247 | isMany: true
|
11248 | },
|
11249 | {
|
11250 | name: "completionQuantity",
|
11251 | "default": 1,
|
11252 | isAttr: true,
|
11253 | type: "Integer"
|
11254 | },
|
11255 | {
|
11256 | name: "loopCharacteristics",
|
11257 | type: "LoopCharacteristics"
|
11258 | }
|
11259 | ]
|
11260 | },
|
11261 | {
|
11262 | name: "ServiceTask",
|
11263 | superClass: [
|
11264 | "Task"
|
11265 | ],
|
11266 | properties: [
|
11267 | {
|
11268 | name: "implementation",
|
11269 | isAttr: true,
|
11270 | type: "String"
|
11271 | },
|
11272 | {
|
11273 | name: "operationRef",
|
11274 | type: "Operation",
|
11275 | isAttr: true,
|
11276 | isReference: true
|
11277 | }
|
11278 | ]
|
11279 | },
|
11280 | {
|
11281 | name: "SubProcess",
|
11282 | superClass: [
|
11283 | "Activity",
|
11284 | "FlowElementsContainer",
|
11285 | "InteractionNode"
|
11286 | ],
|
11287 | properties: [
|
11288 | {
|
11289 | name: "triggeredByEvent",
|
11290 | "default": false,
|
11291 | isAttr: true,
|
11292 | type: "Boolean"
|
11293 | },
|
11294 | {
|
11295 | name: "artifacts",
|
11296 | type: "Artifact",
|
11297 | isMany: true
|
11298 | }
|
11299 | ]
|
11300 | },
|
11301 | {
|
11302 | name: "LoopCharacteristics",
|
11303 | isAbstract: true,
|
11304 | superClass: [
|
11305 | "BaseElement"
|
11306 | ]
|
11307 | },
|
11308 | {
|
11309 | name: "MultiInstanceLoopCharacteristics",
|
11310 | superClass: [
|
11311 | "LoopCharacteristics"
|
11312 | ],
|
11313 | properties: [
|
11314 | {
|
11315 | name: "isSequential",
|
11316 | "default": false,
|
11317 | isAttr: true,
|
11318 | type: "Boolean"
|
11319 | },
|
11320 | {
|
11321 | name: "behavior",
|
11322 | type: "MultiInstanceBehavior",
|
11323 | "default": "All",
|
11324 | isAttr: true
|
11325 | },
|
11326 | {
|
11327 | name: "loopCardinality",
|
11328 | type: "Expression",
|
11329 | xml: {
|
11330 | serialize: "xsi:type"
|
11331 | }
|
11332 | },
|
11333 | {
|
11334 | name: "loopDataInputRef",
|
11335 | type: "ItemAwareElement",
|
11336 | isReference: true
|
11337 | },
|
11338 | {
|
11339 | name: "loopDataOutputRef",
|
11340 | type: "ItemAwareElement",
|
11341 | isReference: true
|
11342 | },
|
11343 | {
|
11344 | name: "inputDataItem",
|
11345 | type: "DataInput",
|
11346 | xml: {
|
11347 | serialize: "property"
|
11348 | }
|
11349 | },
|
11350 | {
|
11351 | name: "outputDataItem",
|
11352 | type: "DataOutput",
|
11353 | xml: {
|
11354 | serialize: "property"
|
11355 | }
|
11356 | },
|
11357 | {
|
11358 | name: "complexBehaviorDefinition",
|
11359 | type: "ComplexBehaviorDefinition",
|
11360 | isMany: true
|
11361 | },
|
11362 | {
|
11363 | name: "completionCondition",
|
11364 | type: "Expression",
|
11365 | xml: {
|
11366 | serialize: "xsi:type"
|
11367 | }
|
11368 | },
|
11369 | {
|
11370 | name: "oneBehaviorEventRef",
|
11371 | type: "EventDefinition",
|
11372 | isAttr: true,
|
11373 | isReference: true
|
11374 | },
|
11375 | {
|
11376 | name: "noneBehaviorEventRef",
|
11377 | type: "EventDefinition",
|
11378 | isAttr: true,
|
11379 | isReference: true
|
11380 | }
|
11381 | ]
|
11382 | },
|
11383 | {
|
11384 | name: "StandardLoopCharacteristics",
|
11385 | superClass: [
|
11386 | "LoopCharacteristics"
|
11387 | ],
|
11388 | properties: [
|
11389 | {
|
11390 | name: "testBefore",
|
11391 | "default": false,
|
11392 | isAttr: true,
|
11393 | type: "Boolean"
|
11394 | },
|
11395 | {
|
11396 | name: "loopCondition",
|
11397 | type: "Expression",
|
11398 | xml: {
|
11399 | serialize: "xsi:type"
|
11400 | }
|
11401 | },
|
11402 | {
|
11403 | name: "loopMaximum",
|
11404 | type: "Integer",
|
11405 | isAttr: true
|
11406 | }
|
11407 | ]
|
11408 | },
|
11409 | {
|
11410 | name: "CallActivity",
|
11411 | superClass: [
|
11412 | "Activity"
|
11413 | ],
|
11414 | properties: [
|
11415 | {
|
11416 | name: "calledElement",
|
11417 | type: "String",
|
11418 | isAttr: true
|
11419 | }
|
11420 | ]
|
11421 | },
|
11422 | {
|
11423 | name: "Task",
|
11424 | superClass: [
|
11425 | "Activity",
|
11426 | "InteractionNode"
|
11427 | ]
|
11428 | },
|
11429 | {
|
11430 | name: "SendTask",
|
11431 | superClass: [
|
11432 | "Task"
|
11433 | ],
|
11434 | properties: [
|
11435 | {
|
11436 | name: "implementation",
|
11437 | isAttr: true,
|
11438 | type: "String"
|
11439 | },
|
11440 | {
|
11441 | name: "operationRef",
|
11442 | type: "Operation",
|
11443 | isAttr: true,
|
11444 | isReference: true
|
11445 | },
|
11446 | {
|
11447 | name: "messageRef",
|
11448 | type: "Message",
|
11449 | isAttr: true,
|
11450 | isReference: true
|
11451 | }
|
11452 | ]
|
11453 | },
|
11454 | {
|
11455 | name: "ReceiveTask",
|
11456 | superClass: [
|
11457 | "Task"
|
11458 | ],
|
11459 | properties: [
|
11460 | {
|
11461 | name: "implementation",
|
11462 | isAttr: true,
|
11463 | type: "String"
|
11464 | },
|
11465 | {
|
11466 | name: "instantiate",
|
11467 | "default": false,
|
11468 | isAttr: true,
|
11469 | type: "Boolean"
|
11470 | },
|
11471 | {
|
11472 | name: "operationRef",
|
11473 | type: "Operation",
|
11474 | isAttr: true,
|
11475 | isReference: true
|
11476 | },
|
11477 | {
|
11478 | name: "messageRef",
|
11479 | type: "Message",
|
11480 | isAttr: true,
|
11481 | isReference: true
|
11482 | }
|
11483 | ]
|
11484 | },
|
11485 | {
|
11486 | name: "ScriptTask",
|
11487 | superClass: [
|
11488 | "Task"
|
11489 | ],
|
11490 | properties: [
|
11491 | {
|
11492 | name: "scriptFormat",
|
11493 | isAttr: true,
|
11494 | type: "String"
|
11495 | },
|
11496 | {
|
11497 | name: "script",
|
11498 | type: "String"
|
11499 | }
|
11500 | ]
|
11501 | },
|
11502 | {
|
11503 | name: "BusinessRuleTask",
|
11504 | superClass: [
|
11505 | "Task"
|
11506 | ],
|
11507 | properties: [
|
11508 | {
|
11509 | name: "implementation",
|
11510 | isAttr: true,
|
11511 | type: "String"
|
11512 | }
|
11513 | ]
|
11514 | },
|
11515 | {
|
11516 | name: "AdHocSubProcess",
|
11517 | superClass: [
|
11518 | "SubProcess"
|
11519 | ],
|
11520 | properties: [
|
11521 | {
|
11522 | name: "completionCondition",
|
11523 | type: "Expression",
|
11524 | xml: {
|
11525 | serialize: "xsi:type"
|
11526 | }
|
11527 | },
|
11528 | {
|
11529 | name: "ordering",
|
11530 | type: "AdHocOrdering",
|
11531 | isAttr: true
|
11532 | },
|
11533 | {
|
11534 | name: "cancelRemainingInstances",
|
11535 | "default": true,
|
11536 | isAttr: true,
|
11537 | type: "Boolean"
|
11538 | }
|
11539 | ]
|
11540 | },
|
11541 | {
|
11542 | name: "Transaction",
|
11543 | superClass: [
|
11544 | "SubProcess"
|
11545 | ],
|
11546 | properties: [
|
11547 | {
|
11548 | name: "protocol",
|
11549 | isAttr: true,
|
11550 | type: "String"
|
11551 | },
|
11552 | {
|
11553 | name: "method",
|
11554 | isAttr: true,
|
11555 | type: "String"
|
11556 | }
|
11557 | ]
|
11558 | },
|
11559 | {
|
11560 | name: "GlobalScriptTask",
|
11561 | superClass: [
|
11562 | "GlobalTask"
|
11563 | ],
|
11564 | properties: [
|
11565 | {
|
11566 | name: "scriptLanguage",
|
11567 | isAttr: true,
|
11568 | type: "String"
|
11569 | },
|
11570 | {
|
11571 | name: "script",
|
11572 | isAttr: true,
|
11573 | type: "String"
|
11574 | }
|
11575 | ]
|
11576 | },
|
11577 | {
|
11578 | name: "GlobalBusinessRuleTask",
|
11579 | superClass: [
|
11580 | "GlobalTask"
|
11581 | ],
|
11582 | properties: [
|
11583 | {
|
11584 | name: "implementation",
|
11585 | isAttr: true,
|
11586 | type: "String"
|
11587 | }
|
11588 | ]
|
11589 | },
|
11590 | {
|
11591 | name: "ComplexBehaviorDefinition",
|
11592 | superClass: [
|
11593 | "BaseElement"
|
11594 | ],
|
11595 | properties: [
|
11596 | {
|
11597 | name: "condition",
|
11598 | type: "FormalExpression"
|
11599 | },
|
11600 | {
|
11601 | name: "event",
|
11602 | type: "ImplicitThrowEvent"
|
11603 | }
|
11604 | ]
|
11605 | },
|
11606 | {
|
11607 | name: "ResourceRole",
|
11608 | superClass: [
|
11609 | "BaseElement"
|
11610 | ],
|
11611 | properties: [
|
11612 | {
|
11613 | name: "resourceRef",
|
11614 | type: "Resource",
|
11615 | isReference: true
|
11616 | },
|
11617 | {
|
11618 | name: "resourceParameterBindings",
|
11619 | type: "ResourceParameterBinding",
|
11620 | isMany: true
|
11621 | },
|
11622 | {
|
11623 | name: "resourceAssignmentExpression",
|
11624 | type: "ResourceAssignmentExpression"
|
11625 | },
|
11626 | {
|
11627 | name: "name",
|
11628 | isAttr: true,
|
11629 | type: "String"
|
11630 | }
|
11631 | ]
|
11632 | },
|
11633 | {
|
11634 | name: "ResourceParameterBinding",
|
11635 | properties: [
|
11636 | {
|
11637 | name: "expression",
|
11638 | type: "Expression",
|
11639 | xml: {
|
11640 | serialize: "xsi:type"
|
11641 | }
|
11642 | },
|
11643 | {
|
11644 | name: "parameterRef",
|
11645 | type: "ResourceParameter",
|
11646 | isAttr: true,
|
11647 | isReference: true
|
11648 | }
|
11649 | ],
|
11650 | superClass: [
|
11651 | "BaseElement"
|
11652 | ]
|
11653 | },
|
11654 | {
|
11655 | name: "ResourceAssignmentExpression",
|
11656 | properties: [
|
11657 | {
|
11658 | name: "expression",
|
11659 | type: "Expression",
|
11660 | xml: {
|
11661 | serialize: "xsi:type"
|
11662 | }
|
11663 | }
|
11664 | ],
|
11665 | superClass: [
|
11666 | "BaseElement"
|
11667 | ]
|
11668 | },
|
11669 | {
|
11670 | name: "Import",
|
11671 | properties: [
|
11672 | {
|
11673 | name: "importType",
|
11674 | isAttr: true,
|
11675 | type: "String"
|
11676 | },
|
11677 | {
|
11678 | name: "location",
|
11679 | isAttr: true,
|
11680 | type: "String"
|
11681 | },
|
11682 | {
|
11683 | name: "namespace",
|
11684 | isAttr: true,
|
11685 | type: "String"
|
11686 | }
|
11687 | ]
|
11688 | },
|
11689 | {
|
11690 | name: "Definitions",
|
11691 | superClass: [
|
11692 | "BaseElement"
|
11693 | ],
|
11694 | properties: [
|
11695 | {
|
11696 | name: "name",
|
11697 | isAttr: true,
|
11698 | type: "String"
|
11699 | },
|
11700 | {
|
11701 | name: "targetNamespace",
|
11702 | isAttr: true,
|
11703 | type: "String"
|
11704 | },
|
11705 | {
|
11706 | name: "expressionLanguage",
|
11707 | "default": "http://www.w3.org/1999/XPath",
|
11708 | isAttr: true,
|
11709 | type: "String"
|
11710 | },
|
11711 | {
|
11712 | name: "typeLanguage",
|
11713 | "default": "http://www.w3.org/2001/XMLSchema",
|
11714 | isAttr: true,
|
11715 | type: "String"
|
11716 | },
|
11717 | {
|
11718 | name: "imports",
|
11719 | type: "Import",
|
11720 | isMany: true
|
11721 | },
|
11722 | {
|
11723 | name: "extensions",
|
11724 | type: "Extension",
|
11725 | isMany: true
|
11726 | },
|
11727 | {
|
11728 | name: "rootElements",
|
11729 | type: "RootElement",
|
11730 | isMany: true
|
11731 | },
|
11732 | {
|
11733 | name: "diagrams",
|
11734 | isMany: true,
|
11735 | type: "bpmndi:BPMNDiagram"
|
11736 | },
|
11737 | {
|
11738 | name: "exporter",
|
11739 | isAttr: true,
|
11740 | type: "String"
|
11741 | },
|
11742 | {
|
11743 | name: "relationships",
|
11744 | type: "Relationship",
|
11745 | isMany: true
|
11746 | },
|
11747 | {
|
11748 | name: "exporterVersion",
|
11749 | isAttr: true,
|
11750 | type: "String"
|
11751 | }
|
11752 | ]
|
11753 | }
|
11754 | ];
|
11755 | var enumerations = [
|
11756 | {
|
11757 | name: "ProcessType",
|
11758 | literalValues: [
|
11759 | {
|
11760 | name: "None"
|
11761 | },
|
11762 | {
|
11763 | name: "Public"
|
11764 | },
|
11765 | {
|
11766 | name: "Private"
|
11767 | }
|
11768 | ]
|
11769 | },
|
11770 | {
|
11771 | name: "GatewayDirection",
|
11772 | literalValues: [
|
11773 | {
|
11774 | name: "Unspecified"
|
11775 | },
|
11776 | {
|
11777 | name: "Converging"
|
11778 | },
|
11779 | {
|
11780 | name: "Diverging"
|
11781 | },
|
11782 | {
|
11783 | name: "Mixed"
|
11784 | }
|
11785 | ]
|
11786 | },
|
11787 | {
|
11788 | name: "EventBasedGatewayType",
|
11789 | literalValues: [
|
11790 | {
|
11791 | name: "Parallel"
|
11792 | },
|
11793 | {
|
11794 | name: "Exclusive"
|
11795 | }
|
11796 | ]
|
11797 | },
|
11798 | {
|
11799 | name: "RelationshipDirection",
|
11800 | literalValues: [
|
11801 | {
|
11802 | name: "None"
|
11803 | },
|
11804 | {
|
11805 | name: "Forward"
|
11806 | },
|
11807 | {
|
11808 | name: "Backward"
|
11809 | },
|
11810 | {
|
11811 | name: "Both"
|
11812 | }
|
11813 | ]
|
11814 | },
|
11815 | {
|
11816 | name: "ItemKind",
|
11817 | literalValues: [
|
11818 | {
|
11819 | name: "Physical"
|
11820 | },
|
11821 | {
|
11822 | name: "Information"
|
11823 | }
|
11824 | ]
|
11825 | },
|
11826 | {
|
11827 | name: "ChoreographyLoopType",
|
11828 | literalValues: [
|
11829 | {
|
11830 | name: "None"
|
11831 | },
|
11832 | {
|
11833 | name: "Standard"
|
11834 | },
|
11835 | {
|
11836 | name: "MultiInstanceSequential"
|
11837 | },
|
11838 | {
|
11839 | name: "MultiInstanceParallel"
|
11840 | }
|
11841 | ]
|
11842 | },
|
11843 | {
|
11844 | name: "AssociationDirection",
|
11845 | literalValues: [
|
11846 | {
|
11847 | name: "None"
|
11848 | },
|
11849 | {
|
11850 | name: "One"
|
11851 | },
|
11852 | {
|
11853 | name: "Both"
|
11854 | }
|
11855 | ]
|
11856 | },
|
11857 | {
|
11858 | name: "MultiInstanceBehavior",
|
11859 | literalValues: [
|
11860 | {
|
11861 | name: "None"
|
11862 | },
|
11863 | {
|
11864 | name: "One"
|
11865 | },
|
11866 | {
|
11867 | name: "All"
|
11868 | },
|
11869 | {
|
11870 | name: "Complex"
|
11871 | }
|
11872 | ]
|
11873 | },
|
11874 | {
|
11875 | name: "AdHocOrdering",
|
11876 | literalValues: [
|
11877 | {
|
11878 | name: "Parallel"
|
11879 | },
|
11880 | {
|
11881 | name: "Sequential"
|
11882 | }
|
11883 | ]
|
11884 | }
|
11885 | ];
|
11886 | var prefix$1 = "bpmn";
|
11887 | var xml = {
|
11888 | tagAlias: "lowerCase",
|
11889 | typePrefix: "t"
|
11890 | };
|
11891 | var BpmnPackage = {
|
11892 | name: name,
|
11893 | uri: uri,
|
11894 | associations: associations,
|
11895 | types: types$1,
|
11896 | enumerations: enumerations,
|
11897 | prefix: prefix$1,
|
11898 | xml: xml
|
11899 | };
|
11900 |
|
11901 | var name$1 = "BPMNDI";
|
11902 | var uri$1 = "http://www.omg.org/spec/BPMN/20100524/DI";
|
11903 | var types$2 = [
|
11904 | {
|
11905 | name: "BPMNDiagram",
|
11906 | properties: [
|
11907 | {
|
11908 | name: "plane",
|
11909 | type: "BPMNPlane",
|
11910 | redefines: "di:Diagram#rootElement"
|
11911 | },
|
11912 | {
|
11913 | name: "labelStyle",
|
11914 | type: "BPMNLabelStyle",
|
11915 | isMany: true
|
11916 | }
|
11917 | ],
|
11918 | superClass: [
|
11919 | "di:Diagram"
|
11920 | ]
|
11921 | },
|
11922 | {
|
11923 | name: "BPMNPlane",
|
11924 | properties: [
|
11925 | {
|
11926 | name: "bpmnElement",
|
11927 | isAttr: true,
|
11928 | isReference: true,
|
11929 | type: "bpmn:BaseElement",
|
11930 | redefines: "di:DiagramElement#modelElement"
|
11931 | }
|
11932 | ],
|
11933 | superClass: [
|
11934 | "di:Plane"
|
11935 | ]
|
11936 | },
|
11937 | {
|
11938 | name: "BPMNShape",
|
11939 | properties: [
|
11940 | {
|
11941 | name: "bpmnElement",
|
11942 | isAttr: true,
|
11943 | isReference: true,
|
11944 | type: "bpmn:BaseElement",
|
11945 | redefines: "di:DiagramElement#modelElement"
|
11946 | },
|
11947 | {
|
11948 | name: "isHorizontal",
|
11949 | isAttr: true,
|
11950 | type: "Boolean"
|
11951 | },
|
11952 | {
|
11953 | name: "isExpanded",
|
11954 | isAttr: true,
|
11955 | type: "Boolean"
|
11956 | },
|
11957 | {
|
11958 | name: "isMarkerVisible",
|
11959 | isAttr: true,
|
11960 | type: "Boolean"
|
11961 | },
|
11962 | {
|
11963 | name: "label",
|
11964 | type: "BPMNLabel"
|
11965 | },
|
11966 | {
|
11967 | name: "isMessageVisible",
|
11968 | isAttr: true,
|
11969 | type: "Boolean"
|
11970 | },
|
11971 | {
|
11972 | name: "participantBandKind",
|
11973 | type: "ParticipantBandKind",
|
11974 | isAttr: true
|
11975 | },
|
11976 | {
|
11977 | name: "choreographyActivityShape",
|
11978 | type: "BPMNShape",
|
11979 | isAttr: true,
|
11980 | isReference: true
|
11981 | }
|
11982 | ],
|
11983 | superClass: [
|
11984 | "di:LabeledShape"
|
11985 | ]
|
11986 | },
|
11987 | {
|
11988 | name: "BPMNEdge",
|
11989 | properties: [
|
11990 | {
|
11991 | name: "label",
|
11992 | type: "BPMNLabel"
|
11993 | },
|
11994 | {
|
11995 | name: "bpmnElement",
|
11996 | isAttr: true,
|
11997 | isReference: true,
|
11998 | type: "bpmn:BaseElement",
|
11999 | redefines: "di:DiagramElement#modelElement"
|
12000 | },
|
12001 | {
|
12002 | name: "sourceElement",
|
12003 | isAttr: true,
|
12004 | isReference: true,
|
12005 | type: "di:DiagramElement",
|
12006 | redefines: "di:Edge#source"
|
12007 | },
|
12008 | {
|
12009 | name: "targetElement",
|
12010 | isAttr: true,
|
12011 | isReference: true,
|
12012 | type: "di:DiagramElement",
|
12013 | redefines: "di:Edge#target"
|
12014 | },
|
12015 | {
|
12016 | name: "messageVisibleKind",
|
12017 | type: "MessageVisibleKind",
|
12018 | isAttr: true,
|
12019 | "default": "initiating"
|
12020 | }
|
12021 | ],
|
12022 | superClass: [
|
12023 | "di:LabeledEdge"
|
12024 | ]
|
12025 | },
|
12026 | {
|
12027 | name: "BPMNLabel",
|
12028 | properties: [
|
12029 | {
|
12030 | name: "labelStyle",
|
12031 | type: "BPMNLabelStyle",
|
12032 | isAttr: true,
|
12033 | isReference: true,
|
12034 | redefines: "di:DiagramElement#style"
|
12035 | }
|
12036 | ],
|
12037 | superClass: [
|
12038 | "di:Label"
|
12039 | ]
|
12040 | },
|
12041 | {
|
12042 | name: "BPMNLabelStyle",
|
12043 | properties: [
|
12044 | {
|
12045 | name: "font",
|
12046 | type: "dc:Font"
|
12047 | }
|
12048 | ],
|
12049 | superClass: [
|
12050 | "di:Style"
|
12051 | ]
|
12052 | }
|
12053 | ];
|
12054 | var enumerations$1 = [
|
12055 | {
|
12056 | name: "ParticipantBandKind",
|
12057 | literalValues: [
|
12058 | {
|
12059 | name: "top_initiating"
|
12060 | },
|
12061 | {
|
12062 | name: "middle_initiating"
|
12063 | },
|
12064 | {
|
12065 | name: "bottom_initiating"
|
12066 | },
|
12067 | {
|
12068 | name: "top_non_initiating"
|
12069 | },
|
12070 | {
|
12071 | name: "middle_non_initiating"
|
12072 | },
|
12073 | {
|
12074 | name: "bottom_non_initiating"
|
12075 | }
|
12076 | ]
|
12077 | },
|
12078 | {
|
12079 | name: "MessageVisibleKind",
|
12080 | literalValues: [
|
12081 | {
|
12082 | name: "initiating"
|
12083 | },
|
12084 | {
|
12085 | name: "non_initiating"
|
12086 | }
|
12087 | ]
|
12088 | }
|
12089 | ];
|
12090 | var associations$1 = [
|
12091 | ];
|
12092 | var prefix$2 = "bpmndi";
|
12093 | var BpmnDiPackage = {
|
12094 | name: name$1,
|
12095 | uri: uri$1,
|
12096 | types: types$2,
|
12097 | enumerations: enumerations$1,
|
12098 | associations: associations$1,
|
12099 | prefix: prefix$2
|
12100 | };
|
12101 |
|
12102 | var name$2 = "DC";
|
12103 | var uri$2 = "http://www.omg.org/spec/DD/20100524/DC";
|
12104 | var types$3 = [
|
12105 | {
|
12106 | name: "Boolean"
|
12107 | },
|
12108 | {
|
12109 | name: "Integer"
|
12110 | },
|
12111 | {
|
12112 | name: "Real"
|
12113 | },
|
12114 | {
|
12115 | name: "String"
|
12116 | },
|
12117 | {
|
12118 | name: "Font",
|
12119 | properties: [
|
12120 | {
|
12121 | name: "name",
|
12122 | type: "String",
|
12123 | isAttr: true
|
12124 | },
|
12125 | {
|
12126 | name: "size",
|
12127 | type: "Real",
|
12128 | isAttr: true
|
12129 | },
|
12130 | {
|
12131 | name: "isBold",
|
12132 | type: "Boolean",
|
12133 | isAttr: true
|
12134 | },
|
12135 | {
|
12136 | name: "isItalic",
|
12137 | type: "Boolean",
|
12138 | isAttr: true
|
12139 | },
|
12140 | {
|
12141 | name: "isUnderline",
|
12142 | type: "Boolean",
|
12143 | isAttr: true
|
12144 | },
|
12145 | {
|
12146 | name: "isStrikeThrough",
|
12147 | type: "Boolean",
|
12148 | isAttr: true
|
12149 | }
|
12150 | ]
|
12151 | },
|
12152 | {
|
12153 | name: "Point",
|
12154 | properties: [
|
12155 | {
|
12156 | name: "x",
|
12157 | type: "Real",
|
12158 | "default": "0",
|
12159 | isAttr: true
|
12160 | },
|
12161 | {
|
12162 | name: "y",
|
12163 | type: "Real",
|
12164 | "default": "0",
|
12165 | isAttr: true
|
12166 | }
|
12167 | ]
|
12168 | },
|
12169 | {
|
12170 | name: "Bounds",
|
12171 | properties: [
|
12172 | {
|
12173 | name: "x",
|
12174 | type: "Real",
|
12175 | "default": "0",
|
12176 | isAttr: true
|
12177 | },
|
12178 | {
|
12179 | name: "y",
|
12180 | type: "Real",
|
12181 | "default": "0",
|
12182 | isAttr: true
|
12183 | },
|
12184 | {
|
12185 | name: "width",
|
12186 | type: "Real",
|
12187 | isAttr: true
|
12188 | },
|
12189 | {
|
12190 | name: "height",
|
12191 | type: "Real",
|
12192 | isAttr: true
|
12193 | }
|
12194 | ]
|
12195 | }
|
12196 | ];
|
12197 | var prefix$3 = "dc";
|
12198 | var associations$2 = [
|
12199 | ];
|
12200 | var DcPackage = {
|
12201 | name: name$2,
|
12202 | uri: uri$2,
|
12203 | types: types$3,
|
12204 | prefix: prefix$3,
|
12205 | associations: associations$2
|
12206 | };
|
12207 |
|
12208 | var name$3 = "DI";
|
12209 | var uri$3 = "http://www.omg.org/spec/DD/20100524/DI";
|
12210 | var types$4 = [
|
12211 | {
|
12212 | name: "DiagramElement",
|
12213 | isAbstract: true,
|
12214 | properties: [
|
12215 | {
|
12216 | name: "id",
|
12217 | type: "String",
|
12218 | isAttr: true,
|
12219 | isId: true
|
12220 | },
|
12221 | {
|
12222 | name: "extension",
|
12223 | type: "Extension"
|
12224 | },
|
12225 | {
|
12226 | name: "owningDiagram",
|
12227 | type: "Diagram",
|
12228 | isReadOnly: true,
|
12229 | isVirtual: true,
|
12230 | isReference: true
|
12231 | },
|
12232 | {
|
12233 | name: "owningElement",
|
12234 | type: "DiagramElement",
|
12235 | isReadOnly: true,
|
12236 | isVirtual: true,
|
12237 | isReference: true
|
12238 | },
|
12239 | {
|
12240 | name: "modelElement",
|
12241 | isReadOnly: true,
|
12242 | isVirtual: true,
|
12243 | isReference: true,
|
12244 | type: "Element"
|
12245 | },
|
12246 | {
|
12247 | name: "style",
|
12248 | type: "Style",
|
12249 | isReadOnly: true,
|
12250 | isVirtual: true,
|
12251 | isReference: true
|
12252 | },
|
12253 | {
|
12254 | name: "ownedElement",
|
12255 | type: "DiagramElement",
|
12256 | isReadOnly: true,
|
12257 | isVirtual: true,
|
12258 | isMany: true
|
12259 | }
|
12260 | ]
|
12261 | },
|
12262 | {
|
12263 | name: "Node",
|
12264 | isAbstract: true,
|
12265 | superClass: [
|
12266 | "DiagramElement"
|
12267 | ]
|
12268 | },
|
12269 | {
|
12270 | name: "Edge",
|
12271 | isAbstract: true,
|
12272 | superClass: [
|
12273 | "DiagramElement"
|
12274 | ],
|
12275 | properties: [
|
12276 | {
|
12277 | name: "source",
|
12278 | type: "DiagramElement",
|
12279 | isReadOnly: true,
|
12280 | isVirtual: true,
|
12281 | isReference: true
|
12282 | },
|
12283 | {
|
12284 | name: "target",
|
12285 | type: "DiagramElement",
|
12286 | isReadOnly: true,
|
12287 | isVirtual: true,
|
12288 | isReference: true
|
12289 | },
|
12290 | {
|
12291 | name: "waypoint",
|
12292 | isUnique: false,
|
12293 | isMany: true,
|
12294 | type: "dc:Point",
|
12295 | xml: {
|
12296 | serialize: "xsi:type"
|
12297 | }
|
12298 | }
|
12299 | ]
|
12300 | },
|
12301 | {
|
12302 | name: "Diagram",
|
12303 | isAbstract: true,
|
12304 | properties: [
|
12305 | {
|
12306 | name: "id",
|
12307 | type: "String",
|
12308 | isAttr: true,
|
12309 | isId: true
|
12310 | },
|
12311 | {
|
12312 | name: "rootElement",
|
12313 | type: "DiagramElement",
|
12314 | isReadOnly: true,
|
12315 | isVirtual: true
|
12316 | },
|
12317 | {
|
12318 | name: "name",
|
12319 | isAttr: true,
|
12320 | type: "String"
|
12321 | },
|
12322 | {
|
12323 | name: "documentation",
|
12324 | isAttr: true,
|
12325 | type: "String"
|
12326 | },
|
12327 | {
|
12328 | name: "resolution",
|
12329 | isAttr: true,
|
12330 | type: "Real"
|
12331 | },
|
12332 | {
|
12333 | name: "ownedStyle",
|
12334 | type: "Style",
|
12335 | isReadOnly: true,
|
12336 | isVirtual: true,
|
12337 | isMany: true
|
12338 | }
|
12339 | ]
|
12340 | },
|
12341 | {
|
12342 | name: "Shape",
|
12343 | isAbstract: true,
|
12344 | superClass: [
|
12345 | "Node"
|
12346 | ],
|
12347 | properties: [
|
12348 | {
|
12349 | name: "bounds",
|
12350 | type: "dc:Bounds"
|
12351 | }
|
12352 | ]
|
12353 | },
|
12354 | {
|
12355 | name: "Plane",
|
12356 | isAbstract: true,
|
12357 | superClass: [
|
12358 | "Node"
|
12359 | ],
|
12360 | properties: [
|
12361 | {
|
12362 | name: "planeElement",
|
12363 | type: "DiagramElement",
|
12364 | subsettedProperty: "DiagramElement-ownedElement",
|
12365 | isMany: true
|
12366 | }
|
12367 | ]
|
12368 | },
|
12369 | {
|
12370 | name: "LabeledEdge",
|
12371 | isAbstract: true,
|
12372 | superClass: [
|
12373 | "Edge"
|
12374 | ],
|
12375 | properties: [
|
12376 | {
|
12377 | name: "ownedLabel",
|
12378 | type: "Label",
|
12379 | isReadOnly: true,
|
12380 | subsettedProperty: "DiagramElement-ownedElement",
|
12381 | isVirtual: true,
|
12382 | isMany: true
|
12383 | }
|
12384 | ]
|
12385 | },
|
12386 | {
|
12387 | name: "LabeledShape",
|
12388 | isAbstract: true,
|
12389 | superClass: [
|
12390 | "Shape"
|
12391 | ],
|
12392 | properties: [
|
12393 | {
|
12394 | name: "ownedLabel",
|
12395 | type: "Label",
|
12396 | isReadOnly: true,
|
12397 | subsettedProperty: "DiagramElement-ownedElement",
|
12398 | isVirtual: true,
|
12399 | isMany: true
|
12400 | }
|
12401 | ]
|
12402 | },
|
12403 | {
|
12404 | name: "Label",
|
12405 | isAbstract: true,
|
12406 | superClass: [
|
12407 | "Node"
|
12408 | ],
|
12409 | properties: [
|
12410 | {
|
12411 | name: "bounds",
|
12412 | type: "dc:Bounds"
|
12413 | }
|
12414 | ]
|
12415 | },
|
12416 | {
|
12417 | name: "Style",
|
12418 | isAbstract: true,
|
12419 | properties: [
|
12420 | {
|
12421 | name: "id",
|
12422 | type: "String",
|
12423 | isAttr: true,
|
12424 | isId: true
|
12425 | }
|
12426 | ]
|
12427 | },
|
12428 | {
|
12429 | name: "Extension",
|
12430 | properties: [
|
12431 | {
|
12432 | name: "values",
|
12433 | type: "Element",
|
12434 | isMany: true
|
12435 | }
|
12436 | ]
|
12437 | }
|
12438 | ];
|
12439 | var associations$3 = [
|
12440 | ];
|
12441 | var prefix$4 = "di";
|
12442 | var xml$1 = {
|
12443 | tagAlias: "lowerCase"
|
12444 | };
|
12445 | var DiPackage = {
|
12446 | name: name$3,
|
12447 | uri: uri$3,
|
12448 | types: types$4,
|
12449 | associations: associations$3,
|
12450 | prefix: prefix$4,
|
12451 | xml: xml$1
|
12452 | };
|
12453 |
|
12454 | var name$4 = "bpmn.io colors for BPMN";
|
12455 | var uri$4 = "http://bpmn.io/schema/bpmn/biocolor/1.0";
|
12456 | var prefix$5 = "bioc";
|
12457 | var types$5 = [
|
12458 | {
|
12459 | name: "ColoredShape",
|
12460 | "extends": [
|
12461 | "bpmndi:BPMNShape"
|
12462 | ],
|
12463 | properties: [
|
12464 | {
|
12465 | name: "stroke",
|
12466 | isAttr: true,
|
12467 | type: "String"
|
12468 | },
|
12469 | {
|
12470 | name: "fill",
|
12471 | isAttr: true,
|
12472 | type: "String"
|
12473 | }
|
12474 | ]
|
12475 | },
|
12476 | {
|
12477 | name: "ColoredEdge",
|
12478 | "extends": [
|
12479 | "bpmndi:BPMNEdge"
|
12480 | ],
|
12481 | properties: [
|
12482 | {
|
12483 | name: "stroke",
|
12484 | isAttr: true,
|
12485 | type: "String"
|
12486 | },
|
12487 | {
|
12488 | name: "fill",
|
12489 | isAttr: true,
|
12490 | type: "String"
|
12491 | }
|
12492 | ]
|
12493 | }
|
12494 | ];
|
12495 | var enumerations$2 = [
|
12496 | ];
|
12497 | var associations$4 = [
|
12498 | ];
|
12499 | var BiocPackage = {
|
12500 | name: name$4,
|
12501 | uri: uri$4,
|
12502 | prefix: prefix$5,
|
12503 | types: types$5,
|
12504 | enumerations: enumerations$2,
|
12505 | associations: associations$4
|
12506 | };
|
12507 |
|
12508 | var packages = {
|
12509 | bpmn: BpmnPackage,
|
12510 | bpmndi: BpmnDiPackage,
|
12511 | dc: DcPackage,
|
12512 | di: DiPackage,
|
12513 | bioc: BiocPackage
|
12514 | };
|
12515 |
|
12516 | function BpmnModdle$1(additionalPackages, options) {
|
12517 | var pks = assign({}, packages, additionalPackages);
|
12518 |
|
12519 | return new BpmnModdle(pks, options);
|
12520 | }
|
12521 |
|
12522 | function elementToString(e) {
|
12523 | if (!e) {
|
12524 | return '<null>';
|
12525 | }
|
12526 |
|
12527 | return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
|
12528 | }
|
12529 |
|
12530 | var diRefs = new objectRefs(
|
12531 | { name: 'bpmnElement', enumerable: true },
|
12532 | { name: 'di', configurable: true }
|
12533 | );
|
12534 |
|
12535 | |
12536 |
|
12537 |
|
12538 |
|
12539 |
|
12540 |
|
12541 |
|
12542 |
|
12543 | function is(element, type) {
|
12544 | return element.$instanceOf(type);
|
12545 | }
|
12546 |
|
12547 |
|
12548 | |
12549 |
|
12550 |
|
12551 |
|
12552 | function findDisplayCandidate(definitions) {
|
12553 | return find(definitions.rootElements, function(e) {
|
12554 | return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration');
|
12555 | });
|
12556 | }
|
12557 |
|
12558 |
|
12559 | function BpmnTreeWalker(handler, translate) {
|
12560 |
|
12561 |
|
12562 | var handledElements = {};
|
12563 |
|
12564 |
|
12565 |
|
12566 | var deferred = [];
|
12567 |
|
12568 |
|
12569 |
|
12570 | function contextual(fn, ctx) {
|
12571 | return function(e) {
|
12572 | fn(e, ctx);
|
12573 | };
|
12574 | }
|
12575 |
|
12576 | function handled(element) {
|
12577 | handledElements[element.id] = element;
|
12578 | }
|
12579 |
|
12580 | function isHandled(element) {
|
12581 | return handledElements[element.id];
|
12582 | }
|
12583 |
|
12584 | function visit(element, ctx) {
|
12585 |
|
12586 | var gfx = element.gfx;
|
12587 |
|
12588 |
|
12589 | if (gfx) {
|
12590 | throw new Error(
|
12591 | translate('already rendered {element}', { element: elementToString(element) })
|
12592 | );
|
12593 | }
|
12594 |
|
12595 |
|
12596 | return handler.element(element, ctx);
|
12597 | }
|
12598 |
|
12599 | function visitRoot(element, diagram) {
|
12600 | return handler.root(element, diagram);
|
12601 | }
|
12602 |
|
12603 | function visitIfDi(element, ctx) {
|
12604 |
|
12605 | try {
|
12606 | var gfx = element.di && visit(element, ctx);
|
12607 |
|
12608 | handled(element);
|
12609 |
|
12610 | return gfx;
|
12611 | } catch (e) {
|
12612 | logError(e.message, { element: element, error: e });
|
12613 |
|
12614 | console.error(translate('failed to import {element}', { element: elementToString(element) }));
|
12615 | console.error(e);
|
12616 | }
|
12617 | }
|
12618 |
|
12619 | function logError(message, context) {
|
12620 | handler.error(message, context);
|
12621 | }
|
12622 |
|
12623 |
|
12624 |
|
12625 | function registerDi(di) {
|
12626 | var bpmnElement = di.bpmnElement;
|
12627 |
|
12628 | if (bpmnElement) {
|
12629 | if (bpmnElement.di) {
|
12630 | logError(
|
12631 | translate('multiple DI elements defined for {element}', {
|
12632 | element: elementToString(bpmnElement)
|
12633 | }),
|
12634 | { element: bpmnElement }
|
12635 | );
|
12636 | } else {
|
12637 | diRefs.bind(bpmnElement, 'di');
|
12638 | bpmnElement.di = di;
|
12639 | }
|
12640 | } else {
|
12641 | logError(
|
12642 | translate('no bpmnElement referenced in {element}', {
|
12643 | element: elementToString(di)
|
12644 | }),
|
12645 | { element: di }
|
12646 | );
|
12647 | }
|
12648 | }
|
12649 |
|
12650 | function handleDiagram(diagram) {
|
12651 | handlePlane(diagram.plane);
|
12652 | }
|
12653 |
|
12654 | function handlePlane(plane) {
|
12655 | registerDi(plane);
|
12656 |
|
12657 | forEach(plane.planeElement, handlePlaneElement);
|
12658 | }
|
12659 |
|
12660 | function handlePlaneElement(planeElement) {
|
12661 | registerDi(planeElement);
|
12662 | }
|
12663 |
|
12664 |
|
12665 |
|
12666 |
|
12667 | |
12668 |
|
12669 |
|
12670 |
|
12671 |
|
12672 |
|
12673 |
|
12674 |
|
12675 | function handleDefinitions(definitions, diagram) {
|
12676 |
|
12677 |
|
12678 | var diagrams = definitions.diagrams;
|
12679 |
|
12680 | if (diagram && diagrams.indexOf(diagram) === -1) {
|
12681 | throw new Error(translate('diagram not part of bpmn:Definitions'));
|
12682 | }
|
12683 |
|
12684 | if (!diagram && diagrams && diagrams.length) {
|
12685 | diagram = diagrams[0];
|
12686 | }
|
12687 |
|
12688 |
|
12689 | if (!diagram) {
|
12690 | throw new Error(translate('no diagram to display'));
|
12691 | }
|
12692 |
|
12693 |
|
12694 | handleDiagram(diagram);
|
12695 |
|
12696 |
|
12697 | var plane = diagram.plane;
|
12698 |
|
12699 | if (!plane) {
|
12700 | throw new Error(translate(
|
12701 | 'no plane for {element}',
|
12702 | { element: elementToString(diagram) }
|
12703 | ));
|
12704 | }
|
12705 |
|
12706 | var rootElement = plane.bpmnElement;
|
12707 |
|
12708 |
|
12709 |
|
12710 | if (!rootElement) {
|
12711 | rootElement = findDisplayCandidate(definitions);
|
12712 |
|
12713 | if (!rootElement) {
|
12714 | throw new Error(translate('no process or collaboration to display'));
|
12715 | } else {
|
12716 |
|
12717 | logError(
|
12718 | translate('correcting missing bpmnElement on {plane} to {rootElement}', {
|
12719 | plane: elementToString(plane),
|
12720 | rootElement: elementToString(rootElement)
|
12721 | })
|
12722 | );
|
12723 |
|
12724 |
|
12725 | plane.bpmnElement = rootElement;
|
12726 | registerDi(plane);
|
12727 | }
|
12728 | }
|
12729 |
|
12730 |
|
12731 | var ctx = visitRoot(rootElement, plane);
|
12732 |
|
12733 | if (is(rootElement, 'bpmn:Process')) {
|
12734 | handleProcess(rootElement, ctx);
|
12735 | } else if (is(rootElement, 'bpmn:Collaboration')) {
|
12736 | handleCollaboration(rootElement, ctx);
|
12737 |
|
12738 |
|
12739 | handleUnhandledProcesses(definitions.rootElements, ctx);
|
12740 | } else {
|
12741 | throw new Error(
|
12742 | translate('unsupported bpmnElement for {plane}: {rootElement}', {
|
12743 | plane: elementToString(plane),
|
12744 | rootElement: elementToString(rootElement)
|
12745 | })
|
12746 | );
|
12747 | }
|
12748 |
|
12749 |
|
12750 | handleDeferred(deferred);
|
12751 | }
|
12752 |
|
12753 | function handleDeferred() {
|
12754 |
|
12755 | var fn;
|
12756 |
|
12757 |
|
12758 | while (deferred.length) {
|
12759 | fn = deferred.shift();
|
12760 |
|
12761 | fn();
|
12762 | }
|
12763 | }
|
12764 |
|
12765 | function handleProcess(process, context) {
|
12766 | handleFlowElementsContainer(process, context);
|
12767 | handleIoSpecification(process.ioSpecification, context);
|
12768 |
|
12769 | handleArtifacts(process.artifacts, context);
|
12770 |
|
12771 |
|
12772 | handled(process);
|
12773 | }
|
12774 |
|
12775 | function handleUnhandledProcesses(rootElements) {
|
12776 |
|
12777 |
|
12778 |
|
12779 |
|
12780 | var processes = filter(rootElements, function(e) {
|
12781 | return !isHandled(e) && is(e, 'bpmn:Process') && e.laneSets;
|
12782 | });
|
12783 |
|
12784 | processes.forEach(contextual(handleProcess));
|
12785 | }
|
12786 |
|
12787 | function handleMessageFlow(messageFlow, context) {
|
12788 | visitIfDi(messageFlow, context);
|
12789 | }
|
12790 |
|
12791 | function handleMessageFlows(messageFlows, context) {
|
12792 | forEach(messageFlows, contextual(handleMessageFlow, context));
|
12793 | }
|
12794 |
|
12795 | function handleDataAssociation(association, context) {
|
12796 | visitIfDi(association, context);
|
12797 | }
|
12798 |
|
12799 | function handleDataInput(dataInput, context) {
|
12800 | visitIfDi(dataInput, context);
|
12801 | }
|
12802 |
|
12803 | function handleDataOutput(dataOutput, context) {
|
12804 | visitIfDi(dataOutput, context);
|
12805 | }
|
12806 |
|
12807 | function handleArtifact(artifact, context) {
|
12808 |
|
12809 |
|
12810 |
|
12811 |
|
12812 |
|
12813 | visitIfDi(artifact, context);
|
12814 | }
|
12815 |
|
12816 | function handleArtifacts(artifacts, context) {
|
12817 |
|
12818 | forEach(artifacts, function(e) {
|
12819 | if (is(e, 'bpmn:Association')) {
|
12820 | deferred.push(function() {
|
12821 | handleArtifact(e, context);
|
12822 | });
|
12823 | } else {
|
12824 | handleArtifact(e, context);
|
12825 | }
|
12826 | });
|
12827 | }
|
12828 |
|
12829 | function handleIoSpecification(ioSpecification, context) {
|
12830 |
|
12831 | if (!ioSpecification) {
|
12832 | return;
|
12833 | }
|
12834 |
|
12835 | forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
|
12836 | forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
|
12837 | }
|
12838 |
|
12839 | function handleSubProcess(subProcess, context) {
|
12840 | handleFlowElementsContainer(subProcess, context);
|
12841 | handleArtifacts(subProcess.artifacts, context);
|
12842 | }
|
12843 |
|
12844 | function handleFlowNode(flowNode, context) {
|
12845 | var childCtx = visitIfDi(flowNode, context);
|
12846 |
|
12847 | if (is(flowNode, 'bpmn:SubProcess')) {
|
12848 | handleSubProcess(flowNode, childCtx || context);
|
12849 | }
|
12850 |
|
12851 | if (is(flowNode, 'bpmn:Activity')) {
|
12852 | handleIoSpecification(flowNode.ioSpecification, context);
|
12853 | }
|
12854 |
|
12855 |
|
12856 |
|
12857 |
|
12858 |
|
12859 |
|
12860 |
|
12861 |
|
12862 | deferred.push(function() {
|
12863 | forEach(flowNode.dataInputAssociations, contextual(handleDataAssociation, context));
|
12864 | forEach(flowNode.dataOutputAssociations, contextual(handleDataAssociation, context));
|
12865 | });
|
12866 | }
|
12867 |
|
12868 | function handleSequenceFlow(sequenceFlow, context) {
|
12869 | visitIfDi(sequenceFlow, context);
|
12870 | }
|
12871 |
|
12872 | function handleDataElement(dataObject, context) {
|
12873 | visitIfDi(dataObject, context);
|
12874 | }
|
12875 |
|
12876 | function handleBoundaryEvent(dataObject, context) {
|
12877 | visitIfDi(dataObject, context);
|
12878 | }
|
12879 |
|
12880 | function handleLane(lane, context) {
|
12881 |
|
12882 | deferred.push(function() {
|
12883 |
|
12884 | var newContext = visitIfDi(lane, context);
|
12885 |
|
12886 | if (lane.childLaneSet) {
|
12887 | handleLaneSet(lane.childLaneSet, newContext || context);
|
12888 | }
|
12889 |
|
12890 | wireFlowNodeRefs(lane);
|
12891 | });
|
12892 | }
|
12893 |
|
12894 | function handleLaneSet(laneSet, context) {
|
12895 | forEach(laneSet.lanes, contextual(handleLane, context));
|
12896 | }
|
12897 |
|
12898 | function handleLaneSets(laneSets, context) {
|
12899 | forEach(laneSets, contextual(handleLaneSet, context));
|
12900 | }
|
12901 |
|
12902 | function handleFlowElementsContainer(container, context) {
|
12903 | handleFlowElements(container.flowElements, context);
|
12904 |
|
12905 | if (container.laneSets) {
|
12906 | handleLaneSets(container.laneSets, context);
|
12907 | }
|
12908 | }
|
12909 |
|
12910 | function handleFlowElements(flowElements, context) {
|
12911 | forEach(flowElements, function(e) {
|
12912 | if (is(e, 'bpmn:SequenceFlow')) {
|
12913 | deferred.push(function() {
|
12914 | handleSequenceFlow(e, context);
|
12915 | });
|
12916 | } else if (is(e, 'bpmn:BoundaryEvent')) {
|
12917 | deferred.unshift(function() {
|
12918 | handleBoundaryEvent(e, context);
|
12919 | });
|
12920 | } else if (is(e, 'bpmn:FlowNode')) {
|
12921 | handleFlowNode(e, context);
|
12922 | } else if (is(e, 'bpmn:DataObject')) ; else if (is(e, 'bpmn:DataStoreReference')) {
|
12923 | handleDataElement(e, context);
|
12924 | } else if (is(e, 'bpmn:DataObjectReference')) {
|
12925 | handleDataElement(e, context);
|
12926 | } else {
|
12927 | logError(
|
12928 | translate('unrecognized flowElement {element} in context {context}', {
|
12929 | element: elementToString(e),
|
12930 | context: (context ? elementToString(context.businessObject) : 'null')
|
12931 | }),
|
12932 | { element: e, context: context }
|
12933 | );
|
12934 | }
|
12935 | });
|
12936 | }
|
12937 |
|
12938 | function handleParticipant(participant, context) {
|
12939 | var newCtx = visitIfDi(participant, context);
|
12940 |
|
12941 | var process = participant.processRef;
|
12942 | if (process) {
|
12943 | handleProcess(process, newCtx || context);
|
12944 | }
|
12945 | }
|
12946 |
|
12947 | function handleCollaboration(collaboration) {
|
12948 |
|
12949 | forEach(collaboration.participants, contextual(handleParticipant));
|
12950 |
|
12951 | handleArtifacts(collaboration.artifacts);
|
12952 |
|
12953 |
|
12954 | deferred.push(function() {
|
12955 | handleMessageFlows(collaboration.messageFlows);
|
12956 | });
|
12957 | }
|
12958 |
|
12959 |
|
12960 | function wireFlowNodeRefs(lane) {
|
12961 |
|
12962 | forEach(lane.flowNodeRef, function(flowNode) {
|
12963 | var lanes = flowNode.get('lanes');
|
12964 |
|
12965 | if (lanes) {
|
12966 | lanes.push(lane);
|
12967 | }
|
12968 | });
|
12969 | }
|
12970 |
|
12971 |
|
12972 |
|
12973 | return {
|
12974 | handleDeferred: handleDeferred,
|
12975 | handleDefinitions: handleDefinitions,
|
12976 | handleSubProcess: handleSubProcess,
|
12977 | registerDi: registerDi
|
12978 | };
|
12979 | }
|
12980 |
|
12981 | |
12982 |
|
12983 |
|
12984 |
|
12985 |
|
12986 |
|
12987 |
|
12988 |
|
12989 |
|
12990 | function importBpmnDiagram(diagram, definitions, done) {
|
12991 |
|
12992 | var importer,
|
12993 | eventBus,
|
12994 | translate;
|
12995 |
|
12996 | var error,
|
12997 | warnings = [];
|
12998 |
|
12999 | |
13000 |
|
13001 |
|
13002 |
|
13003 |
|
13004 |
|
13005 | function render(definitions) {
|
13006 |
|
13007 | var visitor = {
|
13008 |
|
13009 | root: function(element) {
|
13010 | return importer.add(element);
|
13011 | },
|
13012 |
|
13013 | element: function(element, parentShape) {
|
13014 | return importer.add(element, parentShape);
|
13015 | },
|
13016 |
|
13017 | error: function(message, context) {
|
13018 | warnings.push({ message: message, context: context });
|
13019 | }
|
13020 | };
|
13021 |
|
13022 | var walker = new BpmnTreeWalker(visitor, translate);
|
13023 |
|
13024 |
|
13025 |
|
13026 | walker.handleDefinitions(definitions);
|
13027 | }
|
13028 |
|
13029 | try {
|
13030 | importer = diagram.get('bpmnImporter');
|
13031 | eventBus = diagram.get('eventBus');
|
13032 | translate = diagram.get('translate');
|
13033 |
|
13034 | eventBus.fire('import.render.start', { definitions: definitions });
|
13035 |
|
13036 | render(definitions);
|
13037 |
|
13038 | eventBus.fire('import.render.complete', {
|
13039 | error: error,
|
13040 | warnings: warnings
|
13041 | });
|
13042 | } catch (e) {
|
13043 | error = e;
|
13044 | }
|
13045 |
|
13046 | done(error, warnings);
|
13047 | }
|
13048 |
|
13049 | |
13050 |
|
13051 |
|
13052 |
|
13053 |
|
13054 |
|
13055 |
|
13056 |
|
13057 | function is$1(element, type) {
|
13058 | var bo = getBusinessObject(element);
|
13059 |
|
13060 | return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
|
13061 | }
|
13062 |
|
13063 |
|
13064 | |
13065 |
|
13066 |
|
13067 |
|
13068 |
|
13069 |
|
13070 |
|
13071 | function getBusinessObject(element) {
|
13072 | return (element && element.businessObject) || element;
|
13073 | }
|
13074 |
|
13075 | function isExpanded(element) {
|
13076 |
|
13077 | if (is$1(element, 'bpmn:CallActivity')) {
|
13078 | return false;
|
13079 | }
|
13080 |
|
13081 | if (is$1(element, 'bpmn:SubProcess')) {
|
13082 | return !!getBusinessObject(element).di.isExpanded;
|
13083 | }
|
13084 |
|
13085 | if (is$1(element, 'bpmn:Participant')) {
|
13086 | return !!getBusinessObject(element).processRef;
|
13087 | }
|
13088 |
|
13089 | return true;
|
13090 | }
|
13091 |
|
13092 | function isEventSubProcess(element) {
|
13093 | return element && !!getBusinessObject(element).triggeredByEvent;
|
13094 | }
|
13095 |
|
13096 |
|
13097 |
|
13098 | |
13099 |
|
13100 |
|
13101 |
|
13102 |
|
13103 | function isTypedEvent(event, eventDefinitionType, filter$$1) {
|
13104 |
|
13105 | function matches(definition, filter$$1) {
|
13106 | return every(filter$$1, function(val, key) {
|
13107 |
|
13108 |
|
13109 |
|
13110 |
|
13111 | return definition[key] == val;
|
13112 | });
|
13113 | }
|
13114 |
|
13115 | return some(event.eventDefinitions, function(definition) {
|
13116 | return definition.$type === eventDefinitionType && matches(event, filter$$1);
|
13117 | });
|
13118 | }
|
13119 |
|
13120 | function isThrowEvent(event) {
|
13121 | return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
|
13122 | }
|
13123 |
|
13124 | function isCollection(element) {
|
13125 | var dataObject = element.dataObjectRef;
|
13126 |
|
13127 | return element.isCollection || (dataObject && dataObject.isCollection);
|
13128 | }
|
13129 |
|
13130 | function getDi(element) {
|
13131 | return element.businessObject.di;
|
13132 | }
|
13133 |
|
13134 | function getSemantic(element) {
|
13135 | return element.businessObject;
|
13136 | }
|
13137 |
|
13138 |
|
13139 |
|
13140 |
|
13141 | function getFillColor(element, defaultColor) {
|
13142 | return getDi(element).get('bioc:fill') || defaultColor || 'white';
|
13143 | }
|
13144 |
|
13145 | function getStrokeColor(element, defaultColor) {
|
13146 | return getDi(element).get('bioc:stroke') || defaultColor || 'black';
|
13147 | }
|
13148 |
|
13149 |
|
13150 |
|
13151 |
|
13152 | function getCirclePath(shape) {
|
13153 |
|
13154 | var cx = shape.x + shape.width / 2,
|
13155 | cy = shape.y + shape.height / 2,
|
13156 | radius = shape.width / 2;
|
13157 |
|
13158 | var circlePath = [
|
13159 | ['M', cx, cy],
|
13160 | ['m', 0, -radius],
|
13161 | ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
|
13162 | ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
|
13163 | ['z']
|
13164 | ];
|
13165 |
|
13166 | return componentsToPath(circlePath);
|
13167 | }
|
13168 |
|
13169 | function getRoundRectPath(shape, borderRadius) {
|
13170 |
|
13171 | var x = shape.x,
|
13172 | y = shape.y,
|
13173 | width = shape.width,
|
13174 | height = shape.height;
|
13175 |
|
13176 | var roundRectPath = [
|
13177 | ['M', x + borderRadius, y],
|
13178 | ['l', width - borderRadius * 2, 0],
|
13179 | ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius],
|
13180 | ['l', 0, height - borderRadius * 2],
|
13181 | ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius],
|
13182 | ['l', borderRadius * 2 - width, 0],
|
13183 | ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius],
|
13184 | ['l', 0, borderRadius * 2 - height],
|
13185 | ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius],
|
13186 | ['z']
|
13187 | ];
|
13188 |
|
13189 | return componentsToPath(roundRectPath);
|
13190 | }
|
13191 |
|
13192 | function getDiamondPath(shape) {
|
13193 |
|
13194 | var width = shape.width,
|
13195 | height = shape.height,
|
13196 | x = shape.x,
|
13197 | y = shape.y,
|
13198 | halfWidth = width / 2,
|
13199 | halfHeight = height / 2;
|
13200 |
|
13201 | var diamondPath = [
|
13202 | ['M', x + halfWidth, y],
|
13203 | ['l', halfWidth, halfHeight],
|
13204 | ['l', -halfWidth, halfHeight],
|
13205 | ['l', -halfWidth, -halfHeight],
|
13206 | ['z']
|
13207 | ];
|
13208 |
|
13209 | return componentsToPath(diamondPath);
|
13210 | }
|
13211 |
|
13212 | function getRectPath(shape) {
|
13213 | var x = shape.x,
|
13214 | y = shape.y,
|
13215 | width = shape.width,
|
13216 | height = shape.height;
|
13217 |
|
13218 | var rectPath = [
|
13219 | ['M', x, y],
|
13220 | ['l', width, 0],
|
13221 | ['l', 0, height],
|
13222 | ['l', -width, 0],
|
13223 | ['z']
|
13224 | ];
|
13225 |
|
13226 | return componentsToPath(rectPath);
|
13227 | }
|
13228 |
|
13229 | var hat_1 = createCommonjsModule(function (module) {
|
13230 | var hat = module.exports = function (bits, base) {
|
13231 | if (!base) base = 16;
|
13232 | if (bits === undefined) bits = 128;
|
13233 | if (bits <= 0) return '0';
|
13234 |
|
13235 | var digits = Math.log(Math.pow(2, bits)) / Math.log(base);
|
13236 | for (var i = 2; digits === Infinity; i *= 2) {
|
13237 | digits = Math.log(Math.pow(2, bits / i)) / Math.log(base) * i;
|
13238 | }
|
13239 |
|
13240 | var rem = digits - Math.floor(digits);
|
13241 |
|
13242 | var res = '';
|
13243 |
|
13244 | for (var i = 0; i < Math.floor(digits); i++) {
|
13245 | var x = Math.floor(Math.random() * base).toString(base);
|
13246 | res = x + res;
|
13247 | }
|
13248 |
|
13249 | if (rem) {
|
13250 | var b = Math.pow(base, rem);
|
13251 | var x = Math.floor(Math.random() * b).toString(base);
|
13252 | res = x + res;
|
13253 | }
|
13254 |
|
13255 | var parsed = parseInt(res, base);
|
13256 | if (parsed !== Infinity && parsed >= Math.pow(2, bits)) {
|
13257 | return hat(bits, base)
|
13258 | }
|
13259 | else return res;
|
13260 | };
|
13261 |
|
13262 | hat.rack = function (bits, base, expandBy) {
|
13263 | var fn = function (data) {
|
13264 | var iters = 0;
|
13265 | do {
|
13266 | if (iters ++ > 10) {
|
13267 | if (expandBy) bits += expandBy;
|
13268 | else throw new Error('too many ID collisions, use more bits')
|
13269 | }
|
13270 |
|
13271 | var id = hat(bits, base);
|
13272 | } while (Object.hasOwnProperty.call(hats, id));
|
13273 |
|
13274 | hats[id] = data;
|
13275 | return id;
|
13276 | };
|
13277 | var hats = fn.hats = {};
|
13278 |
|
13279 | fn.get = function (id) {
|
13280 | return fn.hats[id];
|
13281 | };
|
13282 |
|
13283 | fn.set = function (id, value) {
|
13284 | fn.hats[id] = value;
|
13285 | return fn;
|
13286 | };
|
13287 |
|
13288 | fn.bits = bits || 128;
|
13289 | fn.base = base || 16;
|
13290 | return fn;
|
13291 | };
|
13292 | });
|
13293 |
|
13294 | |
13295 |
|
13296 |
|
13297 |
|
13298 |
|
13299 |
|
13300 |
|
13301 | function Ids(seed) {
|
13302 |
|
13303 | if (!(this instanceof Ids)) {
|
13304 | return new Ids(seed);
|
13305 | }
|
13306 |
|
13307 | seed = seed || [ 128, 36, 1 ];
|
13308 | this._seed = seed.length ? hat_1.rack(seed[0], seed[1], seed[2]) : seed;
|
13309 | }
|
13310 |
|
13311 | var ids = Ids;
|
13312 |
|
13313 | |
13314 |
|
13315 |
|
13316 |
|
13317 |
|
13318 |
|
13319 |
|
13320 | Ids.prototype.next = function(element) {
|
13321 | return this._seed(element || true);
|
13322 | };
|
13323 |
|
13324 | |
13325 |
|
13326 |
|
13327 |
|
13328 |
|
13329 |
|
13330 |
|
13331 | Ids.prototype.nextPrefixed = function(prefix, element) {
|
13332 | var id;
|
13333 |
|
13334 | do {
|
13335 | id = prefix + this.next(true);
|
13336 | } while (this.assigned(id));
|
13337 |
|
13338 |
|
13339 | this.claim(id, element);
|
13340 |
|
13341 |
|
13342 | return id;
|
13343 | };
|
13344 |
|
13345 | |
13346 |
|
13347 |
|
13348 |
|
13349 |
|
13350 |
|
13351 | Ids.prototype.claim = function(id, element) {
|
13352 | this._seed.set(id, element || true);
|
13353 | };
|
13354 |
|
13355 | |
13356 |
|
13357 |
|
13358 |
|
13359 |
|
13360 |
|
13361 | Ids.prototype.assigned = function(id) {
|
13362 | return this._seed.get(id) || false;
|
13363 | };
|
13364 |
|
13365 | |
13366 |
|
13367 |
|
13368 |
|
13369 |
|
13370 | Ids.prototype.unclaim = function(id) {
|
13371 | delete this._seed.hats[id];
|
13372 | };
|
13373 |
|
13374 |
|
13375 | |
13376 |
|
13377 |
|
13378 | Ids.prototype.clear = function() {
|
13379 |
|
13380 | var hats = this._seed.hats,
|
13381 | id;
|
13382 |
|
13383 | for (id in hats) {
|
13384 | this.unclaim(id);
|
13385 | }
|
13386 | };
|
13387 |
|
13388 | var RENDERER_IDS = new ids();
|
13389 |
|
13390 | var TASK_BORDER_RADIUS = 10;
|
13391 | var INNER_OUTER_DIST = 3;
|
13392 |
|
13393 | var DEFAULT_FILL_OPACITY = .95,
|
13394 | HIGH_FILL_OPACITY = .35;
|
13395 |
|
13396 |
|
13397 | function BpmnRenderer(
|
13398 | config, eventBus, styles, pathMap,
|
13399 | canvas, textRenderer, priority) {
|
13400 |
|
13401 | BaseRenderer.call(this, eventBus, priority);
|
13402 |
|
13403 | var defaultFillColor = config && config.defaultFillColor,
|
13404 | defaultStrokeColor = config && config.defaultStrokeColor;
|
13405 |
|
13406 | var rendererId = RENDERER_IDS.next();
|
13407 |
|
13408 | var markers = {};
|
13409 |
|
13410 | var computeStyle = styles.computeStyle;
|
13411 |
|
13412 | function addMarker(id, options) {
|
13413 | var attrs = assign({
|
13414 | fill: 'black',
|
13415 | strokeWidth: 1,
|
13416 | strokeLinecap: 'round',
|
13417 | strokeDasharray: 'none'
|
13418 | }, options.attrs);
|
13419 |
|
13420 | var ref = options.ref || { x: 0, y: 0 };
|
13421 |
|
13422 | var scale$$1 = options.scale || 1;
|
13423 |
|
13424 |
|
13425 |
|
13426 | if (attrs.strokeDasharray === 'none') {
|
13427 | attrs.strokeDasharray = [10000, 1];
|
13428 | }
|
13429 |
|
13430 | var marker = create('marker');
|
13431 |
|
13432 | attr$1(options.element, attrs);
|
13433 |
|
13434 | append(marker, options.element);
|
13435 |
|
13436 | attr$1(marker, {
|
13437 | id: id,
|
13438 | viewBox: '0 0 20 20',
|
13439 | refX: ref.x,
|
13440 | refY: ref.y,
|
13441 | markerWidth: 20 * scale$$1,
|
13442 | markerHeight: 20 * scale$$1,
|
13443 | orient: 'auto'
|
13444 | });
|
13445 |
|
13446 | var defs = query('defs', canvas._svg);
|
13447 |
|
13448 | if (!defs) {
|
13449 | defs = create('defs');
|
13450 |
|
13451 | append(canvas._svg, defs);
|
13452 | }
|
13453 |
|
13454 | append(defs, marker);
|
13455 |
|
13456 | markers[id] = marker;
|
13457 | }
|
13458 |
|
13459 | function marker(type, fill, stroke) {
|
13460 | var id = type + '-' + fill + '-' + stroke + '-' + rendererId;
|
13461 |
|
13462 | if (!markers[id]) {
|
13463 | createMarker(type, fill, stroke);
|
13464 | }
|
13465 |
|
13466 | return 'url(#' + id + ')';
|
13467 | }
|
13468 |
|
13469 | function createMarker(type, fill, stroke) {
|
13470 | var id = type + '-' + fill + '-' + stroke + '-' + rendererId;
|
13471 |
|
13472 | if (type === 'sequenceflow-end') {
|
13473 | var sequenceflowEnd = create('path');
|
13474 | attr$1(sequenceflowEnd, { d: 'M 1 5 L 11 10 L 1 15 Z' });
|
13475 |
|
13476 | addMarker(id, {
|
13477 | element: sequenceflowEnd,
|
13478 | ref: { x: 11, y: 10 },
|
13479 | scale: 0.5,
|
13480 | attrs: {
|
13481 | fill: stroke,
|
13482 | stroke: stroke
|
13483 | }
|
13484 | });
|
13485 | }
|
13486 |
|
13487 | if (type === 'messageflow-start') {
|
13488 | var messageflowStart = create('circle');
|
13489 | attr$1(messageflowStart, { cx: 6, cy: 6, r: 3.5 });
|
13490 |
|
13491 | addMarker(id, {
|
13492 | element: messageflowStart,
|
13493 | attrs: {
|
13494 | fill: fill,
|
13495 | stroke: stroke
|
13496 | },
|
13497 | ref: { x: 6, y: 6 }
|
13498 | });
|
13499 | }
|
13500 |
|
13501 | if (type === 'messageflow-end') {
|
13502 | var messageflowEnd = create('path');
|
13503 | attr$1(messageflowEnd, { d: 'm 1 5 l 0 -3 l 7 3 l -7 3 z' });
|
13504 |
|
13505 | addMarker(id, {
|
13506 | element: messageflowEnd,
|
13507 | attrs: {
|
13508 | fill: fill,
|
13509 | stroke: stroke,
|
13510 | strokeLinecap: 'butt'
|
13511 | },
|
13512 | ref: { x: 8.5, y: 5 }
|
13513 | });
|
13514 | }
|
13515 |
|
13516 | if (type === 'association-start') {
|
13517 | var associationStart = create('path');
|
13518 | attr$1(associationStart, { d: 'M 11 5 L 1 10 L 11 15' });
|
13519 |
|
13520 | addMarker(id, {
|
13521 | element: associationStart,
|
13522 | attrs: {
|
13523 | fill: 'none',
|
13524 | stroke: stroke,
|
13525 | strokeWidth: 1.5
|
13526 | },
|
13527 | ref: { x: 1, y: 10 },
|
13528 | scale: 0.5
|
13529 | });
|
13530 | }
|
13531 |
|
13532 | if (type === 'association-end') {
|
13533 | var associationEnd = create('path');
|
13534 | attr$1(associationEnd, { d: 'M 1 5 L 11 10 L 1 15' });
|
13535 |
|
13536 | addMarker(id, {
|
13537 | element: associationEnd,
|
13538 | attrs: {
|
13539 | fill: 'none',
|
13540 | stroke: stroke,
|
13541 | strokeWidth: 1.5
|
13542 | },
|
13543 | ref: { x: 12, y: 10 },
|
13544 | scale: 0.5
|
13545 | });
|
13546 | }
|
13547 |
|
13548 | if (type === 'conditional-flow-marker') {
|
13549 | var conditionalflowMarker = create('path');
|
13550 | attr$1(conditionalflowMarker, { d: 'M 0 10 L 8 6 L 16 10 L 8 14 Z' });
|
13551 |
|
13552 | addMarker(id, {
|
13553 | element: conditionalflowMarker,
|
13554 | attrs: {
|
13555 | fill: fill,
|
13556 | stroke: stroke
|
13557 | },
|
13558 | ref: { x: -1, y: 10 },
|
13559 | scale: 0.5
|
13560 | });
|
13561 | }
|
13562 |
|
13563 | if (type === 'conditional-default-flow-marker') {
|
13564 | var conditionaldefaultflowMarker = create('path');
|
13565 | attr$1(conditionaldefaultflowMarker, { d: 'M 6 4 L 10 16' });
|
13566 |
|
13567 | addMarker(id, {
|
13568 | element: conditionaldefaultflowMarker,
|
13569 | attrs: {
|
13570 | stroke: stroke
|
13571 | },
|
13572 | ref: { x: 0, y: 10 },
|
13573 | scale: 0.5
|
13574 | });
|
13575 | }
|
13576 | }
|
13577 |
|
13578 | function drawCircle(parentGfx, width, height, offset, attrs) {
|
13579 |
|
13580 | if (isObject(offset)) {
|
13581 | attrs = offset;
|
13582 | offset = 0;
|
13583 | }
|
13584 |
|
13585 | offset = offset || 0;
|
13586 |
|
13587 | attrs = computeStyle(attrs, {
|
13588 | stroke: 'black',
|
13589 | strokeWidth: 2,
|
13590 | fill: 'white'
|
13591 | });
|
13592 |
|
13593 | if (attrs.fill === 'none') {
|
13594 | delete attrs.fillOpacity;
|
13595 | }
|
13596 |
|
13597 | var cx = width / 2,
|
13598 | cy = height / 2;
|
13599 |
|
13600 | var circle = create('circle');
|
13601 | attr$1(circle, {
|
13602 | cx: cx,
|
13603 | cy: cy,
|
13604 | r: Math.round((width + height) / 4 - offset)
|
13605 | });
|
13606 | attr$1(circle, attrs);
|
13607 |
|
13608 | append(parentGfx, circle);
|
13609 |
|
13610 | return circle;
|
13611 | }
|
13612 |
|
13613 | function drawRect(parentGfx, width, height, r, offset, attrs) {
|
13614 |
|
13615 | if (isObject(offset)) {
|
13616 | attrs = offset;
|
13617 | offset = 0;
|
13618 | }
|
13619 |
|
13620 | offset = offset || 0;
|
13621 |
|
13622 | attrs = computeStyle(attrs, {
|
13623 | stroke: 'black',
|
13624 | strokeWidth: 2,
|
13625 | fill: 'white'
|
13626 | });
|
13627 |
|
13628 | var rect = create('rect');
|
13629 | attr$1(rect, {
|
13630 | x: offset,
|
13631 | y: offset,
|
13632 | width: width - offset * 2,
|
13633 | height: height - offset * 2,
|
13634 | rx: r,
|
13635 | ry: r
|
13636 | });
|
13637 | attr$1(rect, attrs);
|
13638 |
|
13639 | append(parentGfx, rect);
|
13640 |
|
13641 | return rect;
|
13642 | }
|
13643 |
|
13644 | function drawDiamond(parentGfx, width, height, attrs) {
|
13645 |
|
13646 | var x_2 = width / 2;
|
13647 | var y_2 = height / 2;
|
13648 |
|
13649 | var points = [{ x: x_2, y: 0 }, { x: width, y: y_2 }, { x: x_2, y: height }, { x: 0, y: y_2 }];
|
13650 |
|
13651 | var pointsString = points.map(function(point) {
|
13652 | return point.x + ',' + point.y;
|
13653 | }).join(' ');
|
13654 |
|
13655 | attrs = computeStyle(attrs, {
|
13656 | stroke: 'black',
|
13657 | strokeWidth: 2,
|
13658 | fill: 'white'
|
13659 | });
|
13660 |
|
13661 | var polygon = create('polygon');
|
13662 | attr$1(polygon, {
|
13663 | points: pointsString
|
13664 | });
|
13665 | attr$1(polygon, attrs);
|
13666 |
|
13667 | append(parentGfx, polygon);
|
13668 |
|
13669 | return polygon;
|
13670 | }
|
13671 |
|
13672 | function drawLine(parentGfx, waypoints, attrs) {
|
13673 | attrs = computeStyle(attrs, [ 'no-fill' ], {
|
13674 | stroke: 'black',
|
13675 | strokeWidth: 2,
|
13676 | fill: 'none'
|
13677 | });
|
13678 |
|
13679 | var line = createLine(waypoints, attrs);
|
13680 |
|
13681 | append(parentGfx, line);
|
13682 |
|
13683 | return line;
|
13684 | }
|
13685 |
|
13686 | function drawPath(parentGfx, d, attrs) {
|
13687 |
|
13688 | attrs = computeStyle(attrs, [ 'no-fill' ], {
|
13689 | strokeWidth: 2,
|
13690 | stroke: 'black'
|
13691 | });
|
13692 |
|
13693 | var path = create('path');
|
13694 | attr$1(path, { d: d });
|
13695 | attr$1(path, attrs);
|
13696 |
|
13697 | append(parentGfx, path);
|
13698 |
|
13699 | return path;
|
13700 | }
|
13701 |
|
13702 | function drawMarker(type, parentGfx, path, attrs) {
|
13703 | return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
|
13704 | }
|
13705 |
|
13706 | function as(type) {
|
13707 | return function(parentGfx, element) {
|
13708 | return handlers[type](parentGfx, element);
|
13709 | };
|
13710 | }
|
13711 |
|
13712 | function renderer(type) {
|
13713 | return handlers[type];
|
13714 | }
|
13715 |
|
13716 | function renderEventContent(element, parentGfx) {
|
13717 |
|
13718 | var event = getSemantic(element);
|
13719 | var isThrowing = isThrowEvent(event);
|
13720 |
|
13721 | if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
|
13722 | return renderer('bpmn:MessageEventDefinition')(parentGfx, element, isThrowing);
|
13723 | }
|
13724 |
|
13725 | if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
|
13726 | return renderer('bpmn:TimerEventDefinition')(parentGfx, element, isThrowing);
|
13727 | }
|
13728 |
|
13729 | if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
|
13730 | return renderer('bpmn:ConditionalEventDefinition')(parentGfx, element);
|
13731 | }
|
13732 |
|
13733 | if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
|
13734 | return renderer('bpmn:SignalEventDefinition')(parentGfx, element, isThrowing);
|
13735 | }
|
13736 |
|
13737 | if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
13738 | isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
|
13739 | return renderer('bpmn:MultipleEventDefinition')(parentGfx, element, isThrowing);
|
13740 | }
|
13741 |
|
13742 | if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
13743 | isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
|
13744 | return renderer('bpmn:ParallelMultipleEventDefinition')(parentGfx, element, isThrowing);
|
13745 | }
|
13746 |
|
13747 | if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
|
13748 | return renderer('bpmn:EscalationEventDefinition')(parentGfx, element, isThrowing);
|
13749 | }
|
13750 |
|
13751 | if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
|
13752 | return renderer('bpmn:LinkEventDefinition')(parentGfx, element, isThrowing);
|
13753 | }
|
13754 |
|
13755 | if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
|
13756 | return renderer('bpmn:ErrorEventDefinition')(parentGfx, element, isThrowing);
|
13757 | }
|
13758 |
|
13759 | if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
|
13760 | return renderer('bpmn:CancelEventDefinition')(parentGfx, element, isThrowing);
|
13761 | }
|
13762 |
|
13763 | if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
|
13764 | return renderer('bpmn:CompensateEventDefinition')(parentGfx, element, isThrowing);
|
13765 | }
|
13766 |
|
13767 | if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
|
13768 | return renderer('bpmn:TerminateEventDefinition')(parentGfx, element, isThrowing);
|
13769 | }
|
13770 |
|
13771 | return null;
|
13772 | }
|
13773 |
|
13774 | function renderLabel(parentGfx, label, options) {
|
13775 |
|
13776 | options = assign({
|
13777 | size: {
|
13778 | width: 100
|
13779 | }
|
13780 | }, options);
|
13781 |
|
13782 | var text = textRenderer.createText(label || '', options);
|
13783 |
|
13784 | classes$1(text).add('djs-label');
|
13785 |
|
13786 | append(parentGfx, text);
|
13787 |
|
13788 | return text;
|
13789 | }
|
13790 |
|
13791 | function renderEmbeddedLabel(parentGfx, element, align) {
|
13792 | var semantic = getSemantic(element);
|
13793 |
|
13794 | return renderLabel(parentGfx, semantic.name, {
|
13795 | box: element,
|
13796 | align: align,
|
13797 | padding: 5,
|
13798 | style: {
|
13799 | fill: getStrokeColor(element, defaultStrokeColor)
|
13800 | }
|
13801 | });
|
13802 | }
|
13803 |
|
13804 | function renderExternalLabel(parentGfx, element) {
|
13805 | var semantic = getSemantic(element);
|
13806 | var box = {
|
13807 | width: 90,
|
13808 | height: 30,
|
13809 | x: element.width / 2 + element.x,
|
13810 | y: element.height / 2 + element.y
|
13811 | };
|
13812 |
|
13813 | return renderLabel(parentGfx, semantic.name, {
|
13814 | box: box,
|
13815 | fitBox: true,
|
13816 | style: assign(
|
13817 | {},
|
13818 | textRenderer.getExternalStyle(),
|
13819 | {
|
13820 | fill: getStrokeColor(element, defaultStrokeColor)
|
13821 | }
|
13822 | )
|
13823 | });
|
13824 | }
|
13825 |
|
13826 | function renderLaneLabel(parentGfx, text, element) {
|
13827 | var textBox = renderLabel(parentGfx, text, {
|
13828 | box: {
|
13829 | height: 30,
|
13830 | width: element.height
|
13831 | },
|
13832 | align: 'center-middle',
|
13833 | style: {
|
13834 | fill: getStrokeColor(element, defaultStrokeColor)
|
13835 | }
|
13836 | });
|
13837 |
|
13838 | var top = -1 * element.height;
|
13839 |
|
13840 | transform$1(textBox, 0, -top, 270);
|
13841 | }
|
13842 |
|
13843 | function createPathFromConnection(connection) {
|
13844 | var waypoints = connection.waypoints;
|
13845 |
|
13846 | var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
|
13847 | for (var i = 1; i < waypoints.length; i++) {
|
13848 | pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
|
13849 | }
|
13850 | return pathData;
|
13851 | }
|
13852 |
|
13853 | var handlers = this.handlers = {
|
13854 | 'bpmn:Event': function(parentGfx, element, attrs) {
|
13855 |
|
13856 | if (!('fillOpacity' in attrs)) {
|
13857 | attrs.fillOpacity = DEFAULT_FILL_OPACITY;
|
13858 | }
|
13859 |
|
13860 | return drawCircle(parentGfx, element.width, element.height, attrs);
|
13861 | },
|
13862 | 'bpmn:StartEvent': function(parentGfx, element) {
|
13863 | var attrs = {
|
13864 | fill: getFillColor(element, defaultFillColor),
|
13865 | stroke: getStrokeColor(element, defaultStrokeColor)
|
13866 | };
|
13867 |
|
13868 | var semantic = getSemantic(element);
|
13869 |
|
13870 | if (!semantic.isInterrupting) {
|
13871 | attrs = {
|
13872 | strokeDasharray: '6',
|
13873 | strokeLinecap: 'round',
|
13874 | fill: getFillColor(element, defaultFillColor),
|
13875 | stroke: getStrokeColor(element, defaultStrokeColor)
|
13876 | };
|
13877 | }
|
13878 |
|
13879 | var circle = renderer('bpmn:Event')(parentGfx, element, attrs);
|
13880 |
|
13881 | renderEventContent(element, parentGfx);
|
13882 |
|
13883 | return circle;
|
13884 | },
|
13885 | 'bpmn:MessageEventDefinition': function(parentGfx, element, isThrowing) {
|
13886 | var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
|
13887 | xScaleFactor: 0.9,
|
13888 | yScaleFactor: 0.9,
|
13889 | containerWidth: element.width,
|
13890 | containerHeight: element.height,
|
13891 | position: {
|
13892 | mx: 0.235,
|
13893 | my: 0.315
|
13894 | }
|
13895 | });
|
13896 |
|
13897 | var fill = isThrowing ? getStrokeColor(element, defaultStrokeColor) : getFillColor(element, defaultFillColor);
|
13898 | var stroke = isThrowing ? getFillColor(element, defaultFillColor) : getStrokeColor(element, defaultStrokeColor);
|
13899 |
|
13900 | var messagePath = drawPath(parentGfx, pathData, {
|
13901 | strokeWidth: 1,
|
13902 | fill: fill,
|
13903 | stroke: stroke
|
13904 | });
|
13905 |
|
13906 | return messagePath;
|
13907 | },
|
13908 | 'bpmn:TimerEventDefinition': function(parentGfx, element) {
|
13909 | var circle = drawCircle(parentGfx, element.width, element.height, 0.2 * element.height, {
|
13910 | strokeWidth: 2,
|
13911 | fill: getFillColor(element, defaultFillColor),
|
13912 | stroke: getStrokeColor(element, defaultStrokeColor)
|
13913 | });
|
13914 |
|
13915 | var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
|
13916 | xScaleFactor: 0.75,
|
13917 | yScaleFactor: 0.75,
|
13918 | containerWidth: element.width,
|
13919 | containerHeight: element.height,
|
13920 | position: {
|
13921 | mx: 0.5,
|
13922 | my: 0.5
|
13923 | }
|
13924 | });
|
13925 |
|
13926 | drawPath(parentGfx, pathData, {
|
13927 | strokeWidth: 2,
|
13928 | strokeLinecap: 'square',
|
13929 | stroke: getStrokeColor(element, defaultStrokeColor)
|
13930 | });
|
13931 |
|
13932 | for (var i = 0;i < 12; i++) {
|
13933 |
|
13934 | var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
|
13935 | xScaleFactor: 0.75,
|
13936 | yScaleFactor: 0.75,
|
13937 | containerWidth: element.width,
|
13938 | containerHeight: element.height,
|
13939 | position: {
|
13940 | mx: 0.5,
|
13941 | my: 0.5
|
13942 | }
|
13943 | });
|
13944 |
|
13945 | var width = element.width / 2;
|
13946 | var height = element.height / 2;
|
13947 |
|
13948 | drawPath(parentGfx, linePathData, {
|
13949 | strokeWidth: 1,
|
13950 | strokeLinecap: 'square',
|
13951 | transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')',
|
13952 | stroke: getStrokeColor(element, defaultStrokeColor)
|
13953 | });
|
13954 | }
|
13955 |
|
13956 | return circle;
|
13957 | },
|
13958 | 'bpmn:EscalationEventDefinition': function(parentGfx, event, isThrowing) {
|
13959 | var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
|
13960 | xScaleFactor: 1,
|
13961 | yScaleFactor: 1,
|
13962 | containerWidth: event.width,
|
13963 | containerHeight: event.height,
|
13964 | position: {
|
13965 | mx: 0.5,
|
13966 | my: 0.2
|
13967 | }
|
13968 | });
|
13969 |
|
13970 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
13971 |
|
13972 | return drawPath(parentGfx, pathData, {
|
13973 | strokeWidth: 1,
|
13974 | fill: fill,
|
13975 | stroke: getStrokeColor(event, defaultStrokeColor)
|
13976 | });
|
13977 | },
|
13978 | 'bpmn:ConditionalEventDefinition': function(parentGfx, event) {
|
13979 | var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
|
13980 | xScaleFactor: 1,
|
13981 | yScaleFactor: 1,
|
13982 | containerWidth: event.width,
|
13983 | containerHeight: event.height,
|
13984 | position: {
|
13985 | mx: 0.5,
|
13986 | my: 0.222
|
13987 | }
|
13988 | });
|
13989 |
|
13990 | return drawPath(parentGfx, pathData, {
|
13991 | strokeWidth: 1,
|
13992 | stroke: getStrokeColor(event, defaultStrokeColor)
|
13993 | });
|
13994 | },
|
13995 | 'bpmn:LinkEventDefinition': function(parentGfx, event, isThrowing) {
|
13996 | var pathData = pathMap.getScaledPath('EVENT_LINK', {
|
13997 | xScaleFactor: 1,
|
13998 | yScaleFactor: 1,
|
13999 | containerWidth: event.width,
|
14000 | containerHeight: event.height,
|
14001 | position: {
|
14002 | mx: 0.57,
|
14003 | my: 0.263
|
14004 | }
|
14005 | });
|
14006 |
|
14007 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
14008 |
|
14009 | return drawPath(parentGfx, pathData, {
|
14010 | strokeWidth: 1,
|
14011 | fill: fill,
|
14012 | stroke: getStrokeColor(event, defaultStrokeColor)
|
14013 | });
|
14014 | },
|
14015 | 'bpmn:ErrorEventDefinition': function(parentGfx, event, isThrowing) {
|
14016 | var pathData = pathMap.getScaledPath('EVENT_ERROR', {
|
14017 | xScaleFactor: 1.1,
|
14018 | yScaleFactor: 1.1,
|
14019 | containerWidth: event.width,
|
14020 | containerHeight: event.height,
|
14021 | position: {
|
14022 | mx: 0.2,
|
14023 | my: 0.722
|
14024 | }
|
14025 | });
|
14026 |
|
14027 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
14028 |
|
14029 | return drawPath(parentGfx, pathData, {
|
14030 | strokeWidth: 1,
|
14031 | fill: fill,
|
14032 | stroke: getStrokeColor(event, defaultStrokeColor)
|
14033 | });
|
14034 | },
|
14035 | 'bpmn:CancelEventDefinition': function(parentGfx, event, isThrowing) {
|
14036 | var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
|
14037 | xScaleFactor: 1.0,
|
14038 | yScaleFactor: 1.0,
|
14039 | containerWidth: event.width,
|
14040 | containerHeight: event.height,
|
14041 | position: {
|
14042 | mx: 0.638,
|
14043 | my: -0.055
|
14044 | }
|
14045 | });
|
14046 |
|
14047 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
14048 |
|
14049 | var path = drawPath(parentGfx, pathData, {
|
14050 | strokeWidth: 1,
|
14051 | fill: fill,
|
14052 | stroke: getStrokeColor(event, defaultStrokeColor)
|
14053 | });
|
14054 |
|
14055 | rotate(path, 45);
|
14056 |
|
14057 | return path;
|
14058 | },
|
14059 | 'bpmn:CompensateEventDefinition': function(parentGfx, event, isThrowing) {
|
14060 | var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
|
14061 | xScaleFactor: 1,
|
14062 | yScaleFactor: 1,
|
14063 | containerWidth: event.width,
|
14064 | containerHeight: event.height,
|
14065 | position: {
|
14066 | mx: 0.22,
|
14067 | my: 0.5
|
14068 | }
|
14069 | });
|
14070 |
|
14071 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
14072 |
|
14073 | return drawPath(parentGfx, pathData, {
|
14074 | strokeWidth: 1,
|
14075 | fill: fill,
|
14076 | stroke: getStrokeColor(event, defaultStrokeColor)
|
14077 | });
|
14078 | },
|
14079 | 'bpmn:SignalEventDefinition': function(parentGfx, event, isThrowing) {
|
14080 | var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
|
14081 | xScaleFactor: 0.9,
|
14082 | yScaleFactor: 0.9,
|
14083 | containerWidth: event.width,
|
14084 | containerHeight: event.height,
|
14085 | position: {
|
14086 | mx: 0.5,
|
14087 | my: 0.2
|
14088 | }
|
14089 | });
|
14090 |
|
14091 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
14092 |
|
14093 | return drawPath(parentGfx, pathData, {
|
14094 | strokeWidth: 1,
|
14095 | fill: fill,
|
14096 | stroke: getStrokeColor(event, defaultStrokeColor)
|
14097 | });
|
14098 | },
|
14099 | 'bpmn:MultipleEventDefinition': function(parentGfx, event, isThrowing) {
|
14100 | var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
|
14101 | xScaleFactor: 1.1,
|
14102 | yScaleFactor: 1.1,
|
14103 | containerWidth: event.width,
|
14104 | containerHeight: event.height,
|
14105 | position: {
|
14106 | mx: 0.222,
|
14107 | my: 0.36
|
14108 | }
|
14109 | });
|
14110 |
|
14111 | var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor) : 'none';
|
14112 |
|
14113 | return drawPath(parentGfx, pathData, {
|
14114 | strokeWidth: 1,
|
14115 | fill: fill
|
14116 | });
|
14117 | },
|
14118 | 'bpmn:ParallelMultipleEventDefinition': function(parentGfx, event) {
|
14119 | var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
|
14120 | xScaleFactor: 1.2,
|
14121 | yScaleFactor: 1.2,
|
14122 | containerWidth: event.width,
|
14123 | containerHeight: event.height,
|
14124 | position: {
|
14125 | mx: 0.458,
|
14126 | my: 0.194
|
14127 | }
|
14128 | });
|
14129 |
|
14130 | return drawPath(parentGfx, pathData, {
|
14131 | strokeWidth: 1,
|
14132 | fill: getStrokeColor(event, defaultStrokeColor),
|
14133 | stroke: getStrokeColor(event, defaultStrokeColor)
|
14134 | });
|
14135 | },
|
14136 | 'bpmn:EndEvent': function(parentGfx, element) {
|
14137 | var circle = renderer('bpmn:Event')(parentGfx, element, {
|
14138 | strokeWidth: 4,
|
14139 | fill: getFillColor(element, defaultFillColor),
|
14140 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14141 | });
|
14142 |
|
14143 | renderEventContent(element, parentGfx, true);
|
14144 |
|
14145 | return circle;
|
14146 | },
|
14147 | 'bpmn:TerminateEventDefinition': function(parentGfx, element) {
|
14148 | var circle = drawCircle(parentGfx, element.width, element.height, 8, {
|
14149 | strokeWidth: 4,
|
14150 | fill: getStrokeColor(element, defaultStrokeColor),
|
14151 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14152 | });
|
14153 |
|
14154 | return circle;
|
14155 | },
|
14156 | 'bpmn:IntermediateEvent': function(parentGfx, element) {
|
14157 | var outer = renderer('bpmn:Event')(parentGfx, element, {
|
14158 | strokeWidth: 1,
|
14159 | fill: getFillColor(element, defaultFillColor),
|
14160 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14161 | });
|
14162 |
|
14163 |
|
14164 | drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
|
14165 | strokeWidth: 1,
|
14166 | fill: getFillColor(element, 'none'),
|
14167 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14168 | });
|
14169 |
|
14170 | renderEventContent(element, parentGfx);
|
14171 |
|
14172 | return outer;
|
14173 | },
|
14174 | 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
|
14175 | 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
|
14176 |
|
14177 | 'bpmn:Activity': function(parentGfx, element, attrs) {
|
14178 |
|
14179 | attrs = attrs || {};
|
14180 |
|
14181 | if (!('fillOpacity' in attrs)) {
|
14182 | attrs.fillOpacity = DEFAULT_FILL_OPACITY;
|
14183 | }
|
14184 |
|
14185 | return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, attrs);
|
14186 | },
|
14187 |
|
14188 | 'bpmn:Task': function(parentGfx, element) {
|
14189 | var attrs = {
|
14190 | fill: getFillColor(element, defaultFillColor),
|
14191 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14192 | };
|
14193 |
|
14194 | var rect = renderer('bpmn:Activity')(parentGfx, element, attrs);
|
14195 |
|
14196 | renderEmbeddedLabel(parentGfx, element, 'center-middle');
|
14197 | attachTaskMarkers(parentGfx, element);
|
14198 |
|
14199 | return rect;
|
14200 | },
|
14201 | 'bpmn:ServiceTask': function(parentGfx, element) {
|
14202 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14203 |
|
14204 | var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
|
14205 | abspos: {
|
14206 | x: 12,
|
14207 | y: 18
|
14208 | }
|
14209 | });
|
14210 |
|
14211 | drawPath(parentGfx, pathDataBG, {
|
14212 | strokeWidth: 1,
|
14213 | fill: getFillColor(element, defaultFillColor),
|
14214 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14215 | });
|
14216 |
|
14217 | var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
|
14218 | abspos: {
|
14219 | x: 17.2,
|
14220 | y: 18
|
14221 | }
|
14222 | });
|
14223 |
|
14224 | drawPath(parentGfx, fillPathData, {
|
14225 | strokeWidth: 0,
|
14226 | fill: getFillColor(element, defaultFillColor)
|
14227 | });
|
14228 |
|
14229 | var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
|
14230 | abspos: {
|
14231 | x: 17,
|
14232 | y: 22
|
14233 | }
|
14234 | });
|
14235 |
|
14236 | drawPath(parentGfx, pathData, {
|
14237 | strokeWidth: 1,
|
14238 | fill: getFillColor(element, defaultFillColor),
|
14239 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14240 | });
|
14241 |
|
14242 | return task;
|
14243 | },
|
14244 | 'bpmn:UserTask': function(parentGfx, element) {
|
14245 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14246 |
|
14247 | var x = 15;
|
14248 | var y = 12;
|
14249 |
|
14250 | var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
|
14251 | abspos: {
|
14252 | x: x,
|
14253 | y: y
|
14254 | }
|
14255 | });
|
14256 |
|
14257 | drawPath(parentGfx, pathData, {
|
14258 | strokeWidth: 0.5,
|
14259 | fill: getFillColor(element, defaultFillColor),
|
14260 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14261 | });
|
14262 |
|
14263 | var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
|
14264 | abspos: {
|
14265 | x: x,
|
14266 | y: y
|
14267 | }
|
14268 | });
|
14269 |
|
14270 | drawPath(parentGfx, pathData2, {
|
14271 | strokeWidth: 0.5,
|
14272 | fill: getFillColor(element, defaultFillColor),
|
14273 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14274 | });
|
14275 |
|
14276 | var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
|
14277 | abspos: {
|
14278 | x: x,
|
14279 | y: y
|
14280 | }
|
14281 | });
|
14282 |
|
14283 | drawPath(parentGfx, pathData3, {
|
14284 | strokeWidth: 0.5,
|
14285 | fill: getStrokeColor(element, defaultStrokeColor),
|
14286 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14287 | });
|
14288 |
|
14289 | return task;
|
14290 | },
|
14291 | 'bpmn:ManualTask': function(parentGfx, element) {
|
14292 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14293 |
|
14294 | var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
|
14295 | abspos: {
|
14296 | x: 17,
|
14297 | y: 15
|
14298 | }
|
14299 | });
|
14300 |
|
14301 | drawPath(parentGfx, pathData, {
|
14302 | strokeWidth: 0.5,
|
14303 | fill: getFillColor(element, defaultFillColor),
|
14304 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14305 | });
|
14306 |
|
14307 | return task;
|
14308 | },
|
14309 | 'bpmn:SendTask': function(parentGfx, element) {
|
14310 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14311 |
|
14312 | var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
|
14313 | xScaleFactor: 1,
|
14314 | yScaleFactor: 1,
|
14315 | containerWidth: 21,
|
14316 | containerHeight: 14,
|
14317 | position: {
|
14318 | mx: 0.285,
|
14319 | my: 0.357
|
14320 | }
|
14321 | });
|
14322 |
|
14323 | drawPath(parentGfx, pathData, {
|
14324 | strokeWidth: 1,
|
14325 | fill: getStrokeColor(element, defaultStrokeColor),
|
14326 | stroke: getFillColor(element, defaultFillColor)
|
14327 | });
|
14328 |
|
14329 | return task;
|
14330 | },
|
14331 | 'bpmn:ReceiveTask' : function(parentGfx, element) {
|
14332 | var semantic = getSemantic(element);
|
14333 |
|
14334 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14335 | var pathData;
|
14336 |
|
14337 | if (semantic.instantiate) {
|
14338 | drawCircle(parentGfx, 28, 28, 20 * 0.22, { strokeWidth: 1 });
|
14339 |
|
14340 | pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
|
14341 | abspos: {
|
14342 | x: 7.77,
|
14343 | y: 9.52
|
14344 | }
|
14345 | });
|
14346 | } else {
|
14347 |
|
14348 | pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
|
14349 | xScaleFactor: 0.9,
|
14350 | yScaleFactor: 0.9,
|
14351 | containerWidth: 21,
|
14352 | containerHeight: 14,
|
14353 | position: {
|
14354 | mx: 0.3,
|
14355 | my: 0.4
|
14356 | }
|
14357 | });
|
14358 | }
|
14359 |
|
14360 | drawPath(parentGfx, pathData, {
|
14361 | strokeWidth: 1,
|
14362 | fill: getFillColor(element, defaultFillColor),
|
14363 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14364 | });
|
14365 |
|
14366 | return task;
|
14367 | },
|
14368 | 'bpmn:ScriptTask': function(parentGfx, element) {
|
14369 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14370 |
|
14371 | var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
|
14372 | abspos: {
|
14373 | x: 15,
|
14374 | y: 20
|
14375 | }
|
14376 | });
|
14377 |
|
14378 | drawPath(parentGfx, pathData, {
|
14379 | strokeWidth: 1,
|
14380 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14381 | });
|
14382 |
|
14383 | return task;
|
14384 | },
|
14385 | 'bpmn:BusinessRuleTask': function(parentGfx, element) {
|
14386 | var task = renderer('bpmn:Task')(parentGfx, element);
|
14387 |
|
14388 | var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
|
14389 | abspos: {
|
14390 | x: 8,
|
14391 | y: 8
|
14392 | }
|
14393 | });
|
14394 |
|
14395 | var businessHeaderPath = drawPath(parentGfx, headerPathData);
|
14396 | attr$1(businessHeaderPath, {
|
14397 | strokeWidth: 1,
|
14398 | fill: getFillColor(element, '#aaaaaa'),
|
14399 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14400 | });
|
14401 |
|
14402 | var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
|
14403 | abspos: {
|
14404 | x: 8,
|
14405 | y: 8
|
14406 | }
|
14407 | });
|
14408 |
|
14409 | var businessPath = drawPath(parentGfx, headerData);
|
14410 | attr$1(businessPath, {
|
14411 | strokeWidth: 1,
|
14412 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14413 | });
|
14414 |
|
14415 | return task;
|
14416 | },
|
14417 | 'bpmn:SubProcess': function(parentGfx, element, attrs) {
|
14418 | attrs = assign({
|
14419 | fill: getFillColor(element, defaultFillColor),
|
14420 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14421 | }, attrs);
|
14422 |
|
14423 | var rect = renderer('bpmn:Activity')(parentGfx, element, attrs);
|
14424 |
|
14425 | var expanded = isExpanded(element);
|
14426 |
|
14427 | if (isEventSubProcess(element)) {
|
14428 | attr$1(rect, {
|
14429 | strokeDasharray: '1,2'
|
14430 | });
|
14431 | }
|
14432 |
|
14433 | renderEmbeddedLabel(parentGfx, element, expanded ? 'center-top' : 'center-middle');
|
14434 |
|
14435 | if (expanded) {
|
14436 | attachTaskMarkers(parentGfx, element);
|
14437 | } else {
|
14438 | attachTaskMarkers(parentGfx, element, ['SubProcessMarker']);
|
14439 | }
|
14440 |
|
14441 | return rect;
|
14442 | },
|
14443 | 'bpmn:AdHocSubProcess': function(parentGfx, element) {
|
14444 | return renderer('bpmn:SubProcess')(parentGfx, element);
|
14445 | },
|
14446 | 'bpmn:Transaction': function(parentGfx, element) {
|
14447 | var outer = renderer('bpmn:SubProcess')(parentGfx, element);
|
14448 |
|
14449 | var innerAttrs = styles.style([ 'no-fill', 'no-events' ], {
|
14450 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14451 | });
|
14452 |
|
14453 | drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
|
14454 |
|
14455 | return outer;
|
14456 | },
|
14457 | 'bpmn:CallActivity': function(parentGfx, element) {
|
14458 | return renderer('bpmn:SubProcess')(parentGfx, element, {
|
14459 | strokeWidth: 5
|
14460 | });
|
14461 | },
|
14462 | 'bpmn:Participant': function(parentGfx, element) {
|
14463 |
|
14464 | var attrs = {
|
14465 | fillOpacity: DEFAULT_FILL_OPACITY,
|
14466 | fill: getFillColor(element, defaultFillColor),
|
14467 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14468 | };
|
14469 |
|
14470 | var lane = renderer('bpmn:Lane')(parentGfx, element, attrs);
|
14471 |
|
14472 | var expandedPool = isExpanded(element);
|
14473 |
|
14474 | if (expandedPool) {
|
14475 | drawLine(parentGfx, [
|
14476 | { x: 30, y: 0 },
|
14477 | { x: 30, y: element.height }
|
14478 | ], {
|
14479 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14480 | });
|
14481 | var text = getSemantic(element).name;
|
14482 | renderLaneLabel(parentGfx, text, element);
|
14483 | } else {
|
14484 |
|
14485 | var text2 = getSemantic(element).name;
|
14486 | renderLabel(parentGfx, text2, {
|
14487 | box: element, align: 'center-middle',
|
14488 | style: {
|
14489 | fill: getStrokeColor(element, defaultStrokeColor)
|
14490 | }
|
14491 | });
|
14492 | }
|
14493 |
|
14494 | var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
|
14495 |
|
14496 | if (participantMultiplicity) {
|
14497 | renderer('ParticipantMultiplicityMarker')(parentGfx, element);
|
14498 | }
|
14499 |
|
14500 | return lane;
|
14501 | },
|
14502 | 'bpmn:Lane': function(parentGfx, element, attrs) {
|
14503 | var rect = drawRect(parentGfx, element.width, element.height, 0, assign({
|
14504 | fill: getFillColor(element, defaultFillColor),
|
14505 | fillOpacity: HIGH_FILL_OPACITY,
|
14506 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14507 | }, attrs));
|
14508 |
|
14509 | var semantic = getSemantic(element);
|
14510 |
|
14511 | if (semantic.$type === 'bpmn:Lane') {
|
14512 | var text = semantic.name;
|
14513 | renderLaneLabel(parentGfx, text, element);
|
14514 | }
|
14515 |
|
14516 | return rect;
|
14517 | },
|
14518 | 'bpmn:InclusiveGateway': function(parentGfx, element) {
|
14519 | var diamond = renderer('bpmn:Gateway')(parentGfx, element);
|
14520 |
|
14521 |
|
14522 | drawCircle(parentGfx, element.width, element.height, element.height * 0.24, {
|
14523 | strokeWidth: 2.5,
|
14524 | fill: getFillColor(element, defaultFillColor),
|
14525 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14526 | });
|
14527 |
|
14528 | return diamond;
|
14529 | },
|
14530 | 'bpmn:ExclusiveGateway': function(parentGfx, element) {
|
14531 | var diamond = renderer('bpmn:Gateway')(parentGfx, element);
|
14532 |
|
14533 | var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
|
14534 | xScaleFactor: 0.4,
|
14535 | yScaleFactor: 0.4,
|
14536 | containerWidth: element.width,
|
14537 | containerHeight: element.height,
|
14538 | position: {
|
14539 | mx: 0.32,
|
14540 | my: 0.3
|
14541 | }
|
14542 | });
|
14543 |
|
14544 | if ((getDi(element).isMarkerVisible)) {
|
14545 | drawPath(parentGfx, pathData, {
|
14546 | strokeWidth: 1,
|
14547 | fill: getStrokeColor(element, defaultStrokeColor),
|
14548 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14549 | });
|
14550 | }
|
14551 |
|
14552 | return diamond;
|
14553 | },
|
14554 | 'bpmn:ComplexGateway': function(parentGfx, element) {
|
14555 | var diamond = renderer('bpmn:Gateway')(parentGfx, element);
|
14556 |
|
14557 | var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
|
14558 | xScaleFactor: 0.5,
|
14559 | yScaleFactor:0.5,
|
14560 | containerWidth: element.width,
|
14561 | containerHeight: element.height,
|
14562 | position: {
|
14563 | mx: 0.46,
|
14564 | my: 0.26
|
14565 | }
|
14566 | });
|
14567 |
|
14568 | drawPath(parentGfx, pathData, {
|
14569 | strokeWidth: 1,
|
14570 | fill: getStrokeColor(element, defaultStrokeColor),
|
14571 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14572 | });
|
14573 |
|
14574 | return diamond;
|
14575 | },
|
14576 | 'bpmn:ParallelGateway': function(parentGfx, element) {
|
14577 | var diamond = renderer('bpmn:Gateway')(parentGfx, element);
|
14578 |
|
14579 | var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
|
14580 | xScaleFactor: 0.6,
|
14581 | yScaleFactor:0.6,
|
14582 | containerWidth: element.width,
|
14583 | containerHeight: element.height,
|
14584 | position: {
|
14585 | mx: 0.46,
|
14586 | my: 0.2
|
14587 | }
|
14588 | });
|
14589 |
|
14590 | drawPath(parentGfx, pathData, {
|
14591 | strokeWidth: 1,
|
14592 | fill: getStrokeColor(element, defaultStrokeColor),
|
14593 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14594 | });
|
14595 |
|
14596 | return diamond;
|
14597 | },
|
14598 | 'bpmn:EventBasedGateway': function(parentGfx, element) {
|
14599 |
|
14600 | var semantic = getSemantic(element);
|
14601 |
|
14602 | var diamond = renderer('bpmn:Gateway')(parentGfx, element);
|
14603 |
|
14604 | drawCircle(parentGfx, element.width, element.height, element.height * 0.20, {
|
14605 | strokeWidth: 1,
|
14606 | fill: 'none',
|
14607 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14608 | });
|
14609 |
|
14610 | var type = semantic.eventGatewayType;
|
14611 | var instantiate = !!semantic.instantiate;
|
14612 |
|
14613 | function drawEvent() {
|
14614 |
|
14615 | var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
|
14616 | xScaleFactor: 0.18,
|
14617 | yScaleFactor: 0.18,
|
14618 | containerWidth: element.width,
|
14619 | containerHeight: element.height,
|
14620 | position: {
|
14621 | mx: 0.36,
|
14622 | my: 0.44
|
14623 | }
|
14624 | });
|
14625 |
|
14626 | var attrs = {
|
14627 | strokeWidth: 2,
|
14628 | fill: getFillColor(element, 'none'),
|
14629 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14630 | };
|
14631 |
|
14632 | drawPath(parentGfx, pathData, attrs);
|
14633 | }
|
14634 |
|
14635 | if (type === 'Parallel') {
|
14636 |
|
14637 | var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
|
14638 | xScaleFactor: 0.4,
|
14639 | yScaleFactor:0.4,
|
14640 | containerWidth: element.width,
|
14641 | containerHeight: element.height,
|
14642 | position: {
|
14643 | mx: 0.474,
|
14644 | my: 0.296
|
14645 | }
|
14646 | });
|
14647 |
|
14648 | var parallelPath = drawPath(parentGfx, pathData);
|
14649 | attr$1(parallelPath, {
|
14650 | strokeWidth: 1,
|
14651 | fill: 'none'
|
14652 | });
|
14653 | } else if (type === 'Exclusive') {
|
14654 |
|
14655 | if (!instantiate) {
|
14656 | var innerCircle = drawCircle(parentGfx, element.width, element.height, element.height * 0.26);
|
14657 | attr$1(innerCircle, {
|
14658 | strokeWidth: 1,
|
14659 | fill: 'none',
|
14660 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14661 | });
|
14662 | }
|
14663 |
|
14664 | drawEvent();
|
14665 | }
|
14666 |
|
14667 |
|
14668 | return diamond;
|
14669 | },
|
14670 | 'bpmn:Gateway': function(parentGfx, element) {
|
14671 | var attrs = {
|
14672 | fill: getFillColor(element, defaultFillColor),
|
14673 | fillOpacity: DEFAULT_FILL_OPACITY,
|
14674 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14675 | };
|
14676 |
|
14677 | return drawDiamond(parentGfx, element.width, element.height, attrs);
|
14678 | },
|
14679 | 'bpmn:SequenceFlow': function(parentGfx, element) {
|
14680 | var pathData = createPathFromConnection(element);
|
14681 |
|
14682 | var fill = getFillColor(element, defaultFillColor),
|
14683 | stroke = getStrokeColor(element, defaultStrokeColor);
|
14684 |
|
14685 | var attrs = {
|
14686 | strokeLinejoin: 'round',
|
14687 | markerEnd: marker('sequenceflow-end', fill, stroke),
|
14688 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14689 | };
|
14690 |
|
14691 | var path = drawPath(parentGfx, pathData, attrs);
|
14692 |
|
14693 | var sequenceFlow = getSemantic(element);
|
14694 |
|
14695 | var source;
|
14696 |
|
14697 | if (element.source) {
|
14698 | source = element.source.businessObject;
|
14699 |
|
14700 |
|
14701 | if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) {
|
14702 | attr$1(path, {
|
14703 | markerStart: marker('conditional-flow-marker', fill, stroke)
|
14704 | });
|
14705 | }
|
14706 |
|
14707 |
|
14708 | if (source.default && (source.$instanceOf('bpmn:Gateway') || source.$instanceOf('bpmn:Activity')) &&
|
14709 | source.default === sequenceFlow) {
|
14710 | attr$1(path, {
|
14711 | markerStart: marker('conditional-default-flow-marker', fill, stroke)
|
14712 | });
|
14713 | }
|
14714 | }
|
14715 |
|
14716 | return path;
|
14717 | },
|
14718 | 'bpmn:Association': function(parentGfx, element, attrs) {
|
14719 |
|
14720 | var semantic = getSemantic(element);
|
14721 |
|
14722 | var fill = getFillColor(element, defaultFillColor),
|
14723 | stroke = getStrokeColor(element, defaultStrokeColor);
|
14724 |
|
14725 | attrs = assign({
|
14726 | strokeDasharray: '0.5, 5',
|
14727 | strokeLinecap: 'round',
|
14728 | strokeLinejoin: 'round',
|
14729 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14730 | }, attrs || {});
|
14731 |
|
14732 | if (semantic.associationDirection === 'One' ||
|
14733 | semantic.associationDirection === 'Both') {
|
14734 | attrs.markerEnd = marker('association-end', fill, stroke);
|
14735 | }
|
14736 |
|
14737 | if (semantic.associationDirection === 'Both') {
|
14738 | attrs.markerStart = marker('association-start', fill, stroke);
|
14739 | }
|
14740 |
|
14741 | return drawLine(parentGfx, element.waypoints, attrs);
|
14742 | },
|
14743 | 'bpmn:DataInputAssociation': function(parentGfx, element) {
|
14744 | var fill = getFillColor(element, defaultFillColor),
|
14745 | stroke = getStrokeColor(element, defaultStrokeColor);
|
14746 |
|
14747 | return renderer('bpmn:Association')(parentGfx, element, {
|
14748 | markerEnd: marker('association-end', fill, stroke)
|
14749 | });
|
14750 | },
|
14751 | 'bpmn:DataOutputAssociation': function(parentGfx, element) {
|
14752 | var fill = getFillColor(element, defaultFillColor),
|
14753 | stroke = getStrokeColor(element, defaultStrokeColor);
|
14754 |
|
14755 | return renderer('bpmn:Association')(parentGfx, element, {
|
14756 | markerEnd: marker('association-end', fill, stroke)
|
14757 | });
|
14758 | },
|
14759 | 'bpmn:MessageFlow': function(parentGfx, element) {
|
14760 |
|
14761 | var semantic = getSemantic(element),
|
14762 | di = getDi(element);
|
14763 |
|
14764 | var fill = getFillColor(element, defaultFillColor),
|
14765 | stroke = getStrokeColor(element, defaultStrokeColor);
|
14766 |
|
14767 | var pathData = createPathFromConnection(element);
|
14768 |
|
14769 | var attrs = {
|
14770 | markerEnd: marker('messageflow-end', fill, stroke),
|
14771 | markerStart: marker('messageflow-start', fill, stroke),
|
14772 | strokeDasharray: '10, 12',
|
14773 | strokeLinecap: 'round',
|
14774 | strokeLinejoin: 'round',
|
14775 | strokeWidth: '1.5px',
|
14776 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14777 | };
|
14778 |
|
14779 | var path = drawPath(parentGfx, pathData, attrs);
|
14780 |
|
14781 | if (semantic.messageRef) {
|
14782 | var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
|
14783 |
|
14784 | var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
|
14785 | abspos: {
|
14786 | x: midPoint.x,
|
14787 | y: midPoint.y
|
14788 | }
|
14789 | });
|
14790 |
|
14791 | var messageAttrs = { strokeWidth: 1 };
|
14792 |
|
14793 | if (di.messageVisibleKind === 'initiating') {
|
14794 | messageAttrs.fill = 'white';
|
14795 | messageAttrs.stroke = 'black';
|
14796 | } else {
|
14797 | messageAttrs.fill = '#888';
|
14798 | messageAttrs.stroke = 'white';
|
14799 | }
|
14800 |
|
14801 | drawPath(parentGfx, markerPathData, messageAttrs);
|
14802 | }
|
14803 |
|
14804 | return path;
|
14805 | },
|
14806 | 'bpmn:DataObject': function(parentGfx, element) {
|
14807 | var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
|
14808 | xScaleFactor: 1,
|
14809 | yScaleFactor: 1,
|
14810 | containerWidth: element.width,
|
14811 | containerHeight: element.height,
|
14812 | position: {
|
14813 | mx: 0.474,
|
14814 | my: 0.296
|
14815 | }
|
14816 | });
|
14817 |
|
14818 | var elementObject = drawPath(parentGfx, pathData, {
|
14819 | fill: getFillColor(element, defaultFillColor),
|
14820 | fillOpacity: DEFAULT_FILL_OPACITY,
|
14821 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14822 | });
|
14823 |
|
14824 | var semantic = getSemantic(element);
|
14825 |
|
14826 | if (isCollection(semantic)) {
|
14827 | renderDataItemCollection(parentGfx, element);
|
14828 | }
|
14829 |
|
14830 | return elementObject;
|
14831 | },
|
14832 | 'bpmn:DataObjectReference': as('bpmn:DataObject'),
|
14833 | 'bpmn:DataInput': function(parentGfx, element) {
|
14834 |
|
14835 | var arrowPathData = pathMap.getRawPath('DATA_ARROW');
|
14836 |
|
14837 |
|
14838 | var elementObject = renderer('bpmn:DataObject')(parentGfx, element);
|
14839 |
|
14840 | drawPath(parentGfx, arrowPathData, { strokeWidth: 1 });
|
14841 |
|
14842 | return elementObject;
|
14843 | },
|
14844 | 'bpmn:DataOutput': function(parentGfx, element) {
|
14845 | var arrowPathData = pathMap.getRawPath('DATA_ARROW');
|
14846 |
|
14847 |
|
14848 | var elementObject = renderer('bpmn:DataObject')(parentGfx, element);
|
14849 |
|
14850 | drawPath(parentGfx, arrowPathData, {
|
14851 | strokeWidth: 1,
|
14852 | fill: 'black'
|
14853 | });
|
14854 |
|
14855 | return elementObject;
|
14856 | },
|
14857 | 'bpmn:DataStoreReference': function(parentGfx, element) {
|
14858 | var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
|
14859 | xScaleFactor: 1,
|
14860 | yScaleFactor: 1,
|
14861 | containerWidth: element.width,
|
14862 | containerHeight: element.height,
|
14863 | position: {
|
14864 | mx: 0,
|
14865 | my: 0.133
|
14866 | }
|
14867 | });
|
14868 |
|
14869 | var elementStore = drawPath(parentGfx, DATA_STORE_PATH, {
|
14870 | strokeWidth: 2,
|
14871 | fill: getFillColor(element, defaultFillColor),
|
14872 | fillOpacity: DEFAULT_FILL_OPACITY,
|
14873 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14874 | });
|
14875 |
|
14876 | return elementStore;
|
14877 | },
|
14878 | 'bpmn:BoundaryEvent': function(parentGfx, element) {
|
14879 |
|
14880 | var semantic = getSemantic(element),
|
14881 | cancel = semantic.cancelActivity;
|
14882 |
|
14883 | var attrs = {
|
14884 | strokeWidth: 1,
|
14885 | fill: getFillColor(element, defaultFillColor),
|
14886 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14887 | };
|
14888 |
|
14889 | if (!cancel) {
|
14890 | attrs.strokeDasharray = '6';
|
14891 | attrs.strokeLinecap = 'round';
|
14892 | }
|
14893 |
|
14894 |
|
14895 | var outerAttrs = assign({}, attrs, {
|
14896 | fillOpacity: 1
|
14897 | });
|
14898 |
|
14899 |
|
14900 | var innerAttrs = assign({}, attrs, {
|
14901 | fill: 'none'
|
14902 | });
|
14903 |
|
14904 | var outer = renderer('bpmn:Event')(parentGfx, element, outerAttrs);
|
14905 |
|
14906 | drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, innerAttrs);
|
14907 |
|
14908 | renderEventContent(element, parentGfx);
|
14909 |
|
14910 | return outer;
|
14911 | },
|
14912 | 'bpmn:Group': function(parentGfx, element) {
|
14913 | var semantic = getSemantic(element),
|
14914 | di = getDi(element);
|
14915 |
|
14916 | var group = drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, {
|
14917 | strokeWidth: 1,
|
14918 | strokeDasharray: '8,3,1,3',
|
14919 | fill: 'none',
|
14920 | pointerEvents: 'none'
|
14921 | });
|
14922 |
|
14923 | var categoryValueRef = semantic.categoryValueRef || {};
|
14924 |
|
14925 | if (categoryValueRef.value) {
|
14926 | var box = di.label ? di.label.bounds : element;
|
14927 |
|
14928 | renderLabel(parentGfx, categoryValueRef.value, {
|
14929 | box: box,
|
14930 | style: {
|
14931 | fill: getStrokeColor(element, defaultStrokeColor)
|
14932 | }
|
14933 | });
|
14934 | }
|
14935 |
|
14936 | return group;
|
14937 | },
|
14938 | 'label': function(parentGfx, element) {
|
14939 | return renderExternalLabel(parentGfx, element);
|
14940 | },
|
14941 | 'bpmn:TextAnnotation': function(parentGfx, element) {
|
14942 | var style = {
|
14943 | 'fill': 'none',
|
14944 | 'stroke': 'none'
|
14945 | };
|
14946 |
|
14947 | var textElement = drawRect(parentGfx, element.width, element.height, 0, 0, style);
|
14948 |
|
14949 | var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
|
14950 | xScaleFactor: 1,
|
14951 | yScaleFactor: 1,
|
14952 | containerWidth: element.width,
|
14953 | containerHeight: element.height,
|
14954 | position: {
|
14955 | mx: 0.0,
|
14956 | my: 0.0
|
14957 | }
|
14958 | });
|
14959 |
|
14960 | drawPath(parentGfx, textPathData, {
|
14961 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14962 | });
|
14963 |
|
14964 | var text = getSemantic(element).text || '';
|
14965 | renderLabel(parentGfx, text, {
|
14966 | box: element,
|
14967 | align: 'left-top',
|
14968 | padding: 5,
|
14969 | style: {
|
14970 | fill: getStrokeColor(element, defaultStrokeColor)
|
14971 | }
|
14972 | });
|
14973 |
|
14974 | return textElement;
|
14975 | },
|
14976 | 'ParticipantMultiplicityMarker': function(parentGfx, element) {
|
14977 | var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
|
14978 | xScaleFactor: 1,
|
14979 | yScaleFactor: 1,
|
14980 | containerWidth: element.width,
|
14981 | containerHeight: element.height,
|
14982 | position: {
|
14983 | mx: ((element.width / 2) / element.width),
|
14984 | my: (element.height - 15) / element.height
|
14985 | }
|
14986 | });
|
14987 |
|
14988 | drawMarker('participant-multiplicity', parentGfx, markerPath, {
|
14989 | strokeWidth: 1,
|
14990 | fill: getFillColor(element, defaultFillColor),
|
14991 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14992 | });
|
14993 | },
|
14994 | 'SubProcessMarker': function(parentGfx, element) {
|
14995 | var markerRect = drawRect(parentGfx, 14, 14, 0, {
|
14996 | strokeWidth: 1,
|
14997 | fill: getFillColor(element, defaultFillColor),
|
14998 | stroke: getStrokeColor(element, defaultStrokeColor)
|
14999 | });
|
15000 |
|
15001 |
|
15002 |
|
15003 | translate(markerRect, element.width / 2 - 7.5, element.height - 20);
|
15004 |
|
15005 | var markerPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
|
15006 | xScaleFactor: 1.5,
|
15007 | yScaleFactor: 1.5,
|
15008 | containerWidth: element.width,
|
15009 | containerHeight: element.height,
|
15010 | position: {
|
15011 | mx: (element.width / 2 - 7.5) / element.width,
|
15012 | my: (element.height - 20) / element.height
|
15013 | }
|
15014 | });
|
15015 |
|
15016 | drawMarker('sub-process', parentGfx, markerPath, {
|
15017 | fill: getFillColor(element, defaultFillColor),
|
15018 | stroke: getStrokeColor(element, defaultStrokeColor)
|
15019 | });
|
15020 | },
|
15021 | 'ParallelMarker': function(parentGfx, element, position) {
|
15022 | var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
|
15023 | xScaleFactor: 1,
|
15024 | yScaleFactor: 1,
|
15025 | containerWidth: element.width,
|
15026 | containerHeight: element.height,
|
15027 | position: {
|
15028 | mx: ((element.width / 2 + position.parallel) / element.width),
|
15029 | my: (element.height - 20) / element.height
|
15030 | }
|
15031 | });
|
15032 |
|
15033 | drawMarker('parallel', parentGfx, markerPath, {
|
15034 | fill: getFillColor(element, defaultFillColor),
|
15035 | stroke: getStrokeColor(element, defaultStrokeColor)
|
15036 | });
|
15037 | },
|
15038 | 'SequentialMarker': function(parentGfx, element, position) {
|
15039 | var markerPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
|
15040 | xScaleFactor: 1,
|
15041 | yScaleFactor: 1,
|
15042 | containerWidth: element.width,
|
15043 | containerHeight: element.height,
|
15044 | position: {
|
15045 | mx: ((element.width / 2 + position.seq) / element.width),
|
15046 | my: (element.height - 19) / element.height
|
15047 | }
|
15048 | });
|
15049 |
|
15050 | drawMarker('sequential', parentGfx, markerPath, {
|
15051 | fill: getFillColor(element, defaultFillColor),
|
15052 | stroke: getStrokeColor(element, defaultStrokeColor)
|
15053 | });
|
15054 | },
|
15055 | 'CompensationMarker': function(parentGfx, element, position) {
|
15056 | var markerMath = pathMap.getScaledPath('MARKER_COMPENSATION', {
|
15057 | xScaleFactor: 1,
|
15058 | yScaleFactor: 1,
|
15059 | containerWidth: element.width,
|
15060 | containerHeight: element.height,
|
15061 | position: {
|
15062 | mx: ((element.width / 2 + position.compensation) / element.width),
|
15063 | my: (element.height - 13) / element.height
|
15064 | }
|
15065 | });
|
15066 |
|
15067 | drawMarker('compensation', parentGfx, markerMath, {
|
15068 | strokeWidth: 1,
|
15069 | fill: getFillColor(element, defaultFillColor),
|
15070 | stroke: getStrokeColor(element, defaultStrokeColor)
|
15071 | });
|
15072 | },
|
15073 | 'LoopMarker': function(parentGfx, element, position) {
|
15074 | var markerPath = pathMap.getScaledPath('MARKER_LOOP', {
|
15075 | xScaleFactor: 1,
|
15076 | yScaleFactor: 1,
|
15077 | containerWidth: element.width,
|
15078 | containerHeight: element.height,
|
15079 | position: {
|
15080 | mx: ((element.width / 2 + position.loop) / element.width),
|
15081 | my: (element.height - 7) / element.height
|
15082 | }
|
15083 | });
|
15084 |
|
15085 | drawMarker('loop', parentGfx, markerPath, {
|
15086 | strokeWidth: 1,
|
15087 | fill: getFillColor(element, defaultFillColor),
|
15088 | stroke: getStrokeColor(element, defaultStrokeColor),
|
15089 | strokeLinecap: 'round',
|
15090 | strokeMiterlimit: 0.5
|
15091 | });
|
15092 | },
|
15093 | 'AdhocMarker': function(parentGfx, element, position) {
|
15094 | var markerPath = pathMap.getScaledPath('MARKER_ADHOC', {
|
15095 | xScaleFactor: 1,
|
15096 | yScaleFactor: 1,
|
15097 | containerWidth: element.width,
|
15098 | containerHeight: element.height,
|
15099 | position: {
|
15100 | mx: ((element.width / 2 + position.adhoc) / element.width),
|
15101 | my: (element.height - 15) / element.height
|
15102 | }
|
15103 | });
|
15104 |
|
15105 | drawMarker('adhoc', parentGfx, markerPath, {
|
15106 | strokeWidth: 1,
|
15107 | fill: getStrokeColor(element, defaultStrokeColor),
|
15108 | stroke: getStrokeColor(element, defaultStrokeColor)
|
15109 | });
|
15110 | }
|
15111 | };
|
15112 |
|
15113 | function attachTaskMarkers(parentGfx, element, taskMarkers) {
|
15114 | var obj = getSemantic(element);
|
15115 |
|
15116 | var subprocess = taskMarkers && taskMarkers.indexOf('SubProcessMarker') !== -1;
|
15117 | var position;
|
15118 |
|
15119 | if (subprocess) {
|
15120 | position = {
|
15121 | seq: -21,
|
15122 | parallel: -22,
|
15123 | compensation: -42,
|
15124 | loop: -18,
|
15125 | adhoc: 10
|
15126 | };
|
15127 | } else {
|
15128 | position = {
|
15129 | seq: -3,
|
15130 | parallel: -6,
|
15131 | compensation: -27,
|
15132 | loop: 0,
|
15133 | adhoc: 10
|
15134 | };
|
15135 | }
|
15136 |
|
15137 | forEach(taskMarkers, function(marker) {
|
15138 | renderer(marker)(parentGfx, element, position);
|
15139 | });
|
15140 |
|
15141 | if (obj.isForCompensation) {
|
15142 | renderer('CompensationMarker')(parentGfx, element, position);
|
15143 | }
|
15144 |
|
15145 | if (obj.$type === 'bpmn:AdHocSubProcess') {
|
15146 | renderer('AdhocMarker')(parentGfx, element, position);
|
15147 | }
|
15148 |
|
15149 | var loopCharacteristics = obj.loopCharacteristics,
|
15150 | isSequential = loopCharacteristics && loopCharacteristics.isSequential;
|
15151 |
|
15152 | if (loopCharacteristics) {
|
15153 |
|
15154 | if (isSequential === undefined) {
|
15155 | renderer('LoopMarker')(parentGfx, element, position);
|
15156 | }
|
15157 |
|
15158 | if (isSequential === false) {
|
15159 | renderer('ParallelMarker')(parentGfx, element, position);
|
15160 | }
|
15161 |
|
15162 | if (isSequential === true) {
|
15163 | renderer('SequentialMarker')(parentGfx, element, position);
|
15164 | }
|
15165 | }
|
15166 | }
|
15167 |
|
15168 | function renderDataItemCollection(parentGfx, element) {
|
15169 |
|
15170 | var yPosition = (element.height - 16) / element.height;
|
15171 |
|
15172 | var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
|
15173 | xScaleFactor: 1,
|
15174 | yScaleFactor: 1,
|
15175 | containerWidth: element.width,
|
15176 | containerHeight: element.height,
|
15177 | position: {
|
15178 | mx: 0.451,
|
15179 | my: yPosition
|
15180 | }
|
15181 | });
|
15182 |
|
15183 | drawPath(parentGfx, pathData, {
|
15184 | strokeWidth: 2
|
15185 | });
|
15186 | }
|
15187 |
|
15188 |
|
15189 |
|
15190 | this._drawPath = drawPath;
|
15191 |
|
15192 | }
|
15193 |
|
15194 |
|
15195 | inherits_browser(BpmnRenderer, BaseRenderer);
|
15196 |
|
15197 | BpmnRenderer.$inject = [
|
15198 | 'config.bpmnRenderer',
|
15199 | 'eventBus',
|
15200 | 'styles',
|
15201 | 'pathMap',
|
15202 | 'canvas',
|
15203 | 'textRenderer'
|
15204 | ];
|
15205 |
|
15206 |
|
15207 | BpmnRenderer.prototype.canRender = function(element) {
|
15208 | return is$1(element, 'bpmn:BaseElement');
|
15209 | };
|
15210 |
|
15211 | BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
|
15212 | var type = element.type;
|
15213 | var h = this.handlers[type];
|
15214 |
|
15215 |
|
15216 | return h(parentGfx, element);
|
15217 | };
|
15218 |
|
15219 | BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
|
15220 | var type = element.type;
|
15221 | var h = this.handlers[type];
|
15222 |
|
15223 |
|
15224 | return h(parentGfx, element);
|
15225 | };
|
15226 |
|
15227 | BpmnRenderer.prototype.getShapePath = function(element) {
|
15228 |
|
15229 | if (is$1(element, 'bpmn:Event')) {
|
15230 | return getCirclePath(element);
|
15231 | }
|
15232 |
|
15233 | if (is$1(element, 'bpmn:Activity')) {
|
15234 | return getRoundRectPath(element, TASK_BORDER_RADIUS);
|
15235 | }
|
15236 |
|
15237 | if (is$1(element, 'bpmn:Gateway')) {
|
15238 | return getDiamondPath(element);
|
15239 | }
|
15240 |
|
15241 | return getRectPath(element);
|
15242 | };
|
15243 |
|
15244 | var DEFAULT_BOX_PADDING = 0;
|
15245 |
|
15246 | var DEFAULT_LABEL_SIZE = {
|
15247 | width: 150,
|
15248 | height: 50
|
15249 | };
|
15250 |
|
15251 |
|
15252 | function parseAlign(align) {
|
15253 |
|
15254 | var parts = align.split('-');
|
15255 |
|
15256 | return {
|
15257 | horizontal: parts[0] || 'center',
|
15258 | vertical: parts[1] || 'top'
|
15259 | };
|
15260 | }
|
15261 |
|
15262 | function parsePadding(padding) {
|
15263 |
|
15264 | if (isObject(padding)) {
|
15265 | return assign({ top: 0, left: 0, right: 0, bottom: 0 }, padding);
|
15266 | } else {
|
15267 | return {
|
15268 | top: padding,
|
15269 | left: padding,
|
15270 | right: padding,
|
15271 | bottom: padding
|
15272 | };
|
15273 | }
|
15274 | }
|
15275 |
|
15276 | function getTextBBox(text, fakeText) {
|
15277 |
|
15278 | fakeText.textContent = text;
|
15279 |
|
15280 | var textBBox;
|
15281 |
|
15282 | try {
|
15283 | var bbox,
|
15284 | emptyLine = text === '';
|
15285 |
|
15286 |
|
15287 |
|
15288 | fakeText.textContent = emptyLine ? 'dummy' : text;
|
15289 |
|
15290 | textBBox = fakeText.getBBox();
|
15291 |
|
15292 |
|
15293 |
|
15294 | bbox = {
|
15295 | width: textBBox.width + textBBox.x * 2,
|
15296 | height: textBBox.height
|
15297 | };
|
15298 |
|
15299 | if (emptyLine) {
|
15300 |
|
15301 | bbox.width = 0;
|
15302 | }
|
15303 |
|
15304 | return bbox;
|
15305 | } catch (e) {
|
15306 | return { width: 0, height: 0 };
|
15307 | }
|
15308 | }
|
15309 |
|
15310 |
|
15311 | |
15312 |
|
15313 |
|
15314 |
|
15315 |
|
15316 |
|
15317 |
|
15318 |
|
15319 | function layoutNext(lines, maxWidth, fakeText) {
|
15320 |
|
15321 | var originalLine = lines.shift(),
|
15322 | fitLine = originalLine;
|
15323 |
|
15324 | var textBBox;
|
15325 |
|
15326 | for (;;) {
|
15327 | textBBox = getTextBBox(fitLine, fakeText);
|
15328 |
|
15329 | textBBox.width = fitLine ? textBBox.width : 0;
|
15330 |
|
15331 |
|
15332 | if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 2) {
|
15333 | return fit(lines, fitLine, originalLine, textBBox);
|
15334 | }
|
15335 |
|
15336 | fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
|
15337 | }
|
15338 | }
|
15339 |
|
15340 | function fit(lines, fitLine, originalLine, textBBox) {
|
15341 | if (fitLine.length < originalLine.length) {
|
15342 | var remainder = originalLine.slice(fitLine.length).trim();
|
15343 |
|
15344 | lines.unshift(remainder);
|
15345 | }
|
15346 |
|
15347 | return {
|
15348 | width: textBBox.width,
|
15349 | height: textBBox.height,
|
15350 | text: fitLine
|
15351 | };
|
15352 | }
|
15353 |
|
15354 |
|
15355 | |
15356 |
|
15357 |
|
15358 |
|
15359 |
|
15360 |
|
15361 |
|
15362 |
|
15363 | function semanticShorten(line, maxLength) {
|
15364 | var parts = line.split(/(\s|-)/g),
|
15365 | part,
|
15366 | shortenedParts = [],
|
15367 | length = 0;
|
15368 |
|
15369 |
|
15370 | if (parts.length > 1) {
|
15371 | while ((part = parts.shift())) {
|
15372 | if (part.length + length < maxLength) {
|
15373 | shortenedParts.push(part);
|
15374 | length += part.length;
|
15375 | } else {
|
15376 |
|
15377 | if (part === '-') {
|
15378 | shortenedParts.pop();
|
15379 | }
|
15380 |
|
15381 | break;
|
15382 | }
|
15383 | }
|
15384 | }
|
15385 |
|
15386 | return shortenedParts.join('');
|
15387 | }
|
15388 |
|
15389 |
|
15390 | function shortenLine(line, width, maxWidth) {
|
15391 | var length = Math.max(line.length * (maxWidth / width), 1);
|
15392 |
|
15393 |
|
15394 | var shortenedLine = semanticShorten(line, length);
|
15395 |
|
15396 | if (!shortenedLine) {
|
15397 |
|
15398 |
|
15399 | shortenedLine = line.slice(0, Math.max(Math.round(length - 1), 1));
|
15400 | }
|
15401 |
|
15402 | return shortenedLine;
|
15403 | }
|
15404 |
|
15405 |
|
15406 | function getHelperSvg() {
|
15407 | var helperSvg = document.getElementById('helper-svg');
|
15408 |
|
15409 | if (!helperSvg) {
|
15410 | helperSvg = create('svg');
|
15411 |
|
15412 | attr$1(helperSvg, {
|
15413 | id: 'helper-svg',
|
15414 | width: 0,
|
15415 | height: 0,
|
15416 | style: 'visibility: hidden; position: fixed'
|
15417 | });
|
15418 |
|
15419 | document.body.appendChild(helperSvg);
|
15420 | }
|
15421 |
|
15422 | return helperSvg;
|
15423 | }
|
15424 |
|
15425 |
|
15426 | |
15427 |
|
15428 |
|
15429 |
|
15430 |
|
15431 |
|
15432 |
|
15433 |
|
15434 |
|
15435 | function Text(config) {
|
15436 |
|
15437 | this._config = assign({}, {
|
15438 | size: DEFAULT_LABEL_SIZE,
|
15439 | padding: DEFAULT_BOX_PADDING,
|
15440 | style: {},
|
15441 | align: 'center-top'
|
15442 | }, config || {});
|
15443 | }
|
15444 |
|
15445 | |
15446 |
|
15447 |
|
15448 |
|
15449 |
|
15450 |
|
15451 |
|
15452 |
|
15453 | Text.prototype.createText = function(text, options) {
|
15454 | return this.layoutText(text, options).element;
|
15455 | };
|
15456 |
|
15457 | |
15458 |
|
15459 |
|
15460 |
|
15461 |
|
15462 |
|
15463 |
|
15464 |
|
15465 | Text.prototype.getDimensions = function(text, options) {
|
15466 | return this.layoutText(text, options).dimensions;
|
15467 | };
|
15468 |
|
15469 | |
15470 |
|
15471 |
|
15472 |
|
15473 |
|
15474 |
|
15475 |
|
15476 |
|
15477 |
|
15478 |
|
15479 |
|
15480 |
|
15481 |
|
15482 |
|
15483 |
|
15484 |
|
15485 | Text.prototype.layoutText = function(text, options) {
|
15486 | var box = assign({}, this._config.size, options.box),
|
15487 | style = assign({}, this._config.style, options.style),
|
15488 | align = parseAlign(options.align || this._config.align),
|
15489 | padding = parsePadding(options.padding !== undefined ? options.padding : this._config.padding),
|
15490 | fitBox = options.fitBox || false;
|
15491 |
|
15492 | var lineHeight = getLineHeight(style);
|
15493 |
|
15494 | var lines = text.split(/\r?\n/g),
|
15495 | layouted = [];
|
15496 |
|
15497 | var maxWidth = box.width - padding.left - padding.right;
|
15498 |
|
15499 |
|
15500 | var helperText = create('text');
|
15501 | attr$1(helperText, { x: 0, y: 0 });
|
15502 | attr$1(helperText, style);
|
15503 |
|
15504 | var helperSvg = getHelperSvg();
|
15505 |
|
15506 | append(helperSvg, helperText);
|
15507 |
|
15508 | while (lines.length) {
|
15509 | layouted.push(layoutNext(lines, maxWidth, helperText));
|
15510 | }
|
15511 |
|
15512 | if (align.vertical === 'middle') {
|
15513 | padding.top = padding.bottom = 0;
|
15514 | }
|
15515 |
|
15516 | var totalHeight = reduce(layouted, function(sum, line, idx) {
|
15517 | return sum + (lineHeight || line.height);
|
15518 | }, 0) + padding.top + padding.bottom;
|
15519 |
|
15520 | var maxLineWidth = reduce(layouted, function(sum, line, idx) {
|
15521 | return line.width > sum ? line.width : sum;
|
15522 | }, 0);
|
15523 |
|
15524 |
|
15525 | var y = padding.top;
|
15526 |
|
15527 | if (align.vertical === 'middle') {
|
15528 | y += (box.height - totalHeight) / 2;
|
15529 | }
|
15530 |
|
15531 |
|
15532 | y -= (lineHeight || layouted[0].height) / 4;
|
15533 |
|
15534 |
|
15535 | var textElement = create('text');
|
15536 |
|
15537 | attr$1(textElement, style);
|
15538 |
|
15539 |
|
15540 |
|
15541 | forEach(layouted, function(line) {
|
15542 |
|
15543 | var x;
|
15544 |
|
15545 | y += (lineHeight || line.height);
|
15546 |
|
15547 | switch (align.horizontal) {
|
15548 | case 'left':
|
15549 | x = padding.left;
|
15550 | break;
|
15551 |
|
15552 | case 'right':
|
15553 | x = ((fitBox ? maxLineWidth : maxWidth)
|
15554 | - padding.right - line.width);
|
15555 | break;
|
15556 |
|
15557 | default:
|
15558 |
|
15559 | x = Math.max((((fitBox ? maxLineWidth : maxWidth)
|
15560 | - line.width) / 2 + padding.left), 0);
|
15561 | }
|
15562 |
|
15563 | var tspan = create('tspan');
|
15564 | attr$1(tspan, { x: x, y: y });
|
15565 |
|
15566 | tspan.textContent = line.text;
|
15567 |
|
15568 | append(textElement, tspan);
|
15569 | });
|
15570 |
|
15571 | remove$1(helperText);
|
15572 |
|
15573 | var dimensions = {
|
15574 | width: maxLineWidth,
|
15575 | height: totalHeight
|
15576 | };
|
15577 |
|
15578 | return {
|
15579 | dimensions: dimensions,
|
15580 | element: textElement
|
15581 | };
|
15582 | };
|
15583 |
|
15584 |
|
15585 | function getLineHeight(style) {
|
15586 | if ('fontSize' in style && 'lineHeight' in style) {
|
15587 | return style.lineHeight * parseInt(style.fontSize, 10);
|
15588 | }
|
15589 | }
|
15590 |
|
15591 | var DEFAULT_FONT_SIZE = 12;
|
15592 | var LINE_HEIGHT_RATIO = 1.2;
|
15593 |
|
15594 | var MIN_TEXT_ANNOTATION_HEIGHT = 30;
|
15595 |
|
15596 |
|
15597 | function TextRenderer(config) {
|
15598 |
|
15599 | var defaultStyle = assign({
|
15600 | fontFamily: 'Arial, sans-serif',
|
15601 | fontSize: DEFAULT_FONT_SIZE,
|
15602 | fontWeight: 'normal',
|
15603 | lineHeight: LINE_HEIGHT_RATIO
|
15604 | }, config && config.defaultStyle || {});
|
15605 |
|
15606 | var fontSize = parseInt(defaultStyle.fontSize, 10) - 1;
|
15607 |
|
15608 | var externalStyle = assign({}, defaultStyle, {
|
15609 | fontSize: fontSize
|
15610 | }, config && config.externalStyle || {});
|
15611 |
|
15612 | var textUtil = new Text({
|
15613 | style: defaultStyle
|
15614 | });
|
15615 |
|
15616 | |
15617 |
|
15618 |
|
15619 |
|
15620 |
|
15621 |
|
15622 |
|
15623 |
|
15624 |
|
15625 | this.getExternalLabelBounds = function(bounds, text) {
|
15626 |
|
15627 | var layoutedDimensions = textUtil.getDimensions(text, {
|
15628 | box: {
|
15629 | width: 90,
|
15630 | height: 30,
|
15631 | x: bounds.width / 2 + bounds.x,
|
15632 | y: bounds.height / 2 + bounds.y
|
15633 | },
|
15634 | style: externalStyle
|
15635 | });
|
15636 |
|
15637 |
|
15638 | return {
|
15639 | x: Math.round(bounds.x + bounds.width / 2 - layoutedDimensions.width / 2),
|
15640 | y: Math.round(bounds.y),
|
15641 | width: Math.ceil(layoutedDimensions.width),
|
15642 | height: Math.ceil(layoutedDimensions.height)
|
15643 | };
|
15644 |
|
15645 | };
|
15646 |
|
15647 | |
15648 |
|
15649 |
|
15650 |
|
15651 |
|
15652 |
|
15653 |
|
15654 |
|
15655 | this.getTextAnnotationBounds = function(bounds, text) {
|
15656 |
|
15657 | var layoutedDimensions = textUtil.getDimensions(text, {
|
15658 | box: bounds,
|
15659 | style: defaultStyle,
|
15660 | align: 'left-top',
|
15661 | padding: 5
|
15662 | });
|
15663 |
|
15664 | return {
|
15665 | x: bounds.x,
|
15666 | y: bounds.y,
|
15667 | width: bounds.width,
|
15668 | height: Math.max(MIN_TEXT_ANNOTATION_HEIGHT, Math.round(layoutedDimensions.height))
|
15669 | };
|
15670 | };
|
15671 |
|
15672 | |
15673 |
|
15674 |
|
15675 |
|
15676 |
|
15677 |
|
15678 |
|
15679 |
|
15680 | this.createText = function(text, options) {
|
15681 | return textUtil.createText(text, options || {});
|
15682 | };
|
15683 |
|
15684 | |
15685 |
|
15686 |
|
15687 | this.getDefaultStyle = function() {
|
15688 | return defaultStyle;
|
15689 | };
|
15690 |
|
15691 | |
15692 |
|
15693 |
|
15694 | this.getExternalStyle = function() {
|
15695 | return externalStyle;
|
15696 | };
|
15697 |
|
15698 | }
|
15699 |
|
15700 | TextRenderer.$inject = [
|
15701 | 'config.textRenderer'
|
15702 | ];
|
15703 |
|
15704 | |
15705 |
|
15706 |
|
15707 |
|
15708 | function PathMap() {
|
15709 |
|
15710 | |
15711 |
|
15712 |
|
15713 |
|
15714 |
|
15715 |
|
15716 |
|
15717 |
|
15718 |
|
15719 |
|
15720 |
|
15721 |
|
15722 |
|
15723 |
|
15724 |
|
15725 |
|
15726 |
|
15727 |
|
15728 |
|
15729 |
|
15730 |
|
15731 |
|
15732 |
|
15733 |
|
15734 |
|
15735 |
|
15736 |
|
15737 |
|
15738 |
|
15739 |
|
15740 |
|
15741 | this.pathMap = {
|
15742 | 'EVENT_MESSAGE': {
|
15743 | 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}',
|
15744 | height: 36,
|
15745 | width: 36,
|
15746 | heightElements: [6, 14],
|
15747 | widthElements: [10.5, 21]
|
15748 | },
|
15749 | 'EVENT_SIGNAL': {
|
15750 | d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z',
|
15751 | height: 36,
|
15752 | width: 36,
|
15753 | heightElements: [18],
|
15754 | widthElements: [10, 20]
|
15755 | },
|
15756 | 'EVENT_ESCALATION': {
|
15757 | d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x0},-{e.y1} l -{e.x0},{e.y1} Z',
|
15758 | height: 36,
|
15759 | width: 36,
|
15760 | heightElements: [20, 7],
|
15761 | widthElements: [8]
|
15762 | },
|
15763 | 'EVENT_CONDITIONAL': {
|
15764 | d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' +
|
15765 | 'M {e.x2},{e.y3} l {e.x0},0 ' +
|
15766 | 'M {e.x2},{e.y4} l {e.x0},0 ' +
|
15767 | 'M {e.x2},{e.y5} l {e.x0},0 ' +
|
15768 | 'M {e.x2},{e.y6} l {e.x0},0 ' +
|
15769 | 'M {e.x2},{e.y7} l {e.x0},0 ' +
|
15770 | 'M {e.x2},{e.y8} l {e.x0},0 ',
|
15771 | height: 36,
|
15772 | width: 36,
|
15773 | heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5],
|
15774 | widthElements: [10.5, 14.5, 12.5]
|
15775 | },
|
15776 | 'EVENT_LINK': {
|
15777 | 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',
|
15778 | height: 36,
|
15779 | width: 36,
|
15780 | heightElements: [4.4375, 6.75, 7.8125],
|
15781 | widthElements: [9.84375, 13.5]
|
15782 | },
|
15783 | 'EVENT_ERROR': {
|
15784 | 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',
|
15785 | height: 36,
|
15786 | width: 36,
|
15787 | heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714],
|
15788 | widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636]
|
15789 | },
|
15790 | 'EVENT_CANCEL_45': {
|
15791 | d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
|
15792 | '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
|
15793 | height: 36,
|
15794 | width: 36,
|
15795 | heightElements: [4.75, 8.5],
|
15796 | widthElements: [4.75, 8.5]
|
15797 | },
|
15798 | 'EVENT_COMPENSATION': {
|
15799 | d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x1},-{e.y2} {e.x2},-{e.y3} 0,{e.y1} -{e.x2},-{e.y3} z',
|
15800 | height: 36,
|
15801 | width: 36,
|
15802 | heightElements: [6.5, 13, 0.4, 6.1],
|
15803 | widthElements: [9, 9.3, 8.7]
|
15804 | },
|
15805 | 'EVENT_TIMER_WH': {
|
15806 | d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
|
15807 | height: 36,
|
15808 | width: 36,
|
15809 | heightElements: [10, 2],
|
15810 | widthElements: [3, 7]
|
15811 | },
|
15812 | 'EVENT_TIMER_LINE': {
|
15813 | d: 'M {mx},{my} ' +
|
15814 | 'm {e.x0},{e.y0} l -{e.x1},{e.y1} ',
|
15815 | height: 36,
|
15816 | width: 36,
|
15817 | heightElements: [10, 3],
|
15818 | widthElements: [0, 0]
|
15819 | },
|
15820 | 'EVENT_MULTIPLE': {
|
15821 | d:'m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z',
|
15822 | height: 36,
|
15823 | width: 36,
|
15824 | heightElements: [6.28099, 12.56199],
|
15825 | widthElements: [3.1405, 9.42149, 12.56198]
|
15826 | },
|
15827 | 'EVENT_PARALLEL_MULTIPLE': {
|
15828 | d:'m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
|
15829 | '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
|
15830 | height: 36,
|
15831 | width: 36,
|
15832 | heightElements: [2.56228, 7.68683],
|
15833 | widthElements: [2.56228, 7.68683]
|
15834 | },
|
15835 | 'GATEWAY_EXCLUSIVE': {
|
15836 | d:'m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' +
|
15837 | '{e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} ' +
|
15838 | '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z',
|
15839 | height: 17.5,
|
15840 | width: 17.5,
|
15841 | heightElements: [8.5, 6.5312, -6.5312, -8.5],
|
15842 | widthElements: [6.5, -6.5, 3, -3, 5, -5]
|
15843 | },
|
15844 | 'GATEWAY_PARALLEL': {
|
15845 | d:'m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
|
15846 | '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
|
15847 | height: 30,
|
15848 | width: 30,
|
15849 | heightElements: [5, 12.5],
|
15850 | widthElements: [5, 12.5]
|
15851 | },
|
15852 | 'GATEWAY_EVENT_BASED': {
|
15853 | d:'m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z',
|
15854 | height: 11,
|
15855 | width: 11,
|
15856 | heightElements: [-6, 6, 12, -12],
|
15857 | widthElements: [9, -3, -12]
|
15858 | },
|
15859 | 'GATEWAY_COMPLEX': {
|
15860 | 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} ' +
|
15861 | '{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} ' +
|
15862 | '{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} ' +
|
15863 | '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z',
|
15864 | height: 17.125,
|
15865 | width: 17.125,
|
15866 | heightElements: [4.875, 3.4375, 2.125, 3],
|
15867 | widthElements: [3.4375, 2.125, 4.875, 3]
|
15868 | },
|
15869 | 'DATA_OBJECT_PATH': {
|
15870 | 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',
|
15871 | height: 61,
|
15872 | width: 51,
|
15873 | heightElements: [10, 50, 60],
|
15874 | widthElements: [10, 40, 50, 60]
|
15875 | },
|
15876 | 'DATA_OBJECT_COLLECTION_PATH': {
|
15877 | d:'m {mx}, {my} ' +
|
15878 | 'm 0 15 l 0 -15 ' +
|
15879 | 'm 4 15 l 0 -15 ' +
|
15880 | 'm 4 15 l 0 -15 ',
|
15881 | height: 61,
|
15882 | width: 51,
|
15883 | heightElements: [12],
|
15884 | widthElements: [1, 6, 12, 15]
|
15885 | },
|
15886 | 'DATA_ARROW': {
|
15887 | d:'m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z',
|
15888 | height: 61,
|
15889 | width: 51,
|
15890 | heightElements: [],
|
15891 | widthElements: []
|
15892 | },
|
15893 | 'DATA_STORE': {
|
15894 | d:'m {mx},{my} ' +
|
15895 | 'l 0,{e.y2} ' +
|
15896 | 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
|
15897 | 'l 0,-{e.y2} ' +
|
15898 | 'c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0' +
|
15899 | 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
|
15900 | 'm -{e.x2},{e.y0}' +
|
15901 | 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0' +
|
15902 | 'm -{e.x2},{e.y0}' +
|
15903 | 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0',
|
15904 | height: 61,
|
15905 | width: 61,
|
15906 | heightElements: [7, 10, 45],
|
15907 | widthElements: [2, 58, 60]
|
15908 | },
|
15909 | 'TEXT_ANNOTATION': {
|
15910 | d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
|
15911 | height: 30,
|
15912 | width: 10,
|
15913 | heightElements: [30],
|
15914 | widthElements: [10]
|
15915 | },
|
15916 | 'MARKER_SUB_PROCESS': {
|
15917 | d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0',
|
15918 | height: 10,
|
15919 | width: 10,
|
15920 | heightElements: [],
|
15921 | widthElements: []
|
15922 | },
|
15923 | 'MARKER_PARALLEL': {
|
15924 | d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10',
|
15925 | height: 10,
|
15926 | width: 10,
|
15927 | heightElements: [],
|
15928 | widthElements: []
|
15929 | },
|
15930 | 'MARKER_SEQUENTIAL': {
|
15931 | d: 'm{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0',
|
15932 | height: 10,
|
15933 | width: 10,
|
15934 | heightElements: [],
|
15935 | widthElements: []
|
15936 | },
|
15937 | 'MARKER_COMPENSATION': {
|
15938 | d: 'm {mx},{my} 7,-5 0,10 z m 7.1,-0.3 6.9,-4.7 0,10 -6.9,-4.7 z',
|
15939 | height: 10,
|
15940 | width: 21,
|
15941 | heightElements: [],
|
15942 | widthElements: []
|
15943 | },
|
15944 | 'MARKER_LOOP': {
|
15945 | d: 'm {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 ' +
|
15946 | '-6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 ' +
|
15947 | '0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 ' +
|
15948 | 'l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902',
|
15949 | height: 13.9,
|
15950 | width: 13.7,
|
15951 | heightElements: [],
|
15952 | widthElements: []
|
15953 | },
|
15954 | 'MARKER_ADHOC': {
|
15955 | 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 ' +
|
15956 | '3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 ' +
|
15957 | '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 ' +
|
15958 | '-3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 ' +
|
15959 | '-2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z',
|
15960 | height: 4,
|
15961 | width: 15,
|
15962 | heightElements: [],
|
15963 | widthElements: []
|
15964 | },
|
15965 | 'TASK_TYPE_SEND': {
|
15966 | 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}',
|
15967 | height: 14,
|
15968 | width: 21,
|
15969 | heightElements: [6, 14],
|
15970 | widthElements: [10.5, 21]
|
15971 | },
|
15972 | 'TASK_TYPE_SCRIPT': {
|
15973 | d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' +
|
15974 | 'c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z ' +
|
15975 | 'm -7,-12 l 5,0 ' +
|
15976 | 'm -4.5,3 l 4.5,0 ' +
|
15977 | 'm -3,3 l 5,0' +
|
15978 | 'm -4,3 l 5,0',
|
15979 | height: 15,
|
15980 | width: 12.6,
|
15981 | heightElements: [6, 14],
|
15982 | widthElements: [10.5, 21]
|
15983 | },
|
15984 | 'TASK_TYPE_USER_1': {
|
15985 | d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' +
|
15986 | '-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' +
|
15987 | '0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' +
|
15988 | 'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' +
|
15989 | 'm -8,6 l 0,5.5 m 11,0 l 0,-5'
|
15990 | },
|
15991 | 'TASK_TYPE_USER_2': {
|
15992 | d: 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' +
|
15993 | '-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 '
|
15994 | },
|
15995 | 'TASK_TYPE_USER_3': {
|
15996 | 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 ' +
|
15997 | '4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' +
|
15998 | '-4.20799998,3.36699999 -4.20699998,4.34799999 z'
|
15999 | },
|
16000 | 'TASK_TYPE_MANUAL': {
|
16001 | 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 ' +
|
16002 | '-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 ' +
|
16003 | '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 ' +
|
16004 | '-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 ' +
|
16005 | '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 ' +
|
16006 | '-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' +
|
16007 | '2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' +
|
16008 | '-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' +
|
16009 | '-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 ' +
|
16010 | '-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 ' +
|
16011 | '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 ' +
|
16012 | '-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z'
|
16013 | },
|
16014 | 'TASK_TYPE_INSTANTIATING_SEND': {
|
16015 | 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'
|
16016 | },
|
16017 | 'TASK_TYPE_SERVICE': {
|
16018 | d: 'm {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 ' +
|
16019 | '0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 ' +
|
16020 | '-1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 ' +
|
16021 | 'v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 ' +
|
16022 | '-0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 ' +
|
16023 | '-1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 ' +
|
16024 | '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 ' +
|
16025 | '-0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 ' +
|
16026 | 'c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 ' +
|
16027 | 'l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 ' +
|
16028 | '0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 ' +
|
16029 | 'c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z ' +
|
16030 | 'm 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
|
16031 | '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
|
16032 | '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
|
16033 | },
|
16034 | 'TASK_TYPE_SERVICE_FILL': {
|
16035 | d: 'm {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
|
16036 | '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
|
16037 | '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
|
16038 | },
|
16039 | 'TASK_TYPE_BUSINESS_RULE_HEADER': {
|
16040 | d: 'm {mx},{my} 0,4 20,0 0,-4 z'
|
16041 | },
|
16042 | 'TASK_TYPE_BUSINESS_RULE_MAIN': {
|
16043 | d: 'm {mx},{my} 0,12 20,0 0,-12 z' +
|
16044 | 'm 0,8 l 20,0 ' +
|
16045 | 'm -13,-4 l 0,8'
|
16046 | },
|
16047 | 'MESSAGE_FLOW_MARKER': {
|
16048 | 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'
|
16049 | }
|
16050 | };
|
16051 |
|
16052 | this.getRawPath = function getRawPath(pathId) {
|
16053 | return this.pathMap[pathId].d;
|
16054 | };
|
16055 |
|
16056 | |
16057 |
|
16058 |
|
16059 |
|
16060 |
|
16061 |
|
16062 |
|
16063 |
|
16064 |
|
16065 |
|
16066 |
|
16067 |
|
16068 |
|
16069 |
|
16070 |
|
16071 |
|
16072 |
|
16073 |
|
16074 |
|
16075 |
|
16076 |
|
16077 |
|
16078 |
|
16079 |
|
16080 |
|
16081 |
|
16082 |
|
16083 |
|
16084 |
|
16085 |
|
16086 |
|
16087 |
|
16088 |
|
16089 |
|
16090 |
|
16091 |
|
16092 |
|
16093 |
|
16094 |
|
16095 |
|
16096 |
|
16097 |
|
16098 |
|
16099 |
|
16100 |
|
16101 |
|
16102 |
|
16103 |
|
16104 |
|
16105 | this.getScaledPath = function getScaledPath(pathId, param) {
|
16106 | var rawPath = this.pathMap[pathId];
|
16107 |
|
16108 |
|
16109 |
|
16110 | var mx, my;
|
16111 |
|
16112 | if (param.abspos) {
|
16113 | mx = param.abspos.x;
|
16114 | my = param.abspos.y;
|
16115 | } else {
|
16116 | mx = param.containerWidth * param.position.mx;
|
16117 | my = param.containerHeight * param.position.my;
|
16118 | }
|
16119 |
|
16120 | var coordinates = {};
|
16121 | if (param.position) {
|
16122 |
|
16123 |
|
16124 | var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
|
16125 | var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor;
|
16126 |
|
16127 |
|
16128 |
|
16129 | for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
|
16130 | coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
|
16131 | }
|
16132 |
|
16133 |
|
16134 | for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
|
16135 | coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
|
16136 | }
|
16137 | }
|
16138 |
|
16139 |
|
16140 | var path = format(
|
16141 | rawPath.d, {
|
16142 | mx: mx,
|
16143 | my: my,
|
16144 | e: coordinates
|
16145 | }
|
16146 | );
|
16147 | return path;
|
16148 | };
|
16149 | }
|
16150 |
|
16151 |
|
16152 |
|
16153 |
|
16154 | var tokenRegex = /\{([^}]+)\}/g,
|
16155 | objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;
|
16156 |
|
16157 | function replacer(all, key, obj) {
|
16158 | var res = obj;
|
16159 | key.replace(objNotationRegex, function(all, name, quote, quotedName, isFunc) {
|
16160 | name = name || quotedName;
|
16161 | if (res) {
|
16162 | if (name in res) {
|
16163 | res = res[name];
|
16164 | }
|
16165 | typeof res == 'function' && isFunc && (res = res());
|
16166 | }
|
16167 | });
|
16168 | res = (res == null || res == obj ? all : res) + '';
|
16169 |
|
16170 | return res;
|
16171 | }
|
16172 |
|
16173 | function format(str, obj) {
|
16174 | return String(str).replace(tokenRegex, function(all, key) {
|
16175 | return replacer(all, key, obj);
|
16176 | });
|
16177 | }
|
16178 |
|
16179 | var DrawModule$1 = {
|
16180 | __init__: [ 'bpmnRenderer' ],
|
16181 | bpmnRenderer: [ 'type', BpmnRenderer ],
|
16182 | textRenderer: [ 'type', TextRenderer ],
|
16183 | pathMap: [ 'type', PathMap ]
|
16184 | };
|
16185 |
|
16186 | |
16187 |
|
16188 |
|
16189 |
|
16190 |
|
16191 |
|
16192 |
|
16193 |
|
16194 |
|
16195 |
|
16196 |
|
16197 |
|
16198 |
|
16199 |
|
16200 |
|
16201 |
|
16202 |
|
16203 |
|
16204 | function translate$1(template, replacements) {
|
16205 |
|
16206 | replacements = replacements || {};
|
16207 |
|
16208 | return template.replace(/{([^}]+)}/g, function(_, key) {
|
16209 | return replacements[key] || '{' + key + '}';
|
16210 | });
|
16211 | }
|
16212 |
|
16213 | var translate$2 = {
|
16214 | translate: [ 'value', translate$1 ]
|
16215 | };
|
16216 |
|
16217 | var DEFAULT_LABEL_SIZE$1 = {
|
16218 | width: 90,
|
16219 | height: 20
|
16220 | };
|
16221 |
|
16222 | var FLOW_LABEL_INDENT = 15;
|
16223 |
|
16224 |
|
16225 | |
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 | function isLabelExternal(semantic) {
|
16232 | return is$1(semantic, 'bpmn:Event') ||
|
16233 | is$1(semantic, 'bpmn:Gateway') ||
|
16234 | is$1(semantic, 'bpmn:DataStoreReference') ||
|
16235 | is$1(semantic, 'bpmn:DataObjectReference') ||
|
16236 | is$1(semantic, 'bpmn:SequenceFlow') ||
|
16237 | is$1(semantic, 'bpmn:MessageFlow');
|
16238 | }
|
16239 |
|
16240 | |
16241 |
|
16242 |
|
16243 |
|
16244 |
|
16245 |
|
16246 | function getFlowLabelPosition(waypoints) {
|
16247 |
|
16248 |
|
16249 | var mid = waypoints.length / 2 - 1;
|
16250 |
|
16251 | var first = waypoints[Math.floor(mid)];
|
16252 | var second = waypoints[Math.ceil(mid + 0.01)];
|
16253 |
|
16254 |
|
16255 | var position = getWaypointsMid(waypoints);
|
16256 |
|
16257 |
|
16258 | var angle = Math.atan((second.y - first.y) / (second.x - first.x));
|
16259 |
|
16260 | var x = position.x,
|
16261 | y = position.y;
|
16262 |
|
16263 | if (Math.abs(angle) < Math.PI / 2) {
|
16264 | y -= FLOW_LABEL_INDENT;
|
16265 | } else {
|
16266 | x += FLOW_LABEL_INDENT;
|
16267 | }
|
16268 |
|
16269 | return { x: x, y: y };
|
16270 | }
|
16271 |
|
16272 |
|
16273 | |
16274 |
|
16275 |
|
16276 |
|
16277 |
|
16278 |
|
16279 | function getWaypointsMid(waypoints) {
|
16280 |
|
16281 | var mid = waypoints.length / 2 - 1;
|
16282 |
|
16283 | var first = waypoints[Math.floor(mid)];
|
16284 | var second = waypoints[Math.ceil(mid + 0.01)];
|
16285 |
|
16286 | return {
|
16287 | x: first.x + (second.x - first.x) / 2,
|
16288 | y: first.y + (second.y - first.y) / 2
|
16289 | };
|
16290 | }
|
16291 |
|
16292 |
|
16293 | function getExternalLabelMid(element) {
|
16294 |
|
16295 | if (element.waypoints) {
|
16296 | return getFlowLabelPosition(element.waypoints);
|
16297 | } else {
|
16298 | return {
|
16299 | x: element.x + element.width / 2,
|
16300 | y: element.y + element.height + DEFAULT_LABEL_SIZE$1.height / 2
|
16301 | };
|
16302 | }
|
16303 | }
|
16304 |
|
16305 |
|
16306 | |
16307 |
|
16308 |
|
16309 |
|
16310 |
|
16311 |
|
16312 |
|
16313 | function getExternalLabelBounds(semantic, element) {
|
16314 |
|
16315 | var mid,
|
16316 | size$$1,
|
16317 | bounds,
|
16318 | di = semantic.di,
|
16319 | label = di.label;
|
16320 |
|
16321 | if (label && label.bounds) {
|
16322 | bounds = label.bounds;
|
16323 |
|
16324 | size$$1 = {
|
16325 | width: Math.max(DEFAULT_LABEL_SIZE$1.width, bounds.width),
|
16326 | height: bounds.height
|
16327 | };
|
16328 |
|
16329 | mid = {
|
16330 | x: bounds.x + bounds.width / 2,
|
16331 | y: bounds.y + bounds.height / 2
|
16332 | };
|
16333 | } else {
|
16334 |
|
16335 | mid = getExternalLabelMid(element);
|
16336 |
|
16337 | size$$1 = DEFAULT_LABEL_SIZE$1;
|
16338 | }
|
16339 |
|
16340 | return assign({
|
16341 | x: mid.x - size$$1.width / 2,
|
16342 | y: mid.y - size$$1.height / 2
|
16343 | }, size$$1);
|
16344 | }
|
16345 |
|
16346 | |
16347 |
|
16348 |
|
16349 |
|
16350 |
|
16351 |
|
16352 |
|
16353 |
|
16354 |
|
16355 | |
16356 |
|
16357 |
|
16358 |
|
16359 |
|
16360 |
|
16361 |
|
16362 |
|
16363 | var math = Math,
|
16364 | PI = math.PI;
|
16365 |
|
16366 | function roundPoint(point) {
|
16367 |
|
16368 | return {
|
16369 | x: Math.round(point.x),
|
16370 | y: Math.round(point.y)
|
16371 | };
|
16372 | }
|
16373 |
|
16374 |
|
16375 | |
16376 |
|
16377 |
|
16378 |
|
16379 |
|
16380 |
|
16381 |
|
16382 | function getMid(bounds) {
|
16383 | return roundPoint({
|
16384 | x: bounds.x + (bounds.width || 0) / 2,
|
16385 | y: bounds.y + (bounds.height || 0) / 2
|
16386 | });
|
16387 | }
|
16388 |
|
16389 | function elementData(semantic, attrs) {
|
16390 | return assign({
|
16391 | id: semantic.id,
|
16392 | type: semantic.$type,
|
16393 | businessObject: semantic
|
16394 | }, attrs);
|
16395 | }
|
16396 |
|
16397 | function collectWaypoints(waypoints) {
|
16398 | return map(waypoints, function(p) {
|
16399 | return { x: p.x, y: p.y };
|
16400 | });
|
16401 | }
|
16402 |
|
16403 | function notYetDrawn(translate, semantic, refSemantic, property) {
|
16404 | return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
|
16405 | element: elementToString(refSemantic),
|
16406 | referenced: elementToString(semantic),
|
16407 | property: property
|
16408 | }));
|
16409 | }
|
16410 |
|
16411 |
|
16412 | |
16413 |
|
16414 |
|
16415 |
|
16416 |
|
16417 |
|
16418 |
|
16419 |
|
16420 |
|
16421 |
|
16422 | function BpmnImporter(
|
16423 | eventBus, canvas, elementFactory,
|
16424 | elementRegistry, translate, textRenderer) {
|
16425 |
|
16426 | this._eventBus = eventBus;
|
16427 | this._canvas = canvas;
|
16428 | this._elementFactory = elementFactory;
|
16429 | this._elementRegistry = elementRegistry;
|
16430 | this._translate = translate;
|
16431 | this._textRenderer = textRenderer;
|
16432 | }
|
16433 |
|
16434 | BpmnImporter.$inject = [
|
16435 | 'eventBus',
|
16436 | 'canvas',
|
16437 | 'elementFactory',
|
16438 | 'elementRegistry',
|
16439 | 'translate',
|
16440 | 'textRenderer'
|
16441 | ];
|
16442 |
|
16443 |
|
16444 | |
16445 |
|
16446 |
|
16447 |
|
16448 | BpmnImporter.prototype.add = function(semantic, parentElement) {
|
16449 |
|
16450 | var di = semantic.di,
|
16451 | element,
|
16452 | translate = this._translate,
|
16453 | hidden;
|
16454 |
|
16455 | var parentIndex;
|
16456 |
|
16457 |
|
16458 |
|
16459 |
|
16460 | if (is$1(di, 'bpmndi:BPMNPlane')) {
|
16461 |
|
16462 |
|
16463 | element = this._elementFactory.createRoot(elementData(semantic));
|
16464 |
|
16465 | this._canvas.setRootElement(element);
|
16466 | }
|
16467 |
|
16468 |
|
16469 | else if (is$1(di, 'bpmndi:BPMNShape')) {
|
16470 |
|
16471 | var collapsed = !isExpanded(semantic);
|
16472 | hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
|
16473 |
|
16474 | var bounds = semantic.di.bounds;
|
16475 |
|
16476 | element = this._elementFactory.createShape(elementData(semantic, {
|
16477 | collapsed: collapsed,
|
16478 | hidden: hidden,
|
16479 | x: Math.round(bounds.x),
|
16480 | y: Math.round(bounds.y),
|
16481 | width: Math.round(bounds.width),
|
16482 | height: Math.round(bounds.height)
|
16483 | }));
|
16484 |
|
16485 | if (is$1(semantic, 'bpmn:BoundaryEvent')) {
|
16486 | this._attachBoundary(semantic, element);
|
16487 | }
|
16488 |
|
16489 |
|
16490 | if (is$1(semantic, 'bpmn:Lane')) {
|
16491 | parentIndex = 0;
|
16492 | }
|
16493 |
|
16494 | if (is$1(semantic, 'bpmn:DataStoreReference')) {
|
16495 |
|
16496 |
|
16497 | if (!isPointInsideBBox$1(parentElement, getMid(bounds))) {
|
16498 | parentElement = this._canvas.getRootElement();
|
16499 | }
|
16500 | }
|
16501 |
|
16502 | this._canvas.addShape(element, parentElement, parentIndex);
|
16503 | }
|
16504 |
|
16505 |
|
16506 | else if (is$1(di, 'bpmndi:BPMNEdge')) {
|
16507 |
|
16508 | var source = this._getSource(semantic),
|
16509 | target = this._getTarget(semantic);
|
16510 |
|
16511 | hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
|
16512 |
|
16513 | element = this._elementFactory.createConnection(elementData(semantic, {
|
16514 | hidden: hidden,
|
16515 | source: source,
|
16516 | target: target,
|
16517 | waypoints: collectWaypoints(semantic.di.waypoint)
|
16518 | }));
|
16519 |
|
16520 | if (is$1(semantic, 'bpmn:DataAssociation')) {
|
16521 |
|
16522 |
|
16523 |
|
16524 |
|
16525 |
|
16526 | parentElement = null;
|
16527 | }
|
16528 |
|
16529 |
|
16530 | if (is$1(semantic, 'bpmn:SequenceFlow')) {
|
16531 | parentIndex = 0;
|
16532 | }
|
16533 |
|
16534 | this._canvas.addConnection(element, parentElement, parentIndex);
|
16535 | } else {
|
16536 | throw new Error(translate('unknown di {di} for element {semantic}', {
|
16537 | di: elementToString(di),
|
16538 | semantic: elementToString(semantic)
|
16539 | }));
|
16540 | }
|
16541 |
|
16542 | if (isLabelExternal(semantic) && semantic.name) {
|
16543 | this.addLabel(semantic, element);
|
16544 | }
|
16545 |
|
16546 |
|
16547 | this._eventBus.fire('bpmnElement.added', { element: element });
|
16548 |
|
16549 | return element;
|
16550 | };
|
16551 |
|
16552 |
|
16553 | |
16554 |
|
16555 |
|
16556 |
|
16557 |
|
16558 |
|
16559 | BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElement) {
|
16560 | var translate = this._translate;
|
16561 | var hostSemantic = boundarySemantic.attachedToRef;
|
16562 |
|
16563 | if (!hostSemantic) {
|
16564 | throw new Error(translate('missing {semantic}#attachedToRef', {
|
16565 | semantic: elementToString(boundarySemantic)
|
16566 | }));
|
16567 | }
|
16568 |
|
16569 | var host = this._elementRegistry.get(hostSemantic.id),
|
16570 | attachers = host && host.attachers;
|
16571 |
|
16572 | if (!host) {
|
16573 | throw notYetDrawn(translate, boundarySemantic, hostSemantic, 'attachedToRef');
|
16574 | }
|
16575 |
|
16576 |
|
16577 | boundaryElement.host = host;
|
16578 |
|
16579 | if (!attachers) {
|
16580 | host.attachers = attachers = [];
|
16581 | }
|
16582 |
|
16583 | if (attachers.indexOf(boundaryElement) === -1) {
|
16584 | attachers.push(boundaryElement);
|
16585 | }
|
16586 | };
|
16587 |
|
16588 |
|
16589 | |
16590 |
|
16591 |
|
16592 | BpmnImporter.prototype.addLabel = function(semantic, element) {
|
16593 | var bounds,
|
16594 | text,
|
16595 | label;
|
16596 |
|
16597 | bounds = getExternalLabelBounds(semantic, element);
|
16598 |
|
16599 | text = semantic.name;
|
16600 |
|
16601 | if (text) {
|
16602 |
|
16603 | bounds = this._textRenderer.getExternalLabelBounds(bounds, text);
|
16604 | }
|
16605 |
|
16606 | label = this._elementFactory.createLabel(elementData(semantic, {
|
16607 | id: semantic.id + '_label',
|
16608 | labelTarget: element,
|
16609 | type: 'label',
|
16610 | hidden: element.hidden || !semantic.name,
|
16611 | x: Math.round(bounds.x),
|
16612 | y: Math.round(bounds.y),
|
16613 | width: Math.round(bounds.width),
|
16614 | height: Math.round(bounds.height)
|
16615 | }));
|
16616 |
|
16617 | return this._canvas.addShape(label, element.parent);
|
16618 | };
|
16619 |
|
16620 | |
16621 |
|
16622 |
|
16623 |
|
16624 |
|
16625 | BpmnImporter.prototype._getEnd = function(semantic, side) {
|
16626 |
|
16627 | var element,
|
16628 | refSemantic,
|
16629 | type = semantic.$type,
|
16630 | translate = this._translate;
|
16631 |
|
16632 | refSemantic = semantic[side + 'Ref'];
|
16633 |
|
16634 |
|
16635 | if (side === 'source' && type === 'bpmn:DataInputAssociation') {
|
16636 | refSemantic = refSemantic && refSemantic[0];
|
16637 | }
|
16638 |
|
16639 |
|
16640 | if (side === 'source' && type === 'bpmn:DataOutputAssociation' ||
|
16641 | side === 'target' && type === 'bpmn:DataInputAssociation') {
|
16642 |
|
16643 | refSemantic = semantic.$parent;
|
16644 | }
|
16645 |
|
16646 | element = refSemantic && this._getElement(refSemantic);
|
16647 |
|
16648 | if (element) {
|
16649 | return element;
|
16650 | }
|
16651 |
|
16652 | if (refSemantic) {
|
16653 | throw notYetDrawn(translate, semantic, refSemantic, side + 'Ref');
|
16654 | } else {
|
16655 | throw new Error(translate('{semantic}#{side} Ref not specified', {
|
16656 | semantic: elementToString(semantic),
|
16657 | side: side
|
16658 | }));
|
16659 | }
|
16660 | };
|
16661 |
|
16662 | BpmnImporter.prototype._getSource = function(semantic) {
|
16663 | return this._getEnd(semantic, 'source');
|
16664 | };
|
16665 |
|
16666 | BpmnImporter.prototype._getTarget = function(semantic) {
|
16667 | return this._getEnd(semantic, 'target');
|
16668 | };
|
16669 |
|
16670 |
|
16671 | BpmnImporter.prototype._getElement = function(semantic) {
|
16672 | return this._elementRegistry.get(semantic.id);
|
16673 | };
|
16674 |
|
16675 |
|
16676 |
|
16677 |
|
16678 | function isPointInsideBBox$1(bbox, point) {
|
16679 | var x = point.x,
|
16680 | y = point.y;
|
16681 |
|
16682 | return x >= bbox.x &&
|
16683 | x <= bbox.x + bbox.width &&
|
16684 | y >= bbox.y &&
|
16685 | y <= bbox.y + bbox.height;
|
16686 | }
|
16687 |
|
16688 | var ImportModule = {
|
16689 | __depends__: [
|
16690 | translate$2
|
16691 | ],
|
16692 | bpmnImporter: [ 'type', BpmnImporter ]
|
16693 | };
|
16694 |
|
16695 | var CoreModule$1 = {
|
16696 | __depends__: [
|
16697 | DrawModule$1,
|
16698 | ImportModule
|
16699 | ]
|
16700 | };
|
16701 |
|
16702 | function getOriginal(event) {
|
16703 | return event.originalEvent || event.srcEvent;
|
16704 | }
|
16705 |
|
16706 | function isMac() {
|
16707 | return (/mac/i).test(navigator.platform);
|
16708 | }
|
16709 |
|
16710 | function isPrimaryButton(event) {
|
16711 |
|
16712 | return !(getOriginal(event) || event).button;
|
16713 | }
|
16714 |
|
16715 | function hasPrimaryModifier(event) {
|
16716 | var originalEvent = getOriginal(event) || event;
|
16717 |
|
16718 | if (!isPrimaryButton(event)) {
|
16719 | return false;
|
16720 | }
|
16721 |
|
16722 |
|
16723 | if (isMac()) {
|
16724 | return originalEvent.metaKey;
|
16725 | } else {
|
16726 | return originalEvent.ctrlKey;
|
16727 | }
|
16728 | }
|
16729 |
|
16730 | function allowAll(e) { return true; }
|
16731 |
|
16732 | var LOW_PRIORITY = 500;
|
16733 |
|
16734 | |
16735 |
|
16736 |
|
16737 |
|
16738 |
|
16739 |
|
16740 |
|
16741 |
|
16742 |
|
16743 |
|
16744 |
|
16745 |
|
16746 |
|
16747 |
|
16748 |
|
16749 |
|
16750 |
|
16751 |
|
16752 |
|
16753 | function InteractionEvents(eventBus, elementRegistry, styles) {
|
16754 |
|
16755 | var HIT_STYLE = styles.cls('djs-hit', [ 'no-fill', 'no-border' ], {
|
16756 | stroke: 'white',
|
16757 | strokeWidth: 15
|
16758 | });
|
16759 |
|
16760 | |
16761 |
|
16762 |
|
16763 |
|
16764 |
|
16765 |
|
16766 |
|
16767 |
|
16768 | function fire(type, event, element) {
|
16769 |
|
16770 | if (isIgnored(type, event)) {
|
16771 | return;
|
16772 | }
|
16773 |
|
16774 | var target, gfx, returnValue;
|
16775 |
|
16776 | if (!element) {
|
16777 | target = event.delegateTarget || event.target;
|
16778 |
|
16779 | if (target) {
|
16780 | gfx = target;
|
16781 | element = elementRegistry.get(gfx);
|
16782 | }
|
16783 | } else {
|
16784 | gfx = elementRegistry.getGraphics(element);
|
16785 | }
|
16786 |
|
16787 | if (!gfx || !element) {
|
16788 | return;
|
16789 | }
|
16790 |
|
16791 | returnValue = eventBus.fire(type, {
|
16792 | element: element,
|
16793 | gfx: gfx,
|
16794 | originalEvent: event
|
16795 | });
|
16796 |
|
16797 | if (returnValue === false) {
|
16798 | event.stopPropagation();
|
16799 | event.preventDefault();
|
16800 | }
|
16801 | }
|
16802 |
|
16803 |
|
16804 | var handlers = {};
|
16805 |
|
16806 | function mouseHandler(localEventName) {
|
16807 | return handlers[localEventName];
|
16808 | }
|
16809 |
|
16810 | function isIgnored(localEventName, event) {
|
16811 |
|
16812 | var filter$$1 = ignoredFilters[localEventName] || isPrimaryButton;
|
16813 |
|
16814 |
|
16815 |
|
16816 |
|
16817 | return !filter$$1(event);
|
16818 | }
|
16819 |
|
16820 | var bindings = {
|
16821 | mouseover: 'element.hover',
|
16822 | mouseout: 'element.out',
|
16823 | click: 'element.click',
|
16824 | dblclick: 'element.dblclick',
|
16825 | mousedown: 'element.mousedown',
|
16826 | mouseup: 'element.mouseup',
|
16827 | contextmenu: 'element.contextmenu'
|
16828 | };
|
16829 |
|
16830 | var ignoredFilters = {
|
16831 | 'element.contextmenu': allowAll
|
16832 | };
|
16833 |
|
16834 |
|
16835 |
|
16836 |
|
16837 | |
16838 |
|
16839 |
|
16840 |
|
16841 |
|
16842 |
|
16843 |
|
16844 |
|
16845 | function triggerMouseEvent(eventName, event, targetElement) {
|
16846 |
|
16847 |
|
16848 | var localEventName = bindings[eventName];
|
16849 |
|
16850 | if (!localEventName) {
|
16851 | throw new Error('unmapped DOM event name <' + eventName + '>');
|
16852 | }
|
16853 |
|
16854 | return fire(localEventName, event, targetElement);
|
16855 | }
|
16856 |
|
16857 |
|
16858 | var elementSelector = 'svg, .djs-element';
|
16859 |
|
16860 |
|
16861 |
|
16862 | function registerEvent(node, event, localEvent, ignoredFilter) {
|
16863 |
|
16864 | var handler = handlers[localEvent] = function(event) {
|
16865 | fire(localEvent, event);
|
16866 | };
|
16867 |
|
16868 | if (ignoredFilter) {
|
16869 | ignoredFilters[localEvent] = ignoredFilter;
|
16870 | }
|
16871 |
|
16872 | handler.$delegate = delegateEvents.bind(node, elementSelector, event, handler);
|
16873 | }
|
16874 |
|
16875 | function unregisterEvent(node, event, localEvent) {
|
16876 |
|
16877 | var handler = mouseHandler(localEvent);
|
16878 |
|
16879 | if (!handler) {
|
16880 | return;
|
16881 | }
|
16882 |
|
16883 | delegateEvents.unbind(node, event, handler.$delegate);
|
16884 | }
|
16885 |
|
16886 | function registerEvents(svg) {
|
16887 | forEach(bindings, function(val, key) {
|
16888 | registerEvent(svg, key, val);
|
16889 | });
|
16890 | }
|
16891 |
|
16892 | function unregisterEvents(svg) {
|
16893 | forEach(bindings, function(val, key) {
|
16894 | unregisterEvent(svg, key, val);
|
16895 | });
|
16896 | }
|
16897 |
|
16898 | eventBus.on('canvas.destroy', function(event) {
|
16899 | unregisterEvents(event.svg);
|
16900 | });
|
16901 |
|
16902 | eventBus.on('canvas.init', function(event) {
|
16903 | registerEvents(event.svg);
|
16904 | });
|
16905 |
|
16906 |
|
16907 | eventBus.on([ 'shape.added', 'connection.added' ], function(event) {
|
16908 | var element = event.element,
|
16909 | gfx = event.gfx,
|
16910 | hit;
|
16911 |
|
16912 | if (element.waypoints) {
|
16913 | hit = createLine(element.waypoints);
|
16914 | } else {
|
16915 | hit = create('rect');
|
16916 | attr$1(hit, {
|
16917 | x: 0,
|
16918 | y: 0,
|
16919 | width: element.width,
|
16920 | height: element.height
|
16921 | });
|
16922 | }
|
16923 |
|
16924 | attr$1(hit, HIT_STYLE);
|
16925 |
|
16926 | append(gfx, hit);
|
16927 | });
|
16928 |
|
16929 |
|
16930 |
|
16931 |
|
16932 | eventBus.on('shape.changed', LOW_PRIORITY, function(event) {
|
16933 |
|
16934 | var element = event.element,
|
16935 | gfx = event.gfx,
|
16936 | hit = query('.djs-hit', gfx);
|
16937 |
|
16938 | attr$1(hit, {
|
16939 | width: element.width,
|
16940 | height: element.height
|
16941 | });
|
16942 | });
|
16943 |
|
16944 | eventBus.on('connection.changed', function(event) {
|
16945 |
|
16946 | var element = event.element,
|
16947 | gfx = event.gfx,
|
16948 | hit = query('.djs-hit', gfx);
|
16949 |
|
16950 | updateLine(hit, element.waypoints);
|
16951 | });
|
16952 |
|
16953 |
|
16954 |
|
16955 |
|
16956 | this.fire = fire;
|
16957 |
|
16958 | this.triggerMouseEvent = triggerMouseEvent;
|
16959 |
|
16960 | this.mouseHandler = mouseHandler;
|
16961 |
|
16962 | this.registerEvent = registerEvent;
|
16963 | this.unregisterEvent = unregisterEvent;
|
16964 | }
|
16965 |
|
16966 |
|
16967 | InteractionEvents.$inject = [
|
16968 | 'eventBus',
|
16969 | 'elementRegistry',
|
16970 | 'styles'
|
16971 | ];
|
16972 |
|
16973 |
|
16974 | |
16975 |
|
16976 |
|
16977 |
|
16978 |
|
16979 |
|
16980 |
|
16981 |
|
16982 |
|
16983 |
|
16984 |
|
16985 | |
16986 |
|
16987 |
|
16988 |
|
16989 |
|
16990 |
|
16991 |
|
16992 |
|
16993 |
|
16994 |
|
16995 |
|
16996 | |
16997 |
|
16998 |
|
16999 |
|
17000 |
|
17001 |
|
17002 |
|
17003 |
|
17004 |
|
17005 |
|
17006 |
|
17007 | |
17008 |
|
17009 |
|
17010 |
|
17011 |
|
17012 |
|
17013 |
|
17014 |
|
17015 |
|
17016 |
|
17017 |
|
17018 | |
17019 |
|
17020 |
|
17021 |
|
17022 |
|
17023 |
|
17024 |
|
17025 |
|
17026 |
|
17027 |
|
17028 |
|
17029 | |
17030 |
|
17031 |
|
17032 |
|
17033 |
|
17034 |
|
17035 |
|
17036 |
|
17037 |
|
17038 |
|
17039 |
|
17040 | |
17041 |
|
17042 |
|
17043 |
|
17044 |
|
17045 |
|
17046 |
|
17047 |
|
17048 |
|
17049 |
|
17050 |
|
17051 |
|
17052 | var InteractionEventsModule = {
|
17053 | __init__: [ 'interactionEvents' ],
|
17054 | interactionEvents: [ 'type', InteractionEvents ]
|
17055 | };
|
17056 |
|
17057 | var LOW_PRIORITY$1 = 500;
|
17058 |
|
17059 |
|
17060 | |
17061 |
|
17062 |
|
17063 |
|
17064 |
|
17065 |
|
17066 |
|
17067 |
|
17068 |
|
17069 |
|
17070 | function Outline(eventBus, styles, elementRegistry) {
|
17071 |
|
17072 | this.offset = 6;
|
17073 |
|
17074 | var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
|
17075 |
|
17076 | var self = this;
|
17077 |
|
17078 | function createOutline(gfx, bounds) {
|
17079 | var outline = create('rect');
|
17080 |
|
17081 | attr$1(outline, assign({
|
17082 | x: 10,
|
17083 | y: 10,
|
17084 | width: 100,
|
17085 | height: 100
|
17086 | }, OUTLINE_STYLE));
|
17087 |
|
17088 | append(gfx, outline);
|
17089 |
|
17090 | return outline;
|
17091 | }
|
17092 |
|
17093 |
|
17094 |
|
17095 | eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$1, function(event) {
|
17096 | var element = event.element,
|
17097 | gfx = event.gfx;
|
17098 |
|
17099 | var outline = query('.djs-outline', gfx);
|
17100 |
|
17101 | if (!outline) {
|
17102 | outline = createOutline(gfx, element);
|
17103 | }
|
17104 |
|
17105 | self.updateShapeOutline(outline, element);
|
17106 | });
|
17107 |
|
17108 | eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
|
17109 | var element = event.element,
|
17110 | gfx = event.gfx;
|
17111 |
|
17112 | var outline = query('.djs-outline', gfx);
|
17113 |
|
17114 | if (!outline) {
|
17115 | outline = createOutline(gfx, element);
|
17116 | }
|
17117 |
|
17118 | self.updateConnectionOutline(outline, element);
|
17119 | });
|
17120 | }
|
17121 |
|
17122 |
|
17123 | |
17124 |
|
17125 |
|
17126 |
|
17127 |
|
17128 |
|
17129 |
|
17130 | Outline.prototype.updateShapeOutline = function(outline, element) {
|
17131 |
|
17132 | attr$1(outline, {
|
17133 | x: -this.offset,
|
17134 | y: -this.offset,
|
17135 | width: element.width + this.offset * 2,
|
17136 | height: element.height + this.offset * 2
|
17137 | });
|
17138 |
|
17139 | };
|
17140 |
|
17141 |
|
17142 | |
17143 |
|
17144 |
|
17145 |
|
17146 |
|
17147 |
|
17148 |
|
17149 | Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
17150 |
|
17151 | var bbox = getBBox(connection);
|
17152 |
|
17153 | attr$1(outline, {
|
17154 | x: bbox.x - this.offset,
|
17155 | y: bbox.y - this.offset,
|
17156 | width: bbox.width + this.offset * 2,
|
17157 | height: bbox.height + this.offset * 2
|
17158 | });
|
17159 |
|
17160 | };
|
17161 |
|
17162 |
|
17163 | Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
|
17164 |
|
17165 | var OutlineModule = {
|
17166 | __init__: [ 'outline' ],
|
17167 | outline: [ 'type', Outline ]
|
17168 | };
|
17169 |
|
17170 | |
17171 |
|
17172 |
|
17173 |
|
17174 |
|
17175 |
|
17176 |
|
17177 |
|
17178 | function Selection(eventBus) {
|
17179 |
|
17180 | this._eventBus = eventBus;
|
17181 |
|
17182 | this._selectedElements = [];
|
17183 |
|
17184 | var self = this;
|
17185 |
|
17186 | eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
|
17187 | var element = e.element;
|
17188 | self.deselect(element);
|
17189 | });
|
17190 |
|
17191 | eventBus.on([ 'diagram.clear' ], function(e) {
|
17192 | self.select(null);
|
17193 | });
|
17194 | }
|
17195 |
|
17196 | Selection.$inject = [ 'eventBus' ];
|
17197 |
|
17198 |
|
17199 | Selection.prototype.deselect = function(element) {
|
17200 | var selectedElements = this._selectedElements;
|
17201 |
|
17202 | var idx = selectedElements.indexOf(element);
|
17203 |
|
17204 | if (idx !== -1) {
|
17205 | var oldSelection = selectedElements.slice();
|
17206 |
|
17207 | selectedElements.splice(idx, 1);
|
17208 |
|
17209 | this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
17210 | }
|
17211 | };
|
17212 |
|
17213 |
|
17214 | Selection.prototype.get = function() {
|
17215 | return this._selectedElements;
|
17216 | };
|
17217 |
|
17218 | Selection.prototype.isSelected = function(element) {
|
17219 | return this._selectedElements.indexOf(element) !== -1;
|
17220 | };
|
17221 |
|
17222 |
|
17223 | |
17224 |
|
17225 |
|
17226 |
|
17227 |
|
17228 |
|
17229 |
|
17230 |
|
17231 |
|
17232 |
|
17233 |
|
17234 | Selection.prototype.select = function(elements, add) {
|
17235 | var selectedElements = this._selectedElements,
|
17236 | oldSelection = selectedElements.slice();
|
17237 |
|
17238 | if (!isArray(elements)) {
|
17239 | elements = elements ? [ elements ] : [];
|
17240 | }
|
17241 |
|
17242 |
|
17243 |
|
17244 | if (add) {
|
17245 | forEach(elements, function(element) {
|
17246 | if (selectedElements.indexOf(element) !== -1) {
|
17247 |
|
17248 | return;
|
17249 | } else {
|
17250 | selectedElements.push(element);
|
17251 | }
|
17252 | });
|
17253 | } else {
|
17254 | this._selectedElements = selectedElements = elements.slice();
|
17255 | }
|
17256 |
|
17257 | this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
17258 | };
|
17259 |
|
17260 | var MARKER_HOVER = 'hover',
|
17261 | MARKER_SELECTED = 'selected';
|
17262 |
|
17263 |
|
17264 | |
17265 |
|
17266 |
|
17267 |
|
17268 |
|
17269 |
|
17270 |
|
17271 |
|
17272 |
|
17273 |
|
17274 |
|
17275 |
|
17276 | function SelectionVisuals(events, canvas, selection, styles) {
|
17277 |
|
17278 | this._multiSelectionBox = null;
|
17279 |
|
17280 | function addMarker(e, cls) {
|
17281 | canvas.addMarker(e, cls);
|
17282 | }
|
17283 |
|
17284 | function removeMarker(e, cls) {
|
17285 | canvas.removeMarker(e, cls);
|
17286 | }
|
17287 |
|
17288 | events.on('element.hover', function(event) {
|
17289 | addMarker(event.element, MARKER_HOVER);
|
17290 | });
|
17291 |
|
17292 | events.on('element.out', function(event) {
|
17293 | removeMarker(event.element, MARKER_HOVER);
|
17294 | });
|
17295 |
|
17296 | events.on('selection.changed', function(event) {
|
17297 |
|
17298 | function deselect(s) {
|
17299 | removeMarker(s, MARKER_SELECTED);
|
17300 | }
|
17301 |
|
17302 | function select(s) {
|
17303 | addMarker(s, MARKER_SELECTED);
|
17304 | }
|
17305 |
|
17306 | var oldSelection = event.oldSelection,
|
17307 | newSelection = event.newSelection;
|
17308 |
|
17309 | forEach(oldSelection, function(e) {
|
17310 | if (newSelection.indexOf(e) === -1) {
|
17311 | deselect(e);
|
17312 | }
|
17313 | });
|
17314 |
|
17315 | forEach(newSelection, function(e) {
|
17316 | if (oldSelection.indexOf(e) === -1) {
|
17317 | select(e);
|
17318 | }
|
17319 | });
|
17320 | });
|
17321 | }
|
17322 |
|
17323 | SelectionVisuals.$inject = [
|
17324 | 'eventBus',
|
17325 | 'canvas',
|
17326 | 'selection',
|
17327 | 'styles'
|
17328 | ];
|
17329 |
|
17330 | function SelectionBehavior(
|
17331 | eventBus, selection, canvas,
|
17332 | elementRegistry) {
|
17333 |
|
17334 | eventBus.on('create.end', 500, function(e) {
|
17335 |
|
17336 |
|
17337 |
|
17338 | if (e.context.canExecute) {
|
17339 | selection.select(e.context.shape);
|
17340 | }
|
17341 | });
|
17342 |
|
17343 | eventBus.on('connect.end', 500, function(e) {
|
17344 |
|
17345 |
|
17346 |
|
17347 | if (e.context.canExecute && e.context.target) {
|
17348 | selection.select(e.context.target);
|
17349 | }
|
17350 | });
|
17351 |
|
17352 | eventBus.on('shape.move.end', 500, function(e) {
|
17353 | var previousSelection = e.previousSelection || [];
|
17354 |
|
17355 | var shape = elementRegistry.get(e.context.shape.id);
|
17356 |
|
17357 |
|
17358 |
|
17359 | var inSelection = find(previousSelection, function(selectedShape) {
|
17360 | return shape.id === selectedShape.id;
|
17361 | });
|
17362 |
|
17363 | if (!inSelection) {
|
17364 | selection.select(shape);
|
17365 | }
|
17366 | });
|
17367 |
|
17368 |
|
17369 | eventBus.on('element.click', function(event) {
|
17370 |
|
17371 | var element = event.element;
|
17372 |
|
17373 |
|
17374 |
|
17375 | if (element === canvas.getRootElement()) {
|
17376 | element = null;
|
17377 | }
|
17378 |
|
17379 | var isSelected = selection.isSelected(element),
|
17380 | isMultiSelect = selection.get().length > 1;
|
17381 |
|
17382 |
|
17383 | var add = hasPrimaryModifier(event);
|
17384 |
|
17385 |
|
17386 | if (isSelected && isMultiSelect) {
|
17387 | if (add) {
|
17388 | return selection.deselect(element);
|
17389 | } else {
|
17390 | return selection.select(element);
|
17391 | }
|
17392 | } else
|
17393 | if (!isSelected) {
|
17394 | selection.select(element, add);
|
17395 | } else {
|
17396 | selection.deselect(element);
|
17397 | }
|
17398 | });
|
17399 | }
|
17400 |
|
17401 | SelectionBehavior.$inject = [
|
17402 | 'eventBus',
|
17403 | 'selection',
|
17404 | 'canvas',
|
17405 | 'elementRegistry'
|
17406 | ];
|
17407 |
|
17408 | var SelectionModule = {
|
17409 | __init__: [ 'selectionVisuals', 'selectionBehavior' ],
|
17410 | __depends__: [
|
17411 | InteractionEventsModule,
|
17412 | OutlineModule
|
17413 | ],
|
17414 | selection: [ 'type', Selection ],
|
17415 | selectionVisuals: [ 'type', SelectionVisuals ],
|
17416 | selectionBehavior: [ 'type', SelectionBehavior ]
|
17417 | };
|
17418 |
|
17419 | |
17420 |
|
17421 |
|
17422 |
|
17423 |
|
17424 |
|
17425 |
|
17426 |
|
17427 |
|
17428 |
|
17429 |
|
17430 | function IdGenerator(prefix) {
|
17431 |
|
17432 | this._counter = 0;
|
17433 | this._prefix = (prefix ? prefix + '-' : '') + Math.floor(Math.random() * 1000000000) + '-';
|
17434 | }
|
17435 |
|
17436 | |
17437 |
|
17438 |
|
17439 |
|
17440 |
|
17441 |
|
17442 |
|
17443 | IdGenerator.prototype.next = function() {
|
17444 | return this._prefix + (++this._counter);
|
17445 | };
|
17446 |
|
17447 |
|
17448 | var ids$1 = new IdGenerator('ov');
|
17449 |
|
17450 | var LOW_PRIORITY$2 = 500;
|
17451 |
|
17452 |
|
17453 | |
17454 |
|
17455 |
|
17456 |
|
17457 |
|
17458 |
|
17459 |
|
17460 |
|
17461 |
|
17462 |
|
17463 |
|
17464 |
|
17465 |
|
17466 |
|
17467 |
|
17468 |
|
17469 |
|
17470 |
|
17471 |
|
17472 |
|
17473 |
|
17474 |
|
17475 |
|
17476 |
|
17477 |
|
17478 |
|
17479 |
|
17480 |
|
17481 |
|
17482 |
|
17483 |
|
17484 |
|
17485 |
|
17486 |
|
17487 |
|
17488 |
|
17489 |
|
17490 |
|
17491 |
|
17492 |
|
17493 |
|
17494 |
|
17495 |
|
17496 |
|
17497 |
|
17498 |
|
17499 |
|
17500 |
|
17501 |
|
17502 |
|
17503 |
|
17504 |
|
17505 |
|
17506 |
|
17507 |
|
17508 |
|
17509 |
|
17510 |
|
17511 |
|
17512 |
|
17513 |
|
17514 |
|
17515 |
|
17516 |
|
17517 | function Overlays(config, eventBus, canvas, elementRegistry) {
|
17518 |
|
17519 | this._eventBus = eventBus;
|
17520 | this._canvas = canvas;
|
17521 | this._elementRegistry = elementRegistry;
|
17522 |
|
17523 | this._ids = ids$1;
|
17524 |
|
17525 | this._overlayDefaults = assign({
|
17526 |
|
17527 | show: null,
|
17528 |
|
17529 |
|
17530 | scale: true
|
17531 | }, config && config.defaults);
|
17532 |
|
17533 | |
17534 |
|
17535 |
|
17536 | this._overlays = {};
|
17537 |
|
17538 | |
17539 |
|
17540 |
|
17541 | this._overlayContainers = [];
|
17542 |
|
17543 |
|
17544 | this._overlayRoot = createRoot(canvas.getContainer());
|
17545 |
|
17546 | this._init();
|
17547 | }
|
17548 |
|
17549 |
|
17550 | Overlays.$inject = [
|
17551 | 'config.overlays',
|
17552 | 'eventBus',
|
17553 | 'canvas',
|
17554 | 'elementRegistry'
|
17555 | ];
|
17556 |
|
17557 |
|
17558 | |
17559 |
|
17560 |
|
17561 |
|
17562 |
|
17563 |
|
17564 |
|
17565 |
|
17566 |
|
17567 |
|
17568 |
|
17569 |
|
17570 |
|
17571 |
|
17572 |
|
17573 |
|
17574 |
|
17575 |
|
17576 |
|
17577 |
|
17578 |
|
17579 |
|
17580 |
|
17581 |
|
17582 |
|
17583 |
|
17584 | Overlays.prototype.get = function(search) {
|
17585 |
|
17586 | if (isString(search)) {
|
17587 | search = { id: search };
|
17588 | }
|
17589 |
|
17590 | if (isString(search.element)) {
|
17591 | search.element = this._elementRegistry.get(search.element);
|
17592 | }
|
17593 |
|
17594 | if (search.element) {
|
17595 | var container = this._getOverlayContainer(search.element, true);
|
17596 |
|
17597 |
|
17598 | if (container) {
|
17599 | return search.type ? filter(container.overlays, matchPattern({ type: search.type })) : container.overlays.slice();
|
17600 | } else {
|
17601 | return [];
|
17602 | }
|
17603 | } else
|
17604 | if (search.type) {
|
17605 | return filter(this._overlays, matchPattern({ type: search.type }));
|
17606 | } else {
|
17607 |
|
17608 | return search.id ? this._overlays[search.id] : null;
|
17609 | }
|
17610 | };
|
17611 |
|
17612 | |
17613 |
|
17614 |
|
17615 |
|
17616 |
|
17617 |
|
17618 |
|
17619 |
|
17620 |
|
17621 |
|
17622 |
|
17623 |
|
17624 |
|
17625 |
|
17626 |
|
17627 |
|
17628 |
|
17629 |
|
17630 |
|
17631 |
|
17632 |
|
17633 |
|
17634 |
|
17635 | Overlays.prototype.add = function(element, type, overlay) {
|
17636 |
|
17637 | if (isObject(type)) {
|
17638 | overlay = type;
|
17639 | type = null;
|
17640 | }
|
17641 |
|
17642 | if (!element.id) {
|
17643 | element = this._elementRegistry.get(element);
|
17644 | }
|
17645 |
|
17646 | if (!overlay.position) {
|
17647 | throw new Error('must specifiy overlay position');
|
17648 | }
|
17649 |
|
17650 | if (!overlay.html) {
|
17651 | throw new Error('must specifiy overlay html');
|
17652 | }
|
17653 |
|
17654 | if (!element) {
|
17655 | throw new Error('invalid element specified');
|
17656 | }
|
17657 |
|
17658 | var id = this._ids.next();
|
17659 |
|
17660 | overlay = assign({}, this._overlayDefaults, overlay, {
|
17661 | id: id,
|
17662 | type: type,
|
17663 | element: element,
|
17664 | html: overlay.html
|
17665 | });
|
17666 |
|
17667 | this._addOverlay(overlay);
|
17668 |
|
17669 | return id;
|
17670 | };
|
17671 |
|
17672 |
|
17673 | |
17674 |
|
17675 |
|
17676 |
|
17677 |
|
17678 |
|
17679 |
|
17680 |
|
17681 | Overlays.prototype.remove = function(filter$$1) {
|
17682 |
|
17683 | var overlays = this.get(filter$$1) || [];
|
17684 |
|
17685 | if (!isArray(overlays)) {
|
17686 | overlays = [ overlays ];
|
17687 | }
|
17688 |
|
17689 | var self = this;
|
17690 |
|
17691 | forEach(overlays, function(overlay) {
|
17692 |
|
17693 | var container = self._getOverlayContainer(overlay.element, true);
|
17694 |
|
17695 | if (overlay) {
|
17696 | remove(overlay.html);
|
17697 | remove(overlay.htmlContainer);
|
17698 |
|
17699 | delete overlay.htmlContainer;
|
17700 | delete overlay.element;
|
17701 |
|
17702 | delete self._overlays[overlay.id];
|
17703 | }
|
17704 |
|
17705 | if (container) {
|
17706 | var idx = container.overlays.indexOf(overlay);
|
17707 | if (idx !== -1) {
|
17708 | container.overlays.splice(idx, 1);
|
17709 | }
|
17710 | }
|
17711 | });
|
17712 |
|
17713 | };
|
17714 |
|
17715 |
|
17716 | Overlays.prototype.show = function() {
|
17717 | setVisible(this._overlayRoot);
|
17718 | };
|
17719 |
|
17720 |
|
17721 | Overlays.prototype.hide = function() {
|
17722 | setVisible(this._overlayRoot, false);
|
17723 | };
|
17724 |
|
17725 | Overlays.prototype.clear = function() {
|
17726 | this._overlays = {};
|
17727 |
|
17728 | this._overlayContainers = [];
|
17729 |
|
17730 | clear(this._overlayRoot);
|
17731 | };
|
17732 |
|
17733 | Overlays.prototype._updateOverlayContainer = function(container) {
|
17734 | var element = container.element,
|
17735 | html = container.html;
|
17736 |
|
17737 |
|
17738 |
|
17739 |
|
17740 | var x = element.x,
|
17741 | y = element.y;
|
17742 |
|
17743 | if (element.waypoints) {
|
17744 | var bbox = getBBox(element);
|
17745 | x = bbox.x;
|
17746 | y = bbox.y;
|
17747 | }
|
17748 |
|
17749 | setPosition(html, x, y);
|
17750 |
|
17751 | attr(container.html, 'data-container-id', element.id);
|
17752 | };
|
17753 |
|
17754 |
|
17755 | Overlays.prototype._updateOverlay = function(overlay) {
|
17756 |
|
17757 | var position = overlay.position,
|
17758 | htmlContainer = overlay.htmlContainer,
|
17759 | element = overlay.element;
|
17760 |
|
17761 |
|
17762 |
|
17763 |
|
17764 |
|
17765 | var left = position.left,
|
17766 | top = position.top;
|
17767 |
|
17768 | if (position.right !== undefined) {
|
17769 |
|
17770 | var width;
|
17771 |
|
17772 | if (element.waypoints) {
|
17773 | width = getBBox(element).width;
|
17774 | } else {
|
17775 | width = element.width;
|
17776 | }
|
17777 |
|
17778 | left = position.right * -1 + width;
|
17779 | }
|
17780 |
|
17781 | if (position.bottom !== undefined) {
|
17782 |
|
17783 | var height;
|
17784 |
|
17785 | if (element.waypoints) {
|
17786 | height = getBBox(element).height;
|
17787 | } else {
|
17788 | height = element.height;
|
17789 | }
|
17790 |
|
17791 | top = position.bottom * -1 + height;
|
17792 | }
|
17793 |
|
17794 | setPosition(htmlContainer, left || 0, top || 0);
|
17795 | };
|
17796 |
|
17797 |
|
17798 | Overlays.prototype._createOverlayContainer = function(element) {
|
17799 | var html = domify('<div class="djs-overlays" style="position: absolute" />');
|
17800 |
|
17801 | this._overlayRoot.appendChild(html);
|
17802 |
|
17803 | var container = {
|
17804 | html: html,
|
17805 | element: element,
|
17806 | overlays: []
|
17807 | };
|
17808 |
|
17809 | this._updateOverlayContainer(container);
|
17810 |
|
17811 | this._overlayContainers.push(container);
|
17812 |
|
17813 | return container;
|
17814 | };
|
17815 |
|
17816 |
|
17817 | Overlays.prototype._updateRoot = function(viewbox) {
|
17818 | var scale = viewbox.scale || 1;
|
17819 |
|
17820 | var matrix = 'matrix(' +
|
17821 | [
|
17822 | scale,
|
17823 | 0,
|
17824 | 0,
|
17825 | scale,
|
17826 | -1 * viewbox.x * scale,
|
17827 | -1 * viewbox.y * scale
|
17828 | ].join(',') +
|
17829 | ')';
|
17830 |
|
17831 | setTransform(this._overlayRoot, matrix);
|
17832 | };
|
17833 |
|
17834 |
|
17835 | Overlays.prototype._getOverlayContainer = function(element, raw) {
|
17836 | var container = find(this._overlayContainers, function(c) {
|
17837 | return c.element === element;
|
17838 | });
|
17839 |
|
17840 |
|
17841 | if (!container && !raw) {
|
17842 | return this._createOverlayContainer(element);
|
17843 | }
|
17844 |
|
17845 | return container;
|
17846 | };
|
17847 |
|
17848 |
|
17849 | Overlays.prototype._addOverlay = function(overlay) {
|
17850 |
|
17851 | var id = overlay.id,
|
17852 | element = overlay.element,
|
17853 | html = overlay.html,
|
17854 | htmlContainer,
|
17855 | overlayContainer;
|
17856 |
|
17857 |
|
17858 | if (html.get && html.constructor.prototype.jquery) {
|
17859 | html = html.get(0);
|
17860 | }
|
17861 |
|
17862 |
|
17863 |
|
17864 | if (isString(html)) {
|
17865 | html = domify(html);
|
17866 | }
|
17867 |
|
17868 | overlayContainer = this._getOverlayContainer(element);
|
17869 |
|
17870 | htmlContainer = domify('<div class="djs-overlay" data-overlay-id="' + id + '" style="position: absolute">');
|
17871 |
|
17872 | htmlContainer.appendChild(html);
|
17873 |
|
17874 | if (overlay.type) {
|
17875 | classes(htmlContainer).add('djs-overlay-' + overlay.type);
|
17876 | }
|
17877 |
|
17878 | overlay.htmlContainer = htmlContainer;
|
17879 |
|
17880 | overlayContainer.overlays.push(overlay);
|
17881 | overlayContainer.html.appendChild(htmlContainer);
|
17882 |
|
17883 | this._overlays[id] = overlay;
|
17884 |
|
17885 | this._updateOverlay(overlay);
|
17886 | this._updateOverlayVisibilty(overlay, this._canvas.viewbox());
|
17887 | };
|
17888 |
|
17889 |
|
17890 | Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
|
17891 | var show = overlay.show,
|
17892 | minZoom = show && show.minZoom,
|
17893 | maxZoom = show && show.maxZoom,
|
17894 | htmlContainer = overlay.htmlContainer,
|
17895 | visible = true;
|
17896 |
|
17897 | if (show) {
|
17898 | if (
|
17899 | (isDefined(minZoom) && minZoom > viewbox.scale) ||
|
17900 | (isDefined(maxZoom) && maxZoom < viewbox.scale)
|
17901 | ) {
|
17902 | visible = false;
|
17903 | }
|
17904 |
|
17905 | setVisible(htmlContainer, visible);
|
17906 | }
|
17907 |
|
17908 | this._updateOverlayScale(overlay, viewbox);
|
17909 | };
|
17910 |
|
17911 |
|
17912 | Overlays.prototype._updateOverlayScale = function(overlay, viewbox) {
|
17913 | var shouldScale = overlay.scale,
|
17914 | minScale,
|
17915 | maxScale,
|
17916 | htmlContainer = overlay.htmlContainer;
|
17917 |
|
17918 | var scale, transform = '';
|
17919 |
|
17920 | if (shouldScale !== true) {
|
17921 |
|
17922 | if (shouldScale === false) {
|
17923 | minScale = 1;
|
17924 | maxScale = 1;
|
17925 | } else {
|
17926 | minScale = shouldScale.min;
|
17927 | maxScale = shouldScale.max;
|
17928 | }
|
17929 |
|
17930 | if (isDefined(minScale) && viewbox.scale < minScale) {
|
17931 | scale = (1 / viewbox.scale || 1) * minScale;
|
17932 | }
|
17933 |
|
17934 | if (isDefined(maxScale) && viewbox.scale > maxScale) {
|
17935 | scale = (1 / viewbox.scale || 1) * maxScale;
|
17936 | }
|
17937 | }
|
17938 |
|
17939 | if (isDefined(scale)) {
|
17940 | transform = 'scale(' + scale + ',' + scale + ')';
|
17941 | }
|
17942 |
|
17943 | setTransform(htmlContainer, transform);
|
17944 | };
|
17945 |
|
17946 |
|
17947 | Overlays.prototype._updateOverlaysVisibilty = function(viewbox) {
|
17948 |
|
17949 | var self = this;
|
17950 |
|
17951 | forEach(this._overlays, function(overlay) {
|
17952 | self._updateOverlayVisibilty(overlay, viewbox);
|
17953 | });
|
17954 | };
|
17955 |
|
17956 |
|
17957 | Overlays.prototype._init = function() {
|
17958 |
|
17959 | var eventBus = this._eventBus;
|
17960 |
|
17961 | var self = this;
|
17962 |
|
17963 |
|
17964 |
|
17965 |
|
17966 | function updateViewbox(viewbox) {
|
17967 | self._updateRoot(viewbox);
|
17968 | self._updateOverlaysVisibilty(viewbox);
|
17969 |
|
17970 | self.show();
|
17971 | }
|
17972 |
|
17973 | eventBus.on('canvas.viewbox.changing', function(event) {
|
17974 | self.hide();
|
17975 | });
|
17976 |
|
17977 | eventBus.on('canvas.viewbox.changed', function(event) {
|
17978 | updateViewbox(event.viewbox);
|
17979 | });
|
17980 |
|
17981 |
|
17982 |
|
17983 |
|
17984 | eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
|
17985 | var element = e.element;
|
17986 | var overlays = self.get({ element: element });
|
17987 |
|
17988 | forEach(overlays, function(o) {
|
17989 | self.remove(o.id);
|
17990 | });
|
17991 |
|
17992 | var container = self._getOverlayContainer(element);
|
17993 |
|
17994 | if (container) {
|
17995 | remove(container.html);
|
17996 | var i = self._overlayContainers.indexOf(container);
|
17997 | if (i !== -1) {
|
17998 | self._overlayContainers.splice(i, 1);
|
17999 | }
|
18000 | }
|
18001 | });
|
18002 |
|
18003 |
|
18004 |
|
18005 |
|
18006 | eventBus.on('element.changed', LOW_PRIORITY$2, function(e) {
|
18007 | var element = e.element;
|
18008 |
|
18009 | var container = self._getOverlayContainer(element, true);
|
18010 |
|
18011 | if (container) {
|
18012 | forEach(container.overlays, function(overlay) {
|
18013 | self._updateOverlay(overlay);
|
18014 | });
|
18015 |
|
18016 | self._updateOverlayContainer(container);
|
18017 | }
|
18018 | });
|
18019 |
|
18020 |
|
18021 |
|
18022 |
|
18023 | eventBus.on('element.marker.update', function(e) {
|
18024 | var container = self._getOverlayContainer(e.element, true);
|
18025 | if (container) {
|
18026 | classes(container.html)[e.add ? 'add' : 'remove'](e.marker);
|
18027 | }
|
18028 | });
|
18029 |
|
18030 |
|
18031 |
|
18032 |
|
18033 | eventBus.on('diagram.clear', this.clear, this);
|
18034 | };
|
18035 |
|
18036 |
|
18037 |
|
18038 |
|
18039 |
|
18040 | function createRoot(parent) {
|
18041 | var root = domify('<div class="djs-overlay-container" style="position: absolute; width: 0; height: 0;" />');
|
18042 | parent.insertBefore(root, parent.firstChild);
|
18043 |
|
18044 | return root;
|
18045 | }
|
18046 |
|
18047 | function setPosition(el, x, y) {
|
18048 | assign(el.style, { left: x + 'px', top: y + 'px' });
|
18049 | }
|
18050 |
|
18051 | function setVisible(el, visible) {
|
18052 | el.style.display = visible === false ? 'none' : '';
|
18053 | }
|
18054 |
|
18055 | function setTransform(el, transform) {
|
18056 |
|
18057 | el.style['transform-origin'] = 'top left';
|
18058 |
|
18059 | [ '', '-ms-', '-webkit-' ].forEach(function(prefix) {
|
18060 | el.style[prefix + 'transform'] = transform;
|
18061 | });
|
18062 | }
|
18063 |
|
18064 | var OverlaysModule = {
|
18065 | __init__: [ 'overlays' ],
|
18066 | overlays: [ 'type', Overlays ]
|
18067 | };
|
18068 |
|
18069 | |
18070 |
|
18071 |
|
18072 |
|
18073 |
|
18074 |
|
18075 |
|
18076 |
|
18077 | var BPMNIO_LOGO_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 960"><path fill="#fff" d="M960 60v839c0 33-27 61-60 61H60c-33 0-60-27-60-60V60C0 27 27 0 60 0h839c34 0 61 27 61 60z"/><path fill="#52b415" d="M217 548a205 205 0 0 0-144 58 202 202 0 0 0-4 286 202 202 0 0 0 285 3 200 200 0 0 0 48-219 203 203 0 0 0-185-128zM752 6a206 206 0 0 0-192 285 206 206 0 0 0 269 111 207 207 0 0 0 111-260A204 204 0 0 0 752 6zM62 0A62 62 0 0 0 0 62v398l60 46a259 259 0 0 1 89-36c5-28 10-57 14-85l99 2 12 85a246 246 0 0 1 88 38l70-52 69 71-52 68c17 30 29 58 35 90l86 14-2 100-86 12a240 240 0 0 1-38 89l43 58h413c37 0 60-27 60-61V407a220 220 0 0 1-44 40l21 85-93 39-45-76a258 258 0 0 1-98 1l-45 76-94-39 22-85a298 298 0 0 1-70-69l-86 22-38-94 76-45a258 258 0 0 1-1-98l-76-45 40-94 85 22a271 271 0 0 1 41-47z"/></svg>';
|
18078 |
|
18079 | var BPMNIO_LOGO_URL = 'data:image/svg+xml,' + encodeURIComponent(BPMNIO_LOGO_SVG);
|
18080 |
|
18081 | var BPMNIO_IMG = '<img width="52" height="52" src="' + BPMNIO_LOGO_URL + '" />';
|
18082 |
|
18083 | function css(attrs) {
|
18084 | return attrs.join(';');
|
18085 | }
|
18086 |
|
18087 | var LIGHTBOX_STYLES = css([
|
18088 | 'z-index: 1001',
|
18089 | 'position: fixed',
|
18090 | 'top: 0',
|
18091 | 'left: 0',
|
18092 | 'right: 0',
|
18093 | 'bottom: 0'
|
18094 | ]);
|
18095 |
|
18096 | var BACKDROP_STYLES = css([
|
18097 | 'width: 100%',
|
18098 | 'height: 100%',
|
18099 | 'background: rgba(0,0,0,0.2)'
|
18100 | ]);
|
18101 |
|
18102 | var NOTICE_STYLES = css([
|
18103 | 'position: absolute',
|
18104 | 'left: 50%',
|
18105 | 'top: 40%',
|
18106 | 'margin: 0 -130px',
|
18107 | 'width: 260px',
|
18108 | 'padding: 10px',
|
18109 | 'background: white',
|
18110 | 'border: solid 1px #AAA',
|
18111 | 'border-radius: 3px',
|
18112 | 'font-family: Helvetica, Arial, sans-serif',
|
18113 | 'font-size: 14px',
|
18114 | 'line-height: 1.2em'
|
18115 | ]);
|
18116 |
|
18117 | var LIGHTBOX_MARKUP =
|
18118 | '<div class="bjs-powered-by-lightbox" style="' + LIGHTBOX_STYLES + '">' +
|
18119 | '<div class="backdrop" style="' + BACKDROP_STYLES + '"></div>' +
|
18120 | '<div class="notice" style="' + NOTICE_STYLES + '">' +
|
18121 | '<a href="http://bpmn.io" target="_blank" style="float: left; margin-right: 10px">' +
|
18122 | BPMNIO_IMG +
|
18123 | '</a>' +
|
18124 | 'Web-based tooling for BPMN, DMN and CMMN diagrams ' +
|
18125 | 'powered by <a href="http://bpmn.io" target="_blank">bpmn.io</a>.' +
|
18126 | '</div>' +
|
18127 | '</div>';
|
18128 |
|
18129 |
|
18130 | var lightbox;
|
18131 |
|
18132 | function open() {
|
18133 |
|
18134 | if (!lightbox) {
|
18135 | lightbox = domify(LIGHTBOX_MARKUP);
|
18136 |
|
18137 | delegateEvents.bind(lightbox, '.backdrop', 'click', function(event) {
|
18138 | document.body.removeChild(lightbox);
|
18139 | });
|
18140 | }
|
18141 |
|
18142 | document.body.appendChild(lightbox);
|
18143 | }
|
18144 |
|
18145 | |
18146 |
|
18147 |
|
18148 |
|
18149 |
|
18150 |
|
18151 |
|
18152 |
|
18153 | function checkValidationError(err) {
|
18154 |
|
18155 |
|
18156 |
|
18157 |
|
18158 | var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
|
18159 | var match = pattern.exec(err.message);
|
18160 |
|
18161 | if (match) {
|
18162 | err.message =
|
18163 | 'unparsable content <' + match[1] + '> detected; ' +
|
18164 | 'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
|
18165 | }
|
18166 |
|
18167 | return err;
|
18168 | }
|
18169 |
|
18170 | var DEFAULT_OPTIONS = {
|
18171 | width: '100%',
|
18172 | height: '100%',
|
18173 | position: 'relative'
|
18174 | };
|
18175 |
|
18176 |
|
18177 | |
18178 |
|
18179 |
|
18180 | function ensureUnit(val) {
|
18181 | return val + (isNumber(val) ? 'px' : '');
|
18182 | }
|
18183 |
|
18184 | |
18185 |
|
18186 |
|
18187 |
|
18188 |
|
18189 |
|
18190 |
|
18191 |
|
18192 |
|
18193 |
|
18194 |
|
18195 |
|
18196 |
|
18197 |
|
18198 |
|
18199 |
|
18200 |
|
18201 |
|
18202 |
|
18203 |
|
18204 |
|
18205 |
|
18206 |
|
18207 |
|
18208 |
|
18209 |
|
18210 |
|
18211 |
|
18212 |
|
18213 |
|
18214 |
|
18215 |
|
18216 |
|
18217 |
|
18218 |
|
18219 |
|
18220 |
|
18221 |
|
18222 |
|
18223 |
|
18224 |
|
18225 |
|
18226 |
|
18227 |
|
18228 |
|
18229 |
|
18230 |
|
18231 | function Viewer(options) {
|
18232 |
|
18233 | options = assign({}, DEFAULT_OPTIONS, options);
|
18234 |
|
18235 | this._moddle = this._createModdle(options);
|
18236 |
|
18237 | this._container = this._createContainer(options);
|
18238 |
|
18239 |
|
18240 |
|
18241 | addProjectLogo(this._container);
|
18242 |
|
18243 |
|
18244 |
|
18245 | this._init(this._container, this._moddle, options);
|
18246 | }
|
18247 |
|
18248 | inherits_browser(Viewer, diagramJs);
|
18249 |
|
18250 |
|
18251 | |
18252 |
|
18253 |
|
18254 |
|
18255 |
|
18256 |
|
18257 |
|
18258 |
|
18259 |
|
18260 |
|
18261 |
|
18262 |
|
18263 |
|
18264 |
|
18265 |
|
18266 |
|
18267 |
|
18268 |
|
18269 |
|
18270 |
|
18271 |
|
18272 | Viewer.prototype.importXML = function(xml, done) {
|
18273 |
|
18274 |
|
18275 | done = done || function() {};
|
18276 |
|
18277 | var self = this;
|
18278 |
|
18279 |
|
18280 |
|
18281 | xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
18282 |
|
18283 | this._moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
18284 |
|
18285 |
|
18286 |
|
18287 | definitions = self._emit('import.parse.complete', {
|
18288 | error: err,
|
18289 | definitions: definitions,
|
18290 | context: context
|
18291 | }) || definitions;
|
18292 |
|
18293 | var parseWarnings = context.warnings;
|
18294 |
|
18295 | if (err) {
|
18296 | err = checkValidationError(err);
|
18297 |
|
18298 | self._emit('import.done', { error: err, warnings: parseWarnings });
|
18299 |
|
18300 | return done(err, parseWarnings);
|
18301 | }
|
18302 |
|
18303 | self.importDefinitions(definitions, function(err, importWarnings) {
|
18304 | var allWarnings = [].concat(parseWarnings, importWarnings || []);
|
18305 |
|
18306 | self._emit('import.done', { error: err, warnings: allWarnings });
|
18307 |
|
18308 | done(err, allWarnings);
|
18309 | });
|
18310 | });
|
18311 | };
|
18312 |
|
18313 | |
18314 |
|
18315 |
|
18316 |
|
18317 |
|
18318 |
|
18319 |
|
18320 |
|
18321 |
|
18322 |
|
18323 |
|
18324 |
|
18325 |
|
18326 |
|
18327 |
|
18328 |
|
18329 |
|
18330 |
|
18331 |
|
18332 |
|
18333 | Viewer.prototype.saveXML = function(options, done) {
|
18334 |
|
18335 | if (!done) {
|
18336 | done = options;
|
18337 | options = {};
|
18338 | }
|
18339 |
|
18340 | var self = this;
|
18341 |
|
18342 | var definitions = this._definitions;
|
18343 |
|
18344 | if (!definitions) {
|
18345 | return done(new Error('no definitions loaded'));
|
18346 | }
|
18347 |
|
18348 |
|
18349 | definitions = this._emit('saveXML.start', {
|
18350 | definitions: definitions
|
18351 | }) || definitions;
|
18352 |
|
18353 | this._moddle.toXML(definitions, options, function(err, xml) {
|
18354 |
|
18355 | try {
|
18356 | xml = self._emit('saveXML.serialized', {
|
18357 | error: err,
|
18358 | xml: xml
|
18359 | }) || xml;
|
18360 |
|
18361 | self._emit('saveXML.done', {
|
18362 | error: err,
|
18363 | xml: xml
|
18364 | });
|
18365 | } catch (e) {
|
18366 | console.error('error in saveXML life-cycle listener', e);
|
18367 | }
|
18368 |
|
18369 | done(err, xml);
|
18370 | });
|
18371 | };
|
18372 |
|
18373 | |
18374 |
|
18375 |
|
18376 |
|
18377 |
|
18378 |
|
18379 |
|
18380 |
|
18381 |
|
18382 |
|
18383 |
|
18384 |
|
18385 |
|
18386 |
|
18387 |
|
18388 |
|
18389 | Viewer.prototype.saveSVG = function(options, done) {
|
18390 |
|
18391 | if (!done) {
|
18392 | done = options;
|
18393 | options = {};
|
18394 | }
|
18395 |
|
18396 | this._emit('saveSVG.start');
|
18397 |
|
18398 | var svg, err;
|
18399 |
|
18400 | try {
|
18401 | var canvas = this.get('canvas');
|
18402 |
|
18403 | var contentNode = canvas.getDefaultLayer(),
|
18404 | defsNode = query('defs', canvas._svg);
|
18405 |
|
18406 | var contents = innerSVG(contentNode),
|
18407 | defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
|
18408 |
|
18409 | var bbox = contentNode.getBBox();
|
18410 |
|
18411 | svg =
|
18412 | '<?xml version="1.0" encoding="utf-8"?>\n' +
|
18413 | '<!-- created with bpmn-js / http://bpmn.io -->\n' +
|
18414 | '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
18415 | '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
18416 | 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
|
18417 | 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
|
18418 | defs + contents +
|
18419 | '</svg>';
|
18420 | } catch (e) {
|
18421 | err = e;
|
18422 | }
|
18423 |
|
18424 | this._emit('saveSVG.done', {
|
18425 | error: err,
|
18426 | svg: svg
|
18427 | });
|
18428 |
|
18429 | done(err, svg);
|
18430 | };
|
18431 |
|
18432 | |
18433 |
|
18434 |
|
18435 |
|
18436 |
|
18437 |
|
18438 |
|
18439 |
|
18440 |
|
18441 |
|
18442 |
|
18443 |
|
18444 |
|
18445 |
|
18446 |
|
18447 | |
18448 |
|
18449 |
|
18450 |
|
18451 |
|
18452 |
|
18453 |
|
18454 |
|
18455 |
|
18456 |
|
18457 |
|
18458 |
|
18459 |
|
18460 |
|
18461 |
|
18462 |
|
18463 | |
18464 |
|
18465 |
|
18466 |
|
18467 |
|
18468 |
|
18469 |
|
18470 |
|
18471 |
|
18472 | Viewer.prototype.importDefinitions = function(definitions, done) {
|
18473 |
|
18474 |
|
18475 | try {
|
18476 | if (this._definitions) {
|
18477 |
|
18478 | this.clear();
|
18479 | }
|
18480 |
|
18481 |
|
18482 | this._definitions = definitions;
|
18483 | } catch (e) {
|
18484 | return done(e);
|
18485 | }
|
18486 |
|
18487 |
|
18488 | return importBpmnDiagram(this, definitions, done);
|
18489 | };
|
18490 |
|
18491 | Viewer.prototype.getModules = function() {
|
18492 | return this._modules;
|
18493 | };
|
18494 |
|
18495 | |
18496 |
|
18497 |
|
18498 |
|
18499 | Viewer.prototype.destroy = function() {
|
18500 |
|
18501 |
|
18502 | diagramJs.prototype.destroy.call(this);
|
18503 |
|
18504 |
|
18505 | remove(this._container);
|
18506 | };
|
18507 |
|
18508 | |
18509 |
|
18510 |
|
18511 |
|
18512 |
|
18513 |
|
18514 |
|
18515 |
|
18516 |
|
18517 |
|
18518 | Viewer.prototype.on = function(event$$1, priority, callback, target) {
|
18519 | return this.get('eventBus').on(event$$1, priority, callback, target);
|
18520 | };
|
18521 |
|
18522 | |
18523 |
|
18524 |
|
18525 |
|
18526 |
|
18527 |
|
18528 | Viewer.prototype.off = function(event$$1, callback) {
|
18529 | this.get('eventBus').off(event$$1, callback);
|
18530 | };
|
18531 |
|
18532 | Viewer.prototype.attachTo = function(parentNode) {
|
18533 |
|
18534 | if (!parentNode) {
|
18535 | throw new Error('parentNode required');
|
18536 | }
|
18537 |
|
18538 |
|
18539 |
|
18540 | this.detach();
|
18541 |
|
18542 |
|
18543 | if (parentNode.get && parentNode.constructor.prototype.jquery) {
|
18544 | parentNode = parentNode.get(0);
|
18545 | }
|
18546 |
|
18547 | if (typeof parentNode === 'string') {
|
18548 | parentNode = query(parentNode);
|
18549 | }
|
18550 |
|
18551 | parentNode.appendChild(this._container);
|
18552 |
|
18553 | this._emit('attach', {});
|
18554 |
|
18555 | this.get('canvas').resized();
|
18556 | };
|
18557 |
|
18558 | Viewer.prototype.getDefinitions = function() {
|
18559 | return this._definitions;
|
18560 | };
|
18561 |
|
18562 | Viewer.prototype.detach = function() {
|
18563 |
|
18564 | var container = this._container,
|
18565 | parentNode = container.parentNode;
|
18566 |
|
18567 | if (!parentNode) {
|
18568 | return;
|
18569 | }
|
18570 |
|
18571 | this._emit('detach', {});
|
18572 |
|
18573 | parentNode.removeChild(container);
|
18574 | };
|
18575 |
|
18576 | Viewer.prototype._init = function(container, moddle, options) {
|
18577 |
|
18578 | var baseModules = options.modules || this.getModules(),
|
18579 | additionalModules = options.additionalModules || [],
|
18580 | staticModules = [
|
18581 | {
|
18582 | bpmnjs: [ 'value', this ],
|
18583 | moddle: [ 'value', moddle ]
|
18584 | }
|
18585 | ];
|
18586 |
|
18587 | var diagramModules = [].concat(staticModules, baseModules, additionalModules);
|
18588 |
|
18589 | var diagramOptions = assign(omit(options, [ 'additionalModules' ]), {
|
18590 | canvas: assign({}, options.canvas, { container: container }),
|
18591 | modules: diagramModules
|
18592 | });
|
18593 |
|
18594 |
|
18595 | diagramJs.call(this, diagramOptions);
|
18596 |
|
18597 | if (options && options.container) {
|
18598 | this.attachTo(options.container);
|
18599 | }
|
18600 | };
|
18601 |
|
18602 | |
18603 |
|
18604 |
|
18605 |
|
18606 |
|
18607 |
|
18608 |
|
18609 |
|
18610 | Viewer.prototype._emit = function(type, event$$1) {
|
18611 | return this.get('eventBus').fire(type, event$$1);
|
18612 | };
|
18613 |
|
18614 | Viewer.prototype._createContainer = function(options) {
|
18615 |
|
18616 | var container = domify('<div class="bjs-container"></div>');
|
18617 |
|
18618 | assign(container.style, {
|
18619 | width: ensureUnit(options.width),
|
18620 | height: ensureUnit(options.height),
|
18621 | position: options.position
|
18622 | });
|
18623 |
|
18624 | return container;
|
18625 | };
|
18626 |
|
18627 | Viewer.prototype._createModdle = function(options) {
|
18628 | var moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
|
18629 |
|
18630 | return new BpmnModdle$1(moddleOptions);
|
18631 | };
|
18632 |
|
18633 |
|
18634 | Viewer.prototype._modules = [
|
18635 | CoreModule$1,
|
18636 | translate$2,
|
18637 | SelectionModule,
|
18638 | OverlaysModule
|
18639 | ];
|
18640 |
|
18641 |
|
18642 | Viewer.prototype._moddleExtensions = {};
|
18643 |
|
18644 | |
18645 |
|
18646 |
|
18647 |
|
18648 |
|
18649 |
|
18650 |
|
18651 |
|
18652 | function addProjectLogo(container) {
|
18653 | var img = BPMNIO_IMG;
|
18654 |
|
18655 | var linkMarkup =
|
18656 | '<a href="http://bpmn.io" ' +
|
18657 | 'target="_blank" ' +
|
18658 | 'class="bjs-powered-by" ' +
|
18659 | 'title="Powered by bpmn.io" ' +
|
18660 | 'style="position: absolute; bottom: 15px; right: 15px; z-index: 100">' +
|
18661 | img +
|
18662 | '</a>';
|
18663 |
|
18664 | var linkElement = domify(linkMarkup);
|
18665 |
|
18666 | container.appendChild(linkElement);
|
18667 |
|
18668 | componentEvent.bind(linkElement, 'click', function(event$$1) {
|
18669 | open();
|
18670 |
|
18671 | event$$1.preventDefault();
|
18672 | });
|
18673 | }
|
18674 |
|
18675 |
|
18676 |
|
18677 | return Viewer;
|
18678 |
|
18679 | })));
|