void (final Direction direction) { CheckedTreeNode node = getSelectedNode(); if (node != null) { if (isMovingAvailable(node, direction)) { moveNode(node, direction); if (node.getUserObject() instanceof Tool tool) { ToolsGroup group = (ToolsGroup)(((CheckedTreeNode)node.getParent()).getUserObject()); moveElementInsideGroup(tool, group, direction); } TreePath path = new TreePath(node.getPath()); myTree.getSelectionModel().setSelectionPath(path); myTree.expandPath(path); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTree, true)); } } }