org.springframework.richclient.command.config
Class CommandButtonLabelInfo

java.lang.Object
  extended by org.springframework.richclient.command.config.CommandButtonLabelInfo
All Implemented Interfaces:
ButtonConfigurer

public final class CommandButtonLabelInfo
extends Object
implements ButtonConfigurer

An immutable parameter object consisting of the text, mnemonic character, mnemonic character index and keystroke accelerator that may be associated with a labeled command button.

This class also acts as a factory for creating instances of itself based on a string descriptor. The syntax used for this descriptor is described in the javadoc for the valueOf(String) method.

Author:
Keith Donald, Kevin Stembridge
See Also:
LabelInfo, KeyStroke

Field Summary
static CommandButtonLabelInfo BLANK_BUTTON_LABEL
          A default instance to be used for command buttons with no label information.
 
Constructor Summary
CommandButtonLabelInfo(LabelInfo labelInfo, KeyStroke accelerator)
          Creates a new CommandButtonLabelInfo with the given label information and keystroke accelerator.
CommandButtonLabelInfo(String text)
          Creates a new CommandButtonLabelInfo that will display the given text on its label.
 
Method Summary
 AbstractButton configure(AbstractButton button)
          Configures an existing button appropriately based on this label info's properties.
protected  void configureAccelerator(AbstractButton button, KeyStroke keystrokeAccelerator)
          Sets the given keystroke accelerator on the given button.
 boolean equals(Object obj)
          
 KeyStroke getAccelerator()
          Returns the keystroke accelerator for the label.
 int getMnemonic()
          Returns the mnemonic for the label.
 int getMnemonicIndex()
          Returns the zero-based index for the mnemonic character within the label text.
 String getText()
          Returns the displayable text.
 int hashCode()
          
 String toString()
          
static CommandButtonLabelInfo valueOf(String labelDescriptor)
          Return an instance of this class, created by parsing the information in the given label descriptor string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BLANK_BUTTON_LABEL

public static final CommandButtonLabelInfo BLANK_BUTTON_LABEL
A default instance to be used for command buttons with no label information.

Constructor Detail

CommandButtonLabelInfo

public CommandButtonLabelInfo(String text)
Creates a new CommandButtonLabelInfo that will display the given text on its label. There will be no associated mnemonic character and no keystroke accelerator.

Parameters:
text - The label text to be displayed. Must not be null.
Throws:
IllegalArgumentException - if text is null.

CommandButtonLabelInfo

public CommandButtonLabelInfo(LabelInfo labelInfo,
                              KeyStroke accelerator)
Creates a new CommandButtonLabelInfo with the given label information and keystroke accelerator.

Parameters:
labelInfo - The label information. Must not be null.
accelerator - The keystroke accelerator. May be null.
Throws:
IllegalArgumentException - if labelInfo is null.
Method Detail

valueOf

public static CommandButtonLabelInfo valueOf(String labelDescriptor)
Return an instance of this class, created by parsing the information in the given label descriptor string. The expected format of this descriptor is the same as that used by the LabelInfo class, with the following additions: The expected format of the keystroke accelerator string is as described in the javadocs for the KeyStroke.getKeyStroke(String) method.

Parameters:
labelDescriptor - The label descriptor. May be null or empty, in which case, a default blank label info will be returned.
Returns:
A CommandButtonLabelInfo instance, never null.
Throws:
IllegalArgumentException - if labelDescriptor contains invalid syntax.
See Also:
LabelInfo, KeyStroke

getText

public String getText()
Returns the displayable text.

Returns:
The label text. Maybe an empty string but never null.

getMnemonic

public int getMnemonic()
Returns the mnemonic for the label.

Returns:
The mnemonic for the label.

getMnemonicIndex

public int getMnemonicIndex()
Returns the zero-based index for the mnemonic character within the label text.

Returns:
The mnemonic index or -1 to indicate that there is no associated mnemonic character.

getAccelerator

public KeyStroke getAccelerator()
Returns the keystroke accelerator for the label.

Returns:
The keystroke accelerator, or null.

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

configure

public AbstractButton configure(AbstractButton button)
Configures an existing button appropriately based on this label info's properties.

Specified by:
configure in interface ButtonConfigurer
Parameters:
button -
Returns:
the configured button.

configureAccelerator

protected void configureAccelerator(AbstractButton button,
                                    KeyStroke keystrokeAccelerator)
Sets the given keystroke accelerator on the given button.

Parameters:
button - The button. May be null.
keystrokeAccelerator - The accelerator. May be null.

toString

public String toString()

Overrides:
toString in class Object


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