ActionCallback (boolean restoreExpandedPaths) { Runnable afterUpdate; final ActionCallback cb = new ActionCallback(); AbstractTreeBuilder builder = getTreeBuilder(); if (restoreExpandedPaths && builder != null) { List<Object> pathsToExpand = new ArrayList<>(); List<Object> selectionPaths = new ArrayList<>(); TreeBuilderUtil.storePaths(builder, (DefaultMutableTreeNode)myTree.getModel().getRoot(), pathsToExpand, selectionPaths, true); afterUpdate = () -> { if (myTree != null && !builder.isDisposed()) { myTree.clearSelection(); TreeBuilderUtil.restorePaths(builder, pathsToExpand, selectionPaths, true); } cb.setDone(); }; } else { afterUpdate = cb.createSetDoneRunnable(); } if (builder != null) { builder.addSubtreeToUpdate(builder.getRootNode(), afterUpdate); } else if (myAsyncSupport != null) { myAsyncSupport.updateAll(afterUpdate); } else { return ActionCallback.REJECTED; } return cb; }