com.tensegrity.gui
Interface UIManager

All Known Implementing Classes:
DefaultUIManager

public interface UIManager

The UIManager of an application is responsible for applying all textual information to all GUI controls within the application. This naturally includes all labels for buttons, check boxes, combo boxes, menu items, window titles, tool tips, message boxes and more.

At runtime, text strings are stored in a UIItemList, where application-specific identifiers are matched to UIItem objects that hold the text data. In the application itself, only those identifiers are used to associate a UIItem with a control, thereby decoupling the localized text from that control. If the application language should change, the text in the UIItem instance is simply updated. The control, however, will still point to the same identifier.

Class Diagram UIManager

A UIManager maintains UIItem instances and their textual representations. Use class UIManager to create various types of localized controls and be able to switch the application language at runtime, without having to restart it.

A UIManager is used by class UIItemEvaluationList as well as application-specific code to retrieve the designated text resource for a given control.

Version:
$Id: UIManager.java,v 1.39 2006/01/03 13:07:00 BurkhardWick Exp $
Author:
GillesIachelini
See Also:
UIItemList, UIItemEvaluationList

Method Summary
 void applyItem(java.lang.String id, java.lang.Object guiObject)
          Sets the values from the UIItem with the parameter id from the internal ItemList to the given Component.
 boolean containsKey(java.lang.String key)
          Checks if the specified key has a corresponding localized text.
 java.lang.Object createIcon(java.lang.Class refClass, java.lang.String iconURL)
          Factory method for creating an Icon.
 java.lang.Object createLocalizedIcon(java.lang.Class refClass, java.lang.String iconURLKey)
          Factory method for creating a new icon.
 UIItemList getItemList()
          The getItemList method should return an instance of UIItemList to let users of this UIManager manually retrieve elements from this list.
 KeyStroke getKeyStroke(java.lang.String key)
          Factory method for creating a localized Keystroke from a key.
 java.lang.String getText(java.lang.String id)
          This method looks up the id in the resources currently loaded in this instance and returns the corresponding string.
 java.lang.String getText(java.lang.String key, java.lang.Object[] objects)
          The method returns a String for a specific key in the property files.
 void setLocale(java.util.Locale locale)
          Sets the locale for this UIManager.
 void setText(java.lang.String id, java.lang.String text)
          The method setText adds a mappings a String to a specific id.
 

Method Detail

getItemList

public UIItemList getItemList()
The getItemList method should return an instance of UIItemList to let users of this UIManager manually retrieve elements from this list. This list is meant to store instances UIItem.

Returns:
UIItemList the list, this UIManager uses to maintain its items.

applyItem

public void applyItem(java.lang.String id,
                      java.lang.Object guiObject)
Sets the values from the UIItem with the parameter id from the internal ItemList to the given Component. Call this method everytime when you want to initialize the associated Component instance with the (new) values from the appropriate UIItem from the UIItemList. Used by the UIItemEvaluationList.apply() and UIItemEvaluationList.apply(int).

Parameters:
id - the id to be used for the component.
guiObject - a component to apply the values to. the class of this parameter is depending on the used ui toolkit and so it has to be cast to the concrete type by the corresponding implementation

getText

public java.lang.String getText(java.lang.String id)
This method looks up the id in the resources currently loaded in this instance and returns the corresponding string.

Parameters:
id - the id of the item of which you want to retrieve the text.
Returns:
String the string associated with the given id.

Find more information in the class documentation


setText

public void setText(java.lang.String id,
                    java.lang.String text)
The method setText adds a mappings a String to a specific id.

Parameters:
id - the id of the item to set.
text - the string associated with the given id.

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale for this UIManager. This method is required to be implemented by users of this class, to let the UIManager know, to change its default resource bundle.

Parameters:
locale - The new Locale for the default resources.

createIcon

public java.lang.Object createIcon(java.lang.Class refClass,
                                   java.lang.String iconURL)
Factory method for creating an Icon.

Parameters:
refClass - The reference class for loading
iconURL - The url relative to refClass
Returns:
instance of Icon created from the given file. the class of this value is depending on the used ui toolkit and so it has to be cast to the concrete type by the corresponding implementation

createLocalizedIcon

public java.lang.Object createLocalizedIcon(java.lang.Class refClass,
                                            java.lang.String iconURLKey)
Factory method for creating a new icon.

Parameters:
refClass - The reference class for loading
iconURLKey - The key of the resource containing the url relative to refClass
Returns:
an instance of icon created from the given file. the class of this value is depending on the used ui toolkit and so it has to be cast to the concrete type by the corresponding implementation

getKeyStroke

public KeyStroke getKeyStroke(java.lang.String key)
Factory method for creating a localized Keystroke from a key. See javax.swing.KeyStroke.getKeyStroke() for details about the format. If no vaild key in the ResourceBundle is found this method returns silently null.

Parameters:
key - the key to use in the ResourceBundle for getting the localized Text.
Returns:
the Keystroke described by the entry in the ResourceBundle or null if no entry was found
See Also:
KeyStroke.getKeyStroke(char)

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.Object[] objects)
The method returns a String for a specific key in the property files. The objects in the objects parameter will be parsed like described in MessageFormat.

Parameters:
key - the id of the item of which you want to retrieve the text.
objects - An array of objects to be placed as defaults.
Returns:
The string associated with the given id.
See Also:
MessageFormat

containsKey

public boolean containsKey(java.lang.String key)
Checks if the specified key has a corresponding localized text.

Parameters:
key -
Returns:
true if the given key has a localized text, false otherwise


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.