Class FxComponentDelegate

java.lang.Object
org.tentackle.fx.FxControlDelegate
org.tentackle.fx.FxComponentDelegate
All Implemented Interfaces:
ErrorPopupSupported, FxComponent, FxControl, InfoPopupSupported
Direct Known Subclasses:
FxCheckBoxDelegate, FxChoiceBoxDelegate, FxColorPickerDelegate, FxListViewDelegate, FxRadioButtonDelegate, FxTableViewDelegate, FxTextComponentDelegate, FxToggleButtonDelegate, FxTreeTableViewDelegate, FxTreeViewDelegate

public abstract class FxComponentDelegate extends FxControlDelegate implements FxComponent
Delegate implementing FxComponent.
Author:
harald
  • Property Details

  • Field Details

  • Constructor Details

    • FxComponentDelegate

      public FxComponentDelegate()
      Creates a component delegate.
  • Method Details

    • getDelegate

      public FxComponentDelegate getDelegate()
      Description copied from interface: FxControl
      Gets the lazily created component delegate.
      Specified by:
      getDelegate in interface FxComponent
      Specified by:
      getDelegate in interface FxControl
      Overrides:
      getDelegate in class FxControlDelegate
      Returns:
      the delegate
    • getComponent

      public abstract FxComponent getComponent()
      Gets the component of this delegate.
      Returns:
      the component
    • getNode

      public javafx.scene.Node getNode()
      Gets the component as a node.
      Returns:
      the node
    • getParentContainer

      public FxContainer getParentContainer()
      Description copied from interface: FxControl
      Gets the parent container.
      Specified by:
      getParentContainer in interface FxControl
      Returns:
      the parent, null if not a component of a container
    • toGenericString

      public String toGenericString()
      Description copied from interface: FxControl
      Returns the classname plus optional fx:id.
      Specified by:
      toGenericString in interface FxControl
      Returns:
      the generic string for diagnostics and logging
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • updateChangeable

      protected void updateChangeable(boolean changeable)
      Description copied from class: FxControlDelegate
      Updates other properties if changeable is bound to something else.
      Overrides:
      updateChangeable in class FxControlDelegate
      Parameters:
      changeable - the flag
    • createChangeableProperty

      protected javafx.beans.property.ReadOnlyBooleanWrapper createChangeableProperty(boolean changeable)
      Description copied from class: FxControlDelegate
      Creates the changeable property.
      Overrides:
      createChangeableProperty in class FxControlDelegate
      Parameters:
      changeable - the initial value
      Returns:
      the property
    • setContainerChangeable

      public void setContainerChangeable(boolean containerChangeable)
      Description copied from interface: FxControl
      Invoked when setChangeable() is invoked on the container of this component.
      Specified by:
      setContainerChangeable in interface FxControl
      Parameters:
      containerChangeable - true if container is changeable, false if all components readonly
    • setValueTranslator

      public void setValueTranslator(ValueTranslator<?,?> valueTranslator)
      Description copied from interface: FxComponent
      Sets a value translator.
      Specified by:
      setValueTranslator in interface FxComponent
      Parameters:
      valueTranslator - the translator
    • getValueTranslator

      public ValueTranslator<?,?> getValueTranslator()
      Description copied from interface: FxComponent
      Gets the value translator.
      Specified by:
      getValueTranslator in interface FxComponent
      Returns:
      the translator
    • isUpdatingModel

      protected boolean isUpdatingModel()
      Returns a flag to avoid recursive invocations of updateModel().
      Returns:
      true if currently updating the model
    • isUpdatingView

      protected boolean isUpdatingView()
      Returns a flag to avoid recursive invocations of updateView().
      Returns:
      true if currently updating the view
    • updateView

      public void updateView()
      Description copied from interface: FxControl
      Updates the view according to the model.
      Specified by:
      updateView in interface FxControl
    • updateModel

      public void updateModel()
      Description copied from interface: FxControl
      Updates the model according to the view.
      Specified by:
      updateModel in interface FxControl
    • handleInputFailure

      protected void handleInputFailure(String msg)
      Handles a failure during conversion of the user's input to the model.
      Parameters:
      msg - the failure message
    • isModelUpdated

      public boolean isModelUpdated()
      Description copied from interface: FxComponent
      Returns whether model was updated and FxControl.updateView() not invoked since then.
      Some components, such as FxTableView, never update the model because this is already done by the ObservableList. On those cases, false will be returned.
      Specified by:
      isModelUpdated in interface FxComponent
      Returns:
      true if updateView could make sense
    • showErrorPopup

      public void showErrorPopup()
      Description copied from interface: ErrorPopupSupported
      Shows the error popup.
      Requires the error message set.
      Specified by:
      showErrorPopup in interface ErrorPopupSupported
    • hideErrorPopup

      public void hideErrorPopup()
      Description copied from interface: ErrorPopupSupported
      Hides the error popup if shown.
      Specified by:
      hideErrorPopup in interface ErrorPopupSupported
    • getError

      public String getError()
      Description copied from interface: ErrorPopupSupported
      Gets the error message.
      Specified by:
      getError in interface ErrorPopupSupported
      Returns:
      the message, null if no error
    • setError

      public void setError(String errorMessage)
      Description copied from interface: ErrorPopupSupported
      Sets the error message.
      Notice that an empty string will set the style but does not show any popup.
      Specified by:
      setError in interface ErrorPopupSupported
      Parameters:
      errorMessage - the error message, null to clear
    • setErrorTemporary

      public void setErrorTemporary(boolean errorTemporary)
      Description copied from interface: ErrorPopupSupported
      Sets the temporary error flag.
      Specified by:
      setErrorTemporary in interface ErrorPopupSupported
      Parameters:
      errorTemporary - true if this is a temporary error
    • isErrorTemporary

      public boolean isErrorTemporary()
      Description copied from interface: ErrorPopupSupported
      Returns whether this is a temporary error.
      Temporary errors are set by the value translators typically if some parsing failed. Non-temporary are set by the application, for example when a persistence validation failed.
      Specified by:
      isErrorTemporary in interface ErrorPopupSupported
      Returns:
      true if temporary error
    • updateErrorStyle

      protected void updateErrorStyle(boolean enable)
      Updates the error style and shows/hides the popup if component has focus.
      Parameters:
      enable - true to enable style
    • showInfoPopup

      public void showInfoPopup()
      Description copied from interface: InfoPopupSupported
      Shows the info popup.
      Requires the info message set.
      Specified by:
      showInfoPopup in interface InfoPopupSupported
    • hideInfoPopup

      public void hideInfoPopup()
      Description copied from interface: InfoPopupSupported
      Hides the info popup if shown.
      Specified by:
      hideInfoPopup in interface InfoPopupSupported
    • getInfo

      public String getInfo()
      Description copied from interface: InfoPopupSupported
      Gets the info message.
      Specified by:
      getInfo in interface InfoPopupSupported
      Returns:
      the message, null if no info
    • setInfo

      public void setInfo(String infoMessage)
      Description copied from interface: InfoPopupSupported
      Sets the info message.
      Notice that an empty string will set the style but does not show any popup.
      Specified by:
      setInfo in interface InfoPopupSupported
      Parameters:
      infoMessage - the info message, null to clear
    • updateInfoStyle

      protected void updateInfoStyle(boolean enable)
      Updates the info style and shows/hides the popup if component has focus.
      Parameters:
      enable - true to enable style
    • triggerViewModified

      public void triggerViewModified()
      Description copied from interface: FxControl
      Walks up the component hierarchy and updates the viewModified property.
      This is done by comparing the saved view value with the current view.
      Specified by:
      triggerViewModified in interface FxControl
    • setViewValue

      public void setViewValue(Object value)
      Description copied from interface: FxComponent
      Sets a value in this component.
      The value's type is that of the model.
      Specified by:
      setViewValue in interface FxComponent
      Parameters:
      value - is the value to set
    • getViewValue

      public <V> V getViewValue()
      Description copied from interface: FxComponent
      Retrieves the value from this component.
      The value's type is that of the model.
      Specified by:
      getViewValue in interface FxComponent
      Type Parameters:
      V - the value's type
      Returns:
      the value shown by the component
    • saveView

      public void saveView()
      Description copied from interface: FxControl
      Creates a copy of the value shown to the user.
      Specified by:
      saveView in interface FxControl
    • invalidateSavedView

      public void invalidateSavedView()
      Description copied from interface: FxControl
      Invalidates the saved view.
      Specified by:
      invalidateSavedView in interface FxControl
    • isSavedViewObjectValid

      public boolean isSavedViewObjectValid()
      Description copied from interface: FxComponent
      Returns whether the view object is saved.
      Specified by:
      isSavedViewObjectValid in interface FxComponent
      Returns:
      true if saved, false if invalid
    • getSavedViewObject

      public Object getSavedViewObject()
      Description copied from interface: FxComponent
      Retrieves the view value saved with FxControl.saveView().
      The returned type is the internal native type of the component.
      Specified by:
      getSavedViewObject in interface FxComponent
      Returns:
      the saved view value
    • getLastViewObject

      public Object getLastViewObject()
      Gets the last view object.

      This is a hidden feature not exposed to the public API.

      Returns:
      the last view object converted from the model
    • setLastViewObject

      public void setLastViewObject(Object lastViewObject)
      Sets the last view object.
      The method is invoked from setViewValue(Object) when updating from the model.

      This is a hidden feature not exposed to the public API.

      Parameters:
      lastViewObject - the last view object
    • setType

      public void setType(Class<?> type)
      Description copied from interface: FxComponent
      Sets the type for this component.

      Notice that the type can be applied only once. This is because previously installed listeners could cause memory leaks.

      Specified by:
      setType in interface FxComponent
      Parameters:
      type - the type
    • getType

      public Class<?> getType()
      Description copied from interface: FxComponent
      Gets the type this component returns via FxComponent.getViewValue().
      Specified by:
      getType in interface FxComponent
      Returns:
      the type
    • setGenericType

      public void setGenericType(Type genericType)
      Description copied from interface: FxComponent
      Sets the generic type.
      Specified by:
      setGenericType in interface FxComponent
      Parameters:
      genericType - the generic type
    • getGenericType

      public Type getGenericType()
      Description copied from interface: FxComponent
      Gets the generic type.
      Specified by:
      getGenericType in interface FxComponent
      Returns:
      the generic type
    • setMandatory

      public void setMandatory(boolean mandatory)
      Sets the value of the mandatory property.
      Specified by:
      setMandatory in interface FxComponent
      Property description:
      Mandatory property.
      Parameters:
      mandatory - the value for the mandatory property
      See Also:
    • isMandatory

      public boolean isMandatory()
      Gets the value of the mandatory property.
      Specified by:
      isMandatory in interface FxComponent
      Property description:
      Mandatory property.
      Returns:
      the value of the mandatory property
      See Also:
    • mandatoryProperty

      public javafx.beans.property.BooleanProperty mandatoryProperty()
      Mandatory property.
      Specified by:
      mandatoryProperty in interface FxComponent
      Returns:
      the mandatory property
      See Also:
    • updateMandatoryStyle

      protected void updateMandatoryStyle(boolean mandatory)
      Does the physical update of the style. See resources/org/tentackle/fx/tentackle.css
      Parameters:
      mandatory - true if mandatory
    • setBindingPath

      public void setBindingPath(String bindingPath)
      Description copied from interface: FxComponent
      Sets the path to bind this component to.

      Usually the binding path will be determined from the components declared name. However, it can be set programmatically as well.

      Specified by:
      setBindingPath in interface FxComponent
      Parameters:
      bindingPath - the binding path, for ex. "invoiceNumber", null if autobinding
      See Also:
    • getBindingPath

      public String getBindingPath()
      Description copied from interface: FxComponent
      Gets the binding path.
      Specified by:
      getBindingPath in interface FxComponent
      Returns:
      the field path, null if autobinding (default)
    • setComponentPath

      public void setComponentPath(String componentPath)
      Description copied from interface: FxComponent
      Sets the component path.

      The path is <declaring-class-name>.<field-name>. Example "de.krake.invoicer.InvoicePanel.customerNumberField".

      Notice: the component path is set during binding.

      Specified by:
      setComponentPath in interface FxComponent
      Parameters:
      componentPath - the component path
    • getComponentPath

      public String getComponentPath()
      Description copied from interface: FxComponent
      Gets the component path.
      Specified by:
      getComponentPath in interface FxComponent
      Returns:
      the component path, null if not bound
    • setBinding

      public void setBinding(FxComponentBinding binding)
      Description copied from interface: FxComponent
      Sets the binding.
      Specified by:
      setBinding in interface FxComponent
      Parameters:
      binding - the binding, null if none.
    • getBinding

      public FxComponentBinding getBinding()
      Description copied from interface: FxComponent
      Gets the binding.
      Specified by:
      getBinding in interface FxComponent
      Returns:
      the binding, null if none
    • getTableCell

      public FxTableCell<?,?> getTableCell()
      Description copied from interface: FxComponent
      Gets the table cell if the component is used as a table cell editor.
      Specified by:
      getTableCell in interface FxComponent
      Returns:
      the cell, null if not a cell editor
    • setTableCell

      public void setTableCell(FxTableCell<?,?> tableCell)
      Description copied from interface: FxComponent
      Sets the table cell if the component is used as a table cell editor.
      Specified by:
      setTableCell in interface FxComponent
      Parameters:
      tableCell - the cell, null to disconnect from table cell
    • getTreeTableCell

      public FxTreeTableCell<?,?> getTreeTableCell()
      Description copied from interface: FxComponent
      Gets the treetable cell if the component is used as a treetable cell editor.
      Specified by:
      getTreeTableCell in interface FxComponent
      Returns:
      the cell, null if not a cell editor
    • setTreeTableCell

      public void setTreeTableCell(FxTreeTableCell<?,?> treeTableCell)
      Description copied from interface: FxComponent
      Sets the treetable cell if the component is used as a treetable cell editor.
      Specified by:
      setTreeTableCell in interface FxComponent
      Parameters:
      treeTableCell - the cell, null to disconnect from treetable cell
    • isListenerSuppressedIfModelUnchanged

      public boolean isListenerSuppressedIfModelUnchanged()
      Description copied from interface: FxComponent
      Returns whether the ViewToModelListeners should be invoked even if the model's value did not change at all.
      By default, the listener will always be invoked.
      Specified by:
      isListenerSuppressedIfModelUnchanged in interface FxComponent
      Returns:
      true if suppress invocation
    • setListenerSuppressedIfModelUnchanged

      public void setListenerSuppressedIfModelUnchanged(boolean listenerSuppressedIfModelUnchanged)
      Description copied from interface: FxComponent
      Sets whether the ViewToModelListeners should be invoked even if the model's value did not change at all.
      Specified by:
      setListenerSuppressedIfModelUnchanged in interface FxComponent
      Parameters:
      listenerSuppressedIfModelUnchanged - true if suppress invocation
    • isListenerSuppressedIfViewUnchanged

      public boolean isListenerSuppressedIfViewUnchanged()
      Description copied from interface: FxComponent
      Returns whether the ModelToViewListeners should be invoked even if the view's value will not change at all.
      By default, the listener will always be invoked.
      Specified by:
      isListenerSuppressedIfViewUnchanged in interface FxComponent
      Returns:
      true if suppress invocation
    • setListenerSuppressedIfViewUnchanged

      public void setListenerSuppressedIfViewUnchanged(boolean listenerSuppressedIfViewUnchanged)
      Description copied from interface: FxComponent
      Sets whether the ModelToViewListeners should be invoked even if the view's value will not change at all.
      Specified by:
      setListenerSuppressedIfViewUnchanged in interface FxComponent
      Parameters:
      listenerSuppressedIfViewUnchanged - true if suppress invocation