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 Configurer
Configurer.ContextLevelModifier and TypeClassDescriptionstatic enumThe ContextLevel of a Configurer defines the level that it is defined at. -
Field Summary
Fields inherited from class Configurer
changeSupport, context, contextLevel, frozen, hint, key, LIST_ENTRY_HIGHLIGHT_COLOR, name, NAME_PROPERTY, noUpdate, valueModifier and TypeFieldDescriptionprotected PropertyChangeSupportprotected AbstractBuildableprotected Configurer.ContextLevelprotected booleanWhen frozen is true, setting the value programmatically will not result in a PropertyChangeEvent being firedprotected StringA Hint to be displayed in an empty fieldprotected StringA String the uniquely identifies this propertystatic final ColorDefault Highlight Color for Configurable Listsprotected StringA String that provides a short description of the property to the userstatic final Stringprotected booleanWhen noUpdate is true, setting the value programmatically will not result in an update of the GUI Componentprotected ObjectThe value -
Constructor Summary
ConstructorsConstructorDescriptionTranslatingStringEnumConfigurer(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 ConfigurerintString[]Return the array of valid underlying values.intReturn the index of the supplied value in the list of allowed values.Return the underlying value stored in the ConfigurerbooleanbooleanTest if a supplied value is one of the underlying 'real' valued managed by the ConfigurervoidsetDisplayNames(boolean isDisplayNames) voidsetEditable(boolean editable) Set whether or not the value showing in the Configurer can be changed by a uservoidsetEnabled(boolean enabled) Set the enabled status of the Configurer controlsvoidsetLabelVisible(boolean visible) Show/Hide the internal label maintained by this Configurer.voidsetValidValues(String[] values, String[] keys) voidSet 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.voidSet the value stored in the Configurer.Methods inherited from class 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, setNameModifier and TypeMethodDescriptionvoidaddFocusListener(FocusListener listener) Add a FocusListener to the Swing Components that make up this Configurer.voidAdd a listener to be notified when the Object state changesvoidFire a PropertyChangeEvent as if the value had been set from nullGet the Context for this ConfigurergetHint()Return the current hint StringgetKey()Unique identifiergetName()Plain English description of the Objectprotected DimensionReturn the current screen size for use by List type configurers to allow them to take up maximum screen real estate if needed.getValue()The Object value May be null if the Object has not been initializedvoidinitCustomControls(JDialog d, Configurable target) Initialize any custom controls / keystrokesbooleanisFrozen()booleanReturn the current highlighted statusbooleanvoidremoveFocusListener(FocusListener listener) Remove a FocusListener from the Swing Components that make up this Configurer.voidprotected voidrepack()Repack the current configurerprotected voidRepack a dialog or windowvoidMove the cursor to the first input field of this ConfigurervoidsetContext(AbstractBuildable context) Set the Context for this Configurer to the first ancestor that is of type GameModule or Map NOTE: The ContextLevel may already have been preset by the ConfigureFactory when the Configurer was created.voidsetContext(Buildable context) voidsetContext(Configurable context) voidsetContextLevel(Configurer.ContextLevel contextLevel) voidsetFrozen(boolean val) If true, then don't fire PropertyChangeEvents when the value is resetvoidsetHighlighted(boolean highlighted) Set the highlighted status of this configurer.voidSet the Hint StringvoidsetHintKey(String hintKey) Set the Hint String via a I18n keyvoidsetLabelVisibile(boolean visible) Deprecated, for removal: This API element is subject to removal in a future version.void
-
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:
getControlsin 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:
setEnabledin 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:
setValuein classConfigurer- Parameters:
o- Value to set
-
getValueString
Return the underlying value stored in the Configurer- Specified by:
getValueStringin 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:
setValuein classConfigurer- Parameters:
s- Value to store as Configurer value
-
setLabelVisible
public void setLabelVisible(boolean visible) Description copied from class:ConfigurerShow/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:
setLabelVisiblein classConfigurer- Parameters:
visible- Hide label if true
-
Configurer.setLabelVisible(boolean)instead.