You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/10/15 17:27:12 UTC

[GitHub] [netbeans] mbien commented on a diff in pull request #4792: Close whole documents list at once

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


##########
platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java:
##########
@@ -152,7 +152,21 @@ boolean onMouseEvent( MouseEvent e ) {
                         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.project;
+                        ProjectSupport projectSupport = ProjectSupport.getDefault();
+                        for(int i = tabs.size(); i-- > 0;){
+                            TabData projectTab = tabs.get(i);
+                            if(projectSupport.getProjectForTab(projectTab) == (project) || projectSupport.getProjectForTab(projectTab).equals(project)){

Review Comment:
   the equals check alone would be sufficient. but to be sure, lets add a null check too. We can also use the opportunity to store the result in a variable so that we call the method only once (it could be expensive if the result is not cached).
   ```java
     ProjectProxy projectForTab = projectSupport.getProjectForTab(projectTab);
     if (projectForTab != null && projectForTab.equals(project)) {
   ```
   
   



##########
platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java:
##########
@@ -152,7 +152,21 @@ boolean onMouseEvent( MouseEvent e ) {
                         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.project;
+                        ProjectSupport projectSupport = ProjectSupport.getDefault();
+                        for(int i = tabs.size(); i-- > 0;){
+                            TabData projectTab = tabs.get(i);

Review Comment:
   any reason for iterating backwards here?
   instead of:
   ```java
         for (TabData projectTab : tabs) {
   ```



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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