com.pietschy.command
Class Command

java.lang.Object
  extended by com.pietschy.command.Command
All Implemented Interfaces:
Bindable, Identifiable
Direct Known Subclasses:
ActionCommand, CommandGroup

public abstract class Command
extends java.lang.Object
implements Identifiable, Bindable

The base class for all ActionCommands and CommandGroups. It provides the core methods for creating, initialising and managing buttons and menu items.

See Also:
ActionCommand, CommandGroup, Face

Field Summary
protected  Logger internalLog
           
static java.lang.String PROPERTY_ENABLED
           
static java.lang.String PROPERTY_VISIBLE
           
 
Constructor Summary
protected Command(java.lang.String id, boolean loadConfiguration)
          Constructs a new instance with the specified Id.
 
Method Summary
 void addContainerPropertyListener(java.lang.String propertyName, ContainerPropertyListener listener)
          Adds a ContainerPropertyListener to the command.
 void addFace(Face face)
          Adds the specified face to the command.
 void addHoverListener(HoverListener listener)
          Adds the specified listner.
 void addNotify(CommandGroup parent)
          Invoked whenever a command is added to a group.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the specified property change listener.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds the specified listener for the specified property.
protected  void attach(javax.swing.JComponent component, java.lang.String context)
          Attaches this command to the specified component using the specified face context.
 void bind()
          Binds to the global command container.
 void bind(CommandContainer container)
          Binds to the specified CommandContainer.
 void bind(java.awt.Component component)
          Binds to the specified component.
protected abstract  void bindToContainer(CommandContainer container)
          Invoked to bind this instance to the specified command container.
protected  java.util.Iterator<javax.swing.AbstractButton> buttonIterator()
          Returns an iterator over this commands buttons.
 void configureAppearance(java.awt.Component component)
          Configures the appearance of the specified button.
protected  void configureAppearances(Face face)
          Reconfigures all the buttons attached to this command that have the specified face.
protected  void configureButtonAppearances()
          Configures the appearance of all buttons created by this command.
protected  void configureButtonStates()
          Configures the enabled and visible state of all buttons and menu items.
protected  void configureButtonStates(javax.swing.AbstractButton button)
          Called to configure the enabled and visibles states of the specified button.
 javax.swing.AbstractButton createButton()
          Creates a new button.
 javax.swing.AbstractButton createButton(ButtonFactory factory)
          Create a new button using the specified ButtonFactory.
 javax.swing.AbstractButton createButton(ButtonFactory factory, java.lang.String context)
          Create a new button for the specified context command using the specified ButtonFactory.
 javax.swing.AbstractButton createButton(java.lang.String context)
          Creates a new button with for the specified context.
 javax.swing.JComponent createComponent(Factory factory, java.lang.String context)
          Convenience method that creates a new component for the specified face using the specified factory.
 javax.swing.JMenuItem createMenuItem()
          Creates a new menu item.
 javax.swing.JMenuItem createMenuItem(MenuFactory factory)
          Creates a new menu item using the specified MenuFactory.
 javax.swing.JMenuItem createMenuItem(MenuFactory factory, java.lang.String context)
          Creates a new menu item for the specified context sing the specified MenuFactory.
 javax.swing.JMenuItem createMenuItem(java.lang.String context)
          Creates a new menu item for this command for the specified context.
protected  void detach(javax.swing.JComponent component)
          Detaches this command from the specified button.
protected  void doButtonAttachments(javax.swing.AbstractButton button, java.lang.String context)
          Attaches this command to the specified button.
protected  void doButtonDetachments(javax.swing.AbstractButton button)
          Detaches this command from the specified button.
 boolean faceExists(java.lang.String context)
          Checks if a face exists for the specified context.
 Face findBestFace(java.lang.String context)
          Finds the best face to use for buttons created for using in the specified context.
protected  void fireHoverEnded(Face face, java.awt.Component source)
          Fires the HoverListener.hoverEnded(HoverEvent) event.
protected  void fireHoverStarted(Face face, java.awt.Component source)
          Fires the HoverListener.hoverStarted(HoverEvent) event.
protected  void fireIndexedPropertyChange(java.lang.String context, int i, boolean b, boolean b1)
           
protected  void fireIndexedPropertyChange(java.lang.String context, int i, int i1, int i2)
           
protected  void fireIndexedPropertyChange(java.lang.String context, int i, java.lang.Object o, java.lang.Object o1)
           
