mbien commented on code in PR #4792:
URL: https://github.com/apache/netbeans/pull/4792#discussion_r996447584


##########
platform/core.multitabs/src/org/netbeans/core/multitabs/impl/ButtonPopupSwitcher.java:
##########
@@ -355,6 +354,22 @@ private boolean changeSelection( KeyEvent event ) {
                         selRow = Math.min( pTable.getModel().getRowCount()-1, 
selRow );
                         selCol = Math.min( 
pTable.getModel().getColumnCount()-1, selCol );
                         switched = true;
+                    }else if( tabIndex == -1 ){
+                        List<TabData> tabs = 
controller.getTabModel().getTabs();
+                        ProjectProxy project = item.getProject();
+                        ProjectSupport projectSupport = 
ProjectSupport.getDefault();
+                        for ( int i = tabs.size(); i-- > 0; ) {  //reverse 
iteration to close tabs from the end so tabIndex does not change
+                            if( controller.getTabModel().size() == 1 ) {
+                                
SwingUtilities.invokeLater(this::hideCurrentPopup);
+                            }
+                            TabData projectTab = tabs.get( i );
+                            ProjectProxy projectForTab = 
projectSupport.getProjectForTab( projectTab );
+                            if (( project == null && projectForTab == null ) 
|| ( projectForTab != null && projectForTab.equals( project ))) {
+                                tabIndex = controller.getTabModel().indexOf( 
projectTab );
+                                TabActionEvent tae = new TabActionEvent( this, 
TabbedContainer.COMMAND_CLOSE, tabIndex );
+                                controller.postActionEvent( tae );
+                            }
+                        }

Review Comment:
   step 2, remove this. and call the method:
   ```
   pTable.closeTabsOfProject(project);
   ```
   I think project might be the only param you need.



##########
platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java:
##########
@@ -132,27 +132,42 @@ boolean onMouseEvent( MouseEvent e ) {
         p = SwingUtilities.convertPoint((Component) e.getSource(), p, this);
         int selRow = getSelectedRow();
         int selCol = getSelectedColumn();
-        if( selRow < 0 || selCol < 0 )
+        if ( selRow < 0 || selCol < 0 )
             return false;
         Rectangle rect = getCellRect( selRow, selCol, false );
-        if( rect.contains( p ) ) {
+        if ( rect.contains( p ) ) {
             Dimension size = btnClose.getPreferredSize();
             int x = rect.x+rect.width-size.width;
             int y = rect.y + (rect.height-size.height)/2;
             Rectangle btnRect = new Rectangle( x, y, size.width, size.height);
             boolean inButton = btnRect.contains( p );
             boolean mustRepaint = inCloseButtonRect != inButton;
             inCloseButtonRect = inButton;
-            if( inButton ) {
-                if( e.getID() == MouseEvent.MOUSE_PRESSED ) {
+            if ( inButton ) {
+                if ( e.getID() == MouseEvent.MOUSE_PRESSED ) {
                     Item item = ( Item ) getModel().getValueAt( selRow, selCol 
);
                     TabData tab = item.getTabData();
                     int tabIndex = controller.getTabModel().indexOf( tab );
                     if( tabIndex >= 0 ) {
                         TabActionEvent tae = new TabActionEvent( this, 
TabbedContainer.COMMAND_CLOSE, tabIndex );
                         controller.postActionEvent( tae );
                         return true;
+                    }else if ( tabIndex == -1 ) {
+                        List<TabData> tabs = 
controller.getTabModel().getTabs();
+                        ProjectProxy project = item.getProject();
+                        ProjectSupport projectSupport = 
ProjectSupport.getDefault();
+                        for ( int i = tabs.size(); i-- > 0; ) {  //reverse 
iteration to close tabs from the end so tabIndex does not change
+                            TabData projectTab = tabs.get( i );
+                            ProjectProxy projectForTab = 
projectSupport.getProjectForTab( projectTab );
+                            if (( project == null && projectForTab == null ) 
|| ( projectForTab != null && projectForTab.equals( project ))) {
+                                tabIndex = controller.getTabModel().indexOf( 
projectTab );
+                                TabActionEvent tae = new TabActionEvent( this, 
TabbedContainer.COMMAND_CLOSE, tabIndex );
+                                controller.postActionEvent( tae );
+                            }
+                        }

Review Comment:
   step 1, extract this into a package-private method in the same class here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to