【问题标题】:JFace TreeViewer with initial expand on specific element types初始扩展特定元素类型的 JFace TreeViewer
【发布时间】:2017-02-20 01:11:05
【问题描述】:

我想将 TreeViewer 的一些元素设置为默认展开。 这可能吗?

【问题讨论】:

    标签: swt jface


    【解决方案1】:

    TreeViewer 提供了几种方法,您可以根据自己的要求使用:

    • setExpandedElements(..)
    • setExpandedState((..)
    • setExpandedTreePaths(..)
    • setAutoExpandLevel(..)

    【讨论】:

    • 嗨,我不能使用 setExpandedElements,因为此方法需要树中的具体实例对象,而我在编译时没有。此外,treePaths 是在运行时生成的,我在编译时无法访问它们。我需要类似 setExpandedElementsType(ClassName)
    • 这种方法不存在。我假设您可以在运行时访问模型?为什么不遍历模型中的每个对象,检查其类型,然后在适当的地方调用setExpandedState(..)?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多