org.springframework.richclient.command
Class CommandGroup

java.lang.Object
  extended by org.springframework.binding.value.support.AbstractPropertyChangePublisher
      extended by org.springframework.richclient.command.AbstractCommand
          extended by org.springframework.richclient.command.CommandGroup
All Implemented Interfaces:
BeanNameAware, InitializingBean, PropertyChangePublisher, ActionCommandExecutor, GuardedActionCommandExecutor, Authorizable, Guarded, SecurityControllable
Direct Known Subclasses:
ExclusiveCommandGroup, ShowPageMenu, ShowViewMenu

public class CommandGroup
extends AbstractCommand

Implementation of an AbstractCommand that groups a collection of commands. This can be used to construct a menu with all kinds of sub menus.

Author:
Keith Donald

Field Summary
 
Fields inherited from class org.springframework.richclient.command.AbstractCommand
ENABLED_PROPERTY_NAME, VISIBLE_PROPERTY_NAME
 
Fields inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher
logger
 
Fields inherited from interface org.springframework.richclient.core.Authorizable
AUTHORIZED_PROPERTY
 
Constructor Summary
CommandGroup()
           
CommandGroup(String groupId)
           
CommandGroup(String groupId, CommandFaceDescriptor face)
           
CommandGroup(String groupId, CommandRegistry commandRegistry)
          Constructor with id for configuration and the CommandRegistry to use.
CommandGroup(String id, String encodedLabel)
           
CommandGroup(String id, String encodedLabel, Icon icon, String caption)
           
 
Method Summary
 void add(AbstractCommand command)
           
 void add(AbstractCommand command, boolean rebuild)
           
 void add(String groupMemberPath, AbstractCommand command)
           
 void add(String groupMemberPath, AbstractCommand command, boolean rebuild)
           
protected  void addCommandsToGroupContainer(GroupContainerPopulator groupContainerPopulator)
          Create a container with the given GroupContainerPopulator which will hold the members of this group.
protected  void addComponentInternal(Component component)
           
 void addGlue()
           
 void addGlue(boolean rebuild)
           
protected  void addGlueInternal()
           
 void addGroupListener(CommandGroupListener l)
           
protected  void addInternal(AbstractCommand command)
           
protected  void addLazyInternal(String commandId)
           
 void addSeparator()
           
 void addSeparator(boolean rebuild)
           
protected  void addSeparatorInternal()
           
 boolean contains(AbstractCommand command)
           
 AbstractButton createButton(ButtonFactory buttonFactory, MenuFactory menuFactory)
           
 AbstractButton createButton(ButtonFactory buttonFactory, MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer)
           
 AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer)
          Creates a button using the provided id, factory and configurer.
 AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory, MenuFactory menuFactory)
           
 AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory, MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer)
           
 JComponent createButtonBar()
          Create a button bar with buttons for all the commands in this group.
 JComponent createButtonBar(com.jgoodies.forms.layout.ColumnSpec columnSpec, com.jgoodies.forms.layout.RowSpec rowSpec)
          Create a button bar with buttons for all the commands in this.
 JComponent createButtonBar(com.jgoodies.forms.layout.ColumnSpec columnSpec, com.jgoodies.forms.layout.RowSpec rowSpec, Border border)
          Create a button bar with buttons for all the commands in this.
 JComponent createButtonBar(com.jgoodies.forms.layout.Size minimumButtonSize)
          Create a button bar with buttons for all the commands in this group.
 JComponent createButtonBar(com.jgoodies.forms.layout.Size minimumButtonSize, Border border)
          Create a button bar with buttons for all the commands in this.
 JComponent createButtonStack()
          Create a button stack with buttons for all the commands.
 JComponent createButtonStack(com.jgoodies.forms.layout.ColumnSpec columnSpec, com.jgoodies.forms.layout.RowSpec rowSpec)
          Create a button stack with buttons for all the commands.
 JComponent createButtonStack(com.jgoodies.forms.layout.ColumnSpec columnSpec, com.jgoodies.forms.layout.RowSpec rowSpec, Border border)
          Create a button stack with buttons for all the commands.
 JComponent createButtonStack(com.jgoodies.forms.layout.Size minimumButtonSize)
          Create a button stack with buttons for all the commands.
 JComponent createButtonStack(com.jgoodies.forms.layout.Size minimumButtonSize, Border border)
          Create a button stack with buttons for all the commands.
static CommandGroup createCommandGroup(AbstractCommand member)
          Creates a command group with a single command member.
static CommandGroup createCommandGroup(Object[] members)
          Create a command group which holds all the given members.
static CommandGroup createCommandGroup(String groupId, Object[] members)
          Create a command group which holds all the given members.
