Search in sources :

Example 1 with ParamAddinInterface

use of org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinInterface in project zaproxy by zaproxy.

the class HttpPanelParamTableModel method setValueAt.

@Override
public void setValueAt(Object value, int row, int col) {
    boolean changed = false;
    HtmlParameter htmlParameter = allParams.get(row);
    if (col == 0) {
        htmlParameter.setType((HtmlParameter.Type) value);
        changed = true;
    } else if (col == 1) {
        htmlParameter.setName((String) value);
        changed = true;
    } else if (col == 2) {
        htmlParameter.setValue((String) value);
        changed = true;
    } else if (col == 3) {
        if (value instanceof ParamAddinInterface) {
            try {
                htmlParameter.setValue(((ParamAddinInterface) value).convertData(htmlParameter.getValue()));
                changed = true;
                col = 2;
            } catch (UnsupportedEncodingException e) {
                log.warn(e.getMessage(), e);
            }
        }
    }
    if (changed) {
        hasChanged = true;
        this.fireTableCellUpdated(row, col);
    }
    if (row == allParams.size() - 1) {
        htmlParameter = allParams.getLast();
        if (!(htmlParameter.getName().isEmpty() && htmlParameter.getValue().isEmpty())) {
            allParams.add(getDefaultHtmlParameter());
            this.fireTableRowsInserted(row + 1, row + 1);
        }
    }
}
Also used : ParamAddinInterface(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinInterface) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HtmlParameter(org.parosproxy.paros.network.HtmlParameter)

Example 2 with ParamAddinInterface

use of org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinInterface in project zaproxy by zaproxy.

the class HttpPanelParamTableView method initAddins.

private void initAddins() {
    // Get all addins
    addins = new LinkedList<>();
    addins.add(new ParamAddinMagic());
    addins.add(new ParamAddinUrlencode());
    comboBoxAddIns = new JComboBox<>();
    comboBoxAddIns.addItem(ADD_INS);
    for (ParamAddinInterface addin : addins) {
        comboBoxAddIns.addItem(addin);
    }
    comboBoxAddIns.addActionListener(new ComboBoxAddinsActionListener());
    table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(getComboBoxTypes()));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    if (table.getColumnCount() != 4) {
        return;
    }
    table.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(comboBoxAddIns));
    table.getColumnModel().getColumn(3).setCellRenderer(new ComboBoxCellRenderer(comboBoxAddIns));
}
Also used : ParamAddinInterface(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinInterface) ParamAddinMagic(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinMagic) ParamAddinUrlencode(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinUrlencode) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

ParamAddinInterface (org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinInterface)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1 HtmlParameter (org.parosproxy.paros.network.HtmlParameter)1 ParamAddinMagic (org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinMagic)1 ParamAddinUrlencode (org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinUrlencode)1