C - Component to display for each option.T - Type of the field.I - Type of item.SELF - Self type.public abstract class AbstractComponentSelect<C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.ClickNotifier<C>,T,I,SELF extends AbstractComponentSelect<C,T,I,SELF>> extends com.vaadin.flow.component.customfield.CustomField<T> implements com.vaadin.flow.component.HasStyle, WithItemsMixin<I,SELF>, WithIdMixin<SELF>, WithLabelMixin<SELF>, WithLabelPositionableMixin<SELF>, WithHelperMixin<SELF>, WithHelperPositionableMixin<SELF>, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T,SELF>
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>| Modifier and Type | Field and Description |
|---|---|
static int |
NO_SELECTION
Index for no selection.
|
LABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTEHELPER_ABOVE_THEME_VARIANT| Modifier | Constructor and Description |
|---|---|
protected |
AbstractComponentSelect(T defaultValue,
Supplier<L> layoutSupplier,
com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> componentFactory,
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> selectionModifier,
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> deselectionModifier,
I... options)
Creates the select with given options.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
deselect(int index)
Deselects component at the given index.
|
protected void |
ensureValidIndex(int index)
Ensures the index is within bounds.
|
void |
focus() |
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> |
getComponentDeselectedAction()
Returns the action that is currently performed when a component gets deselected.
|
com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> |
getComponentFactory()
Returns the current component factory.
|
protected int |
getComponentIndex(C component)
Returns the index of the given component.
|
com.vaadin.flow.function.SerializableBiConsumer<Integer,C> |
getComponentSelectedAction()
Returns the action that is currently performed when a component gets selected.
|
protected List<I> |
getOptions()
Returns the current list of options.
|
protected abstract boolean |
isSelected(int index)
Checks if the item at the given index is currently selected.
|
protected abstract boolean |
itemClicked(int index)
Clicks an item at the given index.
|
protected static <X,Y> com.vaadin.flow.function.SerializableBiConsumer<X,Y> |
noOp()
A no-op, default do-nothing operation for selection/deselection.
|
protected void |
rebuildComponents()
Rebuilds the components - removes the existing ones then calls the factory to produce new ones.
|
protected void |
select(int index)
Selects component at the given index.
|
void |
setComponentDeselectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
Sets the action to be performed on a deselected component.
|
void |
setComponentFactory(com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> factory)
Sets the factory that will be used to create new components.
|
void |
setComponentSelectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
Sets the action to be performed on a selected component.
|
void |
setItems(Collection<I> items) |
SELF |
withComponentDeselectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
Chains
setComponentDeselectedAction(SerializableBiConsumer) and returns itself. |
SELF |
withComponentFactory(com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> factory)
Chains
setComponentFactory(SerializableBiFunction) and returns itself. |
SELF |
withComponentSelectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
Chains
setComponentSelectedAction(SerializableBiConsumer) and returns itself. |
add, generateModelValue, getErrorMessage, getLabel, isInvalid, remove, setErrorMessage, setInvalid, setLabel, setPresentationValue, updateValueaddValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNamewithItems, withItems, withItemswithIdwithLabelwithLabelPositiongetLabelPosition, setLabelPositionwithHelperComponent, withHelperTextgetHelperComponent, getHelperText, setHelperComponent, setHelperTextwithHelperAbove, withHelperAbove, withHelperBelowisHelperAbove, setHelperAbove, setHelperAbove, setHelperBelowwithValueaddValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setValuegetCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFulladdFocusShortcut, blur, getTabIndex, setTabIndexpublic static final int NO_SELECTION
@SafeVarargs protected AbstractComponentSelect(T defaultValue, Supplier<L> layoutSupplier, com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> componentFactory, com.vaadin.flow.function.SerializableBiConsumer<Integer,C> selectionModifier, com.vaadin.flow.function.SerializableBiConsumer<Integer,C> deselectionModifier, I... options)
L - Layout type.layoutSupplier - Provides layout for the component.componentFactory - A function that creates components for the options.selectionModifier - Action to perform on a component when it is selected.deselectionModifier - Action to perform on a component when it is deselected.options - Items to select from.protected static <X,Y> com.vaadin.flow.function.SerializableBiConsumer<X,Y> noOp()
X - First argument type.Y - Second argument type.protected abstract boolean isSelected(int index)
index - Index of an item.true when the item is selected, false otherwise.protected abstract boolean itemClicked(int index)
index - Index of an item to be clicked.protected void deselect(int index)
index - Index of a component to deselect.protected void select(int index)
index - Index of a component to select.protected final void rebuildComponents()
protected List<I> getOptions()
null, but possibly empty.protected final int getComponentIndex(C component)
component - Component to find.NO_SELECTION.protected void ensureValidIndex(int index)
index - Index to check.IllegalArgumentException - when the index is outside the allowed bounds.public final void setComponentFactory(com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> factory)
factory - Factory. Must not be null.public com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> getComponentFactory()
null.public final SELF withComponentFactory(com.vaadin.flow.function.SerializableBiFunction<Integer,I,C> factory)
setComponentFactory(SerializableBiFunction) and returns itself.factory - Factory. Must not be null.setComponentFactory(SerializableBiFunction)public final void setComponentSelectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
action - Action to use. If null is passed, result of noOp() will be used instead.public com.vaadin.flow.function.SerializableBiConsumer<Integer,C> getComponentSelectedAction()
null.public final SELF withComponentSelectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
setComponentSelectedAction(SerializableBiConsumer) and returns itself.action - Action.setComponentSelectedAction(SerializableBiConsumer)public final void setComponentDeselectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
action - Action to use. If null is passed, result of noOp() will be used instead.public com.vaadin.flow.function.SerializableBiConsumer<Integer,C> getComponentDeselectedAction()
null.public final SELF withComponentDeselectedAction(com.vaadin.flow.function.SerializableBiConsumer<Integer,C> action)
setComponentDeselectedAction(SerializableBiConsumer) and returns itself.action - Action.public void setItems(Collection<I> items)
setItems in interface com.vaadin.flow.data.binder.HasItems<I>public void focus()
focus in interface com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>Copyright © 2023 Miki. All rights reserved.