@@ -96,6 +96,29 @@ abstract class ExplorerTreeView<Connection: ConnectionConfigBase, U : WorkingSet
9696
9797 private var treeModel: AsyncTreeModel
9898
99+ /* *
100+ * Function is called when onFetchCancelled event has been raised.
101+ * It searches for nodes by provided @param Query, looks through the tree and collects
102+ * TreePath objects on Promise resolution. For every found TreePath collapses this path
103+ * @param query - query on which 'fetch cancelled' event has been occurred
104+ */
105+ private fun collapseNodesByQuery (query : Query <* , * >) {
106+ // Collapse only those nodes for which TreePath has been resolved.
107+ // If tree path cannot be resolved as the result of Promise resolution,
108+ // it means that node does not present in the tree model anymore
109+ myFsTreeStructure.findByPredicate { it is FetchNode && it.query == query }
110+ .mapNotNull { myStructure.promisePath(it, myTree).get() }
111+ .forEach { foundTreePath ->
112+ treeModel.onValidThread {
113+ myTree.collapsePath(foundTreePath)
114+ synchronized(myNodesToInvalidateOnExpand) {
115+ val node = foundTreePath.lastPathComponent
116+ myNodesToInvalidateOnExpand.add(node)
117+ }
118+ }
119+ }
120+ }
121+
99122 /* *
100123 * Get node by provided query and invalidate them. The nodes will be either collapsed or invalidated on this action, basing on the provided parameters
101124 * @param query the query to search nodes by
@@ -326,7 +349,7 @@ abstract class ExplorerTreeView<Connection: ConnectionConfigBase, U : WorkingSet
326349 }
327350
328351 override fun <R : Any , Q : Query <R , Unit >> onFetchCancelled (query : Q ) {
329- getNodesByQueryAndInvalidate (query, collapse = true , invalidate = false )
352+ collapseNodesByQuery (query)
330353 }
331354
332355 override fun <R : Any , Q : Query <R , Unit >> onFetchFailure (query : Q , throwable : Throwable ) {
0 commit comments