Search in sources :

Example 36 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 37 with ActionMap

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

the class GenFieldsCustomizer method jbInit.

private void jbInit() {
    ok.setText(Localization.lang("OK"));
    ok.addActionListener(e -> okActionPerformed());
    cancel.setText(Localization.lang("Cancel"));
    cancel.addActionListener(e -> dispose());
    jLabel1.setText(Localization.lang("Delimit fields with semicolon, ex.") + ": url;pdf;note");
    jPanel3.setLayout(gridBagLayout2);
    jPanel4.setBorder(BorderFactory.createEtchedBorder());
    jPanel4.setLayout(gridBagLayout1);
    jLabel2.setText(Localization.lang("General fields"));
    setFieldsText();
    revert.setText(Localization.lang("Default"));
    revert.addActionListener(e -> revertActionPerformed());
    this.getContentPane().add(buttons, BorderLayout.SOUTH);
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(revert);
    bb.addButton(cancel);
    bb.addStrut(Sizes.DLUX5);
    bb.addButton(helpBut);
    bb.addGlue();
    this.getContentPane().add(jPanel3, BorderLayout.CENTER);
    jPanel3.add(jLabel1, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    jPanel3.add(jPanel4, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 318, 193));
    jPanel4.add(jScrollPane1, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    jScrollPane1.getViewport().add(fieldsArea, null);
    jPanel4.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    // Key bindings:
    ActionMap am = buttons.getActionMap();
    InputMap im = buttons.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) ActionMap(javax.swing.ActionMap) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) ActionEvent(java.awt.event.ActionEvent) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 38 with ActionMap

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

the class MassSetFieldAction method createDialog.

private void createDialog() {
    diag = new JDialog(frame, Localization.lang("Set/clear/rename fields"), true);
    field = new JComboBox<>();
    field.setEditable(true);
    text = new JTextField();
    text.setEnabled(false);
    renameTo = new JTextField();
    renameTo.setEnabled(false);
    JButton ok = new JButton(Localization.lang("OK"));
    JButton cancel = new JButton(Localization.lang("Cancel"));
    all = new JRadioButton(Localization.lang("All entries"));
    selected = new JRadioButton(Localization.lang("Selected entries"));
    clear = new JRadioButton(Localization.lang("Clear fields"));
    set = new JRadioButton(Localization.lang("Set fields"));
    rename = new JRadioButton(Localization.lang("Rename field to") + ":");
    rename.setToolTipText(Localization.lang("Move contents of a field into a field with a different name"));
    Set<String> allFields = frame.getCurrentBasePanel().getDatabase().getAllVisibleFields();
    for (String f : allFields) {
        field.addItem(f);
    }
    set.addChangeListener(e -> text.setEnabled(set.isSelected()));
    clear.addChangeListener(e -> overwrite.setEnabled(!clear.isSelected()));
    rename.addChangeListener(e -> renameTo.setEnabled(rename.isSelected()));
    overwrite = new JCheckBox(Localization.lang("Overwrite existing field values"), true);
    ButtonGroup bg = new ButtonGroup();
    bg.add(all);
    bg.add(selected);
    bg = new ButtonGroup();
    bg.add(clear);
    bg.add(set);
    bg.add(rename);
    FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, fill:100dlu:grow", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"));
    builder.addSeparator(Localization.lang("Field name")).xyw(1, 1, 3);
    builder.add(Localization.lang("Field name")).xy(1, 3);
    builder.add(field).xy(3, 3);
    builder.addSeparator(Localization.lang("Include entries")).xyw(1, 5, 3);
    builder.add(all).xyw(1, 7, 3);
    builder.add(selected).xyw(1, 9, 3);
    builder.addSeparator(Localization.lang("New field value")).xyw(1, 11, 3);
    builder.add(set).xy(1, 13);
    builder.add(text).xy(3, 13);
    builder.add(clear).xyw(1, 15, 3);
    builder.add(rename).xy(1, 17);
    builder.add(renameTo).xy(3, 17);
    builder.add(overwrite).xyw(1, 19, 3);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    diag.pack();
    ok.addActionListener(e -> {
        String fieldText = (String) field.getSelectedItem();
        if ((fieldText == null) || fieldText.trim().isEmpty()) {
            JOptionPane.showMessageDialog(diag, Localization.lang("You must enter at least one field name"), "", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (rename.isSelected()) {
            String[] fields = getFieldNames(fieldText);
            if (fields.length > 1) {
                JOptionPane.showMessageDialog(diag, Localization.lang("You can only rename one field at a time"), "", JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
        canceled = false;
        diag.dispose();
    });
    Action cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            canceled = true;
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelAction);
    // Key bindings:
    ActionMap am = builder.getPanel().getActionMap();
    InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelAction);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) FormBuilder(com.jgoodies.forms.builder.FormBuilder) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) JRadioButton(javax.swing.JRadioButton) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) ButtonGroup(javax.swing.ButtonGroup) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Example 39 with ActionMap

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

