Skip to content

Consistently sort Projects and Files view by path - #9629

Merged
jtulach merged 1 commit into
apache:masterfrom
jtulach:jtulach/ConsistentlySortByPath
Oct 5, 2026
Merged

jtulach merged 1 commit into
apache:masterfrom
jtulach:jtulach/ConsistentlySortByPath

Conversation

@jtulach

@jtulach jtulach commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

@jtulach jtulach self-assigned this Sep 21, 2026
@jtulach

jtulach commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorting by Display Name was a UI Bug

First and foremost let me state that the sorting by display name never really worked at scale. It might have worked for few opened projects at the beginning. While user sees them all (at least in collapsed state) then the ordering doesn't really matter.

However sorting projects of bigger sizes like Glassfish, Helidon or Maven always felt random to me. This randomness was even multiplied by the fact that display name was used for sorting, not a real folder name on disk. As such the order of projects in ls or in OS file explorer was different than the order in the IDE.

Sorting by display name might have worked well for demos in 2004 when two or three independent Ant projects were open, but it never helped anyone working on large, nested project structures of real Maven or Gradle projects that have become standard later. With such amount of projects the sorting felt like chaos.

Haven't you felt the same when using the NetBeans IDE with such large projects?

@jtulach

jtulach commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorting by Display Name as an API

Is the change of the sorting order of Project instances (in the Projects and Files views) an API change? If we accept that API is everything someone else code can depend on (e.g. the definition I like the most), then the answer is: Yes, it is an API change.

There might be someone building an application on top of NetBeans Platform using the ide cluster extensions. Such a developer might give the projects alphabetically sorted project names and yes, then the carefully crafted project order would have changed after #9602

I don't think such a scenario is likely, but if we wanted to support the old sorting in NetBeans Platform based applications, then a "branding API" (e.g. a key in Bundle.properties) would be an appropriate API, I guess.

@jtulach

jtulach commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorting by Name for Advanced Users

Just like in the "Sorting by Display Name as an API" case, it is possible that some of advanced NetBeans IDE users, might structure their projects and give them alphabetically sorted display names. Something like P1: Xyz, P2: Uvq, P3: Abc. That would sort by P1, P2, P3 prefixes consistently.

I find such scenario unlikely (I would never rename a project to sort well in my IDE myself), but if it was to be supported and there should be a way to turn such a display name sorting order on again, then these users would probably be fine with a -Dproperty to opt-out of the more reasonable projects by paths sorting order.

