Index: openide/src/org/openide/awt/Actions.java =================================================================== RCS file: /cvs/openide/src/org/openide/awt/Actions.java,v --- openide/src/org/openide/awt/Actions.java 17 Jan 2003 11:23:20 -0000 1.77 +++ openide/src/org/openide/awt/Actions.java 17 Jan 2003 17:31:08 -0000 @@ -26,6 +26,7 @@ import org.openide.util.Mutex; import org.openide.util.actions.*; import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; /** Supporting class for manipulation with menu and toolbar presenters. * @@ -721,8 +722,22 @@ HelpCtx help = model.getHelpCtx (0); associateHelp (menu, help == null ? findHelp (action) : help); } else { - boolean addSeparator = false; int count = model.getCount(); + // For submenus with 5 or more items, if there are no existing mnemonics, + // automatically add some (numbered, lettered, etc.). + boolean autoMnemonic = (count > 4); + if (autoMnemonic) { + for (int i = 0; i < count; i++) { + String label = model.getLabel(i); + if (label != null && label.indexOf('&') != -1) { // NOI18N + autoMnemonic = false; + break; + } + } + } + String autoMnemonicText = autoMnemonic ? NbBundle.getMessage(Actions.class, "MNEM_submenu_items") : null; + int autoMnemonicIndex = 0; + boolean addSeparator = false; for (int i = 0; i < count; i++) { String label = model.getLabel(i); // MenuShortcut shortcut = support.getMenuShortcut(i); @@ -732,6 +747,13 @@ if(addSeparator) { menu.addSeparator(); addSeparator = false; + } + if (autoMnemonicIndex >= autoMnemonicText.length()) { + // Past the end, skip it - but pad text a bit. + // (Padding is approximate since the font is probably proportional anyway.) + label = " " + label; // NOI18N + } else { + label = "&" + autoMnemonicText.charAt(autoMnemonicIndex++) + ' ' + label; // NOI18N } // if (shortcut == null) // (Dafe) changed to support mnemonics in item labels Index: openide/src/org/openide/awt/Bundle.properties =================================================================== RCS file: /cvs/openide/src/org/openide/awt/Bundle.properties,v --- openide/src/org/openide/awt/Bundle.properties 29 May 2002 08:57:32 -0000 1.22 +++ openide/src/org/openide/awt/Bundle.properties 17 Jan 2003 17:31:08 -0000 @@ -60,3 +60,8 @@ # SwingBrowserImpl ACS_SwingBrowserImpl_SwingBrowser=N/A + +# Actions +# Might be localized e.g. in Russian to use Cyrillic keys, if desired. +# Should be a list of single-char mnemonics (usually alphanumerics): +MNEM_submenu_items=1234567890abcdefghijklmnopqrstuvwxyz