Lines 26-31
Link Here
|
26 |
import org.openide.util.Mutex; |
26 |
import org.openide.util.Mutex; |
27 |
import org.openide.util.actions.*; |
27 |
import org.openide.util.actions.*; |
28 |
import org.openide.util.HelpCtx; |
28 |
import org.openide.util.HelpCtx; |
|
|
29 |
import org.openide.util.NbBundle; |
29 |
|
30 |
|
30 |
/** Supporting class for manipulation with menu and toolbar presenters. |
31 |
/** Supporting class for manipulation with menu and toolbar presenters. |
31 |
* |
32 |
* |
Lines 721-728
Link Here
|
721 |
HelpCtx help = model.getHelpCtx (0); |
722 |
HelpCtx help = model.getHelpCtx (0); |
722 |
associateHelp (menu, help == null ? findHelp (action) : help); |
723 |
associateHelp (menu, help == null ? findHelp (action) : help); |
723 |
} else { |
724 |
} else { |
724 |
boolean addSeparator = false; |
|
|
725 |
int count = model.getCount(); |
725 |
int count = model.getCount(); |
|
|
726 |
// For submenus with 5 or more items, if there are no existing mnemonics, |
727 |
// automatically add some (numbered, lettered, etc.). |
728 |
boolean autoMnemonic = (count > 4); |
729 |
if (autoMnemonic) { |
730 |
for (int i = 0; i < count; i++) { |
731 |
String label = model.getLabel(i); |
732 |
if (label != null && label.indexOf('&') != -1) { // NOI18N |
733 |
autoMnemonic = false; |
734 |
break; |
735 |
} |
736 |
} |
737 |
} |
738 |
String autoMnemonicText = autoMnemonic ? NbBundle.getMessage(Actions.class, "MNEM_submenu_items") : null; |
739 |
int autoMnemonicIndex = 0; |
740 |
boolean addSeparator = false; |
726 |
for (int i = 0; i < count; i++) { |
741 |
for (int i = 0; i < count; i++) { |
727 |
String label = model.getLabel(i); |
742 |
String label = model.getLabel(i); |
728 |
// MenuShortcut shortcut = support.getMenuShortcut(i); |
743 |
// MenuShortcut shortcut = support.getMenuShortcut(i); |
Lines 732-737
Link Here
|
732 |
if(addSeparator) { |
747 |
if(addSeparator) { |
733 |
menu.addSeparator(); |
748 |
menu.addSeparator(); |
734 |
addSeparator = false; |
749 |
addSeparator = false; |
|
|
750 |
} |
751 |
if (autoMnemonic) { |
752 |
if (autoMnemonicIndex >= autoMnemonicText.length()) { |
753 |
// Past the end, skip it - but pad text a bit. |
754 |
// (Padding is approximate since the font is probably proportional anyway.) |
755 |
label = " " + label; // NOI18N |
756 |
} else { |
757 |
label = "&" + autoMnemonicText.charAt(autoMnemonicIndex++) + ' ' + label; // NOI18N |
758 |
} |
735 |
} |
759 |
} |
736 |
// if (shortcut == null) |
760 |
// if (shortcut == null) |
737 |
// (Dafe) changed to support mnemonics in item labels |
761 |
// (Dafe) changed to support mnemonics in item labels |