Sorting of custom AbstractTreeNodes

Answered

Hello,

I have had this problem for a while, but my custom AbstractTreeNodes are not sorted properly in Project view. If I do not override getWeight(), it uses a weight of 30, and my custom nodes are below the non-custom node file nodes. If I set it to twenty, which I believe is the standard number for psi files, files are sorted in a way I cannot figure out.

The files are in three runs of alphabetical order. The files in each section are consistent (They do not change between restarts), but I cannot figure out why some are a-z(1) others are a-z(2) and others are a-z(3). The files in each section are of similar file types, and have some upper and some lowercase names, and some are directories. Here is an example image:

 

As you can see, the files in the screen shot go E,F,G,I,E,G,I. I can not figure out what is happening.

The files are properly sorted in Project Files view.

If I override getWeight() and return 21, the folders and non-custom nodes are properly sorted, and then my custom nodes are properly sorted beneath that.

Is there another method I should override or another value to set?

0
2 comments
Avatar
Permanently deleted user

Hi Dan,
Could you please show your sort settings? 

If the Folders Always on Top is set the ProjectViewNode#getTypeSortWeight is used to sort nodes. The sorting mechanism is rather complicated: `GroupByTypeComparator#compare(NodeDescriptor, NodeDescriptor)`

0

Ah, thank you so much! It totally worked. I had extended from abstract node not ProjectViewNode originally. So I extended project view node, and copied the body from PsiFileNode, and everything is now sorted proper.

Thank you again!

0

Please sign in to leave a comment.