org.pietschy.command.delegate
Class DelegateMediator

java.lang.Object
  extended by org.pietschy.command.delegate.DelegateMediator
Direct Known Subclasses:
FocusTrackingDelegateMediator

public class DelegateMediator
extends java.lang.Object

DelegateMediators are used by DelegatingCommand instances to find their delegates. Each mediator is bound to a specified window and is associated with a command by invoking DelegatingCommand.trackDelegateIn(String, java.awt.Window).

DelegateMediator instances can be accessed by calling DelegateManager.getMediatorFor(java.awt.Component) and DelegateManager.getMediatorFor(java.awt.Window).

You can customise the creation of mediators by providing a custom DelegateMediatorFactory to the DelegateManager.


Field Summary
static DelegateContainer[] EMPTY_CONTAINER_ARRAY
           
 
Constructor Summary
DelegateMediator()
           
 
Method Summary
 void addDelegateTrackerListener(DelegateMediatorListener listener)
           
protected  void fireDelegatesChanged(DelegateContainer[] containers)
           
 DelegateContainer[] getDelegateContainers()
           
protected  DelegateContainer[] nullSafeArray(DelegateContainer container)
          Creates an array containing the specified container.
protected  DelegateContainer[] nullSafeArray(DelegateContainer[] containers)
          Returns the specified array or and empty array if containers was null.
 void removeDelegateTrackerListener(DelegateMediatorListener listener)
           
 void setDelegateContainer(DelegateContainer container)
          This method is a convenience for setDelegateContainers(DelegateContainer[]).
 void setDelegateContainers(DelegateContainer[] containers)
          Sets the current DelegateContainer to be used by all DelegatingCommands associated with this mediator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CONTAINER_ARRAY

public static final DelegateContainer[] EMPTY_CONTAINER_ARRAY
Constructor Detail

DelegateMediator

public DelegateMediator()
Method Detail

setDelegateContainer

public void setDelegateContainer(DelegateContainer container)
This method is a convenience for setDelegateContainers(DelegateContainer[]).

Parameters:
container - the container to use or null to disable all delegates.

setDelegateContainers

public void setDelegateContainers(DelegateContainer[] containers)
Sets the current DelegateContainer to be used by all DelegatingCommands associated with this mediator.

Parameters:
containers - the containers to use, or null to clear all the containers.

getDelegateContainers

public DelegateContainer[] getDelegateContainers()

addDelegateTrackerListener

public void addDelegateTrackerListener(DelegateMediatorListener listener)

removeDelegateTrackerListener

public void removeDelegateTrackerListener(DelegateMediatorListener listener)

nullSafeArray

protected DelegateContainer[] nullSafeArray(DelegateContainer container)
Creates an array containing the specified container. If container is null this method returns and empty array.

Parameters:
container - the container.
Returns:
a non null array containing the container or an empty array if the container was null.

nullSafeArray

protected DelegateContainer[] nullSafeArray(DelegateContainer[] containers)
Returns the specified array or and empty array if containers was null.

Parameters:
containers - the DelegateContainers to use.
Returns:
the specified array or and empty array if containers was null.

fireDelegatesChanged

protected void fireDelegatesChanged(DelegateContainer[] containers)