Skip to content

Control indentation of nested projects by UIManager properties - #9627

Merged
jtulach merged 1 commit into
apache:masterfrom
jtulach:jtulach/UIManagerForNestedProjects
Sep 29, 2026
Merged

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

Conversation

@jtulach

@jtulach jtulach commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

@jtulach jtulach self-assigned this Sep 18, 2026
@jtulach jtulach added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Project UI View labels Sep 18, 2026
@jtulach
jtulach force-pushed the jtulach/UIManagerForNestedProjects branch from c5e2b01 to 9f6fb94 Compare September 18, 2026 06:42
Comment thread ide/projectui/src/org/netbeans/modules/project/ui/ProjectsLaF.java Outdated
Comment thread ide/projectui/src/org/netbeans/modules/project/ui/ProjectsLaF.java Outdated
Comment thread ide/projectui/src/org/netbeans/modules/project/ui/ProjectsLaF.java Outdated

@neilcsmith-net neilcsmith-net 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.

Thanks! Looks good on reading. Not tested yet. Probably needs squashing before merge.

Handles my concerns about customization / disabling the display. I still think the node prefixing approach is flawed against filtering the hierarchy, but if everyone else is on the board with the current approach then this is good to go.

Please don't merge this until @mbien has followed up here or on the sorting review though, just in case that gets complicated in master.

@mbien mbien added this to the NB32 milestone Sep 21, 2026
@mbien

mbien commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

tested:

# no indentation (use quotes otherwise it is null)
nb.project.indentation=""

# friendship mode worked too
nb.project.indentation="♥ "

while testing I was wondering if we should split it into three properties: prefix, repeat and postfix?

e.g a user could customize it like:

image

added bonus is that even without using a prefix, this can produce very compact indentation since there is no need to add whitespace to the arrow. The whitespace can be in the postfix.

nb.project.indentation.prefix=""
nb.project.indentation.repeat="»"
nb.project.indentation.postfix=" "
image

pipleline symbols:

nb.project.indentation.prefix="└"
nb.project.indentation.repeat="─"
nb.project.indentation.postfix=" "
image

dark theme / expanded:

image

dots with space in repeat (just like with the arrow now):

nb.project.indentation.prefix=""
nb.project.indentation.repeat="• "
nb.project.indentation.postfix=""
image

pacman would work too but my font doesn't support that symbol :(
pacman

code ( + formatted using 4 spaces):

Details
    static String indentationPrefix(boolean html, int depth) {
        String prefix = UIManager.getString("nb.project.indentation.prefix"); // NOI18N
        if (prefix == null) {
            prefix = "";
        }
        String repeat = UIManager.getString("nb.project.indentation.repeat"); // NOI18N
        if (repeat == null) {
            repeat = "\u00bb";
        }
        String postfix = UIManager.getString("nb.project.indentation.postfix"); // NOI18N
        if (postfix == null) {
            postfix = " ";
        }
        if (depth <= 0 || (prefix.isEmpty() && repeat.isEmpty() && postfix.isEmpty())) {
            return "";
        }
        if (html) {
            try {
                String xml = XMLUtil.toElementContent(prefix + repeat.repeat(depth) + postfix);
                return "<font color='!controlShadow'>" + xml + "</font>";
            } catch (CharConversionException ex) {
                throw new IllegalStateException(ex);
            }
        } else {
            return prefix + repeat.repeat(depth) + postfix;
        }
    }

just an idea - is this too much flexibility?

@neilcsmith-net

Copy link
Copy Markdown
Member

just an idea - is this too much flexibility?

I'm tempted to say, yes too much, except that pipeline example does look quite nice!

I'm curious where the null is coming from for the empty String. FlatLaf issue?

@mbien

mbien commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

I'm curious where the null is coming from for the empty String. FlatLaf issue?

likely. Something seems to equate "" with null during parsing. Plain old properties don't do that usually.

I'm tempted to say, yes too much, except that pipeline example does look quite nice!

yeah I like that one too. The reason I experimented with this is because it looked like the symbol+space pattern appears to be fairly limiting in what symbols you can use. Sometimes you want to repeat a symbol and postfix a space, other times you want to repeat the space and add a symbol at the end - or use different symbols like in that pipeline.

@neilcsmith-net

Copy link
Copy Markdown
Member

Something seems to equate "" with null during parsing. Plain old properties don't do that usually.

Yes, I know. I was surprised reading that as I thought that was how we'd tell people to switch it off. Still, as long as we know, we can explain.

At a guess it's due to the code at https://github.com/JFormDesigner/FlatLaf/blob/e735c4898e6772c734229c688976faceab1bdfc8/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java#L461 Makes sense given the values are typed I suppose, or maybe intended to allow override removal.

@jtulach

jtulach commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Yeah, the pipeline symbol looks pretty nice:

nb.project.indentation.prefix="└"
nb.project.indentation.repeat="─"
nb.project.indentation.postfix=" "
image image

I don't mind changing the algorithm to use prefix, repeat and postfix UI manager keys. Done in bb682d9

@mbien mbien added the UI User Interface label Sep 23, 2026

@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.

code looks good to me and it works. Maybe wait a little more before integration since the impl changed after PR was already approved to give a chance for replies.

(+ don't forget to squash)

@jtulach

jtulach commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

code looks good to me and it works.

  • yeah, it should work
    • it is your code (slightly modified)
    • there are tests
  • but real verification is always nice

... wait ... before integration since the impl

Yeah, that's a good idea. Re-requested @neilcsmith-net and @MartinBalin reviews.

(+ don't forget to squash)

I'll do my best to not forget about it. Or should I optimistically pre-squash before getting the new round of reviews? Squashed into 5b05d8f

@mbien

mbien commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Or should I optimistically pre-squash before getting the new round of reviews?

sure, feel free to do that. There is also the pre-integration checklist on the default PR template with 4 checkboxes to press before merge but few are using it (which is fine).

@jtulach
jtulach force-pushed the jtulach/UIManagerForNestedProjects branch from bb682d9 to 5b05d8f Compare September 24, 2026 14:01
@jtulach

jtulach commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Squashed. Ready to merge. Can I merge, @neilcsmith-net?

@neilcsmith-net neilcsmith-net 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.

Still looks good to me. Bit more complex, but @mbien example showed the value of it. Slight nitpick on the docs.

Comment thread ide/projectui/arch.xml Outdated
</p>
<p>
There is a support for indenting nested projects since
<a href="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/apache/netbeans/pull/9627">PR-9627</a> which can be controlled by two <code>UIManager</code>

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 : there was one, then three, never two! 😄

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.

Good catch. Using "these" since 79df714

@jtulach
jtulach force-pushed the jtulach/UIManagerForNestedProjects branch from 5b05d8f to 79df714 Compare September 29, 2026 04:19
@jtulach
jtulach merged commit 83952aa into apache:master Sep 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Project UI View UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants