bpmn-js 0.20.6 → 0.22.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/.eslintrc +33 -33
- package/.npmignore +8 -8
- package/.travis.yml +19 -17
- package/.wiredeps +88 -88
- package/CONTRIBUTING.md +55 -55
- package/Gruntfile.js +129 -129
- package/LICENSE +22 -22
- package/README.md +113 -113
- package/assets/bpmn-font/css/bpmn-embedded.css +159 -159
- package/assets/bpmn-font/css/bpmn.css +161 -161
- package/assets/bpmn-font/font/bpmn.svg +116 -116
- package/docs/architecture/overview.svg +48 -48
- package/docs/project/COMMIT_MESSAGES.md +82 -82
- package/docs/project/SETUP.md +66 -66
- package/docs/project/setup-alternative.sh +41 -41
- package/docs/project/setup.bat +45 -45
- package/docs/project/setup.sh +40 -40
- package/docs/translations.json +97 -97
- package/lib/Modeler.js +208 -208
- package/lib/NavigatedViewer.js +27 -27
- package/lib/Viewer.js +503 -503
- package/lib/core/index.js +5 -5
- package/lib/draw/BpmnRenderer.js +1934 -1934
- package/lib/draw/PathMap.js +478 -478
- package/lib/draw/index.js +5 -5
- package/lib/features/auto-resize/BpmnAutoResize.js +34 -34
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +51 -51
- package/lib/features/auto-resize/index.js +5 -5
- package/lib/features/context-pad/ContextPadProvider.js +374 -374
- package/lib/features/context-pad/index.js +11 -11
- package/lib/features/copy-paste/BpmnCopyPaste.js +157 -154
- package/lib/features/copy-paste/index.js +7 -7
- package/lib/features/distribute-elements/BpmnDistributeElements.js +34 -34
- package/lib/features/distribute-elements/index.js +7 -7
- package/lib/features/editor-actions/BpmnEditorActions.js +130 -130
- package/lib/features/editor-actions/index.js +15 -15
- package/lib/features/global-connect/BpmnGlobalConnect.js +49 -49
- package/lib/features/global-connect/index.js +7 -7
- package/lib/features/keyboard/BpmnKeyBindings.js +72 -72
- package/lib/features/keyboard/index.js +7 -7
- package/lib/features/label-editing/LabelEditingPreview.js +122 -0
- package/lib/features/label-editing/LabelEditingProvider.js +292 -193
- package/lib/features/label-editing/LabelUtil.js +43 -43
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +116 -112
- package/lib/features/label-editing/index.js +14 -9
- package/lib/features/modeling/BpmnFactory.js +97 -97
- package/lib/features/modeling/BpmnLayouter.js +191 -191
- package/lib/features/modeling/BpmnUpdater.js +692 -688
- package/lib/features/modeling/ElementFactory.js +218 -218
- package/lib/features/modeling/Modeling.js +183 -183
- package/lib/features/modeling/behavior/AppendBehavior.js +42 -42
- package/lib/features/modeling/behavior/CopyPasteBehavior.js +69 -69
- package/lib/features/modeling/behavior/CreateBoundaryEventBehavior.js +51 -51
- package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +37 -37
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +91 -91
- package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +151 -151
- package/lib/features/modeling/behavior/DeleteLaneBehavior.js +107 -107
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +165 -131
- package/lib/features/modeling/behavior/ImportDockingFix.js +80 -80
- package/lib/features/modeling/behavior/LabelBehavior.js +222 -222
- package/lib/features/modeling/behavior/ModelingFeedback.js +50 -50
- package/lib/features/modeling/behavior/RemoveElementBehavior.js +73 -73
- package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +50 -50
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +128 -128
- package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +118 -116
- package/lib/features/modeling/behavior/ResizeLaneBehavior.js +59 -59
- package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +138 -138
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +27 -27
- package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +54 -54
- package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +156 -156
- package/lib/features/modeling/behavior/index.js +44 -44
- package/lib/features/modeling/behavior/util/GeometricUtil.js +129 -129
- package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +218 -218
- package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +233 -233
- package/lib/features/modeling/behavior/util/LineIntersect.js +36 -36
- package/lib/features/modeling/cmd/AddLaneHandler.js +83 -83
- package/lib/features/modeling/cmd/IdClaimHandler.js +41 -41
- package/lib/features/modeling/cmd/ResizeLaneHandler.js +125 -125
- package/lib/features/modeling/cmd/SplitLaneHandler.js +82 -82
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +78 -78
- package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +185 -185
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +264 -264
- package/lib/features/modeling/index.js +23 -23
- package/lib/features/modeling/util/LaneUtil.js +157 -157
- package/lib/features/modeling/util/ModelingUtil.js +48 -48
- package/lib/features/ordering/BpmnOrderingProvider.js +147 -147
- package/lib/features/ordering/index.js +6 -6
- package/lib/features/palette/PaletteProvider.js +158 -158
- package/lib/features/palette/index.js +13 -13
- package/lib/features/popup-menu/ReplaceMenuProvider.js +479 -479
- package/lib/features/popup-menu/index.js +7 -7
- package/lib/features/popup-menu/util/TypeUtil.js +41 -41
- package/lib/features/replace/BpmnReplace.js +197 -197
- package/lib/features/replace/ReplaceOptions.js +787 -787
- package/lib/features/replace/index.js +7 -7
- package/lib/features/replace-preview/BpmnReplacePreview.js +113 -113
- package/lib/features/replace-preview/index.js +5 -5
- package/lib/features/rules/BpmnRules.js +807 -806
- package/lib/features/rules/index.js +7 -7
- package/lib/features/search/BpmnSearchProvider.js +128 -128
- package/lib/features/search/index.js +7 -7
- package/lib/features/snapping/BpmnSnapping.js +511 -495
- package/lib/features/snapping/BpmnSnappingUtil.js +159 -159
- package/lib/features/snapping/index.js +3 -3
- package/lib/import/BpmnImporter.js +302 -302
- package/lib/import/BpmnTreeWalker.js +445 -445
- package/lib/import/Importer.js +69 -69
- package/lib/import/Util.js +8 -8
- package/lib/import/index.js +5 -5
- package/lib/util/DiUtil.js +60 -60
- package/lib/util/LabelUtil.js +139 -139
- package/lib/util/ModelUtil.js +31 -31
- package/lib/util/PoweredByUtil.js +82 -82
- package/lib/util/model/ModelCloneHelper.js +201 -201
- package/lib/util/model/ModelCloneUtils.js +35 -35
- package/package.json +22 -22
- package/resources/initial.bpmn +12 -12
- package/resources/screencast.gif +0 -0
- package/tasks/banner.txt +11 -11
- package/tasks/bundle.js +162 -162
- package/test/TestHelper.js +17 -17
- package/test/config/karma.unit.js +46 -46
- package/test/config/translation-reporter.js +48 -48
- package/test/fixtures/bpmn/align-elements.bpmn +136 -136
- package/test/fixtures/bpmn/basic.bpmn +17 -17
- package/test/fixtures/bpmn/boundary-events.bpmn +59 -59
- package/test/fixtures/bpmn/collaboration/collaboration-empty-participant.bpmn +13 -13
- package/test/fixtures/bpmn/collaboration/collaboration-message-flows.bpmn +89 -89
- package/test/fixtures/bpmn/collaboration/collaboration-participant.bpmn +59 -59
- package/test/fixtures/bpmn/collaboration/process-empty.bpmn +6 -6
- package/test/fixtures/bpmn/collaboration/process.bpmn +47 -47
- package/test/fixtures/bpmn/collaboration-data-items.bpmn +81 -81
- package/test/fixtures/bpmn/collaboration-message-flows.bpmn +82 -82
- package/test/fixtures/bpmn/collaboration-sequence-flows.bpmn +83 -83
- package/test/fixtures/bpmn/collaboration.bpmn +50 -50
- package/test/fixtures/bpmn/complex.bpmn +2151 -2151
- package/test/fixtures/bpmn/conditions.bpmn +82 -82
- package/test/fixtures/bpmn/containers.bpmn +128 -128
- package/test/fixtures/bpmn/distribute-elements-filtering.bpmn +58 -58
- package/test/fixtures/bpmn/distribute-elements.bpmn +232 -232
- package/test/fixtures/bpmn/draw/activity-markers-combination.bpmn +141 -141
- package/test/fixtures/bpmn/draw/activity-markers-simple.bpmn +47 -47
- package/test/fixtures/bpmn/draw/activity-markers.bpmn +212 -212
- package/test/fixtures/bpmn/draw/associations.bpmn +55 -55
- package/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn +81 -81
- package/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn +81 -81
- package/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn +82 -82
- package/test/fixtures/bpmn/draw/call-activity.bpmn +12 -12
- package/test/fixtures/bpmn/draw/colors.bpmn +411 -411
- package/test/fixtures/bpmn/draw/conditional-flow-default.bpmn +100 -100
- package/test/fixtures/bpmn/draw/conditional-flow-gateways.bpmn +72 -72
- package/test/fixtures/bpmn/draw/conditional-flow-typed-task.bpmn +33 -33
- package/test/fixtures/bpmn/draw/conditional-flow.bpmn +248 -248
- package/test/fixtures/bpmn/draw/data-objects.bpmn +265 -265
- package/test/fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn +200 -200
- package/test/fixtures/bpmn/draw/event-subprocesses-expanded.bpmn +274 -274
- package/test/fixtures/bpmn/draw/events-interrupting.bpmn +370 -370
- package/test/fixtures/bpmn/draw/events.bpmn +374 -374
- package/test/fixtures/bpmn/draw/gateway-type-default.bpmn +45 -45
- package/test/fixtures/bpmn/draw/gateways.bpmn +61 -61
- package/test/fixtures/bpmn/draw/group.bpmn +24 -24
- package/test/fixtures/bpmn/draw/message-marker.bpmn +112 -112
- package/test/fixtures/bpmn/draw/pools-with-collection-marker.bpmn +104 -104
- package/test/fixtures/bpmn/draw/pools.bpmn +82 -82
- package/test/fixtures/bpmn/draw/task-types.bpmn +77 -77
- package/test/fixtures/bpmn/draw/text-annotation.bpmn +71 -71
- package/test/fixtures/bpmn/draw/xor.bpmn +45 -45
- package/test/fixtures/bpmn/empty-definitions.bpmn +4 -4
- package/test/fixtures/bpmn/error/categoryValue.bpmn +26 -26
- package/test/fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn +9 -9
- package/test/fixtures/bpmn/error/duplicate-ids.bpmn +14 -14
- package/test/fixtures/bpmn/error/invalid-child.bpmn +6 -6
- package/test/fixtures/bpmn/error/missing-namespace.bpmn +12 -12
- package/test/fixtures/bpmn/event-sub-processes.bpmn +47 -47
- package/test/fixtures/bpmn/extension/camunda.bpmn +52 -52
- package/test/fixtures/bpmn/extension/custom-override.bpmn +53 -53
- package/test/fixtures/bpmn/extension/custom.bpmn +53 -53
- package/test/fixtures/bpmn/features/copy-paste/basic.bpmn +111 -111
- package/test/fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn +102 -102
- package/test/fixtures/bpmn/features/copy-paste/collaboration.bpmn +74 -74
- package/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn +61 -61
- package/test/fixtures/bpmn/features/copy-paste/properties.bpmn +43 -43
- package/test/fixtures/bpmn/features/drop/drop.bpmn +41 -41
- package/test/fixtures/bpmn/features/drop/recursive-task.bpmn +37 -37
- package/test/fixtures/bpmn/features/label-editing/labels.bpmn +178 -248
- package/test/fixtures/bpmn/features/modeling/update-label.bpmn +24 -24
- package/test/fixtures/bpmn/features/replace/01_replace.bpmn +193 -193
- package/test/fixtures/bpmn/features/replace/association-gateways.bpmn +173 -173
- package/test/fixtures/bpmn/features/replace/cancel-events.bpmn +49 -49
- package/test/fixtures/bpmn/features/replace/clone-properties.bpmn +141 -141
- package/test/fixtures/bpmn/features/replace/connection.bpmn +42 -42
- package/test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn +72 -72
- package/test/fixtures/bpmn/features/rules/link-event.bpmn +35 -35
- package/test/fixtures/bpmn/features/rules/text-annotation-association.bpmn +30 -30
- package/test/fixtures/bpmn/flow-markers.bpmn +212 -212
- package/test/fixtures/bpmn/import/boundaryEvent.bpmn +33 -33
- package/test/fixtures/bpmn/import/collaboration.bpmn +50 -50
- package/test/fixtures/bpmn/import/collapsed/collaboration.bpmn +76 -76
- package/test/fixtures/bpmn/import/collapsed/process.bpmn +84 -84
- package/test/fixtures/bpmn/import/collapsed/processWithChildren.bpmn +273 -273
- package/test/fixtures/bpmn/import/default-attrs.bpmn +24 -24
- package/test/fixtures/bpmn/import/error/boundaryEvent-invalidAttachToRef.bpmn +30 -30
- package/test/fixtures/bpmn/import/error/boundaryEvent-missingAttachToRef.bpmn +33 -33
- package/test/fixtures/bpmn/import/error/dangling-process-message-flow.bpmn +81 -81
- package/test/fixtures/bpmn/import/error/invalid-flow-element.bpmn +35 -35
- package/test/fixtures/bpmn/import/error/multiple-dis.bpmn +23 -23
- package/test/fixtures/bpmn/import/labels/collaboration-message-flows.bpmn +41 -41
- package/test/fixtures/bpmn/import/labels/collaboration.bpmn +72 -72
- package/test/fixtures/bpmn/import/labels/embedded.bpmn +39 -39
- package/test/fixtures/bpmn/import/labels/external-no-di.bpmn +42 -42
- package/test/fixtures/bpmn/import/labels/external.bpmn +69 -69
- package/test/fixtures/bpmn/import/position/position-testcase.bpmn +57 -57
- package/test/fixtures/bpmn/import/process.bpmn +60 -60
- package/test/fixtures/bpmn/nested-subprocesses.bpmn +118 -118
- package/test/fixtures/bpmn/sequence-flows.bpmn +60 -60
- package/test/fixtures/bpmn/simple-cropping.bpmn +84 -84
- package/test/fixtures/bpmn/simple-resizable.bpmn +50 -50
- package/test/fixtures/bpmn/simple.bpmn +60 -60
- package/test/fixtures/json/model/camunda.json +1042 -1042
- package/test/fixtures/json/model/custom-override.json +39 -39
- package/test/fixtures/json/model/custom.json +39 -39
- package/test/helper/TranslationCollector.js +17 -17
- package/test/helper/index.js +249 -249
- package/test/integration/CustomElementsSpec.js +223 -223
- package/test/integration/ReimportSpec.js +89 -89
- package/test/integration/SimpleModelingSpec.js +29 -29
- package/test/integration/custom-elements/CustomElementFactory.js +77 -77
- package/test/integration/custom-elements/CustomRenderer.js +151 -151
- package/test/integration/custom-elements/CustomRules.js +148 -148
- package/test/integration/custom-elements/CustomUpdater.js +115 -115
- package/test/integration/custom-elements/index.js +7 -7
- package/test/integration/model/BpmnModdleSpec.js +65 -65
- package/test/matchers/JSONMatcher.js +19 -19
- package/test/spec/ModelerSpec.js +401 -401
- package/test/spec/NavigatedViewerSpec.js +58 -58
- package/test/spec/ViewerSpec.js +977 -977
- package/test/spec/draw/BpmnRendererSpec.js +311 -311
- package/test/spec/environment/MockingSpec.js +53 -53
- package/test/spec/features/align-elements/BpmnAlignElementsSpec.js +137 -137
- package/test/spec/features/auto-resize/AutoResize.lanes.bpmn +54 -54
- package/test/spec/features/auto-resize/AutoResize.multi-selection.bpmn +22 -22
- package/test/spec/features/auto-resize/AutoResize.nested-sub-processes.bpmn +47 -47
- package/test/spec/features/auto-resize/AutoResize.participant.bpmn +38 -38
- package/test/spec/features/auto-resize/AutoResize.space-tool.bpmn +38 -38
- package/test/spec/features/auto-resize/AutoResize.sub-processes.bpmn +37 -37
- package/test/spec/features/auto-resize/AutoResizeSpec.js +607 -607
- package/test/spec/features/context-pad/ContextPad.activation.bpmn +51 -51
- package/test/spec/features/context-pad/ContextPadProviderSpec.js +440 -440
- package/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +763 -725
- package/test/spec/features/copy-paste/DescriptorTree.js +58 -58
- package/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js +113 -113
- package/test/spec/features/editor-actions/BpmnEditorActionsSpec.js +72 -72
- package/test/spec/features/global-connect/BpmnGlobalConnectSpec.js +61 -61
- package/test/spec/features/keyboard/BpmnKeyBindingsSpec.js +142 -142
- package/test/spec/features/label-editing/LabelEditingPreviewSpec.js +133 -0
- package/test/spec/features/label-editing/LabelEditingProviderSpec.js +636 -601
- package/test/spec/features/label-editing/TouchIntegrationSpec.js +40 -40
- package/test/spec/features/modeling/AppendShapeSpec.js +332 -332
- package/test/spec/features/modeling/BendpointsSpec.js +25 -25
- package/test/spec/features/modeling/BpmnFactorySpec.js +73 -73
- package/test/spec/features/modeling/BpmnUpdater.bpmn +99 -99
- package/test/spec/features/modeling/BpmnUpdaterSpec.js +79 -79
- package/test/spec/features/modeling/CreateConnectionSpec.js +171 -171
- package/test/spec/features/modeling/DeleteConnectionSpec.js +75 -75
- package/test/spec/features/modeling/DeleteParticipantSpec.js +97 -97
- package/test/spec/features/modeling/DeleteShapeSpec.js +75 -75
- package/test/spec/features/modeling/DropSpec.js +123 -123
- package/test/spec/features/modeling/IdClaim.bpmn +13 -13
- package/test/spec/features/modeling/IdClaimSpec.js +50 -50
- package/test/spec/features/modeling/LabelBoundsSpec.js +342 -340
- package/test/spec/features/modeling/LabelBoundsSpec.simple.bpmn +27 -27
- package/test/spec/features/modeling/LabelLayouting.initial.bpmn +37 -37
- package/test/spec/features/modeling/LabelLayouting.move.bpmn +99 -99
- package/test/spec/features/modeling/LabelLayouting.special.bpmn +76 -76
- package/test/spec/features/modeling/LabelLayoutingSpec.js +603 -603
- package/test/spec/features/modeling/MoveConnectionSpec.js +101 -101
- package/test/spec/features/modeling/MoveElements.flow-collaboration.bpmn +45 -45
- package/test/spec/features/modeling/MoveElementsSpec.js +70 -70
- package/test/spec/features/modeling/MoveRulesSpec.js +151 -151
- package/test/spec/features/modeling/MoveShapeSpec.js +353 -353
- package/test/spec/features/modeling/ResizeShapeSpec.js +73 -73
- package/test/spec/features/modeling/SpaceToolSpec.js +251 -251
- package/test/spec/features/modeling/UpdateAttachmentSpec.js +96 -96
- package/test/spec/features/modeling/UpdateLabelSpec.js +130 -130
- package/test/spec/features/modeling/UpdatePropertiesSpec.js +503 -503
- package/test/spec/features/modeling/append/TextAnnotationSpec.js +136 -136
- package/test/spec/features/modeling/behavior/CompensationAssociationBehavior.bpmn +26 -26
- package/test/spec/features/modeling/behavior/CompensationAssociationBehaviorSpec.js +43 -43
- package/test/spec/features/modeling/behavior/CreateBoundaryEventBehaviorSpec.js +58 -58
- package/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js +224 -224
- package/test/spec/features/modeling/behavior/DataInputAssociationBehavior.bpmn +33 -33
- package/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js +146 -146
- package/test/spec/features/modeling/behavior/DataObjectBehavior.create-data-association.bpmn +21 -21
- package/test/spec/features/modeling/behavior/DataObjectBehavior.data-object-reference.bpmn +13 -13
- package/test/spec/features/modeling/behavior/DataObjectBehavior.remove-data-association.bpmn +41 -41
- package/test/spec/features/modeling/behavior/DataObjectBehaviorSpec.js +297 -297
- package/test/spec/features/modeling/behavior/DataStoreBehavior.bpmn +26 -26
- package/test/spec/features/modeling/behavior/DataStoreBehavior.connect.bpmn +57 -57
- package/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js +228 -228
- package/test/spec/features/modeling/behavior/DropOnFlowBehavior.bpmn +71 -67
- package/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js +591 -418
- package/test/spec/features/modeling/behavior/ImportDockingFix.bpmn +61 -61
- package/test/spec/features/modeling/behavior/ImportDockingFixSpec.js +37 -37
- package/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +277 -277
- package/test/spec/features/modeling/behavior/ReconnectConnection.data-association.bpmn +41 -41
- package/test/spec/features/modeling/behavior/ReconnectConnectionSpec.js +120 -120
- package/test/spec/features/modeling/behavior/RemoveElementBehavior.bpmn +181 -181
- package/test/spec/features/modeling/behavior/RemoveElementBehavior.perpendicular.bpmn +159 -159
- package/test/spec/features/modeling/behavior/RemoveElementBehaviorSpec.js +251 -251
- package/test/spec/features/modeling/behavior/RemoveParticipantBehaviorSpec.js +125 -125
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.association.bpmn +26 -26
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.boundary-events.bpmn +40 -40
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.message-sequence-flow.bpmn +121 -121
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js +439 -439
- package/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js +450 -450
- package/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js +653 -653
- package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.bpmn +48 -48
- package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.js +77 -77
- package/test/spec/features/modeling/behavior/util/GeometricUtilSpec.js +127 -127
- package/test/spec/features/modeling/behavior/util/LabelLayoutUtilSpec.js +75 -75
- package/test/spec/features/modeling/behavior/util/LineAttachmentUtilSpec.js +294 -294
- package/test/spec/features/modeling/behavior/util/LineIntersectSpec.js +32 -32
- package/test/spec/features/modeling/lanes/AddLaneSpec.js +263 -263
- package/test/spec/features/modeling/lanes/DeleteLaneSpec.js +126 -126
- package/test/spec/features/modeling/lanes/ResizeLaneSpec.js +366 -366
- package/test/spec/features/modeling/lanes/SplitLaneSpec.js +216 -216
- package/test/spec/features/modeling/lanes/UpdateFlowNodeRefsSpec.js +271 -271
- package/test/spec/features/modeling/lanes/flowNodeRefs.bpmn +56 -56
- package/test/spec/features/modeling/lanes/lanes.bpmn +83 -83
- package/test/spec/features/modeling/lanes/participant-lane.bpmn +27 -27
- package/test/spec/features/modeling/lanes/participant-no-lane.bpmn +22 -22
- package/test/spec/features/modeling/layout/Helper.js +64 -64
- package/test/spec/features/modeling/layout/LayoutAssociationSpec.js +101 -101
- package/test/spec/features/modeling/layout/LayoutConnectionSpec.js +98 -98
- package/test/spec/features/modeling/layout/LayoutDataAssociationSpec.js +98 -98
- package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.bpmn +119 -119
- package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js +313 -313
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.boundaryEvents.bpmn +65 -65
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.flowElements.bpmn +70 -70
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js +323 -323
- package/test/spec/features/ordering/BpmnOrderingProviderSpec.js +231 -231
- package/test/spec/features/ordering/Helper.js +185 -185
- package/test/spec/features/ordering/ordering-start-event.bpmn +17 -17
- package/test/spec/features/ordering/ordering-subprocesses.bpmn +41 -41
- package/test/spec/features/ordering/ordering.bpmn +105 -105
- package/test/spec/features/palette/PaletteProviderSpec.js +33 -33
- package/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn +13 -13
- package/test/spec/features/popup-menu/ReplaceMenuProvider.compensation-activity.bpmn +12 -12
- package/test/spec/features/popup-menu/ReplaceMenuProvider.conditionalFlows.bpmn +66 -66
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlows.bpmn +126 -126
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn +48 -48
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromInclusiveGateways.bpmn +48 -48
- package/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +1957 -1957
- package/test/spec/features/replace/BpmnReplace.collaboration.bpmn +70 -70
- package/test/spec/features/replace/BpmnReplace.compensation.bpmn +12 -12
- package/test/spec/features/replace/BpmnReplace.eventSubProcesses.bpmn +126 -126
- package/test/spec/features/replace/BpmnReplaceSpec.js +1302 -1302
- package/test/spec/features/replace/ReplaceRulesSpec.js +78 -78
- package/test/spec/features/replace/SubProcess-collapsed.bpmn +36 -36
- package/test/spec/features/replace-preview/BpmnReplacePreviewSpec.js +304 -304
- package/test/spec/features/rules/BpmnRules.boundaryEvent.bpmn +93 -93
- package/test/spec/features/rules/BpmnRules.collaboration-dataAssociation.bpmn +35 -35
- package/test/spec/features/rules/BpmnRules.collaboration-lanes.bpmn +79 -79
- package/test/spec/features/rules/BpmnRules.collaboration.bpmn +138 -138
- package/test/spec/features/rules/BpmnRules.compensation.bpmn +65 -65
- package/test/spec/features/rules/BpmnRules.dataAssociation.bpmn +33 -33
- package/test/spec/features/rules/BpmnRules.eventBasedGateway.bpmn +82 -82
- package/test/spec/features/rules/BpmnRules.messageFlow.bpmn +27 -27
- package/test/spec/features/rules/BpmnRules.multiSelectionPools.bpmn +37 -37
- package/test/spec/features/rules/BpmnRules.process.bpmn +91 -91
- package/test/spec/features/rules/BpmnRules.subProcess-dataAssociation.bpmn +44 -44
- package/test/spec/features/rules/BpmnRulesSpec.js +1468 -1424
- package/test/spec/features/rules/Helper.js +82 -82
- package/test/spec/features/search/BpmnSearchProviderSpec.js +158 -158
- package/test/spec/features/search/bpmn-search-collaboration.bpmn +106 -106
- package/test/spec/features/search/bpmn-search.bpmn +100 -100
- package/test/spec/features/snapping/BpmnSnapping.connect.bpmn +36 -36
- package/test/spec/features/snapping/BpmnSnapping.labels.bpmn +27 -27
- package/test/spec/features/snapping/BpmnSnapping.lanes-resize.bpmn +43 -43
- package/test/spec/features/snapping/BpmnSnapping.participant-resize.bpmn +50 -50
- package/test/spec/features/snapping/BpmnSnapping.sequenceFlow.bpmn +41 -0
- package/test/spec/features/snapping/BpmnSnapping.subProcess-resize.bpmn +21 -21
- package/test/spec/features/snapping/BpmnSnapping.textAnnotation-resize.bpmn +22 -22
- package/test/spec/features/snapping/BpmnSnappingSpec.js +824 -758
- package/test/spec/features/snapping/BpmnSnappingUtil.lanes-flowNodes.bpmn +82 -82
- package/test/spec/features/snapping/BpmnSnappingUtil.lanes.bpmn +35 -35
- package/test/spec/features/snapping/BpmnSnappingUtilSpec.js +285 -285
- package/test/spec/i18n/custom-translate/custom-translate.js +14 -14
- package/test/spec/i18n/custom-translate/index.js +2 -2
- package/test/spec/i18n/translateSpec.js +56 -56
- package/test/spec/import/ImporterSpec.js +428 -428
- package/test/spec/import/ModelWiringSpec.js +194 -194
- package/test/spec/import/elements/AssociationSpec.collaboration.bpmn +51 -51
- package/test/spec/import/elements/AssociationSpec.compensation.bpmn +28 -28
- package/test/spec/import/elements/AssociationSpec.data-association.bpmn +39 -39
- package/test/spec/import/elements/AssociationSpec.data-input-output.bpmn +40 -40
- package/test/spec/import/elements/AssociationSpec.events.bpmn +51 -51
- package/test/spec/import/elements/AssociationSpec.js +175 -175
- package/test/spec/import/elements/AssociationSpec.text-annotation.bpmn +37 -37
- package/test/spec/import/elements/CollapsedSpec.js +118 -118
- package/test/spec/import/elements/LabelSpec.js +85 -85
- package/test/spec/import/lane-flowNodes.bpmn +44 -44
- package/test/spec/import/lane-missing-flowNodeRef.bpmn +24 -24
- package/test/spec/util/ModelCloneHelperSpec.js +381 -381
- package/test/spec/util/ModelUtilSpec.js +65 -65
- package/test/spec/util/camunda-moddle.js +70 -70
- package/test/util/MockEvents.js +62 -62
- package/test/util/ModelingUtil.js +117 -117
- package/test/util/custom-rules/CustomRules.js +18 -18
- package/test/util/custom-rules/index.js +4 -4
|
@@ -1,806 +1,807 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var find = require('lodash/collection/find'),
|
|
4
|
-
any = require('lodash/collection/any'),
|
|
5
|
-
every = require('lodash/collection/every'),
|
|
6
|
-
filter = require('lodash/collection/filter'),
|
|
7
|
-
forEach = require('lodash/collection/forEach'),
|
|
8
|
-
inherits = require('inherits');
|
|
9
|
-
|
|
10
|
-
var is = require('../../util/ModelUtil').is,
|
|
11
|
-
isAny = require('../modeling/util/ModelingUtil').isAny,
|
|
12
|
-
getBusinessObject = require('../../util/ModelUtil').getBusinessObject,
|
|
13
|
-
isExpanded = require('../../util/DiUtil').isExpanded,
|
|
14
|
-
isEventSubProcess = require('../../util/DiUtil').isEventSubProcess,
|
|
15
|
-
isInterrupting = require('../../util/DiUtil').isInterrupting,
|
|
16
|
-
hasErrorEventDefinition = require('../../util/DiUtil').hasErrorEventDefinition,
|
|
17
|
-
hasEscalationEventDefinition = require('../../util/DiUtil').hasEscalationEventDefinition,
|
|
18
|
-
hasCompensateEventDefinition = require('../../util/DiUtil').hasCompensateEventDefinition;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider');
|
|
22
|
-
|
|
23
|
-
var isBoundaryAttachment = require('../snapping/BpmnSnappingUtil').getBoundaryAttachment;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* BPMN specific modeling rule
|
|
27
|
-
*/
|
|
28
|
-
function BpmnRules(eventBus) {
|
|
29
|
-
RuleProvider.call(this, eventBus);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
inherits(BpmnRules, RuleProvider);
|
|
33
|
-
|
|
34
|
-
BpmnRules.$inject = [ 'eventBus' ];
|
|
35
|
-
|
|
36
|
-
module.exports = BpmnRules;
|
|
37
|
-
|
|
38
|
-
BpmnRules.prototype.init = function() {
|
|
39
|
-
|
|
40
|
-
this.addRule('connection.create', function(context) {
|
|
41
|
-
var source = context.source,
|
|
42
|
-
target = context.target;
|
|
43
|
-
|
|
44
|
-
return canConnect(source, target);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
this.addRule('connection.reconnectStart', function(context) {
|
|
48
|
-
|
|
49
|
-
var connection = context.connection,
|
|
50
|
-
source = context.hover || context.source,
|
|
51
|
-
target = connection.target;
|
|
52
|
-
|
|
53
|
-
return canConnect(source, target, connection);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
this.addRule('connection.reconnectEnd', function(context) {
|
|
57
|
-
|
|
58
|
-
var connection = context.connection,
|
|
59
|
-
source = connection.source,
|
|
60
|
-
target = context.hover || context.target;
|
|
61
|
-
|
|
62
|
-
return canConnect(source, target, connection);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
this.addRule('connection.updateWaypoints', function(context) {
|
|
66
|
-
// OK! but visually ignore
|
|
67
|
-
return null;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
this.addRule('shape.resize', function(context) {
|
|
71
|
-
|
|
72
|
-
var shape = context.shape,
|
|
73
|
-
newBounds = context.newBounds;
|
|
74
|
-
|
|
75
|
-
return canResize(shape, newBounds);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
this.addRule('elements.move', function(context) {
|
|
79
|
-
|
|
80
|
-
var target = context.target,
|
|
81
|
-
shapes = context.shapes,
|
|
82
|
-
position = context.position;
|
|
83
|
-
|
|
84
|
-
return canAttach(shapes, target, null, position) ||
|
|
85
|
-
canReplace(shapes, target, position) ||
|
|
86
|
-
canMove(shapes, target, position) ||
|
|
87
|
-
canInsert(shapes, target, position);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this.addRule([ 'shape.create', 'shape.append' ], function(context) {
|
|
91
|
-
var target = context.target,
|
|
92
|
-
shape = context.shape,
|
|
93
|
-
source = context.source,
|
|
94
|
-
position = context.position;
|
|
95
|
-
|
|
96
|
-
return canAttach([ shape ], target, source, position) || canCreate(shape, target, source, position);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
this.addRule('element.copy', function(context) {
|
|
100
|
-
var collection = context.collection,
|
|
101
|
-
element = context.element;
|
|
102
|
-
|
|
103
|
-
return canCopy(collection, element);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
this.addRule('element.paste', function(context) {
|
|
107
|
-
var parent = context.parent,
|
|
108
|
-
element = context.element,
|
|
109
|
-
position = context.position,
|
|
110
|
-
source = context.source,
|
|
111
|
-
target = context.target;
|
|
112
|
-
|
|
113
|
-
if (source || target) {
|
|
114
|
-
return canConnect(source, target);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return canAttach([ element ], parent, null, position) || canCreate(element, parent, null, position);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
this.addRule('elements.paste', function(context) {
|
|
121
|
-
var tree = context.tree,
|
|
122
|
-
target = context.target;
|
|
123
|
-
|
|
124
|
-
return canPaste(tree, target);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
this.addRule([ 'elements.delete' ], function(context) {
|
|
128
|
-
|
|
129
|
-
// do not allow deletion of labels
|
|
130
|
-
return filter(context.elements, function(e) {
|
|
131
|
-
return !isLabel(e);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
|
|
137
|
-
|
|
138
|
-
BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow;
|
|
139
|
-
|
|
140
|
-
BpmnRules.prototype.canConnectDataAssociation = canConnectDataAssociation;
|
|
141
|
-
|
|
142
|
-
BpmnRules.prototype.canConnectAssociation = canConnectAssociation;
|
|
143
|
-
|
|
144
|
-
BpmnRules.prototype.canMove = canMove;
|
|
145
|
-
|
|
146
|
-
BpmnRules.prototype.canAttach = canAttach;
|
|
147
|
-
|
|
148
|
-
BpmnRules.prototype.canReplace = canReplace;
|
|
149
|
-
|
|
150
|
-
BpmnRules.prototype.canDrop = canDrop;
|
|
151
|
-
|
|
152
|
-
BpmnRules.prototype.canInsert = canInsert;
|
|
153
|
-
|
|
154
|
-
BpmnRules.prototype.canCreate = canCreate;
|
|
155
|
-
|
|
156
|
-
BpmnRules.prototype.canConnect = canConnect;
|
|
157
|
-
|
|
158
|
-
BpmnRules.prototype.canResize = canResize;
|
|
159
|
-
|
|
160
|
-
BpmnRules.prototype.canCopy = canCopy;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Utility functions for rule checking
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
function nonExistantOrLabel(element) {
|
|
167
|
-
return !element || isLabel(element);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function isSame(a, b) {
|
|
171
|
-
return a === b;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function getOrganizationalParent(element) {
|
|
175
|
-
|
|
176
|
-
var bo = getBusinessObject(element);
|
|
177
|
-
|
|
178
|
-
while (bo && !is(bo, 'bpmn:Process')) {
|
|
179
|
-
if (is(bo, 'bpmn:Participant')) {
|
|
180
|
-
return bo.processRef || bo;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
bo = bo.$parent;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return bo;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function isTextAnnotation(element) {
|
|
190
|
-
return is(element, 'bpmn:TextAnnotation');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function
|
|
210
|
-
return is(element, 'bpmn:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
!
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
//
|
|
406
|
-
if (
|
|
407
|
-
return
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
//
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
*
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (
|
|
659
|
-
return false;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
function canConnectAssociation(source, target) {
|
|
718
|
-
|
|
719
|
-
// do not connect connections
|
|
720
|
-
if (isConnection(source) || isConnection(target)) {
|
|
721
|
-
return false;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// compensation boundary events are exception
|
|
725
|
-
if (isCompensationBoundary(source) && isForCompensation(target)) {
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
//
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
//
|
|
780
|
-
//
|
|
781
|
-
//
|
|
782
|
-
//
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var find = require('lodash/collection/find'),
|
|
4
|
+
any = require('lodash/collection/any'),
|
|
5
|
+
every = require('lodash/collection/every'),
|
|
6
|
+
filter = require('lodash/collection/filter'),
|
|
7
|
+
forEach = require('lodash/collection/forEach'),
|
|
8
|
+
inherits = require('inherits');
|
|
9
|
+
|
|
10
|
+
var is = require('../../util/ModelUtil').is,
|
|
11
|
+
isAny = require('../modeling/util/ModelingUtil').isAny,
|
|
12
|
+
getBusinessObject = require('../../util/ModelUtil').getBusinessObject,
|
|
13
|
+
isExpanded = require('../../util/DiUtil').isExpanded,
|
|
14
|
+
isEventSubProcess = require('../../util/DiUtil').isEventSubProcess,
|
|
15
|
+
isInterrupting = require('../../util/DiUtil').isInterrupting,
|
|
16
|
+
hasErrorEventDefinition = require('../../util/DiUtil').hasErrorEventDefinition,
|
|
17
|
+
hasEscalationEventDefinition = require('../../util/DiUtil').hasEscalationEventDefinition,
|
|
18
|
+
hasCompensateEventDefinition = require('../../util/DiUtil').hasCompensateEventDefinition;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider');
|
|
22
|
+
|
|
23
|
+
var isBoundaryAttachment = require('../snapping/BpmnSnappingUtil').getBoundaryAttachment;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* BPMN specific modeling rule
|
|
27
|
+
*/
|
|
28
|
+
function BpmnRules(eventBus) {
|
|
29
|
+
RuleProvider.call(this, eventBus);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
inherits(BpmnRules, RuleProvider);
|
|
33
|
+
|
|
34
|
+
BpmnRules.$inject = [ 'eventBus' ];
|
|
35
|
+
|
|
36
|
+
module.exports = BpmnRules;
|
|
37
|
+
|
|
38
|
+
BpmnRules.prototype.init = function() {
|
|
39
|
+
|
|
40
|
+
this.addRule('connection.create', function(context) {
|
|
41
|
+
var source = context.source,
|
|
42
|
+
target = context.target;
|
|
43
|
+
|
|
44
|
+
return canConnect(source, target);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.addRule('connection.reconnectStart', function(context) {
|
|
48
|
+
|
|
49
|
+
var connection = context.connection,
|
|
50
|
+
source = context.hover || context.source,
|
|
51
|
+
target = connection.target;
|
|
52
|
+
|
|
53
|
+
return canConnect(source, target, connection);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.addRule('connection.reconnectEnd', function(context) {
|
|
57
|
+
|
|
58
|
+
var connection = context.connection,
|
|
59
|
+
source = connection.source,
|
|
60
|
+
target = context.hover || context.target;
|
|
61
|
+
|
|
62
|
+
return canConnect(source, target, connection);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
this.addRule('connection.updateWaypoints', function(context) {
|
|
66
|
+
// OK! but visually ignore
|
|
67
|
+
return null;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
this.addRule('shape.resize', function(context) {
|
|
71
|
+
|
|
72
|
+
var shape = context.shape,
|
|
73
|
+
newBounds = context.newBounds;
|
|
74
|
+
|
|
75
|
+
return canResize(shape, newBounds);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
this.addRule('elements.move', function(context) {
|
|
79
|
+
|
|
80
|
+
var target = context.target,
|
|
81
|
+
shapes = context.shapes,
|
|
82
|
+
position = context.position;
|
|
83
|
+
|
|
84
|
+
return canAttach(shapes, target, null, position) ||
|
|
85
|
+
canReplace(shapes, target, position) ||
|
|
86
|
+
canMove(shapes, target, position) ||
|
|
87
|
+
canInsert(shapes, target, position);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this.addRule([ 'shape.create', 'shape.append' ], function(context) {
|
|
91
|
+
var target = context.target,
|
|
92
|
+
shape = context.shape,
|
|
93
|
+
source = context.source,
|
|
94
|
+
position = context.position;
|
|
95
|
+
|
|
96
|
+
return canAttach([ shape ], target, source, position) || canCreate(shape, target, source, position);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
this.addRule('element.copy', function(context) {
|
|
100
|
+
var collection = context.collection,
|
|
101
|
+
element = context.element;
|
|
102
|
+
|
|
103
|
+
return canCopy(collection, element);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
this.addRule('element.paste', function(context) {
|
|
107
|
+
var parent = context.parent,
|
|
108
|
+
element = context.element,
|
|
109
|
+
position = context.position,
|
|
110
|
+
source = context.source,
|
|
111
|
+
target = context.target;
|
|
112
|
+
|
|
113
|
+
if (source || target) {
|
|
114
|
+
return canConnect(source, target);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return canAttach([ element ], parent, null, position) || canCreate(element, parent, null, position);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
this.addRule('elements.paste', function(context) {
|
|
121
|
+
var tree = context.tree,
|
|
122
|
+
target = context.target;
|
|
123
|
+
|
|
124
|
+
return canPaste(tree, target);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
this.addRule([ 'elements.delete' ], function(context) {
|
|
128
|
+
|
|
129
|
+
// do not allow deletion of labels
|
|
130
|
+
return filter(context.elements, function(e) {
|
|
131
|
+
return !isLabel(e);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
|
|
137
|
+
|
|
138
|
+
BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow;
|
|
139
|
+
|
|
140
|
+
BpmnRules.prototype.canConnectDataAssociation = canConnectDataAssociation;
|
|
141
|
+
|
|
142
|
+
BpmnRules.prototype.canConnectAssociation = canConnectAssociation;
|
|
143
|
+
|
|
144
|
+
BpmnRules.prototype.canMove = canMove;
|
|
145
|
+
|
|
146
|
+
BpmnRules.prototype.canAttach = canAttach;
|
|
147
|
+
|
|
148
|
+
BpmnRules.prototype.canReplace = canReplace;
|
|
149
|
+
|
|
150
|
+
BpmnRules.prototype.canDrop = canDrop;
|
|
151
|
+
|
|
152
|
+
BpmnRules.prototype.canInsert = canInsert;
|
|
153
|
+
|
|
154
|
+
BpmnRules.prototype.canCreate = canCreate;
|
|
155
|
+
|
|
156
|
+
BpmnRules.prototype.canConnect = canConnect;
|
|
157
|
+
|
|
158
|
+
BpmnRules.prototype.canResize = canResize;
|
|
159
|
+
|
|
160
|
+
BpmnRules.prototype.canCopy = canCopy;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Utility functions for rule checking
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
function nonExistantOrLabel(element) {
|
|
167
|
+
return !element || isLabel(element);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function isSame(a, b) {
|
|
171
|
+
return a === b;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function getOrganizationalParent(element) {
|
|
175
|
+
|
|
176
|
+
var bo = getBusinessObject(element);
|
|
177
|
+
|
|
178
|
+
while (bo && !is(bo, 'bpmn:Process')) {
|
|
179
|
+
if (is(bo, 'bpmn:Participant')) {
|
|
180
|
+
return bo.processRef || bo;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
bo = bo.$parent;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return bo;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isTextAnnotation(element) {
|
|
190
|
+
return is(element, 'bpmn:TextAnnotation');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function isCompensationBoundary(element) {
|
|
194
|
+
return is(element, 'bpmn:BoundaryEvent') &&
|
|
195
|
+
hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function isForCompensation(e) {
|
|
199
|
+
return getBusinessObject(e).isForCompensation;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function isSameOrganization(a, b) {
|
|
203
|
+
var parentA = getOrganizationalParent(a),
|
|
204
|
+
parentB = getOrganizationalParent(b);
|
|
205
|
+
|
|
206
|
+
return parentA === parentB;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function isMessageFlowSource(element) {
|
|
210
|
+
return is(element, 'bpmn:InteractionNode') &&
|
|
211
|
+
!isForCompensation(element) && (
|
|
212
|
+
!is(element, 'bpmn:Event') || (
|
|
213
|
+
is(element, 'bpmn:ThrowEvent') &&
|
|
214
|
+
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function isMessageFlowTarget(element) {
|
|
220
|
+
return is(element, 'bpmn:InteractionNode') &&
|
|
221
|
+
!isForCompensation(element) && (
|
|
222
|
+
!is(element, 'bpmn:Event') || (
|
|
223
|
+
is(element, 'bpmn:CatchEvent') &&
|
|
224
|
+
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function getScopeParent(element) {
|
|
230
|
+
|
|
231
|
+
var bo = getBusinessObject(element);
|
|
232
|
+
|
|
233
|
+
if (is(bo, 'bpmn:Participant')) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
while (bo) {
|
|
238
|
+
bo = bo.$parent;
|
|
239
|
+
|
|
240
|
+
if (is(bo, 'bpmn:FlowElementsContainer')) {
|
|
241
|
+
return bo;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return bo;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function isSameScope(a, b) {
|
|
249
|
+
var scopeParentA = getScopeParent(a),
|
|
250
|
+
scopeParentB = getScopeParent(b);
|
|
251
|
+
|
|
252
|
+
return scopeParentA && (scopeParentA === scopeParentB);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function hasEventDefinition(element, eventDefinition) {
|
|
256
|
+
var bo = getBusinessObject(element);
|
|
257
|
+
|
|
258
|
+
return !!find(bo.eventDefinitions || [], function(definition) {
|
|
259
|
+
return is(definition, eventDefinition);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function hasEventDefinitionOrNone(element, eventDefinition) {
|
|
264
|
+
var bo = getBusinessObject(element);
|
|
265
|
+
|
|
266
|
+
return (bo.eventDefinitions || []).every(function(definition) {
|
|
267
|
+
return is(definition, eventDefinition);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function isSequenceFlowSource(element) {
|
|
272
|
+
return is(element, 'bpmn:FlowNode') &&
|
|
273
|
+
!is(element, 'bpmn:EndEvent') &&
|
|
274
|
+
!isEventSubProcess(element) &&
|
|
275
|
+
!(is(element, 'bpmn:IntermediateThrowEvent') &&
|
|
276
|
+
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
|
|
277
|
+
) &&
|
|
278
|
+
!isCompensationBoundary(element) &&
|
|
279
|
+
!isForCompensation(element);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function isSequenceFlowTarget(element) {
|
|
283
|
+
return is(element, 'bpmn:FlowNode') &&
|
|
284
|
+
!is(element, 'bpmn:StartEvent') &&
|
|
285
|
+
!is(element, 'bpmn:BoundaryEvent') &&
|
|
286
|
+
!isEventSubProcess(element) &&
|
|
287
|
+
!(is(element, 'bpmn:IntermediateCatchEvent') &&
|
|
288
|
+
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
|
|
289
|
+
) &&
|
|
290
|
+
!isForCompensation(element);
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function isEventBasedTarget(element) {
|
|
295
|
+
return is(element, 'bpmn:ReceiveTask') || (
|
|
296
|
+
is(element, 'bpmn:IntermediateCatchEvent') && (
|
|
297
|
+
hasEventDefinition(element, 'bpmn:MessageEventDefinition') ||
|
|
298
|
+
hasEventDefinition(element, 'bpmn:TimerEventDefinition') ||
|
|
299
|
+
hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') ||
|
|
300
|
+
hasEventDefinition(element, 'bpmn:SignalEventDefinition')
|
|
301
|
+
)
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function isLabel(element) {
|
|
306
|
+
return element.labelTarget;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function isConnection(element) {
|
|
310
|
+
return element.waypoints;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function getParents(element) {
|
|
314
|
+
|
|
315
|
+
var parents = [];
|
|
316
|
+
|
|
317
|
+
while (element) {
|
|
318
|
+
element = element.parent;
|
|
319
|
+
|
|
320
|
+
if (element) {
|
|
321
|
+
parents.push(element);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return parents;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function isParent(possibleParent, element) {
|
|
329
|
+
var allParents = getParents(element);
|
|
330
|
+
return allParents.indexOf(possibleParent) !== -1;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function canConnect(source, target, connection) {
|
|
334
|
+
|
|
335
|
+
if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// See https://github.com/bpmn-io/bpmn-js/issues/178
|
|
340
|
+
// as a workround we disallow connections with same
|
|
341
|
+
// target and source element.
|
|
342
|
+
// This rule must be removed if a auto layout for this
|
|
343
|
+
// connections is implemented.
|
|
344
|
+
if (isSame(source, target)) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (!is(connection, 'bpmn:DataAssociation')) {
|
|
349
|
+
|
|
350
|
+
if (canConnectMessageFlow(source, target)) {
|
|
351
|
+
return { type: 'bpmn:MessageFlow' };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (canConnectSequenceFlow(source, target)) {
|
|
355
|
+
return { type: 'bpmn:SequenceFlow' };
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
var connectDataAssociation = canConnectDataAssociation(source, target);
|
|
360
|
+
|
|
361
|
+
if (connectDataAssociation) {
|
|
362
|
+
return connectDataAssociation;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (isCompensationBoundary(source) && isForCompensation(target)) {
|
|
366
|
+
return {
|
|
367
|
+
type: 'bpmn:Association',
|
|
368
|
+
associationDirection: 'One'
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (canConnectAssociation(source, target)) {
|
|
373
|
+
|
|
374
|
+
return {
|
|
375
|
+
type: 'bpmn:Association'
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Can an element be dropped into the target element
|
|
384
|
+
*
|
|
385
|
+
* @return {Boolean}
|
|
386
|
+
*/
|
|
387
|
+
function canDrop(element, target, position) {
|
|
388
|
+
|
|
389
|
+
// can move labels everywhere
|
|
390
|
+
if (isLabel(element) && !isConnection(target)) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// disallow to create elements on collapsed pools
|
|
395
|
+
if (is(target, 'bpmn:Participant') && !isExpanded(target)) {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// allow to create new participants on
|
|
400
|
+
// on existing collaboration and process diagrams
|
|
401
|
+
if (is(element, 'bpmn:Participant')) {
|
|
402
|
+
return is(target, 'bpmn:Process') || is(target, 'bpmn:Collaboration');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// allow creating lanes on participants and other lanes only
|
|
406
|
+
if (is(element, 'bpmn:Lane')) {
|
|
407
|
+
return is(target, 'bpmn:Participant') || is(target, 'bpmn:Lane');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (is(element, 'bpmn:BoundaryEvent')) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// drop flow elements onto flow element containers
|
|
415
|
+
// and participants
|
|
416
|
+
if (is(element, 'bpmn:FlowElement')) {
|
|
417
|
+
if (is(target, 'bpmn:FlowElementsContainer')) {
|
|
418
|
+
return isExpanded(target);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// account for the fact that data associations are always
|
|
425
|
+
// rendered and moved to top (Process or Collaboration level)
|
|
426
|
+
//
|
|
427
|
+
// artifacts may be placed wherever, too
|
|
428
|
+
if (isAny(element, [ 'bpmn:Artifact', 'bpmn:DataAssociation' ])) {
|
|
429
|
+
return isAny(target, [
|
|
430
|
+
'bpmn:Collaboration',
|
|
431
|
+
'bpmn:Lane',
|
|
432
|
+
'bpmn:Participant',
|
|
433
|
+
'bpmn:Process',
|
|
434
|
+
'bpmn:SubProcess' ]);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (is(element, 'bpmn:MessageFlow')) {
|
|
438
|
+
return is(target, 'bpmn:Collaboration')
|
|
439
|
+
|| element.source.parent == target
|
|
440
|
+
|| element.target.parent == target;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function canPaste(tree, target) {
|
|
447
|
+
var topLevel = tree[0],
|
|
448
|
+
participants;
|
|
449
|
+
|
|
450
|
+
if (is(target, 'bpmn:Collaboration')) {
|
|
451
|
+
return every(topLevel, function(e) {
|
|
452
|
+
return e.type === 'bpmn:Participant';
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (is(target, 'bpmn:Process')) {
|
|
457
|
+
participants = any(topLevel, function(e) {
|
|
458
|
+
return e.type === 'bpmn:Participant';
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
return !(participants && target.children.length > 0);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// disallow to create elements on collapsed pools
|
|
465
|
+
if (is(target, 'bpmn:Participant') && !isExpanded(target)) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (is(target, 'bpmn:FlowElementsContainer')) {
|
|
470
|
+
return isExpanded(target);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return isAny(target, [
|
|
474
|
+
'bpmn:Collaboration',
|
|
475
|
+
'bpmn:Lane',
|
|
476
|
+
'bpmn:Participant',
|
|
477
|
+
'bpmn:Process',
|
|
478
|
+
'bpmn:SubProcess' ]);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function isBoundaryEvent(element) {
|
|
482
|
+
return !isLabel(element) && is(element, 'bpmn:BoundaryEvent');
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function isLane(element) {
|
|
486
|
+
return is(element, 'bpmn:Lane');
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* We treat IntermediateThrowEvents as boundary events during create,
|
|
491
|
+
* this must be reflected in the rules.
|
|
492
|
+
*/
|
|
493
|
+
function isBoundaryCandidate(element) {
|
|
494
|
+
return isBoundaryEvent(element) ||
|
|
495
|
+
(is(element, 'bpmn:IntermediateThrowEvent') && !element.parent);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
function canAttach(elements, target, source, position) {
|
|
500
|
+
|
|
501
|
+
if (!Array.isArray(elements)) {
|
|
502
|
+
elements = [ elements ];
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// disallow appending as boundary event
|
|
506
|
+
if (source) {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// only (re-)attach one element at a time
|
|
511
|
+
if (elements.length !== 1) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
var element = elements[0];
|
|
516
|
+
|
|
517
|
+
// do not attach labels
|
|
518
|
+
if (isLabel(element)) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// only handle boundary events
|
|
523
|
+
if (!isBoundaryCandidate(element)) {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// allow default move operation
|
|
528
|
+
if (!target) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// disallow drop on event sub processes
|
|
533
|
+
if (isEventSubProcess(target)) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// only allow drop on non compensation activities
|
|
538
|
+
if (!is(target, 'bpmn:Activity') || isForCompensation(target)) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// only attach to subprocess border
|
|
543
|
+
if (position && !isBoundaryAttachment(position, target)) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return 'attach';
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Defines how to replace elements for a given target.
|
|
553
|
+
*
|
|
554
|
+
* Returns an array containing all elements which will be replaced.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
*
|
|
558
|
+
* [{ id: 'IntermediateEvent_2',
|
|
559
|
+
* type: 'bpmn:StartEvent'
|
|
560
|
+
* },
|
|
561
|
+
* { id: 'IntermediateEvent_5',
|
|
562
|
+
* type: 'bpmn:EndEvent'
|
|
563
|
+
* }]
|
|
564
|
+
*
|
|
565
|
+
* @param {Array} elements
|
|
566
|
+
* @param {Object} target
|
|
567
|
+
*
|
|
568
|
+
* @return {Object} an object containing all elements which have to be replaced
|
|
569
|
+
*/
|
|
570
|
+
function canReplace(elements, target, position) {
|
|
571
|
+
|
|
572
|
+
if (!target) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
var canExecute = {
|
|
577
|
+
replacements: []
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
forEach(elements, function(element) {
|
|
581
|
+
|
|
582
|
+
if (!isEventSubProcess(target)) {
|
|
583
|
+
|
|
584
|
+
if (is(element, 'bpmn:StartEvent') &&
|
|
585
|
+
element.type !== 'label' &&
|
|
586
|
+
canDrop(element, target)) {
|
|
587
|
+
|
|
588
|
+
// replace a non-interrupting start event by a blank interrupting start event
|
|
589
|
+
// when the target is not an event sub process
|
|
590
|
+
if (!isInterrupting(element)) {
|
|
591
|
+
canExecute.replacements.push({
|
|
592
|
+
oldElementId: element.id,
|
|
593
|
+
newElementType: 'bpmn:StartEvent'
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// replace an error/escalation/compansate start event by a blank interrupting start event
|
|
598
|
+
// when the target is not an event sub process
|
|
599
|
+
if (hasErrorEventDefinition(element) ||
|
|
600
|
+
hasEscalationEventDefinition(element) ||
|
|
601
|
+
hasCompensateEventDefinition(element)) {
|
|
602
|
+
canExecute.replacements.push({
|
|
603
|
+
oldElementId: element.id,
|
|
604
|
+
newElementType: 'bpmn:StartEvent'
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (!is(target, 'bpmn:Transaction')) {
|
|
611
|
+
if (hasEventDefinition(element, 'bpmn:CancelEventDefinition') &&
|
|
612
|
+
element.type !== 'label') {
|
|
613
|
+
|
|
614
|
+
if (is(element, 'bpmn:EndEvent') && canDrop(element, target)) {
|
|
615
|
+
canExecute.replacements.push({
|
|
616
|
+
oldElementId: element.id,
|
|
617
|
+
newElementType: 'bpmn:EndEvent'
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (is(element, 'bpmn:BoundaryEvent') && canAttach(element, target, null, position)) {
|
|
622
|
+
canExecute.replacements.push({
|
|
623
|
+
oldElementId: element.id,
|
|
624
|
+
newElementType: 'bpmn:BoundaryEvent'
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
return canExecute.replacements.length ? canExecute : false;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function canMove(elements, target) {
|
|
635
|
+
|
|
636
|
+
// do not move selection containing boundary events
|
|
637
|
+
if (any(elements, isBoundaryEvent)) {
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// do not move selection containing lanes
|
|
642
|
+
if (any(elements, isLane)) {
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// allow default move check to start move operation
|
|
647
|
+
if (!target) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
return elements.every(function(element) {
|
|
652
|
+
return canDrop(element, target);
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function canCreate(shape, target, source, position) {
|
|
657
|
+
|
|
658
|
+
if (!target) {
|
|
659
|
+
return false;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (isLabel(target)) {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (isSame(source, target)) {
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ensure we do not drop the element
|
|
671
|
+
// into source
|
|
672
|
+
if (source && isParent(source, target)) {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return canDrop(shape, target, position) || canInsert(shape, target, position);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function canResize(shape, newBounds) {
|
|
680
|
+
if (is(shape, 'bpmn:SubProcess')) {
|
|
681
|
+
return (!!isExpanded(shape)) && (
|
|
682
|
+
!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (is(shape, 'bpmn:Lane')) {
|
|
687
|
+
return !newBounds || (newBounds.width >= 130 && newBounds.height >= 60);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (is(shape, 'bpmn:Participant')) {
|
|
691
|
+
return !newBounds || (newBounds.width >= 250 && newBounds.height >= 50);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (isTextAnnotation(shape)) {
|
|
695
|
+
return true;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return false;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Check, whether one side of the relationship
|
|
703
|
+
* is a text annotation.
|
|
704
|
+
*/
|
|
705
|
+
function isOneTextAnnotation(source, target) {
|
|
706
|
+
|
|
707
|
+
var sourceTextAnnotation = isTextAnnotation(source),
|
|
708
|
+
targetTextAnnotation = isTextAnnotation(target);
|
|
709
|
+
|
|
710
|
+
return (
|
|
711
|
+
(sourceTextAnnotation || targetTextAnnotation) &&
|
|
712
|
+
(sourceTextAnnotation !== targetTextAnnotation)
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
function canConnectAssociation(source, target) {
|
|
718
|
+
|
|
719
|
+
// do not connect connections
|
|
720
|
+
if (isConnection(source) || isConnection(target)) {
|
|
721
|
+
return false;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// compensation boundary events are exception
|
|
725
|
+
if (isCompensationBoundary(source) && isForCompensation(target)) {
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// don't connect parent <-> child
|
|
730
|
+
if (isParent(target, source) || isParent(source, target)) {
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// allow connection of associations between <!TextAnnotation> and <TextAnnotation>
|
|
735
|
+
return isOneTextAnnotation(source, target);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function canConnectMessageFlow(source, target) {
|
|
739
|
+
|
|
740
|
+
return isMessageFlowSource(source) &&
|
|
741
|
+
isMessageFlowTarget(target) &&
|
|
742
|
+
!isSameOrganization(source, target);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function canConnectSequenceFlow(source, target) {
|
|
746
|
+
|
|
747
|
+
return isSequenceFlowSource(source) &&
|
|
748
|
+
isSequenceFlowTarget(target) &&
|
|
749
|
+
isSameScope(source, target) &&
|
|
750
|
+
!(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target));
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
function canConnectDataAssociation(source, target) {
|
|
755
|
+
|
|
756
|
+
if (isAny(source, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ]) &&
|
|
757
|
+
isAny(target, [ 'bpmn:Activity', 'bpmn:ThrowEvent' ])) {
|
|
758
|
+
return { type: 'bpmn:DataInputAssociation' };
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (isAny(target, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ]) &&
|
|
762
|
+
isAny(source, [ 'bpmn:Activity', 'bpmn:CatchEvent' ])) {
|
|
763
|
+
return { type: 'bpmn:DataOutputAssociation' };
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function canInsert(shape, flow, position) {
|
|
770
|
+
|
|
771
|
+
if (Array.isArray(shape)) {
|
|
772
|
+
if (shape.length !== 1) {
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
shape = shape[0];
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// return true if we can drop on the
|
|
780
|
+
// underlying flow parent
|
|
781
|
+
//
|
|
782
|
+
// at this point we are not really able to talk
|
|
783
|
+
// about connection rules (yet)
|
|
784
|
+
|
|
785
|
+
return (
|
|
786
|
+
isAny(flow, [ 'bpmn:SequenceFlow', 'bpmn:MessageFlow' ]) &&
|
|
787
|
+
!isLabel(flow) &&
|
|
788
|
+
is(shape, 'bpmn:FlowNode') &&
|
|
789
|
+
!is(shape, 'bpmn:BoundaryEvent') &&
|
|
790
|
+
canDrop(shape, flow.parent, position));
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function contains(collection, element) {
|
|
794
|
+
return (collection && element) && collection.indexOf(element) !== -1;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function canCopy(collection, element) {
|
|
798
|
+
if (is(element, 'bpmn:Lane') && !contains(collection, element.parent)) {
|
|
799
|
+
return false;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (is(element, 'bpmn:BoundaryEvent') && !contains(collection, element.host)) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
return true;
|
|
807
|
+
}
|