com.levigo.util.swing.action
Class DefaultActionFactory

java.lang.Object
  extended by com.levigo.util.swing.action.DefaultActionFactory
All Implemented Interfaces:
ActionFactory, NamedActionFactory

public class DefaultActionFactory
extends Object
implements NamedActionFactory

Is implementation of the ActionFactory

The factory read the class information for the actions from the property file.

Note:Actions aren't Singletons!

Author:
l.boureanu@levigo.de, Carolin Köhler
See Also:
ActionFactory

Field Summary
protected  String factoryName
          Name of this action factory, usually its properties file name.
protected  List<BasicActionFactory> linkedActionFactories
          List of associated action factories
 
Method Summary
static void addActionCreationListener(ActionCreationListener listener)
          Adds a action creation listener to receive informations or failure messages of action creation process.
 void addLinkedActionFactory(BasicActionFactory actionFactory)
          Adds an action factory as linked factory to this factory.
 CommandAction getAction(Context context, String key)
          Default constructor using the settings of the actions.properties file.
 CommandAction getAction(Context context, String key, String name, String commands, String shortDescription, String longDescription, Icon smallIcon, Icon largeIcon, String actionCommandKey, KeyStroke acceleratorKey, int mnemonicKey, HashMap<String,Object> otherParameters)
          Settings for the icons, texts etc.
static ActionCreationListener[] getActionCreationListener()
          Returns an array of currently registered creation listeners
 String getFactoryName()
          Returns the name of this factory, usually its properties resource name.
static DefaultActionFactory getInstance(String propertiesFileName)
          Provide access to the one and only instance of this factory.
 NamedActionFactory[] getLinkedActionFactories()
          Returns an array of linked actions factories
 String getLinkedFactoryDescription()
          Returns a description of linked factories.
 String getLookupProperty(String key)
          Allows an application to programmatically request lookup properties.
 void insertLinkedActionFactory(int index, BasicActionFactory actionFactory)
          Inserts a action factory at index position of linked factories.
 void putLookupProperty(String key, String value)
          Deprecated. use setLookupProperty(String, String) instead
static void removeActionCreationListener(ActionCreationListener listener)
          Removes a action creation listener.
 void removeLinkedActionFactory(BasicActionFactory actionFactory)
          Removes an action factory of linked factories.
 void reset()
          Clears and resets this factory instance.
 void setLookupProperty(String key, String value)
          Allows an application to overwrite or set lookup properties programmatically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factoryName

protected String factoryName
Name of this action factory, usually its properties file name.


linkedActionFactories

protected List<BasicActionFactory> linkedActionFactories
List of associated action factories

Method Detail

addActionCreationListener

public static void addActionCreationListener(ActionCreationListener listener)
Adds a action creation listener to receive informations or failure messages of action creation process.

Parameters:
listener - the listener instance to add

removeActionCreationListener

public static void removeActionCreationListener(ActionCreationListener listener)
Removes a action creation listener.

Parameters:
listener - the listener instance to remove

getActionCreationListener

public static ActionCreationListener[] getActionCreationListener()
Returns an array of currently registered creation listeners

Returns:
ActionCreationListener[] registered listeners

getInstance

public static DefaultActionFactory getInstance(String propertiesFileName)
Provide access to the one and only instance of this factory. It can exist more types of the ActionFactorybut just one instance.

Parameters:
propertiesFileName -
Returns:
instance of the ActionFactory

getLinkedFactoryDescription

public String getLinkedFactoryDescription()
Returns a description of linked factories.


getFactoryName

public String getFactoryName()
Description copied from interface: NamedActionFactory
Returns the name of this factory, usually its properties resource name.

Specified by:
getFactoryName in interface NamedActionFactory
Returns:
name
See Also:
NamedActionFactory.getFactoryName()

putLookupProperty

@Deprecated
public void putLookupProperty(String key,
                                         String value)
Deprecated. use setLookupProperty(String, String) instead

Allows an application to programmatically overwrite or set lookup properties. This is useful if some of the properties are not yet known in advance from the action.properties file.

Parameters:
key -
value - The value of the given key, null if the key is not mapped to any value.

setLookupProperty

public void setLookupProperty(String key,
                              String value)
Allows an application to overwrite or set lookup properties programmatically. This is useful if some of the properties are not yet known in advance from its properties resource.

Parameters:
key -
value - The value of the given key, null if the key is not mapped to any value.
Throws:
NullPointerException - if the key or value is null.

getLookupProperty

public String getLookupProperty(String key)
Allows an application to programmatically request lookup properties.

Parameters:
key - The key to look up (e.g. MyAction.commands or MyAction.ShortDescription)
Returns:
value The value of the given key, null if the key is not mapped to any value.
Throws:
NullPointerException - if the key is null.

getAction

public CommandAction getAction(Context context,
                               String key)
Description copied from interface: ActionFactory
Default constructor using the settings of the actions.properties file.
Short name is used as the action's name.

To create the commands is the default command factory used.

Specified by:
getAction in interface ActionFactory
Parameters:
context - belongs to the context
key - key of the commandAction
Returns:
created CommandAction
See Also:
ActionFactory.getAction(com.levigo.util.swing.action.Context, java.lang.String)

getAction

public CommandAction getAction(Context context,
                               String key,
                               String name,
                               String commands,
                               String shortDescription,
                               String longDescription,
                               Icon smallIcon,
                               Icon largeIcon,
                               String actionCommandKey,
                               KeyStroke acceleratorKey,
                               int mnemonicKey,
                               HashMap<String,Object> otherParameters)
Description copied from interface: ActionFactory
Settings for the icons, texts etc. in the action.properties file can be overwritten. Key is used as the action's name.

To create the commands is the default command factory used.

Specified by:
getAction in interface ActionFactory
Parameters:
context - belongs to the context
key - key of the commandAction
name - value for Action.NAME
commands - all commands of the commandAction
shortDescription - value for Action.SHORT_DESCRIPTION
longDescription - value for Action.LONG_DESCRIPTION
smallIcon - value for Action.SMALL_ICON
largeIcon - value for Action.LARGE_ICON_KEY
actionCommandKey - value for Action.ACTION_COMMAND_KEY
acceleratorKey - value for Action.ACCELERATOR_KEY
mnemonicKey - value for Action.MNEMONIC_KEY
otherParameters - other parameters which will be added to the action (can be null)
Returns:
created CommandAction
See Also:
ActionFactory.getAction(com.levigo.util.swing.action.Context, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.swing.Icon, javax.swing.Icon, java.lang.String, javax.swing.KeyStroke, int, java.util.HashMap)

getLinkedActionFactories

public NamedActionFactory[] getLinkedActionFactories()
Returns an array of linked actions factories

Returns:
NamedActionFactory[] linked action factories.

addLinkedActionFactory

public void addLinkedActionFactory(BasicActionFactory actionFactory)
Adds an action factory as linked factory to this factory.

Parameters:
actionFactory - factory to add

removeLinkedActionFactory

public void removeLinkedActionFactory(BasicActionFactory actionFactory)
Removes an action factory of linked factories.

Parameters:
actionFactory - factory to remove

insertLinkedActionFactory

public void insertLinkedActionFactory(int index,
                                      BasicActionFactory actionFactory)
Inserts a action factory at index position of linked factories.

Parameters:
index - index of factory
actionFactory - factory to insert

reset

public void reset()
Clears and resets this factory instance. This is useful if the property sources should be reload.



Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.