use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.
the class StandardFieldsDialog method addTargetSelectField.
/*
* 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 addTargetSelectField(int tabIndex, final String fieldLabel, final Target 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);
this.setTextTarget(text, 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
Target target = value;
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
NodeSelectDialog nsd = new NodeSelectDialog(StandardFieldsDialog.this);
nsd.setAllowRoot(allowRoot);
target = nsd.showDialog(target);
setTextTarget(text, target);
targetSelected(fieldLabel, target);
}
});
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);
}
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(final String fieldLabel, final SiteNode value, final boolean editable, final boolean allowRoot) {
if (isTabbed()) {
throw new IllegalArgumentException("Initialised as a tabbed dialog - must use method with tab parameters");
}
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(fieldLabel, text, panel, 0.0D);
}
use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.
the class StandardFieldsDialog method addTextField.
public void addTextField(String fieldLabel, String value) {
if (isTabbed()) {
throw new IllegalArgumentException("Initialised as a tabbed dialog - must use method with tab parameters");
}
ZapTextField field = new ZapTextField();
if (value != null) {
field.setText(value);
}
this.addField(fieldLabel, field, field, 0.0D);
}
use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.
the class StandardFieldsDialog method addTextField.
public void addTextField(int tabIndex, String fieldLabel, String value) {
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);
}
ZapTextField field = new ZapTextField();
if (value != null) {
field.setText(value);
}
this.addField(this.tabPanels.get(tabIndex), this.tabOffsets.get(tabIndex), fieldLabel, field, field, 0.0D);
incTabOffset(tabIndex);
}
use of org.zaproxy.zap.utils.ZapTextField in project zaproxy by zaproxy.
the class DialogAddToken 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;
}
Aggregations