minor
defect
major
minor
minor
#29390
Subtree selection ends too early if the lowest level is not included in the level filter
The context menu command for selecting or deselecting a subtree in tree tables can be limited to a specific number oflevels. In addition, an optionallevel filter can be configured to determine which nodes count as separate levels: Below nodes that the filter does not accept, the selection should descend one more level without decrementing the level counter.
However, the level filter is ignored as soon as the level counter reaches 0: If the last level reached (levels == 0) is one that does not count according to the level filter, the selection will still not descend any further. As a result, fewer nodes are selected or deselected than configured.
The condition `levels > 0` in `com.top_logic.layout.table.tree.SelectSubtree.selectLevel(LayoutComponent, TreeSelectionModel<Object>, Object, int)` must be extended to include a check to determine whether the current level is counted at all.
Proposed solution:
private void selectLevel(LayoutComponent component, TreeSelectionModel<Object> treeSelection, Object directTarget,
int levels) {
if (_filter == null
|| _filter.apply(((TLTreeNode<?>) directTarget).getBusinessObject(), component.getModel())) {
treeSelection.setSelected(directTarget, select());
}
boolean countLevel = _levelFilter == null
|| _levelFilter.apply(((TLTreeNode<?>) directTarget).getBusinessObject(), component.getModel());
if (levels > 0 || !countLevel) {
int childLevels = countLevel ? levels - 1 : levels;
for (Object child : treeSelection.getTreeModel().getChildren(directTarget)) {
selectLevel(component, treeSelection, child, childLevels);
}
}
}