Disable SimpleTreeStructure auto-expand with single child

Answered

How do I disable auto-expand in SimpleTreeStructure when there is only a single child element? I'm trying to display a recursive object and this auto-expand functionality is opening an infinite chain of children. Everything works normally if there is more than one child, but if there is just one child it results in the following issue:

5 comments
Comment actions Permalink

Hi Brandon,

SimpleTreeStructure looks like a model class. Check com.intellij.ui.treeStructure.SimpleNode.isAutoExpandNode() method. I don't know your implementation and use case details but seems like you may to extend SimpleNode and override isAutoExpandNode().

0
Comment actions Permalink

Unfortunately, that method is never called during the issue demonstrated above and the source code for SimpleNode.isAutoExpandNode() shows that if it was called, it returns false. I've also experimented with SimpleNode.getLeafState() with no success.

0
Comment actions Permalink

I see. Please share the full code context then.

0
Comment actions Permalink

https://github.com/BFergerson/simple-tree-structure-issue

The repository above shows a minimally reproducible example of the issue I'm facing. You just need to open a project and the following window should appear which demonstrates the issue:

You can see here that SimpleNode.isAutoExpandNode() has no effect.

0
Comment actions Permalink

It is currently not possible with the open API. Please follow:
https://youtrack.jetbrains.com/issue/IDEA-301210/Add-the-possibility-of-auto-expanding-trees-customization

UPDATE: It is possible with:

UIUtil.putClientProperty(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED, false)
now. The DefaultTreeUI.AUTO_EXPAND_ALLOWED internal API status has been removed since 223.5582.
0

Please sign in to leave a comment.