protected  void firePropertyChange(java.lang.String context, boolean b, boolean b1)
           
protected  void firePropertyChange(java.lang.String context, int i, int i1)
           
protected  void firePropertyChange(java.lang.String context, java.lang.Object o, java.lang.Object o1)
           
 java.lang.String[] getAlternativeFaceContexts(java.lang.String context)
          Gets a list of alternate contexts to try if no face has been registered for the specified context.
protected  ButtonFactory getButtonFactory()
          Gets the button factory to use for this command.
 javax.swing.AbstractButton getButtonIn(java.awt.Container container)
          Finds the first button created by this command in the specified container.
 CommandContainer getCommandContainer()
          Gets this commands CommandContainer or null if it doesn't have one.
 java.lang.Object getContainerProperty(java.lang.String property)
          A convenience method for getting the specified property from this commands CommandContainer.
(package private)  ContainerPropertyListenerSupport getContainerPropertySupport()
          Gets the ContainerPropertyListenerSupport instance.
 Face getDefaultFace()
          Gets this default face of the command.
 Face getDefaultFace(boolean createIfMissing)
          Gets the default face or creates it if it hasn't been defined.
 Face getFace(java.lang.String context)
          Gets the face for the specified context.
 Face getFace(java.lang.String context, boolean createIfMissing)
          Gets the face with the specified name, optionally creating it if it doesn't exits.
 java.lang.String getId()
          Gets the command id.
protected  MenuFactory getMenuFactory()
          Gets the menu factory to use for this command.
 java.lang.String getProperty(java.lang.String name)
          Gets the property value with the specified name.
 java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
          Gets the property value with the specified name.
 java.lang.String[] getPropertyNames()
          Gets all the property names defined for this command.
protected  ToolbarFactory getToolbarFactory()
          Gets the toolbar factory to use for this command.
 boolean isAnonymous()
          Checks if this is an anonymous instance.
 boolean isAttachedTo(java.awt.Component component)
          Tests if this command is attached to the specified button.
 boolean isBound()
          Checks if the command is currently bound to either a component or container.
 boolean isEnabled()
          Checks the enabled state of this command.
 boolean isVisible()
          Checks if the buttons of this command are visible.
protected  void loadConfiguration()
          Invoked during the constructor to load this commands configuration from the currently installed ConfigurationLoader.
protected  void notifyCommandContainerHierarchyChanged()
          Invoked to notify the command that a change in the container heirarchy has occured either via a binding operation or because a containers parent heirarchy has changed.
 void putProperties(java.util.Map<java.lang.String,java.lang.String> map)
          Adds all the specified properties to this command.
 void putProperty(java.lang.String name, java.lang.String value)
          Adds a property to the command.
 void rebind()
          Re-evaluates the current binding.
 void removeContainerPropertyListener(java.lang.String propertyName, ContainerPropertyListener listener)
          Removes the specified ContainerPropertyListener from the command.
 void removeHoverListener(HoverListener listener)
          Removes the specified listener.
 void removeNotify(CommandGroup parent)
          Invoked whenever a command is remvoved from a group.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the specified property change listener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Removes the specifed listener from the specified property.
 void requestFocusIn(java.awt.Container container)
          Find the first button in the specified container and calls JComponent.requestFocus() followed by Component.repaint().
 void setButtonFactory(ButtonFactory factory)
          Sets the factory to use when creating buttons.
 void setEnabled(boolean enabled)
          Updates the enabled state of this command and all its buttons.
 void setMenuFactory(MenuFactory factory)
          Sets the factory to use when creating menus and menu items.
 void setToolbarFactory(ToolbarFactory factory)
          Sets the factory to use when creating toolbars and toolbar buttons.
 void setVisible(boolean visible)
          Sets the visible state of this command and all its buttons and menu item.
 java.lang.String toString()
          Returns a string representation of the object.
 void unbind()
          Unbinds from the current container or component.
protected abstract  void unbindFromContainer(CommandContainer container)
          Invoked to unbind this instance from the specified command container.
static void validateId(java.lang.String id)
          Validates the specified command id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_ENABLED

public static final java.lang.String PROPERTY_ENABLED
See Also:
Constant Field Values

PROPERTY_VISIBLE

public static final java.lang.String PROPERTY_VISIBLE
See Also:
Constant Field Values

internalLog

protected Logger internalLog
Constructor Detail

Command

protected Command(java.lang.String id,
                  boolean loadConfiguration)
