Search in sources :

Example 66 with JButton

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;
}
Also used : BasicTransferable(org.jdesktop.swingx.plaf.basic.core.BasicTransferable) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Transferable(java.awt.datatransfer.Transferable) BasicTransferable(org.jdesktop.swingx.plaf.basic.core.BasicTransferable) TableModel(javax.swing.table.TableModel)

Example 67 with JButton

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;
}
Also used : ActionListener(java.awt.event.ActionListener) Highlight(javax.swing.text.Highlighter.Highlight) HighlightPainter(javax.swing.text.Highlighter.HighlightPainter) JButton(javax.swing.JButton) DefaultHighlighter(javax.swing.text.DefaultHighlighter) ActionEvent(java.awt.event.ActionEvent) BadLocationException(javax.swing.text.BadLocationException) DefaultHighlighter(javax.swing.text.DefaultHighlighter) Highlighter(javax.swing.text.Highlighter)

Example 68 with JButton

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;
}
Also used : ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Example 69 with JButton

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) JButton(javax.swing.JButton)

Example 70 with JButton

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) LogPanel(org.parosproxy.paros.extension.history.LogPanel) JButton(javax.swing.JButton) ContextCreateDialog(org.zaproxy.zap.view.ContextCreateDialog)

Aggregations

JButton (javax.swing.JButton)923 JPanel (javax.swing.JPanel)408 ActionEvent (java.awt.event.ActionEvent)389 ActionListener (java.awt.event.ActionListener)317 JLabel (javax.swing.JLabel)278 JScrollPane (javax.swing.JScrollPane)166 BoxLayout (javax.swing.BoxLayout)158 FlowLayout (java.awt.FlowLayout)142 BorderLayout (java.awt.BorderLayout)138 Dimension (java.awt.Dimension)138 Insets (java.awt.Insets)114 JTextField (javax.swing.JTextField)114 GridBagLayout (java.awt.GridBagLayout)110 JCheckBox (javax.swing.JCheckBox)103 GridBagConstraints (java.awt.GridBagConstraints)95 ImageIcon (javax.swing.ImageIcon)95 JTable (javax.swing.JTable)67 JDialog (javax.swing.JDialog)65 JComboBox (javax.swing.JComboBox)56 JTextArea (javax.swing.JTextArea)56