Product Version = NetBeans IDE 7.3 (Build 201302132200)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.6.0_26
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.1-b02
I tried to use the sorting option available for flies listed on a node/folder.
If I use sort using "type" it does not work correctly.
I looked upon the logic in FolderComparator class in org.openide.loaders module.
There "compareClass" method is called to sort based on type.
Say we have .java files, .properties files and .xml files in folder.
Inside the "compareClass" method the "compareNames" method is called which compares file objects names with extensions. Because the name is also considered the files are sorted based on the name rather than on its extension. Hence the incorrect result.
I think calling the "compareNames" is incorrect. Rather a new method should be written to compare the extensions and then if the extensions are the same , "NameExt" comparison should be made
Thanks for reporting and fine evaluation. Reassigning to Data Systems.
Created attachment 140980 [details]
(In reply to darrshan from comment #1)
> I think calling the "compareNames" is incorrect. Rather a new method should
> be written to compare the extensions and then if the extensions are the same
> , "NameExt" comparison should be made
We cannot change the method for backward compatibility.
It was designed to compare the objects by class, so we cannot modify it.
But I think its display name should be changed to "By Class".
For sorting by file extension, we should introduce new sort mode.
Please review the attached patch.
New public field: org.openide.loaders.DataFolder.SortMode.EXTENSIONS
If there are no objections, I'll integrate the patch tomorrow.
Thank you for reviewing.