微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何在没有 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 举报,一经查实,本站将立刻删除。