Le 14/08/2013 09:23, sebb a ecrit :
On 14 August 2013 08:06,  <[email protected]> wrote:
Author: milamber
Date: Wed Aug 14 07:06:29 2013
New Revision: 1513743

URL: http://svn.apache.org/r1513743
Log:
Fix an issue with localization in Source Address Type list
Bugzilla Id: 54874

Modified:
     
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java

Modified: 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1513743&r1=1513742&r2=1513743&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
 (original)
+++ 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
 Wed Aug 14 07:06:29 2013
@@ -31,6 +31,7 @@ import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
+import java.util.LinkedHashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
@@ -197,10 +198,11 @@ public abstract class HTTPSamplerBase ex

      public static final int SOURCE_TYPE_DEVICE_IPV6 = 3;

-    public static final Map<String, Integer> getSourceTypeMap() {
-        Map<String, Integer> sourceTypeMap = new HashMap<String, Integer>(4);
-        
sourceTypeMap.put(JMeterUtils.getResString("web_testing_source_ip_device"), 
SOURCE_TYPE_DEVICE); //$NON-NLS-1$
+    // Use for ComboBox Source Address Type. LinkedHashMap to preserve order 
(specially with localization)
+    public static final LinkedHashMap<String, Integer> getSourceTypeMap() {
+        LinkedHashMap<String, Integer> sourceTypeMap = new LinkedHashMap<String, 
Integer>(4);
          
sourceTypeMap.put(JMeterUtils.getResString("web_testing_source_ip_hostname"), 
SOURCE_TYPE_IP_HOSTNAME); //$NON-NLS-1$
+        
sourceTypeMap.put(JMeterUtils.getResString("web_testing_source_ip_device"), 
SOURCE_TYPE_DEVICE); //$NON-NLS-1$
          
sourceTypeMap.put(JMeterUtils.getResString("web_testing_source_ip_device_ipv4"),
 SOURCE_TYPE_DEVICE_IPV4); //$NON-NLS-1$
          
sourceTypeMap.put(JMeterUtils.getResString("web_testing_source_ip_device_ipv6"),
 SOURCE_TYPE_DEVICE_IPV6); //$NON-NLS-1$
          return sourceTypeMap;
I'm not sure we need a Map for this - surely all that is needed is to
have an arrray (or list) of the property names in the correct order?

You are right. ArrayList is sufficient.
A simple array (String[]) seems not sufficient to find the index number from SelectedItem (the L10N string). (ArrayList have .indexOf())

The property names are only really needed for creating the drop-down
list; everything else can be done using the list index.
Otherwise we are effectively repeating code that the JComboBox already provides.

Possibly use an enum with the property name passed to the constructor
to tie the name to the index.

I'm not familiar with this? is better?



Reply via email to