我有点迷失,遇到以下问题。我正在使用一个扩展“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 overridedoCreateRefreshJob()
to expand all tree in case of empty string, or overrideupdateToolbar(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/