Search in sources :

Example 26 with KeyStroke

use of javax.swing.KeyStroke in project jadx by skylot.

the class TextStandardActions method addKeyActions.

private void addKeyActions() {
    KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK);
    textComponent.getInputMap().put(undoKey, undoAction);
    KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK);
    textComponent.getInputMap().put(redoKey, redoAction);
}
Also used : KeyStroke(javax.swing.KeyStroke)

Example 27 with KeyStroke

use of javax.swing.KeyStroke in project jgnash by ccavanaugh.

the class Resource method getKeyStroke.

/**
     * Gets a localized keystroke.
     *
     * @param key KeyStroke key
     * @return localized KeyStroke
     */
public static KeyStroke getKeyStroke(final String key) {
    String value = ResourceUtils.getString(key);
    // if working on an QSX system, use the meta key instead of the control key
    if (value != null && value.contains("control") && OS.isSystemOSX()) {
        value = value.replace("control", "meta");
    }
    final KeyStroke keyStroke = KeyStroke.getKeyStroke(value);
    if (keyStroke == null && value != null && !value.isEmpty()) {
        Logger.getLogger(Resource.class.getName()).log(Level.WARNING, "The value ''{0}'' for key ''{1}'' is not valid.", new Object[] { value, key });
    }
    return keyStroke;
}
Also used : KeyStroke(javax.swing.KeyStroke)

Example 28 with KeyStroke

use of javax.swing.KeyStroke in project jabref by JabRef.

the class FindUnlinkedFilesDialog method createRootPane.

/**
     * Close dialog when pressing escape
     */
@Override
protected JRootPane createRootPane() {
    ActionListener actionListener = actionEvent -> setVisible(false);
    JRootPane rPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rPane;
}
Also used : Enumeration(java.util.Enumeration) TreeModel(javax.swing.tree.TreeModel) JabRefPreferences(org.jabref.preferences.JabRefPreferences) FileSystemView(javax.swing.filechooser.FileSystemView) Vector(java.util.Vector) ComponentListener(java.awt.event.ComponentListener) MouseAdapter(java.awt.event.MouseAdapter) ChangeListener(javax.swing.event.ChangeListener) JComboBox(javax.swing.JComboBox) Path(java.nio.file.Path) MouseListener(java.awt.event.MouseListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) KeyStroke(javax.swing.KeyStroke) ChangeEvent(javax.swing.event.ChangeEvent) EntryTypes(org.jabref.model.EntryTypes) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) UnlinkedPDFFileFilter(org.jabref.gui.importer.UnlinkedPDFFileFilter) Frame(java.awt.Frame) TreePath(javax.swing.tree.TreePath) BorderFactory(javax.swing.BorderFactory) JabRefGUI(org.jabref.JabRefGUI) GridBagConstraints(java.awt.GridBagConstraints) ComponentEvent(java.awt.event.ComponentEvent) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) BibtexEntryType(org.jabref.model.entry.BibtexEntryType) Component(java.awt.Component) WindowEvent(java.awt.event.WindowEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTaskExecutor(org.jabref.gui.util.DefaultTaskExecutor) Dimension(java.awt.Dimension) List(java.util.List) AbstractAction(javax.swing.AbstractAction) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) LogFactory(org.apache.commons.logging.LogFactory) GridBagLayout(java.awt.GridBagLayout) JabRefExecutorService(org.jabref.JabRefExecutorService) JPanel(javax.swing.JPanel) WindowConstants(javax.swing.WindowConstants) UnlinkedFilesCrawler(org.jabref.gui.importer.UnlinkedFilesCrawler) Insets(java.awt.Insets) ActionListener(java.awt.event.ActionListener) JTextField(javax.swing.JTextField) FieldName(org.jabref.model.entry.FieldName) TreeNode(javax.swing.tree.TreeNode) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) JabRefDesktop(org.jabref.gui.desktop.JabRefDesktop) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Action(javax.swing.Action) SwingConstants(javax.swing.SwingConstants) EntryFromFileCreator(org.jabref.gui.importer.EntryFromFileCreator) ArrayList(java.util.ArrayList) DirectoryDialogConfiguration(org.jabref.gui.util.DirectoryDialogConfiguration) Localization(org.jabref.logic.l10n.Localization) Container(java.awt.Container) LinkedList(java.util.LinkedList) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) JProgressBar(javax.swing.JProgressBar) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) JComponent(javax.swing.JComponent) JRootPane(javax.swing.JRootPane) JButton(javax.swing.JButton) Iterator(java.util.Iterator) Files(java.nio.file.Files) JList(javax.swing.JList) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) JTree(javax.swing.JTree) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) Globals(org.jabref.Globals) ComponentAdapter(java.awt.event.ComponentAdapter) JScrollPane(javax.swing.JScrollPane) FileFilter(java.io.FileFilter) Paths(java.nio.file.Paths) EntryFromFileCreatorManager(org.jabref.gui.importer.EntryFromFileCreatorManager) JLabel(javax.swing.JLabel) Log(org.apache.commons.logging.Log) EntryType(org.jabref.model.entry.EntryType) Collections(java.util.Collections) ActionListener(java.awt.event.ActionListener) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 29 with KeyStroke

