void (boolean restoreLastState) { List<String> expandedIds = toActionIDs(TreeUtil.collectExpandedPaths(myActionsTree)); List<String> selectedIds = toActionIDs(TreeUtil.collectSelectedPaths(myActionsTree)); DefaultMutableTreeNode root = (DefaultMutableTreeNode)myActionsTree.getModel().getRoot(); TreeUtil.treeNodeTraverser(root).traverse() .filter(node -> node instanceof DefaultMutableTreeNode && ((DefaultMutableTreeNode)node).getUserObject() instanceof Pair) .forEach(node -> doSetIcon(mySelectedSchema, (DefaultMutableTreeNode)node, null)); CustomActionsSchema source = restoreLastState ? CustomActionsSchema.getInstance() : new CustomActionsSchema(null); if (mySelectedSchema == null) mySelectedSchema = new CustomActionsSchema(null); mySelectedSchema.copyFrom(source); updateLocalSchema(mySelectedSchema); mySelectedSchema.initActionIcons(); patchActionsTreeCorrespondingToSchema(root); if (needExpandAll()) { new DefaultTreeExpander(myActionsTree).expandAll(); } else { TreeUtil.restoreExpandedPaths(myActionsTree, toTreePaths(root, expandedIds)); } TreeUtil.selectPaths(myActionsTree, toTreePaths(root, selectedIds)); TreeUtil.ensureSelection(myActionsTree); }