From facc7988fde26215ddfb064e2d73be7d25e23d02 Mon Sep 17 00:00:00 2001 From: valb3r Date: Mon, 26 Aug 2024 11:46:47 +0300 Subject: [PATCH] Support for 'Select All' --- .../intellij/plugin/core/KeyboardEventHandler.kt | 3 +++ .../bpmn/intellij/plugin/core/render/Canvas.kt | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/KeyboardEventHandler.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/KeyboardEventHandler.kt index 82326ab68..4dd1ee134 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/KeyboardEventHandler.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/KeyboardEventHandler.kt @@ -51,6 +51,9 @@ class KeyboardEventHandler(private val project: Project, private val canvas: Can private fun handleKeyWithControl(e: KeyEvent) { when (e.keyCode) { + KeyEvent.VK_A -> { + currentCanvas(project).selectAllElements() + } KeyEvent.VK_Y -> if (updateEventsRegistry(project).undoRedoStatus().contains(ProcessModelUpdateEvents.UndoRedo.REDO)) { updateEventsRegistry(project).redo() currentCanvas(project).repaint() diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt index 88bd90667..74afb90d6 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt @@ -343,6 +343,17 @@ open class Canvas(private val project: Project, private val settings: CanvasCons this.selectedElements.addAll(elements) } + fun selectAllElements() { + clearSelection() + this.selectedElements.addAll( + elemsUnderRect( + null, + excludeAreas = setOf(AreaType.PARENT_PROCESS_SHAPE, AreaType.SELECTS_DRAG_TARGET) + ) + ) + repaint() + } + private fun selectDragTarget(dragged: DiagramElementId, ctx: ElementInteractionContext): DiagramElementId? { val areas = areaByElement!! val area = areas[dragged]!!.area @@ -556,8 +567,8 @@ open class Canvas(private val project: Project, private val settings: CanvasCons return result } - private fun elemsUnderRect(withinRect: Rectangle2D, excludeAreas: Set = setOf(AreaType.PARENT_PROCESS_SHAPE)): List { - val intersection = areaByElement?.filter { withinRect.contains(it.value.area.bounds2D) } + private fun elemsUnderRect(withinRect: Rectangle2D?, excludeAreas: Set = setOf(AreaType.PARENT_PROCESS_SHAPE)): List { + val intersection = if (null == withinRect) areaByElement else areaByElement?.filter { withinRect.contains(it.value.area.bounds2D) } val result = mutableListOf() intersection