Skip to content

Commit

Permalink
Support for 'Select All'
Browse files Browse the repository at this point in the history
  • Loading branch information
valb3r committed Aug 26, 2024
1 parent 74db200 commit facc798
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -556,8 +567,8 @@ open class Canvas(private val project: Project, private val settings: CanvasCons
return result
}

private fun elemsUnderRect(withinRect: Rectangle2D, excludeAreas: Set<AreaType> = setOf(AreaType.PARENT_PROCESS_SHAPE)): List<DiagramElementId> {
val intersection = areaByElement?.filter { withinRect.contains(it.value.area.bounds2D) }
private fun elemsUnderRect(withinRect: Rectangle2D?, excludeAreas: Set<AreaType> = setOf(AreaType.PARENT_PROCESS_SHAPE)): List<DiagramElementId> {
val intersection = if (null == withinRect) areaByElement else areaByElement?.filter { withinRect.contains(it.value.area.bounds2D) }

val result = mutableListOf<DiagramElementId>()
intersection
Expand Down

0 comments on commit facc798

Please sign in to comment.