jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1752526 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java xdocs/changes.xml
Date Wed, 13 Jul 2016 19:22:24 GMT
Author: fschumacher
Date: Wed Jul 13 19:22:24 2016
New Revision: 1752526

URL: http://svn.apache.org/viewvc?rev=1752526&view=rev
Log:
Allow multiple selection and delete in HTTP Authorization Manager.
Based on a patch by Benoit Wiart (b.wiart at ubik-ingenierie.com).

Closes #212 on github.

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java?rev=1752526&r1=1752525&r2=1752526&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java Wed
Jul 13 19:22:24 2016
@@ -178,47 +178,65 @@ public class AuthPanel extends AbstractC
         add(createAuthTablePanel(), BorderLayout.CENTER);
     }
 
-    @Override
-    public void actionPerformed(ActionEvent e) {
-        String action = e.getActionCommand();
+    /**
+     * Remove the currently selected argument from the table.
+     */
+    protected void deleteRows() {
+        // If a table cell is being edited, we must cancel the editing
+        // before deleting the row.
+        cancelEditing();
+
+        int[] rowsSelected = authTable.getSelectedRows();
+        int anchorSelection = authTable.getSelectionModel().getAnchorSelectionIndex();
+        authTable.clearSelection();
+        if (rowsSelected.length > 0) {
+            for (int i = rowsSelected.length - 1; i >= 0; i--) {
+                tableModel.removeRow(rowsSelected[i]);
+            }
+            tableModel.fireTableDataChanged();
 
-        if (action.equals(DELETE_COMMAND)) {
+            // Table still contains one or more rows, so highlight (select)
+            // the appropriate one.
             if (tableModel.getRowCount() > 0) {
-                // If a table cell is being edited, we must cancel the editing
-                // before deleting the row.
-                if (authTable.isEditing()) {
-                    TableCellEditor cellEditor = authTable.getCellEditor(authTable.getEditingRow(),
authTable
-                            .getEditingColumn());
-                    cellEditor.cancelCellEditing();
+                if (anchorSelection >= tableModel.getRowCount()) {
+                    anchorSelection = tableModel.getRowCount() - 1;
                 }
+                authTable.setRowSelectionInterval(anchorSelection, anchorSelection);
+            }
 
-                int rowSelected = authTable.getSelectedRow();
+            checkButtonsStatus();
+        }
+    }
 
-                if (rowSelected != -1) {
-                    tableModel.removeRow(rowSelected);
-                    tableModel.fireTableDataChanged();
+    /**
+     * If a table cell is being edited, we must cancel the editing before deleting the row
+     */
+    private void cancelEditing() {
+        if (authTable.isEditing()) {
+            TableCellEditor cellEditor = authTable.getCellEditor(authTable.getEditingRow(),
authTable.getEditingColumn());
+            cellEditor.cancelCellEditing();
+        }
+    }
 
-                    // Disable the DELETE and SAVE buttons if no rows remaining
-                    // after delete.
-                    if (tableModel.getRowCount() == 0) {
-                        deleteButton.setEnabled(false);
-                        saveButton.setEnabled(false);
-                    }
-
-                    // Table still contains one or more rows, so highlight
-                    // (select) the appropriate one.
-                    else {
-                        int rowToSelect = rowSelected;
-
-                        if (rowSelected >= tableModel.getRowCount()) {
-                            rowToSelect = rowSelected - 1;
-                        }
+    private void checkButtonsStatus() {
+        // Disable DELETE if there are no rows in the table to delete.
+        if (tableModel.getRowCount() == 0) {
+            deleteButton.setEnabled(false);
+            saveButton.setEnabled(false);
+        } else {
+            deleteButton.setEnabled(true);
+            saveButton.setEnabled(true);
+        }
+    }
 
-                        authTable.setRowSelectionInterval(rowToSelect, rowToSelect);
-                    }
-                }
-            }
-        } else if (action.equals(ADD_COMMAND)) {
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        String action = e.getActionCommand();
+
+        if (action.equals(DELETE_COMMAND)) {
+            deleteRows();
+        }
+        else if (action.equals(ADD_COMMAND)) {
             // If a table cell is being edited, we should accept the current
             // value and stop the editing before adding a new row.
             GuiUtils.stopTableEditing(authTable);
@@ -226,14 +244,7 @@ public class AuthPanel extends AbstractC
             tableModel.addNewRow();
             tableModel.fireTableDataChanged();
 
-            // Enable the DELETE and SAVE buttons if they are currently
-            // disabled.
-            if (!deleteButton.isEnabled()) {
-                deleteButton.setEnabled(true);
-            }
-            if (!saveButton.isEnabled()) {
-                saveButton.setEnabled(true);
-            }
+            checkButtonsStatus();
 
             // Highlight (select) the appropriate row.
             int rowToSelect = tableModel.getRowCount() - 1;
@@ -246,13 +257,10 @@ public class AuthPanel extends AbstractC
                     tableModel.manager.addFile(dialog.getSelectedFile().getAbsolutePath());
                     tableModel.fireTableDataChanged();
 
-                    if (tableModel.getRowCount() > 0) {
-                        deleteButton.setEnabled(true);
-                        saveButton.setEnabled(true);
-                    }
+                    checkButtonsStatus();
                 }
             } catch (IOException ex) {
-                log.error("", ex);
+                log.error("Error loading auth data", ex);
             }
         } else if (action.equals(SAVE_COMMAND)) {
             try {
@@ -271,7 +279,7 @@ public class AuthPanel extends AbstractC
         authTable = new JTable(tableModel);
         JMeterUtils.applyHiDPI(authTable);
         authTable.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
-        authTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        authTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         authTable.setPreferredScrollableViewportSize(new Dimension(100, 70));
 
         TableColumn passwordColumn = authTable.getColumnModel().getColumn(AuthManager.COL_PASSWORD);

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1752526&r1=1752525&r2=1752526&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Jul 13 19:22:24 2016
@@ -101,6 +101,7 @@ Summary
 <ul>
     <li><bug>59609</bug>Format extracted JSON Objects in JSON Post Processor
correctly as JSON.</li>
     <li><bug>59845</bug>Log messages about JSON Path mismatches at <code>debug</code>
level instead of <code>error</code>.</li>
+    <li><pr>212</pr>Allow multiple selection and delete in HTTP Authorization
Manager. Based on a patch by Benoit Wiart (b.wiart at ubik-ingenierie.com)</li>
 </ul>
 
 <h3>Functions</h3>
@@ -182,6 +183,7 @@ Summary
 <li>Graham Russell (graham at ham1.co.uk)</li>
 <li>Teemu Vesala (teemu.vesala at qentinel.com)</li>
 <li>Asier Lostalé</li>
+<li>Benoit Wiart (b.wiart at ubik-ingenierie.com)</li>
 </ul>
 <p>We also thank bug reporters who helped us improve JMeter. <br/>
 For this release we want to give special thanks to the following reporters for the clear
reports and tests made after our fixes:</p>



Mime
View raw message