the class PreviewPanel method createKeyBindings.

private void createKeyBindings() {
    ActionMap actionMap = this.getActionMap();
    InputMap inputMap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final String close = "close";
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), close);
    actionMap.put(close, this.closeAction);
    final String copy = "copy";
    getInputMap(JComponent.WHEN_FOCUSED).put(Globals.getKeyPrefs().getKey(KeyBinding.COPY_PREVIEW), copy);
    actionMap.put(copy, this.copyPreviewAction);
}
Also used : ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap)

Example 40 with ActionMap

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

the class FromAuxDialog method jbInit.

private void jbInit() {
    JPanel panel1 = new JPanel();
    panel1.setLayout(new BorderLayout());
    generateButton.setText(Localization.lang("Generate"));
    generateButton.setEnabled(false);
    generateButton.addActionListener(e -> {
        generatePressed = true;
        dispose();
    });
    cancelButton.setText(Localization.lang("Cancel"));
    cancelButton.addActionListener(e -> dispose());
    parseButton.setText(Localization.lang("Parse"));
    parseButton.addActionListener(e -> parseActionPerformed());
    initPanels();
    // insert the buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    JPanel buttonPanel = bb.getPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bb.addGlue();
    bb.addButton(parseButton);
    bb.addRelatedGap();
    bb.addButton(generateButton);
    bb.addButton(cancelButton);
    bb.addGlue();
    this.setModal(true);
    this.setResizable(true);
    this.setTitle(Localization.lang("AUX file import"));
    JLabel desc = new JLabel("<html><h3>" + Localization.lang("AUX file import") + "</h3><p>" + Localization.lang("This feature generates a new library based on which entries " + "are needed in an existing LaTeX document.") + "</p>" + "<p>" + Localization.lang("You need to select one of your open libraries from which to choose " + "entries, as well as the AUX file produced by LaTeX when compiling your document.") + "</p></html>");
    desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.add(desc, BorderLayout.NORTH);
    JPanel centerPane = new JPanel(new BorderLayout());
    centerPane.add(buttons, BorderLayout.NORTH);
    centerPane.add(statusPanel, BorderLayout.CENTER);
    getContentPane().add(panel1, BorderLayout.NORTH);
    getContentPane().add(centerPane, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    // Key bindings:
    ActionMap am = statusPanel.getActionMap();
    InputMap im = statusPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ActionMap(javax.swing.ActionMap) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Aggregations

ActionMap (javax.swing.ActionMap)54 InputMap (javax.swing.InputMap)45 AbstractAction (javax.swing.AbstractAction)27 ActionEvent (java.awt.event.ActionEvent)23 Action (javax.swing.Action)14 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 JButton (javax.swing.JButton)11 BorderLayout (java.awt.BorderLayout)9 JTextField (javax.swing.JTextField)9 JDialog (javax.swing.JDialog)8 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)7 JComponent (javax.swing.JComponent)6 FormBuilder (com.jgoodies.forms.builder.FormBuilder)5 FormLayout (com.jgoodies.forms.layout.FormLayout)5 ActionListener (java.awt.event.ActionListener)5 KeyStroke (javax.swing.KeyStroke)5 AWTKeyStroke (java.awt.AWTKeyStroke)3 Component (java.awt.Component)3 Insets (java.awt.Insets)3