private void selectInTree(VirtualFile[] array, boolean requestFocus, boolean updatePathNeeded) { myTreeIsUpdating = true; final List<VirtualFile> fileList = Arrays.asList(array); if (!Arrays.asList(myFileSystemTree.getSelectedFiles()).containsAll(fileList)) { myFileSystemTree.select( array, () -> { if (!myFileSystemTree.areHiddensShown() && !Arrays.asList(myFileSystemTree.getSelectedFiles()).containsAll(fileList)) { // try to select files in hidden folders myFileSystemTree.showHiddens(true); selectInTree(array, requestFocus, updatePathNeeded); return; } if (array.length == 1 && !Arrays.asList(myFileSystemTree.getSelectedFiles()).containsAll(fileList)) { // try to select a parent of a missed file VirtualFile parent = array[0].getParent(); if (parent != null && parent.isValid()) { selectInTree(new VirtualFile[] {parent}, requestFocus, updatePathNeeded); return; } } reportFileNotFound(); if (updatePathNeeded) { updatePathFromTree(fileList, true); } if (requestFocus) { //noinspection SSBasedInspection SwingUtilities.invokeLater(() -> myFileSystemTree.getTree().requestFocus()); } }); } else { reportFileNotFound(); if (updatePathNeeded) { updatePathFromTree(fileList, true); } } }