Take care not to add separators at the beginning and at the end of the popup menu. BLD200406061800
authormentlicher@netbeans.org
Fri, 04 Jun 2004 15:23:48 +0000
changeset 4739b05db2b754eb
parent 4738 c7f675129d3e
child 4740 c56a7f44a950
Take care not to add separators at the beginning and at the end of the popup menu.
This is a fix of issue #43414.
vcscore/src/org/netbeans/modules/vcscore/actions/CommandMenu.java
     1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/actions/CommandMenu.java	Thu Jun 03 21:50:15 2004 +0000
     1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/actions/CommandMenu.java	Fri Jun 04 15:23:48 2004 +0000
     1.3 @@ -127,7 +127,8 @@
     1.4      }
     1.5  
     1.6      private void createPopup() {
     1.7 -        boolean wasSeparator = false;       
     1.8 +        boolean wasSeparator = true; // In order not to add the separator at the beginning
     1.9 +        boolean willAddSeparator = false; // Whether a separator should be added before the command
    1.10          CommandsTree[] children = commandRoot.children();
    1.11          FileObject[] allFiles;
    1.12          if (filesWithMessages.size() == 1) {
    1.13 @@ -142,21 +143,26 @@
    1.14          Map multiCommandsByDisplayName = getMultiCommandsByDisplayName(children, allFiles);
    1.15          Set addedDisplayNames = new HashSet();
    1.16          for (int i = 0; i < children.length; i++) {
    1.17 -            CommandSupport cmd = (CommandSupport) children[i].getCommandSupport();                                  
    1.18 +            CommandSupport cmd = (CommandSupport) children[i].getCommandSupport();
    1.19              if (cmd == null) {
    1.20 -                // an extra check to not allow more separators, than appropriate     
    1.21 -                if(!wasSeparator){
    1.22 -                    addSeparator();
    1.23 -                    wasSeparator=true;                  
    1.24 +                // an extra check to not allow more separators, than appropriate
    1.25 +                if (!wasSeparator) {
    1.26 +                    willAddSeparator = true;
    1.27 +                    wasSeparator = true;
    1.28                  }
    1.29                  continue;
    1.30 -            }                                 
    1.31 +            }
    1.32              String displayName = cmd.getDisplayName();
    1.33              //System.out.println("VcsAction.addMenu(): cmd = "+cmd.getName());
    1.34 -            if (displayName == null) continue;            
    1.35 +            if (displayName == null) continue;
    1.36              if (removeDisabled && cmd.getApplicableFiles(allFiles) == null) {
    1.37                  continue;
    1.38              }
    1.39 +            if (willAddSeparator) {
    1.40 +                // Add the separator only when a non-null command follows
    1.41 +                addSeparator();
    1.42 +                willAddSeparator = false;
    1.43 +            }
    1.44              wasSeparator = false;           
    1.45              JMenuItem item;
    1.46              if (children[i].hasChildren()) {