Search in sources :

Example 41 with ActionMap

use of javax.swing.ActionMap 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 42 with ActionMap

use of javax.swing.ActionMap 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 43 with ActionMap

use of javax.swing.ActionMap 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)

Example 44 with ActionMap

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

the class WBSJTable method buildCustomActionMaps.

/** Populate the <tt>customActions</tt> list with actions for editing
     * the work breakdown structure. */
private void buildCustomActionMaps() {
    // Map "Tab" and "Shift-Tab" to the demote/promote actions
    customActions.add(new WbsActionMapping(KeyEvent.VK_TAB, 0, "Demote", DEMOTE_ACTION));
    customActions.add(new WbsActionMapping(KeyEvent.VK_TAB, SHIFT, "Promote", PROMOTE_ACTION));
    customActions.add(new ActionMapping(KeyEvent.VK_INSERT, 0, "Insert", INSERT_ACTION));
    customActions.add(new ActionMapping(KeyEvent.VK_ENTER, 0, "Enter", ENTER_ACTION));
    customActions.add(new ActionMapping(KeyEvent.VK_ENTER, SHIFT, "InsertAfter", INSERT_AFTER_ACTION));
    customActions.add(new ActionMapping("collapseTree", COLLAPSE_ACTION));
    customActions.add(new ActionMapping("expandTree", EXPAND_ACTION));
    customActions.add(new ActionMapping("moveTreeUp", MOVEUP_ACTION));
    customActions.add(new ActionMapping("moveTreeDown", MOVEDOWN_ACTION));
    // Find the default row navigation actions for the table, and replace
    // them with new actions which (1) perform the original action, then
    // (2) restart editing on the newly selected cell.
    InputMap inputMap = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap actionMap = getActionMap();
    List filter = Arrays.asList(new String[] { "selectPreviousRow", "selectNextRow", "selectFirstRow", "selectLastRow", "scrollUpChangeSelection", "scrollDownChangeSelection" });
    KeyStroke[] keys = inputMap.allKeys();
    for (int i = 0; i < keys.length; i++) {
        Object actionKey = inputMap.get(keys[i]);
        if (!filter.contains(actionKey))
            continue;
        Action action = actionMap.get(actionKey);
        if (action == null)
            continue;
        customActions.add(new ActionMapping(keys[i], actionKey + "-WBS", new DelegateActionRestartEditing(action, actionKey)));
    }
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionMap(javax.swing.ActionMap) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) JList(javax.swing.JList) EventObject(java.util.EventObject) Point(java.awt.Point)

Example 45 with ActionMap

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

the class WBSJTable method installTableActions.

/** Install actions that are appropriate only for the table (not for any
     * other component). */
void installTableActions() {
    InputMap inputMap = getInputMap();
    InputMap inputMap2 = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    InputMap inputMap3 = getInputMap(WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = getActionMap();
    ClipboardBridge clipboardBridge = new ClipboardBridge(this);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, CTRL), "Cut");
    actionMap.put("Cut", new WbsNodeKeystrokeDelegatingAction(CUT_ACTION, null));
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, CTRL), "Copy");
    actionMap.put("Copy", new WbsNodeKeystrokeDelegatingAction(COPY_ACTION, clipboardBridge.getCopyAction()));
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, CTRL), "Paste");
    inputMap2.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, CTRL), "Paste");
    actionMap.put("Paste", new WbsNodeKeystrokeDelegatingAction(PASTE_ACTION, clipboardBridge.getPasteAction()));
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Delete");
    actionMap.put("Delete", new WbsNodeKeystrokeDelegatingAction(DELETE_ACTION, TABLE_DELETE_ACTION));
    // the expand/collapse icons have accelerators assigned for the plus
    // and minus keys.  Register some additional accelerator keys based on
    // other places where plus and minus appear on the keyboard.
    inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, ALT), "collapseTree");
    inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, ALT), "expandTree");
    inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ALT), "expandTree");
    inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ALT | SHIFT), "expandTree");
}
Also used : ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap)

Aggregations

ActionMap (javax.swing.ActionMap)45 InputMap (javax.swing.InputMap)38 AbstractAction (javax.swing.AbstractAction)24 ActionEvent (java.awt.event.ActionEvent)20 Action (javax.swing.Action)14 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 JButton (javax.swing.JButton)11 BorderLayout (java.awt.BorderLayout)9 JDialog (javax.swing.JDialog)8 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)7 JComponent (javax.swing.JComponent)6 JTextField (javax.swing.JTextField)6 FormBuilder (com.jgoodies.forms.builder.FormBuilder)5 FormLayout (com.jgoodies.forms.layout.FormLayout)5 Component (java.awt.Component)3 Insets (java.awt.Insets)3 List (java.util.List)3 JCheckBox (javax.swing.JCheckBox)3 FlowLayout (java.awt.FlowLayout)2