Constructs a new instance with the specified Id.

Parameters:
id - the command id.
loadConfiguration - true to invoke loadConfiguration() during construction, false otherwise.
Throws:
InvalidIdException - if the id contains whitespace.
Method Detail

loadConfiguration

protected void loadConfiguration()
Invoked during the constructor to load this commands configuration from the currently installed ConfigurationLoader.


getId

public java.lang.String getId()
Gets the command id.

Specified by:
getId in interface Identifiable
Returns:
the command id.

isAnonymous

public boolean isAnonymous()
Checks if this is an anonymous instance. Anonymous commands have no identifier, and can't be exported or configured by the DefaultConfigurationLoader. They are useful when you need to programatically create a command.

All commands created without an id are anonymous.

Returns:
true if this command is anonymous, false otherwise.

bind

public void bind()
Description copied from interface: Bindable
Binds to the global command container.

Specified by:
bind in interface Bindable
See Also:
CommandContainer.globalInstance()

bind

public void bind(java.awt.Component component)
Description copied from interface: Bindable
Binds to the specified component. The component heirarhy will be traversed to locate the nearest bound CommandContainer.

Specified by:
bind in interface Bindable
Parameters:
component - the component to bind to.
See Also:
CommandContainer.bind(Component)

bind

public void bind(CommandContainer container)
Description copied from interface: Bindable
Binds to the specified CommandContainer.

Specified by:
bind in interface Bindable
Parameters:
container - the container to bind to.

rebind

public void rebind()
Description copied from interface: Bindable
Re-evaluates the current binding. This is only relevant for component bindings.

Specified by:
rebind in interface Bindable

unbind

public void unbind()
Description copied from interface: Bindable
Unbinds from the current container or component.

Specified by:
unbind in interface Bindable

isBound

public boolean isBound()
Checks if the command is currently bound to either a component or container.

Returns:
true if the command is bound, false otherwise.

bindToContainer

protected abstract void bindToContainer(CommandContainer container)
Invoked to bind this instance to the specified command container.

Parameters:
container - the container to bind to.

unbindFromContainer

protected abstract void unbindFromContainer(CommandContainer container)
Invoked to unbind this instance from the specified command container.

Parameters:
container - the container to unbind from.

notifyCommandContainerHierarchyChanged

protected void notifyCommandContainerHierarchyChanged()
Invoked to notify the command that a change in the container heirarchy has occured either via a binding operation or because a containers parent heirarchy has changed.

This operation does nothing but can be overridden by subclasses to perform any required updates.

This method will be invoked after both bindToContainer(CommandContainer) and unbindFromContainer(CommandContainer).


getCommandContainer

public CommandContainer getCommandContainer()
Gets this commands CommandContainer or null if it doesn't have one.

Returns:
this commands CommandContainer or null if it doesn't have one.

putProperty

public void putProperty(java.lang.String name,
                        java.lang.String value)
Adds a property to the command. Properties can be specified in the configuration files.
   # specifiy the "color" property as "blue"
   command@properties.color=blue
 

Parameters:
name - the property name
value - the property value.

putProperties

public void putProperties(java.util.Map<java.lang.String,java.lang.String> map)
Adds all the specified properties to this command.

Parameters:
map - the map containing the properties.
See Also:
putProperty(String, String)

getProperty

public java.lang.String getProperty(java.lang.String name)
Gets the property value with the specified name.

Parameters:
name - the property name.
Returns:
the property value or null if the property doesn't exists.

getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String defaultValue)
Gets the property value with the specified name. If the value is null then the specified defaultValue is returned.

Parameters:
name - the property name.
defaultValue - the defaultValue to return if the real value is null.
Returns:
the property value or defaultValue if the real value is null.

getPropertyNames

public java.lang.String[] getPropertyNames()
Gets all the property names defined for this command.

Returns:
all the property names defined for this command.

getContainerProperty

public java.lang.Object getContainerProperty(java.lang.String property)
A convenience method for getting the specified property from this commands CommandContainer.

This method will return null if the command isn't currently bound to a container.

Parameters:
property - the property to retrieve.
Returns:
the value of this commands container property, or null if the command has no container.
See Also:
CommandContainer.getProperty(String), addContainerPropertyListener(String, ContainerPropertyListener)

addNotify

public void addNotify(CommandGroup parent)
Invoked whenever a command is added to a group. Commands may belong to more than one group at any given time. This method does nothing by default, subclasses may override to perform special configuration if needed.

