use of javax.swing.JButton in project zaproxy by zaproxy.
the class ScanProgressDialog method getCopyToClipboardButton.
private JButton getCopyToClipboardButton() {
if (copyToClipboardButton == null) {
copyToClipboardButton = new JButton(Constant.messages.getString("ascan.progress.copyclipboard.button.label"));
copyToClipboardButton.setToolTipText(Constant.messages.getString("ascan.progress.copyclipboard.button.tooltip"));
copyToClipboardButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
// Mimics the implementation of BasicTableUI.TableTransferHandler.createTransferable(JComponent) but copies
// all rows (including column names), not just selected rows/columns (which are none in this case).
StringBuilder plainContent = new StringBuilder();
StringBuilder htmlContent = new StringBuilder();
htmlContent.append("<html>\n<body>\n<table>\n");
TableModel tableModel = getMainPanel().getModel();
htmlContent.append("<tr>\n");
for (int col = 0; col < tableModel.getColumnCount(); col++) {
String val = tableModel.getColumnName(col);
plainContent.append(val).append('\t');
htmlContent.append(" <td>").append(val).append("</td>\n");
}
plainContent.deleteCharAt(plainContent.length() - 1).append("\n");
htmlContent.append("</tr>\n");
for (int row = 0; row < tableModel.getRowCount(); row++) {
htmlContent.append("<tr>\n");
for (int col = 0; col < tableModel.getColumnCount(); col++) {
Object obj = tableModel.getValueAt(row, col);
String val = (obj == null) ? "" : obj.toString();
plainContent.append(val).append('\t');
htmlContent.append(" <td>").append(val).append("</td>\n");
}
plainContent.deleteCharAt(plainContent.length() - 1).append("\n");
htmlContent.append("</tr>\n");
}
plainContent.deleteCharAt(plainContent.length() - 1);
htmlContent.append("</table>\n</body>\n</html>");
Transferable transferable = new BasicTransferable(plainContent.toString(), htmlContent.toString());
try {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
} catch (IllegalStateException e) {
View.getSingleton().showWarningDialog(ScanProgressDialog.this, Constant.messages.getString("ascan.progress.copyclipboard.error"));
log.warn("Failed to copy the contents to clipboard:", e);
}
}
});
}
return copyToClipboardButton;
}
use of javax.swing.JButton in project zaproxy by zaproxy.
the class CustomScanDialog method getAddCustomButton.
private JButton getAddCustomButton() {
if (addCustomButton == null) {
addCustomButton = new JButton(Constant.messages.getString("ascan.custom.button.pt.add"));
addCustomButton.setEnabled(false);
addCustomButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
// Add the selected injection point
int userDefStart = getRequestField().getSelectionStart();
if (userDefStart >= 0) {
int userDefEnd = getRequestField().getSelectionEnd();
Highlighter hl = getRequestField().getHighlighter();
HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.RED);
try {
Highlight hlt = (Highlight) hl.addHighlight(userDefStart, userDefEnd, painter);
injectionPointModel.addElement(hlt);
// Unselect the text
getRequestField().setSelectionStart(userDefEnd);
getRequestField().setSelectionEnd(userDefEnd);
getRequestField().getCaret().setVisible(true);
} catch (BadLocationException e1) {
logger.error(e1.getMessage(), e1);
}
}
}
});
}
return addCustomButton;
}
use of javax.swing.JButton in project zaproxy by zaproxy.
the class ManualHttpRequestEditorDialog method getManualSendPanel.
@Override
protected Component getManualSendPanel() {
if (requestResponsePanel == null) {
requestResponsePanel = new RequestResponsePanel(configurationKey, getRequestPanel(), getResponsePanel());
if (helpKey != null) {
JButton helpButton = new JButton();
helpButton.setIcon(ExtensionHelp.HELP_ICON);
helpButton.setToolTipText(Constant.messages.getString("help.dialog.button.tooltip"));
helpButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
ExtensionHelp.showHelp(helpKey);
}
});
requestResponsePanel.addToolbarButton(helpButton);
}
requestResponsePanel.addEndButton(getBtnSend());
requestResponsePanel.addSeparator();
requestResponsePanel.loadConfig();
}
return requestResponsePanel;
}
use of javax.swing.JButton in project zaproxy by zaproxy.
the class AbstractParamContainerPanel method getHelpButton.
/**
* Gets the button that allows to show the help page of the panel.
*
* @return the button to show the help page of the panel, never {@code null}.
* @see #getShowHelpAction()
*/
private JButton getHelpButton() {
if (btnHelp == null) {
btnHelp = new JButton();
btnHelp.setBorder(null);
// help icon
btnHelp.setIcon(new ImageIcon(AbstractParamContainerPanel.class.getResource("/resource/icon/16/201.png")));
btnHelp.addActionListener(getShowHelpAction());
btnHelp.setToolTipText(Constant.messages.getString("menu.help"));
}
return btnHelp;
}
use of javax.swing.JButton in project zaproxy by zaproxy.
the class SiteMapPanel method getCreateContextButton.
private JButton getCreateContextButton() {
if (createContextButton == null) {
createContextButton = new JButton();
createContextButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(LogPanel.class.getResource("/resource/icon/fugue/application-blue-plus.png"))));
createContextButton.setToolTipText(Constant.messages.getString("menu.file.context.create"));
createContextButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
ContextCreateDialog ccd = new ContextCreateDialog(View.getSingleton().getMainFrame());
ccd.setVisible(true);
}
});
}
return createContextButton;
}
Aggregations