org.jminor.common.ui.valuemap
Class FormattedValueLink<K>

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jminor.common.ui.control.Control
          extended by org.jminor.common.ui.control.AbstractValueLink<ValueChangeMapEditModel<K,V>,V>
              extended by org.jminor.common.ui.valuemap.AbstractValueMapLink<K,Object>
                  extended by org.jminor.common.ui.valuemap.TextValueLink<K>
                      extended by 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

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
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
 
Constructor Summary
FormattedValueLink(JFormattedTextField textComponent, ValueChangeMapEditModel<K,Object> editModel, K key, Format format, boolean immediateUpdate, LinkType linkType)
          Instantiates a new FormattedValueLink
 
Method Summary
 Format getFormat()
           
protected  String getValueAsText(Object value)
          Returns a String representation of the given value object, null is returned in case of a null value
protected  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
protected  Object translate(Object parsedValue)
           
protected  String translate(String text)
          Provides a hook into the value setting mechanism.
 
Methods inherited from class org.jminor.common.ui.valuemap.TextValueLink
getText, getUIValue, isImmediateUpdate, setUIValue
 
Methods inherited from class org.jminor.common.ui.valuemap.AbstractValueMapLink
getEditModel, getKey, getModelValue, getValidationMessage, isModelValueNull, isNullable, setModelValue
 
Methods inherited from class org.jminor.common.ui.control.AbstractValueLink
actionPerformed, getLinkType, getValueOwner, updateModel, updateUI
 
Methods inherited from class org.jminor.common.ui.control.Control
getDescription, getEnabledState, getIcon, getMnemonic, getName, isEnabled, setDescription, setEnabled, setIcon, setKeyStroke, setMnemonic, setName
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 link
editModel - the ValueChangeMapEditModel instance
key - the key to link
format - the format
immediateUpdate - if true then the underlying model value is updated on each keystroke,
linkType - the link type
Method Detail

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)