Skip to content

Commit 196f71c

Browse files
committed
Overload method AbstractTreeViewer::internalConditionalExpandToLevel
1 parent 323f82d commit 196f71c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,10 +1846,22 @@ protected Widget internalGetWidgetToSelect(Object elementOrTreePath) {
18461846
* expand all levels of the tree
18471847
* @param shouldChildrenExpand predicate that defines for a given widget if it
18481848
* should be expanded.
1849-
* @since 3.32
1849+
* @since 3.36
18501850
*/
1851-
private void internalConditionalExpandToLevel(Widget widget, int level,
1851+
protected void internalConditionalExpandToLevel(Widget widget, int level,
18521852
Function<Widget, Boolean> shouldChildrenExpand) {
1853+
internalConditionalExpandToLevel(widget, level, __ -> Boolean.TRUE, shouldChildrenExpand);
1854+
}
1855+
1856+
/**
1857+
* Same as
1858+
* {@link #internalConditionalExpandToLevel(Widget, int, Function, Function)}i
1859+
*
1860+
* @param shouldWidgetExpand evaluates if the widget itself needs to be
1861+
* expanded.
1862+
*/
1863+
protected void internalConditionalExpandToLevel(Widget widget, int level,
1864+
Function<Widget, Boolean> shouldWidgetExpand, Function<Widget, Boolean> shouldChildrenExpand) {
18531865
if (level == ALL_LEVELS || level > 0) {
18541866
Object data = widget.getData();
18551867
if (widget instanceof Item it && data != null && !isExpandable(it, null, data)) {
@@ -1858,6 +1870,10 @@ private void internalConditionalExpandToLevel(Widget widget, int level,
18581870
createChildren(widget, false);
18591871
// XXX for performance widget should be expanded after expanding children:
18601872
if (widget instanceof Item it) {
1873+
if (!shouldWidgetExpand.apply(widget).booleanValue()) {
1874+
return;
1875+
}
1876+
18611877
setExpanded(it, true);
18621878
}
18631879
if (level == ALL_LEVELS || level > 1) {

0 commit comments

Comments
 (0)