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
Properties inherited from class org.tentackle.fx.FxControlDelegate
changeable, viewModified
Properties inherited from interface org.tentackle.fx.FxControl
changeable, viewModified
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected javafx.beans.property.ReadOnlyBooleanWrapper
createChangeableProperty
(boolean changeable) Creates the changeable property.Gets the binding.Gets the binding path.abstract FxComponent
Gets 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.Node
getNode()
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> V
Retrieves the value from this component.
The value's type is that of the model.protected void
handleInputFailure
(String msg) Handles a failure during conversion of the user's input to the model.void
Hides the error popup if shown.void
Hides the info popup if shown.void
Invalidates the saved view.boolean
Returns whether this is a temporary error.
Temporary errors are set by the value translators typically if some parsing failed.boolean
Returns whether theViewToModelListener
s should be invoked even if the model's value did not change at all.
By default, the listener will always be invoked.boolean
Returns whether theModelToViewListener
s should be invoked even if the view's value will not change at all.
By default, the listener will always be invoked.boolean
Gets the value of themandatory
property.boolean
Returns 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.boolean
Returns whether the view object is saved.protected boolean
Returns a flag to avoid recursive invocations ofupdateModel()
.protected boolean
Returns a flag to avoid recursive invocations ofupdateView()
.javafx.beans.property.BooleanProperty
Mandatory property.void
saveView()
Creates a copy of the value shown to the user.void
setBinding
(FxComponentBinding binding) Sets the binding.void
setBindingPath
(String bindingPath) Sets the path to bind this component to.void
setComponentPath
(String componentPath) Sets the component path.void
setContainerChangeable
(boolean containerChangeable) Invoked when setChangeable() is invoked on the container of this component.void
Sets the error message.
Notice that an empty string will set the style but does not show any popup.void
setErrorTemporary
(boolean errorTemporary) Sets the temporary error flag.void
setGenericType
(Type genericType) Sets the generic type.void
Sets the info message.
Notice that an empty string will set the style but does not show any popup.void
setLastViewObject
(Object lastViewObject) Sets the last view object.
The method is invoked fromsetViewValue(Object)
when updating from the model.void
setListenerSuppressedIfModelUnchanged
(boolean listenerSuppressedIfModelUnchanged) Sets whether theViewToModelListener
s should be invoked even if the model's value did not change at all.void
setListenerSuppressedIfViewUnchanged
(boolean listenerSuppressedIfViewUnchanged) Sets whether theModelToViewListener
s should be invoked even if the view's value will not change at all.void
setMandatory
(boolean mandatory) Sets the value of themandatory
property.void
setTableCell
(FxTableCell<?, ?> tableCell) Sets the table cell if the component is used as a table cell editor.void
setTreeTableCell
(FxTreeTableCell<?, ?> treeTableCell) Sets the treetable cell if the component is used as a treetable cell editor.void
Sets the type for this component.void
setValueTranslator
(ValueTranslator<?, ?> valueTranslator) Sets a value translator.void
setViewValue
(Object value) Sets a value in this component.
The value's type is that of the model.void
Shows the error popup.
Requires the error message set.void
Shows the info popup.
Requires the info message set.Returns the classname plus optional fx:id.toString()
void
Walks up the component hierarchy and updates the viewModified property.
This is done by comparing the saved view value with the current view.protected void
updateChangeable
(boolean changeable) Updates other properties if changeable is bound to something else.protected void
updateErrorStyle
(boolean enable) Updates the error style and shows/hides the popup if component has focus.protected void
updateInfoStyle
(boolean enable) Updates the info style and shows/hides the popup if component has focus.protected void
updateMandatoryStyle
(boolean mandatory) Does the physical update of the style.void
Updates the model according to the view.void
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, setContainerChangeableIgnored, 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, isCellEditor, setViewObject
Methods 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:
mandatoryProperty
in 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:FxControl
Gets the lazily created component delegate.- Specified by:
getDelegate
in interfaceFxComponent
- Specified by:
getDelegate
in interfaceFxControl
- Overrides:
getDelegate
in 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:FxControl
Gets the parent container.- Specified by:
getParentContainer
in interfaceFxControl
- Returns:
- the parent, null if not a component of a container
-
toGenericString
Description copied from interface:FxControl
Returns the classname plus optional fx:id.- Specified by:
toGenericString
in interfaceFxControl
- Returns:
- the generic string for diagnostics and logging
-
toString
-
updateChangeable
protected void updateChangeable(boolean changeable) Description copied from class:FxControlDelegate
Updates other properties if changeable is bound to something else.- Overrides:
updateChangeable
in classFxControlDelegate
- 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 classFxControlDelegate
- 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 interfaceFxControl
- Parameters:
containerChangeable
- true if container is changeable, false if all components readonly
-
setValueTranslator
Description copied from interface:FxComponent
Sets a value translator.- Specified by:
setValueTranslator
in interfaceFxComponent
- Parameters:
valueTranslator
- the translator
-
getValueTranslator
Description copied from interface:FxComponent
Gets the value translator.- Specified by:
getValueTranslator
in 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:FxControl
Updates the view according to the model.- Specified by:
updateView
in interfaceFxControl
-
updateModel
public void updateModel()Description copied from interface:FxControl
Updates the model according to the view.- Specified by:
updateModel
in 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:FxComponent
Returns 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:
isModelUpdated
in interfaceFxComponent
- 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 interfaceErrorPopupSupported
-
hideErrorPopup
public void hideErrorPopup()Description copied from interface:ErrorPopupSupported
Hides the error popup if shown.- Specified by:
hideErrorPopup
in interfaceErrorPopupSupported
-
getError
Description copied from interface:ErrorPopupSupported
Gets the error message.- Specified by:
getError
in interfaceErrorPopupSupported
- Returns:
- the message, null if no error
-
setError
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 interfaceErrorPopupSupported
- 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 interfaceErrorPopupSupported
- 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 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:InfoPopupSupported
Shows the info popup.
Requires the info message set.- Specified by:
showInfoPopup
in interfaceInfoPopupSupported
-
hideInfoPopup
public void hideInfoPopup()Description copied from interface:InfoPopupSupported
Hides the info popup if shown.- Specified by:
hideInfoPopup
in interfaceInfoPopupSupported
-
getInfo
Description copied from interface:InfoPopupSupported
Gets the info message.- Specified by:
getInfo
in interfaceInfoPopupSupported
- Returns:
- the message, null if no info
-
setInfo
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 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: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 interfaceFxControl
-
setViewValue
Description copied from interface:FxComponent
Sets a value in this component.
The value's type is that of the model.- Specified by:
setViewValue
in interfaceFxComponent
- 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 interfaceFxComponent
- 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. -
invalidateSavedView
public void invalidateSavedView()Description copied from interface:FxControl
Invalidates the saved view.- Specified by:
invalidateSavedView
in interfaceFxControl
-
isSavedViewObjectValid
public boolean isSavedViewObjectValid()Description copied from interface:FxComponent
Returns whether the view object is saved.- Specified by:
isSavedViewObjectValid
in interfaceFxComponent
- Returns:
- true if saved, false if invalid
-
getSavedViewObject
Description copied from interface:FxComponent
Retrieves the view value saved withFxControl.saveView()
.
The returned type is the internal native type of the component.- Specified by:
getSavedViewObject
in 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: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 interfaceFxComponent
- Parameters:
type
- the type
-
getType
Description copied from interface:FxComponent
Gets the type this component returns viaFxComponent.getViewValue()
.- Specified by:
getType
in interfaceFxComponent
- Returns:
- the type
-
setGenericType
Description copied from interface:FxComponent
Sets the generic type.- Specified by:
setGenericType
in interfaceFxComponent
- Parameters:
genericType
- the generic type
-
getGenericType
Description copied from interface:FxComponent
Gets the generic type.- Specified by:
getGenericType
in interfaceFxComponent
- Returns:
- the generic type
-
setMandatory
public void setMandatory(boolean mandatory) Sets the value of themandatory
property.- Specified by:
setMandatory
in interfaceFxComponent
- Property description:
- Mandatory property.
- Parameters:
mandatory
- the value for themandatory
property- See Also:
-
isMandatory
public boolean isMandatory()Gets the value of themandatory
property.- Specified by:
isMandatory
in interfaceFxComponent
- 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 interfaceFxComponent
- 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
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 interfaceFxComponent
- Parameters:
bindingPath
- the binding path, for ex."invoiceNumber"
, null if autobinding- See Also:
-
getBindingPath
Description copied from interface:FxComponent
Gets the binding path.- Specified by:
getBindingPath
in interfaceFxComponent
- Returns:
- the field path, null if autobinding (default)
-
setComponentPath
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 interfaceFxComponent
- Parameters:
componentPath
- the component path
-
getComponentPath
Description copied from interface:FxComponent
Gets the component path.- Specified by:
getComponentPath
in interfaceFxComponent
- Returns:
- the component path, null if not bound
-
setBinding
Description copied from interface:FxComponent
Sets the binding.- Specified by:
setBinding
in interfaceFxComponent
- Parameters:
binding
- the binding, null if none.
-
getBinding
Description copied from interface:FxComponent
Gets the binding.- Specified by:
getBinding
in interfaceFxComponent
- Returns:
- the binding, null if none
-
getTableCell
Description copied from interface:FxComponent
Gets the table cell if the component is used as a table cell editor.- Specified by:
getTableCell
in interfaceFxComponent
- Returns:
- the cell, null if not a cell editor
-
setTableCell
Description copied from interface:FxComponent
Sets the table cell if the component is used as a table cell editor.- Specified by:
setTableCell
in interfaceFxComponent
- Parameters:
tableCell
- the cell, null to disconnect from table cell
-
getTreeTableCell
Description copied from interface:FxComponent
Gets the treetable cell if the component is used as a treetable cell editor.- Specified by:
getTreeTableCell
in interfaceFxComponent
- Returns:
- the cell, null if not a cell editor
-
setTreeTableCell
Description copied from interface:FxComponent
Sets the treetable cell if the component is used as a treetable cell editor.- Specified by:
setTreeTableCell
in interfaceFxComponent
- Parameters:
treeTableCell
- the cell, null to disconnect from treetable cell
-
isListenerSuppressedIfModelUnchanged
public boolean isListenerSuppressedIfModelUnchanged()Description copied from interface:FxComponent
Returns whether theViewToModelListener
s 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 interfaceFxComponent
- Returns:
- true if suppress invocation
-
setListenerSuppressedIfModelUnchanged
public void setListenerSuppressedIfModelUnchanged(boolean listenerSuppressedIfModelUnchanged) Description copied from interface:FxComponent
Sets whether theViewToModelListener
s should be invoked even if the model's value did not change at all.- Specified by:
setListenerSuppressedIfModelUnchanged
in interfaceFxComponent
- Parameters:
listenerSuppressedIfModelUnchanged
- true if suppress invocation
-
isListenerSuppressedIfViewUnchanged
public boolean isListenerSuppressedIfViewUnchanged()Description copied from interface:FxComponent
Returns whether theModelToViewListener
s 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 interfaceFxComponent
- Returns:
- true if suppress invocation
-
setListenerSuppressedIfViewUnchanged
public void setListenerSuppressedIfViewUnchanged(boolean listenerSuppressedIfViewUnchanged) Description copied from interface:FxComponent
Sets whether theModelToViewListener
s should be invoked even if the view's value will not change at all.- Specified by:
setListenerSuppressedIfViewUnchanged
in interfaceFxComponent
- Parameters:
listenerSuppressedIfViewUnchanged
- true if suppress invocation
-