use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class BinaryBase method initMenuBars.
private void initMenuBars() {
editMenu = new JMenu(Translator.get("binary_viewer.edit"));
MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
int metaMask = getMetaMask();
copyMenuItemPosition = editMenu.getItemCount();
copyMenuItem = MenuToolkit.addMenuItem(editMenu, Translator.get("binary_viewer.copy"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_C, metaMask), e -> binaryComponent.getCodeArea().copy());
selectAllMenuItem = MenuToolkit.addMenuItem(editMenu, Translator.get("binary_viewer.select_all"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_A, metaMask), e -> binaryComponent.getCodeArea().selectAll());
editMenu.addSeparator();
goToMenuItem = MenuToolkit.addMenuItem(editMenu, Translator.get("binary_viewer.go_to"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_G, metaMask), e -> goToPosition());
viewMenu = new JMenu(Translator.get("binary_viewer.view"));
codeTypeMenu = new JMenu(Translator.get("binary_viewer.code_type"));
codeTypeButtonGroup = new ButtonGroup();
binaryCodeTypeRadioButtonMenuItem = new JRadioButtonMenuItem();
codeTypeButtonGroup.add(binaryCodeTypeRadioButtonMenuItem);
binaryCodeTypeRadioButtonMenuItem.setText(Translator.get("binary_viewer.code_type.binary"));
binaryCodeTypeRadioButtonMenuItem.addActionListener(e -> binaryComponent.getCodeArea().setCodeType(CodeType.BINARY));
codeTypeMenu.add(binaryCodeTypeRadioButtonMenuItem);
octalCodeTypeRadioButtonMenuItem = new JRadioButtonMenuItem();
codeTypeButtonGroup.add(octalCodeTypeRadioButtonMenuItem);
octalCodeTypeRadioButtonMenuItem.setText(Translator.get("binary_viewer.code_type.octal"));
octalCodeTypeRadioButtonMenuItem.addActionListener(e -> binaryComponent.getCodeArea().setCodeType(CodeType.OCTAL));
codeTypeMenu.add(octalCodeTypeRadioButtonMenuItem);
decimalCodeTypeRadioButtonMenuItem = new JRadioButtonMenuItem();
codeTypeButtonGroup.add(decimalCodeTypeRadioButtonMenuItem);
decimalCodeTypeRadioButtonMenuItem.setText(Translator.get("binary_viewer.code_type.decimal"));
decimalCodeTypeRadioButtonMenuItem.addActionListener(e -> binaryComponent.getCodeArea().setCodeType(CodeType.DECIMAL));
codeTypeMenu.add(decimalCodeTypeRadioButtonMenuItem);
hexadecimalCodeTypeRadioButtonMenuItem = new JRadioButtonMenuItem();
codeTypeButtonGroup.add(hexadecimalCodeTypeRadioButtonMenuItem);
hexadecimalCodeTypeRadioButtonMenuItem.setSelected(true);
hexadecimalCodeTypeRadioButtonMenuItem.setText(Translator.get("binary_viewer.code_type.hexadecimal"));
hexadecimalCodeTypeRadioButtonMenuItem.addActionListener(e -> binaryComponent.getCodeArea().setCodeType(CodeType.HEXADECIMAL));
codeTypeMenu.add(hexadecimalCodeTypeRadioButtonMenuItem);
viewMenu.add(codeTypeMenu);
codeCharacterCaseMenu = new JMenu(Translator.get("binary_viewer.char_case"));
codeCharacterCaseButtonGroup = new ButtonGroup();
upperCaseRadioButtonMenuItem = new JRadioButtonMenuItem();
codeCharacterCaseButtonGroup.add(upperCaseRadioButtonMenuItem);
upperCaseRadioButtonMenuItem.setSelected(true);
upperCaseRadioButtonMenuItem.setText(Translator.get("binary_viewer.char_case.upper"));
upperCaseRadioButtonMenuItem.addActionListener(e -> binaryComponent.getCodeArea().setCodeCharactersCase(CodeCharactersCase.UPPER));
codeCharacterCaseMenu.add(upperCaseRadioButtonMenuItem);
lowerCaseRadioButtonMenuItem = new JRadioButtonMenuItem();
codeCharacterCaseButtonGroup.add(lowerCaseRadioButtonMenuItem);
lowerCaseRadioButtonMenuItem.setText(Translator.get("binary_viewer.char_case.lower"));
lowerCaseRadioButtonMenuItem.addActionListener(e -> binaryComponent.getCodeArea().setCodeCharactersCase(CodeCharactersCase.LOWER));
codeCharacterCaseMenu.add(lowerCaseRadioButtonMenuItem);
viewMenu.add(codeCharacterCaseMenu);
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class FileViewerPresenter method show.
@Override
protected void show(AbstractFile file) throws IOException {
setCurrentFile(file);
if (fileViewer == null) {
MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
viewerMenu.addSeparator();
closeMenuItem = MenuToolkit.addMenuItem(viewerMenu, Translator.get("file_viewer.close"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), (e) -> {
fileViewer.close();
getFrame().dispose();
});
viewerMenu.add(closeMenuItem);
switchFileViewer(0);
}
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class BinaryViewer method initMenuBars.
private void initMenuBars() {
MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
JPopupMenu popupMenu = new JPopupMenu();
int metaMask = getMetaMask();
copyPopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_viewer.copy"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_C, metaMask), e -> binaryComponent.getCodeArea().copy());
popupMenu.add(copyPopupMenuItem);
popupMenu.add(MenuToolkit.createMenuItem(Translator.get("binary_viewer.select_all"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_A, metaMask), e -> binaryComponent.getCodeArea().selectAll()));
binaryComponent.getCodeArea().setComponentPopupMenu(popupMenu);
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class DrivePopupButton method getPopupMenu.
// //////////////////////////////
// PopupButton implementation //
// //////////////////////////////
@Override
public JPopupMenu getPopupMenu() {
JPopupMenu popupMenu = new JPopupMenu();
// Update the list of volumes in case new ones were mounted
volumes = getDisplayableVolumes();
// Add volumes
int nbVolumes = volumes.length;
final MainFrame mainFrame = folderPanel.getMainFrame();
// Provides mnemonics and ensures uniqueness
MnemonicHelper mnemonicHelper = new MnemonicHelper();
JMenuItem item;
MuAction action;
String volumeName;
boolean useExtendedDriveNames = fileSystemView != null;
ArrayList<JMenuItem> itemsV = new ArrayList<JMenuItem>();
for (int i = 0; i < nbVolumes; i++) {
action = new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), volumes[i]);
volumeName = volumes[i].getName();
// volume's path, to disambiguate
for (int j = 0; j < nbVolumes; j++) {
if (j != i && volumes[j].getName().equalsIgnoreCase(volumeName)) {
action.setLabel(volumes[i].getAbsolutePath());
break;
}
}
item = popupMenu.add(action);
setMnemonic(item, mnemonicHelper);
// Set icon from cache
Icon icon = iconCache.get(volumes[i]);
if (icon != null) {
item.setIcon(icon);
}
if (useExtendedDriveNames) {
// Use the last known value (if any) while we update it in a separate thread
String previousExtendedName = extendedNameCache.get(volumes[i]);
if (previousExtendedName != null)
item.setText(previousExtendedName);
}
// JMenu offers no way to retrieve a particular JMenuItem, so we have to keep them
itemsV.add(item);
}
new RefreshDriveNamesAndIcons(popupMenu, itemsV).start();
popupMenu.add(new JSeparator());
// Add boookmarks
java.util.List<Bookmark> bookmarks = BookmarkManager.getBookmarks();
if (!bookmarks.isEmpty()) {
for (Bookmark bookmark : bookmarks) {
item = popupMenu.add(new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), bookmark));
setMnemonic(item, mnemonicHelper);
}
} else {
// No bookmark : add a disabled menu item saying there is no bookmark
popupMenu.add(Translator.get("bookmarks_menu.no_bookmark")).setEnabled(false);
}
popupMenu.add(new JSeparator());
// Add 'Network shares' shortcut
if (FileFactory.isRegisteredProtocol(FileProtocols.SMB)) {
action = new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), new Bookmark(Translator.get("drive_popup.network_shares"), "smb:///"));
action.setIcon(IconManager.getIcon(IconManager.FILE_ICON_SET, CustomFileIconProvider.NETWORK_ICON_NAME));
setMnemonic(popupMenu.add(action), mnemonicHelper);
}
// Add Bonjour services menu
setMnemonic(popupMenu.add(new BonjourMenu() {
@Override
public MuAction getMenuItemAction(BonjourService bs) {
return new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), bs);
}
}), mnemonicHelper);
popupMenu.add(new JSeparator());
// Add 'connect to server' shortcuts
schemaToPanelProvider.values().stream().sorted(Comparator.comparing(ProtocolPanelProvider::priority)).map(this::toServerConnectAction).map(popupMenu::add).forEach(menuItem -> setMnemonic(menuItem, mnemonicHelper));
return popupMenu;
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class TextViewer method initMenuBarItems.
protected void initMenuBarItems() {
// Edit menu
editMenu = new JMenu(Translator.get("text_viewer.edit"));
MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
copyItem = MenuToolkit.addMenuItem(editMenu, Translator.get("text_viewer.copy"), menuItemMnemonicHelper, null, this);
selectAllItem = MenuToolkit.addMenuItem(editMenu, Translator.get("text_viewer.select_all"), menuItemMnemonicHelper, null, this);
editMenu.addSeparator();
findItem = MenuToolkit.addMenuItem(editMenu, Translator.get("text_viewer.find"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK), this);
findNextItem = MenuToolkit.addMenuItem(editMenu, Translator.get("text_viewer.find_next"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), this);
findPreviousItem = MenuToolkit.addMenuItem(editMenu, Translator.get("text_viewer.find_previous"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_DOWN_MASK), this);
// View menu
viewMenu = new JMenu(Translator.get("text_viewer.view"));
toggleLineWrapItem = MenuToolkit.addCheckBoxMenuItem(viewMenu, Translator.get("text_viewer.line_wrap"), menuItemMnemonicHelper, null, this);
toggleLineWrapItem.setSelected(textEditorImpl.isWrap());
toggleLineNumbersItem = MenuToolkit.addCheckBoxMenuItem(viewMenu, Translator.get("text_viewer.line_numbers"), menuItemMnemonicHelper, null, this);
toggleLineNumbersItem.setSelected(ui.getRowHeader().getView() != null);
}
Aggregations