http://www.jpicedt.org

jpicedt.ui.action
Class PEActionLocalizer

java.lang.Object
  extended by jpicedt.ui.action.PEActionLocalizer
All Implemented Interfaces:
ActionLocalizer

public class PEActionLocalizer
extends Object
implements ActionLocalizer

A class that can feed PEAction's with localized properties (e.g. tooltip,...) provided by a properties file through a ResourceBundle.

Each method takes a unique String argument, namely the non-localized Action name used in PEAction constructor, and builds other Action's properties from this String.

If there's no associated value for this String in the associated ResourceBundle, methods catch the associated MissingResourceException and return a null value.

Since:
jPicEdt
Version:
$Id: PEActionLocalizer.java,v 1.11 2013/03/27 06:52:46 vincentb1 Exp $
Author:
Sylvain Reynal

Field Summary
protected  ResourceBundle resBundle
          the ResourceBundle that feeds this localizer with localized Strings
 
Constructor Summary
PEActionLocalizer(ResourceBundle resBundle)
          Construct a new PEActionLocalizer from the given ResourceBundle.
 
Method Summary
 KeyStroke getActionAccelerator(String actionName)
          
author: Sylvain Reynal
 String getActionHelper(String actionName)
          
author: Sylvain Reynal
 Icon getActionIcon(String actionName)
          
author: Sylvain Reynal
 Integer getActionMnemonic(String actionName)
          
author: Sylvain Reynal
 String getActionName(String actionName)
          
author: Sylvain Reynal
 String getActionTooltip(String actionName)
          
author: Sylvain Reynal
 ResourceBundle getResourceBundle()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resBundle

protected ResourceBundle resBundle
the ResourceBundle that feeds this localizer with localized Strings

Constructor Detail

PEActionLocalizer

public PEActionLocalizer(ResourceBundle resBundle)
Construct a new PEActionLocalizer from the given ResourceBundle.

Method Detail

getResourceBundle

public ResourceBundle getResourceBundle()
Returns:
the ResourceBundle that feeds this localizer with localized Strings

getActionName

public String getActionName(String actionName)
Description copied from interface: ActionLocalizer

author: Sylvain Reynal

Specified by:
getActionName in interface ActionLocalizer
Parameters:
actionName - a non-localized action name
Returns:
a localized Action name (ie Swing Action.NAME property) for the given name
This in effect will return the value associated with "actionName" in the ResourceBundle associated with the localizer.

getActionTooltip

public String getActionTooltip(String actionName)
Description copied from interface: ActionLocalizer

author: Sylvain Reynal

Specified by:
getActionTooltip in interface ActionLocalizer
Returns:
a localized Action tooltip for the given name (ie Swing Action.SHORT_DESCRIPTION)

This will return the value for the key build from : actionName + ".tooltip".


getActionHelper

public String getActionHelper(String actionName)
Description copied from interface: ActionLocalizer

author: Sylvain Reynal

Specified by:
getActionHelper in interface ActionLocalizer
Returns:
a localized Action helper (ie Swing Action.LONG_DESCRIPTION)

This will return the value for the key build from : actionName + ".helper".


getActionMnemonic

public Integer getActionMnemonic(String actionName)
Description copied from interface: ActionLocalizer

author: Sylvain Reynal

Specified by:
getActionMnemonic in interface ActionLocalizer
Returns:
a localized Action mnemonic (ie Swing Action.MNEMONIC_KEY)

This will return a Character initialized from the first character of the value associated with the key : actionName + ".mnemonic".


getActionAccelerator

public KeyStroke getActionAccelerator(String actionName)
Description copied from interface: ActionLocalizer

author: Sylvain Reynal

Specified by:
getActionAccelerator in interface ActionLocalizer
Returns:
a localized Action accelerator keystroke (ie Swing Action.ACCELERATOR_KEY)

This will return a KeyStroke parsed from the following String: actionName + ".accelerator".

See Also:
KeyStroke.getKeyStroke(String)

getActionIcon

public Icon getActionIcon(String actionName)
Description copied from interface: ActionLocalizer

author: Sylvain Reynal

Specified by:
getActionIcon in interface ActionLocalizer
Returns:
a localized Icon (ie Swing Action.SMALL_ICON)

This will return an ImageIcon initialized from a PNG file with path : "/jpicedt/images/"+actionName+".png"
Return null if the PNG file doesn't exist.


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org