J/X/Tree: expanding all nodes on a large tree on/off EDT?
Posted at OTN
copied here for your convenience:
recently I was remembered of a long-standing task in SwingX, which is to support expanding all nodes of a JXTree .. for large trees.
JXTree has api to do so, with a naive implemenation which simply loops through all rows until the end. That's good enough for smaller trees, but not for larger, can take minutes and is blocking the EDT.
Simple way is to tell the developer it's no good for larger trees, "your job to do it somehow in the background" --- thinking about it, I couldn't come up with any idea about the how-to: expanding _is_ all ui-related touching several view-related classes including the tree itself during expansion, so looks like it has to happen on the EDT. Being so, the next option might be some way to partion the expansion into smaller chunks, each being so small that the effective blocking wouldn't be noticeable with some prioritizing such that the visible part of the tree always is expanded. Sounds like quite a task ..
On the other hand, maybe an ui which allows expanding 100k of nodes at once isn't optimal anyway - considering the time it would take the user to browse 100k nodes .. if so, SwingX could lean back and do nothing, happy option :-)
Opinions, ideas, references to existing code or discussions highly welcome!