gpt4 book ai didi

eclipse - 有没有更好的方法来使用 ILazyTreeContentProvider 进行排序和过滤

转载 作者:行者123 更新时间:2023-12-04 18:54:01 25 4
gpt4 key购买 nike

显然,如果使用 ILazyTree(TreePath)ContentProvider TreeViewers 不支持排序和过滤.所以设置ViewerFiltersSorters/Comparators对您的 TreeView 没有任何好处。也许这与不了解所有元素有关,包括那些目前不可见的元素。

为了支持这一声明,这里是来自 org.eclipse.jface.viewers.TreeViewer 的 javadoc 摘录类(class):

If the content provider is an ILazyTreeContentProvider or an ILazyTreePathContentProvider, the underlying Tree must be created using the {@link SWT#VIRTUAL} style bit, the tree viewer will not support sorting or filtering, and hash lookup must be enabled by calling {@link #setUseHashlookup(boolean)}.



我目前看到的唯一解决方案是为已经订购的每个节点获取子节点。如果您需要动态排序,即能够在运行时以 desc 或 asc 顺序切换排序顺序,那么您需要为此提出自己的解决方案,例如在填充和更新子项时监视排序的 bool 标志。

您是否知道可能有更好的解决方案,也许涉及更多 jface API?

最佳答案

实际上,对于 VIRTUAL-TreeViewer 来说,排序是不可能的。您是否使用 IStructuredContentProvider或懒惰的,如 this thread 中所述:

You will have to do the sorting yourself (in your model).
The underlying assumption is that the elements might not even be in memory.



事可 change in e4 (来自 2009 年 6 月的这条消息):

IMHO the JFace Virtual Table and Tree implementation is not as good as the none virtual one - well I stay away from it and use it in none of my projects.

[...] its senseless to have virtual tables because from an UI-Design point of view it is senseless to show an user 10.000s of elements and even more important because the model stays resident in your memory showing big tables with JFace might eat up all your heapspace
(We hope to come up with a redesigned set of Viewers in E4 who fix such problems).
See this project and bug 260451.
(more genral bugs: 167436 and 262160)



马上:

we are creating a strong reference in the viewer after the table requested it.

IMHO its much better to give the user: - paging - intelligent filtering possibilities

instead of showing million of results and then e.g. in case of CDO (Connected Data Objects) the filtering happens on the server using their new query-API.

关于eclipse - 有没有更好的方法来使用 ILazyTreeContentProvider 进行排序和过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1803021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com