org.nuiton.jaxx.action
Interface ActionFactory<A extends MyAbstractAction>

Type Parameters:
A - type of boxed action
All Known Implementing Classes:
ActionFactoryFromProvider

public interface ActionFactory<A extends MyAbstractAction>

Action factory using the ActionConfig-like annotations to configure actions.

An ActionFactory builds actions always on a same type A and obtain them from some ActionProvider via methods newAction(String, JComponent) and newAction(String) .

If the action coming from the provider is not on the same type A, then the action is boxed in a * action A and use the generic mecanism of delegation provided by MyAbstractAction.

Use after the loadActions(jaxx.runtime.JAXXObject) to instanciate actions in ui with id equals a known action...

All actions instanciated are stored in a cache that you can request via method getActionFromCache(String), cacheEntrySet() and resetCache().

You can also from this factory fires some action via the methods fireAction(String, Object, JComponent) , fireAction(String, Object) , fireAction0(String, Object, MyAbstractAction).

Finally, a dispose() method is there to shut down all instanciated action when you want to dispose all uis.

Author:
chemit
See Also:
ActionProvider, MyAbstractAction

Method Summary
 java.util.Set<java.util.Map.Entry<java.lang.String,A>> cacheEntrySet()
           
 void dispose()
          dispose all actions in cache using MyAbstractAction.disposeUI() on each action, then resetCache()
 void fireAction(java.lang.String actionKey, java.lang.Object source)
          Fire an action given his key and his source, no widget are involved here
 void fireAction(java.lang.String actionKey, java.lang.Object source, javax.swing.JComponent component)
          Fire an action given his key, his source and tthe widget responsible of action
 void fireAction0(java.lang.String actionKey, java.lang.Object source, A action)
          Fire an action given his action's key, his source and the real action.
 MyAbstractAction getActionFromCache(java.lang.String actionKey)
           
 java.lang.String[] getActionNames()
           
 java.lang.Class<A> getBaseClass()
           
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Class<? extends MyAbstractAction>>> implsEntrySet()
           
 java.util.Map<java.lang.String,java.lang.Class<? extends MyAbstractAction>> init()
          Method to init the dictionary of knwon action implementations.
 void loadActions(JAXXObject ui)
          For a given ui, load all actions registred in factory.
 A newAction(java.lang.String actionKey)
          Obtain an action instance given his key (should call newAction(String, JComponent)

This is a convinient method when you want to obtain an action with no attached widget.

 A newAction(java.lang.String actionKey, javax.swing.JComponent component)
          Obtain an action instance given his key and widget
 void resetCache()
          clear the cache of instanciated actions.
 

Method Detail

init

java.util.Map<java.lang.String,java.lang.Class<? extends MyAbstractAction>> init()
Method to init the dictionary of knwon action implementations.

Returns:
the dictionary of known action implementations

getBaseClass

java.lang.Class<A> getBaseClass()
Returns:
the class of the base action of the factory.

implsEntrySet

java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Class<? extends MyAbstractAction>>> implsEntrySet()
Returns:
the set of all the action's classes known by the factory.

getActionNames

java.lang.String[] getActionNames()
Returns:
the array of names of all actions known by the factory

cacheEntrySet

java.util.Set<java.util.Map.Entry<java.lang.String,A>> cacheEntrySet()
Returns:
the set of all actions cached in factory indexed by their name

getActionFromCache

MyAbstractAction getActionFromCache(java.lang.String actionKey)
Parameters:
actionKey - the action's key
Returns:
the action in cache or null if action is not in cache

resetCache

void resetCache()
clear the cache of instanciated actions.


loadActions

void loadActions(JAXXObject ui)
For a given ui, load all actions registred in factory.

The id of the widget in ui is directly mapped to a action key.

Parameters:
ui - the ui to treate

newAction

A newAction(java.lang.String actionKey,
            javax.swing.JComponent component)
Obtain an action instance given his key and widget

Parameters:
actionKey - the key of action
component - the component using the action
Returns:
the instanciated action (could come from cache if already instanciated getActionFromCache(String)

newAction

A newAction(java.lang.String actionKey)
Obtain an action instance given his key (should call newAction(String, JComponent)

This is a convinient method when you want to obtain an action with no attached widget.

Parameters:
actionKey - the key of action
Returns:
the instanciated action (could come from cache if already instanciated getActionFromCache(String)

fireAction

void fireAction(java.lang.String actionKey,
                java.lang.Object source,
                javax.swing.JComponent component)
Fire an action given his key, his source and tthe widget responsible of action

Parameters:
actionKey - the action's key
source - the object source of action
component - the component doing the action

fireAction

void fireAction(java.lang.String actionKey,
                java.lang.Object source)
Fire an action given his key and his source, no widget are involved here

Parameters:
actionKey - the action's key
source - the object source of action

fireAction0

void fireAction0(java.lang.String actionKey,
                 java.lang.Object source,
                 A action)
Fire an action given his action's key, his source and the real action.

This is a convinient method when you need to modified action before fire it.

Parameters:
actionKey - action's key
source - source of action
action - real action

dispose

void dispose()
dispose all actions in cache using MyAbstractAction.disposeUI() on each action, then resetCache()



Copyright © 2008-2010 CodeLutin. All Rights Reserved.