Search in sources :

Example 11 with ZapTextField

use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.

the class DynamicFieldsPanel method initialize.

private void initialize() {
    this.setLayout(new GridBagLayout());
    int fieldIndex = 0;
    for (String fieldName : requiredFields) {
        this.add(new JLabel("* " + fieldName + ": "), LayoutHelper.getGBC(0, fieldIndex, 1, 0.0d, 0.0d));
        ZapTextField tf = new ZapTextField();
        this.add(tf, LayoutHelper.getGBC(1, fieldIndex, 1, 1.0d, 0.0d));
        textFields.put(fieldName, tf);
        fieldIndex++;
    }
    for (String fieldName : optionalFields) {
        this.add(new JLabel(fieldName + ": "), LayoutHelper.getGBC(0, fieldIndex, 1, 0.0d, 0.0d));
        ZapTextField tf = new ZapTextField();
        this.add(tf, LayoutHelper.getGBC(1, fieldIndex, 1, 1.0d, 0.0d));
        textFields.put(fieldName, tf);
        fieldIndex++;
    }
}
Also used : GridBagLayout(java.awt.GridBagLayout) ZapTextField(org.zaproxy.zap.utils.ZapTextField) JLabel(javax.swing.JLabel)

Example 12 with ZapTextField

use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.

the class OptionsLangPanel method getFileTextField.

private ZapTextField getFileTextField() {
    if (fileTextField == null) {
        fileTextField = new ZapTextField();
        fileTextFieldDoc = fileTextField.getDocument();
        fileTextFieldDoc.addDocumentListener(new DocumentListener() {

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

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

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

            private void updated(DocumentEvent e) {
                try {
                    String inputString = e.getDocument().getText(0, e.getDocument().getLength());
                    importButton.setEnabled(inputString.endsWith(".zaplang"));
                } catch (BadLocationException e1) {
                //logger.error(e1.getMessage());
                }
            }
        });
    }
    return fileTextField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ZapTextField(org.zaproxy.zap.utils.ZapTextField) DocumentEvent(javax.swing.event.DocumentEvent) BadLocationException(javax.swing.text.BadLocationException)

Example 13 with ZapTextField

use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.

the class DialogAddDomainAlwaysInScope method getDomainTextField.

protected ZapTextField getDomainTextField() {
    if (domainTextField == null) {
        domainTextField = new ZapTextField(25);
        domainTextField.getDocument().addDocumentListener(getConfirmButtonValidatorDocListener());
    }
    return domainTextField;
}
Also used : ZapTextField(org.zaproxy.zap.utils.ZapTextField)

Example 14 with ZapTextField

use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.

the class ExcludedParameterAddDialog method getNameTextField.

protected ZapTextField getNameTextField() {
    if (nameTextField == null) {
        nameTextField = new ZapTextField(25);
        nameTextField.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(getNameTextField().getDocument().getLength() > 0);
            }
        });
    }
    return nameTextField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ZapTextField(org.zaproxy.zap.utils.ZapTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Example 15 with ZapTextField

use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.

the class StandardFieldsDialog method addNodeSelectField.

/*
	 * Add a 'node select' field which provides a button for showing a Node Select Dialog and a 
	 * non editable field for showing the node selected
	 */
public void addNodeSelectField(int tabIndex, final String fieldLabel, final SiteNode value, final boolean editable, final boolean allowRoot) {
    if (!isTabbed()) {
        throw new IllegalArgumentException("Not initialised as a tabbed dialog - must use method without tab parameters");
    }
    if (tabIndex < 0 || tabIndex >= this.tabPanels.size()) {
        throw new IllegalArgumentException("Invalid tab index: " + tabIndex);
    }
    final ZapTextField text = new ZapTextField();
    text.setEditable(editable);
    if (value != null) {
        text.setText(getNodeText(value));
    }
    JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
    // Globe icon
    selectButton.setIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")));
    selectButton.addActionListener(new java.awt.event.ActionListener() {

        // Keep a local copy so that we can always select the last node chosen
        SiteNode node = value;

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            NodeSelectDialog nsd = new NodeSelectDialog(StandardFieldsDialog.this);
            nsd.setAllowRoot(allowRoot);
            SiteNode node = nsd.showDialog(this.node);
            if (node != null) {
                text.setText(getNodeText(node));
                this.node = node;
                siteNodeSelected(fieldLabel, node);
            }
        }
    });
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    panel.add(text, LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4)));
    panel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4)));
    this.addField(this.tabPanels.get(tabIndex), this.tabOffsets.get(tabIndex), fieldLabel, text, panel, 0.0D);
    this.incTabOffset(tabIndex);
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent) ZapTextField(org.zaproxy.zap.utils.ZapTextField) SiteNode(org.parosproxy.paros.model.SiteNode)

Aggregations

ZapTextField (org.zaproxy.zap.utils.ZapTextField)33 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 DocumentEvent (javax.swing.event.DocumentEvent)7 DocumentListener (javax.swing.event.DocumentListener)7 GridBagLayout (java.awt.GridBagLayout)6 JPanel (javax.swing.JPanel)6 JButton (javax.swing.JButton)5 Insets (java.awt.Insets)4 ImageIcon (javax.swing.ImageIcon)3 JLabel (javax.swing.JLabel)3 KeyEvent (java.awt.event.KeyEvent)2 JScrollPane (javax.swing.JScrollPane)2 SiteNode (org.parosproxy.paros.model.SiteNode)2 KeyAdapter (java.awt.event.KeyAdapter)1 KeyListener (java.awt.event.KeyListener)1 File (java.io.File)1 GroupLayout (javax.swing.GroupLayout)1 JFileChooser (javax.swing.JFileChooser)1 JPasswordField (javax.swing.JPasswordField)1