org.pietschy.command.delegate

Class DelegateMediator

Known Direct 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

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.

Field Details

EMPTY_CONTAINER_ARRAY

public static final DelegateContainer[] EMPTY_CONTAINER_ARRAY

Method Details

addDelegateTrackerListener

public void addDelegateTrackerListener(DelegateMediatorListener listener)

fireDelegatesChanged

protected void fireDelegatesChanged(DelegateContainer[] containers)

getDelegateContainers

public DelegateContainer[] getDelegateContainers()

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.

removeDelegateTrackerListener

public void removeDelegateTrackerListener(DelegateMediatorListener listener)

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.