首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NatTable 1.6 - TreeLayer -展开/折叠三角形在折叠上面的一行后不跟随它们的行

问NatTable 1.6 - TreeLayer -展开/折叠三角形在折叠上面的一行后不跟随它们的行
EN

Stack Overflow用户
提问于 2019-11-04 22:54:54
回答 1查看 147关注 0票数 0

当我在TreeLayer中NatTable中折叠一行时,它的子行消失,其他行向上移动。

在NatTable 1.5.0中,展开/折叠图标与行一起向上移动。

在NatTable 1.6.0中,展开/折叠图标停留在原来的行索引中,它们的行过去都在这里。

我需要在1.6中做些额外的事情吗?例如,使树层从其ITreeRowModel更新?

编辑

这是这个问题的一个例子。当NatTable升级到1.6,而没有其他代码更改时,就会发生这种情况。

​

​

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-06 09:31:21

不幸的是,这是一个没有被注意到的倒退。主要是因为大多数人似乎在GlazedLists中使用了GlazedLists。而且NatTable项目甚至没有一个没有GlazedLists的使用示例。

我已经创建了一张票证并修复了这个问题:https://bugs.eclipse.org/bugs/show_bug.cgi?id=552727

同时,您可以通过以下方式重写TreeLayer#getConfigLabelsByPosition(int, int)来解决这个问题:

代码语言:javascript
复制
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack configLabels = super.getConfigLabelsByPosition(columnPosition, rowPosition);

    if (isTreeColumn(columnPosition)) {
        configLabels.addLabelOnTop(TREE_COLUMN_CELL);

        ILayerCell cell = getCellByPosition(columnPosition, rowPosition);
        if (cell != null) {
            int rowIndex = getRowIndexByPosition(cell.getOriginRowPosition());
            configLabels.addLabelOnTop(
                    DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + this.treeRowModel.depth(rowIndex));
            if (!this.treeRowModel.hasChildren(rowIndex)) {
                configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_LEAF_CONFIG_TYPE);
            } else {
                if (this.treeRowModel.isCollapsed(rowIndex)) {
                    configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE);
                } else {
                    configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE);
                }
            }
        }
    }
    return configLabels;
}

主要问题是在1.6实现中缺少将原始行位置转换为索引的问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58702216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档