Revision: 1639
          http://svn.sourceforge.net/spring-rich-c/?rev=1639&view=rev
Author:   kevinstembridge
Date:     2007-01-09 14:56:03 -0800 (Tue, 09 Jan 2007)

Log Message:
-----------
Changes to DefaultApplicationObjectConfigurer to make it more subclass-friendly.
See RCP-456 for more details

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationObjectConfigurer.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/DefaultApplicationObjectConfigurer.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/config/DefaultCommandConfigurer.java

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationObjectConfigurer.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationObjectConfigurer.java
    2007-01-09 22:54:16 UTC (rev 1638)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationObjectConfigurer.java
    2007-01-09 22:56:03 UTC (rev 1639)
@@ -24,13 +24,13 @@
 public interface ApplicationObjectConfigurer {
 
     /**
-     * Configure the specified object with the provided object name.
+     * Configure the specified object.
      * 
-     * @param applicationObject
-     *            the object to configure
-     * @param objectName
-     *            a unique name for the object
-     * @return the configured object
+     * @param applicationObject The object to be configured. Must not be null.
+     * @param objectName A name for the object that is unique within the 
application. Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
      */
-    public Object configure(Object applicationObject, String objectName);
-}
\ No newline at end of file
+    public void configure(Object applicationObject, String objectName);
+    
+}

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/DefaultApplicationObjectConfigurer.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/DefaultApplicationObjectConfigurer.java
     2007-01-09 22:54:16 UTC (rev 1638)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/DefaultApplicationObjectConfigurer.java
     2007-01-09 22:56:03 UTC (rev 1639)
@@ -29,6 +29,7 @@
 import org.springframework.richclient.application.ApplicationServicesLocator;
 import org.springframework.richclient.application.ServiceNotFoundException;
 import org.springframework.richclient.command.config.CommandButtonIconInfo;
+import org.springframework.richclient.command.config.CommandButtonLabelInfo;
 import org.springframework.richclient.command.config.CommandIconConfigurable;
 import org.springframework.richclient.command.config.CommandLabelConfigurable;
 import org.springframework.richclient.core.DescriptionConfigurable;
@@ -43,7 +44,7 @@
 import org.springframework.richclient.image.config.ImageConfigurable;
 import org.springframework.richclient.security.SecurityController;
 import org.springframework.richclient.security.SecurityControllerManager;
-import org.springframework.util.Assert;
+import org.springframework.richclient.util.Assert;
 import org.springframework.util.StringUtils;
 
 /**
@@ -65,24 +66,36 @@
  */
 public class DefaultApplicationObjectConfigurer implements 
