Package com.storedobject.ui
Class AbstractObjectField<T extends StoredObject>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T>,T>
com.vaadin.flow.component.customfield.CustomField<T>
com.storedobject.vaadin.CustomField<T>
com.storedobject.ui.AbstractObjectField<T>
- Type Parameters:
T- Type of object instance accepted.
- All Implemented Interfaces:
FilterMethods<T>,ObjectGetter<T>,ObjectSetter<T>,ObjectInput<T>,ObjectProvider<T>,AbstractObjectInput<T>,HasElement,HasThemeStyle,ValueRequired,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasPlaceholder,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> Serializable,Consumer<T>
- Direct Known Subclasses:
FileField,ObjectGetField,ObjectSearchField
public abstract class AbstractObjectField<T extends StoredObject>
extends CustomField<T>
implements ObjectInput<T>, ValueRequired
The base field for accepting a
StoredObject instance. (This is the base for a couple of fields that
accept object instances).- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called whenever a filter condition is changed.voidclear()Clear the field value.protected final ObjectBrowser<T> Create the default searcher.protected abstract com.vaadin.flow.component.Componentprotected ObjectBrowser<T> Get the searcher for this field.protected voiddoSearch()Do a search using the searcher component.protected ObjectEditor<T> editor()Return theObjectEditorassociated with this.protected TCheck a given value to see if it satisfies the filter condition of the searcher.protected ObjectIterator<T> filteredList(ObjectIterator<T> list) Check a given set of values to see if they satisfy the filter condition of the searcher.Get browse columns of the searcher.final TGet the currently cached object.protected ButtonLayoutThis is where the content of the field display is created.com.vaadin.flow.component.ComponentGet the component that is currently displaying details of the object value.Get the consumer that is currently consuming details of the object value.Get the internal label of this field.Get the load filter.Class of the object supported in this input field.com.vaadin.flow.component.ComponentGet search columns.final ObjectBrowser<T> Get the searcher for this field.protected ButtonLayoutThis is where the display parts of the field is initialized.final booleanWhether this field allows any derived object values or not.booleanbooleanGet the value required flag.voidload(ObjectIterator<T> objects) Load allowed values from a list.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidreget()Check the current value to see if it is satisfying the filter condition of the searcher or not.voidreload()Reload the allowed values by applying newly set filters.voidsetBrowseColumns(StringList browseColumns) Set browse columns of the searcher.final voidCache an object instance.voidsetDetailComponent(com.vaadin.flow.component.Component detailComponent) Set a component that will display details of the object value.voidsetDisplayDetail(Consumer<T> displayDetail) Set a consumer that can display/consume the details of the object value.voidsetEnabled(boolean enabled) Enable/disable this field.voidsetInternalLabel(String label) Set the internal label for this field.voidsetItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Set an "item label generator" that returns the string value of the object value of this field.voidsetPrefixFieldControl(boolean prefixFieldControl) Decide whether "prefix components" needs to be controlled by this field or not.protected voidsetPresentationValue(T value) voidsetReadOnly(boolean readOnly) Make this field read-only.voidsetRequired(boolean required) Set value required flag.voidsetSearchColumns(StringList searchColumns) Set search columns.Methods inherited from class com.storedobject.vaadin.CustomField
addField, addField, focusMethods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, generateModelValue, getLabel, remove, removeThemeVariants, setLabel, updateValueMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.ui.util.AbstractObjectInput
applyFilterPredicate, convert, focus, getObject, getObjectId, getObjectId, setObjectMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.storedobject.core.FilterMethods
getEffectiveCondition, getFilterCondition, setFilter, setFilter, setFilter, setFilter, setFilter, setFilter, setLoadFilter, setLoadFilter, setViewFilter, setViewFilterMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.storedobject.vaadin.HasElement
getAttribute, getStyle, setAttribute, setStyleMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasLabel
getLabel, setLabelMethods inherited from interface com.vaadin.flow.component.HasPlaceholder
getPlaceholder, setPlaceholderMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.storedobject.vaadin.HasThemeStyle
addTheme, asPrimary, asSmall, clearThemes, getInternalElement, removeTheme, setThemeMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, getEmptyValue, getOptionalValue, getValue, isEmpty, setValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setRequiredIndicatorVisibleMethods inherited from interface com.storedobject.ui.ObjectInput
getObject, getValue, setObject, setObjectClass, setValue, setValueMethods inherited from interface com.storedobject.core.ObjectSetter
accept
-
Constructor Details
-
AbstractObjectField
-
-
Method Details
-
initComponent
This is where the display parts of the field is initialized. If overridden, you need to make sure to always return the same component between calls.- Returns:
- The layout component containing other display components.
-
clear
public void clear()Description copied from interface:AbstractObjectInputClear the field value.- Specified by:
clearin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
clearin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject>
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
getContent
This is where the content of the field display is created. The default implementation invokesinitComponent()and stuffs the return value into the layout. If overridden, you need to make sure to always return the same component between calls.- Returns:
- Content part of the field.
-
setInternalLabel
Description copied from interface:ObjectInputSet the internal label for this field. Internal labels are used by the embedded field within this field.- Specified by:
setInternalLabelin interfaceObjectInput<T extends StoredObject>- Parameters:
label- Label.
-
getInternalLabel
Description copied from interface:ObjectInputGet the internal label of this field. Internal labels are used by the embedded field within this field.- Specified by:
getInternalLabelin interfaceObjectInput<T extends StoredObject>- Returns:
- Label.
-
getCached
Description copied from interface:AbstractObjectInputGet the currently cached object.- Specified by:
getCachedin interfaceAbstractObjectInput<T extends StoredObject>- Returns:
- Object that is currently cached. It may return
null.
-
setCached
Description copied from interface:AbstractObjectInputCache an object instance. Default implementation doesn't do anything but a field may cache it and re-used for eliminating unwanted database access.- Specified by:
setCachedin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
cached- Object to be cached.
-
createPrefixComponent
protected abstract com.vaadin.flow.component.Component createPrefixComponent() -
getObjectClass
Description copied from interface:AbstractObjectInputClass of the object supported in this input field.- Specified by:
getObjectClassin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
getObjectClassin interfaceObjectGetter<T extends StoredObject>- Specified by:
getObjectClassin interfaceObjectProvider<T extends StoredObject>- Specified by:
getObjectClassin interfaceObjectSetter<T extends StoredObject>- Returns:
- Class of the supported object.
-
isAllowAny
public final boolean isAllowAny()Description copied from interface:AbstractObjectInputWhether this field allows any derived object values or not.- Specified by:
isAllowAnyin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
isAllowAnyin interfaceObjectGetter<T extends StoredObject>- Specified by:
isAllowAnyin interfaceObjectSetter<T extends StoredObject>- Returns:
- True or false.
-
getPrefixComponent
public com.vaadin.flow.component.Component getPrefixComponent() -
filter
-
filteredList
Check a given set of values to see if they satisfy the filter condition of the searcher.- Parameters:
list- Values to check.- Returns:
- The list of values that satisfy the filter condition.
-
reget
protected void reget()Check the current value to see if it is satisfying the filter condition of the searcher or not. -
getLoadFilter
Description copied from interface:FilterMethodsGet the load filter.- Specified by:
getLoadFilterin interfaceFilterMethods<T extends StoredObject>- Returns:
- Current load filter.
-
applyFilter
public void applyFilter()Description copied from interface:FilterMethodsThis method is called whenever a filter condition is changed. Methods with default implementation already invoke this method. If any of those methods are overridden, make sure that it invokes this method so that logic to handle filter changes can be coded here.- Specified by:
applyFilterin interfaceFilterMethods<T extends StoredObject>
-
doSearch
protected void doSearch()Do a search using the searcher component. -
getSearcher
Get the searcher for this field. If you want to return a customized searcher, overridecreateSearcher().- Specified by:
getSearcherin interfaceObjectInput<T extends StoredObject>- Returns:
- Typically, an instance of the
ObjectBrowserthat has search capability.
-
createDefaultSearcher
Create the default searcher.- Returns:
- Searcher (which is an
ObjectBrowser).
-
editor
Return theObjectEditorassociated with this. This will be invoked when the searcher is set and the editor will be checked for additional filter conditions.- Returns:
- Editor instance is available.
-
load
Description copied from interface:ObjectInputLoad allowed values from a list. Once invoked, only this list will be used for showing the allowed objects that can be selected via this field.- Specified by:
loadin interfaceObjectInput<T extends StoredObject>- Parameters:
objects- Objects to load.
-
createSearcher
Get the searcher for this field.- Returns:
- Typically, an instance of the
ObjectBrowserthat has search capability.
-
setDetailComponent
public void setDetailComponent(com.vaadin.flow.component.Component detailComponent) Description copied from interface:AbstractObjectInputSet a component that will display details of the object value.- Specified by:
setDetailComponentin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
detailComponent- A component that can display information regarding the object.
-
getDetailComponent
public com.vaadin.flow.component.Component getDetailComponent()Description copied from interface:AbstractObjectInputGet the component that is currently displaying details of the object value.- Specified by:
getDetailComponentin interfaceAbstractObjectInput<T extends StoredObject>- Returns:
- Component that is displaying the details.
-
setDisplayDetail
Description copied from interface:AbstractObjectInputSet a consumer that can display/consume the details of the object value.- Specified by:
setDisplayDetailin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
displayDetail- A consumer that can accept the object value.
-
getDisplayDetail
Description copied from interface:AbstractObjectInputGet the consumer that is currently consuming details of the object value.- Specified by:
getDisplayDetailin interfaceAbstractObjectInput<T extends StoredObject>- Returns:
- Consumer that is currently set.
-
setPresentationValue
- Specified by:
setPresentationValuein classcom.vaadin.flow.component.customfield.CustomField<T extends StoredObject>
-
setItemLabelGenerator
public void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Description copied from interface:AbstractObjectInputSet an "item label generator" that returns the string value of the object value of this field. (It is mainly used to display the object).- Specified by:
setItemLabelGeneratorin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
itemLabelGenerator- Item value generator.
-
setPrefixFieldControl
public void setPrefixFieldControl(boolean prefixFieldControl) Description copied from interface:AbstractObjectInputDecide whether "prefix components" needs to be controlled by this field or not. "Prefix components" are parts of the field that display extra information, and it needs to be turned on or off when the status of the field changes via methods such asAbstractObjectInput.setEnabled(boolean),AbstractObjectInput.setReadOnly(boolean)etc. In some cases, prefix components may be displayed elsewhere and needs to be controlled outside the field.- Specified by:
setPrefixFieldControlin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
prefixFieldControl- True if it needs to be controlled by this field.
-
setReadOnly
public void setReadOnly(boolean readOnly) Description copied from interface:AbstractObjectInputMake this field read-only.- Specified by:
setReadOnlyin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject> - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject> - Parameters:
readOnly- True to set as read-only.
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:AbstractObjectInputEnable/disable this field.- Specified by:
setEnabledin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled- Parameters:
enabled- True for enabling.
-
isRequired
public boolean isRequired()Description copied from interface:ValueRequiredGet the value required flag.- Specified by:
isRequiredin interfaceValueRequired- Returns:
- Whether required or not.
-
setRequired
public void setRequired(boolean required) Description copied from interface:ValueRequiredSet value required flag.- Specified by:
setRequiredin interfaceValueRequired- Parameters:
required- Required or not
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation- Specified by:
isInvalidin interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
reload
public void reload()Description copied from interface:ObjectInputReload the allowed values by applying newly set filters.- Specified by:
reloadin interfaceObjectInput<T extends StoredObject>
-
setBrowseColumns
Set browse columns of the searcher.- Parameters:
browseColumns- Browse columns.
-
getBrowseColumns
Get browse columns of the searcher. Used bycreateDefaultSearcher().- Returns:
- Browse columns of the searcher.
-
setSearchColumns
Set search columns.- Parameters:
searchColumns- Search columns of the searcher's browser.
-
getSearchColumns
Get search columns. Used bycreateDefaultSearcher().- Returns:
- Search columns of the searcher's browser.
-