static CommandGroup createCommandGroup(String groupId, Object[] members, CommandConfigurer configurer)
          Create a command group which holds all the given members.
static CommandGroup createExclusiveCommandGroup(Object[] members)
           
static CommandGroup createExclusiveCommandGroup(String groupId, Object[] members)
           
static CommandGroup createExclusiveCommandGroup(String groupId, Object[] members, CommandConfigurer configurer)
           
 JMenuBar createMenuBar()
           
 JMenuBar createMenuBar(MenuFactory factory)
           
 JMenuItem createMenuItem(String faceDescriptorId, MenuFactory factory, CommandButtonConfigurer buttonConfigurer)
          Create a menuItem using the provided id, factory and configurer.
 JPopupMenu createPopupMenu()
           
 JPopupMenu createPopupMenu(MenuFactory factory)
           
 JComponent createToolBar()
           
 JComponent createToolBar(ButtonFactory buttonFactory)
           
 void execute()
          Executes all the members of this group.
 AbstractCommand find(String memberPath)
          Search for and return the command contained by this group with the specified path.
protected  void fireMembersChanged()
           
protected  CommandRegistry getCommandRegistry()
           
 int getMemberCount()
           
protected  GroupMemberList getMemberList()
           
protected  CommandButtonConfigurer getPullDownMenuButtonConfigurer()
           
 boolean isAllowedMember(AbstractCommand proposedMember)
           
protected  Iterator memberIterator()
           
protected  void rebuildAllControls()
           
 void remove(AbstractCommand command)
           
 void remove(AbstractCommand command, boolean rebuild)
           
 void remove(String groupMemberPath, AbstractCommand command)
           
 void remove(String groupMemberPath, AbstractCommand command, boolean rebuild)
           
 void removeGroupListener(CommandGroupListener l)
           
 void reset()
           
 void setCommandRegistry(CommandRegistry registry)
           
 void setEnabled(boolean enabled)
          Set the enabled state of this command.
 void setVisible(boolean visible)
          Set this command visible and update all associated buttons.
 int size()
           
 
Methods inherited from class org.springframework.richclient.command.AbstractCommand
addEnabledListener, afterPropertiesSet, attach, attach, attach, buttonIterator, createButton, createButton, createButton, createButton, createButton, createMenuItem, createMenuItem, createMenuItem, createMenuItem, createMenuItem, defaultButtonIterator, detach, getAccelerator, getButtonFactory, getButtonIn, getCommandServices, getComponentFactory, getDefaultButtonConfigurer, getDefaultFaceDescriptorId, getFaceDescriptor, getFaceDescriptorRegistry, getIcon, getId, getMenuFactory, getMenuItemButtonConfigurer, getMnemonic, getMnemonicIndex, getSecurityControllerId, getText, getToolBarButtonConfigurer, getToolBarButtonFactory, isAnonymous, isAttached, isAuthorized, isEnabled, isFaceConfigured, isVisible, onButtonAttached, onButtonDetached, removeEnabledListener, requestFocusIn, setAuthorized, setBeanName, setCaption, setCommandServices, setDefaultFaceDescriptorId, setFaceDescriptor, setFaceDescriptor, setFaceDescriptorRegistry, setFaceDescriptors, setIcon, setIconInfo, setId, setLabel, setLabel, setSecurityControllerId, toString, updatedEnabledState, updatedVisibleState
 
Methods inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, firePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasChanged, hasChanged, hasChanged, hasChanged, hasChanged, hasChanged, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandGroup

public CommandGroup()
See Also:
AbstractCommand.AbstractCommand()

CommandGroup

public CommandGroup(String groupId)
See Also:
AbstractCommand.AbstractCommand(String)

CommandGroup

public CommandGroup(String groupId,
                    CommandFaceDescriptor face)
See Also:
AbstractCommand.AbstractCommand(String, CommandFaceDescriptor)

CommandGroup

public CommandGroup(String groupId,
                    CommandRegistry commandRegistry)
Constructor with id for configuration and the CommandRegistry to use.

See Also:
AbstractCommand.AbstractCommand(String)

CommandGroup

public CommandGroup(String id,
                    String encodedLabel)
See Also:
AbstractCommand.AbstractCommand(String, String)

CommandGroup

public CommandGroup(String id,
                    String encodedLabel,
                    Icon icon,
                    String caption)
See Also:
AbstractCommand.AbstractCommand(String, String, Icon, String)
Method Detail

createCommandGroup

public static CommandGroup createCommandGroup(AbstractCommand member)
Creates a command group with a single command member.

Parameters:
member - the command to put in the CommandGroup
Returns:
a CommandGroup which contains the given command.

createCommandGroup

public static CommandGroup createCommandGroup(Object[] members)
Create a command group which holds all the given members.

