From f1d098e6a78274249ef50a7c60dae4062650c448 Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Thu, 14 Mar 2024 04:13:12 +0100 Subject: [PATCH] Core Editor: Show "+" icon next to new elements --- .../decima/ui/editor/core/command/BaseNodeCommand.java | 4 +++- .../decima/ui/editor/core/command/ElementAddCommand.java | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/BaseNodeCommand.java b/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/BaseNodeCommand.java index ea5bcefc1..89098795e 100644 --- a/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/BaseNodeCommand.java +++ b/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/BaseNodeCommand.java @@ -20,7 +20,9 @@ public BaseNodeCommand(@NotNull Tree tree, @NotNull CoreNodeObject node) { public void redo() { super.redo(); - node.setState(CoreNodeObject.State.CHANGED); + if (node.getState() == CoreNodeObject.State.UNCHANGED) { + node.setState(CoreNodeObject.State.CHANGED); + } } @Override diff --git a/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/ElementAddCommand.java b/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/ElementAddCommand.java index dfd37df0f..596cb5e2e 100644 --- a/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/ElementAddCommand.java +++ b/modules/decima-ui/src/main/java/com/shade/decima/ui/editor/core/command/ElementAddCommand.java @@ -3,6 +3,7 @@ import com.shade.decima.model.rtti.types.RTTITypeArray; import com.shade.decima.ui.editor.core.CoreNodeObject; import com.shade.platform.ui.controls.tree.Tree; +import com.shade.platform.ui.controls.tree.TreeNode; import com.shade.util.NotNull; import javax.swing.tree.TreePath; @@ -60,7 +61,13 @@ private void perform(boolean redo) { node.unloadChildren(); tree.getModel().fireStructureChanged(node); - final TreePath path = tree.getModel().getTreePathToRoot(tree.getModel().getChild(node, leaf)); + final TreeNode child = tree.getModel().getChild(node, leaf); + + if (redo && child instanceof CoreNodeObject object) { + object.setState(CoreNodeObject.State.NEW); + } + + final TreePath path = tree.getModel().getTreePathToRoot(child); tree.setSelectionPath(path); tree.scrollPathToVisible(path); }