use of javax.swing.KeyStroke in project jabref by JabRef.

the class EmacsKeyBindings method createBackup.

private static void createBackup() {
    Keymap oldBackup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[0].getClass().getName());
    if (oldBackup != null) {
        // if there is already a backup, do not create a new backup
        return;
    }
    for (JTextComponent jtc : EmacsKeyBindings.JTCS) {
        Keymap orig = jtc.getKeymap();
        Keymap backup = JTextComponent.addKeymap(jtc.getClass().getName(), null);
        Action[] bound = orig.getBoundActions();
        for (Action aBound : bound) {
            KeyStroke[] strokes = orig.getKeyStrokesForAction(aBound);
            for (KeyStroke stroke : strokes) {
                backup.addActionForKeyStroke(stroke, aBound);
            }
        }
        backup.setDefaultAction(orig.getDefaultAction());
    }
}
Also used : Action(javax.swing.Action) TextAction(javax.swing.text.TextAction) KeyStroke(javax.swing.KeyStroke) JTextComponent(javax.swing.text.JTextComponent) Keymap(javax.swing.text.Keymap)

Example 30 with KeyStroke

use of javax.swing.KeyStroke in project jabref by JabRef.

the class EmacsKeyBindings method unload.

/**
     * Restores the original keybindings for the concrete subclasses of
     * {@link JTextComponent}.
     */
public static void unload() {
    for (int i = 0; i < EmacsKeyBindings.JTCS.length; i++) {
        Keymap backup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[i].getClass().getName());
        if (backup != null) {
            Keymap current = EmacsKeyBindings.JTCS[i].getKeymap();
            current.removeBindings();
            Action[] bound = backup.getBoundActions();
            for (Action aBound : bound) {
                KeyStroke[] strokes = backup.getKeyStrokesForAction(bound[i]);
                for (KeyStroke stroke : strokes) {
                    current.addActionForKeyStroke(stroke, aBound);
                }
            }
            current.setDefaultAction(backup.getDefaultAction());
        }
    }
}
Also used : Action(javax.swing.Action) TextAction(javax.swing.text.TextAction) KeyStroke(javax.swing.KeyStroke) Keymap(javax.swing.text.Keymap)

Aggregations

KeyStroke (javax.swing.KeyStroke)68 ActionEvent (java.awt.event.ActionEvent)27 ActionListener (java.awt.event.ActionListener)15 AbstractAction (javax.swing.AbstractAction)13 JRootPane (javax.swing.JRootPane)13 Action (javax.swing.Action)10 InputMap (javax.swing.InputMap)9 WindowEvent (java.awt.event.WindowEvent)6 ActionMap (javax.swing.ActionMap)5 GridBagLayout (java.awt.GridBagLayout)4 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 JMenuItem (javax.swing.JMenuItem)4 JPanel (javax.swing.JPanel)4 JScrollPane (javax.swing.JScrollPane)4 AWTKeyStroke (java.awt.AWTKeyStroke)3 Dimension (java.awt.Dimension)3 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 KeyEvent (java.awt.event.KeyEvent)3