Parameters:
members - members to add to the group.
Returns:
a CommandGroup which contains all the members.

createCommandGroup

public static CommandGroup createCommandGroup(String groupId,
                                              Object[] members)
Create a command group which holds all the given members.

Parameters:
id - the id to configure the group.
members - members to add to the group.
Returns:
a CommandGroup which contains all the members.

createCommandGroup

public static CommandGroup createCommandGroup(String groupId,
                                              Object[] members,
                                              CommandConfigurer configurer)
Create a command group which holds all the given members.

Parameters:
id - the id to configure the group.
members - members to add to the group.
configurer - the configurer to use.
Returns:
a CommandGroup which contains all the members.

createExclusiveCommandGroup

public static CommandGroup createExclusiveCommandGroup(Object[] members)

createExclusiveCommandGroup

public static CommandGroup createExclusiveCommandGroup(String groupId,
                                                       Object[] members)

createExclusiveCommandGroup

public static CommandGroup createExclusiveCommandGroup(String groupId,
                                                       Object[] members,
                                                       CommandConfigurer configurer)

addInternal

protected void addInternal(AbstractCommand command)

addLazyInternal

protected void addLazyInternal(String commandId)

addSeparatorInternal

protected void addSeparatorInternal()

addGlueInternal

protected void addGlueInternal()

addComponentInternal

protected void addComponentInternal(Component component)

setCommandRegistry

public final void setCommandRegistry(CommandRegistry registry)

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: AbstractCommand
Set the enabled state of this command. Note that if we are currently not authorized, then the new value will just be recorded and no change in the current enabled state will be made.

Specified by:
setEnabled in interface Guarded
Overrides:
setEnabled in class AbstractCommand
Parameters:
enabled - state

setVisible

public void setVisible(boolean visible)
Description copied from class: AbstractCommand
Set this command visible and update all associated buttons.

Overrides:
setVisible in class AbstractCommand

getCommandRegistry

protected CommandRegistry getCommandRegistry()

add

public void add(AbstractCommand command)

add

public void add(AbstractCommand command,
                boolean rebuild)

add

public void add(String groupMemberPath,
                AbstractCommand command)

add

public void add(String groupMemberPath,
                AbstractCommand command,
                boolean rebuild)

remove

public void remove(AbstractCommand command)

remove

public void remove(AbstractCommand command,
                   boolean rebuild)

remove

public void remove(String groupMemberPath,
                   AbstractCommand command)

remove

public void remove(String groupMemberPath,
                   AbstractCommand command,
                   boolean rebuild)

addSeparator

public void addSeparator()

addSeparator

public void addSeparator(boolean rebuild)

addGlue

public void addGlue()

addGlue

public void addGlue(boolean rebuild)

rebuildAllControls

protected void rebuildAllControls()

getMemberList

protected GroupMemberList getMemberList()

memberIterator

protected Iterator memberIterator()

size

public int size()

isAllowedMember

public boolean isAllowedMember(AbstractCommand proposedMember)

find

public AbstractCommand find(String memberPath)
Search for and return the command contained by this group with the specified path. Nested paths should be deliniated by the "/" character; for example, "fileGroup/newGroup/simpleFileCommand". The returned command may be a group or an action command.

Parameters:
memberPath - the path of the command, with nested levels deliniated by the "/" path separator.
Returns:
the command at the specified member path, or null if no was command found.

execute

public void execute()
Executes all the members of this group.


getMemberCount

public int getMemberCount()

contains

public boolean contains(AbstractCommand command)

reset

public void reset()

createButton

public AbstractButton createButton(String faceDescriptorId,
                                   ButtonFactory buttonFactory,
                                   CommandButtonConfigurer buttonConfigurer)
Description copied from class: AbstractCommand
Creates a button using the provided id, factory and configurer.

Overrides:
createButton in class AbstractCommand
Parameters:
faceDescriptorId - id of the faceDescriptor used to configure the button.
buttonFactory - factory that delivers the button.
buttonConfigurer - configurer mapping the faceDescriptor on the button.
Returns:
a button attached to this command.

createButton

public AbstractButton createButton(ButtonFactory buttonFactory,
                                   MenuFactory menuFactory)

createButton

public AbstractButton createButton(String faceDescriptorId,
                                   ButtonFactory buttonFactory,
                                   MenuFactory menuFactory)

createButton

public AbstractButton createButton(ButtonFactory buttonFactory,
                                   MenuFactory menuFactory,
                                   CommandButtonConfigurer buttonConfigurer)

createButton

public AbstractButton createButton(String faceDescriptorId,
                                   ButtonFactory buttonFactory,
                                   MenuFactory menuFactory,
                                   CommandButtonConfigurer buttonConfigurer)