ApplicationObjectConfigurer, BeanPostProcessor {
     
-    private final Log logger = LogFactory.getLog(getClass());
+    /** The key fragment used to retrieve the <i>pressed</i> icon for a given 
object. */
+    public static final String PRESSED_ICON_KEY = "pressedIcon";
 
-    private static final String PRESSED_ICON_KEY = "pressedIcon";
+    /** The key fragment used to retrieve the <i>disabled</i> icon for a given 
object. */
+    public static final String DISABLED_ICON_KEY = "disabledIcon";
 
-    private static final String DISABLED_ICON_KEY = "disabledIcon";
+    /** The key fragment used to retrieve the <i>rollover</i> icon for a given 
object. */
+    public static final String ROLLOVER_ICON_KEY = "rolloverIcon";
 
-    private static final String ROLLOVER_ICON_KEY = "rolloverIcon";
+    /** The key fragment used to retrieve the <i>selected</i> icon for a given 
object. */
+    public static final String SELECTED_ICON_KEY = "selectedIcon";
 
-    private static final String SELECTED_ICON_KEY = "selectedIcon";
+    /** The key fragment used to retrieve the icon for a given object. */
+    public static final String ICON_KEY = "icon";
 
-    private static final String ICON_KEY = "icon";
+    /** The key fragment used to retrieve the image for a given object. */
+    public static final String IMAGE_KEY = "image";
 
-    private static final String IMAGE_KEY = "image";
+    /** The key fragment used to retrieve the description for a given object. 
*/
+    public static final String DESCRIPTION_KEY = "description";
 
-    private static final String DESCRIPTION_KEY = "description";
+    /** The key fragment used to retrieve the caption for a given object. */
+    public static final String CAPTION_KEY = "caption";
+    
+    /** The key fragment used to retrieve the title for a given object. */
+    public static final String TITLE_KEY = "title";
+    
+    /** Class logger, available to subclasses. */
+    protected final Log logger = LogFactory.getLog(getClass());
 
-    private static final String CAPTION_KEY = "caption";
-
     private boolean loadOptionalIcons = true;
 
     private MessageSource messageSource;
@@ -90,6 +103,8 @@
     private ImageSource imageSource;
 
     private IconSource iconSource;
+    
+    private SecurityControllerManager securityControllerManager;
 
     /**
      * Creates a new [EMAIL PROTECTED] DefaultApplicationObjectConfigurer} 
that will obtain required services
@@ -106,7 +121,7 @@
      * @param messageSource The message source. May be null.
      */
     public DefaultApplicationObjectConfigurer(MessageSource messageSource) {
-        this(messageSource, null, null);
+        this(messageSource, null, null, null);
     }
 
     /**
@@ -118,7 +133,7 @@
      * @param imageSource The image source. May be null.
      */
     public DefaultApplicationObjectConfigurer(MessageSource messageSource, 
ImageSource imageSource) {
-        this(messageSource, imageSource, null);
+        this(messageSource, imageSource, null, null);
     }
 
     /**
@@ -129,17 +144,27 @@
      * @param messageSource The message source. May be null.
      * @param imageSource The image source. May be null.
      * @param iconSource The icon source. May be null.
+     * @param securityControllerManager The security controller manager. May 
be null.
      */
     public DefaultApplicationObjectConfigurer(MessageSource messageSource, 
                                               ImageSource imageSource, 
-                                              IconSource iconSource) {
+                                              IconSource iconSource,
+                                              SecurityControllerManager 
securityControllerManager) {
         
         this.messageSource = messageSource;
         this.imageSource = imageSource;
         this.iconSource = iconSource;
+        this.securityControllerManager = securityControllerManager;
         
     }
 
+    /**
+     * Sets the flag that determines if optional icons will be loaded for any 
+     * [EMAIL PROTECTED] CommandIconConfigurable} objects that are configured 
by this instance. The default 
+     * is true.
+     *
+     * @param loadOptionalIcons The flag to load optional options.
+     */
     public void setLoadOptionalIcons(boolean loadOptionalIcons) {
         this.loadOptionalIcons = loadOptionalIcons;
     }
@@ -200,74 +225,237 @@
         return imageSource;
         
     }
+    
 
