org.springframework.richclient.command
Class SimpleGroupMember

java.lang.Object
  extended by org.springframework.richclient.command.GroupMember
      extended by org.springframework.richclient.command.SimpleGroupMember

public class SimpleGroupMember
extends GroupMember

A simple implementation of the GroupMember interface that manages normal commands that can be associated with instances of AbstractButtons.


Field Summary
 
Fields inherited from class org.springframework.richclient.command.GroupMember
logger
 
Constructor Summary
SimpleGroupMember(CommandGroup parentGroup, AbstractCommand command)
          Creates a new SimpleGroupMember belonging to the given command group and wrapping the given command.
 
Method Summary
protected  void fill(GroupContainerPopulator containerPopulator, 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.
protected  AbstractButton findButton(AbstractCommand attachedCommand, List buttons)
          Searches the given list of AbstractButtons for one that is not an instance of a JMenuItem and has the given command attached to it.
protected  JMenuItem findMenu(AbstractCommand attachedCommand, List abstractButtons)
          Searches the given list of AbstractButtons for one that is an instance of a JMenuItem and has the given command attached to it.
 AbstractCommand getCommand()
          Returns the underlying command, never null.
 boolean managesCommand(String commandId)
          Subclasses must implement this method to indicate whether or not they manage a command with the given id.
protected  void onAdded()
          Subclasses may override to be notified when they are added to a command group.
protected  void onRemoved()
          Subclasses may override to be notified when they are removed from the group they belong to.
 void setEnabled(boolean enabled)
          Sets the enabled flag of the underlying command.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleGroupMember

public SimpleGroupMember(CommandGroup parentGroup,
                         AbstractCommand command)
Creates a new SimpleGroupMember belonging to the given command group and wrapping the given command.

Parameters:
parentGroup - The command group that this member belongs to.
command - The command that this group member represents.
Throws:
IllegalArgumentException - if either argument is null.
InvalidGroupMemberException - if the given command group does not support the type of the given command.
Method Detail

setEnabled

public void setEnabled(boolean enabled)
Sets the enabled flag of the underlying command.

Specified by:
setEnabled in class GroupMember
Parameters:
enabled - The enabled flag.

fill

protected void fill(GroupContainerPopulator containerPopulator,
                    Object controlFactory,
                    CommandButtonConfigurer buttonConfigurer,
                    List previousButtons)
Description copied from class: GroupMember
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 controlFactory provided, but it will generally be a control that a command can be associated with, such as a button or menu item.

Specified by:
fill in class GroupMember
Parameters:
containerPopulator - The object responsible for populating a GUI container with an appropriate control component based on this instance. Must not be null.
controlFactory - The factory for creating an appropriate GUI control that the underlying command will be associated with.
buttonConfigurer - The object that is to configure the newly created control component.
previousButtons - A list of AbstractButton instances that have already been added to the container. May be null or empty.

managesCommand

public boolean managesCommand(String commandId)
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 CommandGroup.

Specified by:
managesCommand in class GroupMember
Parameters:
commandId - The id of the command to be checked for. May be null.
Returns:
true if the command, or any of its nested commands, managed by this group member has the given command id.

getCommand

public AbstractCommand getCommand()
Returns the underlying command, never null.

Overrides:
getCommand in class GroupMember
Returns:
The underlying command.

findMenu

protected JMenuItem findMenu(AbstractCommand attachedCommand,
                             List abstractButtons)
Searches the given list of AbstractButtons for one that is an instance of a JMenuItem and has the given command attached to it. If found, the menu item will be removed from the list.

Parameters:
attachedCommand - The command that we are checking to see if it attached to any item in the list.
abstractButtons - The collection of AbstractButtons that will be checked to see if they have the given command attached to them. May be null or empty.
Returns:
The element from the list that the given command is attached to, or null if no such element could be found.

findButton

protected AbstractButton findButton(AbstractCommand attachedCommand,
                                    List buttons)
Searches the given list of AbstractButtons for one that is not an instance of a JMenuItem and has the given command attached to it. If found, the button will be removed from the list.

Parameters:
attachedCommand - The command that we are checking to see if it attached to any item in the list.
abstractButtons - The collection of AbstractButtons that will be checked to see if they have the given command attached to them. May be null or empty.
Returns:
The element from the list that the given command is attached to, or null if no such element could be found.

onAdded

protected void onAdded()
Subclasses may override to be notified when they are added to a command group.

Overrides:
onAdded in class GroupMember

onRemoved

protected void onRemoved()
Subclasses may override to be notified when they are removed from the group they belong to.

Overrides:
onRemoved in class GroupMember

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.