diff --git a/src/app/modeler/edit-mode/context-menu/menu-items/select-arcs-menu-item.ts b/src/app/modeler/edit-mode/context-menu/menu-items/select-arcs-menu-item.ts new file mode 100644 index 0000000..6402738 --- /dev/null +++ b/src/app/modeler/edit-mode/context-menu/menu-items/select-arcs-menu-item.ts @@ -0,0 +1,16 @@ +import {MenuItem} from './menu-item'; +import {SelectTool} from '../../services/modes/select-tool'; +import {CanvasNodeElement} from '../../domain/canvas-node-element'; + +export class SelectArcsMenuItem extends MenuItem { + + constructor(tool: SelectTool, element: CanvasNodeElement) { + super( + `Select connected arcs`, + 'sync_alt', + () => { + tool.selectConnectedArcs(element); + } + ); + } +} diff --git a/src/app/modeler/edit-mode/services/modes/quick-draw-tool.ts b/src/app/modeler/edit-mode/services/modes/quick-draw-tool.ts index 3c8154d..a2958c4 100644 --- a/src/app/modeler/edit-mode/services/modes/quick-draw-tool.ts +++ b/src/app/modeler/edit-mode/services/modes/quick-draw-tool.ts @@ -95,6 +95,20 @@ export class QuickDrawTool extends CanvasTool { super.onArcContextMenu(event, arc); } + onArcEnter(event: MouseEvent, arc: CanvasArc) { + if (this.isWorkInProgress()) { + return; + } + super.onArcEnter(event, arc); + } + + onArcLeave(event: MouseEvent, arc: CanvasArc) { + if (this.isWorkInProgress()) { + return; + } + super.onArcLeave(event, arc); + } + onPlaceClick(event: MouseEvent, canvasPlace: CanvasPlace) { if (this.isContextMenuOpen()) { this.closeContextMenu(); diff --git a/src/app/modeler/edit-mode/services/modes/select-tool.ts b/src/app/modeler/edit-mode/services/modes/select-tool.ts index 46bb347..949ca07 100644 --- a/src/app/modeler/edit-mode/services/modes/select-tool.ts +++ b/src/app/modeler/edit-mode/services/modes/select-tool.ts @@ -21,6 +21,8 @@ import { import {ModelerConfig} from '../../../modeler-config'; import {DeleteSelectedMenuItem} from '../../context-menu/menu-items/delete-selected-menu-item'; import {DeleteMenuItem} from '../../context-menu/menu-items/delete-menu-item'; +import {SelectArcsMenuItem} from '../../context-menu/menu-items/select-arcs-menu-item'; +import {CanvasNodeElement} from '../../domain/canvas-node-element'; export class SelectTool extends CanvasTool { @@ -533,17 +535,27 @@ export class SelectTool extends CanvasTool { } placeContextMenu(place: CanvasPlace, event: MouseEvent): ContextMenu { - return this.replaceDeleteMenuItem(super.placeContextMenu(place, event)); + const menu = this.replaceDeleteMenuItem(super.placeContextMenu(place, event)); + menu.items.push(new SelectArcsMenuItem(this, place)); + return menu; } transitionContextMenu(transition: CanvasTransition, event: MouseEvent): ContextMenu { - return this.replaceDeleteMenuItem(super.transitionContextMenu(transition, event)); + const menu = this.replaceDeleteMenuItem(super.transitionContextMenu(transition, event)); + menu.items.push(new SelectArcsMenuItem(this, transition)); + return menu; } arcContextMenu(arc: CanvasArc, event: MouseEvent): ContextMenu { return this.replaceDeleteMenuItem(super.arcContextMenu(arc, event)); } + selectConnectedArcs(element: CanvasNodeElement) { + const elementId = element.modelElement.id; + const connected = this.elements.arcs.filter(a => a.modelArc.source.id === elementId || a.modelArc.destination.id === elementId); + connected.forEach(a => this.addToSelection(a)); + } + private replaceDeleteMenuItem(menuItem: ContextMenu): ContextMenu { const index = menuItem.items.findIndex(value => value instanceof DeleteMenuItem); if (index >= 0) {