Jface的CheckboxTreeViewer如何设置初始选择
这个问题听起来可能微不足道,但我正在努力解决这个问题,所以,如果可以的话,请提供帮助。所以,这就是:出于一些充分的原因,我使用 CheckboxTreeViewer
。我已经在 google-it 上搜索了一些类的用法,目前我可以检查/取消选中所选节点的所有子节点,并在使用 StyledCellLabelProvider
的自定义实现进行实时搜索后保留选择> 提供商。到目前为止一切都很好。但是,到目前为止,在显示小部件并调用查看器的 setInput() 方法后,我无法以编程方式选择树查看器的一个或多个元素。
因此,我们假设树有 10 个主节点,节点 6 上有 5 个叶子节点。我的问题是如何设置第三个叶子节点的检查状态?
感谢你。
This question may sounds trivial, but i am struggling with the issue, so, please help if u can. So, here it is : i am using a CheckboxTreeViewer
for some good reasons. I've google-it for some class usages, and i am currently able to check/uncheck all the childrens of a selected node, and to preserve the selection after a live search with a custom implementation of the StyledCellLabelProvider
provider. All good so far. However, so far i am unable to programatically select one or more elements of the tree viewer after i display the widget and call the setInput()
method of the viewer.
So, let's assume for instance that the tree will have 10 main nodes, and 5 leafs on node 6. My question is how do i set the checked state of the 3rd leaf?
Thank u.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该为树查看器使用 ICheckedStateProvider。例如:
You should be using an ICheckedStateProvider for the tree viewer. For instance:
看看这个:http://akravets.blogspot。 com/2009/08/disabling-nodes-in-checkboxtreeviewer.html,可能会有所帮助。它可能不是您正在寻找的 100% 解决方案,但我解释了如何跳过一些节点。
Take a look at this: http://akravets.blogspot.com/2009/08/disabling-nodes-in-checkboxtreeviewer.html, might be of some help. It might not be 100% solution to what you are looking for, but I explain how to skip some nodes.