Search in sources :

Example 6 with MnemonicHelper

use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.

the class ButtonChoicePanel method updateMnemonics.

/**
 * Updates the buttons mnemonics. This method should be called when at least one of the button's label has changed.
 */
public void updateMnemonics() {
    MnemonicHelper mnemonicHelper = new MnemonicHelper();
    char mnemonic;
    for (JButton button : buttons) {
        mnemonic = mnemonicHelper.getMnemonic(button);
        if (mnemonic != 0)
            button.setMnemonic(mnemonic);
    }
}
Also used : JButton(javax.swing.JButton) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Example 7 with MnemonicHelper

use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.

the class DialogToolkit method createButtonPanel.

/**
 * Creates a button panel using the given buttons, and register the given listener for button actions.
 * Buttons are disposed horizontally, aligned to the right.
 */
public static JPanel createButtonPanel(List<JButton> buttons, JRootPane rootPane, ActionListener actionListener) {
    JPanel panel = new ButtonChoicePanel(buttons, 0, rootPane);
    MnemonicHelper mnemonicHelper = new MnemonicHelper();
    for (JButton button : buttons) {
        button.setMnemonic(mnemonicHelper.getMnemonic(button.getText()));
        button.addActionListener(actionListener);
        panel.add(button);
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) ButtonChoicePanel(com.mucommander.commons.util.ui.button.ButtonChoicePanel) JButton(javax.swing.JButton) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Example 8 with MnemonicHelper

use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.

the class DialogToolkit method createButtonPanel.

/**
 * Creates a button panel using the given buttons, and register the given listener for button actions.
 * Buttons are disposed horizontally, aligned to the right.
 */
public static JPanel createButtonPanel(JButton[] buttons, JRootPane rootPane, ActionListener actionListener) {
    JPanel panel = new ButtonChoicePanel(buttons, 0, rootPane);
    MnemonicHelper mnemonicHelper = new MnemonicHelper();
    for (JButton button : buttons) {
        button.setMnemonic(mnemonicHelper.getMnemonic(button.getText()));
        button.addActionListener(actionListener);
        panel.add(button);
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) ButtonChoicePanel(com.mucommander.commons.util.ui.button.ButtonChoicePanel) JButton(javax.swing.JButton) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Example 9 with MnemonicHelper

use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.

the class BonjourMenu method menuSelected.

// ///////////////////////////////
// MenuListener implementation //
// ///////////////////////////////
public void menuSelected(MenuEvent menuEvent) {
    // Remove previous menu items (if any)
    removeAll();
    if (BonjourDirectory.isActive()) {
        BonjourService[] services = BonjourDirectory.getServices();
        int nbServices = services.length;
        if (nbServices > 0) {
            // Add a menu item for each Bonjour service.
            // When clicked, the corresponding URL will opened in the active table.
            JMenuItem menuItem;
            MnemonicHelper mnemonicHelper = new MnemonicHelper();
            for (int i = 0; i < nbServices; i++) {
                menuItem = new JMenuItem(getMenuItemAction(services[i]));
                menuItem.setMnemonic(mnemonicHelper.getMnemonic(menuItem.getText()));
                add(menuItem);
            }
        } else {
            // Inform that no service have been discovered
            add(new JMenuItem(Translator.get("bonjour.no_service_discovered"))).setEnabled(false);
        }
    } else {
        // Inform that Bonjour support has been disabled
        add(new JMenuItem(Translator.get("bonjour.bonjour_disabled"))).setEnabled(false);
    }
}
Also used : MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Example 10 with MnemonicHelper

use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.

the class BinaryEditor method initMenuBars.

private void initMenuBars() {
    MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
    fileMenu = new JMenu(Translator.get("binary_editor.file"));
    int metaMask = getMetaMask();
    saveMenuItem = MenuToolkit.addMenuItem(fileMenu, Translator.get("binary_editor.save"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_S, metaMask), e -> saveFile());
    saveAsMenuItem = MenuToolkit.addMenuItem(fileMenu, Translator.get("binary_editor.save_as"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.SHIFT_DOWN_MASK | metaMask), e -> saveAsFile());
    cutMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.cut"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_X, metaMask), e -> binaryComponent.getCodeArea().cut());
    editMenu.add(cutMenuItem, copyMenuItemPosition);
    pasteMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.paste"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_V, metaMask), e -> binaryComponent.getCodeArea().paste());
    deleteMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.delete"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), e -> binaryComponent.getCodeArea().delete());
    editMenu.add(pasteMenuItem, copyMenuItemPosition + 2);
    editMenu.add(deleteMenuItem, copyMenuItemPosition + 3);
    JPopupMenu popupMenu = new JPopupMenu();
    cutPopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.cut"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_X, metaMask), e -> binaryComponent.getCodeArea().cut());
    popupMenu.add(cutPopupMenuItem);
    copyPopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_viewer.copy"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_C, getMetaMask()), e -> binaryComponent.getCodeArea().copy());
    popupMenu.add(copyPopupMenuItem);
    pastePopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.paste"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_V, metaMask), e -> binaryComponent.getCodeArea().paste());
    popupMenu.add(pastePopupMenuItem);
    deletePopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.delete"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), e -> binaryComponent.getCodeArea().delete());
    popupMenu.add(deletePopupMenuItem);
    popupMenu.add(MenuToolkit.createMenuItem(Translator.get("binary_viewer.select_all"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_A, getMetaMask()), e -> binaryComponent.getCodeArea().selectAll()));
    binaryComponent.getCodeArea().setComponentPopupMenu(popupMenu);
}
Also used : FileFactory(com.mucommander.commons.file.FileFactory) Arrays(java.util.Arrays) DialogOwner(com.mucommander.commons.util.ui.dialog.DialogOwner) MenuToolkit(com.mucommander.commons.util.ui.helper.MenuToolkit) EditorPresenter(com.mucommander.viewer.EditorPresenter) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) Level(java.util.logging.Level) JMenuItem(javax.swing.JMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) PagedData(org.exbin.auxiliary.paged_data.PagedData) CodeArea(org.exbin.bined.swing.basic.CodeArea) JFileChooser(javax.swing.JFileChooser) Translator(com.mucommander.text.Translator) Nonnull(javax.annotation.Nonnull) OsFamily(com.mucommander.commons.runtime.OsFamily) EncodingMenu(com.mucommander.ui.encoding.EncodingMenu) CloseCancelledException(com.mucommander.viewer.CloseCancelledException) FileEditor(com.mucommander.viewer.FileEditor) OutputStream(java.io.OutputStream) JComponent(javax.swing.JComponent) JMenuBar(javax.swing.JMenuBar) KeyStroke(javax.swing.KeyStroke) LocalFile(com.mucommander.commons.file.protocol.local.LocalFile) QuestionDialog(com.mucommander.ui.dialog.QuestionDialog) JPopupMenu(javax.swing.JPopupMenu) JMenu(javax.swing.JMenu) IOException(java.io.IOException) KeyEvent(java.awt.event.KeyEvent) Logger(java.util.logging.Logger) DialogAction(com.mucommander.ui.dialog.DialogAction) Objects(java.util.Objects) InformationDialog(com.mucommander.ui.dialog.InformationDialog) FileCollisionChecker(com.mucommander.job.FileCollisionChecker) FileOperation(com.mucommander.commons.file.FileOperation) BinaryData(org.exbin.auxiliary.paged_data.BinaryData) FileCollisionDialog(com.mucommander.ui.dialog.file.FileCollisionDialog) AbstractFile(com.mucommander.commons.file.AbstractFile) InputStream(java.io.InputStream) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JMenu(javax.swing.JMenu) JPopupMenu(javax.swing.JPopupMenu)

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