@@ -1850,6 +1850,19 @@ protected Widget internalGetWidgetToSelect(Object elementOrTreePath) {
18501850 */
18511851 private 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+ * @since 3.36
1863+ */
1864+ protected void internalConditionalExpandToLevel (Widget widget , int level ,
1865+ Function <Widget , Boolean > shouldWidgetExpand , Function <Widget , Boolean > shouldChildrenExpand ) {
18531866 if (level == ALL_LEVELS || level > 0 ) {
18541867 Object data = widget .getData ();
18551868 if (widget instanceof Item it && data != null && !isExpandable (it , null , data )) {
@@ -1858,6 +1871,10 @@ private void internalConditionalExpandToLevel(Widget widget, int level,
18581871 createChildren (widget , false );
18591872 // XXX for performance widget should be expanded after expanding children:
18601873 if (widget instanceof Item it ) {
1874+ if (!shouldWidgetExpand .apply (widget ).booleanValue ()) {
1875+ return ;
1876+ }
1877+
18611878 setExpanded (it , true );
18621879 }
18631880 if (level == ALL_LEVELS || level > 1 ) {
0 commit comments