Search in sources :

Example 51 with InputMap

use of javax.swing.InputMap in project jmeter by apache.

the class SearchTreeDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    // Hide Window on ESC
    Action escapeAction = new AbstractAction("ESCAPE") {

        private static final long serialVersionUID = -6543764044868772971L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    // Do search on Enter
    Action enterAction = new AbstractAction("ENTER") {

        private static final long serialVersionUID = -3661361497864527363L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            doSearch(actionEvent);
        }
    };
    ActionMap actionMap = rootPane.getActionMap();
    actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
    actionMap.put(enterAction.getValue(Action.NAME), enterAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
    return rootPane;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 52 with InputMap

use of javax.swing.InputMap in project jmeter by apache.

the class EscapeDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    Action escapeAction = new AbstractAction("ESCAPE") {

        /**
             * 
             */
        private static final long serialVersionUID = 2208129319916921772L;

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    };
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction);
    return rootPane;
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 53 with InputMap

use of javax.swing.InputMap in project jmeter by apache.

the class FunctionHelper method createRootPane.

/**
     * Allow Dialog to be closed by ESC key
     */
@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    javax.swing.Action escapeAction = new AbstractAction("ESCAPE") {

        private static final long serialVersionUID = -4036804004190858925L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    return rootPane;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction)

Example 54 with InputMap

use of javax.swing.InputMap in project jmeter by apache.

the class SearchTextExtension method createSearchTextPanel.

/**
     * Create the text find task pane
     *
     * @return Text find task pane
     */
private JPanel createSearchTextPanel() {
    // Search field
    searchPanel = new JPanel();
    searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.X_AXIS));
    searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    // $NON-NLS-1$
    label = new JLabel(JMeterUtils.getResString("search_text_field"));
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    searchPanel.add(label);
    // $NON-NLS-1$
    textToFindField = new JTextField();
    searchPanel.add(textToFindField);
    searchPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    // add listener to intercept texttofind changes and reset search
    textToFindField.getDocument().addDocumentListener(this);
    // Buttons
    findButton = new JButton(JMeterUtils.getResString(// $NON-NLS-1$
    "search_text_button_find"));
    findButton.setFont(FONT_SMALL);
    findButton.setActionCommand(SEARCH_TEXT_COMMAND);
    findButton.addActionListener(this);
    searchPanel.add(findButton);
    // checkboxes
    caseChkBox = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"), // $NON-NLS-1$
    false);
    caseChkBox.setFont(FONT_SMALL);
    searchPanel.add(caseChkBox);
    regexpChkBox = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"), // $NON-NLS-1$
    false);
    regexpChkBox.setFont(FONT_SMALL);
    searchPanel.add(regexpChkBox);
    // when Enter is pressed, search start
    InputMap im = textToFindField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(KeyStrokes.ENTER, SEARCH_TEXT_COMMAND);
    ActionMap am = textToFindField.getActionMap();
    am.put(SEARCH_TEXT_COMMAND, new EnterAction());
    // default not visible
    searchPanel.setVisible(true);
    return searchPanel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) ActionMap(javax.swing.ActionMap) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) InputMap(javax.swing.InputMap) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 55 with InputMap

use of javax.swing.InputMap in project processdash by dtuma.

the class WBSTabPanel method installKeyboardShortcuts.

/**
     * Configure a number of keyboard shortcuts for navigating within the
     * contents of the WBS tab panel
     */
private void installKeyboardShortcuts() {
    InputMap inputMap = dataTable.getInputMap();
    ActionMap actionMap = dataTable.getActionMap();
    inputMap.put(KeyStroke.getKeyStroke("HOME"), "focusTree");
    inputMap.put(KeyStroke.getKeyStroke("shift SPACE"), "focusTree");
    actionMap.put("focusTree", new TransferFocusToWbsNode());
    new MoveLeftFromDataCell().install(dataTable);
    inputMap = wbsTable.getInputMap();
    actionMap = wbsTable.getActionMap();
    inputMap.put(KeyStroke.getKeyStroke("END"), "lastDataCol");
    actionMap.put("lastDataCol", new TransferFocusToDataTable(true));
    inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "firstDataCol");
    actionMap.put("firstDataCol", new TransferFocusToDataTable(false));
    inputMap.put(KeyStroke.getKeyStroke("LEFT"), "startEditing");
    inputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputMap.put(//
    KeyStroke.getKeyStroke(//
    KeyEvent.VK_T, MacGUIUtils.getCtrlModifier()), "focusTabs");
    this.getActionMap().put("focusTabs", new TransferFocusToTabs());
}
Also used : ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap)

Aggregations

InputMap (javax.swing.InputMap)59 ActionMap (javax.swing.ActionMap)38 AbstractAction (javax.swing.AbstractAction)32 ActionEvent (java.awt.event.ActionEvent)30 Action (javax.swing.Action)18 JButton (javax.swing.JButton)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 BorderLayout (java.awt.BorderLayout)9 JPanel (javax.swing.JPanel)9 JCheckBox (javax.swing.JCheckBox)8 JDialog (javax.swing.JDialog)8 JScrollPane (javax.swing.JScrollPane)8 JTextField (javax.swing.JTextField)7 KeyStroke (javax.swing.KeyStroke)7 JComponent (javax.swing.JComponent)6 JRootPane (javax.swing.JRootPane)6 FormBuilder (com.jgoodies.forms.builder.FormBuilder)5 FormLayout (com.jgoodies.forms.layout.FormLayout)5 ComponentInputMapUIResource (javax.swing.plaf.ComponentInputMapUIResource)5 Insets (java.awt.Insets)4