org.jminor.common.ui.valuemap
Class FormattedValueLink<K>
java.lang.Object
javax.swing.AbstractAction
org.jminor.common.ui.control.Control
org.jminor.common.ui.control.AbstractValueLink<ValueChangeMapEditModel<K,V>,V>
org.jminor.common.ui.valuemap.AbstractValueMapLink<K,Object>
org.jminor.common.ui.valuemap.TextValueLink<K>
org.jminor.common.ui.valuemap.FormattedValueLink<K>
- All Implemented Interfaces:
- ActionListener, Serializable, Cloneable, EventListener, Action
- Direct Known Subclasses:
- DateValueLink
public class FormattedValueLink<K>
- extends TextValueLink<K>
A class for linking a JFormattedTextField to a ValueChangeMapEditModel property value.
- See Also:
- Serialized Form
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
Methods inherited from class org.jminor.common.ui.control.Control |
getDescription, getEnabledState, getIcon, getMnemonic, getName, isEnabled, setDescription, setEnabled, setIcon, setKeyStroke, setMnemonic, setName |
FormattedValueLink
public FormattedValueLink(JFormattedTextField textComponent,
ValueChangeMapEditModel<K,Object> editModel,
K key,
Format format,
boolean immediateUpdate,
LinkType linkType)
- Instantiates a new FormattedValueLink
- Parameters:
textComponent
- the text component to linkeditModel
- the ValueChangeMapEditModel instancekey
- the key to linkformat
- the formatimmediateUpdate
- if true then the underlying model value is updated on each keystroke,linkType
- the link type
getFormat
public final Format getFormat()
- Returns:
- the format, if any
getValueFromText
protected final Object getValueFromText(String text)
- Returns a property value based on the given text, if the text can not
be parsed into a valid value, null is returned
- Overrides:
getValueFromText
in class TextValueLink<K>
- Parameters:
text
- the text from which to parse a value
- Returns:
- a value, null if the input text has zero length or if it does not yield a valid value
getValueAsText
protected final String getValueAsText(Object value)
- Returns a String representation of the given value object, null is returned in case of a null value
- Overrides:
getValueAsText
in class TextValueLink<K>
- Parameters:
value
- the value to return as String
- Returns:
- a String representation of the given value, null if the value is null
translate
protected String translate(String text)
- Provides a hook into the value setting mechanism.
- Overrides:
translate
in class TextValueLink<K>
- Parameters:
text
- the value returned from the UI component
- Returns:
- the translated value
translate
protected Object translate(Object parsedValue)