Search in sources :

Example 1 with MnemonicHelper

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);
}
Also used : Color(java.awt.Color) EditOperation(org.exbin.bined.EditOperation) CodeType(org.exbin.bined.CodeType) GoToBinaryPanel(com.mucommander.viewer.binary.ui.GoToBinaryPanel) FocusDialog(com.mucommander.commons.util.ui.dialog.FocusDialog) MenuToolkit(com.mucommander.commons.util.ui.helper.MenuToolkit) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) EditMode(org.exbin.bined.EditMode) SwingUtilities(javax.swing.SwingUtilities) Charset(java.nio.charset.Charset) JMenuItem(javax.swing.JMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) CodeArea(org.exbin.bined.swing.basic.CodeArea) FontChangedEvent(com.mucommander.ui.theme.FontChangedEvent) CodeAreaCaretPosition(org.exbin.bined.CodeAreaCaretPosition) ThemeManager(com.mucommander.ui.theme.ThemeManager) EditModeCapable(org.exbin.bined.capability.EditModeCapable) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Translator(com.mucommander.text.Translator) Nonnull(javax.annotation.Nonnull) ColorChangedEvent(com.mucommander.ui.theme.ColorChangedEvent) KeyStroke(javax.swing.KeyStroke) JButton(javax.swing.JButton) DialogToolkit(com.mucommander.commons.util.ui.dialog.DialogToolkit) Theme(com.mucommander.ui.theme.Theme) ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu) BinaryStatusPanel(com.mucommander.viewer.binary.ui.BinaryStatusPanel) KeyEvent(java.awt.event.KeyEvent) MouseEvent(java.awt.event.MouseEvent) Dimension(java.awt.Dimension) CodeCharactersCase(org.exbin.bined.CodeCharactersCase) ThemeListener(com.mucommander.ui.theme.ThemeListener) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JPanel(javax.swing.JPanel) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JMenu(javax.swing.JMenu)

Example 2 with MnemonicHelper

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);
    }
}
Also used : Cursor(java.awt.Cursor) ViewerPresenter(com.mucommander.viewer.ViewerPresenter) MenuToolkit(com.mucommander.commons.util.ui.helper.MenuToolkit) Function(java.util.function.Function) WarnUserException(com.mucommander.viewer.WarnUserException) FileViewerService(com.mucommander.viewer.FileViewerService) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) JMenuItem(javax.swing.JMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JFrame(javax.swing.JFrame) Translator(com.mucommander.text.Translator) JComponent(javax.swing.JComponent) JMenuBar(javax.swing.JMenuBar) KeyStroke(javax.swing.KeyStroke) FileTable(com.mucommander.ui.main.table.FileTable) ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu) IOException(java.io.IOException) KeyEvent(java.awt.event.KeyEvent) Logger(java.util.logging.Logger) List(java.util.List) FileViewer(com.mucommander.viewer.FileViewer) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) AbstractFile(com.mucommander.commons.file.AbstractFile) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Example 3 with MnemonicHelper

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);
}
Also used : JComponent(javax.swing.JComponent) JMenuBar(javax.swing.JMenuBar) KeyStroke(javax.swing.KeyStroke) DialogOwner(com.mucommander.commons.util.ui.dialog.DialogOwner) JPopupMenu(javax.swing.JPopupMenu) ViewerPresenter(com.mucommander.viewer.ViewerPresenter) MenuToolkit(com.mucommander.commons.util.ui.helper.MenuToolkit) KeyEvent(java.awt.event.KeyEvent) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) Objects(java.util.Objects) EditMode(org.exbin.bined.EditMode) FileViewer(com.mucommander.viewer.FileViewer) JMenuItem(javax.swing.JMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) CodeArea(org.exbin.bined.swing.basic.CodeArea) Translator(com.mucommander.text.Translator) Nonnull(javax.annotation.Nonnull) AbstractFile(com.mucommander.commons.file.AbstractFile) EncodingMenu(com.mucommander.ui.encoding.EncodingMenu) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JPopupMenu(javax.swing.JPopupMenu)

Example 4 with MnemonicHelper

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;
}
Also used : Hashtable(java.util.Hashtable) ProtocolPanelProvider(com.mucommander.protocol.ui.ProtocolPanelProvider) ArrayList(java.util.ArrayList) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) Bookmark(com.mucommander.bookmark.Bookmark) BonjourService(com.mucommander.bonjour.BonjourService) MuAction(com.mucommander.ui.action.MuAction) BonjourMenu(com.mucommander.bonjour.BonjourMenu) Icon(javax.swing.Icon) JMenuItem(javax.swing.JMenuItem)

Example 5 with MnemonicHelper

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);
}
Also used : MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JMenu(javax.swing.JMenu)

Aggregations

MnemonicHelper (com.mucommander.commons.util.ui.helper.MnemonicHelper)11 JMenuItem (javax.swing.JMenuItem)6 MenuToolkit (com.mucommander.commons.util.ui.helper.MenuToolkit)5 Translator (com.mucommander.text.Translator)5 KeyEvent (java.awt.event.KeyEvent)5 JMenu (javax.swing.JMenu)5 KeyStroke (javax.swing.KeyStroke)5 AbstractFile (com.mucommander.commons.file.AbstractFile)4 JComponent (javax.swing.JComponent)4 JMenuBar (javax.swing.JMenuBar)4 ArrayList (java.util.ArrayList)3 Nonnull (javax.annotation.Nonnull)3 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)3 JButton (javax.swing.JButton)3 ButtonChoicePanel (com.mucommander.commons.util.ui.button.ButtonChoicePanel)2 DialogOwner (com.mucommander.commons.util.ui.dialog.DialogOwner)2 EncodingMenu (com.mucommander.ui.encoding.EncodingMenu)2 CloseCancelledException (com.mucommander.viewer.CloseCancelledException)2 EditorPresenter (com.mucommander.viewer.EditorPresenter)2 FileEditor (com.mucommander.viewer.FileEditor)2