Revision: 1663
          http://svn.sourceforge.net/spring-rich-c/?rev=1663&view=rev
Author:   kevinstembridge
Date:     2007-01-15 05:25:46 -0800 (Mon, 15 Jan 2007)

Log Message:
-----------
Added javadoc

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/ExpansionPointGroupMember.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GlueGroupMember.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GroupMember.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/LazyGroupMember.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SeparatorGroupMember.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SimpleGroupMember.java

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/ExpansionPointGroupMember.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/ExpansionPointGroupMember.java
 2007-01-12 22:02:47 UTC (rev 1662)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/ExpansionPointGroupMember.java
 2007-01-15 13:25:46 UTC (rev 1663)
@@ -21,78 +21,168 @@
 import java.util.List;
 
 import org.springframework.richclient.command.config.CommandButtonConfigurer;
+import org.springframework.richclient.util.Assert;
 
+/**
+ * A collection of [EMAIL PROTECTED] GroupMember}s that represent a subsection 
of a [EMAIL PROTECTED] CommandGroup}. 
+ *
+ */
 public class ExpansionPointGroupMember extends GroupMember {
+
     private static final String DEFAULT_EXPANSION_POINT_NAME = "default";
 
-    private HashSet members = new LinkedHashSet(5);
+    private final HashSet members = new LinkedHashSet(5);
 
-    private String expansionGroupName;
+    private final String expansionPointName;
 
     private boolean leadingSeparator;
 
     private boolean endingSeparator;
 
+    /**
+     * Creates a new [EMAIL PROTECTED] ExpansionPointGroupMember} with a 
default name.
+     */
     protected ExpansionPointGroupMember() {
-        expansionGroupName = DEFAULT_EXPANSION_POINT_NAME;
+        expansionPointName = DEFAULT_EXPANSION_POINT_NAME;
     }
 
-    protected ExpansionPointGroupMember(String name) {
-        this.expansionGroupName = name;
+    /**
+     * Creates a new [EMAIL PROTECTED] ExpansionPointGroupMember} with the 
given name.
+     *
+     * @param expansionPointName The name of the expansion point. Must not be 
null.
+     * 
+     * @throws IllegalArgumentException if [EMAIL PROTECTED] 
expansionPointName} is null.
+     */
+    protected ExpansionPointGroupMember(String expansionPointName) {
+        Assert.required(expansionPointName, "expansionPointName");
+        this.expansionPointName = expansionPointName;
     }
 
+    /**
+     * Returns true if the visual representation of this expansion point will 
include a leading
+     * separator.
+     *
+     * @return true for a leading separator.
+     */
     public boolean isLeadingSeparator() {
         return leadingSeparator;
     }
 
+    /**
+     * Sets the flag that indicates whether or not the visual representation 
of this expansion
+     * point will display a leading separator.
+     *
+     * @param leadingSeparator Set to true to display a leading separator.
+     */
     public void setLeadingSeparator(boolean leadingSeparator) {
         this.leadingSeparator = leadingSeparator;
     }
 
+    /**
+     * Returns true if the visual representation of this expansion point will 
include a trailing
+     * separator.
+     *
+     * @return true for a trailing separator.
+     */
     public boolean isEndingSeparator() {
         return endingSeparator;
     }
 
+    /**
+     * Sets the flag that indicates whether or not the visual representation 
of this expansion
+     * point will display a trailing separator.
+     *
+     * @param endingSeparator Set to true to display a trailing separator.
+     */
     public void setEndingSeparator(boolean endingSeparator) {
         this.endingSeparator = endingSeparator;
     }
 
-    public String getExpansionGroupName() {
-        return expansionGroupName;
+    /**
+     * Returns the name of this expansion point.
+     *
+     * @return The expansion point name, never null.
+     */
+    public String getExpansionPointName() {
+        return expansionPointName;
     }
 
+    /**
+     * Attempts to add the given member to this expansion point. The member 
will not be added if
+     * an equivalent entry (according to its equals() method) already exists. 
If added, the member's
+     * [EMAIL PROTECTED] GroupMember#onAdded()} method will be called.
+     *
+     * @param member The member to be added. Must not be null.
+     * 
+     * @throws IllegalArgumentException if [EMAIL PROTECTED] member} is null.
+     */
     protected void add(GroupMember member) {
+        
+        Assert.required(member, "member");
+        
         if (members.add(member)) {
             member.onAdded();
         }
+        
     }
 
+    /**
+     * If the given member belongs to this exponsion point, it will be 
removed. Its 
+     * [EMAIL PROTECTED] GroupMember#onRemoved()} method will be called.  
+     *
+     * @param member The member that is to be removed.
+     */
     public void remove(GroupMember member) {
         if (members.remove(member)) {
             member.onRemoved();
         }
     }
 
+    /**
+     * Removes all the group members from this expansion point.
+     */
     protected void clear() {
         members.clear();
     }
 
-    protected void fill(GroupContainerPopulator parent, Object factory, 
CommandButtonConfigurer configurer,
-            List previousButtons) {
+    /**
+     * Adds each member of this expansion point to a GUI container using the 
given container 
+     * populator. Leading and trailing separators will also be added as 
determined by the 
+     * appropriate flags set on this instance.
+     * 
+     * [EMAIL PROTECTED]
+     */
+    protected void fill(GroupContainerPopulator containerPopulator, 
+                        Object controlFactory, 
+                        CommandButtonConfigurer configurer,
+                        List previousButtons) {
+        
+        Assert.required(containerPopulator, "containerPopulator");
+        Assert.required(controlFactory, "controlFactory");
+        Assert.required(configurer, "configurer");
+        
         if (members.size() > 0 && isLeadingSeparator()) {
-            addSeparator(parent);
+            containerPopulator.addSeparator();
         }
 
         for (Iterator iterator = members.iterator(); iterator.hasNext();) {
             GroupMember member = (GroupMember)iterator.next();
-            member.fill(parent, factory, configurer, previousButtons);
+            member.fill(containerPopulator, controlFactory, configurer, 
previousButtons);
         }
 
         if (members.size() > 0 && isEndingSeparator()) {
-            addSeparator(parent);
+            containerPopulator.addSeparator();
         }
+        
     }
 
+    /**
+     * Returns the group member that manages the command with the given id, or 
null if none of the
+     * members in this expansion point manage a command with that id.
+     * 
+     * @param commandId The id of the command whose managing member is to be 
returned.
+     * @return The group member that manages the command with the given id, or 
null.
+     */
     public GroupMember getMemberFor(String commandId) {
         for (Iterator it = members.iterator(); it.hasNext();) {
             GroupMember member = (GroupMember)it.next();
@@ -103,6 +193,9 @@
         return null;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean managesCommand(String commandId) {
         for (Iterator iterator = members.iterator(); iterator.hasNext();) {
             GroupMember member = (GroupMember)iterator.next();
@@ -113,8 +206,19 @@
         return false;
     }
 
+    /**
+     * Returns true if this expansion point has no members.
+     * @return true if this expansion point has no members.
+     */
     public boolean isEmpty() {
         return members.isEmpty();
     }
 
-}
\ No newline at end of file
+    /**
+     * Default implementation, performs no operation.
+     */
+    public void setEnabled(boolean enabled) {
+        //do nothing
+    }
+
+}

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GlueGroupMember.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GlueGroupMember.java
   2007-01-12 22:02:47 UTC (rev 1662)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GlueGroupMember.java
   2007-01-15 13:25:46 UTC (rev 1663)
@@ -21,12 +21,52 @@
 
 import org.springframework.richclient.command.config.CommandButtonConfigurer;
 
+/**
+ * A member of a [EMAIL PROTECTED] CommandGroup} that represents a 'glue' 
component between other members
+ * of the group. 
+ * 
+ * <p>
+ * A glue component is most often used as a filler between other components in 
a layout where those
+ * components cannot expand beyound a maximum height or width. As the layout 
area expands, the glue 
+ * component will expand to take up the space.
+ * </p>
+ *
+ * @see Box#createGlue()
+ */
 public class GlueGroupMember extends GroupMember {
+    
+    /**
+     * Creates a new uninitialized [EMAIL PROTECTED] GlueGroupMember}.
+     */
     public GlueGroupMember() {
+        //do nothing
     }
 
-    protected void fill(GroupContainerPopulator parentContainer, Object 
factory, CommandButtonConfigurer configurer,
-            List previousButtons) {
+    /**
+     * Adds a glue component using the given container populator.
+     * 
+     * [EMAIL PROTECTED]
+     */
+    protected void fill(GroupContainerPopulator parentContainer, 
+                        Object factory, 
+                        CommandButtonConfigurer configurer,
+                        List previousButtons) {
         parentContainer.add(Box.createGlue());
     }
+
+    /**
+     * Always returns false. A glue group member does not manage any commands.
+     * @return false always.
+     */
+    public final boolean managesCommand(String commandId) {
+        return false;
+    }
+
+    /**
+     * Default implemenation, performs no operation.
+     */
+    public void setEnabled(boolean enabled) {
+        // do nothing
+    }
+    
 }
\ No newline at end of file

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GroupMember.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GroupMember.java
       2007-01-12 22:02:47 UTC (rev 1662)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/GroupMember.java
       2007-01-15 13:25:46 UTC (rev 1663)
@@ -21,42 +21,84 @@
 import org.apache.commons.logging.LogFactory;
 import org.springframework.richclient.command.config.CommandButtonConfigurer;
 
+/**
+ * A member of a [EMAIL PROTECTED] CommandGroup}. 
+ * 
+ * <p>
+ * A command group will generally consist of command objects but may also 
contain other objects 
+ * such as separators or glue components used for spacing. This class is a 
simple wrapper around 
+ * these various types of command group members. 
+ * </p>
+ *
+ */
 public abstract class GroupMember {
 
+    /** Class logger, available to subclasses. */
     protected final Log logger = LogFactory.getLog(getClass());
 
-    protected abstract void fill(GroupContainerPopulator 
parentContainerPopulator, Object controlFactory,
-            CommandButtonConfigurer buttonConfigurer, List previousButtons);
+    /**
+     * Subclasses must implement this method to use the given container 
populator to add a 
+     * GUI control component to a GUI container. The actual type of the GUI 
control will be 
+     * determined by the type of the [EMAIL PROTECTED] controlFactory} 
provided, but it will generally be
+     * a control that a command can be associated with, such as a button or 
menu item.
+     *
+     * @param containerPopulator The object responsible for populating a GUI 
container with 
+     * an appropriate control component based on this instance. Must not be 
null.
+     * 
+     * @param controlFactory The factory for creating an appropriate GUI 
control that the underlying
+     * command will be associated with.
+     * 
+     * @param buttonConfigurer The object that is to configure the newly 
created control component. 
+     * 
+     * @param previousButtons A list of [EMAIL PROTECTED] AbstractButton} 
instances that have already been
+     * added to the container. May be null or empty.
+     * 
+     * @throws IllegalArgumentException if [EMAIL PROTECTED] 
containerPopulator}, [EMAIL PROTECTED] controlFactory}
+     * or [EMAIL PROTECTED] buttonConfigurer} are null.
+     */
+    protected abstract void fill(GroupContainerPopulator containerPopulator,
+                                 Object controlFactory,
+                                 CommandButtonConfigurer buttonConfigurer, 
+                                 List previousButtons);
 
-    public void setEnabled(boolean enabled) {
+    /**
+     * Subclasses may override this method to allow their underlying command 
to be enabled or disabled.
+     * @param enabled The enabled flag.
+     */
+    public abstract void setEnabled(boolean enabled);
 
-    }
-
     /**
-     * Returns <code>true</code> if this member manages a command and its
-     * managed command id equals the specified <code>commandId</code>. This
-     * method should also traverse nested commands, if the command managed by
-     * this member is a <code>CommandGroup</code>.
+     * Subclasses must implement this method to indicate whether or not they 
manage a command
+     * with the given id. This method should also traverse nested commands if 
the command managed 
+     * by this member is a [EMAIL PROTECTED] CommandGroup}.
      * 
-     * @param commandId
-     *            the command Id
-     * @return true or false
+     * @param commandId The id of the command to be checked for. May be null.
+     * @return true if the command, or any of its nested commands, managed by 
this group member
+     * has the given command id.
      */
-    public boolean managesCommand(String commandId) {
-        return false;
-    }
+    public abstract boolean managesCommand(String commandId);
 
+    /**
+     * Subclasses may override to return the command that they wrap.
+     *
+     * @return The wrapped command, possibly null.
+     */
     public AbstractCommand getCommand() {
         return null;
     }
 
-    protected void addSeparator(GroupContainerPopulator 
parentContainerPopulator) {
-        parentContainerPopulator.addSeparator();
-    }
-
+    /**
+     * Subclasses may override to be notified when they are added to a command 
group.
+     */
     protected void onAdded() {
+        //do nothing
     }
 
+    /**
+     * Subclasses may override to be notified when they are removed from the 
group they belong to.
+     */
     protected void onRemoved() {
+        //do nothing
     }
-}
\ No newline at end of file
+    
+}

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/LazyGroupMember.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/LazyGroupMember.java
   2007-01-12 22:02:47 UTC (rev 1662)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/LazyGroupMember.java
   2007-01-15 13:25:46 UTC (rev 1663)
@@ -18,48 +18,82 @@
 import java.util.List;
 
 import org.springframework.richclient.command.config.CommandButtonConfigurer;
-import org.springframework.util.Assert;
+import org.springframework.richclient.util.Assert;
 
+/**
+ * A [EMAIL PROTECTED] GroupMember} implementation that can be used as a 
placeholder for lazily initialized
+ * commands.
+ *
+ */
 public class LazyGroupMember extends GroupMember {
-    private CommandGroup parentGroup;
+    
+    private final CommandGroup parentGroup;
 
-    private String lazyCommandId;
+    private final String lazyCommandId;
 
     private boolean addedLazily;
 
     private GroupMember loadedMember;
-
+    
+    /**
+     * Creates a new [EMAIL PROTECTED] LazyGroupMember} belonging to the given 
command group and managing
+     * a lazily initialized command with the given id.
+     *
+     * @param parentGroup The command group that this member belongs to.
+     * @param lazyCommandId The id of the command that this group member 
represents.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     */
     public LazyGroupMember(CommandGroup parentGroup, String lazyCommandId) {
+        
+        Assert.required(parentGroup, "parentGroup");
+        Assert.required(lazyCommandId, "lazyCommandId");
+        
         if (logger.isDebugEnabled()) {
-            logger.debug("Lazy group member '" + lazyCommandId + "' 
instantiated for group '" + parentGroup.getId()
-                    + "'");
+            logger.debug("Lazy group member '" 
+                         + lazyCommandId 
+                         + "' instantiated for group '" 
+                         + parentGroup.getId()
+                         + "'");
         }
+        
         this.parentGroup = parentGroup;
         this.lazyCommandId = lazyCommandId;
     }
 
+    /**
+     * Delegates this call to the lazily loaded member, but only if it has 
already been loaded.
+     * Calling this method before the underlying member has beeen loaded will 
have no effect.
+     */
     public void setEnabled(boolean enabled) {
         if (loadedMember != null) {
             loadedMember.setEnabled(enabled);
         }
     }
 
-    protected void fill(GroupContainerPopulator parentContainerPopulator, 
Object controlFactory,
-            CommandButtonConfigurer buttonConfigurer, List previousButtons) {
-        if (lazyLoaded()) {
+    protected void fill(GroupContainerPopulator parentContainerPopulator, 
+                        Object controlFactory,
+                        CommandButtonConfigurer buttonConfigurer, 
+                        List previousButtons) {
+        
+        loadIfNecessary();
+        
+        if (loadedMember != null) {
             loadedMember.fill(parentContainerPopulator, controlFactory, 
buttonConfigurer, previousButtons);
         }
+        
     }
 
-    private boolean lazyLoaded() {
+    /**
+     * Attempts to load the lazy command from the command registry of the 
parent command group, but
+     * only if it hasn't already been loaded.
+     */
+    private void loadIfNecessary() {
+        
         if (loadedMember != null) {
-            return true;
+            return;
         }
-        doLazyLoad();
-        return loadedMember != null;
-    }
-
-    private void doLazyLoad() {
+        
         CommandRegistry commandRegistry = parentGroup.getCommandRegistry();
 
         Assert.isTrue(parentGroup.getCommandRegistry() != null, "Command 
registry must be set for group '"
@@ -74,19 +108,32 @@
             loadedMember = new SimpleGroupMember(parentGroup, command);
         }
         else {
-            logger.warn("Lazy command '" + lazyCommandId
-                    + "' was asked to display; however, no backing command 
instance exists in registry.");
+            
+            if (logger.isWarnEnabled()) {
+                logger.warn("Lazy command '" 
+                            + lazyCommandId
+                            + "' was asked to display; however, no backing 
command instance exists in registry.");
+            }
+            
         }
 
         if (addedLazily && loadedMember != null) {
             loadedMember.onAdded();
         }
+        
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean managesCommand(String commandId) {
+        //FIXME isn't this supposed to recurse if command is a command group?
         return this.lazyCommandId.equals(commandId);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     protected void onAdded() {
         if (loadedMember != null) {
             loadedMember.onAdded();
@@ -96,6 +143,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     protected void onRemoved() {
         if (loadedMember != null) {
             loadedMember.onRemoved();

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SeparatorGroupMember.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SeparatorGroupMember.java
      2007-01-12 22:02:47 UTC (rev 1662)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SeparatorGroupMember.java
      2007-01-15 13:25:46 UTC (rev 1663)
@@ -32,11 +32,28 @@
     }
 
     /**
-     * Asks the given container to add a separator to itself.
+     * Asks the given container populator to add a separator to its underlying 
container.
      */
-    protected void fill(GroupContainerPopulator container, Object factory, 
CommandButtonConfigurer configurer,
-            List previousButtons) {
-        addSeparator(container);
+    protected void fill(GroupContainerPopulator container, 
+                        Object factory, 
+                        CommandButtonConfigurer configurer,
+                        List previousButtons) {
+        container.addSeparator();
     }
 
+    /**
+     * Always returns false.
+     * @return false always.
+     */
+    public final boolean managesCommand(String commandId) {
+        return false;
+    }
+
+    /**
+     * Default implementation, performs no operation.
+     */
+    public void setEnabled(boolean enabled) {
+        //do nothing
+    }
+
 }

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SimpleGroupMember.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SimpleGroupMember.java
 2007-01-12 22:02:47 UTC (rev 1662)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SimpleGroupMember.java
 2007-01-15 13:25:46 UTC (rev 1663)
@@ -25,59 +25,123 @@
 import org.springframework.richclient.command.config.CommandButtonConfigurer;
 import org.springframework.richclient.factory.ButtonFactory;
 import org.springframework.richclient.factory.MenuFactory;
+import org.springframework.richclient.util.Assert;
 
+/**
+ * A simple implementation of the [EMAIL PROTECTED] GroupMember} interface 
that manages normal commands that
+ * can be associated with instances of [EMAIL PROTECTED] AbstractButton}s.
+ *
+ */
 public class SimpleGroupMember extends GroupMember {
-    private CommandGroup parent;
 
-    private AbstractCommand command;
+    private final CommandGroup parent;
 
+    private final AbstractCommand command;
+
+    /**
+     * Creates a new [EMAIL PROTECTED] SimpleGroupMember} belonging to the 
given command group and wrapping
+     * the given command.
+     *
+     * @param parentGroup The command group that this member belongs to.
+     * @param command The command that this group member represents.
+     * 
+     * @throws IllegalArgumentException if either argument is null.
+     * @throws InvalidGroupMemberException if the given command group does not 
support the type of
+     * the given command.
+     */
     public SimpleGroupMember(CommandGroup parentGroup, AbstractCommand 
command) {
         this.parent = parentGroup;
         this.command = command;
-        if (!parentGroup.isAllowedMember(command))
-            throw new IllegalArgumentException("Command: " + command + " is 
not allowed in group: " + parentGroup);
+        
+        if (!parentGroup.isAllowedMember(command)) {
+            throw new InvalidGroupMemberException(command.getClass(), 
parentGroup.getClass());
+        }
+        
     }
 
+    /**
+     * Sets the enabled flag of the underlying command.
+     */
     public void setEnabled(boolean enabled) {
         command.setEnabled(enabled);
     }
 
-    protected void fill(GroupContainerPopulator parentContainerPopulator, 
Object controlFactory,
-            CommandButtonConfigurer buttonConfigurer, List previousButtons) {
+    
+    protected void fill(GroupContainerPopulator containerPopulator, 
+                        Object controlFactory,
+                        CommandButtonConfigurer buttonConfigurer, 
+                        List previousButtons) {
+        
+        Assert.required(containerPopulator, "containerPopulator");
+        Assert.required(buttonConfigurer, "buttonConfigurer");
+        
         if (controlFactory instanceof MenuFactory) {
             JMenuItem menu = findMenu(command, previousButtons);
+
             if (menu == null) {
                 menu = command.createMenuItem(((MenuFactory)controlFactory), 
buttonConfigurer);
             }
-            if (logger.isDebugEnabled()) {
-                logger.debug("Adding menu item to container");
-            }
-            parentContainerPopulator.add(menu);
+            
+            logger.debug("Adding menu item to container");
+            containerPopulator.add(menu);
         }
         else if (controlFactory instanceof ButtonFactory) {
             AbstractButton button = findButton(command, previousButtons);
+            
             if (button == null) {
                 button = command.createButton(((ButtonFactory)controlFactory), 
buttonConfigurer);
             }
-            if (logger.isDebugEnabled()) {
-                logger.debug("Adding button to container");
-            }
-            parentContainerPopulator.add(button);
+            
+            logger.debug("Adding button to container");
+            containerPopulator.add(button);
         }
+        
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean managesCommand(String commandId) {
-        return this.command.getId().equals(commandId);
+        //FIXME isn't this supposed to recursively check subcommands if 
command is a commandgroup?
+        
+        if (commandId == null) {
+            return false;
+        }
+        
+        return commandId.equals(this.command.getId());
+        
     }
 
+    /**
+     * Returns the underlying command, never null.
+     * @return The underlying command.
+     */
     public AbstractCommand getCommand() {
         return command;
     }
 
-    protected JMenuItem findMenu(AbstractCommand command, List 
previousButtons) {
-        for (Iterator it = previousButtons.iterator(); it.hasNext();) {
+    /**
+     * Searches the given list of [EMAIL PROTECTED] AbstractButton}s for one 
that is an instance of a 
+     * [EMAIL PROTECTED] JMenuItem} and has the given command attached to it. 
If found, the menu item will be
+     * removed from the list.
+     *
+     * @param attachedCommand The command that we are checking to see if it 
attached to any item in the list.
+     * @param abstractButtons The collection of [EMAIL PROTECTED] 
AbstractButton}s that will be checked to
+     * see if they have the given command attached to them. May be null or 
empty.
+     *  
+     * @return The element from the list that the given command is attached 
to, or null if no
+     * such element could be found.
+     * 
+     */
+    protected JMenuItem findMenu(AbstractCommand attachedCommand, List 
abstractButtons) {
+        
+        if (abstractButtons == null) {
+            return null;
+        }
+        
+        for (Iterator it = abstractButtons.iterator(); it.hasNext();) {
             AbstractButton button = (AbstractButton)it.next();
-            if (button instanceof JMenuItem && command.isAttached(button)) {
+            if (button instanceof JMenuItem && 
attachedCommand.isAttached(button)) {
                 it.remove();
                 return (JMenuItem)button;
             }
@@ -85,10 +149,28 @@
         return null;
     }
 
-    protected AbstractButton findButton(AbstractCommand command, List 
previousButtons) {
-        for (Iterator it = previousButtons.iterator(); it.hasNext();) {
+    /**
+     * Searches the given list of [EMAIL PROTECTED] AbstractButton}s for one 
that is not an instance of a 
+     * [EMAIL PROTECTED] JMenuItem} and has the given command attached to it. 
If found, the button will be
+     * removed from the list.
+     *
+     * @param attachedCommand The command that we are checking to see if it 
attached to any item in the list.
+     * @param abstractButtons The collection of [EMAIL PROTECTED] 
AbstractButton}s that will be checked to
+     * see if they have the given command attached to them. May be null or 
empty.
+     *  
+     * @return The element from the list that the given command is attached 
to, or null if no
+     * such element could be found.
+     * 
+     */
+    protected AbstractButton findButton(AbstractCommand attachedCommand, List 
buttons) {
+        
+        if (buttons == null) {
+            return null;
+        }
+        
+        for (Iterator it = buttons.iterator(); it.hasNext();) {
             AbstractButton button = (AbstractButton)it.next();
-            if (!(button instanceof JMenuItem) && command.isAttached(button)) {
+            if (!(button instanceof JMenuItem) && 
attachedCommand.isAttached(button)) {
                 it.remove();
                 return button;
             }
@@ -96,19 +178,29 @@
         return null;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     protected void onAdded() {
         if (parent instanceof ExclusiveCommandGroup) {
             
((ExclusiveCommandGroup)parent).getSelectionController().add((ToggleCommand)command);
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     protected void onRemoved() {
         if (parent instanceof ExclusiveCommandGroup) {
             
((ExclusiveCommandGroup)parent).getSelectionController().remove((ToggleCommand)command);
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String toString() {
         return new ToStringCreator(this).append("command", command).toString();
     }
-}
\ No newline at end of file
+    
+}


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