开发者

Expanding Java SWT Tree asynchronously

I am having a problem with my SWT Tree. It contains many leaves what makes expanding an item very time consuming. Sometimes I even need to expand all items. Is there a way to expand it asynchronously? I have tried to use asyncExec() on t开发者_开发问答he display putting expandAll() inside the run() method, but it didn't help. And it doesn't solve the first problem where I want to expand only one item. Any ideas?

Additional node: The slow expansion of an item happenes only the first time I expand it. All later expansions of the same item (after collapsing it) are fast.


I solved performance issues with large trees by change the content provider to an ILazyTreeContentProvider. This won't help if you have to expand the full tree at once.

An alternative: Have a closer look at your content and label providers. Maybe their operations are too expensive and you can speed up things if you cache or pre-calculate some information for the tree. If, for example, you have a normal (non-lazy) content provider that loads the items from a database (one-by-one), expanding the tree will take forever...


Are you loading the model items in the UI thread? You should ideally load your model items in a non-UI thread and then update the tree with the items in the UI thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