JFace:扩展特定节点的更多级别

时间:2013-11-12 19:35:34

标签: java eclipse jface treeviewer treelistview

当用户在我的TreeViewer中扩展特定节点时,它应该扩展两个级别而不是一个级别。所以我添加了以下代码:

viewer.addTreeListener(new ITreeViewerListener() {
            public void treeCollapsed(TreeExpansionEvent event) {
            }

            public void treeExpanded(TreeExpansionEvent event) {
                if (event.getElement() instanceof Feature) {
                    Feature feature = (Feature) event.getElement();
                    viewer.expandToLevel(feature, 2);
                }
            }
        });

但扩展功能节点时我只收到此错误消息:

!MESSAGE Ignored reentrant call while viewer is busy. This is only logged once per viewer instance, but similar calls will still be ignored.
!STACK 0
java.lang.RuntimeException
    at org.eclipse.jface.viewers.ColumnViewer.checkBusy(ColumnViewer.java:781)
    at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1071)
...

任何想法我做错了或如何以另一种方式解决它?

干杯, 菲尔

1 个答案:

答案 0 :(得分:2)

您无法在侦听器中调用expandToLevel之类的查看方法,因为查看器已经在处理扩展,而不是设计为在执行此操作时处理另一个扩展。

您可以在Display.asyncExec方法中使用treeExpanded在展开当前广告完成后运行expandToLevel