// **********************************************************************
//
//
* Intended Usage:
* There are several possible uses of this interface, outlined below: * *
*
* I18n i18n = Environment.getI18n();
* String message = i18n.get(this, "message", "Please enter a number: ");
*
* There is also similar version of get(...) that takes a
* Class instead, and thefore can be used in static contexts.
* If the Strings you are looking for pertain to specific types (i.e. uses)
* you can you the form of get(...) that specifies this, as the
* following example illustrates:
*
* I18n i18n = Environment.getI18n();
* JButton okButton = new JButton(i18n.get(this, "okButton", i18n.TEXT, "Ok"));
*
* okButton.setTooltipText(i18n.get(this, "okButton", i18n.TOOLTOP, "Ok"));
*
* Again there is a similar version of this method that takes a
* Class instead of an object so it can be used in static
* contexts.
*
* Note that in both examples given, the field parameter to the
* get(...) methods are the name of the variable that holds the
* string returned. For the these methods, this is a convention rather than
* a requirement. However, it suggested that you maintain this convention
* because doing so makes it clearer what is going on and because it is
* most similar to how the calls are made in the reflective case below.
*
*
set(...) methods of this class can help you. Here is an
* example:
*
* I18n i18n = Environment.getI18n();
* JButton myButton = new JButton();
* I18n.set(this, "myButton", myButton);
*
* This will get the string information (both tool tip and text) from * the appropriate ResourceBundle and set the button's slots with it. *
* Note that in this example the field parameter to the
* set(...) method is the name of the field that holds the object
* being setup. For these methods this is a convention rather than a
* requirement. However, it suggested that you maintain this convention
* because doing so makes it clearer what is going on and because it is
* most similar to how the calls are made in the reflective case below.
*
*
* public class MyClass {
* JButton myButton = new JButton();
* public MyClass() {
* Environment.getI18n().set(this, "myButton");
* }
* }
*
* This code will setup the properties of the object held by the
* myButton variable, without the programmer having to do
* much at all. Here is an example of the other reflective method:
*
* public class MyClass {
* JButton myButton = new JButton();
* JLabel myLabel = new JLabel();
* public MyClass() {
* Environment.getI18n().fill(this);
* }
* }
*
* Here we can see that a single call is filling in all of the text for
* all of the relevant objects, in this case both myButton and
* myLabel.
*
* In case you were wondering, the oft used I18n
* abreviation comes from the 18 characters between the 'I' and the 'n' in
* the word Internationalization.
* @see com.bbn.openmap.Environment
* @see com.bbn.openmap.BasicI18n
*/
public interface I18n {
//Types:
////////
/** Primary type for a given field (default if types aren't applicable).*/
public final int TEXT = 1;
/** Tooltip for a given field. */
public final int TOOLTIP = 2;
/** Mnemonic for a given field. */
public final int MNEMONIC = 3;
/**
* Get the string associated with the given object/field
* (Defaults to TEXT for the type).
* @param requestor object containing the code requesting the String
* (typically thisthisFoo.classFoo.classthiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JLabel comp);
/**
* Set the textual properties from values in the appropriate
* ResourceBundle.
* @param requestor object containing the code requesting the String
* (typically thiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JButton comp);
/**
* Set the textual properties from values in the appropriate
* ResourceBundle.
* @param requestor object containing the code requesting the String
* (typically thiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JMenu comp);
/**
* Set the textual properties from values in the appropriate
* ResourceBundle.
* @param requestor object containing the code requesting the String
* (typically thiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JMenuItem comp);
/**
* Set the textual properties from values in the appropriate
* ResourceBundle.
* @param requestor object containing the code requesting the String
* (typically thiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JDialog comp);
/**
* Set the textual properties from values in the appropriate
* ResourceBundle.
* @param requestor object containing the code requesting the String
* (typically thiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JFrame comp);
/**
* Set the textual properties from values in the appropriate
* ResourceBundle.
*
* Note: This method just looks for a TitledBorder on the component.
* @param requestor object containing the code requesting the String
* (typically thiscomp parameter.
* @param comp the component whose properties are being set.
**/
public void set(Object requestor, String field, JComponent comp);
//Methods for filling in strings using reflection:
//////////////////////////////////////////////////
/**
* Set the textual properties on a Swing component that is a member of a
* given class, from values in the ResourceBundle associated with that
* class. Note that the field must contain an object of a known type
* (see the other set(...) methods of this class).
*
* The setting of the values of this field will be accomplished by calling
* the appropriate set(...) method on this class.
* @param requestor object containing the code requesting the Component
* setup (typically this
* The setting of the values of this field will be accomplished by calling
* the appropriate set(...) method on this class.
**/
public void fill(Object requestor);
}