@@ -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