Project View File Tree Follow
I'm developing custom project views that displays only project's files that correspond some condition: for example, containing some specific text/have some extension/etc. And for now I probably achieved filtering project's files, but also have run in a problem with sorting trees.
As I could see in default views, the files are firstly sorted by the predicate like if VirtualFile is a directory, and then by names. Such an example could be found in the official sdk samples (https://github.com/JetBrains/intellij-sdk-code-samples/blob/main/project_view_pane/src/main/java/org/intellij/sdk/view/pane/ImagesProjectNode.java) and as I could see, we perform sorting node's children looking up if some of them are directories.
However, repeating such an action didn't help me and I'm getting children in tree sorted only by name. Moreover, in debug mode I saw that even if I sort them like in the example, later children are re-sorted (in StructureTreeModel.java, getValidChildren method) with some comparator.
The comparator type is probably GroupByTypeComparator, and I haven't found any places when I could somehow affect re-sorting by concretizing any info from my class for such a comparator. Moreover, I haven't found any information about in docs.
I suppose that this problem could be solved easier that affecting that comporator - probably specifying some methods of my ProjectView implementation. Could you please give me some tips how could I achive similar file sorting to that I could see in default project views?
In addition: few words about my implementation of Project Views: its fully alike samples given in linked github page. Thats a pity that link, given on the corresponding readme for that extension, forwards to the page that doesn't contain any information about implementing Project Views at all (https://plugins.jetbrains.com/docs/intellij/project-view.html). Modifying Project View Structure page is helpful, but I consider that couldn't be used in my purpose because of it always filters files, but I need it only in some time segments.
Thank in advance for any help!
Please sign in to leave a comment.
As I've read, that was an major problem for IDEA based IDE in some versions. Especially I've found that firstly such a problem (or at least similar) was spotted in 2019.3 version of InellliJ IDEA.
Here is the link for it (https://youtrack.jetbrains.com/issue/IDEA-227802).
Currently Im running my plugin on 2020.3.1 and 2020.2 versions.
Idk if that's really linked issues but I am looking forward any help!
Could you please clarify what extension point you're currently using and/or which classes you're extending?
I'm using projectViewPane extension, and my classes are almost copypasted from this 2 (https://github.com/JetBrains/intellij-sdk-code-samples/tree/main/project_view_pane/src/main/java/org/intellij/sdk/view/pane). The only difference is that I use another method for getting and filtering all the files that I want to show in my panel.
Please try overriding com.intellij.ide.projectView.impl.AbstractProjectViewPane#createComparator and provide your custom implementation