cvs commit: jakarta-jmeter/src/core/org/apache/jmeter/gui GUIFactory.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

cvs commit: jakarta-jmeter/src/core/org/apache/jmeter/gui GUIFactory.java

sebb-3
sebb        2005/06/14 16:41:04

  Modified:    src/core/org/apache/jmeter/gui GUIFactory.java
  Log:
  Add support for disabled icons
 
  Revision  Changes    Path
  1.8       +36 -4     jakarta-jmeter/src/core/org/apache/jmeter/gui/GUIFactory.java
 
  Index: GUIFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/GUIFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- GUIFactory.java 13 Feb 2004 02:21:37 -0000 1.7
  +++ GUIFactory.java 14 Jun 2005 23:41:04 -0000 1.8
  @@ -41,6 +41,9 @@
       /** A Map from String to ImageIcon of registered icons. */
       private static final Map ICON_MAP = new HashMap();
   
  +    /** A Map from String to ImageIcon of registered icons. */
  +    private static final Map DISABLED_ICON_MAP = new HashMap();
  +
       /**
        * Prevent instantiation since this is a static utility class.
        */
  @@ -58,8 +61,24 @@
        */
       public static ImageIcon getIcon(Class elementClass)
       {
  +        return getIcon(elementClass, true);
  +        
  +    }
  +
  +    /**
  +     * Get icon/disabledicon which has previously been registered for this class object.
  +     *
  +     * @param elementClass the class object which we want to get an icon for
  +     * @param enabled - is icon enabled
  +     *
  +     * @return the associated icon, or null if this class or its superclass
  +     *         has not been registered
  +     */
  +public static ImageIcon getIcon(Class elementClass, boolean enabled)
  +    {
           String key = elementClass.getName();
  -        ImageIcon icon = (ImageIcon) ICON_MAP.get(key);
  +        ImageIcon icon = (ImageIcon) (enabled ?
  +                ICON_MAP.get(key) : DISABLED_ICON_MAP.get(key));
   
           if (icon != null)
           {
  @@ -68,7 +87,7 @@
           
           if (elementClass.getSuperclass() != null)
           {
  -            return getIcon(elementClass.getSuperclass());
  +            return getIcon(elementClass.getSuperclass(),enabled);
           }
           
           return null;
  @@ -118,6 +137,19 @@
           ICON_MAP.put(key, icon);
       }
   
  +    /**
  +     * Register an icon so that it can later be retrieved via
  +     * {@link #getIcon(Class)}.  The key should match the fully-qualified
  +     * class name for the class used as the parameter when retrieving the
  +     * icon.
  +     *
  +     * @param key   the name which can be used to retrieve this icon later
  +     * @param icon  the icon to store
  +     */
  +    public static void registerDisabledIcon(String key, ImageIcon icon)
  +    {
  +        DISABLED_ICON_MAP.put(key, icon);
  +    }
   
       /**
        * Register a GUI class so that it can later be retrieved via
 
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]