jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1210159 - /jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java
Date Sun, 04 Dec 2011 17:56:18 GMT
Author: pmouawad
Date: Sun Dec  4 17:56:17 2011
New Revision: 1210159

URL: http://svn.apache.org/viewvc?rev=1210159&view=rev
Log:
Bug 52280 - The menu item Options / Choose Language does not change all the displayed text
to the new language

Better fix after discussion on mailing list

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java?rev=1210159&r1=1210158&r2=1210159&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java Sun Dec  4 17:56:17
2011
@@ -59,6 +59,8 @@ import org.apache.jmeter.testelement.pro
 import org.apache.jmeter.timers.Timer;
 import org.apache.jmeter.timers.gui.AbstractTimerGui;
 import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.util.LocaleChangeEvent;
+import org.apache.jmeter.util.LocaleChangeListener;
 import org.apache.jmeter.visualizers.Visualizer;
 import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
 import org.apache.jorphan.logging.LoggingManager;
@@ -84,14 +86,14 @@ import org.apache.log.Logger;
  * customizers should implement SharedCustomizer.
  *
  */
-public class TestBeanGUI extends AbstractJMeterGuiComponent implements JMeterGUIComponent
{
+public class TestBeanGUI extends AbstractJMeterGuiComponent implements JMeterGUIComponent,
LocaleChangeListener{
     private static final long serialVersionUID = 240L;
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     private final Class<?> testBeanClass;
 
-    private transient final BeanInfo beanInfo;
+    private transient BeanInfo beanInfo;
 
     private final Class<?> customizerClass;
 
@@ -177,6 +179,7 @@ public class TestBeanGUI extends Abstrac
         // label, menu
         // categories, etc!
         initialized = false;
+        JMeterUtils.addLocaleChangeListener(this);
     }
 
     private Customizer createCustomizer() {
@@ -199,13 +202,7 @@ public class TestBeanGUI extends Abstrac
         if (beanInfo == null){
             return "null";// $NON-NLS-1$
         }
-        try {
-        	// We get new BeanInfo instead of cached one
-        	// TODO Find a better way to reinitialize the beanInfo instance
-			return Introspector.getBeanInfo(testBeanClass).getBeanDescriptor().getDisplayName();
-		} catch (IntrospectionException e) {
-			return beanInfo.getBeanDescriptor().getDisplayName();
-		}
+        return beanInfo.getBeanDescriptor().getDisplayName();
     }
 
     /**
@@ -470,4 +467,18 @@ public class TestBeanGUI extends Abstrac
     public boolean isExpert() {
         return beanInfo.getBeanDescriptor().isExpert();
     }
+
+	/**
+	 * Handle Locale Change by reloading BeanInfo
+	 * @param event {@link LocaleChangeEvent}
+	 */
+	public void localeChanged(LocaleChangeEvent event) {
+		try {
+            beanInfo = Introspector.getBeanInfo(testBeanClass);
+        } catch (IntrospectionException e) {
+            log.error("Can't get beanInfo for " + testBeanClass.getName(), e);
+            throw new Error(e.toString()); // Programming error. Don't
+                                            // continue.
+        }
+	}
 }



Mime
View raw message