"LBL_NoneMainProject_Name=&None"
})
private void createSubMenu(Project[] projects) {
Arrays.sort(projects, OpenProjectList.projectByDisplayName());

@jtulach jtulach Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • while implementing b1f3e7d
  • I realized there are three places when ordering of projects is used
  • my expectation is: at all places the sorting order should be the same
  • e.g. whatever configuration option is offered, applies to all those places at once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, let me show an annecdoctical evidence of the randomness of the sorting by display name. Sometimes I am mixing projects from multiple repositories. Today I had projects from NetBeans own code base, as well as projects from GraalVM repository open. This is how it looks like in NetBeans 31:

Randomness in old NetBeans

It is easy to recognize what projects are coming from which repository as they have different icons. But the order! Because the projects are sorted by display name, those two independent sets of projects are intermixed with each other. The ordering is random, basically.

Today I decided to switch to the latest development version and voilá:

ordering by path

The ordering by path makes sense! First of all there is a group of projects from the GraalVM repository, then there is the group of projects from the NetBeans repository. There is no nesting in the hierarchy of those groups (that'd be subject of #9624 for example), but even the grouping by path is a tremendous step forward.

PS: I've been so shocked realizing how better the ordering is! I've just had to install the (already deleted) old NetBeans again to take the picture. As it speaks for thousand of words.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, let me show an annecdoctical evidence of the randomness of the sorting by display name

I believe seeing somewhere lazy/non-blocking init mechanisms where display names were used only when available. If its there it is used, if not it falls back to something else. I an imagine - if used for sorting - it can be placed at the wrong spot initially - until the full list is refreshed.

the group-by-project dropdown of the file list behaves similarly. If it can't list all projects fast enough it will display a simple list on very first open. Once the cached, it will properly group. NB has a lot of caching behind the scenes.

image

The ordering by path makes sense!

yes I agree. I thought about this and tested that already back when I looked at #9602 (comment)

Since it sorts by String path, it should produce pretty good results. (Path.compareTo() would have been slightly more dangerous - I remember the showstopper #6361 which was hard to debug since the cause was completely removed from the symptom (that one was about weird File instances - Path may be backed by different file systems))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing ... lazy/non-blocking init mechanisms where display names were used only when available.

@Chris2011

Copy link
Copy Markdown
Contributor

My 2 cents: somtimes I like to sort by project type so that I can see if I have a lot of open projects, what is PHP, Java, HTML etc.

@jtulach
jtulach force-pushed the jtulach/ConsistentlySortByPath branch from b1f3e7d to 1d5531c Compare September 24, 2026 09:20
@jtulach

jtulach commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

... sort by project type ...

  • understandable, but not completely easy and certainly out of scope of this PR, but:
  • do you store your projects in Git repositories?
  • if so, then in new NetBeans you'll get sorting and grouping by Git repository
  • assuming you have one repository for PHP, another one for Java EE, etc. your projects will be "grouped"

@jtulach

jtulach commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author
  • @mbien your review is needed as this PR takes different route than
  • your suggestion of "adding sorting options is definitely a good thing"

Is the Option Needed at All?

  • Who would be the user of such a sorting option? I was originally imagining few categories:
  • depending on the answer we can design the right way to flip the sorting switch
  • or just keep b1f3e7d and consistently use sorting by projects path

@jtulach

jtulach commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for your review, Sven. Integrating.

@jtulach
jtulach merged commit 8f97827 into apache:master Oct 5, 2026
29 checks passed
@mbien

mbien commented Oct 6, 2026

Copy link
Copy Markdown
Member

would be good to mention in the PR description where the sorting order will change. PRs are linked from release notes.

@mbien mbien added this to the NB32 milestone Oct 6, 2026
@mbien mbien added the UI User Interface label Oct 6, 2026
@jtulach jtulach changed the title Consistently sort projects by path Consistently sort Projects and Files view by path Oct 6, 2026
@mclaborn

Copy link
Copy Markdown

I know I'm late to the party, but here goes.

I like, and depend on, the sorting behavior in NB 31 where the projects are sorted by name. In my use case that makes sense and is perfectly logical. Since upgrading to NB 32 it takes me way too long to find the project that I need to work on next.

IMO a change with the potential for dramatic user impact should always be introduced as optional.


private static class ProjectByDisplayNameComparator implements Comparator<Project> {

private static final Comparator<Object> COLLATOR = Collator.getInstance();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • thank you @mclaborn for using NetBeans and for speaking up
    • your feedback is important as it is going to shape ...
    • ... what I will (have to) do for NetBeans 33+
  • can you share a screenshot of your projects?
    • how many of them is open?
    • are those just your own projects?
    • are you never opening 3rd party projects?
    • how comes this randomness doesn't bother you?
  • Which of these arguments apply/doesn't apply to your case?
  • Do you know you can search by typing, btw.?
    • just click the Projects view and type "snow"
    • your Snowboard project will be immediately selected
  • thank you in advance for helping us make future NetBeans versions better
  • btw. I am not replying to your comment but rather creating a separate thread where we can have a discussion focused on your case

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue @mclaborn opened at #9813 is probably a better place for ongoing discussion than a merged PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would you like my comments, here or in #9813 ?

@jtulach jtulach Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neil is right. The issue is a better place. I didn't notice the issue existence before asking here. The only worry I have is the "threaded discussion" won't be possible in the issue. But yes, please, answer there. Or even modify the issue description, with a text that answers my questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Project UI View UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants