Search in sources :

Example 6 with DocumentListener

use of javax.swing.event.DocumentListener in project gradle by gradle.

the class SearchPanel method createTextToMatchField.

private Component createTextToMatchField() {
    textToMatchField = new JTextField();
    textToMatchField.setMinimumSize(new Dimension(50, 10));
    //escape closes this dialog
    textToMatchField.registerKeyboardAction(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    //hook up the key strokes that perform the search
    ActionListener performSearchNextAction = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            goToNextMatch();
        }
    };
    //hook up the key strokes that perform the search
    ActionListener performSearchPreviousAction = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            goToPreviousMatch();
        }
    };
    textToMatchField.registerKeyboardAction(performSearchNextAction, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    //F3 and Shift F3
    textToMatchField.registerKeyboardAction(performSearchNextAction, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    textToMatchField.registerKeyboardAction(performSearchPreviousAction, KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    //as the user types, perform a 'continue' search.
    textToMatchField.getDocument().addDocumentListener(new DocumentListener() {

        public void insertUpdate(DocumentEvent e) {
            requestSearch();
        }

        public void removeUpdate(DocumentEvent e) {
            requestSearch();
        }

        public void changedUpdate(DocumentEvent e) {
            requestSearch();
        }
    });
    return textToMatchField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent)

Example 7 with DocumentListener

use of javax.swing.event.DocumentListener in project gradle by gradle.

the class SwingEditFavoriteInteraction method createMainPanel.

private Component createMainPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    fullCommandLineTextField = new JTextField();
    displayNameTextField = new JTextField();
    alwaysShowOutputCheckBox = new JCheckBox("Always Show Live Output");
    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Command Line")));
    panel.add(Utility.addLeftJustifiedComponent(fullCommandLineTextField));
    panel.add(Box.createVerticalStrut(10));
    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Display Name")));
    panel.add(Utility.addLeftJustifiedComponent(displayNameTextField));
    panel.add(Box.createVerticalStrut(10));
    panel.add(Utility.addLeftJustifiedComponent(alwaysShowOutputCheckBox));
    panel.add(Box.createVerticalGlue());
    //create some listeners that we can use for synchronization purposes.
    synchronizationDocumentListener = new DocumentListener() {

        public void insertUpdate(DocumentEvent documentEvent) {
            setDisplayNameTextToCommandLineText();
        }

        public void removeUpdate(DocumentEvent documentEvent) {
            setDisplayNameTextToCommandLineText();
        }

        public void changedUpdate(DocumentEvent documentEvent) {
            setDisplayNameTextToCommandLineText();
        }
    };
    synchronizationKeyAdapter = new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent keyEvent) {
            //the user typed something. Remove the document listener
            fullCommandLineTextField.getDocument().removeDocumentListener(synchronizationDocumentListener);
            //and we don't need this anymore either
            displayNameTextField.removeKeyListener(synchronizationKeyAdapter);
        }
    };
    return panel;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 8 with DocumentListener

use of javax.swing.event.DocumentListener in project zaproxy by zaproxy.

the class ManageAddOnsDialog method createFilterPanel.

private static JPanel createFilterPanel(final JXTable table) {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new GridBagLayout());
    JLabel filterLabel = new JLabel(Constant.messages.getString("cfu.label.addons.filter"));
    final JTextField filterTextField = new JTextField();
    filterLabel.setLabelFor(filterTextField);
    filterPanel.add(filterLabel, LayoutHelper.getGBC(0, 0, 1, 0.0D));
    filterPanel.add(filterTextField, LayoutHelper.getGBC(1, 0, 1, 1.0D));
    String tooltipText = Constant.messages.getString("cfu.label.addons.filter.tooltip");
    filterLabel.setToolTipText(tooltipText);
    filterTextField.setToolTipText(tooltipText);
    // Set filter listener
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateFilter();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateFilter();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateFilter();
        }

        public void updateFilter() {
            String filterText = filterTextField.getText();
            if (filterText.isEmpty()) {
                table.setRowFilter(null);
                filterTextField.setForeground(UIManager.getColor("TextField.foreground"));
            } else {
                try {
                    table.setRowFilter(RowFilter.regexFilter("(?i)" + filterText));
                    filterTextField.setForeground(UIManager.getColor("TextField.foreground"));
                } catch (PatternSyntaxException e) {
                    filterTextField.setForeground(Color.RED);
                }
            }
        }
    });
    return filterPanel;
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 9 with DocumentListener

use of javax.swing.event.DocumentListener in project zaproxy by zaproxy.

the class DialogAddToken method getRegexTextField.

protected ZapTextField getRegexTextField() {
    if (regexTextField == null) {
        regexTextField = new ZapTextField(25);
        regexTextField.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void removeUpdate(DocumentEvent e) {
                checkAndEnableConfirmButton();
            }

            @Override
            public void insertUpdate(DocumentEvent e) {
                checkAndEnableConfirmButton();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                checkAndEnableConfirmButton();
            }

            private void checkAndEnableConfirmButton() {
                setConfirmButtonEnabled(getRegexTextField().getDocument().getLength() > 0);
            }
        });
    }
    return regexTextField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ZapTextField(org.zaproxy.zap.utils.ZapTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Example 10 with DocumentListener

use of javax.swing.event.DocumentListener in project zaproxy by zaproxy.

the class EncodeDecodeDialog method getInputField.

private ZapTextArea getInputField() {
    if (inputField == null) {
        inputField = newField(true);
        inputField.setName(ENCODE_DECODE_FIELD);
        inputField.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void insertUpdate(DocumentEvent documentEvent) {
                updateEncodeDecodeFields();
            }

            @Override
            public void removeUpdate(DocumentEvent documentEvent) {
                updateEncodeDecodeFields();
            }

            @Override
            public void changedUpdate(DocumentEvent documentEvent) {
            }
        });
        inputField.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                if (SwingUtilities.isRightMouseButton(e)) {
                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });
    }
    return inputField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

DocumentListener (javax.swing.event.DocumentListener)55 DocumentEvent (javax.swing.event.DocumentEvent)53 ActionEvent (java.awt.event.ActionEvent)19 ActionListener (java.awt.event.ActionListener)17 JTextField (javax.swing.JTextField)14 JPanel (javax.swing.JPanel)12 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)9 JCheckBox (javax.swing.JCheckBox)8 ZapTextField (org.zaproxy.zap.utils.ZapTextField)7 Dimension (java.awt.Dimension)6 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)5 GridBagLayout (java.awt.GridBagLayout)5 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)4 BorderLayout (java.awt.BorderLayout)4 GridBagConstraints (java.awt.GridBagConstraints)4 KeyEvent (java.awt.event.KeyEvent)4 JTextArea (javax.swing.JTextArea)4 DocumentAdapter (com.intellij.ui.DocumentAdapter)3 Insets (java.awt.Insets)3