org.pietschy.command.delegate

Class FocusTrackingDelegateMediator


public class FocusTrackingDelegateMediator
extends DelegateMediator

This mediator derives the DelegateContainer heirarchy by traversing up the component hierarchy from the currently focused component. The final container list consists of any static constainers (see setStaticContainers(DelegateContainer[])) and those compulted from the focus hierarchy. Those found from the focus hierarchy are given precedence over the static containers.

This mediator is used when you install the FocusTrackingDelegateMediatorFactory into the DelegateManager. There are also convenience methods for getting the current mediator from the DelegateManager without explicitly casting.

See Also:
setDelegateContainers(DelegateContainer[]), setDelegateContainer(DelegateContainer), getMediatorFor(java.awt.Window), getMediatorFor(java.awt.Component), DelegateManager.setDelegateMediatorFactory(DelegateMediatorFactory)

Field Summary

Fields inherited from class org.pietschy.command.delegate.DelegateMediator

EMPTY_CONTAINER_ARRAY

Constructor Summary

FocusTrackingDelegateMediator(Window window, RelatedWindowDiscriminator discriminator)
Creates a new DelegateManager for the specified window.

Method Summary

static FocusTrackingDelegateMediator
getMediatorFor(Component component)
Conveinence method for DelegateManager.getMediatorFor(java.awt.Component) for when the FocusTrackingDelegateMediatorFactory is being used.
static FocusTrackingDelegateMediator
getMediatorFor(Window window)
Conveinence method for DelegateManager.getMediatorFor(java.awt.Window) for when the FocusTrackingDelegateMediatorFactory is being used.
void
setRelatedWindowDiscriminator(RelatedWindowDiscriminator relatedWindowDiscriminator)
Sets the discriminator to use when tracking focus events.
void
setStaticContainer(DelegateContainer staticContainer)
Sets the current static container list to be the specified container.
void
setStaticContainers(DelegateContainer[] containers)
Sets the current static container list to the specified list.

Methods inherited from class org.pietschy.command.delegate.DelegateMediator

addDelegateTrackerListener, fireDelegatesChanged, getDelegateContainers, nullSafeArray, nullSafeArray, removeDelegateTrackerListener, setDelegateContainer, setDelegateContainers

Constructor Details

FocusTrackingDelegateMediator

public FocusTrackingDelegateMediator(Window window,
                                     RelatedWindowDiscriminator discriminator)
Creates a new DelegateManager for the specified window.
Parameters:
window - the window of interest.

Method Details

getMediatorFor

public static FocusTrackingDelegateMediator getMediatorFor(Component component)
Conveinence method for DelegateManager.getMediatorFor(java.awt.Component) for when the FocusTrackingDelegateMediatorFactory is being used.
Parameters:
component - the component of interest.
Returns:

getMediatorFor

public static FocusTrackingDelegateMediator getMediatorFor(Window window)
Conveinence method for DelegateManager.getMediatorFor(java.awt.Window) for when the FocusTrackingDelegateMediatorFactory is being used.
Parameters:
window - the window of interest.
Returns:

setRelatedWindowDiscriminator

public void setRelatedWindowDiscriminator(RelatedWindowDiscriminator relatedWindowDiscriminator)
Sets the discriminator to use when tracking focus events. The discriminator is used to determine if the currently focused window should be tracked for delegates pertaining to DelegatingCommands bound to the parent window.

The default discriminator only tracks delegates in the same window as the DelegatingCommand.

Parameters:
relatedWindowDiscriminator - the discriminator to use.

setStaticContainer

public void setStaticContainer(DelegateContainer staticContainer)
Sets the current static container list to be the specified container. This method will removed all focus specific containers until the next focus change. If the container is null then the static container list will be emptied, thus clearing all delegates until the next focus event.
Parameters:
staticContainer - the container to use or null to clear the static container list.

setStaticContainers

public void setStaticContainers(DelegateContainer[] containers)
Sets the current static container list to the specified list. This method will removed all focus specific containers until the next focus change. If containers is null then the container list will be emptied, thus clearing all delegates until the next focus event.
Parameters:
containers - the containers to use or null to clear the container list.