Search in sources :

Example 1 with PowerTableModel

use of org.apache.jmeter.gui.util.PowerTableModel in project jmeter by apache.

the class SimpleConfigGui method createTablePanel.

/**
     * Create a GUI panel containing the table of configuration parameters.
     *
     * @return a GUI panel containing the parameter table
     */
private Component createTablePanel() {
    tableModel = new PowerTableModel(new String[] { COLUMN_NAMES_0, COLUMN_NAMES_1 }, new Class[] { String.class, String.class });
    table = new JTable(tableModel);
    JMeterUtils.applyHiDPI(table);
    table.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    return makeScrollPane(table);
}
Also used : PowerTableModel(org.apache.jmeter.gui.util.PowerTableModel) JTable(javax.swing.JTable) HeaderAsPropertyRenderer(org.apache.jmeter.gui.util.HeaderAsPropertyRenderer)

Example 2 with PowerTableModel

use of org.apache.jmeter.gui.util.PowerTableModel in project jmeter by apache.

the class AssertionGui method createStringPanel.

/**
     * Create a panel allowing the user to supply a list of string patterns to
     * test against.
     *
     * @return a new panel for adding string patterns
     */
private JPanel createStringPanel() {
    tableModel = new PowerTableModel(new String[] { COL_RESOURCE_NAME }, new Class[] { String.class });
    stringTable = new JTable(tableModel);
    stringTable.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
    stringTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JMeterUtils.applyHiDPI(stringTable);
    TextAreaCellRenderer renderer = new TextAreaCellRenderer();
    stringTable.setRowHeight(renderer.getPreferredHeight());
    stringTable.setDefaultRenderer(String.class, renderer);
    stringTable.setDefaultEditor(String.class, new TextAreaTableCellEditor());
    stringTable.setPreferredScrollableViewportSize(new Dimension(100, 70));
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    //$NON-NLS-1$
    panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_patterns_to_test")));
    panel.add(new JScrollPane(stringTable), BorderLayout.CENTER);
    panel.add(createButtonPanel(), BorderLayout.SOUTH);
    return panel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) PowerTableModel(org.apache.jmeter.gui.util.PowerTableModel) JTable(javax.swing.JTable) HeaderAsPropertyRenderer(org.apache.jmeter.gui.util.HeaderAsPropertyRenderer) TextAreaTableCellEditor(org.apache.jmeter.gui.util.TextAreaTableCellEditor) Dimension(java.awt.Dimension) TextAreaCellRenderer(org.apache.jmeter.gui.util.TextAreaCellRenderer)

Example 3 with PowerTableModel

use of org.apache.jmeter.gui.util.PowerTableModel in project jmeter by apache.

the class CookiePanel method init.

/**
     * Shows the main cookie configuration panel.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    tableModel = new PowerTableModel(COLUMN_RESOURCE_NAMES, columnClasses);
    clearEachIteration = //$NON-NLS-1$
    new JCheckBox(JMeterUtils.getResString("clear_cookies_per_iter"), false);
    policy = new JLabeledChoice(//$NON-NLS-1$
    JMeterUtils.getResString("cookie_manager_policy"), new HC4CookieHandler().getPolicies());
    setLayout(new BorderLayout());
    setBorder(makeBorder());
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
    northPanel.add(makeTitlePanel());
    JPanel optionsPane = new JPanel();
    optionsPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // $NON-NLS-1$
    JMeterUtils.getResString("cookie_options")));
    optionsPane.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
    optionsPane.add(clearEachIteration);
    JPanel policyTypePane = new JPanel();
    policyTypePane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    policyTypePane.add(policy);
    optionsPane.add(policyTypePane);
    northPanel.add(optionsPane);
    add(northPanel, BorderLayout.NORTH);
    add(createCookieTablePanel(), BorderLayout.CENTER);
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JLabeledChoice(org.apache.jorphan.gui.JLabeledChoice) HC4CookieHandler(org.apache.jmeter.protocol.http.control.HC4CookieHandler) BorderLayout(java.awt.BorderLayout) PowerTableModel(org.apache.jmeter.gui.util.PowerTableModel) VerticalLayout(org.apache.jorphan.gui.layout.VerticalLayout)

Example 4 with PowerTableModel

use of org.apache.jmeter.gui.util.PowerTableModel in project jmeter by apache.

the class ProxyControlGui method addSuggestedExcludes.

/**
     * Add suggested excludes to exclude table
     * @param table {@link JTable}
     */