getPullDownMenuButtonConfigurer

protected CommandButtonConfigurer getPullDownMenuButtonConfigurer()

createMenuItem

public JMenuItem createMenuItem(String faceDescriptorId,
                                MenuFactory factory,
                                CommandButtonConfigurer buttonConfigurer)
Description copied from class: AbstractCommand
Create a menuItem using the provided id, factory and configurer.

Overrides:
createMenuItem in class AbstractCommand
Parameters:
faceDescriptorId - id of the faceDescriptor used to configure the button.
factory - factory that delivers the menuItem.
buttonConfigurer - configurer mapping the faceDescriptor on the button.
Returns:
a menuItem attached to this command.

createPopupMenu

public JPopupMenu createPopupMenu()

createPopupMenu

public JPopupMenu createPopupMenu(MenuFactory factory)

createToolBar

public JComponent createToolBar()

createToolBar

public JComponent createToolBar(ButtonFactory buttonFactory)

createMenuBar

public JMenuBar createMenuBar()

createMenuBar

public JMenuBar createMenuBar(MenuFactory factory)

createButtonBar

public JComponent createButtonBar()
Create a button bar with buttons for all the commands in this group.

Returns:
never null

createButtonBar

public JComponent createButtonBar(com.jgoodies.forms.layout.Size minimumButtonSize)
Create a button bar with buttons for all the commands in this group. Adds a border top and bottom of 2 spaces.

Parameters:
minimumButtonSize - if null, then there is no minimum size
Returns:
never null

createButtonBar

public JComponent createButtonBar(com.jgoodies.forms.layout.ColumnSpec columnSpec,
                                  com.jgoodies.forms.layout.RowSpec rowSpec)
Create a button bar with buttons for all the commands in this.

Parameters:
columnSpec - Custom columnSpec for each column containing a button, can be null.
rowSpec - Custom rowspec for the buttonbar, can be null.
Returns:
never null

createButtonBar

public JComponent createButtonBar(com.jgoodies.forms.layout.Size minimumButtonSize,
                                  Border border)
Create a button bar with buttons for all the commands in this.

Parameters:
minimumButtonSize - if null, then there is no minimum size
border - if null, then don't use a border
Returns:
never null

createButtonBar

public JComponent createButtonBar(com.jgoodies.forms.layout.ColumnSpec columnSpec,
                                  com.jgoodies.forms.layout.RowSpec rowSpec,
                                  Border border)
Create a button bar with buttons for all the commands in this.

Parameters:
columnSpec - Custom columnSpec for each column containing a button, can be null.
rowSpec - Custom rowspec for the buttonbar, can be null.
border - if null, then don't use a border
Returns:
never null

createButtonStack

public JComponent createButtonStack()
Create a button stack with buttons for all the commands.

Returns:
never null

createButtonStack

public JComponent createButtonStack(com.jgoodies.forms.layout.Size minimumButtonSize)
Create a button stack with buttons for all the commands. Adds a border left and right of 2 spaces.

Parameters:
minimumButtonSize - Minimum size of the buttons (can be null)
Returns:
never null

createButtonStack

public JComponent createButtonStack(com.jgoodies.forms.layout.Size minimumButtonSize,
                                    Border border)
Create a button stack with buttons for all the commands.

Parameters:
minimumButtonSize - Minimum size of the buttons (can be null)
border - Border to set around the stack.
Returns:
never null

createButtonStack

public JComponent createButtonStack(com.jgoodies.forms.layout.ColumnSpec columnSpec,
                                    com.jgoodies.forms.layout.RowSpec rowSpec)
Create a button stack with buttons for all the commands.

Parameters:
columnSpec - Custom columnSpec for the stack, can be null.
rowSpec - Custom rowspec for each row containing a button can be null.
Returns:
never null

createButtonStack

public JComponent createButtonStack(com.jgoodies.forms.layout.ColumnSpec columnSpec,
                                    com.jgoodies.forms.layout.RowSpec rowSpec,
                                    Border border)
Create a button stack with buttons for all the commands.

Parameters:
columnSpec - Custom columnSpec for the stack, can be null.
rowSpec - Custom rowspec for each row containing a button can be null.
border - Border to set around the stack.
Returns:
never null

addCommandsToGroupContainer

protected void addCommandsToGroupContainer(GroupContainerPopulator groupContainerPopulator)
Create a container with the given GroupContainerPopulator which will hold the members of this group.

Parameters:
groupContainerPopulator -

addGroupListener

public void addGroupListener(CommandGroupListener l)

removeGroupListener

public void removeGroupListener(CommandGroupListener l)

fireMembersChanged

protected void fireMembersChanged()


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