jsalvata    2004/02/05 01:50:03

  Modified:    src/core/org/apache/jmeter/gui GuiPackage.java
               src/core/org/apache/jmeter/testbeans BeanInfoSupport.java
  Log:
  Fix bug when switching locales while a TestBean is being edited.
  
  Revision  Changes    Path
  1.26      +23 -7     jakarta-jmeter/src/core/org/apache/jmeter/gui/GuiPackage.java
  
  Index: GuiPackage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/GuiPackage.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- GuiPackage.java   28 Jan 2004 10:08:39 -0000      1.25
  +++ GuiPackage.java   5 Feb 2004 09:50:03 -0000       1.26
  @@ -2,7 +2,7 @@
    * ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001,2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001,2003,2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -51,12 +51,16 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  + * 
  + * @author Michael Stover
  + * @author <a href="mailto:[EMAIL PROTECTED]">Jordi Salvat i Alabart</a>
  + * @version $Id$
    */
   package org.apache.jmeter.gui;
   
   import java.awt.Component;
  -import java.awt.event.ActionEvent;
   import java.awt.event.MouseEvent;
  +import java.beans.Introspector;
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -64,7 +68,6 @@
   
   import org.apache.jmeter.engine.util.ValueReplacer;
   import org.apache.jmeter.exceptions.IllegalUserActionException;
  -import org.apache.jmeter.gui.action.ActionRouter;
   import org.apache.jmeter.gui.tree.JMeterTreeListener;
   import org.apache.jmeter.gui.tree.JMeterTreeModel;
   import org.apache.jmeter.gui.tree.JMeterTreeNode;
  @@ -87,9 +90,6 @@
    * it to query the GUI about it's state.  When actions, for instance, need to
    * affect the GUI, they typically use GuiPackage to get access to different
    * parts of the GUI.
  - * 
  - * @author Michael Stover
  - * @version $Revision$
    */
   public final class GuiPackage implements LocaleChangeListener
   {
  @@ -631,10 +631,26 @@
        */
       public void localeChanged(LocaleChangeEvent event)
       {
  +        // FIrst make sure we save the content of the current GUI (since we
  +        // will flush it away):
  +        updateCurrentNode();
  +
           // Forget about all GUIs we've created so far: we'll need to re-created 
them all!
           guis= new HashMap();
           nodesToGui= new HashMap();
           testBeanGUIs= new HashMap();
  -             ActionRouter.getInstance().actionPerformed(new ActionEvent(this, 3333, 
"edit"));
  +
  +        // BeanInfo objects also contain locale-sensitive data -- flush them away:
  +        Introspector.flushCaches();
  +
  +        // Now put the current GUI in place. [This code was copied from the
  +        // EditCommand action -- we can't just trigger the action because that
  +        // would populate the current node with the contents of the new GUI --
  +        // which is empty.]
  +        getMainFrame().setMainPanel(
  +            (javax.swing.JComponent) getCurrentGui());
  +        getMainFrame().setEditMenu(
  +            ((JMeterGUIComponent) getTreeListener().getCurrentNode())
  +                .createPopupMenu());
       }
   }
  
  
  
  1.2       +2 -25     
jakarta-jmeter/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java
  
  Index: BeanInfoSupport.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanInfoSupport.java      1 Feb 2004 23:49:02 -0000       1.1
  +++ BeanInfoSupport.java      5 Feb 2004 09:50:03 -0000       1.2
  @@ -70,8 +70,6 @@
   
   import org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer;
   import org.apache.jmeter.util.JMeterUtils;
  -import org.apache.jmeter.util.LocaleChangeEvent;
  -import org.apache.jmeter.util.LocaleChangeListener;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.log.Logger;
   
  @@ -103,7 +101,7 @@
    * <b><i>groupName</i>.displayName</b>.
    */
   public abstract class BeanInfoSupport 
  -        implements BeanInfo, LocaleChangeListener
  +        implements BeanInfo
   {
   
        private static transient Logger log = LoggingManager.getLoggerForClass();
  @@ -205,8 +203,6 @@
                {
                        log.warn("Localized strings not available for bean 
"+beanClass);
                }
  -
  -        JMeterUtils.addLocaleChangeListener(this);
        }
        
        /**
  @@ -285,23 +281,4 @@
        public PropertyDescriptor[] getPropertyDescriptors() {
                return rootBeanInfo.getPropertyDescriptors();
        }
  -
  -    /* (non-Javadoc)
  -     * @see 
org.apache.jmeter.util.LocaleChangeListener#localeChanged(org.apache.jmeter.util.LocaleChangeEvent)
  -     */
  -    public void localeChanged(LocaleChangeEvent event)
  -    {
  -        // This object is locale-dependent, so if the locale changes, we need
  -        // to remove it from the Introspector's BeanInfo cache:
  -        Introspector.flushFromCaches(beanClass);
  -        
  -        // Now this instance is no longer useful -- no more need to listen to
  -        // this events (and prevent being GCd):
  -        JMeterUtils.removeLocaleChangeListener(this);
  -
  -        // Note: another option --just as easy to implement-- would be to
  -        // regenerate the locale-dependent information. But this would require
  -        // any subclasses grabbing additional locale-dependent information to
  -        // override this method, while this solution will work without that.
  -    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to