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) {
validateTabbed(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"));
selectButton.setIcon(// Globe icon
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);
}
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) {
validateNotTabbed();
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"));
selectButton.setIcon(// Globe icon
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 addFileSelectField.
public void addFileSelectField(int tabIndex, final String fieldLabel, final File dir, final int mode, final FileFilter filter) {
validateTabbed(tabIndex);
final ZapTextField text = new ZapTextField();
text.setEditable(false);
if (dir != null) {
text.setText(dir.getAbsolutePath());
}
final StandardFieldsDialog sfd = this;
JButton selectButton = new JButton("...");
selectButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
JFileChooser chooser = new JFileChooser(dir);
chooser.setFileSelectionMode(mode);
if (filter != null) {
chooser.setFileFilter(filter);
}
int rc = chooser.showSaveDialog(sfd);
if (rc == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
if (file == null) {
return;
}
text.setText(file.getAbsolutePath());
}
}
});
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);
}
Aggregations