From e58116100cc540c057c922e864caba50ca7cf3d2 Mon Sep 17 00:00:00 2001 From: fscarponi Date: Mon, 30 Oct 2023 14:40:25 +0100 Subject: [PATCH] feat: Add expandTree() and collapseTree() methods to TreeState --- .../org/jetbrains/jewel/foundation/lazy/tree/TreeState.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/TreeState.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/TreeState.kt index 43bce01fa..5b0fdcd40 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/TreeState.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/TreeState.kt @@ -39,4 +39,12 @@ class TreeState( fun openNodes(nodes: List) { openNodes += nodes } + + fun expandTree() { + if (allNodes.size != openNodes.size) openNodes = allNodes.toSet() + } + + fun collapseTree() { + if (openNodes.isNotEmpty()) openNodes = emptySet() + } }