|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.common.swing.ActionFactory
public class ActionFactory
The ActionFactory is responsible for creating CWActions and making them available to the program. Each Action is constructed from resources of the form: simplename.field=value where simplename is the ACTION_COMMAND_KEY value and field is one of the CWAction constants, e.g. LargeIcon. The values for the icons are a path which can be found as a resource.
for license details.
The copyright to this program is held by it's authors.
Field Summary | |
---|---|
private Map |
actions
The map of known CWActions |
private Object |
bean
The object to which we forward events |
private static Logger |
log
The log stream |
private static String |
METHOD_PREFIX
The prefix to methods that we call |
private static String |
MISSING_RESOURCE
The tooltip for actions that we generate to paper around missing resources Normally we would assert, but in live we might want to limp on. |
private static String |
SEPARATOR
What we lookup |
private static String |
TEST
The test string to find actions |
Constructor Summary | |
---|---|
ActionFactory(Class type,
Object bean)
Constructor that distinguishes between the object to call and the type to look up resources against. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent ev)
|
private void |
buildActionMap(Class basis)
Build the map of actions from resources |
private CWAction |
createAction(String acronymn,
String name,
String short_desc,
String long_desc,
Integer mnemonic,
KeyStroke accel,
Icon small_icon,
Icon large_icon,
boolean enabled)
Create a new CWAction |
JLabel |
createJLabel(String key)
Construct a JLabel from the Action. |
private KeyStroke |
getAccelerator(ResourceBundle resources,
String actionName)
Convert the string to a valid Accelerator (ie a KeyStroke) |
Action |
getAction(String key)
Get the Action for the given actionName. |
private String |
getActionString(ResourceBundle resources,
String actionName,
String field)
Lookup an action/field combination, warning about missing resources rather than excepting. |
private Icon |
getIcon(ResourceBundle resources,
String actionName,
String iconName)
Get an icon for the string |
private int |
getInteger(String str)
Convert the string to an integer. |
private Integer |
getMnemonic(ResourceBundle resources,
String actionName)
Convert the string to a mnemonic |
private int |
getModifier(String[] modifiers)
|
private String |
getOptionalActionString(ResourceBundle resources,
String actionName,
String field)
Lookup an action/field combination, returning null for missing resoruces. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String MISSING_RESOURCE
private static final String METHOD_PREFIX
private static final String SEPARATOR
private static final String TEST
private Object bean
private static final Logger log
private Map actions
Constructor Detail |
---|
public ActionFactory(Class type, Object bean)
Method Detail |
---|
public void actionPerformed(ActionEvent ev)
actionPerformed
in interface ActionListener
public Action getAction(String key)
key
- the internal name of the CWAction
public JLabel createJLabel(String key)
key
- the internal name of the CWAction
private void buildActionMap(Class basis)
private String getActionString(ResourceBundle resources, String actionName, String field)
private String getOptionalActionString(ResourceBundle resources, String actionName, String field)
private Icon getIcon(ResourceBundle resources, String actionName, String iconName)
private Integer getMnemonic(ResourceBundle resources, String actionName)
private KeyStroke getAccelerator(ResourceBundle resources, String actionName)
private int getInteger(String str) throws NumberFormatException
NumberFormatException
private int getModifier(String[] modifiers)
private CWAction createAction(String acronymn, String name, String short_desc, String long_desc, Integer mnemonic, KeyStroke accel, Icon small_icon, Icon large_icon, boolean enabled)
acronymn
- The internal name for this action. Must not be null.name
- The label for buttons, menu items, ...small_icon
- The icon used in labellinglarge_icon
- The icon to use if large icons are neededshort_desc
- Tooltip textlong_desc
- Context sensitive helpmnemonic
- The java.awt.event.EventKey value for the mnemonicaccel
- The accelerator keyenabled
- Whether the CWAction is enabled initially
|
Copyright ยจ 2003-2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |