diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java index de4c75a558..fb7450a63e 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java @@ -9,12 +9,10 @@ import static net.sourceforge.pmd.util.fxdesigner.util.DesignerIteratorUtil.pare import java.util.Objects; import java.util.function.BiConsumer; -import java.util.function.Consumer; import org.reactfx.EventSource; import org.reactfx.EventStreams; import org.reactfx.SuspendableEventStream; -import org.reactfx.value.Var; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.util.fxdesigner.app.DesignerRoot; @@ -33,7 +31,6 @@ import javafx.scene.control.TreeView; public class AstTreeView extends TreeView implements NodeSelectionSource { - private final Var> onNodeClickedHandler = Var.newSimpleVar(n -> {}); private final TreeViewWrapper myWrapper = new TreeViewWrapper<>(this); private ASTTreeItem selectedTreeItem; @@ -49,6 +46,10 @@ public class AstTreeView extends TreeView implements NodeSelectionSource { initNodeSelectionHandling(root, selectionEvents, false); + // this needs to be done even if the selection originates from this node + EventStreams.changesOf(getSelectionModel().selectedItemProperty()) + .subscribe(item -> highlightFocusNodeParents((ASTTreeItem) item.getOldValue(), (ASTTreeItem) item.getNewValue())); + // push a node selection event whenever... // * The selection changes EventStreams.valuesOf(getSelectionModel().selectedItemProperty()) @@ -90,8 +91,6 @@ public class AstTreeView extends TreeView implements NodeSelectionSource { selectionEvents.suspendWhile(() -> selectionModel.select(found)); } - highlightFocusNodeParents(selectedTreeItem, found); - selectedTreeItem = found; getFocusModel().focus(selectionModel.getSelectedIndex()); @@ -135,11 +134,6 @@ public class AstTreeView extends TreeView implements NodeSelectionSource { } - public Var> onNodeClickedHandlerProperty() { - return onNodeClickedHandler; - } - - @Override public DesignerRoot getDesignerRoot() { return designerRoot;