Class TranslatingStringEnumConfigurer

java.lang.Object
VASSAL.configure.Configurer
VASSAL.configure.TranslatingStringEnumConfigurer

public class TranslatingStringEnumConfigurer extends Configurer
A Configurer that allows a user to select from an underlying list of values, based on a translatable list of descriptions of those values. Drop-in replacement for StringEnumConfigurer that allows a set of translation keys to be supplied to specify the drop-down values
  • Constructor Details

    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, String[] validValues, String[] i18nKeys)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - Array of values to maintain
      i18nKeys - Array of Translation Keys used to describe the list of values
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String[] validValues, String[] i18nKeys)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      validValues - Array of values to maintain
      i18nKeys - Array of Translation Keys used to describe the list of values
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String[] validValues, String[] i18nKeys, boolean isDisplayNames)
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, String[] validValues, String[] i18nKeys, boolean isDisplayNames)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - Array of values to maintain
      i18nKeys - Array of Translation Keys used to describe the list of values
      isDisplayNames - True if we have already been given full translated strings; false if they are "keys" for Resources.getString()
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, List<String> validValues, List<String> i18nKeys)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(List<String> validValues, List<String> i18nKeys)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, List<String> validValues, List<String> i18nKeys, boolean isDisplayNames)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
      isDisplayNames - True if we have already been given full translated strings; false if they are "keys" for Resources.getString()
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, String[] validValues, String[] i18nKeys, String initialValue)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - Array of values to maintain
      i18nKeys - Array of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, String[] validValues, String[] i18nKeys, char initialValue)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String[] validValues, String[] i18nKeys, String initialValue)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      validValues - Array of values to maintain
      i18nKeys - Array of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String[] validValues, String[] i18nKeys, char initialValue)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, String[] validValues, String[] i18nKeys, String initialValue, boolean isDisplayNames)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - Array of values to maintain
      i18nKeys - Array of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
      isDisplayNames - True if we have already been given full translated strings; false if they are "keys" for Resources.getString()
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, List<String> validValues, List<String> i18nKeys, String initialValue)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(List<String> validValues, List<String> i18nKeys, String initialValue)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
    • TranslatingStringEnumConfigurer

      public TranslatingStringEnumConfigurer(String key, String name, List<String> validValues, List<String> i18nKeys, String initialValue, boolean isDisplayNames)
      Create a drop-list of localised display values that allows you to select a value from an underlying list of 'internal' untranslated values.
      Parameters:
      key - Configurer Key
      name - Configurer Name
      validValues - List of values to maintain
      i18nKeys - List of Translation Keys used to describe the list of values
      initialValue - Initial Value to set in the Configurer.
      isDisplayNames - True if we have already been given full translated strings; false if they are "keys" for Resources.getString()
  • Method Details

    • isDisplayNames

      public boolean isDisplayNames()
      Returns:
      true if our "keys" are actually already translated strings; false if they are really keys
    • setDisplayNames

      public void setDisplayNames(boolean isDisplayNames)
      Parameters:
      isDisplayNames - true if our "keys" are actually already translated strings; false if they are really keys
    • getControls

      public Component getControls()
      Get the Controls that make up this Configurer
      Specified by:
      getControls in class Configurer
      Returns:
      A swing Component that holds all of the Configurer controls
    • getSelectedIndex

      public int getSelectedIndex()
    • setEnabled

      public void setEnabled(boolean enabled)
      Set the enabled status of the Configurer controls
      Overrides:
      setEnabled in class Configurer
      Parameters:
      enabled - set the Enabled status of the Configurer
    • setEditable

      public void setEditable(boolean editable)
      Set whether or not the value showing in the Configurer can be changed by a user
      Parameters:
      editable - Set the Editable status of the Configurer
    • isValidValue

      public boolean isValidValue(Object o)
      Test if a supplied value is one of the underlying 'real' valued managed by the Configurer
      Parameters:
      o - Value to test
      Returns:
      true if the supplied Object is one of the allowed values
    • getValueIndex

      public int getValueIndex(Object o)
      Return the index of the supplied value in the list of allowed values. Return 0 if the supplied value is not found so that the Configurer will display the first valid value by default
      Parameters:
      o - Value to look for
      Returns:
      The index of the value, or 0 (i.e. first) if not found
    • getValidValues

      public String[] getValidValues()
      Return the array of valid underlying values.
      Returns:
      Array of underlying values.
    • setValidValues

      public void setValidValues(String[] values, String[] keys)
    • setValue

      public void setValue(Object o)
      Set a value into the configurer If the value is one of the list of allowable values, then set the core value and update the drop-down list to show the corresponding translation.
      Overrides:
      setValue in class Configurer
      Parameters:
      o - Value to set
    • getValueString

      public String getValueString()
      Return the underlying value stored in the Configurer
      Specified by:
      getValueString in class Configurer
      Returns:
      stored value
    • setValue

      public void setValue(String s)
      Set the value stored in the Configurer. Note that the value must be one of the valid allowed values.
      Specified by:
      setValue in class Configurer
      Parameters:
      s - Value to store as Configurer value
    • setLabelVisible

      public void setLabelVisible(boolean visible)
      Description copied from class: Configurer
      Show/Hide the internal label maintained by this Configurer. It is up to individual Configurers to track and hide the label (if they can). This method is currently only utilized by the Preference configs PrefsEditor.addOption(String, Configurer) to extract an existing label in a configurer, display correctly aligned and suppress the original label. This keeps compatibility with custom module code setting up preferences. This method only needs to be implemented in Configurers that are added as preferences.
      Overrides:
      setLabelVisible in class Configurer
      Parameters:
      visible - Hide label if true