net.ponec.jworksheet.core
Class LanguageManager

Package class diagram package LanguageManager
java.lang.Object
  extended by net.ponec.jworksheet.core.LanguageManager

public class LanguageManager
extends java.lang.Object

Tool provide two services
First: in the debug mode it display to user a language property parameters from top hierarchy komponent to down recursively.
Second: allways set Name parameter (if one is not only assigned) for all compoments.
Examples for JFrame:

Examples for JDialog called from JFrame:


Note 1: For new JLabel("Label") -> jLabel.setName("~Label"); // Default usage
Note 2: jLabel.setName(".myPrefix.Label"); // User usage
Note 3: jLabel.setName("#"); // Ignore It


Field Summary
protected  java.awt.Container basicContainer
          Top level container.
protected  java.util.WeakHashMap<java.util.Locale,java.util.ResourceBundle> bundleMap
          Bundle like weak map.
protected  java.lang.String bundleName
          Basic Bundle Name.
static boolean DEBUG_MODE
          Debug Mode
static java.util.Locale DEFAULT_LOCALE
          A Locale for default property:
static boolean enableTiming
          Attribute for enable timing (outupt to console).
protected  boolean firstRuning
          The first conversion.
protected  java.util.Locale locale
          Locale
static java.lang.String STOP_TRANSLATION
          A key word to skipping a generic translation for marked component.
 
Constructor Summary
LanguageManager(java.awt.Container basicContainer, java.lang.Class bundlePattern, boolean showDebugWindow)
          Creates new LanguageManager class.
 
Method Summary
 java.util.Locale getLocale()
          Return current locale:
 java.lang.String getText(java.lang.Class anOwnerClass, java.lang.String key, java.util.Locale aLocale)
          Language Sensitive Text.
 java.lang.String getText(java.lang.String key)
          Language Sensitive Text.
 java.lang.String getText(java.lang.String key, boolean exception)
          Language Sensitive Text.
 java.lang.String getText(java.lang.String key, java.lang.Object... parameters)
          Language Sensitive Text.
 java.lang.String getText(java.lang.String key, java.lang.Object parameter)
          Language Sensitive Text.
 java.lang.String getTextAllways(java.lang.Class anOwnerClass, java.lang.String key, java.util.Locale aLocale)
          Language Sensitive Text.
 java.lang.String getTextAllways(java.lang.Class anOwnerClass, java.lang.String key, java.lang.String[] parameters, java.util.Locale aLocale)
          Language Sensitive Text.
 java.lang.String getTextAllways(java.lang.String key)
          Language Sensitive Text.
 java.lang.String getTextAllways(UjoProperty key)
          Language Sensitive Text.
 void setFirstRunTexts(java.awt.Container topContainer)
          Create an key Name for the param container and their subcomponents for the first run.
 void setFirstRunTexts(java.awt.Container topContainer, java.util.Locale aLocale)
          Create an key Name for the param container and their subcomponents for the first run.
 void setLocale(java.util.Locale locale, boolean changeGuiText)
          Create an key Name for the param container and their subcomponents.
 void setLocaleAndTranslate(java.util.Locale locale, boolean translate)
          Set new locale and change texts in GUI on the top container and his subcomponents.
 void setTexts(java.util.Locale locale, java.awt.Container topContainer)
          Create an key Name for the top container and their subcomponents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STOP_TRANSLATION

public static final java.lang.String STOP_TRANSLATION
A key word to skipping a generic translation for marked component.

See Also:
Constant Field Values

DEFAULT_LOCALE

public static final java.util.Locale DEFAULT_LOCALE
A Locale for default property:


DEBUG_MODE

public static final boolean DEBUG_MODE
Debug Mode

See Also:
Constant Field Values

enableTiming

public static final boolean enableTiming
Attribute for enable timing (outupt to console).

See Also:
Constant Field Values

basicContainer

protected java.awt.Container basicContainer
Top level container.


bundleName

protected java.lang.String bundleName
Basic Bundle Name.


bundleMap

