Non-closable TopComponent still closable via middle-click button
Apache NetBeans version
Apache NetBeans 25
What happened
A (non-editor) TopComponent with client property TopComponent.PROP_CLOSING_DISABLED=true is displayed as a tab with no close button and no close menu entry. This is OK.
But actually it is still closable via mouse middle-click on the tab.
Language / Project Type / NetBeans Component
Netbeans platform application
How to reproduce
Add a TopComponent to a NB platform app.
Add putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); in constructor.
Run, middle-click tab name (possibly several times), TopComponent is closed.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Win 11
JDK
Adoptium 23
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
It seems problem comes from: https://github.com/apache/netbeans/blob/master/platform/core.windows/src/org/netbeans/core/windows/view/ui/CloseButtonTabbedPane.java, see MouseListener at the beginning.
I tried setting client property TabbedPaneFactory.NO_CLOSE_BUTTON to true in my TopComponent, so that hideCloseButton() returns true and blocks the call to fireCloseRequest() in mouseReleased(), but it did not work. I could not debug from my config so I stopped there.
I found an easy workaround by overriding TopComponent.canClose() to return false.
Are you willing to submit a pull request?
No
I had a feeling you were looking at the wrong code when looking at CloseButtonTabbedPane, but this led to a little rabbit warren! 😄 That class is used for things like the tabs in the Output component.
For the standard window tabs I think the problem is at https://github.com/apache/netbeans/blob/master/platform/o.n.swing.tabcontrol/src/org/netbeans/swing/tabcontrol/plaf/AbstractTabCellRenderer.java#L119 The if check here should be checking if the close button is active before setting the command, like the later if check (which is also hit but doesn't unset the command).
On the other hand, the handling for this is different if multitabs are enabled, assuming an uncloseable TC in the editor area, which will route through the code at https://github.com/apache/netbeans/blob/master/platform/core.multitabs/src/org/netbeans/core/multitabs/Controller.java#L132
It all seems a little weird to me that this is handled in the view of the tabs, rather than in the underlying UI model? eg. maybe better handled somewhere like https://github.com/apache/netbeans/blob/master/platform/core.windows/src/org/netbeans/core/windows/view/ui/TabbedHandler.java#L308 ? Overriding TopComponent::canClose doesn't quite have the same semantics of disabling only UI closing?
If I find some time I'll try to make a PR.
what are "multitabs" vs "standard tabs" ?
Is there a doc somewhere about the NB platform high-level architecture ? Usually my main issue when I try to dig into the NB code, is I don't know where to start. So I do some keyword searching on the github repo, but that's not efficient, like for our issue. So I usually give up... (I must also say that there are many files with 0 comments). E.g. what mean the o.n.xx modules vs the openide.xx modules ?