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.
Files changed (65) hide show
  1. package/.travis.yml +1 -1
  2. package/.wiredeps +5 -5
  3. package/lib/Modeler.js +52 -9
  4. package/lib/Viewer.js +205 -105
  5. package/lib/draw/BpmnRenderer.js +4 -0
  6. package/lib/features/context-pad/ContextPadProvider.js +21 -15
  7. package/lib/features/label-editing/LabelEditingProvider.js +21 -6
  8. package/lib/features/label-editing/LabelUtil.js +6 -6
  9. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +19 -17
  10. package/lib/features/modeling/BpmnUpdater.js +12 -4
  11. package/lib/features/modeling/ElementFactory.js +25 -11
  12. package/lib/features/modeling/{BpmnLabelSupport.js → behavior/LabelBehavior.js} +14 -4
  13. package/lib/features/modeling/behavior/ModelingFeedback.js +3 -3
  14. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +4 -4
  15. package/lib/features/modeling/behavior/index.js +2 -0
  16. package/lib/features/modeling/cmd/SplitLaneHandler.js +6 -4
  17. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +6 -0
  18. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +6 -0
  19. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +6 -4
  20. package/lib/features/modeling/index.js +1 -2
  21. package/lib/features/ordering/BpmnOrderingProvider.js +7 -4
  22. package/lib/features/ordering/index.js +3 -0
  23. package/lib/features/palette/PaletteProvider.js +13 -9
  24. package/lib/features/palette/index.js +2 -1
  25. package/lib/features/popup-menu/ReplaceMenuProvider.js +22 -10
  26. package/lib/features/popup-menu/index.js +4 -0
  27. package/lib/features/replace/BpmnReplace.js +17 -1
  28. package/lib/features/replace/ReplaceOptions.js +22 -0
  29. package/lib/features/replace/index.js +0 -1
  30. package/lib/features/rules/BpmnRules.js +14 -0
  31. package/lib/features/snapping/BpmnSnapping.js +2 -2
  32. package/lib/import/BpmnImporter.js +30 -18
  33. package/lib/import/BpmnTreeWalker.js +42 -15
  34. package/lib/import/Importer.js +19 -7
  35. package/lib/import/index.js +3 -0
  36. package/package.json +8 -7
  37. package/test/fixtures/bpmn/extension/custom-override.bpmn +54 -0
  38. package/test/fixtures/bpmn/extension/custom.bpmn +54 -0
  39. package/test/fixtures/bpmn/features/modeling/update-label.bpmn +24 -0
  40. package/test/fixtures/json/model/custom-override.json +39 -0
  41. package/test/fixtures/json/model/custom.json +39 -0
  42. package/test/helper/index.js +6 -1
  43. package/test/integration/ReimportSpec.js +89 -0
  44. package/test/spec/ModelerSpec.js +155 -9
  45. package/test/spec/ViewerSpec.js +328 -43
  46. package/test/spec/features/context-pad/ContextPadProviderSpec.js +5 -5
  47. package/test/spec/features/label-editing/LabelEditingProviderSpec.js +201 -128
  48. package/test/spec/features/modeling/AppendShapeSpec.js +0 -43
  49. package/test/spec/features/modeling/UpdateLabelSpec.js +129 -0
  50. package/test/spec/features/modeling/append/TextAnnotationSpec.js +13 -0
  51. package/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +144 -0
  52. package/test/spec/features/modeling/layout/LayoutAssociationSpec.js +3 -3
  53. package/test/spec/features/ordering/BpmnOrderingProviderSpec.js +41 -2
  54. package/test/spec/features/ordering/ordering-subprocesses.bpmn +14 -2
  55. package/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +0 -4
  56. package/test/spec/features/replace/BpmnReplace.collaboration.bpmn +70 -0
  57. package/test/spec/features/replace/BpmnReplaceSpec.js +37 -0
  58. package/test/spec/features/rules/BpmnRules.collaboration.bpmn +6 -1
  59. package/test/spec/features/rules/BpmnRulesSpec.js +32 -0
  60. package/test/spec/features/snapping/BpmnSnappingSpec.js +16 -6
  61. package/test/spec/i18n/custom-translate/custom-translate.js +15 -0
  62. package/test/spec/i18n/custom-translate/index.js +3 -0
  63. package/test/spec/i18n/translateSpec.js +53 -0
  64. package/test/spec/import/ImporterSpec.js +3 -3
  65. package/test/spec/features/modeling/BpmnLabelSupportSpec.js +0 -37
@@ -5,6 +5,7 @@ var assign = require('lodash/object/assign'),
5
5
  forEach = require('lodash/collection/forEach'),
6
6
  isArray = require('lodash/lang/isArray'),
7
7
  is = require('../../util/ModelUtil').is,
8
+ isExpanded = require('../../util/DiUtil').isExpanded,
8
9
  isAny = require('../modeling/util/ModelingUtil').isAny,
9
10
  getChildLanes = require('../modeling/util/LaneUtil').getChildLanes,
10
11
  isEventSubProcess = require('../../util/DiUtil').isEventSubProcess;
@@ -15,7 +16,7 @@ var assign = require('lodash/object/assign'),
15
16
  */
16
17
  function ContextPadProvider(contextPad, modeling, elementFactory,
17
18
  connect, create, popupMenu,
18
- canvas, rules) {
19
+ canvas, rules, translate) {
19
20
 
20
21
  contextPad.registerProvider(this);
21
22
 
@@ -29,6 +30,7 @@ function ContextPadProvider(contextPad, modeling, elementFactory,
29
30
  this._popupMenu = popupMenu;
30
31
  this._canvas = canvas;
31
32
  this._rules = rules;
33
+ this._translate = translate;
32
34
  }
33
35
 
34
36
  ContextPadProvider.$inject = [
@@ -39,7 +41,8 @@ ContextPadProvider.$inject = [
39
41
  'create',
40
42
  'popupMenu',
41
43
  'canvas',
42
- 'rules'
44
+ 'rules',
45
+ 'translate'
43
46
  ];
44
47
 
45
48
  module.exports = ContextPadProvider;
@@ -55,7 +58,9 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
55
58
  create = this._create,
56
59
  popupMenu = this._popupMenu,
57
60
  canvas = this._canvas,
58
- rules = this._rules;
61
+ rules = this._rules,
62
+
63
+ translate = this._translate;
59
64
 
60
65
  var actions = {};
61
66
 
@@ -109,7 +114,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
109
114
 
110
115
  if (typeof title !== 'string') {
111
116
  options = title;
112
- title = 'Append ' + type.replace(/^bpmn\:/, '');
117
+ title = translate('Append {type}', { type: type.replace(/^bpmn\:/, '') });
113
118
  }
114
119
 
115
120
  function appendListener(event, element) {
@@ -141,7 +146,8 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
141
146
  };
142
147
  }
143
148
 
144
- if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ])) {
149
+
150
+ if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(businessObject)) {
145
151
 
146
152
  var childLanes = getChildLanes(element);
147
153
 
@@ -149,7 +155,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
149
155
  'lane-insert-above': {
150
156
  group: 'lane-insert-above',
151
157
  className: 'bpmn-icon-lane-insert-above',
152
- title: 'Add Lane above',
158
+ title: translate('Add Lane above'),
153
159
  action: {
154
160
  click: function(event, element) {
155
161
  modeling.addLane(element, 'top');
@@ -165,7 +171,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
165
171
  'lane-divide-two': {
166
172
  group: 'lane-divide',
167
173
  className: 'bpmn-icon-lane-divide-two',
168
- title: 'Divide into two Lanes',
174
+ title: translate('Divide into two Lanes'),
169
175
  action: {
170
176
  click: splitLaneHandler(2)
171
177
  }
@@ -178,7 +184,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
178
184
  'lane-divide-three': {
179
185
  group: 'lane-divide',
180
186
  className: 'bpmn-icon-lane-divide-three',
181
- title: 'Divide into three Lanes',
187
+ title: translate('Divide into three Lanes'),
182
188
  action: {
183
189
  click: splitLaneHandler(3)
184
190
  }
@@ -191,7 +197,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
191
197
  'lane-insert-below': {
192
198
  group: 'lane-insert-below',
193
199
  className: 'bpmn-icon-lane-insert-below',
194
- title: 'Add Lane below',
200
+ title: translate('Add Lane below'),
195
201
  action: {
196
202
  click: function(event, element) {
197
203
  modeling.addLane(element, 'bottom');
@@ -227,7 +233,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
227
233
 
228
234
  assign(actions, {
229
235
  'append.compensation-activity':
230
- appendAction('bpmn:Task', 'bpmn-icon-task', 'Append compensation activity', {
236
+ appendAction('bpmn:Task', 'bpmn-icon-task', translate('Append compensation activity'), {
231
237
  isForCompensation: true
232
238
  })
233
239
  });
@@ -261,7 +267,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
261
267
  'replace': {
262
268
  group: 'edit',
263
269
  className: 'bpmn-icon-screw-wrench',
264
- title: 'Change type',
270
+ title: translate('Change type'),
265
271
  action: {
266
272
  click: function(event, element) {
267
273
  replaceMenu.open(assign(getReplaceMenuPosition(element), {
@@ -281,9 +287,9 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
281
287
  'connect': {
282
288
  group: 'connect',
283
289
  className: 'bpmn-icon-connection-multi',
284
- title: 'Connect using ' +
290
+ title: translate('Connect using ' +
285
291
  (businessObject.isForCompensation ? '' : 'Sequence/MessageFlow or ') +
286
- 'Association',
292
+ 'Association'),
287
293
  action: {
288
294
  click: startConnect,
289
295
  dragstart: startConnect
@@ -297,7 +303,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
297
303
  'connect': {
298
304
  group: 'connect',
299
305
  className: 'bpmn-icon-connection-multi',
300
- title: 'Connect using DataInputAssociation',
306
+ title: translate('Connect using DataInputAssociation'),
301
307
  action: {
302
308
  click: startConnect,
303
309
  dragstart: startConnect
@@ -319,7 +325,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
319
325
  'delete': {
320
326
  group: 'edit',
321
327
  className: 'bpmn-icon-trash',
322
- title: 'Remove',
328
+ title: translate('Remove'),
323
329
  action: {
324
330
  click: removeElement,
325
331
  dragstart: removeElement
@@ -25,7 +25,7 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack) {
25
25
  });
26
26
 
27
27
  // complete on followup canvas operation
28
- eventBus.on([ 'element.mousedown', 'drag.activate', 'canvas.viewbox.changed' ], function(event) {
28
+ eventBus.on([ 'element.mousedown', 'drag.init', 'canvas.viewbox.changed' ], function(event) {
29
29
  directEditing.complete();
30
30
  });
31
31
 
@@ -91,13 +91,28 @@ LabelEditingProvider.prototype.activate = function(element) {
91
91
  bbox.y = bbox.mid.y - bbox.height / 2;
92
92
  }
93
93
 
94
- // adjust for expanded sub processes
95
- if (is(element, 'bpmn:SubProcess') && isExpanded(element)) {
94
+ // ajust minumum size for task and activities
95
+ if ((is(element, 'bpmn:Task') || is(element, 'bpmn:Activity') )) {
96
96
 
97
+ if (bbox.width < 100) {
98
+ bbox.width = 100;
99
+ bbox.x = bbox.mid.x - bbox.width / 2;
100
+ }
101
+
102
+ if (bbox.height < 80) {
103
+ bbox.height = 80;
104
+ bbox.y = bbox.mid.y - bbox.height / 2;
105
+ }
106
+ }
107
+
108
+ // adjust for expanded sub processes and collapsed pools
109
+ if ((is(element, 'bpmn:SubProcess') && isExpanded(element)) ||
110
+ (is(element, 'bpmn:Participant') && !isExpanded(element))) {
111
+
112
+ bbox.width = element.width;
97
113
  bbox.height = MIN_BOUNDS.height;
98
114
 
99
- bbox.x = bbox.mid.x - bbox.width / 2;
100
- bbox.y = bbox.y + 10 - bbox.height / 2;
115
+ bbox.x = bbox.mid.x - element.width / 2;
101
116
  }
102
117
 
103
118
  return { bounds: bbox, text: text };
@@ -134,4 +149,4 @@ LabelEditingProvider.prototype.update = function(element, newLabel) {
134
149
  element: element,
135
150
  newLabel: newLabel
136
151
  });
137
- };
152
+ };
@@ -27,7 +27,7 @@ module.exports.getLabel = function(element) {
27
27
  };
28
28
 
29
29
 
30
- module.exports.setLabel = function(element, text) {
30
+ module.exports.setLabel = function(element, text, isExternal) {
31
31
  var semantic = element.businessObject,
32
32
  attr = getLabelAttr(semantic);
33
33
 
@@ -35,10 +35,10 @@ module.exports.setLabel = function(element, text) {
35
35
  semantic[attr] = text;
36
36
  }
37
37
 
38
- var label = element.label || element;
39
-
40
- // show label
41
- label.hidden = false;
38
+ // show external label if not empty
39
+ if (isExternal) {
40
+ element.hidden = !text;
41
+ }
42
42
 
43
- return label;
43
+ return element;
44
44
  };
@@ -5,15 +5,27 @@ var LabelUtil = require('../LabelUtil');
5
5
 
6
6
  /**
7
7
  * A handler that updates the text of a BPMN element.
8
- *
9
- * @param {EventBus} eventBus
10
8
  */
11
- function UpdateTextHandler(eventBus) {
12
-
9
+ function UpdateLabelHandler() {
10
+
11
+ /**
12
+ * Set the label and return the changed elements.
13
+ *
14
+ * Element parameter can be label itself or connection (i.e. sequence flow).
15
+ *
16
+ * @param {djs.model.Base} element
17
+ * @param {String} text
18
+ */
13
19
  function setText(element, text) {
14
- var label = LabelUtil.setLabel(element, text);
15
20
 
16
- eventBus.fire('element.changed', { element: label });
21
+ // external label if present
22
+ var label = element.label || element;
23
+
24
+ var labelTarget = element.labelTarget || element;
25
+
26
+ LabelUtil.setLabel(label, text, labelTarget !== label);
27
+
28
+ return [ label, labelTarget ];
17
29
  }
18
30
 
19
31
  function execute(ctx) {
@@ -25,20 +37,10 @@ function UpdateTextHandler(eventBus) {
25
37
  return setText(ctx.element, ctx.oldLabel);
26
38
  }
27
39
 
28
-
29
- function canExecute(ctx) {
30
- return true;
31
- }
32
-
33
40
  // API
34
41
 
35
42
  this.execute = execute;
36
43
  this.revert = revert;
37
-
38
- this.canExecute = canExecute;
39
44
  }
40
45
 
41
-
42
- UpdateTextHandler.$inject = [ 'eventBus' ];
43
-
44
- module.exports = UpdateTextHandler;
46
+ module.exports = UpdateLabelHandler;
@@ -17,11 +17,12 @@ var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
17
17
  * A handler responsible for updating the underlying BPMN 2.0 XML + DI
18
18
  * once changes on the diagram happen
19
19
  */
20
- function BpmnUpdater(eventBus, bpmnFactory, connectionDocking) {
20
+ function BpmnUpdater(eventBus, bpmnFactory, connectionDocking, translate) {
21
21
 
22
22
  CommandInterceptor.call(this, eventBus);
23
23
 
24
24
  this._bpmnFactory = bpmnFactory;
25
+ this._translate = translate;
25
26
 
26
27
  var self = this;
27
28
 
@@ -247,7 +248,7 @@ inherits(BpmnUpdater, CommandInterceptor);
247
248
 
248
249
  module.exports = BpmnUpdater;
249
250
 
250
- BpmnUpdater.$inject = [ 'eventBus', 'bpmnFactory', 'connectionDocking' ];
251
+ BpmnUpdater.$inject = [ 'eventBus', 'bpmnFactory', 'connectionDocking', 'translate' ];
251
252
 
252
253
 
253
254
  /////// implementation //////////////////////////////////
@@ -402,7 +403,8 @@ BpmnUpdater.prototype.getLaneSet = function(container) {
402
403
 
403
404
  BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent) {
404
405
 
405
- var containment;
406
+ var containment,
407
+ translate = this._translate;
406
408
 
407
409
  if (businessObject.$parent === newParent) {
408
410
  return;
@@ -494,7 +496,13 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent)
494
496
  }
495
497
 
496
498
  if (!containment) {
497
- throw new Error('no parent for ', businessObject, newParent);
499
+ throw new Error(translate(
500
+ 'no parent for {element} in {parent}',
501
+ {
502
+ element: businessObject.id,
503
+ parent: newParent.id
504
+ }
505
+ ));
498
506
  }
499
507
 
500
508
  var children;
@@ -5,24 +5,26 @@ var assign = require('lodash/object/assign'),
5
5
 
6
6
  var is = require('../../util/ModelUtil').is;
7
7
 
8
+ var isExpanded = require('../../util/DiUtil').isExpanded;
9
+
8
10
  var BaseElementFactory = require('diagram-js/lib/core/ElementFactory'),
9
11
  LabelUtil = require('../../util/LabelUtil');
10
12
 
11
-
12
13
  /**
13
14
  * A bpmn-aware factory for diagram-js shapes
14
15
  */
15
- function ElementFactory(bpmnFactory, moddle) {
16
+ function ElementFactory(bpmnFactory, moddle, translate) {
16
17
  BaseElementFactory.call(this);
17
18
 
18
19
  this._bpmnFactory = bpmnFactory;
19
20
  this._moddle = moddle;
21
+ this._translate = translate;
20
22
  }
21
23
 
22
24
  inherits(ElementFactory, BaseElementFactory);
23
25
 
24
26
 
25
- ElementFactory.$inject = [ 'bpmnFactory', 'moddle' ];
27
+ ElementFactory.$inject = [ 'bpmnFactory', 'moddle', 'translate' ];
26
28
 
27
29
  module.exports = ElementFactory;
28
30
 
@@ -40,7 +42,8 @@ ElementFactory.prototype.create = function(elementType, attrs) {
40
42
  };
41
43
 
42
44
  ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
43
- var size;
45
+ var size,
46
+ translate = this._translate;
44
47
 
45
48
  attrs = attrs || {};
46
49
 
@@ -48,7 +51,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
48
51
 
49
52
  if (!businessObject) {
50
53
  if (!attrs.type) {
51
- throw new Error('no shape type specified');
54
+ throw new Error(translate('no shape type specified'));
52
55
  }
53
56
 
54
57
  businessObject = this._bpmnFactory.create(attrs.type);
@@ -71,6 +74,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
71
74
  }
72
75
  }
73
76
 
77
+ if (attrs.processRef) {
78
+ businessObject.processRef = attrs.processRef;
79
+ }
80
+
74
81
  if (attrs.isExpanded) {
75
82
  businessObject.di.isExpanded = attrs.isExpanded;
76
83
  }
@@ -118,9 +125,8 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
118
125
  ElementFactory.prototype._getDefaultSize = function(semantic) {
119
126
 
120
127
  if (is(semantic, 'bpmn:SubProcess')) {
121
- var isExpanded = semantic.di.isExpanded === true;
122
128
 
123
- if (isExpanded) {
129
+ if (isExpanded(semantic)) {
124
130
  return { width: 350, height: 200 };
125
131
  } else {
126
132
  return { width: 100, height: 80 };
@@ -140,7 +146,11 @@ ElementFactory.prototype._getDefaultSize = function(semantic) {
140
146
  }
141
147
 
142
148
  if (is(semantic, 'bpmn:Participant')) {
143
- return { width: 600, height: 250 };
149
+ if (!isExpanded(semantic)) {
150
+ return { width: 400, height: 100 };
151
+ } else {
152
+ return { width: 600, height: 250 };
153
+ }
144
154
  }
145
155
 
146
156
  if (is(semantic, 'bpmn:Lane')) {
@@ -155,17 +165,21 @@ ElementFactory.prototype._getDefaultSize = function(semantic) {
155
165
  return { width: 50, height: 50 };
156
166
  }
157
167
 
168
+ if (is(semantic, 'bpmn:TextAnnotation')) {
169
+ return { width: 100, height: 30 };
170
+ }
171
+
158
172
  return { width: 100, height: 80 };
159
173
  };
160
174
 
161
175
 
162
176
  ElementFactory.prototype.createParticipantShape = function(collapsed) {
163
177
 
164
- var participantShape = this.createShape({ type: 'bpmn:Participant' });
178
+ var attrs = { type: 'bpmn:Participant' };
165
179
 
166
180
  if (!collapsed) {
167
- participantShape.businessObject.processRef = this._bpmnFactory.create('bpmn:Process');
181
+ attrs.processRef = this._bpmnFactory.create('bpmn:Process');
168
182
  }
169
183
 
170
- return participantShape;
184
+ return this.createShape(attrs);
171
185
  };
@@ -3,8 +3,8 @@
3
3
  var assign = require('lodash/object/assign'),
4
4
  inherits = require('inherits');
5
5
 
6
- var LabelUtil = require('../../util/LabelUtil'),
7
- is = require('../../util/ModelUtil').is;
6
+ var LabelUtil = require('../../../util/LabelUtil'),
7
+ is = require('../../../util/ModelUtil').is;
8
8
 
9
9
  var hasExternalLabel = LabelUtil.hasExternalLabel,
10
10
  getExternalLabelMid = LabelUtil.getExternalLabelMid;
@@ -12,6 +12,15 @@ var hasExternalLabel = LabelUtil.hasExternalLabel,
12
12
  var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
13
13
 
14
14
 
15
+ /**
16
+ * A component that makes sure that external labels are added
17
+ * together with respective elements and properly updated (DI wise)
18
+ * during move.
19
+ *
20
+ * @param {EventBus} eventBus
21
+ * @param {Modeling} modeling
22
+ * @param {BpmnFactory} bpmnFactory
23
+ */
15
24
  function LabelSupport(eventBus, modeling, bpmnFactory) {
16
25
 
17
26
  CommandInterceptor.call(this, eventBus);
@@ -37,8 +46,9 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
37
46
  }
38
47
  });
39
48
 
40
- // update di information on label movement and creation
41
- this.executed([ 'label.create', 'shape.moved' ], function(e) {
49
+ // update di information on label creation
50
+ this.executed([ 'label.create' ], function(e) {
51
+
42
52
  var element = e.context.shape,
43
53
  businessObject,
44
54
  di;
@@ -3,7 +3,7 @@
3
3
  var is = require('../../../util/ModelUtil').is;
4
4
 
5
5
 
6
- function ModelingFeedback(eventBus, tooltips) {
6
+ function ModelingFeedback(eventBus, tooltips, translate) {
7
7
 
8
8
  function showError(position, message) {
9
9
  tooltips.add({
@@ -24,13 +24,13 @@ function ModelingFeedback(eventBus, tooltips) {
24
24
  target = context.target;
25
25
 
26
26
  if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
27
- showError(event, 'flow elements must be children of pools/participants');
27
+ showError(event, translate('flow elements must be children of pools/participants'));
28
28
  }
29
29
  });
30
30
 
31
31
  }
32
32
 
33
33
 
34
- ModelingFeedback.$inject = [ 'eventBus', 'tooltips' ];
34
+ ModelingFeedback.$inject = [ 'eventBus', 'tooltips', 'translate' ];
35
35
 
36
36
  module.exports = ModelingFeedback;
@@ -14,7 +14,7 @@ var LOW_PRIORITY = 500,
14
14
  /**
15
15
  * BPMN specific delete lane behavior
16
16
  */
17
- function UpdateFlowNodeRefsBehavior(eventBus, modeling) {
17
+ function UpdateFlowNodeRefsBehavior(eventBus, modeling, translate) {
18
18
 
19
19
  CommandInterceptor.call(this, eventBus);
20
20
 
@@ -44,7 +44,7 @@ function UpdateFlowNodeRefsBehavior(eventBus, modeling) {
44
44
 
45
45
  function getContext() {
46
46
  if (!context) {
47
- throw new Error('out of bounds release');
47
+ throw new Error(translate('out of bounds release'));
48
48
  }
49
49
 
50
50
  return context;
@@ -53,7 +53,7 @@ function UpdateFlowNodeRefsBehavior(eventBus, modeling) {
53
53
  function releaseContext() {
54
54
 
55
55
  if (!context) {
56
- throw new Error('out of bounds release');
56
+ throw new Error(translate('out of bounds release'));
57
57
  }
58
58
 
59
59
  var triggerUpdate = context.leave();
@@ -122,7 +122,7 @@ function UpdateFlowNodeRefsBehavior(eventBus, modeling) {
122
122
  });
123
123
  }
124
124
 
125
- UpdateFlowNodeRefsBehavior.$inject = [ 'eventBus', 'modeling' ];
125
+ UpdateFlowNodeRefsBehavior.$inject = [ 'eventBus', 'modeling' , 'translate'];
126
126
 
127
127
  inherits(UpdateFlowNodeRefsBehavior, CommandInterceptor);
128
128
 
@@ -7,6 +7,7 @@ module.exports = {
7
7
  'createParticipantBehavior',
8
8
  'dataInputAssociationBehavior',
9
9
  'deleteLaneBehavior',
10
+ 'labelBehavior',
10
11
  'modelingFeedback',
11
12
  'removeParticipantBehavior',
12
13
  'replaceConnectionBehavior',
@@ -21,6 +22,7 @@ module.exports = {
21
22
  createParticipantBehavior: [ 'type', require('./CreateParticipantBehavior') ],
22
23
  dataInputAssociationBehavior: [ 'type', require('./DataInputAssociationBehavior') ],
23
24
  deleteLaneBehavior: [ 'type', require('./DeleteLaneBehavior') ],
25
+ labelBehavior: [ 'type', require('./LabelBehavior') ],
24
26
  modelingFeedback: [ 'type', require('./ModelingFeedback') ],
25
27
  removeParticipantBehavior: [ 'type', require('./RemoveParticipantBehavior') ],
26
28
  replaceConnectionBehavior: [ 'type', require('./ReplaceConnectionBehavior') ],
@@ -10,18 +10,20 @@ var LANE_INDENTATION = require('../util/LaneUtil').LANE_INDENTATION;
10
10
  *
11
11
  * @param {Modeling} modeling
12
12
  */
13
- function SplitLaneHandler(modeling) {
13
+ function SplitLaneHandler(modeling, translate) {
14
14
  this._modeling = modeling;
15
+ this._translate = translate;
15
16
  }
16
17
 
17
- SplitLaneHandler.$inject = [ 'modeling' ];
18
+ SplitLaneHandler.$inject = [ 'modeling', 'translate'];
18
19
 
19
20
  module.exports = SplitLaneHandler;
20
21
 
21
22
 
22
23
  SplitLaneHandler.prototype.preExecute = function(context) {
23
24
 
24
- var modeling = this._modeling;
25
+ var modeling = this._modeling,
26
+ translate = this._translate;
25
27
 
26
28
  var shape = context.shape,
27
29
  newLanesCount = context.count;
@@ -30,7 +32,7 @@ SplitLaneHandler.prototype.preExecute = function(context) {
30
32
  existingLanesCount = childLanes.length;
31
33
 
32
34
  if (existingLanesCount > newLanesCount) {
33
- throw new Error('more than ' + newLanesCount + ' child lanes');
35
+ throw new Error(translate('more than {count} child lanes', { count: newLanesCount }));
34
36
  }
35
37
 
36
38
  var newLanesHeight = Math.round(shape.height / newLanesCount);
@@ -41,6 +41,9 @@ UpdateCanvasRootHandler.prototype.execute = function(context) {
41
41
  newRootBusinessObject.di = diPlane;
42
42
 
43
43
  context.oldRoot = oldRoot;
44
+
45
+ // TODO(nikku): return changed elements?
46
+ // return [ newRoot, oldRoot ];
44
47
  };
45
48
 
46
49
 
@@ -70,4 +73,7 @@ UpdateCanvasRootHandler.prototype.revert = function(context) {
70
73
 
71
74
  diPlane.bpmnElement = oldRootBusinessObject;
72
75
  oldRootBusinessObject.di = diPlane;
76
+
77
+ // TODO(nikku): return changed elements?
78
+ // return [ newRoot, oldRoot ];
73
79
  };
@@ -153,6 +153,9 @@ UpdateFlowNodeRefsHandler.prototype.execute = function(context) {
153
153
  Collections.add(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
154
154
  });
155
155
  });
156
+
157
+ // TODO(nikku): return changed elements
158
+ // return [ ... ];
156
159
  };
157
160
 
158
161
 
@@ -177,4 +180,7 @@ UpdateFlowNodeRefsHandler.prototype.revert = function(context) {
177
180
  Collections.add(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
178
181
  });
179
182
  });
183
+
184
+ // TODO(nikku): return changed elements
185
+ // return [ ... ];
180
186
  };
@@ -21,12 +21,13 @@ var DEFAULT_FLOW = 'default',
21
21
  * Use respective diagram-js provided handlers if you would
22
22
  * like to perform automated modeling.
23
23
  */
24
- function UpdatePropertiesHandler(elementRegistry, moddle) {
24
+ function UpdatePropertiesHandler(elementRegistry, moddle, translate) {
25
25
  this._elementRegistry = elementRegistry;
26
26
  this._moddle = moddle;
27
+ this._translate = translate;
27
28
  }
28
29
 
29
- UpdatePropertiesHandler.$inject = [ 'elementRegistry', 'moddle' ];
30
+ UpdatePropertiesHandler.$inject = [ 'elementRegistry', 'moddle', 'translate' ];
30
31
 
31
32
  module.exports = UpdatePropertiesHandler;
32
33
 
@@ -46,10 +47,11 @@ module.exports = UpdatePropertiesHandler;
46
47
  UpdatePropertiesHandler.prototype.execute = function(context) {
47
48
 
48
49
  var element = context.element,
49
- changed = [ element ];
50
+ changed = [ element],
51
+ translate = this._translate;
50
52
 
51
53
  if (!element) {
52
- throw new Error('element required');
54
+ throw new Error(translate('element required'));
53
55
  }
54
56
 
55
57
  var elementRegistry = this._elementRegistry,
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- __init__: [ 'modeling', 'bpmnUpdater', 'bpmnLabelSupport' ],
2
+ __init__: [ 'modeling', 'bpmnUpdater' ],
3
3
  __depends__: [
4
4
  require('./behavior'),
5
5
  require('../label-editing'),
@@ -18,7 +18,6 @@ module.exports = {
18
18
  bpmnUpdater: [ 'type', require('./BpmnUpdater') ],
19
19
  elementFactory: [ 'type', require('./ElementFactory') ],
20
20
  modeling: [ 'type', require('./Modeling') ],
21
- bpmnLabelSupport: [ 'type', require('./BpmnLabelSupport') ],
22
21
  layouter: [ 'type', require('./BpmnLayouter') ],
23
22
  connectionDocking: [ 'type', require('diagram-js/lib/layout/CroppingConnectionDocking') ]
24
23
  };