Class AbstractValueTranslator<M,V>

java.lang.Object
org.tentackle.fx.translate.AbstractValueTranslator<M,V>
Type Parameters:
M - the model's type
V - the view's type
All Implemented Interfaces:
ValueTranslator<M,V>
Direct Known Subclasses:
CollectionTreeItemTranslator, EnumStringTranslator, IdentityTranslator, ObservableListTranslator, StringColorTranslator, TreeItemTranslator, ValueStringTranslator

public abstract class AbstractValueTranslator<M,V> extends Object implements ValueTranslator<M,V>
Base class of a value translator.
Author:
harald
  • Constructor Details

    • AbstractValueTranslator

      public AbstractValueTranslator(FxComponent component)
      Creates a string translator for a given text component.
      Parameters:
      component - the component
  • Method Details

    • getComponent

      public FxComponent getComponent()
      Description copied from interface: ValueTranslator
      Gets the component.
      Specified by:
      getComponent in interface ValueTranslator<M,V>
      Returns:
      the component
    • isLenient

      public boolean isLenient()
      Description copied from interface: ValueTranslator
      Returns whether parsing to model should be lenient.
      Specified by:
      isLenient in interface ValueTranslator<M,V>
      Returns:
      true if lenient, false is default
    • setLenient

      public void setLenient(boolean lenient)
      Sets whether parsing to model should be lenient.
      Parameters:
      lenient - true if lenient
    • isMappingIncomplete

      public boolean isMappingIncomplete()
      Description copied from interface: ValueTranslator
      Returns whether the model value is only mapped partially to the view.
      Such data types may hold more data that could have changed by the translator, but the view object still looks unchanged.
      An example for such a type is I18NText.
      Specified by:
      isMappingIncomplete in interface ValueTranslator<M,V>
      Returns:
      true if view may look unchanged but the model could be modified
    • saveModelValue

      public void saveModelValue(M modelValue)
      Description copied from interface: ValueTranslator
      Remembers the model value for later check if changed.
      Only invoked if ValueTranslator.isMappingIncomplete() is true.
      Specified by:
      saveModelValue in interface ValueTranslator<M,V>
      Parameters:
      modelValue - the model value
    • isModelModified

      public boolean isModelModified()
      Description copied from interface: ValueTranslator
      Returns whether the model is modified compared to value saved via ValueTranslator.saveModelValue(Object).
      Only invoked if ValueTranslator.isMappingIncomplete() is true.
      Specified by:
      isModelModified in interface ValueTranslator<M,V>
      Returns:
      true if model is modified