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.
We need a way to change Document Tab names. Usecase: We have a set of files in our explorer panel, when these files are opened, the document Tab name should say "<FileName> Shared". Problem: I tried to do this by using filtered set of nodes, the annotated node display name does not appear as the file name. The root cause is the ubiquitous reliance on DataEditorSupport, and the implementation of its messageName() method. This implementation is as follows: protected String messageName () { if (! obj.isValid()) return ""; // NOI18N String name; if(DataNode.getShowFileExtensions()) { name = obj.getPrimaryFile().getNameExt(); } else { name = obj.getPrimaryFile().getName(); } Clearly, it ignores anythig but the physical file name. It would be possible to patch this method. The approach would be to change the messageName() method to use the display name of the associated node.
The method doesn't pick up the Node's display name intentionally. If it did so, you'll end up with filesystem annotations (like "File.java [Up-to-date; 1.23]" in the editor tabs, which will lead to very long tabs.
So, Is there other approach to address this issue, a hack or something.
Sure. I believe it is doable by listening on a TC.Registry for PROP_OPENED and for each TC decide whether to mark it. For each marked TC, add a listener for "displayName" property and fix the changed name as well, ignoring our own changes. I'll try to craft a prototype.
Created attachment 21195 [details] Example module doing tab name annotations without API
Try unpacking the provided example module under $nbsrc/contrib and build it (using ant in the created folder). It will add a module that catch any opened TC and annotates its name with red font. Seems quite doable without any API support (although not straightforward), so closing this as WONTFIX for now.
Thanks Petr. I tried the attached code inside my module (with some modification to filter out everthing except what I want to change), works as expected. -Ayub
Marking as verified then.