如何在没有 UI 事件 ITreeContentProvider 的情况下调用 getChildren()?

问题描述

    @Override
    public Object[] getChildren(Object parentElement) {
        if (parentElement instanceof List) {
            List<?> arraysList = ((List<?>) parentElement).stream()
                    .filter(p -> p instanceof List && !((List<?>) p).isEmpty()).collect(Collectors.toList());
            datas = arraysList.toArray();
            return arraysList.toArray();
        }
        return null;
    }

getChildren() 方法用户尝试展开子节点时被调用并填充子节点数据。如果我尝试在调用 getChildren() 之前以编程方式扩展子节点,它会显示这样的树。那么有什么想法可以初始化子节点或以编程方式调用 getChildren() 吗?

当我调用 item.setExpanded(true) 来展开子节点及其显示

enter image description here

enter image description here

但是如果我从 UI 展开 1-9 节点中的任何一个,它将调用 getChildren() 方法并填充该特定节点的子数据,例如:我在这里和下次单击 searchAction 时扩展节点 4 (item.setExpanded(true)) 它显示 4 的子节点只是因为它在我从 UI 展开时设置数据我需要为所有节点设置子节点数据

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)