Class TranslatingStringEnumConfigurer
java.lang.Object
VASSAL.configure.Configurer
VASSAL.configure.TranslatingStringEnumConfigurer
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-
Nested Class Summary
Nested classes/interfaces inherited from class VASSAL.configure.Configurer
Configurer.ContextLevel
-
Field Summary
Fields inherited from class VASSAL.configure.Configurer
changeSupport, context, contextLevel, frozen, hint, key, LIST_ENTRY_HIGHLIGHT_COLOR, name, NAME_PROPERTY, noUpdate, value
-
Constructor Summary
ConstructorDescriptionTranslatingStringEnumConfigurer
(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.TranslatingStringEnumConfigurer
(String[] validValues, String[] i18nKeys, boolean isDisplayNames) 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.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.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.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.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.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.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.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.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.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.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.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.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. -
Method Summary
Modifier and TypeMethodDescriptionGet the Controls that make up this Configurerint
String[]
Return the array of valid underlying values.int
Return the index of the supplied value in the list of allowed values.Return the underlying value stored in the Configurerboolean
boolean
Test if a supplied value is one of the underlying 'real' valued managed by the Configurervoid
setDisplayNames
(boolean isDisplayNames) void
setEditable
(boolean editable) Set whether or not the value showing in the Configurer can be changed by a uservoid
setEnabled
(boolean enabled) Set the enabled status of the Configurer controlsvoid
setLabelVisible
(boolean visible) Show/Hide the internal label maintained by this Configurer.void
setValidValues
(String[] values, String[] keys) void
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.void
Set the value stored in the Configurer.Methods inherited from class VASSAL.configure.Configurer
addFocusListener, addPropertyChangeListener, fireUpdate, getContext, getContextLevel, getHint, getKey, getName, getScreenSize, getValue, initCustomControls, isFrozen, isHighlighted, isPieceContext, removeFocusListener, removePropertyChangeListener, repack, repack, requestFocus, setContext, setContext, setContext, setContextLevel, setFrozen, setHighlighted, setHint, setHintKey, setLabelVisibile, setName
-
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 Keyname
- Configurer NamevalidValues
- Array of values to maintaini18nKeys
- Array of Translation Keys used to describe the list of values
-
TranslatingStringEnumConfigurer
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 maintaini18nKeys
- Array of Translation Keys used to describe the list of values
-
TranslatingStringEnumConfigurer
-
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 Keyname
- Configurer NamevalidValues
- Array of values to maintaini18nKeys
- Array of Translation Keys used to describe the list of valuesisDisplayNames
- 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 Keyname
- Configurer NamevalidValues
- List of values to maintaini18nKeys
- List of Translation Keys used to describe the list of values
-
TranslatingStringEnumConfigurer
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 maintaini18nKeys
- 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 Keyname
- Configurer NamevalidValues
- List of values to maintaini18nKeys
- List of Translation Keys used to describe the list of valuesisDisplayNames
- 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 Keyname
- Configurer NamevalidValues
- Array of values to maintaini18nKeys
- Array of Translation Keys used to describe the list of valuesinitialValue
- 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 Keyname
- Configurer NamevalidValues
- List of values to maintaini18nKeys
- List of Translation Keys used to describe the list of valuesinitialValue
- 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 maintaini18nKeys
- Array of Translation Keys used to describe the list of valuesinitialValue
- Initial Value to set in the Configurer.
-
TranslatingStringEnumConfigurer
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 maintaini18nKeys
- List of Translation Keys used to describe the list of valuesinitialValue
- 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 Keyname
- Configurer NamevalidValues
- Array of values to maintaini18nKeys
- Array of Translation Keys used to describe the list of valuesinitialValue
- 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 Keyname
- Configurer NamevalidValues
- List of values to maintaini18nKeys
- List of Translation Keys used to describe the list of valuesinitialValue
- 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 maintaini18nKeys
- List of Translation Keys used to describe the list of valuesinitialValue
- 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 Keyname
- Configurer NamevalidValues
- List of values to maintaini18nKeys
- List of Translation Keys used to describe the list of valuesinitialValue
- 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
Get the Controls that make up this Configurer- Specified by:
getControls
in classConfigurer
- 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 classConfigurer
- 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
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
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
Return the array of valid underlying values.- Returns:
- Array of underlying values.
-
setValidValues
-
setValue
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 classConfigurer
- Parameters:
o
- Value to set
-
getValueString
Return the underlying value stored in the Configurer- Specified by:
getValueString
in classConfigurer
- Returns:
- stored value
-
setValue
Set the value stored in the Configurer. Note that the value must be one of the valid allowed values.- Specified by:
setValue
in classConfigurer
- 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 configsPrefsEditor.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 classConfigurer
- Parameters:
visible
- Hide label if true
-