当我在TreeLayer中NatTable中折叠一行时,它的子行消失,其他行向上移动。
在NatTable 1.5.0中,展开/折叠图标与行一起向上移动。
在NatTable 1.6.0中,展开/折叠图标停留在原来的行索引中,它们的行过去都在这里。
我需要在1.6中做些额外的事情吗?例如,使树层从其ITreeRowModel更新?
编辑
这是这个问题的一个例子。当NatTable升级到1.6,而没有其他代码更改时,就会发生这种情况。

发布于 2019-11-06 09:31:21
不幸的是,这是一个没有被注意到的倒退。主要是因为大多数人似乎在GlazedLists中使用了GlazedLists。而且NatTable项目甚至没有一个没有GlazedLists的使用示例。
我已经创建了一张票证并修复了这个问题:https://bugs.eclipse.org/bugs/show_bug.cgi?id=552727
同时,您可以通过以下方式重写TreeLayer#getConfigLabelsByPosition(int, int)来解决这个问题:
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实现中缺少将原始行位置转换为索引的问题。
https://stackoverflow.com/questions/58702216
复制相似问题