protected java.util.WeakHashMap<java.util.Locale,java.util.ResourceBundle> bundleMap
Bundle like weak map.


locale

protected java.util.Locale locale
Locale


firstRuning

protected boolean firstRuning
The first conversion.

Constructor Detail

LanguageManager

public LanguageManager(java.awt.Container basicContainer,
                       java.lang.Class bundlePattern,
                       boolean showDebugWindow)
Creates new LanguageManager class.

Parameters:
basicContainer - Parameter is default Root. It is used alse for PROPERTY file name.
bundlePattern - A bundlePattern class determine a bundle name.
showDebugWindow -
Method Detail

setFirstRunTexts

public void setFirstRunTexts(java.awt.Container topContainer)
Create an key Name for the param container and their subcomponents for the first run. This was meaning for a DIALOG box.

Parameters:
topContainer - A root of the component tree.

setFirstRunTexts

public void setFirstRunTexts(java.awt.Container topContainer,
                             java.util.Locale aLocale)
Create an key Name for the param container and their subcomponents for the first run. This was meaning for a DIALOG box.

Parameters:
topContainer - A root of the component tree.

setLocaleAndTranslate

public void setLocaleAndTranslate(java.util.Locale locale,
                                  boolean translate)
Set new locale and change texts in GUI on the top container and his subcomponents.
Modify to an supported locale

Parameters:
locale - The Language

setLocale

public void setLocale(java.util.Locale locale,
                      boolean changeGuiText)
Create an key Name for the param container and their subcomponents.

Parameters:
locale - The Language
changeGuiText - if value is false, don't change text on a GUI containter.

setTexts

public void setTexts(java.util.Locale locale,
                     java.awt.Container topContainer)
Create an key Name for the top container and their subcomponents.

Parameters:
locale -
topContainer - If the Continer is null, only locale is assigned.

getText

public java.lang.String getText(java.lang.Class anOwnerClass,
                                java.lang.String key,
                                java.util.Locale aLocale)
Language Sensitive Text. Throws an exception, if appears any mistake!

Parameters:
key -
Returns:
Text from properties.

getTextAllways

public java.lang.String getTextAllways(java.lang.Class anOwnerClass,
                                       java.lang.String key,
                                       java.util.Locale aLocale)
Language Sensitive Text. Throws an exception, if appears any mistake!

Parameters:
key -
Returns:
Text from properties.

getTextAllways

public java.lang.String getTextAllways(java.lang.Class anOwnerClass,
                                       java.lang.String key,
                                       java.lang.String[] parameters,
                                       java.util.Locale aLocale)
Language Sensitive Text. Throws an exception, if appears any mistake!

Parameters:
key -
Returns:
Text from properties.

getText

public java.lang.String getText(java.lang.String key,
                                boolean exception)
                         throws java.util.MissingResourceException
Language Sensitive Text. Throws an exception, if exists any mistake!

Parameters:
key -
Returns:
Text from properties.
Throws:
java.util.MissingResourceException

getText

public java.lang.String getText(java.lang.String key)
Language Sensitive Text. Throws an exception, if exists any mistake!

Parameters:
key -
Returns:
Text from properties.

getTextAllways

public java.lang.String getTextAllways(UjoProperty key)
Language Sensitive Text. Does not throw any exception. Does not return null nor empty String!

Parameters:
key -
Returns:
Text from properties.

getTextAllways

public java.lang.String getTextAllways(java.lang.String key)
Language Sensitive Text. Does not throw any exception. Does not return null nor empty String!

Parameters:
key -
Returns:
Text from properties.

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.Object... parameters)
Language Sensitive Text. Throws an exception, if exists any mistake!

Parameters:
key -
parameters - Any parameters of the message.
Returns:
Text from properties.

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.Object parameter)
Language Sensitive Text. Throws an exception, if exists any mistake!

Parameters:
key -
parameter - The one parameter of the message.
Returns:
Text from properties.

getLocale

public java.util.Locale getLocale()
Return current locale:

Returns:


Copyright © 2007-2009 PPonec