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
Delegate implementing FxComponent.
- Author:
- harald
-
Property Summary
PropertiesProperties inherited from class org.tentackle.fx.FxControlDelegate
changeable, viewModifiedProperties inherited from interface org.tentackle.fx.FxControl
changeable, viewModified -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected javafx.beans.property.ReadOnlyBooleanWrappercreateChangeableProperty(boolean changeable) Creates the changeable property.Gets the binding.Gets the binding path.abstract FxComponentGets the component of this delegate.Gets the component path.Gets the lazily created component delegate.getError()Gets the error message.Gets the generic type.getInfo()Gets the info message.Gets the last view object.javafx.scene.NodegetNode()Gets the component as a node.Gets the parent container.Retrieves the view value saved withFxControl.saveView().
The returned type is the internal native type of the component.FxTableCell<?, ?> Gets the table cell if the component is used as a table cell editor.FxTreeTableCell<?, ?> Gets the treetable cell if the component is used as a treetable cell editor.Class<?> getType()Gets the type this component returns viaFxComponent.getViewValue().ValueTranslator<?, ?> Gets the value translator.<V> VRetrieves the value from this component.
The value's type is that of the model.protected voidhandleInputFailure(String msg) Handles a failure during conversion of the user's input to the model.voidHides the error popup if shown.voidHides the info popup if shown.voidInvalidates the saved view.booleanReturns whether this is a temporary error.
Temporary errors are set by the value translators typically if some parsing failed.booleanReturns whether theViewToModelListeners should be invoked even if the model's value did not change at all.
By default, the listener will always be invoked.booleanReturns whether theModelToViewListeners should be invoked even if the view's value will not change at all.
By default, the listener will always be invoked.booleanGets the value of themandatoryproperty.booleanReturns whether model was updated andFxControl.updateView()not invoked since then.
Some components, such as FxTableView, never update the model because this is already done by the ObservableList.booleanReturns whether the view object is saved.protected booleanReturns a flag to avoid recursive invocations ofupdateModel().protected booleanReturns a flag to avoid recursive invocations ofupdateView().javafx.beans.property.BooleanPropertyMandatory property.voidsaveView()Creates a copy of the value shown to the user.voidsetBinding(FxComponentBinding binding) Sets the binding.voidsetBindingPath(String bindingPath) Sets the path to bind this component to.voidsetComponentPath(String componentPath) Sets the component path.voidsetContainerChangeable(boolean containerChangeable) Invoked when setChangeable() is invoked on the container of this component.voidSets the error message.
Notice that an empty string will set the style but does not show any popup.voidsetErrorTemporary(boolean errorTemporary) Sets the temporary error flag.voidsetGenericType(Type genericType) Sets the generic type.voidSets the info message.
Notice that an empty string will set the style but does not show any popup.voidsetLastViewObject(Object lastViewObject) Sets the last view object.
The method is invoked fromsetViewValue(Object)when updating from the model.voidsetListenerSuppressedIfModelUnchanged(boolean listenerSuppressedIfModelUnchanged) Sets whether theViewToModelListeners should be invoked even if the model's value did not change at all.voidsetListenerSuppressedIfViewUnchanged(boolean listenerSuppressedIfViewUnchanged) Sets whether theModelToViewListeners should be invoked even if the view's value will not change at all.voidsetMandatory(boolean mandatory) Sets the value of themandatoryproperty.voidsetTableCell(FxTableCell<?, ?> tableCell) Sets the table cell if the component is used as a table cell editor.voidsetTreeTableCell(FxTreeTableCell<?, ?> treeTableCell) Sets the treetable cell if the component is used as a treetable cell editor.voidSets the type for this component.voidsetValueTranslator(ValueTranslator<?, ?> valueTranslator) Sets a value translator.voidsetViewValue(Object value) Sets a value in this component.
The value's type is that of the model.voidShows the error popup.
Requires the error message set.voidShows the info popup.
Requires the info message set.Returns the classname plus optional fx:id.toString()voidWalks 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.voidUpdates the model according to the view.voidUpdates 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, setContainerChangeableIgnored, setHelpUrl, setViewModified, showHelp, viewModifiedPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tentackle.fx.FxComponent
getViewObject, isCellEditor, setViewObjectMethods inherited from interface org.tentackle.fx.FxControl
addModelToViewListener, addViewToModelListener, changeableProperty, getHelpUrl, isBindable, isChangeable, isContainerChangeableIgnored, isViewModified, removeModelToViewListener, removeViewToModelListener, setBindable, setChangeable, setContainerChangeableIgnored, setHelpUrl, setViewModified, showHelp, viewModifiedProperty
-
Property Details
-
mandatory
public javafx.beans.property.BooleanProperty mandatoryPropertyMandatory property.- Specified by:
mandatoryPropertyin interfaceFxComponent- Returns:
- the property
- See Also:
-
-
Field Details
-
MANDATORY_STYLE
Mandatory CSS style class.- See Also:
-
ERROR_STYLE
Error CSS style class.- See Also:
-
INFO_STYLE
Info CSS style class.- See Also:
-
-
Constructor Details
-
FxComponentDelegate
public FxComponentDelegate()Creates a component delegate.
-
-
Method Details
-
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
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
Description copied from interface:FxControlGets the parent container.- Specified by:
getParentContainerin interfaceFxControl- Returns:
- the parent, null if not a component of a container
-
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
-
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
Description copied from interface:FxComponentSets a value translator.- Specified by:
setValueTranslatorin interfaceFxComponent- Parameters:
valueTranslator- the translator
-
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
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 andFxControl.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
Description copied from interface:ErrorPopupSupportedGets the error message.- Specified by:
getErrorin interfaceErrorPopupSupported- Returns:
- the message, null if no error
-
setError
Description copied from interface:ErrorPopupSupportedSets the error message.
Notice that an empty string will set the style but does 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
Description copied from interface:InfoPopupSupportedGets the info message.- Specified by:
getInfoin interfaceInfoPopupSupported- Returns:
- the message, null if no info
-
setInfo
Description copied from interface:InfoPopupSupportedSets the info message.
Notice that an empty string will set the style but does 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
-
setViewValue
Description copied from interface:FxComponentSets a value in this component.
The value's type is that of the model.- Specified by:
setViewValuein interfaceFxComponent- Parameters:
value- is the value to set
-
getViewValue
public <V> V getViewValue()Description copied from interface:FxComponentRetrieves the value from this component.
The value's type is that of the model.- Specified by:
getViewValuein interfaceFxComponent- Type Parameters:
V- the value's type- Returns:
- the value shown by the component
-
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
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
-
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
Sets the last view object.
The method is invoked fromsetViewValue(Object)when updating from the model.This is a hidden feature not exposed to the public API.
- Parameters:
lastViewObject- the last view object
-
setType
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 memory leaks.
- Specified by:
setTypein interfaceFxComponent- Parameters:
type- the type
-
getType
Description copied from interface:FxComponentGets the type this component returns viaFxComponent.getViewValue().- Specified by:
getTypein interfaceFxComponent- Returns:
- the type
-
setGenericType
Description copied from interface:FxComponentSets the generic type.- Specified by:
setGenericTypein interfaceFxComponent- Parameters:
genericType- the generic type
-
getGenericType
Description copied from interface:FxComponentGets the generic type.- Specified by:
getGenericTypein interfaceFxComponent- Returns:
- the generic type
-
setMandatory
public void setMandatory(boolean mandatory) Sets the value of themandatoryproperty.- Specified by:
setMandatoryin interfaceFxComponent- Property description:
- Mandatory property.
- Parameters:
mandatory- the value for themandatoryproperty- See Also:
-
isMandatory
public boolean isMandatory()Gets the value of themandatoryproperty.- Specified by:
isMandatoryin interfaceFxComponent- Property description:
- Mandatory property.
- Returns:
- the value of the
mandatoryproperty - See Also:
-
mandatoryProperty
public javafx.beans.property.BooleanProperty mandatoryProperty()Mandatory property.- Specified by:
mandatoryPropertyin interfaceFxComponent- Returns:
- the
mandatoryproperty - 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
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 programmatically as well.
- Specified by:
setBindingPathin interfaceFxComponent- Parameters:
bindingPath- the binding path, for ex."invoiceNumber", null if autobinding- See Also:
-
getBindingPath
Description copied from interface:FxComponentGets the binding path.- Specified by:
getBindingPathin interfaceFxComponent- Returns:
- the field path, null if autobinding (default)
-
setComponentPath
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
Description copied from interface:FxComponentGets the component path.- Specified by:
getComponentPathin interfaceFxComponent- Returns:
- the component path, null if not bound
-
setBinding
Description copied from interface:FxComponentSets the binding.- Specified by:
setBindingin interfaceFxComponent- Parameters:
binding- the binding, null if none.
-
getBinding
Description copied from interface:FxComponentGets the binding.- Specified by:
getBindingin interfaceFxComponent- Returns:
- the binding, null if none
-
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
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
-
getTreeTableCell
Description copied from interface:FxComponentGets the treetable cell if the component is used as a treetable cell editor.- Specified by:
getTreeTableCellin interfaceFxComponent- Returns:
- the cell, null if not a cell editor
-
setTreeTableCell
Description copied from interface:FxComponentSets the treetable cell if the component is used as a treetable cell editor.- Specified by:
setTreeTableCellin interfaceFxComponent- Parameters:
treeTableCell- the cell, null to disconnect from treetable cell
-
isListenerSuppressedIfModelUnchanged
public boolean isListenerSuppressedIfModelUnchanged()Description copied from interface:FxComponentReturns whether theViewToModelListeners should be invoked even if the model's value did not change at all.
By default, the listener will always be invoked.- Specified by:
isListenerSuppressedIfModelUnchangedin interfaceFxComponent- Returns:
- true if suppress invocation
-
setListenerSuppressedIfModelUnchanged
public void setListenerSuppressedIfModelUnchanged(boolean listenerSuppressedIfModelUnchanged) Description copied from interface:FxComponentSets whether theViewToModelListeners should be invoked even if the model's value did not change at all.- Specified by:
setListenerSuppressedIfModelUnchangedin interfaceFxComponent- Parameters:
listenerSuppressedIfModelUnchanged- true if suppress invocation
-
isListenerSuppressedIfViewUnchanged
public boolean isListenerSuppressedIfViewUnchanged()Description copied from interface:FxComponentReturns whether theModelToViewListeners should be invoked even if the view's value will not change at all.
By default, the listener will always be invoked.- Specified by:
isListenerSuppressedIfViewUnchangedin interfaceFxComponent- Returns:
- true if suppress invocation
-
setListenerSuppressedIfViewUnchanged
public void setListenerSuppressedIfViewUnchanged(boolean listenerSuppressedIfViewUnchanged) Description copied from interface:FxComponentSets whether theModelToViewListeners should be invoked even if the view's value will not change at all.- Specified by:
setListenerSuppressedIfViewUnchangedin interfaceFxComponent- Parameters:
listenerSuppressedIfViewUnchanged- true if suppress invocation
-