protected void addSuggestedExcludes(JTable table) {
    GuiUtils.stopTableEditing(table);
    int rowCount = table.getRowCount();
    PowerTableModel model = null;
    // $NON-NLS-1$
    String[] exclusions = SUGGESTED_EXCLUSIONS.split(";");
    if (exclusions.length > 0) {
        model = (PowerTableModel) table.getModel();
        if (model != null) {
            for (String clipboardLine : exclusions) {
                model.addRow(new Object[] { clipboardLine });
            }
            if (table.getRowCount() > rowCount) {
                // Highlight (select) the appropriate rows.
                int rowToSelect = model.getRowCount() - 1;
                table.setRowSelectionInterval(rowCount, rowToSelect);
            }
        }
    }
}
Also used : PowerTableModel(org.apache.jmeter.gui.util.PowerTableModel)

Example 5 with PowerTableModel

use of org.apache.jmeter.gui.util.PowerTableModel in project jmeter by apache.

the class ProxyControlGui method addFromClipboard.

/**
     * Add values from the clipboard to table
     * @param table {@link JTable}
     */
protected void addFromClipboard(JTable table) {
    GuiUtils.stopTableEditing(table);
    int rowCount = table.getRowCount();
    PowerTableModel model = null;
    try {
        String clipboardContent = GuiUtils.getPastedText();
        if (clipboardContent != null) {
            String[] clipboardLines = clipboardContent.split(NEW_LINE);
            for (String clipboardLine : clipboardLines) {
                model = (PowerTableModel) table.getModel();
                model.addRow(new Object[] { clipboardLine });
            }
            if (table.getRowCount() > rowCount) {
                if (model != null) {
                    // Highlight (select) the appropriate rows.
                    int rowToSelect = model.getRowCount() - 1;
                    table.setRowSelectionInterval(rowCount, rowToSelect);
                }
            }
        }
    } catch (IOException ioe) {
        JOptionPane.showMessageDialog(this, // $NON-NLS-1$
        JMeterUtils.getResString("proxy_daemon_error_read_args") + "\n" + // $NON-NLS-1$  $NON-NLS-2$
        ioe.getLocalizedMessage(), // $NON-NLS-1$  $NON-NLS-2$
        JMeterUtils.getResString("error_title"), JOptionPane.ERROR_MESSAGE);
    } catch (UnsupportedFlavorException ufe) {
        JOptionPane.showMessageDialog(this, // $NON-NLS-1$
        JMeterUtils.getResString("proxy_daemon_error_not_retrieve") + SPACE + DataFlavor.stringFlavor.getHumanPresentableName() + SPACE + // $NON-NLS-1$
        JMeterUtils.getResString("proxy_daemon_error_from_clipboard") + // $NON-NLS-1$
        ufe.getLocalizedMessage(), // $NON-NLS-1$
        JMeterUtils.getResString("error_title"), JOptionPane.ERROR_MESSAGE);
    }
}
Also used : PowerTableModel(org.apache.jmeter.gui.util.PowerTableModel) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Aggregations

PowerTableModel (org.apache.jmeter.gui.util.PowerTableModel)8 BorderLayout (java.awt.BorderLayout)5 JPanel (javax.swing.JPanel)5 JTable (javax.swing.JTable)4 HeaderAsPropertyRenderer (org.apache.jmeter.gui.util.HeaderAsPropertyRenderer)4 Dimension (java.awt.Dimension)3 JScrollPane (javax.swing.JScrollPane)3 JCheckBox (javax.swing.JCheckBox)2 VerticalLayout (org.apache.jorphan.gui.layout.VerticalLayout)2 FlowLayout (java.awt.FlowLayout)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1 TextAreaCellRenderer (org.apache.jmeter.gui.util.TextAreaCellRenderer)1 TextAreaTableCellEditor (org.apache.jmeter.gui.util.TextAreaTableCellEditor)1 HC4CookieHandler (org.apache.jmeter.protocol.http.control.HC4CookieHandler)1 JLabeledChoice (org.apache.jorphan.gui.JLabeledChoice)1