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.

Bug 57027 - need a way to change Document Tab names
Summary: need a way to change Document Tab names
Status: CLOSED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 4.x
Hardware: All All
: P1 blocker (vote)
Assignee: Petr Nejedly
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-25 19:48 UTC by Ayub Khan
Modified: 2008-12-22 19:05 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Example module doing tab name annotations without API (5.60 KB, application/octet-stream)
2005-03-29 13:51 UTC, Petr Nejedly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ayub Khan 2005-03-25 19:48:36 UTC
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.
Comment 1 Petr Nejedly 2005-03-25 20:17:11 UTC
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.
Comment 2 Ayub Khan 2005-03-28 05:04:12 UTC
So, Is there other approach to address this issue, a hack or something.
Comment 3 Petr Nejedly 2005-03-29 08:53:57 UTC
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.
Comment 4 Petr Nejedly 2005-03-29 13:51:02 UTC
Created attachment 21195 [details]
Example module doing tab name annotations without API
Comment 5 Petr Nejedly 2005-03-29 13:57:23 UTC
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.
Comment 6 Ayub Khan 2005-03-30 05:24:43 UTC
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
Comment 7 Petr Nejedly 2005-03-30 09:28:04 UTC
Marking as verified then.