From f012eaef47a700d8ba8ac2e372fee1e590a4575b Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 12 Jun 2021 23:29:09 +0100 Subject: [PATCH] fix focus on uploaded file in tree view --- .../views/com/muwire/gui/MainFrameView.groovy | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 2ce90e5b..01d540df 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -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)