jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1514547 - in /jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui: EnumEditor.java GenericTestBeanCustomizer.java TypeEditor.java
Date Fri, 16 Aug 2013 00:37:24 GMT
Author: sebb
Date: Fri Aug 16 00:37:24 2013
New Revision: 1514547

URL: http://svn.apache.org/r1514547
Log:
Need GUI Editor to process fields which are based on Enums with localised display strings
Better invocation strategy - pass in enum class and resource bundle
Bugzilla Id: 55241

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/EnumEditor.java
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TypeEditor.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/EnumEditor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/EnumEditor.java?rev=1514547&r1=1514546&r2=1514547&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/EnumEditor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/EnumEditor.java Fri Aug 16 00:37:24
2013
@@ -33,8 +33,6 @@ import org.apache.jmeter.gui.ClearGui;
  * <p>
  * The provided GUI is a combo box with an option for each value in the enum.
  * <p>
- * The resource bundle must be provided by the attribute
- * GenericTestBeanCustomizer.RESOURCE_BUNDLE
  */
 class EnumEditor extends PropertyEditorSupport implements ClearGui {
 
@@ -42,26 +40,20 @@ class EnumEditor extends PropertyEditorS
 
     private final DefaultComboBoxModel model;
 
-    private final Enum<?>[] eNum;
-
-    private final ResourceBundle rb;
-
     private final int defaultIndex;
 
-    public EnumEditor(PropertyDescriptor descriptor) {
+    public EnumEditor(final PropertyDescriptor descriptor, final Class<? extends Enum<?>>
enumClazz, final ResourceBundle rb) {
         model = new DefaultComboBoxModel();
         combo = new JComboBox(model);
         combo.setEditable(false);
-        rb = (ResourceBundle) descriptor.getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
-        eNum = (Enum<?>[]) descriptor.getValue(GenericTestBeanCustomizer.TAGS);
-        for(Enum<?> e : eNum) {
+        for(Enum<?> e : enumClazz.getEnumConstants()) {
             model.addElement(rb.getObject(e.toString()));
         }
         Enum<?> def = (Enum<?>) descriptor.getValue(GenericTestBeanCustomizer.DEFAULT);
         if (def != null) {
-            this.defaultIndex = def.ordinal();
+            defaultIndex = def.ordinal();
         } else {
-            this.defaultIndex = 0;
+            defaultIndex = 0;
         }
         combo.setSelectedIndex(defaultIndex);
     }

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java?rev=1514547&r1=1514546&r2=1514547&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java Fri
Aug 16 00:37:24 2013
@@ -225,6 +225,10 @@ public class GenericTestBeanCustomizer e
             Object guiType = descriptor.getValue(GUITYPE);
             if (guiType instanceof TypeEditor) {
                 propertyEditor = ((TypeEditor) guiType).getInstance(descriptor);
+            } else if (guiType instanceof Class && Enum.class.isAssignableFrom((Class<?>)
guiType)) {
+                    @SuppressWarnings("unchecked") // we check the class type above
+                    final Class<? extends Enum<?>> enumClass = (Class<? extends
Enum<?>>) guiType;
+                    propertyEditor = new EnumEditor(descriptor, enumClass, (ResourceBundle)
descriptor.getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE));
             } else {
                 Class<?> editorClass = descriptor.getPropertyEditorClass();
                 if (log.isDebugEnabled()) {

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TypeEditor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TypeEditor.java?rev=1514547&r1=1514546&r2=1514547&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TypeEditor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TypeEditor.java Fri Aug 16 00:37:24
2013
@@ -29,7 +29,6 @@ public enum TypeEditor {
     PasswordEditor {@Override PropertyEditor getInstance(PropertyDescriptor descriptor) {
return new PasswordEditor(); }},
     TableEditor    {@Override PropertyEditor getInstance(PropertyDescriptor descriptor) {
return new TableEditor(); }},
     TextAreaEditor {@Override PropertyEditor getInstance(PropertyDescriptor descriptor) {
return new TextAreaEditor(descriptor); }},
-    EnumEditor     {@Override PropertyEditor getInstance(PropertyDescriptor descriptor) {
return new EnumEditor(descriptor); }},
     ;
     // Some editors may need the descriptor
     abstract PropertyEditor getInstance(PropertyDescriptor descriptor);



Mime
View raw message