Parameters:
parent - the parent group to which the command was added.

removeNotify

public void removeNotify(CommandGroup parent)
Invoked whenever a command is remvoved from a group. Commands may belong to more than one group at any given time. This method does nothing by default, subclasses may override to perform special configuration if needed.

Parameters:
parent - the parent from which the command was removed.

doButtonAttachments

protected void doButtonAttachments(javax.swing.AbstractButton button,
                                   java.lang.String context)
Attaches this command to the specified button. If the specified face doesn't exist, then the default face is used.

Parameters:
button - the button to which this command should be attached.

doButtonDetachments

protected void doButtonDetachments(javax.swing.AbstractButton button)
Detaches this command from the specified button.

Parameters:
button - the button from which this command is to be detached.

attach

protected void attach(javax.swing.JComponent component,
                      java.lang.String context)
Attaches this command to the specified component using the specified face context.

Parameters:
component - the component to which this command should be attached.
context - the face context to use.

detach

protected void detach(javax.swing.JComponent component)
Detaches this command from the specified button.

Parameters:
component - the button from which this command is to be detached.

isAttachedTo

public boolean isAttachedTo(java.awt.Component component)
Tests if this command is attached to the specified button.

Parameters:
component - the button to check
Returns:
true if this command is attached to the button, false otherwise.

configureButtonStates

protected void configureButtonStates()
Configures the enabled and visible state of all buttons and menu items.

See Also:
configureButtonStates(AbstractButton)

configureButtonStates

protected void configureButtonStates(javax.swing.AbstractButton button)
Called to configure the enabled and visibles states of the specified button. Subclasses may override this method to perform special configuration if required.

Parameters:
button - the button to configure.

getButtonFactory

protected ButtonFactory getButtonFactory()
Gets the button factory to use for this command. If the button factory hasn't been configured by calling setButtonFactory(com.pietschy.command.factory.ButtonFactory), then the default factory specified by Defaults.getButtonFactory() is used.

Returns:
this commands default ButtonFactory.
See Also:
setButtonFactory(com.pietschy.command.factory.ButtonFactory), Defaults.setButtonFactory(ButtonFactory)

setButtonFactory

public void setButtonFactory(ButtonFactory factory)
Sets the factory to use when creating buttons.

Parameters:
factory - the factory to use or null to use the global factory defined by Defaults.getButtonFactory().

getToolbarFactory

protected ToolbarFactory getToolbarFactory()
Gets the toolbar factory to use for this command. If the factory hasn't been configured by calling setToolbarFactory(ToolbarFactory) then the default factory specified by Defaults.getToolbarFactory() is used.

Returns:
this commands default toolbar factory
See Also:
setToolbarFactory(ToolbarFactory), Defaults.setToolbarFactory(ToolbarFactory)

setToolbarFactory

public void setToolbarFactory(ToolbarFactory factory)
Sets the factory to use when creating toolbars and toolbar buttons.

Parameters:
factory - the factory to use or null to use the global factory defined by Defaults.getToolbarFactory().

getMenuFactory

protected MenuFactory getMenuFactory()
Gets the menu factory to use for this command. If the factory hasn't been configured by calling setMenuFactory(MenuFactory) then the default factory specified by Defaults.getMenuFactory() is used.

Returns:
this commands default menu factory
See Also:
setMenuFactory(MenuFactory), Defaults.setMenuFactory(MenuFactory)

setMenuFactory

public void setMenuFactory(MenuFactory factory)
Sets the factory to use when creating menus and menu items.

Parameters:
factory - the factory to use or null to use the global factory defined by Defaults.getMenuFactory().

setEnabled

public void setEnabled(boolean enabled)
Updates the enabled state of this command and all its buttons.

Parameters:
enabled - true to enable the command, false to disable it.

isEnabled

public boolean isEnabled()
Checks the enabled state of this command.

Returns:
true if the command is enabled, false if disabled.

setVisible

public void setVisible(boolean visible)
Sets the visible state of this command and all its buttons and menu item.

Parameters:
visible - true to show the commands buttons, false to hide them.

isVisible

public boolean isVisible()
Checks if the buttons of this command are visible.

Returns:
true if the command is visible, false otherwise.

buttonIterator

protected java.util.Iterator<javax.swing.AbstractButton> buttonIterator()
Returns an iterator over this commands buttons.

Returns:
an Iterator over the attached buttons