-    public Object configure(Object object, String objectName) {
-        configureTitle(object, objectName);
-        configureLabel(object, objectName);
-        configureDescription(object, objectName);
-        configureImageIcons(object, objectName);
-        configureSecurityController(object, objectName);
-        return object;
+    /**
+     * Returns this instance's security controller manager. If the security 
manager was not 
+     * provided at construction, it will be retrieved by the application 
services locator.
+     *
+     * @return The security controller manager, never null.
+     * 
+     * @throws ServiceNotFoundException if a security controller manager was 
not provided at 
+     * construction time and the application services locator cannot find an 
instance of the service.
+     */
+    protected SecurityControllerManager getSecurityControllerManager() {
+        
+        if (securityControllerManager == null) {
+            securityControllerManager 
+                    = (SecurityControllerManager) 
ApplicationServicesLocator.services().getService(SecurityControllerManager.class);
+        }
+        
+        return securityControllerManager;
+        
     }
 
-    private void configureTitle(Object object, String objectName) {
+    /**
+     * Configures the given object according to the interfaces that it 
implements.
+     * 
+     * <p>
+     * This implementation forwards the object to the following overridable 
methods in the 
+     * order listed. Subclasses can use these methods as hooks to modify the 
default configuration
+     * behaviour without having to override this method entirely. 
+     * 
+     * <ul>
+     * <li>[EMAIL PROTECTED] #configureTitle(TitleConfigurable, String)}</li>
+     * <li>[EMAIL PROTECTED] #configureLabel(LabelConfigurable, String)}</li>
+     * <li>[EMAIL PROTECTED] #configureCommandLabel(CommandLabelConfigurable, 
String)}</li>
+     * <li>[EMAIL PROTECTED] #configureDescription(DescriptionConfigurable, 
String)}</li>
+     * <li>[EMAIL PROTECTED] #configureImage(ImageConfigurable, String)}</li>
+     * <li>[EMAIL PROTECTED] #configureIcon(IconConfigurable, String)}</li>
+     * <li>[EMAIL PROTECTED] #configureCommandIcons(CommandIconConfigurable, 
String)}</li>
+     * <li>[EMAIL PROTECTED] 
#configureSecurityController(SecurityControllable, String)}</li>
+     * </ul>
+     * </p>
+     * 
+     * @param object The object to be configured. May be null.
+     * @param objectName The name for the object, expected to be unique within 
the application. 
+     * If [EMAIL PROTECTED] object} is not null, then [EMAIL PROTECTED] 
objectName} must also be non-null.
+     * 
+     * @throws IllegalArgumentException if [EMAIL PROTECTED] object} is not 
null, but [EMAIL PROTECTED] objectName} 
+     * is null.
+     *  
+     */
+    public void configure(Object object, String objectName) {
+        
+        if (object == null) {
+            logger.debug("object to be configured is null");
+            return;
+        }
+        
+        Assert.required(objectName, "objectName");
+        
         if (object instanceof TitleConfigurable) {
-            TitleConfigurable titleable = (TitleConfigurable)object;
-            titleable.setTitle(loadMessage(objectName, "title"));
+            configureTitle((TitleConfigurable) object, objectName);
         }
-    }
-
-    private void configureLabel(Object object, String objectName) {
+        
         if (object instanceof LabelConfigurable) {
-            LabelConfigurable labelable = (LabelConfigurable)object;
-            String labelStr = loadMessage(objectName, "label");
-            labelable.setLabelInfo(new 
LabelInfoFactory(labelStr).createLabelInfo());
+            configureLabel((LabelConfigurable) object, objectName);
         }
-        else {
-            if (object instanceof CommandLabelConfigurable) {
-                CommandLabelConfigurable labelable = 
(CommandLabelConfigurable)object;
-                String labelStr = loadMessage(objectName, "label");
-                labelable.setLabelInfo(new 
LabelInfoFactory(labelStr).createButtonLabelInfo());
-            }
+
+        if (object instanceof CommandLabelConfigurable) {
+            configureCommandLabel((CommandLabelConfigurable) object, 
objectName);
         }
-    }
-
-    private void configureDescription(Object object, String objectName) {
+        
         if (object instanceof DescriptionConfigurable) {
-            DescriptionConfigurable config = (DescriptionConfigurable)object;
-            String caption = loadMessage(objectName, CAPTION_KEY);
-            if (StringUtils.hasText(caption)) {
-                config.setCaption(caption);
-            }
-            String description = loadMessage(objectName, DESCRIPTION_KEY);
-            if (StringUtils.hasText(description)) {
-                config.setDescription(description);
-            }
+            configureDescription((DescriptionConfigurable) object, objectName);
         }
-    }
+        
+        if (object instanceof ImageConfigurable) {
+            configureImage((ImageConfigurable) object, objectName);
+        }
 
-    private void configureImageIcons( Object object, String objectName ) {
-        if( object instanceof ImageConfigurable ) {
-            if( getImageSource() != null ) {
-                ImageConfigurable imageable = (ImageConfigurable) object;
-                imageable.setImage(loadImage(objectName, IMAGE_KEY));
-            }
+        if (object instanceof IconConfigurable) {
+            configureIcon((IconConfigurable) object, objectName);
         }
-        if( object instanceof IconConfigurable ) {
-            if( getIconSource() != null ) {
-                IconConfigurable iconable = (IconConfigurable) object;
-                iconable.setIcon(loadOptionalIcon(objectName, ICON_KEY));
-            }
+        
+        if (object instanceof CommandIconConfigurable) {
+            configureCommandIcons((CommandIconConfigurable) object, 
objectName);
         }
-        if( object instanceof CommandIconConfigurable ) {
-            if( getIconSource() != null ) {
-                setIconInfo((CommandIconConfigurable) object, objectName);
-                setLargeIconInfo((CommandIconConfigurable) object, objectName);
-            }
+        
+        if (object instanceof SecurityControllable) {
+            configureSecurityController((SecurityControllable) object, 
objectName);
         }
+        
     }
 
     /**
+     * Sets the title of the given object. The title is loaded from this 
instance's 
+     * [EMAIL PROTECTED] MessageSource} using a message code in the format 
<pre>&lt;objectName&gt;.title</pre>
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureTitle(TitleConfigurable configurable, String 
objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        String title = loadMessage(objectName + "." + TITLE_KEY);
+        configurable.setTitle(title);
+    }
+
+    /**
+     * Sets the [EMAIL PROTECTED] LabelInfo} of the given object. The label 
info is created after loading the 
+     * encoded label string from this instance's [EMAIL PROTECTED] 
MessageSource} using a message code in the 
+     * format <pre>&lt;objectName&gt;.label</pre>
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureLabel(LabelConfigurable configurable, String 
objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        String labelStr = loadMessage(objectName + ".label");
+        configurable.setLabelInfo(new 
LabelInfoFactory(labelStr).createLabelInfo());
+    }
+    
+
+    /**
+     * Sets the [EMAIL PROTECTED] CommandButtonLabelInfo} of the given object. 
The label info is created 
+     * after loading the encoded label string from this instance's [EMAIL 
PROTECTED] MessageSource} using a 
+     * message code in the format <pre>&lt;objectName&gt;.label</pre>
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureCommandLabel(CommandLabelConfigurable 
configurable, String objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        String labelStr = loadMessage(objectName + ".label");
+        configurable.setLabelInfo(new 
LabelInfoFactory(labelStr).createButtonLabelInfo());
+    }
+
+    /**
+     * Sets the description and caption of the given object. These values are 
loaded from this 
+     * instance's [EMAIL PROTECTED] MessageSource} using message codes in the 
format 
+     * <pre>&lt;objectName&gt;.description</pre> and 
<pre>&lt;objectName&gt;.caption</pre> respectively.
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureDescription(DescriptionConfigurable configurable, 
String objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        
+        String caption = loadMessage(objectName + "." + CAPTION_KEY);
+        
+        if (StringUtils.hasText(caption)) {
+            configurable.setCaption(caption);
+        }
+        
+        String description = loadMessage(objectName + "." + DESCRIPTION_KEY);
+        
+        if (StringUtils.hasText(description)) {
+            configurable.setDescription(description);
+        }
+        
+    }
+    
+    /**
+     * Sets the image of the given object. The image is loaded from this 
instance's 
+     * [EMAIL PROTECTED] ImageSource} using a key in the format 
<pre>&lt;objectName&gt;.image</pre> If the image source
+     * cannot find an image under that key, the object's image will be set to 
null.
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureImage(ImageConfigurable configurable, String 
objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        Image image = loadImage(objectName, IMAGE_KEY);
+        configurable.setImage(image);
+    }
+
+    /**
+     * Sets the icon of the given object. The icon is loaded from this 
instance's 
+     * [EMAIL PROTECTED] IconSource} using a key in the format 
<pre>&lt;objectName&gt;.icon</pre> If the icon source
+     * cannot find an icon under that key, the object's icon will be set to 
null.
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureIcon(IconConfigurable configurable, String 
objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        Icon icon = loadIcon(objectName, ICON_KEY);
+        configurable.setIcon(icon);
+    }
+    
+    /**
+     * Sets the icons of the given object. The icons are loaded from this 
instance's 
+     * [EMAIL PROTECTED] IconSource}.  using a key in the format 
<pre>&lt;objectName&gt;.icon</pre> If the icon source
+     * cannot find an icon under that key, the object's icon will be set to 
null.
+     *
+     * @param configurable The object to be configured. Must not be null.
+     * @param objectName The name of the configurable object, unique within 
the application. 
+     * Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
+    protected void configureCommandIcons(CommandIconConfigurable configurable, 
String objectName) {
+        Assert.required(configurable, "configurable");
+        Assert.required(objectName, "objectName");
+        setIconInfo(configurable, objectName);
+        setLargeIconInfo(configurable, objectName);
+    }
+
+    /**
      * Associates the given object with a security controller if it implements 
the
      * [EMAIL PROTECTED] SecurityControllable} interface.
      * @param object The object to be configured.
@@ -275,88 +463,163 @@
      * @throws BeansException if a referenced security controller is not found 
or is of
      *             the wrong type
      */
-    private void configureSecurityController(Object object, String objectName) 
throws BeansException {
+    protected void configureSecurityController(SecurityControllable 
controllable, String objectName) {
+        Assert.required(controllable, "controllable");
+        Assert.required(objectName, "objectName");
         
-        if (object instanceof SecurityControllable) {
-            SecurityControllable controllable = (SecurityControllable) object;
-            String controllerId = controllable.getSecurityControllerId();
+        String controllerId = controllable.getSecurityControllerId();
 
-            if (controllerId != null) {
-                // Find the referenced controller.
-                SecurityControllerManager manager = 
(SecurityControllerManager)ApplicationServicesLocator.services().getService(SecurityControllerManager.class);
-                SecurityController controller = manager.getSecurityController( 
controllerId );
+        if (controllerId != null) {
+            // Find the referenced controller.
+            
+            if (logger.isDebugEnabled()) {
+                logger.debug("Lookup SecurityController with id [" + 
controllerId + "]");
+            }
 
+            SecurityController controller = 
getSecurityControllerManager().getSecurityController(controllerId);
+            
+            // And add the object to the controlled object set
+            if (controller != null) {
                 if (logger.isDebugEnabled()) {
-                    logger.debug("Lookup SecurityController with id [" + 
controllerId + "]");
+                    logger.debug("configuring SecurityControllable [" 
+                                 + objectName 
+                                 + "]; security controller id='"
+                                 + controllerId 
+                                 + "'");
                 }
-
-                // And add the object to the controlled object set
-                if (controller != null) {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("configuring SecurityControllable [" 
-                                     + objectName 
-                                     + "]; security controller id='"
-                                     + controllerId 
-                                     + "'");
-                    }
-                    controller.addControlledObject( controllable );
-                } else {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("configuring SecurityControllable [" 
-                                     + objectName 
-                                     + "]; no security controller for id='"
-                                     + controllerId 
-                                     + "'");
-                    }
-                }
+                controller.addControlledObject(controllable);
             } else {
-                
                 if (logger.isDebugEnabled()) {
                     logger.debug("configuring SecurityControllable [" 
-                                 + objectName
-                                 + "]; no security controller Id specified");
+                                 + objectName 
+                                 + "]; no security controller for id='"
+                                 + controllerId 
+                                 + "'");
                 }
-                
             }
+        } else {
             
+            if (logger.isDebugEnabled()) {
+                logger.debug("configuring SecurityControllable [" 
+                             + objectName
+                             + "]; no security controller Id specified");
+            }
+            
         }
+            
         
     }
 
+    /**
+     * Sets the icons for the given object by retrieving them from this 
instance's 
+     * [EMAIL PROTECTED] IconSource} and adding them to the [EMAIL PROTECTED] 
CommandButtonIconInfo} object to be set 
+     * on the configurable object. 
+     * 
+     * <p>
+     * The keys used to retrieve icons from the icon source are created by 
concatenating the given 
+     * [EMAIL PROTECTED] objectName} with a dot (.) and then an icon type like 
so: 
+     * </p>
+     * 
+     * <pre>    [EMAIL PROTECTED] myObjectName.someIconType}.</pre>
+     * 
+     * If the [EMAIL PROTECTED] loadOptionalIcons} flag is set to true (it is 
by default) all the following 
+     * icon types will be used. If the flag is false, only the first will be 
used:
+     * 
+     * <ul>
+     * <li>[EMAIL PROTECTED] #ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #SELECTED_ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #ROLLOVER_ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #DISABLED_ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #PRESSED_ICON_KEY}</li>
+     * </ul>
+     * 
+     * @param object The object to be configured. Must not be null.
+     * @param objectName The name of the object. Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
     public void setIconInfo(CommandIconConfigurable object, String objectName) 
{
-        Icon icon = loadOptionalIcon(objectName, ICON_KEY);
-        if (icon != null) {
-            CommandButtonIconInfo iconInfo;
-            if (loadOptionalIcons) {
-                Icon selectedIcon = loadOptionalIcon(objectName, 
SELECTED_ICON_KEY);
-                Icon rolloverIcon = loadOptionalIcon(objectName, 
ROLLOVER_ICON_KEY);
-                Icon disabledIcon = loadOptionalIcon(objectName, 
DISABLED_ICON_KEY);
-                Icon pressedIcon = loadOptionalIcon(objectName, 
PRESSED_ICON_KEY);
-                iconInfo = new CommandButtonIconInfo(icon, selectedIcon, 
rolloverIcon, disabledIcon, pressedIcon);
-            }
-            else {
-                iconInfo = new CommandButtonIconInfo(icon);
-            }
-            object.setIconInfo(iconInfo);
+        
+        Assert.required(object, "object");
+        Assert.required(objectName, "objectName");
+        
+        Icon icon = loadIcon(objectName, ICON_KEY);
+        
+        if (icon == null) {
+            return;
         }
+        
+        CommandButtonIconInfo iconInfo;
+        
+        if (loadOptionalIcons) {
+            Icon selectedIcon = loadIcon(objectName, SELECTED_ICON_KEY);
+            Icon rolloverIcon = loadIcon(objectName, ROLLOVER_ICON_KEY);
+            Icon disabledIcon = loadIcon(objectName, DISABLED_ICON_KEY);
+            Icon pressedIcon = loadIcon(objectName, PRESSED_ICON_KEY);
+            iconInfo = new CommandButtonIconInfo(icon, selectedIcon, 
rolloverIcon, disabledIcon, pressedIcon);
+        }
+        else {
+            iconInfo = new CommandButtonIconInfo(icon);
+        }
+        
+        object.setIconInfo(iconInfo);
+        
     }
 
+    /**
+     * Sets the large icons for the given object by retrieving them from this 
instance's 
+     * [EMAIL PROTECTED] IconSource} and adding them to the [EMAIL PROTECTED] 
CommandButtonIconInfo} object to be set 
+     * on the configurable object. 
+     * 
+     * <p>
+     * The keys used to retrieve icons from the icon source are created by 
concatenating the given 
+     * [EMAIL PROTECTED] objectName} with a dot (.), the text 'large' and then 
an icon type like so: 
+     * </p>
+     * 
+     * <pre>    [EMAIL PROTECTED] myObjectName.large.someIconType}.</pre>
+     * 
+     * If the [EMAIL PROTECTED] loadOptionalIcons} flag is set to true (it is 
by default) all the following 
+     * icon types will be used. If the flag is false, only the first will be 
used:
+     * 
+     * <ul>
+     * <li>[EMAIL PROTECTED] #ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #SELECTED_ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #ROLLOVER_ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #DISABLED_ICON_KEY}</li>
+     * <li>[EMAIL PROTECTED] #PRESSED_ICON_KEY}</li>
+     * </ul>
+     * 
+     * @param object The object to be configured. Must not be null.
+     * @param objectName The name of the object. Must not be null.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
     public void setLargeIconInfo(CommandIconConfigurable object, String 
objectName) {
-        Icon icon = loadOptionalLargeIcon(objectName, ICON_KEY);
-        if (icon != null) {
-            CommandButtonIconInfo iconInfo;
-            if (loadOptionalIcons) {
-                Icon selectedIcon = loadOptionalLargeIcon(objectName, 
SELECTED_ICON_KEY);
-                Icon rolloverIcon = loadOptionalLargeIcon(objectName, 
ROLLOVER_ICON_KEY);
-                Icon disabledIcon = loadOptionalLargeIcon(objectName, 
DISABLED_ICON_KEY);
-                Icon pressedIcon = loadOptionalIcon(objectName, 
PRESSED_ICON_KEY);
-                iconInfo = new CommandButtonIconInfo(icon, selectedIcon, 
rolloverIcon, disabledIcon, pressedIcon);
-            }
-            else {
-                iconInfo = new CommandButtonIconInfo(icon);
-            }
-            object.setLargeIconInfo(iconInfo);
+        
+        Assert.required(object, "object");
+        Assert.required(objectName, "objectName");
+        
+        Icon icon = loadLargeIcon(objectName, ICON_KEY);
+        
+        if (icon == null) {
+            return;
         }
+    
+        CommandButtonIconInfo iconInfo;
+        
+        if (loadOptionalIcons) {
+            Icon selectedIcon = loadLargeIcon(objectName, SELECTED_ICON_KEY);
+            Icon rolloverIcon = loadLargeIcon(objectName, ROLLOVER_ICON_KEY);
+            Icon disabledIcon = loadLargeIcon(objectName, DISABLED_ICON_KEY);
+            Icon pressedIcon = loadLargeIcon(objectName, PRESSED_ICON_KEY);
+            iconInfo = new CommandButtonIconInfo(icon, selectedIcon, 
rolloverIcon, disabledIcon, pressedIcon);
+        }
+        else {
+            iconInfo = new CommandButtonIconInfo(icon);
+        }
+        
+        object.setLargeIconInfo(iconInfo);
+        
     }
 
     /**
@@ -364,27 +627,41 @@
      * @see #configure(Object, String)
      */
     public Object postProcessBeforeInitialization(Object bean, String 
beanName) throws BeansException {
-        return configure(bean, beanName);
+        configure(bean, beanName);
+        return bean;
     }
 
-    private String loadMessage(String objectName, String messageType) {
-        Assert.notNull(objectName, "The bean's object name must be provided");
-        String labelCode = objectName + "." + messageType;
+    /**
+     * Attempts to load the message corresponding to the given message code 
using this instance's 
+     * [EMAIL PROTECTED] MessageSource} and locale.
+     *
+     * @param messageCode The message code that will be used to retrieve the 
message. Must not be null.
+     * @return The message for the given code, or null if the message code 
could not be found.
+     * 
+     * @throws IllegalArgumentException if [EMAIL PROTECTED] messageCode} is 
null.
+     */
+    private String loadMessage(String messageCode) {
         
+        Assert.required(messageCode, "messageCode");
+        
         if (logger.isDebugEnabled()) {
-            logger.debug("Resolving label with code '" + labelCode + "'");
+            logger.debug("Resolving label with code '" + messageCode + "'");
         }
         
         try {
-            return getMessageSource().getMessage(labelCode, null, getLocale());
+            return getMessageSource().getMessage(messageCode, null, 
getLocale());
         }
         catch (NoSuchMessageException e) {
+            
             if (logger.isInfoEnabled()) {
-                logger.info("Labeled property message code '" + labelCode
-                        + "' does not exist in message bundle; continuing...");
+                logger.info("The message source is unable to find message code 
[" 
+                            + messageCode
+                            + "]. Ignoring and returning null.");
             }
+            
             return null;
         }
+        
     }
 
     /**
@@ -396,12 +673,12 @@
         return Locale.getDefault();
     }
 
-    private Icon loadOptionalIcon(String objectName, String iconType) {
+    private Icon loadIcon(String objectName, String iconType) {
         String key = objectName + "." + iconType;
         return getIconSource().getIcon(key);
     }
 
-    private Icon loadOptionalLargeIcon(String objectName, String iconType) {
+    private Icon loadLargeIcon(String objectName, String iconType) {
         String key = objectName + ".large." + iconType;
         return getIconSource().getIcon(key);
     }

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/config/DefaultCommandConfigurer.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/config/DefaultCommandConfigurer.java
   2007-01-09 22:54:16 UTC (rev 1638)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/config/DefaultCommandConfigurer.java
   2007-01-09 22:56:03 UTC (rev 1639)
@@ -79,7 +79,8 @@
             logger.debug("Configuring faces (aka visual appearance 
descriptors) for " + command);
         }
         CommandFaceDescriptor face = new CommandFaceDescriptor();
-        
command.setFaceDescriptor((CommandFaceDescriptor)configurer.configure(face, 
objectName));
+        configurer.configure(face, objectName);
+        command.setFaceDescriptor(face);
         if (face.isBlank()) {
             face.setButtonLabelInfo("&" + command.getId());
         }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to