net.curre.prefcount.util
Class LocaleExt

java.lang.Object
  extended by net.curre.prefcount.util.LocaleExt

public class LocaleExt
extends java.lang.Object

Object of this class represents locale with extended functionality/properties.

Created date: Jun 2, 2007

Author:
Yevgeny Nyden

Nested Class Summary
static interface LocaleExt.LocaleExec
          Helper interface to assist with changing locale-sensitive messages.
static class LocaleExt.Triple
          Class to represent a "locale-sensitive" component with its key.
 
Constructor Summary
LocaleExt(java.lang.String language, java.lang.String country, java.lang.String displayLanguage)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          
static void fireLocaleChangeEvent()
          Updates the text/label/title on all registered components when the application locale changes.
 java.lang.String getDisplayLanguage()
          Getter for the language display name.
 java.util.Locale getLocale()
          Getter for the reference to the locale object.
 javax.swing.ImageIcon getLocaleIcon()
          Gets the icon that represents this locale.
static java.lang.String getString(java.lang.String key, java.lang.String... keyArgs)
          Gets the string resource for the given key.
 int hashCode()
          
static void registerComponent(java.lang.Object component, java.lang.String key, java.lang.String... keyArgs)
          Registers a "locale-sensitive" component so it's label is updated when the application locale changes.
static void registerComponent(java.lang.Object component, WindowComponent keyEnum, java.lang.String... keyArgs)
          Registers a "locale-sensitive" component so it's label is updated when the application locale changes.
static void registerShortcuts(javax.swing.InputMap map, java.lang.String... shortcutKeys)
          This method will register shortcuts with the given input map.
static void reregisterComponent(java.lang.Object component, java.lang.String key, java.lang.String... keyArgs)
          Reregisters a "locale-sensitive" component so it's label is updated when the application locale changes.
 java.lang.String toString()
          
static void unregisterAllComponents()
          Unregisters all currently registered components.
static void unregisterComponent(java.awt.Component component)
          Unregisters locale sensitive component.
static void unregisterComponents(java.util.Collection<java.awt.Component> components)
          Unregisters locale sensitive components.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocaleExt

public LocaleExt(java.lang.String language,
                 java.lang.String country,
                 java.lang.String displayLanguage)
Constructor.

Parameters:
language - Locale language.
country - Locale country.
displayLanguage - Language display name.
Method Detail

getLocale

public java.util.Locale getLocale()
Getter for the reference to the locale object.

Returns:
Reference to the locale object.

getDisplayLanguage

public java.lang.String getDisplayLanguage()
Getter for the language display name.

Returns:
Language display name.

getLocaleIcon

public javax.swing.ImageIcon getLocaleIcon()
Gets the icon that represents this locale.

Returns:
Icon that represents this locale.

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getString

public static java.lang.String getString(java.lang.String key,
                                         java.lang.String... keyArgs)
Gets the string resource for the given key. If any keyArgs are passed, they will replace the "{0}", "{1}", etc. string sequences in this resource (if they exist) in the order they appear on the argument list. Note, that only maximum of 10 arguments are supported (indeces 0 through 9).

Parameters:
key - key for a resource to fetch.
keyArgs - array of arguments for the resource key (optional).
Returns:
string resource for the given key.

registerComponent

public static void registerComponent(java.lang.Object component,
                                     WindowComponent keyEnum,
                                     java.lang.String... keyArgs)
Registers a "locale-sensitive" component so it's label is updated when the application locale changes.

Parameters:
component - reference to the component.
keyEnum - WindowComponent enum that represents the component.
keyArgs - array of arguments for the resource key (optional).

registerComponent

public static void registerComponent(java.lang.Object component,
                                     java.lang.String key,
                                     java.lang.String... keyArgs)
Registers a "locale-sensitive" component so it's label is updated when the application locale changes.

Parameters:
component - reference to the component.
key - string resource key for the component.
keyArgs - array of arguments for the resource key (optional).

reregisterComponent

public static void reregisterComponent(java.lang.Object component,
                                       java.lang.String key,
                                       java.lang.String... keyArgs)
Reregisters a "locale-sensitive" component so it's label is updated when the application locale changes.

Parameters:
component - reference to the component.
key - string resource key for the component.
keyArgs - array of arguments for the resource key (optional).

unregisterAllComponents

public static void unregisterAllComponents()
Unregisters all currently registered components.


unregisterComponents

public static void unregisterComponents(java.util.Collection<java.awt.Component> components)
Unregisters locale sensitive components.

Parameters:
components - components to unregister.

unregisterComponent

public static void unregisterComponent(java.awt.Component component)
Unregisters locale sensitive component.

Parameters:
component - component to unregister.

fireLocaleChangeEvent

public static void fireLocaleChangeEvent()
Updates the text/label/title on all registered components when the application locale changes.


registerShortcuts

public static void registerShortcuts(javax.swing.InputMap map,
                                     java.lang.String... shortcutKeys)
This method will register shortcuts with the given input map. We support only Ctrl+ shortcuts here and assume that the shotcut action has been added to the same component's action map using the shortcut resource key as a map key.

Parameters:
map - component's input map to add shortcuts to.
shortcutKeys - array of shortcuts' resource keys.


Copyright © 2008. All Rights Reserved.