getDefaultFace

public Face getDefaultFace()
Gets this default face of the command.

Returns:
the default face or null if this command has no faces.
See Also:
getDefaultFace(boolean), findBestFace(String)

getDefaultFace

public Face getDefaultFace(boolean createIfMissing)
Gets the default face or creates it if it hasn't been defined.

Parameters:
createIfMissing - true to create the face if it doesn't exist, false to return null if it doesn't exists.
Returns:
this commands default face or null if there is no default face and createIfMissing is false.
See Also:
findBestFace(String)

getFace

public Face getFace(java.lang.String context)
Gets the face for the specified context.

Parameters:
context - the name of the face to retrieved. Face.BUTTON for example.
Returns:
the specified face, or null if the face doesn't exists.
See Also:
getFace(String, boolean), findBestFace(String)

getFace

public Face getFace(java.lang.String context,
                    boolean createIfMissing)
Gets the face with the specified name, optionally creating it if it doesn't exits.

Parameters:
context - the context of the face to retrieved. Face.BUTTON for example.
createIfMissing - true to create the face if it doesn't exist, false to return null.
Returns:
the specified face, or the next best face according to getAlternativeFaceContexts(java.lang.String).

addFace

public void addFace(Face face)
Adds the specified face to the command.

Parameters:
face - the face to add.
Throws:
java.lang.IllegalStateException - if a face with the same context already exists.

findBestFace

public Face findBestFace(java.lang.String context)
Finds the best face to use for buttons created for using in the specified context. If there is no exact match then a search is performed using getAlternativeFaceContexts(String). If no matching face is found a FaceNotFoundException is thrown.

Parameters:
context - the desired face context.
Returns:
the face most suited for the specified context.
Throws:
FaceNotFoundException - if no suitable face can be found.

faceExists

public boolean faceExists(java.lang.String context)
Checks if a face exists for the specified context.

Parameters:
context - the context of interest
Returns:
true if a face exits, false otherwise.

getAlternativeFaceContexts

public java.lang.String[] getAlternativeFaceContexts(java.lang.String context)
Gets a list of alternate contexts to try if no face has been registered for the specified context.

This method delegates to Defaults.getAlternativeFaceContexts(String).

Parameters:
context - the desired context
Returns:
a list of alternative contexts with the best alternative at index 0.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the specified property change listener.

Parameters:
listener - the listener to add.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds the specified listener for the specified property.

Parameters:
propertyName - the property to listen to.
listener - the listener to add

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the specified property change listener.

Parameters:
listener - the listener to remove

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Removes the specifed listener from the specified property.

Parameters:
propertyName - the property to stop listening to.
listener - the listener to remove

addContainerPropertyListener

public void addContainerPropertyListener(java.lang.String propertyName,
                                         ContainerPropertyListener listener)
Adds a ContainerPropertyListener to the command. The listener will be notified when ever there is a change to the value of the named container property. Container property values may change as a result of:
  1. Binding or unbinding the command
  2. Calling CommandContainer.putProperty(String, Object) within the commands container hierarchy
  3. Any changes to the container hierarchy
In all of the above cases the listener will be notified.

Unlike PropertyChangeListeners, ContainerPropertyListeners only provide the new property value.

Parameters:
propertyName - the name of the property to monitor
listener - the listener

removeContainerPropertyListener

public void removeContainerPropertyListener(java.lang.String propertyName,
                                            ContainerPropertyListener listener)
Removes the specified ContainerPropertyListener from the command.

Parameters:
propertyName - the property that was being monitored.
listener - the listener to remove.

getContainerPropertySupport

ContainerPropertyListenerSupport getContainerPropertySupport()
Gets the ContainerPropertyListenerSupport instance. This method lazily creates the support object.

Returns:
the support object.

addHoverListener

public void addHoverListener(HoverListener listener)
Adds the specified listner. The listener will be notified when ever the mouse hovers a button or menu item created by this command.

See HoverManager to listen to hover events from all commands.

Parameters:
listener - the listener to add.
See Also:
HoverManager

removeHoverListener

public void removeHoverListener(HoverListener listener)
Removes the specified listener.

Parameters:
listener - the listener to remove
See Also:
HoverManager

fireHoverStarted

protected void fireHoverStarted(Face face,
                                java.awt.Component source)
Fires the HoverListener.hoverStarted(HoverEvent) event.

Parameters:
face - the face used to create the hovered component.
source - the component that was hovered.

