fix focus on uploaded file in tree view

pull/62/head
Zlatin Balevsky 2021-06-12 23:29:09 +01:00
parent d3cfcef063
commit f012eaef47
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 20 additions and 3 deletions

View File

@ -1467,9 +1467,26 @@ class MainFrameView {
def node = model.fileToNode.get(sf)
if (node == null)
return
def path = new TreePath(node.getPath())
tree.setSelectionPath(path)
tree.scrollPathToVisible(path)
Object[] path = node.getUserObjectPath()
DefaultMutableTreeNode otherNode = model.treeRoot
for (int i = 1; i < path.length; i++) {
Object o = path[i]
DefaultMutableTreeNode next = null
for (int j = 0; j < otherNode.childCount; j++) {
if (otherNode.getChildAt(j).getUserObject() == o) {
next = otherNode.getChildAt(j)
break
}
}
if (next == null)
return // probably filtered from view
otherNode = next
}
def otherPath = new TreePath(otherNode.getPath())
tree.setSelectionPath(otherPath)
tree.scrollPathToVisible(otherPath)
} else {
def table = builder.getVariable("shared-files-table")
int row = model.shared.indexOf(sf)