On 14 January 2016 at 13:47,  <[email protected]> wrote:
> Author: pmouawad
> Date: Thu Jan 14 13:47:34 2016
> New Revision: 1724608
>
> URL: http://svn.apache.org/viewvc?rev=1724608&view=rev
> Log:
> Bug 58860 - HTTP Request : Add automatic variable generation in HTTP 
> parameters table by right click
> #resolve #76
> Bugzilla Id: 58860
>
> Modified:
>     jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java
>     jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
>     jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
>     
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
>     jmeter/trunk/xdocs/changes.xml
>
> Modified: 
> jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java
> URL: 
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java?rev=1724608&r1=1724607&r2=1724608&view=diff
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java 
> (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java 
> Thu Jan 14 13:47:34 2016
> @@ -674,7 +674,7 @@ public class ArgumentsPanel extends Abst
>      /**
>       * Initialize the components and layout of this component.
>       */
> -    private void init() {
> +    protected void init() {

-1

init() is called from the constructor and must not be overridden.

If such methods are overriden by subclasses, then it's possible that
the subclass will see a partially constructed object.
This can cause all sorts of odd behaviour.

The init() method must either remain private or be marked final.

>          JPanel p = this;
>
>          if (standalone) {
>
> Modified: 
> jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
> URL: 
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1724608&r1=1724607&r2=1724608&view=diff
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
> (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Thu 
> Jan 14 13:47:34 2016
> @@ -1167,6 +1167,7 @@ tr=Turkish
>  transaction_controller_include_timers=Include duration of timer and pre-post 
> processors in generated sample
>  transaction_controller_parent=Generate parent sample
>  transaction_controller_title=Transaction Controller
> +transform_into_variable=Replace values with variables
>  unbind=Thread Unbind
>  undo=Undo
>  unescape_html_string=String to unescape
>
> Modified: 
> jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
> URL: 
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1724608&r1=1724607&r2=1724608&view=diff
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties 
> (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties 
> Thu Jan 14 13:47:34 2016
> @@ -1152,6 +1152,7 @@ tr=Turc
>  transaction_controller_include_timers=Inclure la dur\u00E9e des compteurs de 
> temps et pre/post processeurs dans le calcul du temps
>  transaction_controller_parent=G\u00E9n\u00E9rer en \u00E9chantillon parent
>  transaction_controller_title=Contr\u00F4leur Transaction
> +transform_into_variable=Remplacer les valeurs par des variables
>  unbind=D\u00E9connexion de l'unit\u00E9
>  undo=Annuler
>  unescape_html_string=Cha\u00EEne \u00E0 \u00E9chapper
>
> Modified: 
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
> URL: 
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java?rev=1724608&r1=1724607&r2=1724608&view=diff
> ==============================================================================
> --- 
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
>  (original)
> +++ 
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
>  Thu Jan 14 13:47:34 2016
> @@ -18,11 +18,16 @@
>
>  package org.apache.jmeter.protocol.http.gui;
>
> +import java.awt.event.ActionEvent;
> +import java.awt.event.ActionListener;
>  import java.util.Iterator;
>
> +import javax.swing.JMenuItem;
> +import javax.swing.JPopupMenu;
>  import javax.swing.JTable;
>
>  import org.apache.commons.lang3.BooleanUtils;
> +import org.apache.commons.lang3.StringUtils;
>  import org.apache.jmeter.config.Argument;
>  import org.apache.jmeter.config.Arguments;
>  import org.apache.jmeter.config.gui.ArgumentsPanel;
> @@ -160,6 +165,41 @@ public class HTTPArgumentsPanel extends
>
>          return argument;
>      }
> +
> +    @Override
> +    protected void init() {
> +        super.init();
> +
> +        // register the right click menu
> +        JTable table = getTable();
> +        final JPopupMenu popupMenu = new JPopupMenu();
> +        JMenuItem variabilizeItem = new 
> JMenuItem(JMeterUtils.getResString("transform_into_variable"));
> +        variabilizeItem.addActionListener(new ActionListener() {
> +            @Override
> +            public void actionPerformed(ActionEvent e) {
> +                transformNameIntoVariable();
> +            }
> +        });
> +        popupMenu.add(variabilizeItem);
> +        table.setComponentPopupMenu(popupMenu);
> +    }
>
> +    /**
> +     * replace the argument value of the selection with a variable
> +     * the variable name is derived from the parameter name
> +     */
> +    private void transformNameIntoVariable() {
> +        int[] rowsSelected = getTable().getSelectedRows();
> +        for (int i = 0; i < rowsSelected.length; i++) {
> +            String name = (String) tableModel.getValueAt(rowsSelected[i], 0);
> +            if(StringUtils.isNotBlank(name)) {
> +                name = name.trim();
> +                name = name.replaceAll("\\$", "_");
> +                name = name.replaceAll("\\{", "_");
> +                name = name.replaceAll("\\}", "_");
> +                tableModel.setValueAt("${"+name+"}", rowsSelected[i], 1);
> +            }
> +        }
> +    }
>
>  }
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL: 
> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1724608&r1=1724607&r2=1724608&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml (original)
> +++ jmeter/trunk/xdocs/changes.xml Thu Jan 14 13:47:34 2016
> @@ -98,6 +98,7 @@ Summary
>      <li><bug>57995</bug>Use FileServer for HTTP Request files. Implemented 
> by Andrey Pokhilko (andrey at blazemeter.com) and contributed by BlazeMeter 
> Ltd.</li>
>      <li><bug>58811</bug>When pasting arguments between http samplers the 
> column "Encode" and "Include Equals" are lost. Contributed by Benoit Wiart 
> (benoit dot wiart at gmail.com)</li>
>      <li><bug>58843</bug>Improve the usable space in the HTTP sampler GUI. 
> Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
> +    <li><bug>58860</bug>HTTP Request : Add automatic variable generation in 
> HTTP parameters table by right click. Contributed by Benoit Wiart (benoit dot 
> wiart at gmail.com)</li>
>  </ul>
>
>  <h3>Other samplers</h3>
>
>

Reply via email to