fireHoverEnded

protected void fireHoverEnded(Face face,
                              java.awt.Component source)
Fires the HoverListener.hoverEnded(HoverEvent) event.

Parameters:
face - the face used to create the hovered component.
source - the component that was hovered.

requestFocusIn

public void requestFocusIn(java.awt.Container container)
Find the first button in the specified container and calls JComponent.requestFocus() followed by Component.repaint().

Parameters:
container - the container that contains a button from this command.

getButtonIn

public javax.swing.AbstractButton getButtonIn(java.awt.Container container)
Finds the first button created by this command in the specified container.

Parameters:
container - the container that holds a button from this command.

createButton

public javax.swing.AbstractButton createButton()
Creates a new button.

Returns:
the newly created button

createButton

public javax.swing.AbstractButton createButton(java.lang.String context)
Creates a new button with for the specified context.

Returns:
the newly created button

createButton

public javax.swing.AbstractButton createButton(ButtonFactory factory)
Create a new button using the specified ButtonFactory.

Returns:
a new button
See Also:
ButtonFactory

createButton

public javax.swing.AbstractButton createButton(ButtonFactory factory,
                                               java.lang.String context)
Create a new button for the specified context command using the specified ButtonFactory.

Returns:
a new button

createMenuItem

public javax.swing.JMenuItem createMenuItem()
Creates a new menu item.

Returns:
a new menu item
See Also:
createMenuItem(String), createMenuItem(MenuFactory, String), createMenuItem(MenuFactory)

createMenuItem

public javax.swing.JMenuItem createMenuItem(java.lang.String context)
Creates a new menu item for this command for the specified context.

Returns:
a new menu item.
See Also:
createMenuItem(MenuFactory, String), createMenuItem(MenuFactory)

createMenuItem

public javax.swing.JMenuItem createMenuItem(MenuFactory factory)
Creates a new menu item using the specified MenuFactory.

Returns:
a new menu item.
See Also:
createMenuItem(MenuFactory, String)

createMenuItem

public javax.swing.JMenuItem createMenuItem(MenuFactory factory,
                                            java.lang.String context)
Creates a new menu item for the specified context sing the specified MenuFactory.

Returns:
a new menu item.

createComponent

public javax.swing.JComponent createComponent(Factory factory,
                                              java.lang.String context)
Convenience method that creates a new component for the specified face using the specified factory.

This method will invoke either createButton(ButtonFactory, String) or createMenuItem(MenuFactory, String) based on the factory type.

This method is also the main entry point for the library when creating buttons and menus for using in groups. This allows subclasses to create custom components that are not an instance of AbstractButton.

Parameters:
factory - the factory to use to create the component.
context - the face context to use.
Returns:
a component suitable for the specified factory and context.

configureButtonAppearances

protected void configureButtonAppearances()
Configures the appearance of all buttons created by this command.


configureAppearances

protected void configureAppearances(Face face)
Reconfigures all the buttons attached to this command that have the specified face. This method will be automatically called whenever the property of a face is modified.

Parameters:
face - the face whose buttons are to be reconfigured.

configureAppearance

public void configureAppearance(java.awt.Component component)
Configures the appearance of the specified button. This method simply delegates to Defaults.getFaceRenderer().

Parameters:
component - the button to configure.

firePropertyChange

protected void firePropertyChange(java.lang.String context,
                                  java.lang.Object o,
                                  java.lang.Object o1)

firePropertyChange

protected void firePropertyChange(java.lang.String context,
                                  int i,
                                  int i1)

firePropertyChange

protected void firePropertyChange(java.lang.String context,
                                  boolean b,
                                  boolean b1)

fireIndexedPropertyChange

protected void fireIndexedPropertyChange(java.lang.String context,
                                         int i,
                                         java.lang.Object o,
                                         java.lang.Object o1)

fireIndexedPropertyChange

protected void fireIndexedPropertyChange(java.lang.String context,
                                         int i,
                                         int i1,
                                         int i2)

fireIndexedPropertyChange

protected void fireIndexedPropertyChange(java.lang.String context,
                                         int i,
                                         boolean b,
                                         boolean b1)

toString

public java.lang.String toString()
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character '@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

validateId

public static void validateId(java.lang.String id)
Validates the specified command id.

Parameters:
id - the id to check.
Throws:
InvalidIdException - if the id isn't valid.


Copyright © 2006 - 2007 Andrew Pietsch