Bug 268040 - Tabs are still closable despite the close button is not visible in the drop-down menu (DocumentSwitcherTable)
Tabs are still closable despite the close button is not visible in the drop-d...
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Window System
8.1
All All
: P1 (vote)
: Dev
Assigned To: Jiri Sedlacek
issues@platform
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-15 11:20 UTC by tdr
Modified: 2017-03-10 02:55 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tdr 2016-09-15 11:20:41 UTC
When using putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE) in a TopComponent, the close [x] button in the tab switcher (DocumentSwitcherTable) drop-down menu is not visible.
But when clicking on the position where the close [x] button would be displayed when enabled, the TopComponent is still closed. This is not expected.

When looking into the code of the DocumentSwitcherTable, the close button is always created.

69             btnClose = createCloseButton();

When a mouse event occurs, the click is mapped to the area of btnClose. If the click is inside this area the TopComponent is closed. There is no check if closing is allowed.

111            Dimension size = btnClose.getPreferredSize();
112            int x = rect.x+rect.width-size.width;
113            int y = rect.y + (rect.height-size.height)/2;
114            Rectangle btnRect = new Rectangle( x, y, size.width, size.height);
115            boolean inButton = btnRect.contains( p );
116            boolean mustRepaint = inCloseButtonRect != inButton;
117            inCloseButtonRect = inButton;
118            if( inButton ) {
119                if( e.getID() == MouseEvent.MOUSE_PRESSED ) {
120                    Item item = ( Item ) getModel().getValueAt( selRow, selCol );
121                    TabData tab = item.getTabData();
122                    int tabIndex = displayer.getModel().indexOf( tab );
123                    if( tabIndex >= 0 ) {
124                        TabActionEvent evt = new TabActionEvent( displayer, TabDisplayer.COMMAND_CLOSE, tabIndex);
125                        displayer.postActionEvent( evt );
126                        return true;
127                    }
128                }
129            }

Can you please add a "closing allowed" check. The needed method "isClosable" already exists.
Comment 1 tdr 2017-01-18 10:04:42 UTC
Can you please fix this bug. That would be really helpful. Thanks!
Comment 2 Jiri Sedlacek 2017-03-08 10:41:54 UTC
Fixed by http://hg.netbeans.org/profiler-main/rev/caea4b46b499.
Comment 3 Quality Engineering 2017-03-10 02:55:24 UTC
Integrated into 'main-silver', will be available in build *201703100002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/caea4b46b499
User: Jiri Sedlacek <jis@netbeans.org>
Log: Bugfix #268040 - make sure a non-closable TopComponent cannot be closed from Document switcher


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo