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 240810 - TabbedContainer and BasicTabDisplayerUI should support hiding of "Close" button for non TopComponent
Summary: TabbedContainer and BasicTabDisplayerUI should support hiding of "Close" butt...
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-22 10:30 UTC by jmborer
Modified: 2014-01-22 12:53 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jmborer 2014-01-22 10:30:28 UTC
When you use a TabbedContainer, it is not possible to disable(hide) the close button for other components than TopComponents.

TabbedContainer is a very useful component and should be improved to be used inside TopComponents for example for sub tabs.

Currently the implementation of BasicTabDisplayerUI does allow that. In method getTabCellRendere:

    public TabCellRenderer getTabCellRenderer(int tab) {
        defaultRenderer.setShowCloseButton(displayer.isShowCloseButton());
        if( tab >=0 && tab < displayer.getModel().size() ) {
            TabData data = displayer.getModel().getTab(tab);
            boolean closingEnabled = true;
            if( data.getComponent() instanceof TopComponent ) {
                closingEnabled = displayer.getContainerWinsysInfo().isTopComponentClosingEnabled( (TopComponent)data.getComponent() );
            }

            defaultRenderer.setShowCloseButton(displayer.isShowCloseButton() && closingEnabled);
        }
        return defaultRenderer;
    }

it is possible to hide the close button only if the component is a TopComponent even though you provide pour own implementation of WinsysInfoForTabbed.

One option would be to add (or replace isTopComponentClosingEnabled) a new method to WinsysInfoForTabbed named isClosingEnabled(Component comp) and then remove the "data.getComponent() instanceof TopComponent" test.
Comment 1 Stanislav Aubrecht 2014-01-22 11:34:22 UTC
Why don't you use TabDisplayer.setShowCloseButton(false)? Or do you need to suppress close button for a single tab only?
Comment 2 jmborer 2014-01-22 12:47:24 UTC
I need to hide the button for a single tab, that always remains at position 0. OK, you might argue that my HMI is bad. Well, possible. Meanwhile having one fixed tab and other dynamic a closeable beside it, is very easy to understand for the end user and saves a lot of space.
Comment 3 jmborer 2014-01-22 12:53:37 UTC
So what I did meanwhile is make my "non-closeable" component extend TopComponent and provide my own WinsysInfoForTabbed which checks for client property TopComponent.PROP_CLOSING_DISABLED.

It works, but I don't really know if there are side effects of using TopComponents inside other TopComponents and outside the windowing system of Netbeans.

I know that there is TabbedPaneFactory.createCloseButtonTabbedPane(), but aside that TabbedContainer has a "greater" implementation for handling a lot of tabs, I appreciate TabbedContainer's default behaviors like, "close all" or "close all but me" features, that doesn't exist with TabbedPaneFactory.

I don't know if there are better technics or APIs I could use.