|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.pietschy.command.delegate.AbstractDelegateMediator
com.pietschy.command.delegate.FocusTrackingDelegateMediator
public class FocusTrackingDelegateMediator
A DelegateMediator that finds its ActionCommandExecutor set by
traversing up the swing component hierarchy from the focused component. The final set
consists of all executors in all DelegateProviders found in the focus heirarchy
along with any that have been statically added using setBaselineDelegateProviders(DelegateProvider[])
or setBaselineDelegates(ActionCommandExecutor, ActionCommandExecutor...).
Those found from the focus hierarchy are given precedence over the baseline providers.
The delegate provider heirarchy is only updated on changes to the permenant focus owner.
The following examples show a panel the implements DelegateProvider utilising
an internal CommandContainer.
class MyPanel extends JPanel implements DelegateProvider
{
private CommandContainer commandContainer = new CommandContainer();
public MyPanel()
{
...
}
public ActionCommandExecutor getActionCommandExecutor(String id)
{
commandContainer.getActionCommandExecutor(id);
}
}
| Field Summary |
|---|
| Fields inherited from class com.pietschy.command.delegate.AbstractDelegateMediator |
|---|
EMPTY_PROVIDER_ARRAY |
| Constructor Summary | |
|---|---|
FocusTrackingDelegateMediator(java.awt.Window context)
Creates a new DelegateManager that tracks focus in the same window as the specified component. |
|
FocusTrackingDelegateMediator(java.awt.Window context,
RelatedWindowDiscriminator discriminator)
Creates a new DelegateManager that uses the specified RelatedWindowDiscriminator to
determine focus events related to the main window. |
|
| Method Summary | |
|---|---|
protected void |
extractProviders(java.awt.Component component,
java.util.ArrayList<DelegateProvider> providers)
Extracts all the provider from the heirarchy of the specified component. |
ActionCommandExecutor |
getExecutor(java.lang.String id)
Searches the container hierarchy and gets the first executor it finds. |
java.awt.Window |
getWindow()
Gets the window associated with this mediator. |
protected boolean |
isEligableForTracking(java.awt.Component component)
Checks if the specified component is eligable for focus tracking. |
protected void |
recomputeProvidersFromComponent(java.awt.Component component)
Invoked on a focus change to update the current provider list and notify all listeners |
void |
setBaselineDelegateProvider(DelegateProvider staticProvider)
Sets the current static provider list to be the specified provider. |
void |
setBaselineDelegateProviders(DelegateProvider[] providers)
Sets the current static provider list to the specified list. |
void |
setBaselineDelegates(ActionCommandExecutor delegate,
ActionCommandExecutor... otherDelegates)
Sets the current list of baseline delegates to those specified. |
void |
setBaselineDelegates(java.util.Collection<? extends ActionCommandExecutor> delegates)
Sets the current list of baseline delegates to those specified. |
void |
setRelatedWindowDiscriminator(RelatedWindowDiscriminator relatedWindowDiscriminator)
Sets the discriminator to use when tracking focus events. |
| Methods inherited from class com.pietschy.command.delegate.AbstractDelegateMediator |
|---|
addDelegateMediatorListener, fireDelegatesChanged, getExecutor, nullSafeArray, nullSafeArray, removeDelegateMediatorListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FocusTrackingDelegateMediator(java.awt.Window context)
context - the window of interest.
public FocusTrackingDelegateMediator(java.awt.Window context,
RelatedWindowDiscriminator discriminator)
RelatedWindowDiscriminator to
determine focus events related to the main window.
context - the window of interest for this mediator.| Method Detail |
|---|
public java.awt.Window getWindow()
public void setBaselineDelegateProvider(DelegateProvider staticProvider)
null then the static provider list will be emptied, thus clearing all
delegates until the next focus event.
staticProvider - the provider to use or null to clear the static
provider list.public void setBaselineDelegateProviders(DelegateProvider[] providers)
null then the provider list will be emptied, thus clearing all
delegates until the next focus event.
providers - the providers to use or null to clear the provider list.
public void setBaselineDelegates(ActionCommandExecutor delegate,
ActionCommandExecutor... otherDelegates)
delegate - the first delegate.otherDelegates - any additional delegates.public void setBaselineDelegates(java.util.Collection<? extends ActionCommandExecutor> delegates)
delegates - the new delegates to use.public ActionCommandExecutor getExecutor(java.lang.String id)
DelegateMediator
id - the id to search for.
null if
none exists.public void setRelatedWindowDiscriminator(RelatedWindowDiscriminator relatedWindowDiscriminator)
relatedWindowDiscriminator - the discriminator to use.
java.lang.NullPointerException - if the discriminator is null.
protected void extractProviders(java.awt.Component component,
java.util.ArrayList<DelegateProvider> providers)
component - the component to traverse.providers - the array in which to store any providers that are found.protected void recomputeProvidersFromComponent(java.awt.Component component)
component - the currently focused component.protected boolean isEligableForTracking(java.awt.Component component)
true
but can be overridden by subclasses to prevent certain focus events from re-computing the delegate
provider heirarchy.
component - the component that has been focused.
true if the component should result in recalculation of the delegate
chain. If false the delegate chain will remain as it was for the last
focus event.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||