java - 当filtertext为空时展开Jface FilteredTree上的所有项目

标签 java eclipse swt jface

我有点迷失,遇到以下问题。我正在使用一个扩展“org.eclipse.dialogs.FilterTree”的类。当过滤文本为空时,树中的每个节点都会折叠。但在这种情况下我想扩展树。

有人可以给个提示吗?最好的方法是什么?到目前为止,我已经重写了各种方法,但没有成功。

谢谢

最佳答案

您可以使用TreeViewer#expandAll()展开所有树

Edit 1:

The FilteredTree refreshes the tree on every change to the filter text control, but with some delay (by default 200ms). So adding a modify listener on text control for expanding all tree will at the time show a different set of items (maybe none) and later the refresh job will overwrite the state using its own rules. So either we need to override doCreateRefreshJob() to expand all tree in case of empty string, or override updateToolbar(boolean) which is always called at the end of the refresh job. this is what I tried and it worked:

FilteredTree ft = new FilteredTree(composite, SWT.FULL_SELECTION, p, true) {
    @Override
    protected void updateToolbar(boolean visible) {
        super.updateToolbar(visible);
        treeViewer.expandAll();
    }
};

关于java - 当filtertext为空时展开Jface FilteredTree上的所有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15069584/

相关文章:

c++ - 如何抑制第三方源文件中的警告?

java - 如何更改列表中特定项目的前景色?

java - 如何以垂直方式填充 TableViewer

java - 如何使用 SimpleMessageListenerContainer 禁用 RabbitMQ 预取计数

Java 使用 Apache Spark 指定架构从 json 文件读取

java - Java 和 Eclipse IDE 中的 UTF-8 和字符

eclipse - 从 Eclipse 中删除 git 存储库

java - 在现有的java项目中加载hibernate.cfg.xml

Java 实现了 webbrowser : does this save to browser cache,,你能直接提供内容吗?

java - 访问嵌套类中的全局变量