void (@NotNull AnActionEvent e) { List<TreePath> expandedPaths = TreeUtil.collectExpandedPaths(myActionsTree); TreePath selectionPath = myActionsTree.getLeadSelectionPath(); int row = myActionsTree.getRowForPath(selectionPath); if (selectionPath != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)selectionPath.getLastPathComponent(); AddActionDialog dlg = new AddActionDialog(mySelectedSchema, isInsideMenu(selectionPath)); if (dlg.showAndGet()) { List<Object> addedActions = dlg.getAddedActions(); if (!addedActions.isEmpty()) { boolean isGroupSelected = CustomizationUtil.getGroupForNode(node) != null; for (int ind = 0; ind < addedActions.size(); ind++) { Object action = addedActions.get(ind); if (action instanceof Group group) { group.setForceShowAsPopup(true); } int newActionPosition = isGroupSelected ? node.getChildCount() : node.getParent().getIndex(node) + ind + 1; ActionUrl url = new ActionUrl(getGroupPath(new TreePath(node.getPath()), true), action, ADDED, newActionPosition); addCustomizedAction(url); DefaultMutableTreeNode newNode = addPathToActionsTree(myActionsTree, url); if (newNode != null && action instanceof String actionId) { String path = mySelectedSchema.getIconPath(actionId); if (path.isEmpty()) { path = actionId; } Icon icon = CustomActionsSchemaKt.getIconForPath(ActionManager.getInstance(), path); newNode.setUserObject(new Pair<>(actionId, icon)); } } ((DefaultTreeModel)myActionsTree.getModel()).reload(); TreeUtil.restoreExpandedPaths(myActionsTree, expandedPaths); if (isGroupSelected) myActionsTree.expandPath(selectionPath); int newSelectedRow = row + (isGroupSelected ? node.getChildCount() : addedActions.size()); myActionsTree.setSelectionRow(newSelectedRow); } } } }