mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
'Project Structure' dialog: fix moving module node to a group node if it was initially located directly the tree root
This commit is contained in:
+23
-25
@@ -650,34 +650,32 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
@Override
|
||||
protected void reloadNode(DefaultTreeModel treeModel) {
|
||||
TreeNode parent = getParent();
|
||||
if (parent instanceof ModuleGroupNode) {
|
||||
List<String> actualPath = ((ModuleGroupNode)parent).myModuleGroup.getGroupPathList();
|
||||
List<String> expectedPath = myGrouper.getGroupPath(getModule());
|
||||
if (!actualPath.equals(expectedPath)) {
|
||||
TreePath path = myTree.getSelectionPath();
|
||||
boolean wasSelected = path != null && this.equals(path.getLastPathComponent());
|
||||
boolean autoScrollWasEnabled = myAutoScrollEnabled;
|
||||
try {
|
||||
myAutoScrollEnabled = false;
|
||||
MyNode newParent = getOrCreateModuleGroupNode(expectedPath, treeModel);
|
||||
treeModel.removeNodeFromParent(this);
|
||||
while (parent instanceof ModuleGroupNode && parent.getChildCount() == 0) {
|
||||
TreeNode grandParent = parent.getParent();
|
||||
treeModel.removeNodeFromParent((MutableTreeNode)parent);
|
||||
parent = grandParent;
|
||||
}
|
||||
List<String> actualPath = parent instanceof ModuleGroupNode ? ((ModuleGroupNode)parent).myModuleGroup.getGroupPathList() : Collections.emptyList();
|
||||
List<String> expectedPath = myGrouper.getGroupPath(getModule());
|
||||
if (!actualPath.equals(expectedPath)) {
|
||||
TreePath path = myTree.getSelectionPath();
|
||||
boolean wasSelected = path != null && this.equals(path.getLastPathComponent());
|
||||
boolean autoScrollWasEnabled = myAutoScrollEnabled;
|
||||
try {
|
||||
myAutoScrollEnabled = false;
|
||||
MyNode newParent = getOrCreateModuleGroupNode(expectedPath, treeModel);
|
||||
treeModel.removeNodeFromParent(this);
|
||||
while (parent instanceof ModuleGroupNode && parent.getChildCount() == 0) {
|
||||
TreeNode grandParent = parent.getParent();
|
||||
treeModel.removeNodeFromParent((MutableTreeNode)parent);
|
||||
parent = grandParent;
|
||||
}
|
||||
|
||||
newParent.add(this);
|
||||
treeModel.nodesWereInserted(newParent, new int[] {newParent.getChildCount()-1});
|
||||
if (wasSelected) {
|
||||
myTree.expandPath(TreeUtil.getPath(myRoot, newParent));
|
||||
myTree.setSelectionPath(TreeUtil.getPath(myRoot, this));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myAutoScrollEnabled = autoScrollWasEnabled;
|
||||
newParent.add(this);
|
||||
treeModel.nodesWereInserted(newParent, new int[] {newParent.getChildCount()-1});
|
||||
if (wasSelected) {
|
||||
myTree.expandPath(TreeUtil.getPath(myRoot, newParent));
|
||||
myTree.setSelectionPath(TreeUtil.getPath(myRoot, this));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myAutoScrollEnabled = autoScrollWasEnabled;
|
||||
}
|
||||
}
|
||||
super.reloadNode(treeModel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user