How to insert a node into a Tree without reloading everything?

Answered

Hi,

i created a "tree":

var tree = new Tree(node);

now i want to insert a node "dynamically" into it via an action:

var treeModel = (DefaultTreeModel)tree.getModel();

treeModel.insertNodeInto(newChild, this, childCount);

The node is correctly inserted, i can check this by doing 

treeModel.reload(this);

The problem is that this collapses all childs and not the new one. 

I also cannot do 

treeModel.reload();

as this collapses all nodes (parent of a parent etc).

Is there a way to tell the treeModel to insert the node and dont refresh/collapse the other childs?

0
2 comments

Not sure why you call "reload"?

See also `com.intellij.util.ui.tree.TreeUtil` for many utility methods dealing with trees.

0

If i dont call reload, the node is not appearing in the UI. I even used TreeUtils.insertNode, but it still is not appearing in the UI

0

Please sign in to leave a comment.