mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-350091 Items disappear from list when using up/down actions
GitOrigin-RevId: 51c677dbdf232eb8a886d75369d650fb314b5674
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ef9234dfc4
commit
a730e33576
@@ -938,13 +938,17 @@ public final class TreeUtil {
|
||||
selectPath(tree, getPathFromRoot(node));
|
||||
}
|
||||
|
||||
public static void moveSelectedRow(final @NotNull JTree tree, final int direction){
|
||||
final TreePath selectionPath = tree.getSelectionPath();
|
||||
final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)selectionPath.getLastPathComponent();
|
||||
final DefaultMutableTreeNode parent = (DefaultMutableTreeNode)treeNode.getParent();
|
||||
final int idx = parent.getIndex(treeNode);
|
||||
((DefaultTreeModel)tree.getModel()).removeNodeFromParent(treeNode);
|
||||
((DefaultTreeModel)tree.getModel()).insertNodeInto(treeNode, parent, idx + direction);
|
||||
public static void moveSelectedRow(@NotNull JTree tree, int direction) {
|
||||
TreePath selectionPath = tree.getSelectionPath();
|
||||
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)selectionPath.getLastPathComponent();
|
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode)treeNode.getParent();
|
||||
int idx = parent.getIndex(treeNode);
|
||||
if (idx + direction < 0 || idx + direction >= parent.getChildCount()) {
|
||||
return;
|
||||
}
|
||||
DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
|
||||
model.removeNodeFromParent(treeNode);
|
||||
model.insertNodeInto(treeNode, parent, idx + direction);
|
||||
selectNode(tree, treeNode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user