- 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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringERROR_STYLEError CSS style class.static java.lang.StringINFO_STYLEInfo CSS style class.static java.lang.StringMANDATORY_STYLEMandatory CSS style class.
-
Constructor Summary
Constructors Constructor Description FxComponentDelegate()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected javafx.beans.property.ReadOnlyBooleanWrappercreateChangeableProperty(boolean changeable)Creates the changeable property.FxComponentBindinggetBinding()Gets the binding.java.lang.StringgetBindingPath()Gets the binding path.abstract FxComponentgetComponent()Gets the component of this delegate.java.lang.StringgetComponentPath()Gets the component path.FxComponentDelegategetDelegate()Gets the lazily created component delegate.java.lang.StringgetError()Gets the error message.java.lang.reflect.TypegetGenericType()Gets the generic type.java.lang.StringgetInfo()Gets the info message.javafx.scene.NodegetNode()Gets the component as a node.FxContainergetParentContainer()Gets the parent container.java.lang.ObjectgetSavedViewObject()Retrieves the view value saved withFxControl.saveView().
The returned type is the internal native type of the component.FxTableCell<?,?>getTableCell()Gets the table cell if the component is used as a table cell editor.java.lang.Class<?>getType()Gets the type this component returns viaFxComponent.getViewValue().ValueTranslator<?,?>getValueTranslator()Gets the value translator.protected voidhandleInputFailure(java.lang.String msg)Handles a failure during conversion of the user's input to the model.voidhideErrorPopup()Hides the error popup if shown.voidhideInfoPopup()Hides the info popup if shown.voidinvalidateSavedView()Invalidates the saved view.booleanisErrorTemporary()Returns whether this is a temporary error.
Temporary errors are set by the value translators typically if some parsing failed.booleanisMandatory()Gets the mandatory option.booleanisModelUpdated()Returns whether model was updated and updateview not invoked since then.
Some components, such as FxTableView, never update the model because this is already done by the ObservableList.booleanisSavedViewObjectValid()Returns whether the view object is saved.protected booleanisUpdatingModel()Returns a flag to avoid recursive invocations ofupdateModel().protected booleanisUpdatingView()Returns a flag to avoid recursive invocations ofupdateView().javafx.beans.property.BooleanPropertymandatoryProperty()Gets the mandatory property.voidsaveView()Creates a copy of the value shown to the user.voidsetBinding(FxComponentBinding binding)Sets the binding.voidsetBindingPath(java.lang.String bindingPath)Sets the path to bind this component to.voidsetComponentPath(java.lang.String componentPath)Sets the component path.voidsetContainerChangeable(boolean containerChangeable)Invoked when setChangeable() is invoked on the container of this component.voidsetError(java.lang.String errorMessage)Sets the error message.
Notice that an empty string will set the style but dows not show any popup.voidsetErrorTemporary(boolean errorTemporary)Sets the temporary error flag.voidsetGenericType(java.lang.reflect.Type genericType)Sets the generic type.voidsetInfo(java.lang.String infoMessage)Sets the info message.
Notice that an empty string will set the style but dows not show any popup.voidsetMandatory(boolean mandatory)Sets the mandatory option.
Mandatory fields are differently visualized.voidsetTableCell(FxTableCell<?,?> tableCell)Sets the table cell if the component is used as a table cell editor.voidsetType(java.lang.Class<?> type)Sets the type for this component.voidsetValueTranslator(ValueTranslator<?,?> valueTranslator)Sets a value translator.voidshowErrorPopup()Shows the error popup.
Requires the error message set.voidshowInfoPopup()Shows the info popup.
Requires the info message set.java.lang.StringtoGenericString()Returns the classname plus optional fx:id.java.lang.StringtoString()voidtriggerViewModified()Walks up the component hierarchy and updates the viewModified property.
This is done by comparing the saved view value with the current view.protected voidupdateChangeable(boolean changeable)Updates other properties if changeable is bound to something else.protected voidupdateErrorStyle(boolean enable)Updates the error style and shows/hides the popup if component has focus.protected voidupdateInfoStyle(boolean enable)Updates the info style and shows/hides the popup if component has focus.protected voidupdateMandatoryStyle(boolean mandatory)Does the physical update of the style.voidupdateModel()Updates the model according to the view.voidupdateView()Updates the view according to the model.-
Methods inherited from class org.tentackle.fx.FxControlDelegate
addModelToViewListener, addViewToModelListener, changeableProperty, fireModelToViewListeners, fireViewToModelListeners, getHelpUrl, getModelToViewListeners, getViewToModelListeners, isBindable, isChangeable, isContainerChangeableIgnored, isControlChangeable, isViewModified, removeModelToViewListener, removeViewToModelListener, setBindable, setChangeable, setContainerChangableIgnored, setHelpUrl, setViewModified, showHelp, viewModifiedProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.tentackle.fx.FxComponent
getViewObject, getViewValue, setViewObject, setViewValue
-
Methods inherited from interface org.tentackle.fx.FxControl
addModelToViewListener, addViewToModelListener, changeableProperty, getHelpUrl, isBindable, isChangeable, isContainerChangeableIgnored, isViewModified, removeModelToViewListener, removeViewToModelListener, setBindable, setChangeable, setContainerChangableIgnored, setHelpUrl, setViewModified, showHelp, viewModifiedProperty
-
-
-
-
Field Detail
-
MANDATORY_STYLE
public static final java.lang.String MANDATORY_STYLE
Mandatory CSS style class.- See Also:
- Constant Field Values
-
ERROR_STYLE
public static final java.lang.String ERROR_STYLE
Error CSS style class.- See Also:
- Constant Field Values
-
INFO_STYLE
public static final java.lang.String INFO_STYLE
Info CSS style class.- See Also:
- Constant Field Values
-
-
Method Detail
-
getDelegate
public FxComponentDelegate getDelegate()
Description copied from interface:FxControlGets the lazily created component delegate.- Specified by:
getDelegatein interfaceFxComponent- Specified by:
getDelegatein interfaceFxControl- Overrides:
getDelegatein classFxControlDelegate- 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:FxControlGets the parent container.- Specified by:
getParentContainerin interfaceFxControl- Returns:
- the parent, null if not a component of a container
-
toGenericString
public java.lang.String toGenericString()
Description copied from interface:FxControlReturns the classname plus optional fx:id.- Specified by:
toGenericStringin interfaceFxControl- Returns:
- the generic string for diagnostics and logging
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
updateChangeable
protected void updateChangeable(boolean changeable)
Description copied from class:FxControlDelegateUpdates other properties if changeable is bound to something else.- Overrides:
updateChangeablein classFxControlDelegate- Parameters:
changeable- the flag
-
createChangeableProperty
protected javafx.beans.property.ReadOnlyBooleanWrapper createChangeableProperty(boolean changeable)
Description copied from class:FxControlDelegateCreates the changeable property.- Overrides:
createChangeablePropertyin classFxControlDelegate- Parameters:
changeable- the initial value- Returns:
- the property
-
setContainerChangeable
public void setContainerChangeable(boolean containerChangeable)
Description copied from interface:FxControlInvoked when setChangeable() is invoked on the container of this component.- Specified by:
setContainerChangeablein interfaceFxControl- Parameters:
containerChangeable- true if container is changeable, false if all components readonly
-
setValueTranslator
public void setValueTranslator(ValueTranslator<?,?> valueTranslator)
Description copied from interface:FxComponentSets a value translator.- Specified by:
setValueTranslatorin interfaceFxComponent- Parameters:
valueTranslator- the translator
-
getValueTranslator
public ValueTranslator<?,?> getValueTranslator()
Description copied from interface:FxComponentGets the value translator.- Specified by:
getValueTranslatorin interfaceFxComponent- Returns:
- the translator
-
isUpdatingModel
protected boolean isUpdatingModel()
Returns a flag to avoid recursive invocations ofupdateModel().- Returns:
- true if currently updating the model
-
isUpdatingView
protected boolean isUpdatingView()
Returns a flag to avoid recursive invocations ofupdateView().- Returns:
- true if currently updating the view
-
updateView
public void updateView()
Description copied from interface:FxControlUpdates the view according to the model.- Specified by:
updateViewin interfaceFxControl
-
updateModel
public void updateModel()
Description copied from interface:FxControlUpdates the model according to the view.- Specified by:
updateModelin interfaceFxControl
-
handleInputFailure
protected void handleInputFailure(java.lang.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:FxComponentReturns whether model was updated and 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:
isModelUpdatedin interfaceFxComponent- Returns:
- true if updateView could make sense
-
showErrorPopup
public void showErrorPopup()
Description copied from interface:ErrorPopupSupportedShows the error popup.
Requires the error message set.- Specified by:
showErrorPopupin interfaceErrorPopupSupported
-
hideErrorPopup
public void hideErrorPopup()
Description copied from interface:ErrorPopupSupportedHides the error popup if shown.- Specified by:
hideErrorPopupin interfaceErrorPopupSupported
-
getError
public java.lang.String getError()
Description copied from interface:ErrorPopupSupportedGets the error message.- Specified by:
getErrorin interfaceErrorPopupSupported- Returns:
- the message, null if no error
-
setError
public void setError(java.lang.String errorMessage)
Description copied from interface:ErrorPopupSupportedSets the error message.
Notice that an empty string will set the style but dows not show any popup.- Specified by:
setErrorin interfaceErrorPopupSupported- Parameters:
errorMessage- the error message, null to clear
-
setErrorTemporary
public void setErrorTemporary(boolean errorTemporary)
Description copied from interface:ErrorPopupSupportedSets the temporary error flag.- Specified by:
setErrorTemporaryin interfaceErrorPopupSupported- Parameters:
errorTemporary- true if this is a temporary error
-
isErrorTemporary
public boolean isErrorTemporary()
Description copied from interface:ErrorPopupSupportedReturns 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:
isErrorTemporaryin interfaceErrorPopupSupported- 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:InfoPopupSupportedShows the info popup.
Requires the info message set.- Specified by:
showInfoPopupin interfaceInfoPopupSupported
-
hideInfoPopup
public void hideInfoPopup()
Description copied from interface:InfoPopupSupportedHides the info popup if shown.- Specified by:
hideInfoPopupin interfaceInfoPopupSupported
-
getInfo
public java.lang.String getInfo()
Description copied from interface:InfoPopupSupportedGets the info message.- Specified by:
getInfoin interfaceInfoPopupSupported- Returns:
- the message, null if no info
-
setInfo
public void setInfo(java.lang.String infoMessage)
Description copied from interface:InfoPopupSupportedSets the info message.
Notice that an empty string will set the style but dows not show any popup.- Specified by:
setInfoin interfaceInfoPopupSupported- 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:FxControlWalks up the component hierarchy and updates the viewModified property.
This is done by comparing the saved view value with the current view.- Specified by:
triggerViewModifiedin interfaceFxControl
-
saveView
public void saveView()
Description copied from interface:FxControlCreates a copy of the value shown to the user.
-
invalidateSavedView
public void invalidateSavedView()
Description copied from interface:FxControlInvalidates the saved view.- Specified by:
invalidateSavedViewin interfaceFxControl
-
isSavedViewObjectValid
public boolean isSavedViewObjectValid()
Description copied from interface:FxComponentReturns whether the view object is saved.- Specified by:
isSavedViewObjectValidin interfaceFxComponent- Returns:
- true if saved, false if invalid
-
getSavedViewObject
public java.lang.Object getSavedViewObject()
Description copied from interface:FxComponentRetrieves the view value saved withFxControl.saveView().
The returned type is the internal native type of the component.- Specified by:
getSavedViewObjectin interfaceFxComponent- Returns:
- the saved view value
-
setType
public void setType(java.lang.Class<?> type)
Description copied from interface:FxComponentSets the type for this component.Notice that the type can be applied only once. This is because previously installed listeners could cause memleaks.
- Specified by:
setTypein interfaceFxComponent- Parameters:
type- the type
-
getType
public java.lang.Class<?> getType()
Description copied from interface:FxComponentGets the type this component returns viaFxComponent.getViewValue().- Specified by:
getTypein interfaceFxComponent- Returns:
- the type
-
setGenericType
public void setGenericType(java.lang.reflect.Type genericType)
Description copied from interface:FxComponentSets the generic type.- Specified by:
setGenericTypein interfaceFxComponent- Parameters:
genericType- the generic type
-
getGenericType
public java.lang.reflect.Type getGenericType()
Description copied from interface:FxComponentGets the generic type.- Specified by:
getGenericTypein interfaceFxComponent- Returns:
- the generic type
-
setMandatory
public void setMandatory(boolean mandatory)
Description copied from interface:FxComponentSets the mandatory option.
Mandatory fields are differently visualized. There is no further functional difference.- Specified by:
setMandatoryin interfaceFxComponent- Parameters:
mandatory- true if mandatory
-
isMandatory
public boolean isMandatory()
Description copied from interface:FxComponentGets the mandatory option.- Specified by:
isMandatoryin interfaceFxComponent- Returns:
- true if mandatory
-
mandatoryProperty
public javafx.beans.property.BooleanProperty mandatoryProperty()
Description copied from interface:FxComponentGets the mandatory property.- Specified by:
mandatoryPropertyin interfaceFxComponent- Returns:
- the property
-
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(java.lang.String bindingPath)
Description copied from interface:FxComponentSets the path to bind this component to.Usually the binding path will be determined from the components declared name. However, it can be set programatically as well.
- Specified by:
setBindingPathin interfaceFxComponent- Parameters:
bindingPath- the binding path, for ex."invoiceNumber", null if autobinding- See Also:
Binder
-
getBindingPath
public java.lang.String getBindingPath()
Description copied from interface:FxComponentGets the binding path.- Specified by:
getBindingPathin interfaceFxComponent- Returns:
- the field path, null if autobinding (default)
-
setComponentPath
public void setComponentPath(java.lang.String componentPath)
Description copied from interface:FxComponentSets 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:
setComponentPathin interfaceFxComponent- Parameters:
componentPath- the component path
-
getComponentPath
public java.lang.String getComponentPath()
Description copied from interface:FxComponentGets the component path.- Specified by:
getComponentPathin interfaceFxComponent- Returns:
- the component path, null if not bound
-
setBinding
public void setBinding(FxComponentBinding binding)
Description copied from interface:FxComponentSets the binding.- Specified by:
setBindingin interfaceFxComponent- Parameters:
binding- the binding, null if none.
-
getBinding
public FxComponentBinding getBinding()
Description copied from interface:FxComponentGets the binding.- Specified by:
getBindingin interfaceFxComponent- Returns:
- the binding, null if none
-
getTableCell
public FxTableCell<?,?> getTableCell()
Description copied from interface:FxComponentGets the table cell if the component is used as a table cell editor.- Specified by:
getTableCellin interfaceFxComponent- Returns:
- the cell, null if not a cell editor
-
setTableCell
public void setTableCell(FxTableCell<?,?> tableCell)
Description copied from interface:FxComponentSets the table cell if the component is used as a table cell editor.- Specified by:
setTableCellin interfaceFxComponent- Parameters:
tableCell- the cell, null to disconnect from table cell
-
-