This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 230821 - Sorting with type for files in folders does not work properly
Summary: Sorting with type for files in folders does not work properly
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 7.2.1
Hardware: PC Windows 7
: P3 normal with 3 votes (vote)
Assignee: Jaroslav Havlin
URL:
Keywords: API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2013-06-06 08:04 UTC by darrshan
Modified: 2014-01-02 18:47 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed Patch (6.83 KB, patch)
2013-10-10 14:09 UTC, Jaroslav Havlin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description darrshan 2013-06-06 08:04:51 UTC
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
Comment 1 darrshan 2013-06-06 08:24:52 UTC
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
Comment 2 Jan Peska 2013-06-24 10:00:01 UTC
Thanks for reporting and fine evaluation. Reassigning to Data Systems.
Comment 3 Jaroslav Havlin 2013-10-10 14:09:33 UTC
Created attachment 140980 [details]
Proposed Patch
Comment 4 Jaroslav Havlin 2013-10-10 14:21:58 UTC
(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

Thank you.
Comment 5 Jaroslav Havlin 2013-10-21 07:24:52 UTC
If there are no objections, I'll integrate the patch tomorrow.
Thank you for reviewing.
Comment 6 Jaroslav Havlin 2013-10-22 07:32:57 UTC
http://hg.netbeans.org/core-main/rev/48f8fd2feef0