bpmn-js 0.13.1 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +1 -1
- package/.wiredeps +5 -5
- package/lib/Modeler.js +52 -9
- package/lib/Viewer.js +205 -105
- package/lib/draw/BpmnRenderer.js +4 -0
- package/lib/features/context-pad/ContextPadProvider.js +21 -15
- package/lib/features/label-editing/LabelEditingProvider.js +21 -6
- package/lib/features/label-editing/LabelUtil.js +6 -6
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +19 -17
- package/lib/features/modeling/BpmnUpdater.js +12 -4
- package/lib/features/modeling/ElementFactory.js +25 -11
- package/lib/features/modeling/{BpmnLabelSupport.js → behavior/LabelBehavior.js} +14 -4
- package/lib/features/modeling/behavior/ModelingFeedback.js +3 -3
- package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +4 -4
- package/lib/features/modeling/behavior/index.js +2 -0
- package/lib/features/modeling/cmd/SplitLaneHandler.js +6 -4
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +6 -0
- package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +6 -0
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +6 -4
- package/lib/features/modeling/index.js +1 -2
- package/lib/features/ordering/BpmnOrderingProvider.js +7 -4
- package/lib/features/ordering/index.js +3 -0
- package/lib/features/palette/PaletteProvider.js +13 -9
- package/lib/features/palette/index.js +2 -1
- package/lib/features/popup-menu/ReplaceMenuProvider.js +22 -10
- package/lib/features/popup-menu/index.js +4 -0
- package/lib/features/replace/BpmnReplace.js +17 -1
- package/lib/features/replace/ReplaceOptions.js +22 -0
- package/lib/features/replace/index.js +0 -1
- package/lib/features/rules/BpmnRules.js +14 -0
- package/lib/features/snapping/BpmnSnapping.js +2 -2
- package/lib/import/BpmnImporter.js +30 -18
- package/lib/import/BpmnTreeWalker.js +42 -15
- package/lib/import/Importer.js +19 -7
- package/lib/import/index.js +3 -0
- package/package.json +8 -7
- package/test/fixtures/bpmn/extension/custom-override.bpmn +54 -0
- package/test/fixtures/bpmn/extension/custom.bpmn +54 -0
- package/test/fixtures/bpmn/features/modeling/update-label.bpmn +24 -0
- package/test/fixtures/json/model/custom-override.json +39 -0
- package/test/fixtures/json/model/custom.json +39 -0
- package/test/helper/index.js +6 -1
- package/test/integration/ReimportSpec.js +89 -0
- package/test/spec/ModelerSpec.js +155 -9
- package/test/spec/ViewerSpec.js +328 -43
- package/test/spec/features/context-pad/ContextPadProviderSpec.js +5 -5
- package/test/spec/features/label-editing/LabelEditingProviderSpec.js +201 -128
- package/test/spec/features/modeling/AppendShapeSpec.js +0 -43
- package/test/spec/features/modeling/UpdateLabelSpec.js +129 -0
- package/test/spec/features/modeling/append/TextAnnotationSpec.js +13 -0
- package/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +144 -0
- package/test/spec/features/modeling/layout/LayoutAssociationSpec.js +3 -3
- package/test/spec/features/ordering/BpmnOrderingProviderSpec.js +41 -2
- package/test/spec/features/ordering/ordering-subprocesses.bpmn +14 -2
- package/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +0 -4
- package/test/spec/features/replace/BpmnReplace.collaboration.bpmn +70 -0
- package/test/spec/features/replace/BpmnReplaceSpec.js +37 -0
- package/test/spec/features/rules/BpmnRules.collaboration.bpmn +6 -1
- package/test/spec/features/rules/BpmnRulesSpec.js +32 -0
- package/test/spec/features/snapping/BpmnSnappingSpec.js +16 -6
- package/test/spec/i18n/custom-translate/custom-translate.js +15 -0
- package/test/spec/i18n/custom-translate/index.js +3 -0
- package/test/spec/i18n/translateSpec.js +53 -0
- package/test/spec/import/ImporterSpec.js +3 -3
- package/test/spec/features/modeling/BpmnLabelSupportSpec.js +0 -37
|
@@ -17,7 +17,7 @@ var find = require('lodash/collection/find');
|
|
|
17
17
|
* (1) elements are ordered by a {level} property
|
|
18
18
|
* (2) elements with {alwaysOnTop} are always added to the root
|
|
19
19
|
*/
|
|
20
|
-
function BpmnOrderingProvider(eventBus) {
|
|
20
|
+
function BpmnOrderingProvider(eventBus, translate) {
|
|
21
21
|
|
|
22
22
|
OrderingProvider.call(this, eventBus);
|
|
23
23
|
|
|
@@ -53,7 +53,7 @@ function BpmnOrderingProvider(eventBus) {
|
|
|
53
53
|
|
|
54
54
|
function computeOrder(element) {
|
|
55
55
|
var entry = find(orders, function(o) {
|
|
56
|
-
return element
|
|
56
|
+
return isAny(element, [ o.type ]);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
return entry && entry.order || { level: 1 };
|
|
@@ -84,7 +84,10 @@ function BpmnOrderingProvider(eventBus) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
if (!actualParent) {
|
|
87
|
-
throw new Error('no parent for
|
|
87
|
+
throw new Error(translate('no parent for {element} in {parent}', {
|
|
88
|
+
element: element.id,
|
|
89
|
+
parent: newParent.id
|
|
90
|
+
}));
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
return actualParent;
|
|
@@ -132,7 +135,7 @@ function BpmnOrderingProvider(eventBus) {
|
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
137
|
|
|
135
|
-
BpmnOrderingProvider.$inject = [ 'eventBus' ];
|
|
138
|
+
BpmnOrderingProvider.$inject = [ 'eventBus', 'translate' ];
|
|
136
139
|
|
|
137
140
|
inherits(BpmnOrderingProvider, OrderingProvider);
|
|
138
141
|
|
|
@@ -5,7 +5,7 @@ var assign = require('lodash/object/assign');
|
|
|
5
5
|
/**
|
|
6
6
|
* A palette provider for BPMN 2.0 elements.
|
|
7
7
|
*/
|
|
8
|
-
function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool, handTool) {
|
|
8
|
+
function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool, handTool, translate) {
|
|
9
9
|
|
|
10
10
|
this._palette = palette;
|
|
11
11
|
this._create = create;
|
|
@@ -13,6 +13,7 @@ function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool,
|
|
|
13
13
|
this._spaceTool = spaceTool;
|
|
14
14
|
this._lassoTool = lassoTool;
|
|
15
15
|
this._handTool = handTool;
|
|
16
|
+
this._translate = translate;
|
|
16
17
|
|
|
17
18
|
palette.registerProvider(this);
|
|
18
19
|
}
|
|
@@ -25,7 +26,9 @@ PaletteProvider.$inject = [
|
|
|
25
26
|
'elementFactory',
|
|
26
27
|
'spaceTool',
|
|
27
28
|
'lassoTool',
|
|
28
|
-
'handTool'
|
|
29
|
+
'handTool',
|
|
30
|
+
'translate',
|
|
31
|
+
'eventBus'
|
|
29
32
|
];
|
|
30
33
|
|
|
31
34
|
|
|
@@ -36,7 +39,8 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
|
36
39
|
elementFactory = this._elementFactory,
|
|
37
40
|
spaceTool = this._spaceTool,
|
|
38
41
|
lassoTool = this._lassoTool,
|
|
39
|
-
handTool = this._handTool
|
|
42
|
+
handTool = this._handTool,
|
|
43
|
+
translate = this._translate;
|
|
40
44
|
|
|
41
45
|
function createAction(type, group, className, title, options) {
|
|
42
46
|
|
|
@@ -55,7 +59,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
|
55
59
|
return {
|
|
56
60
|
group: group,
|
|
57
61
|
className: className,
|
|
58
|
-
title: title || 'Create '
|
|
62
|
+
title: title || translate('Create {type}', { type: shortType }),
|
|
59
63
|
action: {
|
|
60
64
|
dragstart: createListener,
|
|
61
65
|
click: createListener
|
|
@@ -71,7 +75,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
|
71
75
|
'hand-tool': {
|
|
72
76
|
group: 'tools',
|
|
73
77
|
className: 'bpmn-icon-hand-tool',
|
|
74
|
-
title: 'Activate the hand tool',
|
|
78
|
+
title: translate('Activate the hand tool'),
|
|
75
79
|
action: {
|
|
76
80
|
click: function(event) {
|
|
77
81
|
handTool.activateHand(event);
|
|
@@ -81,7 +85,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
|
81
85
|
'lasso-tool': {
|
|
82
86
|
group: 'tools',
|
|
83
87
|
className: 'bpmn-icon-lasso-tool',
|
|
84
|
-
title: 'Activate the lasso tool',
|
|
88
|
+
title: translate('Activate the lasso tool'),
|
|
85
89
|
action: {
|
|
86
90
|
click: function(event) {
|
|
87
91
|
lassoTool.activateSelection(event);
|
|
@@ -91,7 +95,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
|
91
95
|
'space-tool': {
|
|
92
96
|
group: 'tools',
|
|
93
97
|
className: 'bpmn-icon-space-tool',
|
|
94
|
-
title: 'Activate the create/remove space tool',
|
|
98
|
+
title: translate('Activate the create/remove space tool'),
|
|
95
99
|
action: {
|
|
96
100
|
click: function(event) {
|
|
97
101
|
spaceTool.activateSelection(event);
|
|
@@ -124,13 +128,13 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
|
124
128
|
'bpmn:DataStoreReference', 'data-store', 'bpmn-icon-data-store'
|
|
125
129
|
),
|
|
126
130
|
'create.subprocess-expanded': createAction(
|
|
127
|
-
'bpmn:SubProcess', 'activity', 'bpmn-icon-subprocess-expanded', 'Create expanded SubProcess',
|
|
131
|
+
'bpmn:SubProcess', 'activity', 'bpmn-icon-subprocess-expanded', translate('Create expanded SubProcess'),
|
|
128
132
|
{ isExpanded: true }
|
|
129
133
|
),
|
|
130
134
|
'create.participant-expanded': {
|
|
131
135
|
group: 'collaboration',
|
|
132
136
|
className: 'bpmn-icon-participant',
|
|
133
|
-
title: 'Create Pool/Participant',
|
|
137
|
+
title: translate('Create Pool/Participant'),
|
|
134
138
|
action: {
|
|
135
139
|
dragstart: createParticipant,
|
|
136
140
|
click: createParticipant
|
|
@@ -4,7 +4,8 @@ module.exports = {
|
|
|
4
4
|
require('diagram-js/lib/features/create'),
|
|
5
5
|
require('diagram-js/lib/features/space-tool'),
|
|
6
6
|
require('diagram-js/lib/features/lasso-tool'),
|
|
7
|
-
require('diagram-js/lib/features/hand-tool')
|
|
7
|
+
require('diagram-js/lib/features/hand-tool'),
|
|
8
|
+
require('diagram-js/lib/i18n/translate')
|
|
8
9
|
],
|
|
9
10
|
__init__: [ 'paletteProvider' ],
|
|
10
11
|
paletteProvider: [ 'type', require('./PaletteProvider') ]
|
|
@@ -15,18 +15,19 @@ var replaceOptions = require ('../replace/ReplaceOptions');
|
|
|
15
15
|
/**
|
|
16
16
|
* This module is an element agnostic replace menu provider for the popup menu.
|
|
17
17
|
*/
|
|
18
|
-
function ReplaceMenuProvider(popupMenu, modeling, moddle, bpmnReplace, rules) {
|
|
18
|
+
function ReplaceMenuProvider(popupMenu, modeling, moddle, bpmnReplace, rules, translate) {
|
|
19
19
|
|
|
20
20
|
this._popupMenu = popupMenu;
|
|
21
21
|
this._modeling = modeling;
|
|
22
22
|
this._moddle = moddle;
|
|
23
23
|
this._bpmnReplace = bpmnReplace;
|
|
24
24
|
this._rules = rules;
|
|
25
|
+
this._translate = translate;
|
|
25
26
|
|
|
26
27
|
this.register();
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
ReplaceMenuProvider.$inject = [ 'popupMenu', 'modeling', 'moddle', 'bpmnReplace', 'rules' ];
|
|
30
|
+
ReplaceMenuProvider.$inject = [ 'popupMenu', 'modeling', 'moddle', 'bpmnReplace', 'rules', 'translate' ];
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -67,6 +68,16 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
|
|
67
68
|
return this._createEntries(element, entries);
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
// expanded/collapsed pools
|
|
72
|
+
if (is(businessObject, 'bpmn:Participant')) {
|
|
73
|
+
|
|
74
|
+
entries = filter(replaceOptions.PARTICIPANT, function(entry) {
|
|
75
|
+
return isExpanded(businessObject) !== entry.target.isExpanded;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return this._createEntries(element, entries);
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
// start events inside event sub processes
|
|
71
82
|
if (is(businessObject, 'bpmn:StartEvent') && isEventSubProcess(businessObject.$parent)) {
|
|
72
83
|
|
|
@@ -252,7 +263,6 @@ ReplaceMenuProvider.prototype._createEntries = function(element, replaceOptions)
|
|
|
252
263
|
return menuEntries;
|
|
253
264
|
};
|
|
254
265
|
|
|
255
|
-
|
|
256
266
|
/**
|
|
257
267
|
* Creates an array of menu entry objects for a given sequence flow.
|
|
258
268
|
*
|
|
@@ -331,7 +341,7 @@ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function (element, re
|
|
|
331
341
|
* @return {Object} menu entry item
|
|
332
342
|
*/
|
|
333
343
|
ReplaceMenuProvider.prototype._createMenuEntry = function(definition, element, action) {
|
|
334
|
-
|
|
344
|
+
var translate = this._translate;
|
|
335
345
|
var replaceElement = this._bpmnReplace.replaceElement;
|
|
336
346
|
|
|
337
347
|
var replaceAction = function() {
|
|
@@ -341,7 +351,7 @@ ReplaceMenuProvider.prototype._createMenuEntry = function(definition, element, a
|
|
|
341
351
|
action = action || replaceAction;
|
|
342
352
|
|
|
343
353
|
var menuEntry = {
|
|
344
|
-
label: definition.label,
|
|
354
|
+
label: translate(definition.label),
|
|
345
355
|
className: definition.className,
|
|
346
356
|
id: definition.actionName,
|
|
347
357
|
action: action
|
|
@@ -360,6 +370,7 @@ ReplaceMenuProvider.prototype._createMenuEntry = function(definition, element, a
|
|
|
360
370
|
ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
|
|
361
371
|
|
|
362
372
|
var self = this;
|
|
373
|
+
var translate = this._translate;
|
|
363
374
|
|
|
364
375
|
function toggleLoopEntry(event, entry) {
|
|
365
376
|
var loopCharacteristics;
|
|
@@ -394,7 +405,7 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
|
|
|
394
405
|
{
|
|
395
406
|
id: 'toggle-parallel-mi',
|
|
396
407
|
className: 'bpmn-icon-parallel-mi-marker',
|
|
397
|
-
title: 'Parallel Multi Instance',
|
|
408
|
+
title: translate('Parallel Multi Instance'),
|
|
398
409
|
active: isParallel,
|
|
399
410
|
action: toggleLoopEntry,
|
|
400
411
|
options: {
|
|
@@ -405,7 +416,7 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
|
|
|
405
416
|
{
|
|
406
417
|
id: 'toggle-sequential-mi',
|
|
407
418
|
className: 'bpmn-icon-sequential-mi-marker',
|
|
408
|
-
title: 'Sequential Multi Instance',
|
|
419
|
+
title: translate('Sequential Multi Instance'),
|
|
409
420
|
active: isSequential,
|
|
410
421
|
action: toggleLoopEntry,
|
|
411
422
|
options: {
|
|
@@ -416,7 +427,7 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
|
|
|
416
427
|
{
|
|
417
428
|
id: 'toggle-loop',
|
|
418
429
|
className: 'bpmn-icon-loop-marker',
|
|
419
|
-
title: 'Loop',
|
|
430
|
+
title: translate('Loop'),
|
|
420
431
|
active: isLoop,
|
|
421
432
|
action: toggleLoopEntry,
|
|
422
433
|
options: {
|
|
@@ -436,6 +447,7 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
|
|
|
436
447
|
* @return {Object} a menu item
|
|
437
448
|
*/
|
|
438
449
|
ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
|
|
450
|
+
var translate = this._translate;
|
|
439
451
|
var businessObject = getBusinessObject(element);
|
|
440
452
|
|
|
441
453
|
var isAdHoc = is(businessObject, 'bpmn:AdHocSubProcess');
|
|
@@ -445,7 +457,7 @@ ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
|
|
|
445
457
|
var adHocEntry = {
|
|
446
458
|
id: 'toggle-adhoc',
|
|
447
459
|
className: 'bpmn-icon-ad-hoc-marker',
|
|
448
|
-
title: 'Ad-hoc',
|
|
460
|
+
title: translate('Ad-hoc'),
|
|
449
461
|
active: isAdHoc,
|
|
450
462
|
action: function(event, entry) {
|
|
451
463
|
if (isAdHoc) {
|
|
@@ -459,4 +471,4 @@ ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
|
|
|
459
471
|
return adHocEntry;
|
|
460
472
|
};
|
|
461
473
|
|
|
462
|
-
module.exports = ReplaceMenuProvider;
|
|
474
|
+
module.exports = ReplaceMenuProvider;
|
|
@@ -65,6 +65,22 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling) {
|
|
|
65
65
|
newElement.isExpanded = isExpanded(oldBusinessObject);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// transform collapsed/expanded pools
|
|
69
|
+
if (is(oldBusinessObject, 'bpmn:Participant')) {
|
|
70
|
+
|
|
71
|
+
// create expanded pool
|
|
72
|
+
if (target.isExpanded === true) {
|
|
73
|
+
newBusinessObject.processRef = bpmnFactory.create('bpmn:Process');
|
|
74
|
+
} else {
|
|
75
|
+
// remove children when transforming to collapsed pool
|
|
76
|
+
hints.moveChildren = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// apply same size
|
|
80
|
+
newElement.width = element.width;
|
|
81
|
+
newElement.height = element.height;
|
|
82
|
+
}
|
|
83
|
+
|
|
68
84
|
newBusinessObject.name = oldBusinessObject.name;
|
|
69
85
|
|
|
70
86
|
// retain loop characteristics if the target element is not an event sub process
|
|
@@ -85,7 +101,7 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling) {
|
|
|
85
101
|
newBusinessObject.isForCompensation = true;
|
|
86
102
|
}
|
|
87
103
|
|
|
88
|
-
newElement = replace.replaceElement(element, newElement);
|
|
104
|
+
newElement = replace.replaceElement(element, newElement, hints);
|
|
89
105
|
|
|
90
106
|
if (hints.select !== false) {
|
|
91
107
|
selection.select(newElement);
|
|
@@ -745,3 +745,25 @@ module.exports.SEQUENCE_FLOW = [
|
|
|
745
745
|
className: 'bpmn-icon-conditional-flow'
|
|
746
746
|
}
|
|
747
747
|
];
|
|
748
|
+
|
|
749
|
+
module.exports.PARTICIPANT = [
|
|
750
|
+
{
|
|
751
|
+
label: 'Expanded Pool',
|
|
752
|
+
actionName: 'replace-with-expanded-pool',
|
|
753
|
+
className: 'bpmn-icon-participant',
|
|
754
|
+
target: {
|
|
755
|
+
type: 'bpmn:Participant',
|
|
756
|
+
isExpanded: true
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
label: 'Collapsed Pool',
|
|
761
|
+
actionName: 'replace-with-collapsed-pool',
|
|
762
|
+
// TODO(@janstuemmel): maybe design new icon
|
|
763
|
+
className: 'bpmn-icon-lane',
|
|
764
|
+
target: {
|
|
765
|
+
type: 'bpmn:Participant',
|
|
766
|
+
isExpanded: false
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var find = require('lodash/collection/find'),
|
|
4
4
|
any = require('lodash/collection/any'),
|
|
5
|
+
filter = require('lodash/collection/filter'),
|
|
5
6
|
forEach = require('lodash/collection/forEach'),
|
|
6
7
|
inherits = require('inherits');
|
|
7
8
|
|
|
@@ -91,6 +92,13 @@ BpmnRules.prototype.init = function() {
|
|
|
91
92
|
return canAttach([ shape ], target, source, position) || canCreate(shape, target, source, position);
|
|
92
93
|
});
|
|
93
94
|
|
|
95
|
+
this.addRule([ 'elements.delete' ], function(context) {
|
|
96
|
+
|
|
97
|
+
// do not allow deletion of labels
|
|
98
|
+
return filter(context.elements, function(e) {
|
|
99
|
+
return !isLabel(e);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
94
102
|
};
|
|
95
103
|
|
|
96
104
|
BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
|
|
@@ -341,6 +349,11 @@ function canDrop(element, target, position) {
|
|
|
341
349
|
return true;
|
|
342
350
|
}
|
|
343
351
|
|
|
352
|
+
// disallow to create elements on collapsed pools
|
|
353
|
+
if (is(target, 'bpmn:Participant') && !isExpanded(target)) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
|
|
344
357
|
// allow to create new participants on
|
|
345
358
|
// on existing collaboration and process diagrams
|
|
346
359
|
if (is(element, 'bpmn:Participant')) {
|
|
@@ -401,6 +414,7 @@ function isBoundaryCandidate(element) {
|
|
|
401
414
|
|
|
402
415
|
|
|
403
416
|
function canAttach(elements, target, source, position) {
|
|
417
|
+
|
|
404
418
|
if (!Array.isArray(elements)) {
|
|
405
419
|
elements = [ elements ];
|
|
406
420
|
}
|
|
@@ -234,7 +234,7 @@ function BpmnSnapping(eventBus, canvas, bpmnRules, elementRegistry) {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
if (is(shape, 'bpmn:TextAnnotation')) {
|
|
237
|
-
context.minDimensions = { width: 50, height:
|
|
237
|
+
context.minDimensions = { width: 50, height: 30 };
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
|
|
@@ -455,4 +455,4 @@ function snapBoundaryEvent(event, shape, target) {
|
|
|
455
455
|
if (/right/.test(direction)) {
|
|
456
456
|
setSnapped(event, 'x', targetTRBL.right);
|
|
457
457
|
}
|
|
458
|
-
}
|
|
458
|
+
}
|
|
@@ -27,10 +27,12 @@ function collectWaypoints(waypoints) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function notYetDrawn(semantic, refSemantic, property) {
|
|
31
|
-
return new Error(
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
function notYetDrawn(translate, semantic, refSemantic, property) {
|
|
31
|
+
return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
|
|
32
|
+
element: elementToString(refSemantic),
|
|
33
|
+
referenced: elementToString(semantic),
|
|
34
|
+
property: property
|
|
35
|
+
}));
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -41,15 +43,16 @@ function notYetDrawn(semantic, refSemantic, property) {
|
|
|
41
43
|
* @param {ElementFactory} elementFactory
|
|
42
44
|
* @param {ElementRegistry} elementRegistry
|
|
43
45
|
*/
|
|
44
|
-
function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry) {
|
|
46
|
+
function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry, translate) {
|
|
45
47
|
this._eventBus = eventBus;
|
|
46
48
|
this._canvas = canvas;
|
|
47
49
|
|
|
48
50
|
this._elementFactory = elementFactory;
|
|
49
51
|
this._elementRegistry = elementRegistry;
|
|
52
|
+
this._translate = translate;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
BpmnImporter.$inject = [ 'eventBus', 'canvas', 'elementFactory', 'elementRegistry' ];
|
|
55
|
+
BpmnImporter.$inject = [ 'eventBus', 'canvas', 'elementFactory', 'elementRegistry', 'translate' ];
|
|
53
56
|
|
|
54
57
|
module.exports = BpmnImporter;
|
|
55
58
|
|
|
@@ -61,12 +64,13 @@ module.exports = BpmnImporter;
|
|
|
61
64
|
BpmnImporter.prototype.add = function(semantic, parentElement) {
|
|
62
65
|
|
|
63
66
|
var di = semantic.di,
|
|
64
|
-
element
|
|
67
|
+
element,
|
|
68
|
+
translate = this._translate;
|
|
65
69
|
|
|
66
70
|
// ROOT ELEMENT
|
|
67
71
|
// handle the special case that we deal with a
|
|
68
72
|
// invisible root element (process or collaboration)
|
|
69
|
-
if (di
|
|
73
|
+
if (is(di, 'bpmndi:BPMNPlane')) {
|
|
70
74
|
|
|
71
75
|
// add a virtual element (not being drawn)
|
|
72
76
|
element = this._elementFactory.createRoot(elementData(semantic));
|
|
@@ -75,7 +79,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
|
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
// SHAPE
|
|
78
|
-
else if (di
|
|
82
|
+
else if (is(di, 'bpmndi:BPMNShape')) {
|
|
79
83
|
|
|
80
84
|
var collapsed = !isExpanded(semantic);
|
|
81
85
|
var hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
|
|
@@ -99,7 +103,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
// CONNECTION
|
|
102
|
-
else if (di
|
|
106
|
+
else if (is(di, 'bpmndi:BPMNEdge')) {
|
|
103
107
|
|
|
104
108
|
var source = this._getSource(semantic),
|
|
105
109
|
target = this._getTarget(semantic);
|
|
@@ -112,9 +116,11 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
|
|
|
112
116
|
|
|
113
117
|
this._canvas.addConnection(element, parentElement);
|
|
114
118
|
} else {
|
|
115
|
-
throw new Error('unknown di
|
|
119
|
+
throw new Error(translate('unknown di {di} for element {semantic}', {
|
|
120
|
+
di: elementToString(di),
|
|
121
|
+
semantic: elementToString(semantic)
|
|
122
|
+
}));
|
|
116
123
|
}
|
|
117
|
-
|
|
118
124
|
// (optional) LABEL
|
|
119
125
|
if (hasExternalLabel(semantic)) {
|
|
120
126
|
this.addLabel(semantic, element);
|
|
@@ -134,18 +140,20 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
|
|
|
134
140
|
* @param {djs.model.Base} boundaryElement
|
|
135
141
|
*/
|
|
136
142
|
BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElement) {
|
|
137
|
-
|
|
143
|
+
var translate = this._translate;
|
|
138
144
|
var hostSemantic = boundarySemantic.attachedToRef;
|
|
139
145
|
|
|
140
146
|
if (!hostSemantic) {
|
|
141
|
-
throw new Error('missing
|
|
147
|
+
throw new Error(translate('missing {semantic}#attachedToRef', {
|
|
148
|
+
semantic: elementToString(boundarySemantic)
|
|
149
|
+
}));
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
var host = this._elementRegistry.get(hostSemantic.id),
|
|
145
153
|
attachers = host && host.attachers;
|
|
146
154
|
|
|
147
155
|
if (!host) {
|
|
148
|
-
throw notYetDrawn(boundarySemantic, hostSemantic, 'attachedToRef');
|
|
156
|
+
throw notYetDrawn(translate, boundarySemantic, hostSemantic, 'attachedToRef');
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
// wire element.host <> host.attachers
|
|
@@ -190,7 +198,8 @@ BpmnImporter.prototype._getEnd = function(semantic, side) {
|
|
|
190
198
|
|
|
191
199
|
var element,
|
|
192
200
|
refSemantic,
|
|
193
|
-
type = semantic.$type
|
|
201
|
+
type = semantic.$type,
|
|
202
|
+
translate = this._translate;
|
|
194
203
|
|
|
195
204
|
refSemantic = semantic[side + 'Ref'];
|
|
196
205
|
|
|
@@ -213,9 +222,12 @@ BpmnImporter.prototype._getEnd = function(semantic, side) {
|
|
|
213
222
|
}
|
|
214
223
|
|
|
215
224
|
if (refSemantic) {
|
|
216
|
-
throw notYetDrawn(semantic, refSemantic, side + 'Ref');
|
|
225
|
+
throw notYetDrawn(translate, semantic, refSemantic, side + 'Ref');
|
|
217
226
|
} else {
|
|
218
|
-
throw new Error(
|
|
227
|
+
throw new Error(translate('{semantic}#{side} Ref not specified', {
|
|
228
|
+
semantic: elementToString(semantic),
|
|
229
|
+
side: side
|
|
230
|
+
}));
|
|
219
231
|
}
|
|
220
232
|
};
|
|
221
233
|
|
|
@@ -34,7 +34,7 @@ function findDisplayCandidate(definitions) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
function BpmnTreeWalker(handler) {
|
|
37
|
+
function BpmnTreeWalker(handler, translate) {
|
|
38
38
|
|
|
39
39
|
// list of containers already walked
|
|
40
40
|
var handledElements = {};
|
|
@@ -65,7 +65,9 @@ function BpmnTreeWalker(handler) {
|
|
|
65
65
|
|
|
66
66
|
// avoid multiple rendering of elements
|
|
67
67
|
if (gfx) {
|
|
68
|
-
throw new Error(
|
|
68
|
+
throw new Error(
|
|
69
|
+
translate('already rendered {element}', { element: elementToString(element) })
|
|
70
|
+
);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
// call handler
|
|
@@ -87,7 +89,7 @@ function BpmnTreeWalker(handler) {
|
|
|
87
89
|
} catch (e) {
|
|
88
90
|
logError(e.message, { element: element, error: e });
|
|
89
91
|
|
|
90
|
-
console.error('failed to import '
|
|
92
|
+
console.error(translate('failed to import {element}', { element: elementToString(element) }));
|
|
91
93
|
console.error(e);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -103,13 +105,23 @@ function BpmnTreeWalker(handler) {
|
|
|
103
105
|
|
|
104
106
|
if (bpmnElement) {
|
|
105
107
|
if (bpmnElement.di) {
|
|
106
|
-
logError(
|
|
108
|
+
logError(
|
|
109
|
+
translate('multiple DI elements defined for {element}', {
|
|
110
|
+
element: elementToString(bpmnElement)
|
|
111
|
+
}),
|
|
112
|
+
{ element: bpmnElement }
|
|
113
|
+
);
|
|
107
114
|
} else {
|
|
108
115
|
diRefs.bind(bpmnElement, 'di');
|
|
109
116
|
bpmnElement.di = di;
|
|
110
117
|
}
|
|
111
118
|
} else {
|
|
112
|
-
logError(
|
|
119
|
+
logError(
|
|
120
|
+
translate('no bpmnElement referenced in {element}', {
|
|
121
|
+
element: elementToString(di)
|
|
122
|
+
}),
|
|
123
|
+
{ element: di }
|
|
124
|
+
);
|
|
113
125
|
}
|
|
114
126
|
}
|
|
115
127
|
|
|
@@ -144,7 +156,7 @@ function BpmnTreeWalker(handler) {
|
|
|
144
156
|
var diagrams = definitions.diagrams;
|
|
145
157
|
|
|
146
158
|
if (diagram && diagrams.indexOf(diagram) === -1) {
|
|
147
|
-
throw new Error('diagram not part of bpmn:Definitions');
|
|
159
|
+
throw new Error(translate('diagram not part of bpmn:Definitions'));
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
if (!diagram && diagrams && diagrams.length) {
|
|
@@ -153,7 +165,7 @@ function BpmnTreeWalker(handler) {
|
|
|
153
165
|
|
|
154
166
|
// no diagram -> nothing to import
|
|
155
167
|
if (!diagram) {
|
|
156
|
-
throw new Error('no diagram to display');
|
|
168
|
+
throw new Error(translate('no diagram to display'));
|
|
157
169
|
}
|
|
158
170
|
|
|
159
171
|
// load DI from selected diagram only
|
|
@@ -163,10 +175,12 @@ function BpmnTreeWalker(handler) {
|
|
|
163
175
|
var plane = diagram.plane;
|
|
164
176
|
|
|
165
177
|
if (!plane) {
|
|
166
|
-
throw new Error(
|
|
178
|
+
throw new Error(translate(
|
|
179
|
+
'no plane for {element}',
|
|
180
|
+
{ element: elementToString(diagram) }
|
|
181
|
+
));
|
|
167
182
|
}
|
|
168
183
|
|
|
169
|
-
|
|
170
184
|
var rootElement = plane.bpmnElement;
|
|
171
185
|
|
|
172
186
|
// ensure we default to a suitable display candidate (process or collaboration),
|
|
@@ -175,10 +189,15 @@ function BpmnTreeWalker(handler) {
|
|
|
175
189
|
rootElement = findDisplayCandidate(definitions);
|
|
176
190
|
|
|
177
191
|
if (!rootElement) {
|
|
178
|
-
throw new Error('no process or collaboration to display');
|
|
192
|
+
throw new Error(translate('no process or collaboration to display'));
|
|
179
193
|
} else {
|
|
180
194
|
|
|
181
|
-
logError(
|
|
195
|
+
logError(
|
|
196
|
+
translate('correcting missing bpmnElement on {plane} to {rootElement}', {
|
|
197
|
+
plane: elementToString(plane),
|
|
198
|
+
rootElement: elementToString(rootElement)
|
|
199
|
+
})
|
|
200
|
+
);
|
|
182
201
|
|
|
183
202
|
// correct DI on the fly
|
|
184
203
|
plane.bpmnElement = rootElement;
|
|
@@ -197,7 +216,12 @@ function BpmnTreeWalker(handler) {
|
|
|
197
216
|
// force drawing of everything not yet drawn that is part of the target DI
|
|
198
217
|
handleUnhandledProcesses(definitions.rootElements, ctx);
|
|
199
218
|
} else {
|
|
200
|
-
throw new Error(
|
|
219
|
+
throw new Error(
|
|
220
|
+
translate('unsupported bpmnElement for {plane}: {rootElement}', {
|
|
221
|
+
plane: elementToString(plane),
|
|
222
|
+
rootElement: elementToString(rootElement)
|
|
223
|
+
})
|
|
224
|
+
);
|
|
201
225
|
}
|
|
202
226
|
|
|
203
227
|
// handle all deferred elements
|
|
@@ -369,9 +393,12 @@ function BpmnTreeWalker(handler) {
|
|
|
369
393
|
handleDataElement(e, context);
|
|
370
394
|
} else {
|
|
371
395
|
logError(
|
|
372
|
-
'unrecognized flowElement
|
|
373
|
-
|
|
374
|
-
|
|
396
|
+
translate('unrecognized flowElement {element} in context {context}', {
|
|
397
|
+
element: elementToString(e),
|
|
398
|
+
context: (context ? elementToString(context.businessObject) : 'null')
|
|
399
|
+
}),
|
|
400
|
+
{ element: e, context: context }
|
|
401
|
+
);
|
|
375
402
|
}
|
|
376
403
|
});
|
|
377
404
|
}
|