Skip to content

Show nested projects co-located and indented - #9602

Open
jtulach wants to merge 3 commits into
apache:masterfrom
jtulach:jtulach/NestedProjectsNextToEachOther
Open

Show nested projects co-located and indented#9602
jtulach wants to merge 3 commits into
apache:masterfrom
jtulach:jtulach/NestedProjectsNextToEachOther

Conversation

@jtulach

@jtulach jtulach commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
  • this PR is implementation of @mbien's idea
    • sorting of project is changed so nested projects are co-located next to each other
  • however just co-locating isn't enough to express which project is nested to each
    • as such we also indent nested projects
    • that gives the user a clue of the project relations
  • while it keeps the overall presentation unchanged
    • except indentation and different sorting the project view behavior remains the same
  • no API changes in the Project API are needed
    • that's very encouraging
  • one small API change was needed to reuse NodeRenderer and control its (already existing and used in ChoiceView) indentation support
  • write some unit tests
  • verify indentation is updated when project list is changed
  • make it fast (e.g. avoid too frequent traversal)
Maven 4 Projects with Indentation

@svenreimers

Copy link
Copy Markdown
Member

Awesome!

@mbien mbien added Platform [ci] enable platform tests (platform/*) UI User Interface ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Sep 4, 2026
@apache apache locked and limited conversation to collaborators Sep 4, 2026
@apache apache unlocked this conversation Sep 4, 2026
@jtulach
jtulach requested a review from struberg September 5, 2026 02:12

@mbien mbien left a comment

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.

I think this has potential. Since this is solved via UI, it avoids many issues e.g having to think about how to represent open/closed projects in trees etc - it builds on top of the existing logic, project groups etc.

It does also automatically work for gradle too:

Image

Visually it will likely need some tweaks since it moves the expand/collapse control away from the icon (visible only deeper in the tree). Comparison (right is NB 31): Image

indentation amount could also become a UI property so that it can be easier themed - but this could be done in followups.

Comment on lines +430 to +434
var node = Visualizer.findNode(vis);
while (node != null) {
if (node instanceof ProjectsRootNode.BadgingNode) {
var badge = (ProjectsRootNode.BadgingNode) node;
return badge.pair.depth;

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.

nitpick: we could bump the language level to 21 to use the instanceof pattern.

                if (node instanceof ProjectsRootNode.BadgingNode badge) {
                    return badge.pair.depth;
                }

pet peeve: I am personally not a fan of using var everywhere since it obfuscates code and is in many cases not necessary when the type is already concise. But I am not going to argue against it, its more about code style and mostly non technical.

Its just a bit unfortunate that the trend of overusing var made IDEs render the type next to it which entirely defeated the purpose of it in the first place since it now uses more space than before and breaks formatting:

Image

but that is just my "pet peeve" - feel free to ignore it ;)

@JaroslavTulach JaroslavTulach Sep 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • yes, I wanted to use instanceof pattern too
  • I've noticed the NetBeans IDE support of var is pretty poor
    • for example move refactoring replaces var with FQN types!?
      • I hope I fix it one day.
    • probably a result of this kind of attitude towards var
  • I don't share such attitude
    • For last for years I was coding in languages where it is enough to write x = 3.14
    • even var is too verbose for my taste
  • I prefer use of var in my code over needless verbosity of specifying the type at each assignment

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.

I've noticed the NetBeans IDE support of var is pretty poor (...) or example move refactoring (...) probably a result of this kind of attitude towards var

facepalm. Not sure what to say to statements like this.

For last for years I was coding in languages where it is enough to write x = 3.14

DSLs are great for their domains. That is why there are so many languages.

But it is OK to disagree. As I said I am not going to block anything based on style.

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.

Yes, we've had lots of fixes for var, and another one just one my radar to look at. We did talk about blocking use of var at one point in style guidelines for the IDE code, but I think we ended up with a general feeling of making sure it's legible. Personally I think that's a judgement call based on making sure type information is easily understandable from reading text in the vicinity without requiring IDE annotations - eg. assignments with new may be OK whereas assignments from method calls may not.

Comment on lines 193 to +194
if (list.getModel() instanceof NodeListModel && (((NodeListModel) list.getModel()).getDepth() > 1)) {
int indent = iconWidth * NodeListModel.findVisualizerDepth(list.getModel(), vis);
int indent = iconWidth * findIndent(list.getModel(), vis);

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.

nit: instanceof pattern would clean this up too

Comment on lines +213 to +214
if (model instanceof ListModel) {
return NodeListModel.findVisualizerDepth((ListModel) model, visualizer);

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.

nit: instanceof pattern

if (p2 == null) {
return 1;
}
return p1.getProjectDirectory().getPath().compareTo(p2.getProjectDirectory().getPath());

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.

Alphabetical String comparison with paths seems to be indeed working well for this. My instinct told me that this will probably break with edge cases but it is always making sure that parent dir ends up before child dir. This is good for this purpose (I think) and also fast.

Path comparison has the limitation that the projects do actually have to be a tree structure on disk since it shows the filesystem hierarchy, not the actual project parent which could be anywhere. It correlates location with relationship between projects. This might be fine still - curious what others think.

@JaroslavTulach JaroslavTulach Sep 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

projects do actually have to be a tree structure on disk

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.

and we decided we rather keep it simple

Decided?? I think both approaches have pros and cons right now. This simpler approach might be the better one, and the least intrusive, but having the view not end up reflecting the underlying model might end up causing issues down the line.

@neilcsmith-net

Copy link
Copy Markdown
Member

I think this has potential. Since this is solved via UI, it avoids many issues e.g having to think about how to represent open/closed projects in trees etc - it builds on top of the existing logic, project groups etc.

+1

Visually it will likely need some tweaks since it moves the expand/collapse control away from the icon (visible only deeper in the tree)

This is my concern too, but it's more than just "visual" in the sense that it affects also where you can click to control expansion. We'll end up with a tree UI that diverges more and more from the underlying model. That might start to get "interesting".

The other UI thought that comes to mind with this is the potential to change the root of the project tree to just one project / subproject, with a breadcrumb bar (similar to eg. the GNOME file browser in list mode when tree expansion is enabled).

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

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Platform [ci] enable platform tests (platform/*) Project UI View UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants