void (int oldIndex, int newIndex, @NotNull Position position) { final List<TreePath> expandedPaths = TreeUtil.collectExpandedPaths(myActionsTree); TreePath path = myActionsTree.getPathForRow(oldIndex); TreePath targetPath = myActionsTree.getPathForRow(newIndex); if (Objects.equals(path.getParentPath(), targetPath.getParentPath()) && position != INTO) { ActionUrl url = CustomizationUtil.getActionUrl(path, MOVE); url.setInitialPosition(url.getAbsolutePosition()); int shift = position == ABOVE && oldIndex < newIndex ? -1: position == BELOW && oldIndex > newIndex ? 1 : 0; url.setAbsolutePosition(url.getInitialPosition() + newIndex - oldIndex + shift); changePathInActionsTree(myActionsTree, url); addCustomizedAction(url); } else { ActionUrl removeUrl = CustomizationUtil.getActionUrl(path, DELETED); changePathInActionsTree(myActionsTree, removeUrl); addCustomizedAction(removeUrl); ActionUrl addUrl = CustomizationUtil.getActionUrl(targetPath, ADDED); if (position == INTO) { addUrl.setAbsolutePosition(((DefaultMutableTreeNode)targetPath.getLastPathComponent()).getChildCount()); if (TreeUtil.getUserObject(targetPath.getLastPathComponent()) instanceof Group group) { addUrl.getGroupPath().add(group.getName()); } } addUrl.setComponent(removeUrl.getComponent()); changePathInActionsTree(myActionsTree, addUrl); addCustomizedAction(addUrl); } ((DefaultTreeModel)myActionsTree.getModel()).reload(); TreeUtil.restoreExpandedPaths(myActionsTree, expandedPaths); Object[] arr = Arrays.copyOf(targetPath.getParentPath().getPath(), targetPath.getPathCount()); arr[arr.length - 1] = path.getLastPathComponent(); TreePath pathToSelect = new TreePath(arr); TreeUtil.selectPath(myActionsTree, pathToSelect); TreeUtil.scrollToVisible(myActionsTree, path, false); }