- java.lang.Object
-
- org.tentackle.fx.FxControlDelegate
-
- org.tentackle.fx.FxComponentDelegate
-
- org.tentackle.fx.FxTextComponentDelegate
-
- All Implemented Interfaces:
java.util.function.Function<javafx.scene.control.TextFormatter.Change,javafx.scene.control.TextFormatter.Change>,java.util.function.UnaryOperator<javafx.scene.control.TextFormatter.Change>,ErrorPopupSupported,FxComponent,FxControl,FxTextComponent,InfoPopupSupported
- Direct Known Subclasses:
AbstractTextFieldDelegate,FxComboBoxDelegate,FxDatePickerDelegate,FxHTMLEditorDelegate
public abstract class FxTextComponentDelegate extends FxComponentDelegate implements FxTextComponent, java.util.function.UnaryOperator<javafx.scene.control.TextFormatter.Change>
Delegate implementing FxComponent.- Author:
- harald
-
-
Field Summary
-
Fields inherited from class org.tentackle.fx.FxComponentDelegate
ERROR_STYLE, INFO_STYLE, MANDATORY_STYLE
-
-
Constructor Summary
Constructors Constructor Description FxTextComponentDelegate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.scene.control.TextFormatter.Changeapply(javafx.scene.control.TextFormatter.Change t)voidautoSelect()Selects or deselects all text in the text input.protected javafx.beans.property.ReadOnlyBooleanWrappercreateChangeableProperty(boolean changeable)Creates the changeable property.protected ValueTranslator<?,?>createValueTranslator(java.lang.Class<?> type)java.lang.Stringfilter(java.lang.String text)Filters input characters.CaseConversiongetCaseConversion()Gets the case conversion.java.lang.IntegergetErrorOffset()Gets the error offset.chargetFiller()Gets the filler character.java.lang.StringgetInvalidChars()Gets invalid characters.intgetMaxColumns()Gets the maximum number of columns.java.lang.StringgetPattern()Gets the format pattern.intgetScale()Gets the current scale.javafx.geometry.PosgetTextAlignment()Gets the text alignment.protected FxTextComponentgetTextComponent()Gets the text component.java.util.function.Function<java.lang.String,java.lang.String>getTextConverter()Gets the text converter.java.lang.StringgetValidChars()Gets allowed characters.booleanisAutoSelect()Returns whether the auto-select feature is enabled.booleanisLenient()Returns whether parsing to model should be lenient.booleanisUnsigned()Returns whether a numeric field is unsigned or signed.booleanisUTC()Returns whether this is a UTC timestamp.voidsaveView()Creates a copy of the value shown to the user.voidsetAutoSelect(boolean autoSelect)Sets the auto-select feature.
A component with autoselect enabled will automatically select all characters if the component gets the keyboard focus.voidsetCaseConversion(CaseConversion caseConversion)Sets the case conversion.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.voidsetErrorOffset(java.lang.Integer errorOffset)Sets the error offset.voidsetFiller(char filler)Sets the filler character.
The default is space.voidsetInvalidChars(java.lang.String invalidChars)Sets invalid characters.voidsetLenient(boolean lenient)Sets whether parsing to model should be lenient.voidsetMaxColumns(int maxColumns)Sets the maximum number of columns.
The number of columns will be enforced by the model.voidsetPattern(java.lang.String pattern)Sets the format pattern.
The format pattern is used to format the view of the data.voidsetScale(int scale)Changes the format according to the given scale.voidsetTextAlignment(javafx.geometry.Pos textAlignment)Sets the text alignment.voidsetTextConverter(java.util.function.Function<java.lang.String,java.lang.String> textConverter)Sets a text converter.
Converts input text to the view's text.voidsetType(java.lang.Class<?> type)Sets the type for this component.voidsetUnsigned(boolean unsigned)Sets whether a numeric field is unsigned or signed.voidsetUTC(boolean utc)Sets whether this is a UTC timestamp.voidsetValidChars(java.lang.String validChars)Sets allowed characters.voidshowErrorPopup()Shows the error popup.
Requires the error message set.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 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.FxComponentDelegate
getBinding, getBindingPath, getComponent, getComponentPath, getDelegate, getError, getGenericType, getInfo, getNode, getParentContainer, getSavedViewObject, getTableCell, getType, getValueTranslator, handleInputFailure, hideErrorPopup, hideInfoPopup, invalidateSavedView, isErrorTemporary, isMandatory, isModelUpdated, isSavedViewObjectValid, isUpdatingModel, isUpdatingView, mandatoryProperty, setBinding, setBindingPath, setComponentPath, setErrorTemporary, setGenericType, setInfo, setMandatory, setTableCell, setValueTranslator, showInfoPopup, toGenericString, toString, updateErrorStyle, updateInfoStyle
-
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.ErrorPopupSupported
getError, hideErrorPopup, isErrorTemporary, setErrorTemporary
-
Methods inherited from interface org.tentackle.fx.FxComponent
getBinding, getBindingPath, getComponentPath, getDelegate, getGenericType, getSavedViewObject, getTableCell, getType, getValueTranslator, getViewObject, getViewValue, isMandatory, isModelUpdated, isSavedViewObjectValid, mandatoryProperty, setBinding, setBindingPath, setComponentPath, setGenericType, setMandatory, setTableCell, setValueTranslator, setViewObject, setViewValue
-
Methods inherited from interface org.tentackle.fx.FxControl
addModelToViewListener, addViewToModelListener, changeableProperty, getHelpUrl, getParentContainer, invalidateSavedView, isBindable, isChangeable, isContainerChangeableIgnored, isViewModified, removeModelToViewListener, removeViewToModelListener, setBindable, setChangeable, setContainerChangableIgnored, setHelpUrl, setViewModified, showHelp, toGenericString, viewModifiedProperty
-
Methods inherited from interface org.tentackle.fx.FxTextComponent
getColumns, mapErrorOffsetToCaretPosition, setColumns
-
Methods inherited from interface org.tentackle.fx.InfoPopupSupported
getInfo, hideInfoPopup, setInfo, showInfoPopup
-
-
-
-
Method Detail
-
getTextComponent
protected FxTextComponent getTextComponent()
Gets the text component.- Returns:
- the text component
-
updateChangeable
protected void updateChangeable(boolean changeable)
Description copied from class:FxControlDelegateUpdates other properties if changeable is bound to something else.- Overrides:
updateChangeablein classFxComponentDelegate- Parameters:
changeable- the flag
-
updateMandatoryStyle
protected void updateMandatoryStyle(boolean mandatory)
Description copied from class:FxComponentDelegateDoes the physical update of the style. See resources/org/tentackle/fx/tentackle.css- Overrides:
updateMandatoryStylein classFxComponentDelegate- Parameters:
mandatory- true if mandatory
-
createChangeableProperty
protected javafx.beans.property.ReadOnlyBooleanWrapper createChangeableProperty(boolean changeable)
Description copied from class:FxControlDelegateCreates the changeable property.- Overrides:
createChangeablePropertyin classFxComponentDelegate- 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- Overrides:
setContainerChangeablein classFxComponentDelegate- Parameters:
containerChangeable- true if container is changeable, false if all components readonly
-
getErrorOffset
public java.lang.Integer getErrorOffset()
Description copied from interface:FxTextComponentGets the error offset.- Specified by:
getErrorOffsetin interfaceFxTextComponent- Returns:
- the offset, null if no offset
-
setErrorOffset
public void setErrorOffset(java.lang.Integer errorOffset)
Description copied from interface:FxTextComponentSets the error offset.- Specified by:
setErrorOffsetin interfaceFxTextComponent- Parameters:
errorOffset- null to clear
-
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- Overrides:
setErrorin classFxComponentDelegate- Parameters:
errorMessage- the error message, null to clear
-
showErrorPopup
public void showErrorPopup()
Description copied from interface:ErrorPopupSupportedShows the error popup.
Requires the error message set.- Specified by:
showErrorPopupin interfaceErrorPopupSupported- Overrides:
showErrorPopupin classFxComponentDelegate
-
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- Overrides:
triggerViewModifiedin classFxComponentDelegate
-
updateView
public void updateView()
Description copied from interface:FxControlUpdates the view according to the model.- Specified by:
updateViewin interfaceFxControl- Overrides:
updateViewin classFxComponentDelegate
-
updateModel
public void updateModel()
Description copied from interface:FxControlUpdates the model according to the view.- Specified by:
updateModelin interfaceFxControl- Overrides:
updateModelin classFxComponentDelegate
-
saveView
public void saveView()
Description copied from interface:FxControlCreates a copy of the value shown to the user.- Specified by:
saveViewin interfaceFxControl- Overrides:
saveViewin classFxComponentDelegate
-
setValidChars
public void setValidChars(java.lang.String validChars)
Description copied from interface:FxTextComponentSets allowed characters.- Specified by:
setValidCharsin interfaceFxTextComponent- Parameters:
validChars- the valid characters, null = all (default)
-
getValidChars
public java.lang.String getValidChars()
Description copied from interface:FxTextComponentGets allowed characters.- Specified by:
getValidCharsin interfaceFxTextComponent- Returns:
- the valid characters, null = all (default)
-
setInvalidChars
public void setInvalidChars(java.lang.String invalidChars)
Description copied from interface:FxTextComponentSets invalid characters.- Specified by:
setInvalidCharsin interfaceFxTextComponent- Parameters:
invalidChars- the invalid characters, null = none (default)
-
getInvalidChars
public java.lang.String getInvalidChars()
Description copied from interface:FxTextComponentGets invalid characters.- Specified by:
getInvalidCharsin interfaceFxTextComponent- Returns:
- the invalid characters, null = none (default)
-
setTextConverter
public void setTextConverter(java.util.function.Function<java.lang.String,java.lang.String> textConverter)
Description copied from interface:FxTextComponentSets a text converter.
Converts input text to the view's text.- Specified by:
setTextConverterin interfaceFxTextComponent- Parameters:
textConverter- the converter
-
getTextConverter
public java.util.function.Function<java.lang.String,java.lang.String> getTextConverter()
Description copied from interface:FxTextComponentGets the text converter.- Specified by:
getTextConverterin interfaceFxTextComponent- Returns:
- the converter
-
apply
public javafx.scene.control.TextFormatter.Change apply(javafx.scene.control.TextFormatter.Change t)
- Specified by:
applyin interfacejava.util.function.Function<javafx.scene.control.TextFormatter.Change,javafx.scene.control.TextFormatter.Change>
-
filter
public java.lang.String filter(java.lang.String text)
Filters input characters.- Parameters:
text- the input text, never null- Returns:
- the filtered text, never null
-
setTextAlignment
public void setTextAlignment(javafx.geometry.Pos textAlignment)
Description copied from interface:FxTextComponentSets the text alignment.- Specified by:
setTextAlignmentin interfaceFxTextComponent- Parameters:
textAlignment- the alignment, null if component's default
-
getTextAlignment
public javafx.geometry.Pos getTextAlignment()
Description copied from interface:FxTextComponentGets the text alignment.- Specified by:
getTextAlignmentin interfaceFxTextComponent- Returns:
- the alignment, null if component's default
-
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- Overrides:
setTypein classFxComponentDelegate- Parameters:
type- the type
-
createValueTranslator
protected ValueTranslator<?,?> createValueTranslator(java.lang.Class<?> type)
-
setMaxColumns
public void setMaxColumns(int maxColumns)
Description copied from interface:FxTextComponentSets the maximum number of columns.
The number of columns will be enforced by the model.- Specified by:
setMaxColumnsin interfaceFxTextComponent- Parameters:
maxColumns- the maximum number of columns, 0 if unlimited (default)
-
getMaxColumns
public int getMaxColumns()
Description copied from interface:FxTextComponentGets the maximum number of columns.- Specified by:
getMaxColumnsin interfaceFxTextComponent- Returns:
- the maximum number of columns, 0 if unlimited (default)
-
setAutoSelect
public void setAutoSelect(boolean autoSelect)
Description copied from interface:FxTextComponentSets the auto-select feature.
A component with autoselect enabled will automatically select all characters if the component gets the keyboard focus. Useful for numerical fields, for example.- Specified by:
setAutoSelectin interfaceFxTextComponent- Parameters:
autoSelect- true if autoselect enabled, false if disabled (default)
-
isAutoSelect
public boolean isAutoSelect()
Description copied from interface:FxTextComponentReturns whether the auto-select feature is enabled.- Specified by:
isAutoSelectin interfaceFxTextComponent- Returns:
- true if autoselect enabled, false if disabled (default)
-
setPattern
public void setPattern(java.lang.String pattern)
Description copied from interface:FxTextComponentSets the format pattern.
The format pattern is used to format the view of the data.- Specified by:
setPatternin interfaceFxTextComponent- Parameters:
pattern- the format pattern
-
getPattern
public java.lang.String getPattern()
Description copied from interface:FxTextComponentGets the format pattern.- Specified by:
getPatternin interfaceFxTextComponent- Returns:
- the format pattern
-
isLenient
public boolean isLenient()
Description copied from interface:FxTextComponentReturns whether parsing to model should be lenient.- Specified by:
isLenientin interfaceFxTextComponent- Returns:
- true if lenient, false is default
-
setLenient
public void setLenient(boolean lenient)
Description copied from interface:FxTextComponentSets whether parsing to model should be lenient.- Specified by:
setLenientin interfaceFxTextComponent- Parameters:
lenient- true if lenient
-
setScale
public void setScale(int scale)
Description copied from interface:FxTextComponentChanges the format according to the given scale.- Specified by:
setScalein interfaceFxTextComponent- Parameters:
scale- the number of digits after the comma
-
getScale
public int getScale()
Description copied from interface:FxTextComponentGets the current scale.- Specified by:
getScalein interfaceFxTextComponent- Returns:
- the scale
-
isUnsigned
public boolean isUnsigned()
Description copied from interface:FxTextComponentReturns whether a numeric field is unsigned or signed.- Specified by:
isUnsignedin interfaceFxTextComponent- Returns:
- true if unsigned
-
setUnsigned
public void setUnsigned(boolean unsigned)
Description copied from interface:FxTextComponentSets whether a numeric field is unsigned or signed.- Specified by:
setUnsignedin interfaceFxTextComponent- Parameters:
unsigned- true if unsigned
-
isUTC
public boolean isUTC()
Description copied from interface:FxTextComponentReturns whether this is a UTC timestamp.- Specified by:
isUTCin interfaceFxTextComponent- Returns:
- true if UTC
-
setUTC
public void setUTC(boolean utc)
Description copied from interface:FxTextComponentSets whether this is a UTC timestamp.- Specified by:
setUTCin interfaceFxTextComponent- Parameters:
utc- true if UTC
-
setCaseConversion
public void setCaseConversion(CaseConversion caseConversion)
Description copied from interface:FxTextComponentSets the case conversion.- Specified by:
setCaseConversionin interfaceFxTextComponent- Parameters:
caseConversion- the conversion, null if no conversion (default)
-
getCaseConversion
public CaseConversion getCaseConversion()
Description copied from interface:FxTextComponentGets the case conversion.- Specified by:
getCaseConversionin interfaceFxTextComponent- Returns:
- the conversion, null if no conversion (default)
-
setFiller
public void setFiller(char filler)
Description copied from interface:FxTextComponentSets the filler character.
The default is space.- Specified by:
setFillerin interfaceFxTextComponent- Parameters:
filler- the filler
-
getFiller
public char getFiller()
Description copied from interface:FxTextComponentGets the filler character.- Specified by:
getFillerin interfaceFxTextComponent- Returns:
- the filler
-
autoSelect
public void autoSelect()
Description copied from interface:FxTextComponentSelects or deselects all text in the text input.- Specified by:
autoSelectin interfaceFxTextComponent- See Also:
FxTextComponent.isAutoSelect()
-
-