bpmn-js 18.2.0 → 18.3.0
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/LICENSE +23 -23
- package/README.md +95 -95
- package/dist/assets/bpmn-js.css +145 -145
- package/dist/bpmn-modeler.development.js +38704 -38477
- package/dist/bpmn-modeler.production.min.js +11 -11
- package/dist/bpmn-navigated-viewer.development.js +21139 -21139
- package/dist/bpmn-navigated-viewer.production.min.js +1 -1
- package/dist/bpmn-viewer.development.js +21080 -21080
- package/dist/bpmn-viewer.production.min.js +1 -1
- package/lib/BaseModeler.d.ts +15 -15
- package/lib/BaseModeler.js +79 -79
- package/lib/BaseViewer.d.ts +352 -352
- package/lib/BaseViewer.js +858 -858
- package/lib/Modeler.d.ts +86 -86
- package/lib/Modeler.js +206 -206
- package/lib/NavigatedViewer.d.ts +11 -11
- package/lib/NavigatedViewer.js +37 -37
- package/lib/Viewer.d.ts +47 -47
- package/lib/Viewer.js +76 -76
- package/lib/core/index.d.ts +10 -10
- package/lib/core/index.js +8 -8
- package/lib/draw/BpmnRenderUtil.d.ts +123 -123
- package/lib/draw/BpmnRenderUtil.js +256 -256
- package/lib/draw/BpmnRenderer.d.ts +116 -116
- package/lib/draw/BpmnRenderer.js +2339 -2339
- package/lib/draw/PathMap.d.ts +330 -330
- package/lib/draw/PathMap.js +478 -478
- package/lib/draw/TextRenderer.d.ts +74 -74
- package/lib/draw/TextRenderer.js +136 -136
- package/lib/draw/index.d.ts +10 -10
- package/lib/draw/index.js +11 -11
- package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +32 -32
- package/lib/features/align-elements/AlignElementsContextPadProvider.js +105 -105
- package/lib/features/align-elements/AlignElementsIcons.d.ts +10 -10
- package/lib/features/align-elements/AlignElementsIcons.js +43 -43
- package/lib/features/align-elements/AlignElementsMenuProvider.d.ts +32 -32
- package/lib/features/align-elements/AlignElementsMenuProvider.js +100 -100
- package/lib/features/align-elements/BpmnAlignElements.d.ts +9 -9
- package/lib/features/align-elements/BpmnAlignElements.js +45 -45
- package/lib/features/align-elements/index.d.ts +11 -11
- package/lib/features/align-elements/index.js +23 -23
- package/lib/features/append-preview/AppendPreview.d.ts +36 -36
- package/lib/features/append-preview/AppendPreview.js +108 -108
- package/lib/features/append-preview/index.d.ts +16 -16
- package/lib/features/append-preview/index.js +15 -15
- package/lib/features/auto-place/BpmnAutoPlace.d.ts +15 -15
- package/lib/features/auto-place/BpmnAutoPlace.js +22 -22
- package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +52 -52
- package/lib/features/auto-place/BpmnAutoPlaceUtil.js +226 -226
- package/lib/features/auto-place/index.d.ts +7 -7
- package/lib/features/auto-place/index.js +8 -8
- package/lib/features/auto-resize/BpmnAutoResize.d.ts +25 -25
- package/lib/features/auto-resize/BpmnAutoResize.js +45 -45
- package/lib/features/auto-resize/BpmnAutoResizeProvider.d.ts +26 -26
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +69 -69
- package/lib/features/auto-resize/index.d.ts +8 -8
- package/lib/features/auto-resize/index.js +12 -12
- package/lib/features/context-pad/ContextPadProvider.d.ts +62 -62
- package/lib/features/context-pad/ContextPadProvider.js +582 -582
- package/lib/features/context-pad/index.d.ts +7 -7
- package/lib/features/context-pad/index.js +22 -22
- package/lib/features/copy-paste/BpmnCopyPaste.d.ts +17 -17
- package/lib/features/copy-paste/BpmnCopyPaste.js +192 -192
- package/lib/features/copy-paste/ModdleCopy.d.ts +45 -45
- package/lib/features/copy-paste/index.d.ts +9 -9
- package/lib/features/copy-paste/index.js +13 -13
- package/lib/features/di-ordering/BpmnDiOrdering.d.ts +11 -11
- package/lib/features/di-ordering/BpmnDiOrdering.js +48 -48
- package/lib/features/di-ordering/index.d.ts +6 -6
- package/lib/features/di-ordering/index.js +7 -7
- package/lib/features/distribute-elements/BpmnDistributeElements.d.ts +10 -10
- package/lib/features/distribute-elements/BpmnDistributeElements.js +60 -60
- package/lib/features/distribute-elements/DistributeElementsIcons.d.ts +5 -5
- package/lib/features/distribute-elements/DistributeElementsIcons.js +18 -18
- package/lib/features/distribute-elements/DistributeElementsMenuProvider.d.ts +32 -32
- package/lib/features/distribute-elements/DistributeElementsMenuProvider.js +92 -92
- package/lib/features/distribute-elements/index.d.ts +9 -9
- package/lib/features/distribute-elements/index.js +19 -19
- package/lib/features/drilldown/DrilldownBreadcrumbs.d.ts +19 -19
- package/lib/features/drilldown/DrilldownBreadcrumbs.js +138 -138
- package/lib/features/drilldown/DrilldownCentering.d.ts +17 -17
- package/lib/features/drilldown/DrilldownCentering.js +122 -122
- package/lib/features/drilldown/DrilldownOverlayBehavior.d.ts +20 -20
- package/lib/features/drilldown/DrilldownOverlayBehavior.js +218 -218
- package/lib/features/drilldown/SubprocessCompatibility.d.ts +21 -21
- package/lib/features/drilldown/SubprocessCompatibility.js +266 -266
- package/lib/features/drilldown/index.d.ts +13 -13
- package/lib/features/drilldown/index.js +16 -16
- package/lib/features/editor-actions/BpmnEditorActions.d.ts +13 -13
- package/lib/features/editor-actions/BpmnEditorActions.js +187 -187
- package/lib/features/editor-actions/index.d.ts +6 -6
- package/lib/features/editor-actions/index.js +10 -10
- package/lib/features/grid-snapping/BpmnGridSnapping.d.ts +9 -9
- package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +14 -14
- package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.d.ts +27 -27
- package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.js +155 -155
- package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.d.ts +13 -13
- package/lib/features/grid-snapping/behavior/index.d.ts +10 -10
- package/lib/features/grid-snapping/index.d.ts +11 -11
- package/lib/features/interaction-events/BpmnInteractionEvents.d.ts +18 -18
- package/lib/features/interaction-events/BpmnInteractionEvents.js +146 -146
- package/lib/features/interaction-events/index.d.ts +6 -6
- package/lib/features/interaction-events/index.js +5 -5
- package/lib/features/keyboard/BpmnKeyboardBindings.d.ts +15 -15
- package/lib/features/keyboard/BpmnKeyboardBindings.js +179 -179
- package/lib/features/keyboard/index.d.ts +7 -7
- package/lib/features/keyboard/index.js +11 -11
- package/lib/features/label-editing/LabelEditingPreview.d.ts +13 -13
- package/lib/features/label-editing/LabelEditingPreview.js +145 -145
- package/lib/features/label-editing/LabelEditingProvider.d.ts +62 -62
- package/lib/features/label-editing/LabelEditingProvider.js +519 -519
- package/lib/features/label-editing/LabelUtil.d.ts +1 -1
- package/lib/features/label-editing/LabelUtil.js +4 -4
- package/lib/features/label-editing/cmd/UpdateLabelHandler.d.ts +22 -22
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +149 -149
- package/lib/features/label-editing/index.d.ts +9 -9
- package/lib/features/label-editing/index.js +21 -21
- package/lib/features/modeling/BpmnFactory.d.ts +73 -73
- package/lib/features/modeling/BpmnFactory.js +180 -180
- package/lib/features/modeling/BpmnLayouter.d.ts +30 -30
- package/lib/features/modeling/BpmnLayouter.js +488 -488
- package/lib/features/modeling/BpmnUpdater.d.ts +90 -90
- package/lib/features/modeling/BpmnUpdater.js +818 -818
- package/lib/features/modeling/ElementFactory.d.ts +117 -117
- package/lib/features/modeling/ElementFactory.js +412 -412
- package/lib/features/modeling/ElementFactory.test.ts +132 -132
- package/lib/features/modeling/Modeling.d.ts +150 -150
- package/lib/features/modeling/Modeling.js +309 -309
- package/lib/features/modeling/Modeling.test.ts +147 -147
- package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.d.ts +19 -19
- package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js +288 -288
- package/lib/features/modeling/behavior/AppendBehavior.d.ts +6 -6
- package/lib/features/modeling/behavior/AppendBehavior.js +42 -42
- package/lib/features/modeling/behavior/AssociationBehavior.d.ts +11 -11
- package/lib/features/modeling/behavior/AttachEventBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/AttachEventBehavior.js +106 -106
- package/lib/features/modeling/behavior/BoundaryEventBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/BoundaryEventBehavior.js +74 -74
- package/lib/features/modeling/behavior/CompensateBoundaryEventBehavior.d.ts +17 -17
- package/lib/features/modeling/behavior/CompensateBoundaryEventBehavior.js +222 -222
- package/lib/features/modeling/behavior/CreateBehavior.d.ts +9 -9
- package/lib/features/modeling/behavior/CreateBehavior.js +33 -33
- package/lib/features/modeling/behavior/CreateDataObjectBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +43 -43
- package/lib/features/modeling/behavior/CreateParticipantBehavior.d.ts +19 -19
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +237 -237
- package/lib/features/modeling/behavior/DataInputAssociationBehavior.d.ts +21 -21
- package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +162 -162
- package/lib/features/modeling/behavior/DataStoreBehavior.d.ts +19 -19
- package/lib/features/modeling/behavior/DeleteLaneBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/DeleteLaneBehavior.js +162 -162
- package/lib/features/modeling/behavior/DetachEventBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/DetachEventBehavior.js +101 -101
- package/lib/features/modeling/behavior/DropOnFlowBehavior.d.ts +13 -13
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +221 -221
- package/lib/features/modeling/behavior/EventBasedGatewayBehavior.d.ts +11 -11
- package/lib/features/modeling/behavior/EventBasedGatewayBehavior.js +110 -110
- package/lib/features/modeling/behavior/FixHoverBehavior.d.ts +17 -17
- package/lib/features/modeling/behavior/GroupBehavior.d.ts +26 -26
- package/lib/features/modeling/behavior/ImportDockingFix.d.ts +13 -13
- package/lib/features/modeling/behavior/ImportDockingFix.js +83 -83
- package/lib/features/modeling/behavior/IsHorizontalFix.d.ts +10 -10
- package/lib/features/modeling/behavior/IsHorizontalFix.js +54 -54
- package/lib/features/modeling/behavior/LabelBehavior.d.ts +56 -56
- package/lib/features/modeling/behavior/LabelBehavior.js +364 -364
- package/lib/features/modeling/behavior/LayoutConnectionBehavior.d.ts +16 -16
- package/lib/features/modeling/behavior/LayoutConnectionBehavior.js +121 -121
- package/lib/features/modeling/behavior/MessageFlowBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/NonInterruptingBehavior.d.ts +4 -4
- package/lib/features/modeling/behavior/NonInterruptingBehavior.js +41 -41
- package/lib/features/modeling/behavior/RemoveElementBehavior.d.ts +13 -13
- package/lib/features/modeling/behavior/RemoveElementBehavior.js +91 -91
- package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.d.ts +16 -16
- package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.js +41 -41
- package/lib/features/modeling/behavior/RemoveParticipantBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +59 -59
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +194 -194
- package/lib/features/modeling/behavior/ReplaceElementBehaviour.d.ts +23 -23
- package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +144 -144
- package/lib/features/modeling/behavior/ResizeBehavior.d.ts +64 -64
- package/lib/features/modeling/behavior/ResizeBehavior.js +265 -265
- package/lib/features/modeling/behavior/ResizeLaneBehavior.d.ts +16 -16
- package/lib/features/modeling/behavior/ResizeLaneBehavior.js +70 -70
- package/lib/features/modeling/behavior/RootElementReferenceBehavior.d.ts +25 -25
- package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.d.ts +16 -16
- package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.js +66 -66
- package/lib/features/modeling/behavior/SpaceToolBehavior.d.ts +10 -10
- package/lib/features/modeling/behavior/SpaceToolBehavior.js +207 -207
- package/lib/features/modeling/behavior/SubProcessPlaneBehavior.d.ts +28 -28
- package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +588 -588
- package/lib/features/modeling/behavior/SubProcessStartEventBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/SubProcessStartEventBehavior.js +55 -55
- package/lib/features/modeling/behavior/TextAnnotationBehavior.d.ts +6 -6
- package/lib/features/modeling/behavior/TextAnnotationBehavior.js +42 -42
- package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.d.ts +14 -14
- package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +87 -87
- package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.d.ts +13 -13
- package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +156 -156
- package/lib/features/modeling/behavior/UnclaimIdBehavior.d.ts +19 -19
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +64 -64
- package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.d.ts +16 -16
- package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +59 -59
- package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts +15 -15
- package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +157 -157
- package/lib/features/modeling/behavior/index.d.ts +2 -2
- package/lib/features/modeling/behavior/index.js +131 -131
- package/lib/features/modeling/behavior/util/CategoryUtil.d.ts +49 -49
- package/lib/features/modeling/behavior/util/CategoryUtil.js +86 -86
- package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.d.ts +19 -19
- package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.js +22 -22
- package/lib/features/modeling/behavior/util/GeometricUtil.d.ts +1 -1
- package/lib/features/modeling/behavior/util/LabelLayoutUtil.d.ts +32 -32
- package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +41 -41
- package/lib/features/modeling/behavior/util/LayoutUtil.d.ts +48 -48
- package/lib/features/modeling/behavior/util/LayoutUtil.js +259 -259
- package/lib/features/modeling/behavior/util/LineAttachmentUtil.d.ts +37 -37
- package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +241 -241
- package/lib/features/modeling/behavior/util/LineIntersect.d.ts +13 -13
- package/lib/features/modeling/behavior/util/LineIntersect.js +39 -39
- package/lib/features/modeling/behavior/util/NonInterruptingUtil.d.ts +3 -3
- package/lib/features/modeling/behavior/util/NonInterruptingUtil.js +32 -32
- package/lib/features/modeling/behavior/util/ResizeUtil.d.ts +1 -1
- package/lib/features/modeling/cmd/AddLaneHandler.d.ts +22 -22
- package/lib/features/modeling/cmd/AddLaneHandler.js +187 -187
- package/lib/features/modeling/cmd/IdClaimHandler.d.ts +22 -22
- package/lib/features/modeling/cmd/IdClaimHandler.js +51 -51
- package/lib/features/modeling/cmd/ResizeLaneHandler.d.ts +39 -39
- package/lib/features/modeling/cmd/ResizeLaneHandler.js +146 -146
- package/lib/features/modeling/cmd/SetColorHandler.d.ts +18 -18
- package/lib/features/modeling/cmd/SplitLaneHandler.d.ts +20 -20
- package/lib/features/modeling/cmd/SplitLaneHandler.js +99 -99
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.d.ts +20 -20
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +99 -99
- package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts +21 -21
- package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +218 -218
- package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.d.ts +20 -20
- package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.js +107 -107
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.d.ts +58 -58
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +260 -260
- package/lib/features/modeling/cmd/UpdateSemanticParentHandler.d.ts +18 -18
- package/lib/features/modeling/index.d.ts +27 -27
- package/lib/features/modeling/index.js +45 -45
- package/lib/features/modeling/util/LaneUtil.d.ts +46 -46
- package/lib/features/modeling/util/LaneUtil.js +188 -188
- package/lib/features/modeling/util/ModelingUtil.d.ts +23 -23
- package/lib/features/modeling/util/ModelingUtil.js +88 -88
- package/lib/features/modeling-feedback/ModelingFeedback.d.ts +13 -13
- package/lib/features/modeling-feedback/ModelingFeedback.js +46 -46
- package/lib/features/modeling-feedback/index.d.ts +7 -7
- package/lib/features/modeling-feedback/index.js +12 -12
- package/lib/features/ordering/BpmnOrderingProvider.d.ts +19 -19
- package/lib/features/ordering/BpmnOrderingProvider.js +191 -191
- package/lib/features/ordering/index.d.ts +6 -6
- package/lib/features/ordering/index.js +5 -5
- package/lib/features/outline/OutlineProvider.d.ts +39 -39
- package/lib/features/outline/OutlineProvider.js +189 -189
- package/lib/features/outline/OutlineUtil.d.ts +23 -23
- package/lib/features/outline/OutlineUtil.js +35 -35
- package/lib/features/outline/index.d.ts +7 -7
- package/lib/features/outline/index.js +10 -10
- package/lib/features/palette/PaletteProvider.d.ts +34 -34
- package/lib/features/palette/PaletteProvider.js +214 -214
- package/lib/features/palette/index.d.ts +9 -9
- package/lib/features/palette/index.js +23 -23
- package/lib/features/popup-menu/ReplaceMenuProvider.d.ts +52 -52
- package/lib/features/popup-menu/ReplaceMenuProvider.js +656 -629
- package/lib/features/popup-menu/index.d.ts +11 -11
- package/lib/features/popup-menu/index.js +16 -16
- package/lib/features/popup-menu/util/Icons.d.ts +5 -5
- package/lib/features/popup-menu/util/Icons.js +14 -14
- package/lib/features/popup-menu/util/TypeUtil.d.ts +14 -14
- package/lib/features/popup-menu/util/TypeUtil.js +52 -52
- package/lib/features/replace/BpmnReplace.d.ts +45 -45
- package/lib/features/replace/BpmnReplace.js +391 -391
- package/lib/features/replace/ReplaceOptions.d.ts +85 -79
- package/lib/features/replace/ReplaceOptions.js +1198 -998
- package/lib/features/replace/index.d.ts +9 -9
- package/lib/features/replace/index.js +14 -14
- package/lib/features/replace-preview/BpmnReplacePreview.d.ts +17 -17
- package/lib/features/replace-preview/BpmnReplacePreview.js +139 -139
- package/lib/features/replace-preview/index.d.ts +7 -7
- package/lib/features/replace-preview/index.js +11 -11
- package/lib/features/rules/BpmnRules.d.ts +181 -181
- package/lib/features/rules/BpmnRules.js +1191 -1191
- package/lib/features/rules/index.d.ts +7 -7
- package/lib/features/rules/index.js +11 -11
- package/lib/features/search/BpmnSearchProvider.d.ts +34 -34
- package/lib/features/search/BpmnSearchProvider.js +91 -91
- package/lib/features/search/index.d.ts +7 -7
- package/lib/features/search/index.js +14 -14
- package/lib/features/snapping/BpmnConnectSnapping.d.ts +17 -17
- package/lib/features/snapping/BpmnCreateMoveSnapping.d.ts +41 -41
- package/lib/features/snapping/BpmnCreateMoveSnapping.js +289 -289
- package/lib/features/snapping/BpmnSnappingUtil.d.ts +11 -11
- package/lib/features/snapping/index.d.ts +9 -9
- package/lib/features/snapping/index.js +12 -12
- package/lib/features/space-tool/BpmnSpaceTool.d.ts +21 -21
- package/lib/features/space-tool/BpmnSpaceTool.js +69 -69
- package/lib/features/space-tool/index.d.ts +6 -6
- package/lib/features/space-tool/index.js +7 -7
- package/lib/import/BpmnImporter.d.ts +51 -51
- package/lib/import/BpmnImporter.js +363 -363
- package/lib/import/BpmnTreeWalker.d.ts +20 -20
- package/lib/import/BpmnTreeWalker.js +453 -453
- package/lib/import/Importer.d.ts +25 -25
- package/lib/import/Importer.js +222 -222
- package/lib/import/Util.d.ts +1 -1
- package/lib/import/Util.js +6 -6
- package/lib/import/index.d.ts +6 -6
- package/lib/import/index.js +9 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/model/Types.d.ts +25 -25
- package/lib/model/Types.ts +40 -40
- package/lib/util/CompatibilityUtil.d.ts +8 -8
- package/lib/util/CompatibilityUtil.js +29 -29
- package/lib/util/DiUtil.d.ts +60 -60
- package/lib/util/DiUtil.js +122 -122
- package/lib/util/DrilldownUtil.d.ts +39 -39
- package/lib/util/DrilldownUtil.js +69 -69
- package/lib/util/LabelUtil.d.ts +83 -83
- package/lib/util/LabelUtil.js +266 -266
- package/lib/util/ModelUtil.d.ts +40 -40
- package/lib/util/ModelUtil.js +58 -58
- package/lib/util/PoweredByUtil.d.ts +8 -8
- package/lib/util/PoweredByUtil.js +99 -99
- package/lib/util/Types.js +4 -4
- package/lib/util/Types.ts +3 -3
- package/package.json +131 -131
- package/test/helper/TranslationCollector.js +15 -15
- package/test/helper/index.js +313 -313
- package/test/matchers/BoundsMatchers.js +252 -252
- package/test/matchers/ConnectionMatchers.js +165 -165
- package/test/matchers/JSONMatcher.js +19 -19
- package/test/util/KeyEvents.js +22 -22
- package/test/util/MockEvents.js +61 -61
- package/test/util/custom-rules/CustomRules.js +16 -16
- package/test/util/custom-rules/index.js +6 -6
|
@@ -1,1191 +1,1191 @@
|
|
|
1
|
-
import {
|
|
2
|
-
every,
|
|
3
|
-
find,
|
|
4
|
-
forEach,
|
|
5
|
-
some
|
|
6
|
-
} from 'min-dash';
|
|
7
|
-
|
|
8
|
-
import inherits from 'inherits-browser';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
is,
|
|
12
|
-
getBusinessObject
|
|
13
|
-
} from '../../util/ModelUtil';
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
getParent,
|
|
17
|
-
isAny
|
|
18
|
-
} from '../modeling/util/ModelingUtil';
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
isLabel
|
|
22
|
-
} from '../../util/LabelUtil';
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
isExpanded,
|
|
26
|
-
isEventSubProcess,
|
|
27
|
-
isInterrupting,
|
|
28
|
-
hasErrorEventDefinition,
|
|
29
|
-
hasEscalationEventDefinition,
|
|
30
|
-
hasCompensateEventDefinition
|
|
31
|
-
} from '../../util/DiUtil';
|
|
32
|
-
|
|
33
|
-
import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
|
|
34
|
-
|
|
35
|
-
import {
|
|
36
|
-
getBoundaryAttachment as isBoundaryAttachment
|
|
37
|
-
} from '../snapping/BpmnSnappingUtil';
|
|
38
|
-
|
|
39
|
-
import { isConnection } from 'diagram-js/lib/util/ModelUtil';
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
|
|
43
|
-
*
|
|
44
|
-
* @typedef {import('../../model/Types').Connection} Connection
|
|
45
|
-
* @typedef {import('../../model/Types').Element} Element
|
|
46
|
-
* @typedef {import('../../model/Types').Shape} Shape
|
|
47
|
-
* @typedef {import('../../model/Types').ModdleElement} ModdleElement
|
|
48
|
-
*
|
|
49
|
-
* @typedef {import('diagram-js/lib/util/Types').Point} Point
|
|
50
|
-
* @typedef {import('diagram-js/lib/util/Types').Rect} Rect
|
|
51
|
-
*
|
|
52
|
-
* @typedef { {
|
|
53
|
-
* associationDirection?: 'None' | 'One' | 'Both';
|
|
54
|
-
* type: string;
|
|
55
|
-
* } | boolean | null } CanConnectResult
|
|
56
|
-
*
|
|
57
|
-
* @typedef { {
|
|
58
|
-
* id: string;
|
|
59
|
-
* type: string;
|
|
60
|
-
* } | boolean } CanReplaceResult
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* BPMN-specific modeling rules.
|
|
65
|
-
*
|
|
66
|
-
* @param {EventBus} eventBus
|
|
67
|
-
*/
|
|
68
|
-
export default function BpmnRules(eventBus) {
|
|
69
|
-
RuleProvider.call(this, eventBus);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
inherits(BpmnRules, RuleProvider);
|
|
73
|
-
|
|
74
|
-
BpmnRules.$inject = [ 'eventBus' ];
|
|
75
|
-
|
|
76
|
-
BpmnRules.prototype.init = function() {
|
|
77
|
-
|
|
78
|
-
this.addRule('connection.start', function(context) {
|
|
79
|
-
var source = context.source;
|
|
80
|
-
|
|
81
|
-
return canStartConnection(source);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
this.addRule('connection.create', function(context) {
|
|
85
|
-
var source = context.source,
|
|
86
|
-
target = context.target,
|
|
87
|
-
hints = context.hints || {},
|
|
88
|
-
targetParent = hints.targetParent,
|
|
89
|
-
targetAttach = hints.targetAttach;
|
|
90
|
-
|
|
91
|
-
// don't allow incoming connections on
|
|
92
|
-
// newly created boundary events
|
|
93
|
-
// to boundary events
|
|
94
|
-
if (targetAttach) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// temporarily set target parent for scoping
|
|
99
|
-
// checks to work
|
|
100
|
-
if (targetParent) {
|
|
101
|
-
target.parent = targetParent;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
return canConnect(source, target);
|
|
106
|
-
} finally {
|
|
107
|
-
|
|
108
|
-
// unset temporary target parent
|
|
109
|
-
if (targetParent) {
|
|
110
|
-
target.parent = null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
this.addRule('connection.reconnect', function(context) {
|
|
116
|
-
|
|
117
|
-
var connection = context.connection,
|
|
118
|
-
source = context.source,
|
|
119
|
-
target = context.target;
|
|
120
|
-
|
|
121
|
-
return canConnect(source, target, connection);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
this.addRule('connection.updateWaypoints', function(context) {
|
|
125
|
-
return {
|
|
126
|
-
type: context.connection.type
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
this.addRule('shape.resize', function(context) {
|
|
131
|
-
|
|
132
|
-
var shape = context.shape,
|
|
133
|
-
newBounds = context.newBounds;
|
|
134
|
-
|
|
135
|
-
return canResize(shape, newBounds);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
this.addRule('elements.create', function(context) {
|
|
139
|
-
var elements = context.elements,
|
|
140
|
-
position = context.position,
|
|
141
|
-
target = context.target;
|
|
142
|
-
|
|
143
|
-
if (isConnection(target) && !canInsert(elements, target, position)) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return every(elements, function(element) {
|
|
148
|
-
if (isConnection(element)) {
|
|
149
|
-
return canConnect(element.source, element.target, element);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (element.host) {
|
|
153
|
-
return canAttach(element, element.host, null, position);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return canCreate(element, target, null, position);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
this.addRule('elements.move', function(context) {
|
|
161
|
-
|
|
162
|
-
var target = context.target,
|
|
163
|
-
shapes = context.shapes,
|
|
164
|
-
position = context.position;
|
|
165
|
-
|
|
166
|
-
return canAttach(shapes, target, null, position) ||
|
|
167
|
-
canReplace(shapes, target, position) ||
|
|
168
|
-
canMove(shapes, target, position) ||
|
|
169
|
-
canInsert(shapes, target, position);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
this.addRule('shape.create', function(context) {
|
|
173
|
-
return canCreate(
|
|
174
|
-
context.shape,
|
|
175
|
-
context.target,
|
|
176
|
-
context.source,
|
|
177
|
-
context.position
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
this.addRule('shape.attach', function(context) {
|
|
182
|
-
|
|
183
|
-
return canAttach(
|
|
184
|
-
context.shape,
|
|
185
|
-
context.target,
|
|
186
|
-
null,
|
|
187
|
-
context.position
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
this.addRule('element.copy', function(context) {
|
|
192
|
-
var element = context.element,
|
|
193
|
-
elements = context.elements;
|
|
194
|
-
|
|
195
|
-
return canCopy(elements, element);
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
|
|
200
|
-
|
|
201
|
-
BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow;
|
|
202
|
-
|
|
203
|
-
BpmnRules.prototype.canConnectDataAssociation = canConnectDataAssociation;
|
|
204
|
-
|
|
205
|
-
BpmnRules.prototype.canConnectAssociation = canConnectAssociation;
|
|
206
|
-
|
|
207
|
-
BpmnRules.prototype.canConnectCompensationAssociation = canConnectCompensationAssociation;
|
|
208
|
-
|
|
209
|
-
BpmnRules.prototype.canMove = canMove;
|
|
210
|
-
|
|
211
|
-
BpmnRules.prototype.canAttach = canAttach;
|
|
212
|
-
|
|
213
|
-
BpmnRules.prototype.canReplace = canReplace;
|
|
214
|
-
|
|
215
|
-
BpmnRules.prototype.canDrop = canDrop;
|
|
216
|
-
|
|
217
|
-
BpmnRules.prototype.canInsert = canInsert;
|
|
218
|
-
|
|
219
|
-
BpmnRules.prototype.canCreate = canCreate;
|
|
220
|
-
|
|
221
|
-
BpmnRules.prototype.canConnect = canConnect;
|
|
222
|
-
|
|
223
|
-
BpmnRules.prototype.canResize = canResize;
|
|
224
|
-
|
|
225
|
-
BpmnRules.prototype.canCopy = canCopy;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Utility functions for rule checking
|
|
229
|
-
*/
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Checks if given element can be used for starting connection.
|
|
233
|
-
*
|
|
234
|
-
* @param {Element} source
|
|
235
|
-
*
|
|
236
|
-
* @return {boolean}
|
|
237
|
-
*/
|
|
238
|
-
function canStartConnection(element) {
|
|
239
|
-
if (nonExistingOrLabel(element)) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return isAny(element, [
|
|
244
|
-
'bpmn:FlowNode',
|
|
245
|
-
'bpmn:InteractionNode',
|
|
246
|
-
'bpmn:DataObjectReference',
|
|
247
|
-
'bpmn:DataStoreReference',
|
|
248
|
-
'bpmn:Group',
|
|
249
|
-
'bpmn:TextAnnotation'
|
|
250
|
-
]);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* @param {Element} element
|
|
255
|
-
*
|
|
256
|
-
* @return {boolean}
|
|
257
|
-
*/
|
|
258
|
-
function nonExistingOrLabel(element) {
|
|
259
|
-
return !element || isLabel(element);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function isSame(a, b) {
|
|
263
|
-
return a === b;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @param {Element} element
|
|
268
|
-
*
|
|
269
|
-
* @return {ModdleElement}
|
|
270
|
-
*/
|
|
271
|
-
function getOrganizationalParent(element) {
|
|
272
|
-
|
|
273
|
-
do {
|
|
274
|
-
if (is(element, 'bpmn:Process')) {
|
|
275
|
-
return getBusinessObject(element);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (is(element, 'bpmn:Participant')) {
|
|
279
|
-
return (
|
|
280
|
-
getBusinessObject(element).processRef ||
|
|
281
|
-
getBusinessObject(element)
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
} while ((element = element.parent));
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @param {Element} element
|
|
290
|
-
*
|
|
291
|
-
* @return {boolean}
|
|
292
|
-
*/
|
|
293
|
-
function isTextAnnotation(element) {
|
|
294
|
-
return is(element, 'bpmn:TextAnnotation');
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* @param {Element} element
|
|
299
|
-
*
|
|
300
|
-
* @return {boolean}
|
|
301
|
-
*/
|
|
302
|
-
function isGroup(element) {
|
|
303
|
-
return is(element, 'bpmn:Group') && !element.labelTarget;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* @param {Element} element
|
|
308
|
-
*
|
|
309
|
-
* @return {boolean}
|
|
310
|
-
*/
|
|
311
|
-
function isCompensationBoundary(element) {
|
|
312
|
-
return is(element, 'bpmn:BoundaryEvent') &&
|
|
313
|
-
hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* @param {Element} element
|
|
318
|
-
*
|
|
319
|
-
* @return {boolean}
|
|
320
|
-
*/
|
|
321
|
-
function isForCompensation(element) {
|
|
322
|
-
return getBusinessObject(element).isForCompensation;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* @param {Element} a
|
|
327
|
-
* @param {Element} b
|
|
328
|
-
*
|
|
329
|
-
* @return {boolean}
|
|
330
|
-
*/
|
|
331
|
-
function isSameOrganization(a, b) {
|
|
332
|
-
var parentA = getOrganizationalParent(a),
|
|
333
|
-
parentB = getOrganizationalParent(b);
|
|
334
|
-
|
|
335
|
-
return parentA === parentB;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* @param {Element} element
|
|
340
|
-
*
|
|
341
|
-
* @return {boolean}
|
|
342
|
-
*/
|
|
343
|
-
function isMessageFlowSource(element) {
|
|
344
|
-
return (
|
|
345
|
-
is(element, 'bpmn:InteractionNode') &&
|
|
346
|
-
!is(element, 'bpmn:BoundaryEvent') && (
|
|
347
|
-
!is(element, 'bpmn:Event') || (
|
|
348
|
-
is(element, 'bpmn:ThrowEvent') &&
|
|
349
|
-
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
|
350
|
-
)
|
|
351
|
-
)
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* @param {Element} element
|
|
357
|
-
*
|
|
358
|
-
* @return {boolean}
|
|
359
|
-
*/
|
|
360
|
-
function isMessageFlowTarget(element) {
|
|
361
|
-
return (
|
|
362
|
-
is(element, 'bpmn:InteractionNode') &&
|
|
363
|
-
!isForCompensation(element) && (
|
|
364
|
-
!is(element, 'bpmn:Event') || (
|
|
365
|
-
is(element, 'bpmn:CatchEvent') &&
|
|
366
|
-
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
|
367
|
-
)
|
|
368
|
-
) && !(
|
|
369
|
-
is(element, 'bpmn:BoundaryEvent') &&
|
|
370
|
-
!hasEventDefinition(element, 'bpmn:MessageEventDefinition')
|
|
371
|
-
)
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* @param {Element} element
|
|
377
|
-
*
|
|
378
|
-
* @return {ModdleElement}
|
|
379
|
-
*/
|
|
380
|
-
function getScopeParent(element) {
|
|
381
|
-
|
|
382
|
-
var parent = element;
|
|
383
|
-
|
|
384
|
-
while ((parent = parent.parent)) {
|
|
385
|
-
|
|
386
|
-
if (is(parent, 'bpmn:FlowElementsContainer')) {
|
|
387
|
-
return getBusinessObject(parent);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (is(parent, 'bpmn:Participant')) {
|
|
391
|
-
return getBusinessObject(parent).processRef;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* @param {Element} a
|
|
400
|
-
* @param {Element} b
|
|
401
|
-
*
|
|
402
|
-
* @return {boolean}
|
|
403
|
-
*/
|
|
404
|
-
function isSameScope(a, b) {
|
|
405
|
-
var scopeParentA = getScopeParent(a),
|
|
406
|
-
scopeParentB = getScopeParent(b);
|
|
407
|
-
|
|
408
|
-
return scopeParentA === scopeParentB;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* @param {Element} element
|
|
413
|
-
* @param {string} eventDefinition
|
|
414
|
-
*
|
|
415
|
-
* @return {boolean}
|
|
416
|
-
*/
|
|
417
|
-
function hasEventDefinition(element, eventDefinition) {
|
|
418
|
-
var businessObject = getBusinessObject(element);
|
|
419
|
-
|
|
420
|
-
return !!find(businessObject.eventDefinitions || [], function(definition) {
|
|
421
|
-
return is(definition, eventDefinition);
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* @param {Element} element
|
|
427
|
-
* @param {string} eventDefinition
|
|
428
|
-
*
|
|
429
|
-
* @return {boolean}
|
|
430
|
-
*/
|
|
431
|
-
function hasEventDefinitionOrNone(element, eventDefinition) {
|
|
432
|
-
var businessObject = getBusinessObject(element);
|
|
433
|
-
|
|
434
|
-
return (businessObject.eventDefinitions || []).every(function(definition) {
|
|
435
|
-
return is(definition, eventDefinition);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* @param {Element} element
|
|
441
|
-
*
|
|
442
|
-
* @return {boolean}
|
|
443
|
-
*/
|
|
444
|
-
function isSequenceFlowSource(element) {
|
|
445
|
-
return (
|
|
446
|
-
is(element, 'bpmn:FlowNode') &&
|
|
447
|
-
!is(element, 'bpmn:EndEvent') &&
|
|
448
|
-
!isEventSubProcess(element) &&
|
|
449
|
-
!(is(element, 'bpmn:IntermediateThrowEvent') &&
|
|
450
|
-
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
|
|
451
|
-
) &&
|
|
452
|
-
!isCompensationBoundary(element) &&
|
|
453
|
-
!isForCompensation(element)
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* @param {Element} element
|
|
459
|
-
*
|
|
460
|
-
* @return {boolean}
|
|
461
|
-
*/
|
|
462
|
-
function isSequenceFlowTarget(element) {
|
|
463
|
-
return (
|
|
464
|
-
is(element, 'bpmn:FlowNode') &&
|
|
465
|
-
!is(element, 'bpmn:StartEvent') &&
|
|
466
|
-
!is(element, 'bpmn:BoundaryEvent') &&
|
|
467
|
-
!isEventSubProcess(element) &&
|
|
468
|
-
!(is(element, 'bpmn:IntermediateCatchEvent') &&
|
|
469
|
-
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
|
|
470
|
-
) &&
|
|
471
|
-
!isForCompensation(element)
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* @param {Element} element
|
|
477
|
-
*
|
|
478
|
-
* @return {boolean}
|
|
479
|
-
*/
|
|
480
|
-
function isEventBasedTarget(element) {
|
|
481
|
-
return (
|
|
482
|
-
is(element, 'bpmn:ReceiveTask') || (
|
|
483
|
-
is(element, 'bpmn:IntermediateCatchEvent') && (
|
|
484
|
-
hasEventDefinition(element, 'bpmn:MessageEventDefinition') ||
|
|
485
|
-
hasEventDefinition(element, 'bpmn:TimerEventDefinition') ||
|
|
486
|
-
hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') ||
|
|
487
|
-
hasEventDefinition(element, 'bpmn:SignalEventDefinition')
|
|
488
|
-
)
|
|
489
|
-
)
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* @param {Element} element
|
|
495
|
-
*
|
|
496
|
-
* @return {Shape[]}
|
|
497
|
-
*/
|
|
498
|
-
function getParents(element) {
|
|
499
|
-
|
|
500
|
-
var parents = [];
|
|
501
|
-
|
|
502
|
-
while (element) {
|
|
503
|
-
element = element.parent;
|
|
504
|
-
|
|
505
|
-
if (element) {
|
|
506
|
-
parents.push(element);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
return parents;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* @param {Shape} possibleParent
|
|
515
|
-
* @param {Element} element
|
|
516
|
-
*
|
|
517
|
-
* @return {boolean}
|
|
518
|
-
*/
|
|
519
|
-
function isParent(possibleParent, element) {
|
|
520
|
-
var allParents = getParents(element);
|
|
521
|
-
|
|
522
|
-
return allParents.indexOf(possibleParent) !== -1;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* @param {Element} source
|
|
527
|
-
* @param {Element} target
|
|
528
|
-
* @param {Connection} connection
|
|
529
|
-
*
|
|
530
|
-
* @return {CanConnectResult}
|
|
531
|
-
*/
|
|
532
|
-
function canConnect(source, target, connection) {
|
|
533
|
-
|
|
534
|
-
if (nonExistingOrLabel(source) || nonExistingOrLabel(target)) {
|
|
535
|
-
return null;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
if (!is(connection, 'bpmn:DataAssociation')) {
|
|
539
|
-
|
|
540
|
-
if (canConnectMessageFlow(source, target)) {
|
|
541
|
-
return { type: 'bpmn:MessageFlow' };
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
if (canConnectSequenceFlow(source, target)) {
|
|
545
|
-
return { type: 'bpmn:SequenceFlow' };
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
var connectDataAssociation = canConnectDataAssociation(source, target);
|
|
550
|
-
|
|
551
|
-
if (connectDataAssociation) {
|
|
552
|
-
return connectDataAssociation;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (canConnectCompensationAssociation(source, target)) {
|
|
556
|
-
return {
|
|
557
|
-
type: 'bpmn:Association',
|
|
558
|
-
associationDirection: 'One'
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
if (canConnectAssociation(source, target)) {
|
|
563
|
-
return {
|
|
564
|
-
type: 'bpmn:Association',
|
|
565
|
-
associationDirection: 'None'
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
return false;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Can an element be dropped into the target element.
|
|
574
|
-
*
|
|
575
|
-
* @param {Element} element
|
|
576
|
-
* @param {Shape} target
|
|
577
|
-
*
|
|
578
|
-
* @return {boolean}
|
|
579
|
-
*/
|
|
580
|
-
function canDrop(element, target) {
|
|
581
|
-
|
|
582
|
-
// can move labels and groups everywhere
|
|
583
|
-
if (isLabel(element) || isGroup(element)) {
|
|
584
|
-
return true;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
// disallow to create elements on collapsed pools
|
|
589
|
-
if (is(target, 'bpmn:Participant') && !isExpanded(target)) {
|
|
590
|
-
return false;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
// allow to create new participants on
|
|
594
|
-
// existing collaboration and process diagrams
|
|
595
|
-
if (is(element, 'bpmn:Participant')) {
|
|
596
|
-
return is(target, 'bpmn:Process') || is(target, 'bpmn:Collaboration');
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// allow moving DataInput / DataOutput within its original container only
|
|
600
|
-
if (isAny(element, [ 'bpmn:DataInput', 'bpmn:DataOutput' ])) {
|
|
601
|
-
|
|
602
|
-
if (element.parent) {
|
|
603
|
-
return target === element.parent;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// allow creating lanes on participants and other lanes only
|
|
608
|
-
if (is(element, 'bpmn:Lane')) {
|
|
609
|
-
return is(target, 'bpmn:Participant') || is(target, 'bpmn:Lane');
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
// disallow dropping boundary events which cannot replace with intermediate event
|
|
613
|
-
if (is(element, 'bpmn:BoundaryEvent') && !isDroppableBoundaryEvent(element)) {
|
|
614
|
-
return false;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
// drop flow elements onto flow element containers
|
|
618
|
-
// and participants
|
|
619
|
-
if (is(element, 'bpmn:FlowElement') && !is(element, 'bpmn:DataStoreReference')) {
|
|
620
|
-
if (is(target, 'bpmn:FlowElementsContainer')) {
|
|
621
|
-
return isExpanded(target);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
// disallow dropping data store reference if there is no process to append to
|
|
628
|
-
if (is(element, 'bpmn:DataStoreReference') && is(target, 'bpmn:Collaboration')) {
|
|
629
|
-
return some(getBusinessObject(target).get('participants'), function(participant) {
|
|
630
|
-
return !!participant.get('processRef');
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
// account for the fact that data associations are always
|
|
635
|
-
// rendered and moved to top (Process or Collaboration level)
|
|
636
|
-
//
|
|
637
|
-
// artifacts may be placed wherever, too
|
|
638
|
-
if (isAny(element, [ 'bpmn:Artifact', 'bpmn:DataAssociation', 'bpmn:DataStoreReference' ])) {
|
|
639
|
-
return isAny(target, [
|
|
640
|
-
'bpmn:Collaboration',
|
|
641
|
-
'bpmn:Lane',
|
|
642
|
-
'bpmn:Participant',
|
|
643
|
-
'bpmn:Process',
|
|
644
|
-
'bpmn:SubProcess' ]);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
if (is(element, 'bpmn:MessageFlow')) {
|
|
648
|
-
return is(target, 'bpmn:Collaboration')
|
|
649
|
-
|| element.source.parent == target
|
|
650
|
-
|| element.target.parent == target;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
return false;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* @param {Shape} event
|
|
658
|
-
*
|
|
659
|
-
* @return {boolean}
|
|
660
|
-
*/
|
|
661
|
-
function isDroppableBoundaryEvent(event) {
|
|
662
|
-
return getBusinessObject(event).cancelActivity && (
|
|
663
|
-
hasNoEventDefinition(event) || hasCommonBoundaryIntermediateEventDefinition(event)
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* @param {Element} element
|
|
669
|
-
*
|
|
670
|
-
* @return {boolean}
|
|
671
|
-
*/
|
|
672
|
-
function isBoundaryEvent(element) {
|
|
673
|
-
return !isLabel(element) && is(element, 'bpmn:BoundaryEvent');
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* @param {Element} element
|
|
678
|
-
*
|
|
679
|
-
* @return {boolean}
|
|
680
|
-
*/
|
|
681
|
-
function isLane(element) {
|
|
682
|
-
return is(element, 'bpmn:Lane');
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* `bpmn:IntermediateThrowEvents` are treated as boundary events during create.
|
|
687
|
-
*
|
|
688
|
-
* @param {Element} element
|
|
689
|
-
*
|
|
690
|
-
* @return {boolean}
|
|
691
|
-
*/
|
|
692
|
-
function isBoundaryCandidate(element) {
|
|
693
|
-
if (isBoundaryEvent(element)) {
|
|
694
|
-
return true;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if (is(element, 'bpmn:IntermediateThrowEvent') && hasNoEventDefinition(element)) {
|
|
698
|
-
return true;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
return (
|
|
702
|
-
is(element, 'bpmn:IntermediateCatchEvent') &&
|
|
703
|
-
hasCommonBoundaryIntermediateEventDefinition(element)
|
|
704
|
-
);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* @param {Element} element
|
|
709
|
-
*
|
|
710
|
-
* @return {boolean}
|
|
711
|
-
*/
|
|
712
|
-
function hasNoEventDefinition(element) {
|
|
713
|
-
var businessObject = getBusinessObject(element);
|
|
714
|
-
|
|
715
|
-
return businessObject && !(businessObject.eventDefinitions && businessObject.eventDefinitions.length);
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* @param {Element} element
|
|
720
|
-
*
|
|
721
|
-
* @return {boolean}
|
|
722
|
-
*/
|
|
723
|
-
function hasCommonBoundaryIntermediateEventDefinition(element) {
|
|
724
|
-
return hasOneOfEventDefinitions(element, [
|
|
725
|
-
'bpmn:MessageEventDefinition',
|
|
726
|
-
'bpmn:TimerEventDefinition',
|
|
727
|
-
'bpmn:SignalEventDefinition',
|
|
728
|
-
'bpmn:ConditionalEventDefinition'
|
|
729
|
-
]);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* @param {Element} element
|
|
734
|
-
* @param {string[]} eventDefinitions
|
|
735
|
-
*
|
|
736
|
-
* @return {boolean}
|
|
737
|
-
*/
|
|
738
|
-
function hasOneOfEventDefinitions(element, eventDefinitions) {
|
|
739
|
-
return eventDefinitions.some(function(definition) {
|
|
740
|
-
return hasEventDefinition(element, definition);
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* @param {Element} element
|
|
746
|
-
*
|
|
747
|
-
* @return {boolean}
|
|
748
|
-
*/
|
|
749
|
-
function isReceiveTaskAfterEventBasedGateway(element) {
|
|
750
|
-
return (
|
|
751
|
-
is(element, 'bpmn:ReceiveTask') &&
|
|
752
|
-
find(element.incoming, function(incoming) {
|
|
753
|
-
return is(incoming.source, 'bpmn:EventBasedGateway');
|
|
754
|
-
})
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
/**
|
|
759
|
-
* TODO(philippfromme): remove `source` parameter
|
|
760
|
-
*
|
|
761
|
-
* @param {Element[]} elements
|
|
762
|
-
* @param {Shape} target
|
|
763
|
-
* @param {Element} source
|
|
764
|
-
* @param {Point} [position]
|
|
765
|
-
*
|
|
766
|
-
* @return {boolean | 'attach'}
|
|
767
|
-
*/
|
|
768
|
-
function canAttach(elements, target, source, position) {
|
|
769
|
-
|
|
770
|
-
if (!Array.isArray(elements)) {
|
|
771
|
-
elements = [ elements ];
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// only (re-)attach one element at a time
|
|
775
|
-
if (elements.length !== 1) {
|
|
776
|
-
return false;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
var element = elements[0];
|
|
780
|
-
|
|
781
|
-
// do not attach labels
|
|
782
|
-
if (isLabel(element)) {
|
|
783
|
-
return false;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
// only handle boundary events
|
|
787
|
-
if (!isBoundaryCandidate(element)) {
|
|
788
|
-
return false;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
// disallow drop on event sub processes
|
|
792
|
-
if (isEventSubProcess(target)) {
|
|
793
|
-
return false;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
// only allow drop on non compensation activities
|
|
797
|
-
if (!is(target, 'bpmn:Activity') || isForCompensation(target)) {
|
|
798
|
-
return false;
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// only attach to subprocess border
|
|
802
|
-
if (position && !isBoundaryAttachment(position, target)) {
|
|
803
|
-
return false;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
// do not attach on receive tasks after event based gateways
|
|
807
|
-
if (isReceiveTaskAfterEventBasedGateway(target)) {
|
|
808
|
-
return false;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
return 'attach';
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Check whether the given elements can be replaced. Return all elements which
|
|
816
|
-
* can be replaced.
|
|
817
|
-
*
|
|
818
|
-
* @example
|
|
819
|
-
*
|
|
820
|
-
* ```javascript
|
|
821
|
-
* [{
|
|
822
|
-
* id: 'IntermediateEvent_1',
|
|
823
|
-
* type: 'bpmn:StartEvent'
|
|
824
|
-
* },
|
|
825
|
-
* {
|
|
826
|
-
* id: 'Task_1',
|
|
827
|
-
* type: 'bpmn:ServiceTask'
|
|
828
|
-
* }]
|
|
829
|
-
* ```
|
|
830
|
-
*
|
|
831
|
-
* @param {Element[]} elements
|
|
832
|
-
* @param {Shape} [target]
|
|
833
|
-
* @param {Point} [position]
|
|
834
|
-
*
|
|
835
|
-
* @return {CanReplaceResult}
|
|
836
|
-
*/
|
|
837
|
-
function canReplace(elements, target, position) {
|
|
838
|
-
|
|
839
|
-
if (!target) {
|
|
840
|
-
return false;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
var canExecute = {
|
|
844
|
-
replacements: []
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
forEach(elements, function(element) {
|
|
848
|
-
|
|
849
|
-
if (!isEventSubProcess(target)) {
|
|
850
|
-
|
|
851
|
-
if (is(element, 'bpmn:StartEvent') &&
|
|
852
|
-
element.type !== 'label' &&
|
|
853
|
-
canDrop(element, target)) {
|
|
854
|
-
|
|
855
|
-
// replace a non-interrupting start event by a blank interrupting start event
|
|
856
|
-
// when the target is not an event sub process
|
|
857
|
-
if (!isInterrupting(element)) {
|
|
858
|
-
canExecute.replacements.push({
|
|
859
|
-
oldElementId: element.id,
|
|
860
|
-
newElementType: 'bpmn:StartEvent'
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
// replace an error/escalation/compensate start event by a blank interrupting start event
|
|
865
|
-
// when the target is not an event sub process
|
|
866
|
-
if (hasErrorEventDefinition(element) ||
|
|
867
|
-
hasEscalationEventDefinition(element) ||
|
|
868
|
-
hasCompensateEventDefinition(element)) {
|
|
869
|
-
canExecute.replacements.push({
|
|
870
|
-
oldElementId: element.id,
|
|
871
|
-
newElementType: 'bpmn:StartEvent'
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
// replace a typed start event by a blank interrupting start event
|
|
876
|
-
// when the target is a sub process but not an event sub process
|
|
877
|
-
if (hasOneOfEventDefinitions(element,
|
|
878
|
-
[
|
|
879
|
-
'bpmn:MessageEventDefinition',
|
|
880
|
-
'bpmn:TimerEventDefinition',
|
|
881
|
-
'bpmn:SignalEventDefinition',
|
|
882
|
-
'bpmn:ConditionalEventDefinition'
|
|
883
|
-
]) &&
|
|
884
|
-
is(target, 'bpmn:SubProcess')) {
|
|
885
|
-
canExecute.replacements.push({
|
|
886
|
-
oldElementId: element.id,
|
|
887
|
-
newElementType: 'bpmn:StartEvent'
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
if (!is(target, 'bpmn:Transaction')) {
|
|
894
|
-
if (hasEventDefinition(element, 'bpmn:CancelEventDefinition') &&
|
|
895
|
-
element.type !== 'label') {
|
|
896
|
-
|
|
897
|
-
if (is(element, 'bpmn:EndEvent') && canDrop(element, target)) {
|
|
898
|
-
canExecute.replacements.push({
|
|
899
|
-
oldElementId: element.id,
|
|
900
|
-
newElementType: 'bpmn:EndEvent'
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
if (is(element, 'bpmn:BoundaryEvent') && canAttach(element, target, null, position)) {
|
|
905
|
-
canExecute.replacements.push({
|
|
906
|
-
oldElementId: element.id,
|
|
907
|
-
newElementType: 'bpmn:BoundaryEvent'
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
return canExecute.replacements.length ? canExecute : false;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
/**
|
|
918
|
-
* @param {Element[]} elements
|
|
919
|
-
* @param {Shape} target
|
|
920
|
-
*
|
|
921
|
-
* @return {boolean}
|
|
922
|
-
*/
|
|
923
|
-
function canMove(elements, target) {
|
|
924
|
-
|
|
925
|
-
// do not move selection containing lanes
|
|
926
|
-
if (some(elements, isLane)) {
|
|
927
|
-
return false;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
// allow default move check to start move operation
|
|
931
|
-
if (!target) {
|
|
932
|
-
return true;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
return elements.every(function(element) {
|
|
936
|
-
return canDrop(element, target);
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* @param {Shape} shape
|
|
942
|
-
* @param {Shape} target
|
|
943
|
-
* @param {Element} source
|
|
944
|
-
* @param {Point} position
|
|
945
|
-
*
|
|
946
|
-
* @return {boolean}
|
|
947
|
-
*/
|
|
948
|
-
function canCreate(shape, target, source, position) {
|
|
949
|
-
|
|
950
|
-
if (!target) {
|
|
951
|
-
return false;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
if (isLabel(shape) || isGroup(shape)) {
|
|
955
|
-
return true;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
if (isSame(source, target)) {
|
|
959
|
-
return false;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
// ensure we do not drop the element
|
|
963
|
-
// into source
|
|
964
|
-
if (source && isParent(source, target)) {
|
|
965
|
-
return false;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
return canDrop(shape, target, position) || canInsert(shape, target, position);
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
/**
|
|
972
|
-
* @param {Shape} shape
|
|
973
|
-
* @param {Rect} newBounds
|
|
974
|
-
*
|
|
975
|
-
* @return {boolean}
|
|
976
|
-
*/
|
|
977
|
-
function canResize(shape, newBounds) {
|
|
978
|
-
if (is(shape, 'bpmn:SubProcess')) {
|
|
979
|
-
return (
|
|
980
|
-
isExpanded(shape) && (
|
|
981
|
-
!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
|
|
982
|
-
)
|
|
983
|
-
);
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
if (is(shape, 'bpmn:Lane')) {
|
|
987
|
-
return true;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
if (is(shape, 'bpmn:Participant')) {
|
|
991
|
-
return true;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
if (isTextAnnotation(shape)) {
|
|
995
|
-
return true;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
if (isGroup(shape)) {
|
|
999
|
-
return true;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
return false;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
/**
|
|
1006
|
-
* Check whether one of of the elements to be connected is a text annotation.
|
|
1007
|
-
*
|
|
1008
|
-
* @param {Element} source
|
|
1009
|
-
* @param {Element} target
|
|
1010
|
-
*
|
|
1011
|
-
* @return {boolean}
|
|
1012
|
-
*/
|
|
1013
|
-
function isOneTextAnnotation(source, target) {
|
|
1014
|
-
|
|
1015
|
-
var sourceTextAnnotation = isTextAnnotation(source),
|
|
1016
|
-
targetTextAnnotation = isTextAnnotation(target);
|
|
1017
|
-
|
|
1018
|
-
return (
|
|
1019
|
-
(sourceTextAnnotation || targetTextAnnotation) &&
|
|
1020
|
-
(sourceTextAnnotation !== targetTextAnnotation)
|
|
1021
|
-
);
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
/**
|
|
1025
|
-
* @param {Element} source
|
|
1026
|
-
* @param {Element} target
|
|
1027
|
-
*
|
|
1028
|
-
* @return {CanConnectResult}
|
|
1029
|
-
*/
|
|
1030
|
-
function canConnectAssociation(source, target) {
|
|
1031
|
-
|
|
1032
|
-
// don't connect parent <-> child
|
|
1033
|
-
if (isParent(target, source) || isParent(source, target)) {
|
|
1034
|
-
return false;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// allow connection of associations between <!TextAnnotation> and <TextAnnotation>
|
|
1038
|
-
if (isOneTextAnnotation(source, target)) {
|
|
1039
|
-
return true;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// can connect associations where we can connect
|
|
1043
|
-
// data associations, too (!)
|
|
1044
|
-
return !!canConnectDataAssociation(source, target);
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* @param {Element} source
|
|
1049
|
-
* @param {Element} target
|
|
1050
|
-
*
|
|
1051
|
-
* @return {boolean}
|
|
1052
|
-
*/
|
|
1053
|
-
function canConnectCompensationAssociation(source, target) {
|
|
1054
|
-
return (
|
|
1055
|
-
isSameScope(source, target) &&
|
|
1056
|
-
isCompensationBoundary(source) &&
|
|
1057
|
-
is(target, 'bpmn:Activity') &&
|
|
1058
|
-
!isHostOfElement(target, source) &&
|
|
1059
|
-
!isEventSubProcess(target)
|
|
1060
|
-
);
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
/**
|
|
1064
|
-
* @param {Element} source
|
|
1065
|
-
* @param {Element} target
|
|
1066
|
-
*
|
|
1067
|
-
* @return {boolean}
|
|
1068
|
-
*/
|
|
1069
|
-
function canConnectMessageFlow(source, target) {
|
|
1070
|
-
|
|
1071
|
-
// during connect user might move mouse out of canvas
|
|
1072
|
-
// https://github.com/bpmn-io/bpmn-js/issues/1033
|
|
1073
|
-
if (getRootElement(source) && !getRootElement(target)) {
|
|
1074
|
-
return false;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
return (
|
|
1078
|
-
isMessageFlowSource(source) &&
|
|
1079
|
-
isMessageFlowTarget(target) &&
|
|
1080
|
-
!isSameOrganization(source, target)
|
|
1081
|
-
);
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* @param {Element} source
|
|
1086
|
-
* @param {Element} target
|
|
1087
|
-
*
|
|
1088
|
-
* @return {boolean}
|
|
1089
|
-
*/
|
|
1090
|
-
function canConnectSequenceFlow(source, target) {
|
|
1091
|
-
return isSequenceFlowSource(source) &&
|
|
1092
|
-
isSequenceFlowTarget(target) &&
|
|
1093
|
-
isSameScope(source, target) &&
|
|
1094
|
-
!(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target));
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
/**
|
|
1098
|
-
* @param {Element} source
|
|
1099
|
-
* @param {Element} target
|
|
1100
|
-
*
|
|
1101
|
-
* @return {CanConnectResult}
|
|
1102
|
-
*/
|
|
1103
|
-
function canConnectDataAssociation(source, target) {
|
|
1104
|
-
|
|
1105
|
-
if (isAny(source, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ]) &&
|
|
1106
|
-
isAny(target, [ 'bpmn:Activity', 'bpmn:ThrowEvent' ])) {
|
|
1107
|
-
return { type: 'bpmn:DataInputAssociation' };
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
if (isAny(target, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ]) &&
|
|
1111
|
-
isAny(source, [ 'bpmn:Activity', 'bpmn:CatchEvent' ])) {
|
|
1112
|
-
return { type: 'bpmn:DataOutputAssociation' };
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
return false;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/**
|
|
1119
|
-
* @param {Shape} shape
|
|
1120
|
-
* @param {Connection} connection
|
|
1121
|
-
* @param {Point} position
|
|
1122
|
-
*
|
|
1123
|
-
* @return {boolean}
|
|
1124
|
-
*/
|
|
1125
|
-
function canInsert(shape, connection, position) {
|
|
1126
|
-
if (!connection) {
|
|
1127
|
-
return false;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
if (Array.isArray(shape)) {
|
|
1131
|
-
if (shape.length !== 1) {
|
|
1132
|
-
return false;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
shape = shape[ 0 ];
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
if (connection.source === shape ||
|
|
1139
|
-
connection.target === shape) {
|
|
1140
|
-
return false;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
// return true if shape can be inserted into connection parent
|
|
1144
|
-
return (
|
|
1145
|
-
isAny(connection, [ 'bpmn:SequenceFlow', 'bpmn:MessageFlow' ]) &&
|
|
1146
|
-
!isLabel(connection) &&
|
|
1147
|
-
is(shape, 'bpmn:FlowNode') &&
|
|
1148
|
-
!is(shape, 'bpmn:BoundaryEvent') &&
|
|
1149
|
-
canDrop(shape, connection.parent, position));
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
* @param {Element[]} elements
|
|
1154
|
-
* @param {Element} element
|
|
1155
|
-
*
|
|
1156
|
-
* @return {boolean}
|
|
1157
|
-
*/
|
|
1158
|
-
function includes(elements, element) {
|
|
1159
|
-
return (elements && element) && elements.indexOf(element) !== -1;
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
/**
|
|
1163
|
-
* @param {Element[]} elements
|
|
1164
|
-
* @param {Element} element
|
|
1165
|
-
*
|
|
1166
|
-
* @return {boolean}
|
|
1167
|
-
*/
|
|
1168
|
-
function canCopy(elements, element) {
|
|
1169
|
-
if (isLabel(element)) {
|
|
1170
|
-
return true;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
if (is(element, 'bpmn:Lane') && !includes(elements, element.parent)) {
|
|
1174
|
-
return false;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
return true;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* @param {Element} element
|
|
1182
|
-
*
|
|
1183
|
-
* @return {Element|null}
|
|
1184
|
-
*/
|
|
1185
|
-
function getRootElement(element) {
|
|
1186
|
-
return getParent(element, 'bpmn:Process') || getParent(element, 'bpmn:Collaboration');
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
function isHostOfElement(potentialHost, element) {
|
|
1190
|
-
return potentialHost.attachers.includes(element);
|
|
1191
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
every,
|
|
3
|
+
find,
|
|
4
|
+
forEach,
|
|
5
|
+
some
|
|
6
|
+
} from 'min-dash';
|
|
7
|
+
|
|
8
|
+
import inherits from 'inherits-browser';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
is,
|
|
12
|
+
getBusinessObject
|
|
13
|
+
} from '../../util/ModelUtil';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
getParent,
|
|
17
|
+
isAny
|
|
18
|
+
} from '../modeling/util/ModelingUtil';
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
isLabel
|
|
22
|
+
} from '../../util/LabelUtil';
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
isExpanded,
|
|
26
|
+
isEventSubProcess,
|
|
27
|
+
isInterrupting,
|
|
28
|
+
hasErrorEventDefinition,
|
|
29
|
+
hasEscalationEventDefinition,
|
|
30
|
+
hasCompensateEventDefinition
|
|
31
|
+
} from '../../util/DiUtil';
|
|
32
|
+
|
|
33
|
+
import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
getBoundaryAttachment as isBoundaryAttachment
|
|
37
|
+
} from '../snapping/BpmnSnappingUtil';
|
|
38
|
+
|
|
39
|
+
import { isConnection } from 'diagram-js/lib/util/ModelUtil';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
|
|
43
|
+
*
|
|
44
|
+
* @typedef {import('../../model/Types').Connection} Connection
|
|
45
|
+
* @typedef {import('../../model/Types').Element} Element
|
|
46
|
+
* @typedef {import('../../model/Types').Shape} Shape
|
|
47
|
+
* @typedef {import('../../model/Types').ModdleElement} ModdleElement
|
|
48
|
+
*
|
|
49
|
+
* @typedef {import('diagram-js/lib/util/Types').Point} Point
|
|
50
|
+
* @typedef {import('diagram-js/lib/util/Types').Rect} Rect
|
|
51
|
+
*
|
|
52
|
+
* @typedef { {
|
|
53
|
+
* associationDirection?: 'None' | 'One' | 'Both';
|
|
54
|
+
* type: string;
|
|
55
|
+
* } | boolean | null } CanConnectResult
|
|
56
|
+
*
|
|
57
|
+
* @typedef { {
|
|
58
|
+
* id: string;
|
|
59
|
+
* type: string;
|
|
60
|
+
* } | boolean } CanReplaceResult
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* BPMN-specific modeling rules.
|
|
65
|
+
*
|
|
66
|
+
* @param {EventBus} eventBus
|
|
67
|
+
*/
|
|
68
|
+
export default function BpmnRules(eventBus) {
|
|
69
|
+
RuleProvider.call(this, eventBus);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
inherits(BpmnRules, RuleProvider);
|
|
73
|
+
|
|
74
|
+
BpmnRules.$inject = [ 'eventBus' ];
|
|
75
|
+
|
|
76
|
+
BpmnRules.prototype.init = function() {
|
|
77
|
+
|
|
78
|
+
this.addRule('connection.start', function(context) {
|
|
79
|
+
var source = context.source;
|
|
80
|
+
|
|
81
|
+
return canStartConnection(source);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
this.addRule('connection.create', function(context) {
|
|
85
|
+
var source = context.source,
|
|
86
|
+
target = context.target,
|
|
87
|
+
hints = context.hints || {},
|
|
88
|
+
targetParent = hints.targetParent,
|
|
89
|
+
targetAttach = hints.targetAttach;
|
|
90
|
+
|
|
91
|
+
// don't allow incoming connections on
|
|
92
|
+
// newly created boundary events
|
|
93
|
+
// to boundary events
|
|
94
|
+
if (targetAttach) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// temporarily set target parent for scoping
|
|
99
|
+
// checks to work
|
|
100
|
+
if (targetParent) {
|
|
101
|
+
target.parent = targetParent;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
return canConnect(source, target);
|
|
106
|
+
} finally {
|
|
107
|
+
|
|
108
|
+
// unset temporary target parent
|
|
109
|
+
if (targetParent) {
|
|
110
|
+
target.parent = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
this.addRule('connection.reconnect', function(context) {
|
|
116
|
+
|
|
117
|
+
var connection = context.connection,
|
|
118
|
+
source = context.source,
|
|
119
|
+
target = context.target;
|
|
120
|
+
|
|
121
|
+
return canConnect(source, target, connection);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
this.addRule('connection.updateWaypoints', function(context) {
|
|
125
|
+
return {
|
|
126
|
+
type: context.connection.type
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this.addRule('shape.resize', function(context) {
|
|
131
|
+
|
|
132
|
+
var shape = context.shape,
|
|
133
|
+
newBounds = context.newBounds;
|
|
134
|
+
|
|
135
|
+
return canResize(shape, newBounds);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
this.addRule('elements.create', function(context) {
|
|
139
|
+
var elements = context.elements,
|
|
140
|
+
position = context.position,
|
|
141
|
+
target = context.target;
|
|
142
|
+
|
|
143
|
+
if (isConnection(target) && !canInsert(elements, target, position)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return every(elements, function(element) {
|
|
148
|
+
if (isConnection(element)) {
|
|
149
|
+
return canConnect(element.source, element.target, element);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (element.host) {
|
|
153
|
+
return canAttach(element, element.host, null, position);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return canCreate(element, target, null, position);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
this.addRule('elements.move', function(context) {
|
|
161
|
+
|
|
162
|
+
var target = context.target,
|
|
163
|
+
shapes = context.shapes,
|
|
164
|
+
position = context.position;
|
|
165
|
+
|
|
166
|
+
return canAttach(shapes, target, null, position) ||
|
|
167
|
+
canReplace(shapes, target, position) ||
|
|
168
|
+
canMove(shapes, target, position) ||
|
|
169
|
+
canInsert(shapes, target, position);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
this.addRule('shape.create', function(context) {
|
|
173
|
+
return canCreate(
|
|
174
|
+
context.shape,
|
|
175
|
+
context.target,
|
|
176
|
+
context.source,
|
|
177
|
+
context.position
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
this.addRule('shape.attach', function(context) {
|
|
182
|
+
|
|
183
|
+
return canAttach(
|
|
184
|
+
context.shape,
|
|
185
|
+
context.target,
|
|
186
|
+
null,
|
|
187
|
+
context.position
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
this.addRule('element.copy', function(context) {
|
|
192
|
+
var element = context.element,
|
|
193
|
+
elements = context.elements;
|
|
194
|
+
|
|
195
|
+
return canCopy(elements, element);
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
|
|
200
|
+
|
|
201
|
+
BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow;
|
|
202
|
+
|
|
203
|
+
BpmnRules.prototype.canConnectDataAssociation = canConnectDataAssociation;
|
|
204
|
+
|
|
205
|
+
BpmnRules.prototype.canConnectAssociation = canConnectAssociation;
|
|
206
|
+
|
|
207
|
+
BpmnRules.prototype.canConnectCompensationAssociation = canConnectCompensationAssociation;
|
|
208
|
+
|
|
209
|
+
BpmnRules.prototype.canMove = canMove;
|
|
210
|
+
|
|
211
|
+
BpmnRules.prototype.canAttach = canAttach;
|
|
212
|
+
|
|
213
|
+
BpmnRules.prototype.canReplace = canReplace;
|
|
214
|
+
|
|
215
|
+
BpmnRules.prototype.canDrop = canDrop;
|
|
216
|
+
|
|
217
|
+
BpmnRules.prototype.canInsert = canInsert;
|
|
218
|
+
|
|
219
|
+
BpmnRules.prototype.canCreate = canCreate;
|
|
220
|
+
|
|
221
|
+
BpmnRules.prototype.canConnect = canConnect;
|
|
222
|
+
|
|
223
|
+
BpmnRules.prototype.canResize = canResize;
|
|
224
|
+
|
|
225
|
+
BpmnRules.prototype.canCopy = canCopy;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Utility functions for rule checking
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Checks if given element can be used for starting connection.
|
|
233
|
+
*
|
|
234
|
+
* @param {Element} source
|
|
235
|
+
*
|
|
236
|
+
* @return {boolean}
|
|
237
|
+
*/
|
|
238
|
+
function canStartConnection(element) {
|
|
239
|
+
if (nonExistingOrLabel(element)) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return isAny(element, [
|
|
244
|
+
'bpmn:FlowNode',
|
|
245
|
+
'bpmn:InteractionNode',
|
|
246
|
+
'bpmn:DataObjectReference',
|
|
247
|
+
'bpmn:DataStoreReference',
|
|
248
|
+
'bpmn:Group',
|
|
249
|
+
'bpmn:TextAnnotation'
|
|
250
|
+
]);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {Element} element
|
|
255
|
+
*
|
|
256
|
+
* @return {boolean}
|
|
257
|
+
*/
|
|
258
|
+
function nonExistingOrLabel(element) {
|
|
259
|
+
return !element || isLabel(element);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function isSame(a, b) {
|
|
263
|
+
return a === b;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @param {Element} element
|
|
268
|
+
*
|
|
269
|
+
* @return {ModdleElement}
|
|
270
|
+
*/
|
|
271
|
+
function getOrganizationalParent(element) {
|
|
272
|
+
|
|
273
|
+
do {
|
|
274
|
+
if (is(element, 'bpmn:Process')) {
|
|
275
|
+
return getBusinessObject(element);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (is(element, 'bpmn:Participant')) {
|
|
279
|
+
return (
|
|
280
|
+
getBusinessObject(element).processRef ||
|
|
281
|
+
getBusinessObject(element)
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
} while ((element = element.parent));
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {Element} element
|
|
290
|
+
*
|
|
291
|
+
* @return {boolean}
|
|
292
|
+
*/
|
|
293
|
+
function isTextAnnotation(element) {
|
|
294
|
+
return is(element, 'bpmn:TextAnnotation');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @param {Element} element
|
|
299
|
+
*
|
|
300
|
+
* @return {boolean}
|
|
301
|
+
*/
|
|
302
|
+
function isGroup(element) {
|
|
303
|
+
return is(element, 'bpmn:Group') && !element.labelTarget;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @param {Element} element
|
|
308
|
+
*
|
|
309
|
+
* @return {boolean}
|
|
310
|
+
*/
|
|
311
|
+
function isCompensationBoundary(element) {
|
|
312
|
+
return is(element, 'bpmn:BoundaryEvent') &&
|
|
313
|
+
hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @param {Element} element
|
|
318
|
+
*
|
|
319
|
+
* @return {boolean}
|
|
320
|
+
*/
|
|
321
|
+
function isForCompensation(element) {
|
|
322
|
+
return getBusinessObject(element).isForCompensation;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @param {Element} a
|
|
327
|
+
* @param {Element} b
|
|
328
|
+
*
|
|
329
|
+
* @return {boolean}
|
|
330
|
+
*/
|
|
331
|
+
function isSameOrganization(a, b) {
|
|
332
|
+
var parentA = getOrganizationalParent(a),
|
|
333
|
+
parentB = getOrganizationalParent(b);
|
|
334
|
+
|
|
335
|
+
return parentA === parentB;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* @param {Element} element
|
|
340
|
+
*
|
|
341
|
+
* @return {boolean}
|
|
342
|
+
*/
|
|
343
|
+
function isMessageFlowSource(element) {
|
|
344
|
+
return (
|
|
345
|
+
is(element, 'bpmn:InteractionNode') &&
|
|
346
|
+
!is(element, 'bpmn:BoundaryEvent') && (
|
|
347
|
+
!is(element, 'bpmn:Event') || (
|
|
348
|
+
is(element, 'bpmn:ThrowEvent') &&
|
|
349
|
+
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
|
350
|
+
)
|
|
351
|
+
)
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @param {Element} element
|
|
357
|
+
*
|
|
358
|
+
* @return {boolean}
|
|
359
|
+
*/
|
|
360
|
+
function isMessageFlowTarget(element) {
|
|
361
|
+
return (
|
|
362
|
+
is(element, 'bpmn:InteractionNode') &&
|
|
363
|
+
!isForCompensation(element) && (
|
|
364
|
+
!is(element, 'bpmn:Event') || (
|
|
365
|
+
is(element, 'bpmn:CatchEvent') &&
|
|
366
|
+
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
|
367
|
+
)
|
|
368
|
+
) && !(
|
|
369
|
+
is(element, 'bpmn:BoundaryEvent') &&
|
|
370
|
+
!hasEventDefinition(element, 'bpmn:MessageEventDefinition')
|
|
371
|
+
)
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @param {Element} element
|
|
377
|
+
*
|
|
378
|
+
* @return {ModdleElement}
|
|
379
|
+
*/
|
|
380
|
+
function getScopeParent(element) {
|
|
381
|
+
|
|
382
|
+
var parent = element;
|
|
383
|
+
|
|
384
|
+
while ((parent = parent.parent)) {
|
|
385
|
+
|
|
386
|
+
if (is(parent, 'bpmn:FlowElementsContainer')) {
|
|
387
|
+
return getBusinessObject(parent);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (is(parent, 'bpmn:Participant')) {
|
|
391
|
+
return getBusinessObject(parent).processRef;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @param {Element} a
|
|
400
|
+
* @param {Element} b
|
|
401
|
+
*
|
|
402
|
+
* @return {boolean}
|
|
403
|
+
*/
|
|
404
|
+
function isSameScope(a, b) {
|
|
405
|
+
var scopeParentA = getScopeParent(a),
|
|
406
|
+
scopeParentB = getScopeParent(b);
|
|
407
|
+
|
|
408
|
+
return scopeParentA === scopeParentB;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @param {Element} element
|
|
413
|
+
* @param {string} eventDefinition
|
|
414
|
+
*
|
|
415
|
+
* @return {boolean}
|
|
416
|
+
*/
|
|
417
|
+
function hasEventDefinition(element, eventDefinition) {
|
|
418
|
+
var businessObject = getBusinessObject(element);
|
|
419
|
+
|
|
420
|
+
return !!find(businessObject.eventDefinitions || [], function(definition) {
|
|
421
|
+
return is(definition, eventDefinition);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* @param {Element} element
|
|
427
|
+
* @param {string} eventDefinition
|
|
428
|
+
*
|
|
429
|
+
* @return {boolean}
|
|
430
|
+
*/
|
|
431
|
+
function hasEventDefinitionOrNone(element, eventDefinition) {
|
|
432
|
+
var businessObject = getBusinessObject(element);
|
|
433
|
+
|
|
434
|
+
return (businessObject.eventDefinitions || []).every(function(definition) {
|
|
435
|
+
return is(definition, eventDefinition);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* @param {Element} element
|
|
441
|
+
*
|
|
442
|
+
* @return {boolean}
|
|
443
|
+
*/
|
|
444
|
+
function isSequenceFlowSource(element) {
|
|
445
|
+
return (
|
|
446
|
+
is(element, 'bpmn:FlowNode') &&
|
|
447
|
+
!is(element, 'bpmn:EndEvent') &&
|
|
448
|
+
!isEventSubProcess(element) &&
|
|
449
|
+
!(is(element, 'bpmn:IntermediateThrowEvent') &&
|
|
450
|
+
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
|
|
451
|
+
) &&
|
|
452
|
+
!isCompensationBoundary(element) &&
|
|
453
|
+
!isForCompensation(element)
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* @param {Element} element
|
|
459
|
+
*
|
|
460
|
+
* @return {boolean}
|
|
461
|
+
*/
|
|
462
|
+
function isSequenceFlowTarget(element) {
|
|
463
|
+
return (
|
|
464
|
+
is(element, 'bpmn:FlowNode') &&
|
|
465
|
+
!is(element, 'bpmn:StartEvent') &&
|
|
466
|
+
!is(element, 'bpmn:BoundaryEvent') &&
|
|
467
|
+
!isEventSubProcess(element) &&
|
|
468
|
+
!(is(element, 'bpmn:IntermediateCatchEvent') &&
|
|
469
|
+
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
|
|
470
|
+
) &&
|
|
471
|
+
!isForCompensation(element)
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* @param {Element} element
|
|
477
|
+
*
|
|
478
|
+
* @return {boolean}
|
|
479
|
+
*/
|
|
480
|
+
function isEventBasedTarget(element) {
|
|
481
|
+
return (
|
|
482
|
+
is(element, 'bpmn:ReceiveTask') || (
|
|
483
|
+
is(element, 'bpmn:IntermediateCatchEvent') && (
|
|
484
|
+
hasEventDefinition(element, 'bpmn:MessageEventDefinition') ||
|
|
485
|
+
hasEventDefinition(element, 'bpmn:TimerEventDefinition') ||
|
|
486
|
+
hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') ||
|
|
487
|
+
hasEventDefinition(element, 'bpmn:SignalEventDefinition')
|
|
488
|
+
)
|
|
489
|
+
)
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* @param {Element} element
|
|
495
|
+
*
|
|
496
|
+
* @return {Shape[]}
|
|
497
|
+
*/
|
|
498
|
+
function getParents(element) {
|
|
499
|
+
|
|
500
|
+
var parents = [];
|
|
501
|
+
|
|
502
|
+
while (element) {
|
|
503
|
+
element = element.parent;
|
|
504
|
+
|
|
505
|
+
if (element) {
|
|
506
|
+
parents.push(element);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return parents;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* @param {Shape} possibleParent
|
|
515
|
+
* @param {Element} element
|
|
516
|
+
*
|
|
517
|
+
* @return {boolean}
|
|
518
|
+
*/
|
|
519
|
+
function isParent(possibleParent, element) {
|
|
520
|
+
var allParents = getParents(element);
|
|
521
|
+
|
|
522
|
+
return allParents.indexOf(possibleParent) !== -1;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* @param {Element} source
|
|
527
|
+
* @param {Element} target
|
|
528
|
+
* @param {Connection} connection
|
|
529
|
+
*
|
|
530
|
+
* @return {CanConnectResult}
|
|
531
|
+
*/
|
|
532
|
+
function canConnect(source, target, connection) {
|
|
533
|
+
|
|
534
|
+
if (nonExistingOrLabel(source) || nonExistingOrLabel(target)) {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (!is(connection, 'bpmn:DataAssociation')) {
|
|
539
|
+
|
|
540
|
+
if (canConnectMessageFlow(source, target)) {
|
|
541
|
+
return { type: 'bpmn:MessageFlow' };
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (canConnectSequenceFlow(source, target)) {
|
|
545
|
+
return { type: 'bpmn:SequenceFlow' };
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
var connectDataAssociation = canConnectDataAssociation(source, target);
|
|
550
|
+
|
|
551
|
+
if (connectDataAssociation) {
|
|
552
|
+
return connectDataAssociation;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (canConnectCompensationAssociation(source, target)) {
|
|
556
|
+
return {
|
|
557
|
+
type: 'bpmn:Association',
|
|
558
|
+
associationDirection: 'One'
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (canConnectAssociation(source, target)) {
|
|
563
|
+
return {
|
|
564
|
+
type: 'bpmn:Association',
|
|
565
|
+
associationDirection: 'None'
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Can an element be dropped into the target element.
|
|
574
|
+
*
|
|
575
|
+
* @param {Element} element
|
|
576
|
+
* @param {Shape} target
|
|
577
|
+
*
|
|
578
|
+
* @return {boolean}
|
|
579
|
+
*/
|
|
580
|
+
function canDrop(element, target) {
|
|
581
|
+
|
|
582
|
+
// can move labels and groups everywhere
|
|
583
|
+
if (isLabel(element) || isGroup(element)) {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
// disallow to create elements on collapsed pools
|
|
589
|
+
if (is(target, 'bpmn:Participant') && !isExpanded(target)) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// allow to create new participants on
|
|
594
|
+
// existing collaboration and process diagrams
|
|
595
|
+
if (is(element, 'bpmn:Participant')) {
|
|
596
|
+
return is(target, 'bpmn:Process') || is(target, 'bpmn:Collaboration');
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// allow moving DataInput / DataOutput within its original container only
|
|
600
|
+
if (isAny(element, [ 'bpmn:DataInput', 'bpmn:DataOutput' ])) {
|
|
601
|
+
|
|
602
|
+
if (element.parent) {
|
|
603
|
+
return target === element.parent;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// allow creating lanes on participants and other lanes only
|
|
608
|
+
if (is(element, 'bpmn:Lane')) {
|
|
609
|
+
return is(target, 'bpmn:Participant') || is(target, 'bpmn:Lane');
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// disallow dropping boundary events which cannot replace with intermediate event
|
|
613
|
+
if (is(element, 'bpmn:BoundaryEvent') && !isDroppableBoundaryEvent(element)) {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// drop flow elements onto flow element containers
|
|
618
|
+
// and participants
|
|
619
|
+
if (is(element, 'bpmn:FlowElement') && !is(element, 'bpmn:DataStoreReference')) {
|
|
620
|
+
if (is(target, 'bpmn:FlowElementsContainer')) {
|
|
621
|
+
return isExpanded(target);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// disallow dropping data store reference if there is no process to append to
|
|
628
|
+
if (is(element, 'bpmn:DataStoreReference') && is(target, 'bpmn:Collaboration')) {
|
|
629
|
+
return some(getBusinessObject(target).get('participants'), function(participant) {
|
|
630
|
+
return !!participant.get('processRef');
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// account for the fact that data associations are always
|
|
635
|
+
// rendered and moved to top (Process or Collaboration level)
|
|
636
|
+
//
|
|
637
|
+
// artifacts may be placed wherever, too
|
|
638
|
+
if (isAny(element, [ 'bpmn:Artifact', 'bpmn:DataAssociation', 'bpmn:DataStoreReference' ])) {
|
|
639
|
+
return isAny(target, [
|
|
640
|
+
'bpmn:Collaboration',
|
|
641
|
+
'bpmn:Lane',
|
|
642
|
+
'bpmn:Participant',
|
|
643
|
+
'bpmn:Process',
|
|
644
|
+
'bpmn:SubProcess' ]);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (is(element, 'bpmn:MessageFlow')) {
|
|
648
|
+
return is(target, 'bpmn:Collaboration')
|
|
649
|
+
|| element.source.parent == target
|
|
650
|
+
|| element.target.parent == target;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @param {Shape} event
|
|
658
|
+
*
|
|
659
|
+
* @return {boolean}
|
|
660
|
+
*/
|
|
661
|
+
function isDroppableBoundaryEvent(event) {
|
|
662
|
+
return getBusinessObject(event).cancelActivity && (
|
|
663
|
+
hasNoEventDefinition(event) || hasCommonBoundaryIntermediateEventDefinition(event)
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* @param {Element} element
|
|
669
|
+
*
|
|
670
|
+
* @return {boolean}
|
|
671
|
+
*/
|
|
672
|
+
function isBoundaryEvent(element) {
|
|
673
|
+
return !isLabel(element) && is(element, 'bpmn:BoundaryEvent');
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* @param {Element} element
|
|
678
|
+
*
|
|
679
|
+
* @return {boolean}
|
|
680
|
+
*/
|
|
681
|
+
function isLane(element) {
|
|
682
|
+
return is(element, 'bpmn:Lane');
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* `bpmn:IntermediateThrowEvents` are treated as boundary events during create.
|
|
687
|
+
*
|
|
688
|
+
* @param {Element} element
|
|
689
|
+
*
|
|
690
|
+
* @return {boolean}
|
|
691
|
+
*/
|
|
692
|
+
function isBoundaryCandidate(element) {
|
|
693
|
+
if (isBoundaryEvent(element)) {
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (is(element, 'bpmn:IntermediateThrowEvent') && hasNoEventDefinition(element)) {
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
return (
|
|
702
|
+
is(element, 'bpmn:IntermediateCatchEvent') &&
|
|
703
|
+
hasCommonBoundaryIntermediateEventDefinition(element)
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* @param {Element} element
|
|
709
|
+
*
|
|
710
|
+
* @return {boolean}
|
|
711
|
+
*/
|
|
712
|
+
function hasNoEventDefinition(element) {
|
|
713
|
+
var businessObject = getBusinessObject(element);
|
|
714
|
+
|
|
715
|
+
return businessObject && !(businessObject.eventDefinitions && businessObject.eventDefinitions.length);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* @param {Element} element
|
|
720
|
+
*
|
|
721
|
+
* @return {boolean}
|
|
722
|
+
*/
|
|
723
|
+
function hasCommonBoundaryIntermediateEventDefinition(element) {
|
|
724
|
+
return hasOneOfEventDefinitions(element, [
|
|
725
|
+
'bpmn:MessageEventDefinition',
|
|
726
|
+
'bpmn:TimerEventDefinition',
|
|
727
|
+
'bpmn:SignalEventDefinition',
|
|
728
|
+
'bpmn:ConditionalEventDefinition'
|
|
729
|
+
]);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* @param {Element} element
|
|
734
|
+
* @param {string[]} eventDefinitions
|
|
735
|
+
*
|
|
736
|
+
* @return {boolean}
|
|
737
|
+
*/
|
|
738
|
+
function hasOneOfEventDefinitions(element, eventDefinitions) {
|
|
739
|
+
return eventDefinitions.some(function(definition) {
|
|
740
|
+
return hasEventDefinition(element, definition);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* @param {Element} element
|
|
746
|
+
*
|
|
747
|
+
* @return {boolean}
|
|
748
|
+
*/
|
|
749
|
+
function isReceiveTaskAfterEventBasedGateway(element) {
|
|
750
|
+
return (
|
|
751
|
+
is(element, 'bpmn:ReceiveTask') &&
|
|
752
|
+
find(element.incoming, function(incoming) {
|
|
753
|
+
return is(incoming.source, 'bpmn:EventBasedGateway');
|
|
754
|
+
})
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* TODO(philippfromme): remove `source` parameter
|
|
760
|
+
*
|
|
761
|
+
* @param {Element[]} elements
|
|
762
|
+
* @param {Shape} target
|
|
763
|
+
* @param {Element} source
|
|
764
|
+
* @param {Point} [position]
|
|
765
|
+
*
|
|
766
|
+
* @return {boolean | 'attach'}
|
|
767
|
+
*/
|
|
768
|
+
function canAttach(elements, target, source, position) {
|
|
769
|
+
|
|
770
|
+
if (!Array.isArray(elements)) {
|
|
771
|
+
elements = [ elements ];
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// only (re-)attach one element at a time
|
|
775
|
+
if (elements.length !== 1) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
var element = elements[0];
|
|
780
|
+
|
|
781
|
+
// do not attach labels
|
|
782
|
+
if (isLabel(element)) {
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// only handle boundary events
|
|
787
|
+
if (!isBoundaryCandidate(element)) {
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// disallow drop on event sub processes
|
|
792
|
+
if (isEventSubProcess(target)) {
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// only allow drop on non compensation activities
|
|
797
|
+
if (!is(target, 'bpmn:Activity') || isForCompensation(target)) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// only attach to subprocess border
|
|
802
|
+
if (position && !isBoundaryAttachment(position, target)) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// do not attach on receive tasks after event based gateways
|
|
807
|
+
if (isReceiveTaskAfterEventBasedGateway(target)) {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
return 'attach';
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Check whether the given elements can be replaced. Return all elements which
|
|
816
|
+
* can be replaced.
|
|
817
|
+
*
|
|
818
|
+
* @example
|
|
819
|
+
*
|
|
820
|
+
* ```javascript
|
|
821
|
+
* [{
|
|
822
|
+
* id: 'IntermediateEvent_1',
|
|
823
|
+
* type: 'bpmn:StartEvent'
|
|
824
|
+
* },
|
|
825
|
+
* {
|
|
826
|
+
* id: 'Task_1',
|
|
827
|
+
* type: 'bpmn:ServiceTask'
|
|
828
|
+
* }]
|
|
829
|
+
* ```
|
|
830
|
+
*
|
|
831
|
+
* @param {Element[]} elements
|
|
832
|
+
* @param {Shape} [target]
|
|
833
|
+
* @param {Point} [position]
|
|
834
|
+
*
|
|
835
|
+
* @return {CanReplaceResult}
|
|
836
|
+
*/
|
|
837
|
+
function canReplace(elements, target, position) {
|
|
838
|
+
|
|
839
|
+
if (!target) {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
var canExecute = {
|
|
844
|
+
replacements: []
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
forEach(elements, function(element) {
|
|
848
|
+
|
|
849
|
+
if (!isEventSubProcess(target)) {
|
|
850
|
+
|
|
851
|
+
if (is(element, 'bpmn:StartEvent') &&
|
|
852
|
+
element.type !== 'label' &&
|
|
853
|
+
canDrop(element, target)) {
|
|
854
|
+
|
|
855
|
+
// replace a non-interrupting start event by a blank interrupting start event
|
|
856
|
+
// when the target is not an event sub process
|
|
857
|
+
if (!isInterrupting(element)) {
|
|
858
|
+
canExecute.replacements.push({
|
|
859
|
+
oldElementId: element.id,
|
|
860
|
+
newElementType: 'bpmn:StartEvent'
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// replace an error/escalation/compensate start event by a blank interrupting start event
|
|
865
|
+
// when the target is not an event sub process
|
|
866
|
+
if (hasErrorEventDefinition(element) ||
|
|
867
|
+
hasEscalationEventDefinition(element) ||
|
|
868
|
+
hasCompensateEventDefinition(element)) {
|
|
869
|
+
canExecute.replacements.push({
|
|
870
|
+
oldElementId: element.id,
|
|
871
|
+
newElementType: 'bpmn:StartEvent'
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// replace a typed start event by a blank interrupting start event
|
|
876
|
+
// when the target is a sub process but not an event sub process
|
|
877
|
+
if (hasOneOfEventDefinitions(element,
|
|
878
|
+
[
|
|
879
|
+
'bpmn:MessageEventDefinition',
|
|
880
|
+
'bpmn:TimerEventDefinition',
|
|
881
|
+
'bpmn:SignalEventDefinition',
|
|
882
|
+
'bpmn:ConditionalEventDefinition'
|
|
883
|
+
]) &&
|
|
884
|
+
is(target, 'bpmn:SubProcess')) {
|
|
885
|
+
canExecute.replacements.push({
|
|
886
|
+
oldElementId: element.id,
|
|
887
|
+
newElementType: 'bpmn:StartEvent'
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (!is(target, 'bpmn:Transaction')) {
|
|
894
|
+
if (hasEventDefinition(element, 'bpmn:CancelEventDefinition') &&
|
|
895
|
+
element.type !== 'label') {
|
|
896
|
+
|
|
897
|
+
if (is(element, 'bpmn:EndEvent') && canDrop(element, target)) {
|
|
898
|
+
canExecute.replacements.push({
|
|
899
|
+
oldElementId: element.id,
|
|
900
|
+
newElementType: 'bpmn:EndEvent'
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if (is(element, 'bpmn:BoundaryEvent') && canAttach(element, target, null, position)) {
|
|
905
|
+
canExecute.replacements.push({
|
|
906
|
+
oldElementId: element.id,
|
|
907
|
+
newElementType: 'bpmn:BoundaryEvent'
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
return canExecute.replacements.length ? canExecute : false;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* @param {Element[]} elements
|
|
919
|
+
* @param {Shape} target
|
|
920
|
+
*
|
|
921
|
+
* @return {boolean}
|
|
922
|
+
*/
|
|
923
|
+
function canMove(elements, target) {
|
|
924
|
+
|
|
925
|
+
// do not move selection containing lanes
|
|
926
|
+
if (some(elements, isLane)) {
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// allow default move check to start move operation
|
|
931
|
+
if (!target) {
|
|
932
|
+
return true;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
return elements.every(function(element) {
|
|
936
|
+
return canDrop(element, target);
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* @param {Shape} shape
|
|
942
|
+
* @param {Shape} target
|
|
943
|
+
* @param {Element} source
|
|
944
|
+
* @param {Point} position
|
|
945
|
+
*
|
|
946
|
+
* @return {boolean}
|
|
947
|
+
*/
|
|
948
|
+
function canCreate(shape, target, source, position) {
|
|
949
|
+
|
|
950
|
+
if (!target) {
|
|
951
|
+
return false;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if (isLabel(shape) || isGroup(shape)) {
|
|
955
|
+
return true;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
if (isSame(source, target)) {
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
// ensure we do not drop the element
|
|
963
|
+
// into source
|
|
964
|
+
if (source && isParent(source, target)) {
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return canDrop(shape, target, position) || canInsert(shape, target, position);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* @param {Shape} shape
|
|
973
|
+
* @param {Rect} newBounds
|
|
974
|
+
*
|
|
975
|
+
* @return {boolean}
|
|
976
|
+
*/
|
|
977
|
+
function canResize(shape, newBounds) {
|
|
978
|
+
if (is(shape, 'bpmn:SubProcess')) {
|
|
979
|
+
return (
|
|
980
|
+
isExpanded(shape) && (
|
|
981
|
+
!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
|
|
982
|
+
)
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (is(shape, 'bpmn:Lane')) {
|
|
987
|
+
return true;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
if (is(shape, 'bpmn:Participant')) {
|
|
991
|
+
return true;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
if (isTextAnnotation(shape)) {
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
if (isGroup(shape)) {
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Check whether one of of the elements to be connected is a text annotation.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {Element} source
|
|
1009
|
+
* @param {Element} target
|
|
1010
|
+
*
|
|
1011
|
+
* @return {boolean}
|
|
1012
|
+
*/
|
|
1013
|
+
function isOneTextAnnotation(source, target) {
|
|
1014
|
+
|
|
1015
|
+
var sourceTextAnnotation = isTextAnnotation(source),
|
|
1016
|
+
targetTextAnnotation = isTextAnnotation(target);
|
|
1017
|
+
|
|
1018
|
+
return (
|
|
1019
|
+
(sourceTextAnnotation || targetTextAnnotation) &&
|
|
1020
|
+
(sourceTextAnnotation !== targetTextAnnotation)
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* @param {Element} source
|
|
1026
|
+
* @param {Element} target
|
|
1027
|
+
*
|
|
1028
|
+
* @return {CanConnectResult}
|
|
1029
|
+
*/
|
|
1030
|
+
function canConnectAssociation(source, target) {
|
|
1031
|
+
|
|
1032
|
+
// don't connect parent <-> child
|
|
1033
|
+
if (isParent(target, source) || isParent(source, target)) {
|
|
1034
|
+
return false;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
// allow connection of associations between <!TextAnnotation> and <TextAnnotation>
|
|
1038
|
+
if (isOneTextAnnotation(source, target)) {
|
|
1039
|
+
return true;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// can connect associations where we can connect
|
|
1043
|
+
// data associations, too (!)
|
|
1044
|
+
return !!canConnectDataAssociation(source, target);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* @param {Element} source
|
|
1049
|
+
* @param {Element} target
|
|
1050
|
+
*
|
|
1051
|
+
* @return {boolean}
|
|
1052
|
+
*/
|
|
1053
|
+
function canConnectCompensationAssociation(source, target) {
|
|
1054
|
+
return (
|
|
1055
|
+
isSameScope(source, target) &&
|
|
1056
|
+
isCompensationBoundary(source) &&
|
|
1057
|
+
is(target, 'bpmn:Activity') &&
|
|
1058
|
+
!isHostOfElement(target, source) &&
|
|
1059
|
+
!isEventSubProcess(target)
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* @param {Element} source
|
|
1065
|
+
* @param {Element} target
|
|
1066
|
+
*
|
|
1067
|
+
* @return {boolean}
|
|
1068
|
+
*/
|
|
1069
|
+
function canConnectMessageFlow(source, target) {
|
|
1070
|
+
|
|
1071
|
+
// during connect user might move mouse out of canvas
|
|
1072
|
+
// https://github.com/bpmn-io/bpmn-js/issues/1033
|
|
1073
|
+
if (getRootElement(source) && !getRootElement(target)) {
|
|
1074
|
+
return false;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
return (
|
|
1078
|
+
isMessageFlowSource(source) &&
|
|
1079
|
+
isMessageFlowTarget(target) &&
|
|
1080
|
+
!isSameOrganization(source, target)
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* @param {Element} source
|
|
1086
|
+
* @param {Element} target
|
|
1087
|
+
*
|
|
1088
|
+
* @return {boolean}
|
|
1089
|
+
*/
|
|
1090
|
+
function canConnectSequenceFlow(source, target) {
|
|
1091
|
+
return isSequenceFlowSource(source) &&
|
|
1092
|
+
isSequenceFlowTarget(target) &&
|
|
1093
|
+
isSameScope(source, target) &&
|
|
1094
|
+
!(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target));
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* @param {Element} source
|
|
1099
|
+
* @param {Element} target
|
|
1100
|
+
*
|
|
1101
|
+
* @return {CanConnectResult}
|
|
1102
|
+
*/
|
|
1103
|
+
function canConnectDataAssociation(source, target) {
|
|
1104
|
+
|
|
1105
|
+
if (isAny(source, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ]) &&
|
|
1106
|
+
isAny(target, [ 'bpmn:Activity', 'bpmn:ThrowEvent' ])) {
|
|
1107
|
+
return { type: 'bpmn:DataInputAssociation' };
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
if (isAny(target, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ]) &&
|
|
1111
|
+
isAny(source, [ 'bpmn:Activity', 'bpmn:CatchEvent' ])) {
|
|
1112
|
+
return { type: 'bpmn:DataOutputAssociation' };
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* @param {Shape} shape
|
|
1120
|
+
* @param {Connection} connection
|
|
1121
|
+
* @param {Point} position
|
|
1122
|
+
*
|
|
1123
|
+
* @return {boolean}
|
|
1124
|
+
*/
|
|
1125
|
+
function canInsert(shape, connection, position) {
|
|
1126
|
+
if (!connection) {
|
|
1127
|
+
return false;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if (Array.isArray(shape)) {
|
|
1131
|
+
if (shape.length !== 1) {
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
shape = shape[ 0 ];
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
if (connection.source === shape ||
|
|
1139
|
+
connection.target === shape) {
|
|
1140
|
+
return false;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// return true if shape can be inserted into connection parent
|
|
1144
|
+
return (
|
|
1145
|
+
isAny(connection, [ 'bpmn:SequenceFlow', 'bpmn:MessageFlow' ]) &&
|
|
1146
|
+
!isLabel(connection) &&
|
|
1147
|
+
is(shape, 'bpmn:FlowNode') &&
|
|
1148
|
+
!is(shape, 'bpmn:BoundaryEvent') &&
|
|
1149
|
+
canDrop(shape, connection.parent, position));
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* @param {Element[]} elements
|
|
1154
|
+
* @param {Element} element
|
|
1155
|
+
*
|
|
1156
|
+
* @return {boolean}
|
|
1157
|
+
*/
|
|
1158
|
+
function includes(elements, element) {
|
|
1159
|
+
return (elements && element) && elements.indexOf(element) !== -1;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* @param {Element[]} elements
|
|
1164
|
+
* @param {Element} element
|
|
1165
|
+
*
|
|
1166
|
+
* @return {boolean}
|
|
1167
|
+
*/
|
|
1168
|
+
function canCopy(elements, element) {
|
|
1169
|
+
if (isLabel(element)) {
|
|
1170
|
+
return true;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
if (is(element, 'bpmn:Lane') && !includes(elements, element.parent)) {
|
|
1174
|
+
return false;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* @param {Element} element
|
|
1182
|
+
*
|
|
1183
|
+
* @return {Element|null}
|
|
1184
|
+
*/
|
|
1185
|
+
function getRootElement(element) {
|
|
1186
|
+
return getParent(element, 'bpmn:Process') || getParent(element, 'bpmn:Collaboration');
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function isHostOfElement(potentialHost, element) {
|
|
1190
|
+
return potentialHost.attachers.includes(element);
|
|
1191
|
+
}
|