Package org.vaadin.miki.superfields.util
Class CollectionComponentProviders
java.lang.Object
org.vaadin.miki.superfields.util.CollectionComponentProviders
Utility class with common (hopefully) use-cases of
CollectionComponentProvider and subclasses.- Since:
- 2021-09-04
- Author:
- miki
-
Method Summary
Modifier and TypeMethodDescriptionstatic CollectionComponentProvider<com.vaadin.flow.component.button.Button>addFirstButton(String text) ACollectionComponentProviderthat produces aButtonthat adds an element to the collection by callingCollectionController.add(int)with0as parameter.static CollectionComponentProvider<com.vaadin.flow.component.button.Button>addLastButton(String text) ACollectionComponentProviderthat produces aButtonthat adds an element to the collection by callingCollectionController.add().static CollectionLayoutProvider<HeaderFooterLayoutWrapper<com.vaadin.flow.component.orderedlayout.FlexLayout,com.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> columnWithHeaderAndFooterRows(Collection<CollectionComponentProvider<?>> headerComponents, Collection<CollectionComponentProvider<?>> footerComponents) static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, T>>
CollectionValueComponentProvider<T,HeaderFooterFieldWrapper<T, com.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> columnWithHeaderAndFooterRows(CollectionValueComponentProvider<T, F> inner, Collection<CollectionComponentProvider<?>> headerComponents, Collection<CollectionComponentProvider<?>> footerComponents) ACollectionValueComponentProviderfor a column-basedHeaderFooterFieldWrapperwhere header and footer are row-basedFlexLayouts.static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, T> & com.vaadin.flow.component.HasLabel>
CollectionValueComponentProvider<T,F> labelledField(Supplier<F> fieldSupplier, String label) Returns aCollectionValueComponentProviderthat generates a given field and sets its label.static <K,V, C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, K>, W extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, V>>
CollectionValueComponentProvider<Map.Entry<K,V>, MapEntryField<K, V>> mapEntryField(com.vaadin.flow.function.SerializableSupplier<C> keyComponentSupplier, com.vaadin.flow.function.SerializableSupplier<W> valueComponentSupplier) ACollectionValueComponentProviderthat produces aMapEntryFieldwith given key and value suppliers.static <K,V, C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasLabel & com.vaadin.flow.component.HasValue<?, K>, W extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasLabel & com.vaadin.flow.component.HasValue<?, V>>
CollectionValueComponentProvider<Map.Entry<K,V>, MapEntryField<K, V>> mapEntryField(String keyLabel, com.vaadin.flow.function.SerializableSupplier<C> keyComponentSupplier, String valueLabel, com.vaadin.flow.function.SerializableSupplier<W> valueComponentSupplier) ACollectionValueComponentProviderthat produces aMapEntryFieldwith given key and value suppliers, but also sets labels to both produced components..static CollectionComponentProvider<com.vaadin.flow.component.button.Button>removeAllButton(String text) ACollectionComponentProviderthat produces aButtonthat clears the collection by callingCollectionController.removeAll().removeButton(String text) ACollectionComponentProviderthat produces anIndexedButtonthat removes a given element from the collection by callingCollectionController.remove(int).static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, T>>
CollectionValueComponentProvider<T,HeaderFooterFieldWrapper<T, com.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> row(CollectionValueComponentProvider<T, F> inner, Collection<CollectionComponentProvider<?>> headerComponents, Collection<CollectionComponentProvider<?>> footerComponents) ACollectionValueComponentProviderthat wraps given field with a layout containing header and footer.static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, T>>
CollectionValueComponentProvider<T,HeaderFooterFieldWrapper<T, com.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> rowWithRemoveButtonFirst(CollectionValueComponentProvider<T, F> inner, String removeButtonText) ACollectionValueComponentProviderthat wraps given field with a layout containing a header and footer.static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, T>>
CollectionValueComponentProvider<T,HeaderFooterFieldWrapper<T, com.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> rowWithRemoveButtonLast(CollectionValueComponentProvider<T, F> inner, String removeButtonText) ACollectionValueComponentProviderthat wraps given field with a layout containing a header and footer.static SuperTextAreatextArea(int index, CollectionController controller) Produces plain text area.static SuperTextFieldtextField(int index, CollectionController controller) Produces plain text field.
-
Method Details
-
textField
Produces plain text field. Method signature followsCollectionValueComponentProvider.- Parameters:
index- Index.controller- Controller.- Returns:
- A
SuperTextField.
-
textArea
Produces plain text area. Method signature followsCollectionValueComponentProvider.- Parameters:
index- Index.controller- Controller.- Returns:
- A
SuperTextArea.
-
labelledField
public static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, CollectionValueComponentProvider<T,T> & com.vaadin.flow.component.HasLabel> F> labelledField(Supplier<F> fieldSupplier, String label) Returns aCollectionValueComponentProviderthat generates a given field and sets its label.- Type Parameters:
T- Type of data.F- Type of component to display the data.- Parameters:
fieldSupplier- Field supplier.label- Label to use.String.format(label, index)will be applied, so any%dwill be replaced with an index.- Returns:
- A
CollectionValueComponentProviderthat generates given field and sets its label.
-
row
public static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, CollectionValueComponentProvider<T,T>> HeaderFooterFieldWrapper<T, rowcom.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> (CollectionValueComponentProvider<T, F> inner, Collection<CollectionComponentProvider<?>> headerComponents, Collection<CollectionComponentProvider<?>> footerComponents) ACollectionValueComponentProviderthat wraps given field with a layout containing header and footer. The wrapper is row-aligned, with header and footer being column-based. None of the parameters may ever benull.- Type Parameters:
T- Type of the value.F- Type of the field used to show the value.- Parameters:
inner- Inner field generator.headerComponents- A collection of generators for components to appear in the header.footerComponents- A collection of generators for components to appear in the footer.- Returns:
- A
CollectionValueComponentProviderthat generates aHeaderFooterFieldWrapperwith a given field, header and footer.
-
rowWithRemoveButtonLast
public static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, CollectionValueComponentProvider<T,T>> HeaderFooterFieldWrapper<T, rowWithRemoveButtonLastcom.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> (CollectionValueComponentProvider<T, F> inner, String removeButtonText) ACollectionValueComponentProviderthat wraps given field with a layout containing a header and footer. The footer contains a button that removes the entry from the collection.- Type Parameters:
T- Type of the value.F- Type of the field used to show the value.- Parameters:
inner- Inner field generator.removeButtonText- Text to appear on the button.- Returns:
- A
CollectionValueComponentProviderthat generates aHeaderFooterFieldWrapperwith a given field, header and footer (with a button).
-
rowWithRemoveButtonFirst
public static <T,F extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, CollectionValueComponentProvider<T,T>> HeaderFooterFieldWrapper<T, rowWithRemoveButtonFirstcom.vaadin.flow.component.orderedlayout.FlexLayout, com.vaadin.flow.component.orderedlayout.FlexLayout>> (CollectionValueComponentProvider<T, F> inner, String removeButtonText) ACollectionValueComponentProviderthat wraps given field with a layout containing a header and footer. The header contains a button that removes the entry from the collection.- Type Parameters:
T- Type of the value.F- Type of the field used to show the value.- Parameters:
inner- Inner field generator.removeButtonText- Text to appear on the button.- Returns:
- A
CollectionValueComponentProviderthat generates aHeaderFooterFieldWrapperwith a given field, header (with a button) and a footer.
-
removeAllButton
public static CollectionComponentProvider<com.vaadin.flow.component.button.Button> removeAllButton(String text) ACollectionComponentProviderthat produces aButtonthat clears the collection by callingCollectionController.removeAll().- Parameters:
text- Text to appear on the button.- Returns:
- A
CollectionComponentProviderthat produces aButton.
-
addFirstButton
public static CollectionComponentProvider<com.vaadin.flow.component.button.Button> addFirstButton(String text) ACollectionComponentProviderthat produces aButtonthat adds an element to the collection by callingCollectionController.add(int)with0as parameter.- Parameters:
text- Text to appear on the button.- Returns:
- A
CollectionComponentProviderthat produces aButton.
-
addLastButton
public static CollectionComponentProvider<com.vaadin.flow.component.button.Button> addLastButton(String text) ACollectionComponentProviderthat produces aButtonthat adds an element to the collection by callingCollectionController.add().- Parameters:
text- Text to appear on the button.- Returns:
- A
CollectionComponentProviderthat produces aButton.
-
removeButton
ACollectionComponentProviderthat produces anIndexedButtonthat removes a given element from the collection by callingCollectionController.remove(int).- Parameters:
text- Text to appear on the button.- Returns:
- A
CollectionComponentProviderthat produces aButton.
-
mapEntryField
public static <K,V, CollectionValueComponentProvider<Map.Entry<K,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, K>, W extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?, V>> V>, mapEntryFieldMapEntryField<K, V>> (com.vaadin.flow.function.SerializableSupplier<C> keyComponentSupplier, com.vaadin.flow.function.SerializableSupplier<W> valueComponentSupplier) ACollectionValueComponentProviderthat produces aMapEntryFieldwith given key and value suppliers.- Type Parameters:
K- Key type.V- Value type.C- Ensures key component supplier is aComponentthatHasValueof typeK.W- Ensures value component supplier is aComponentthatHasValueof typeV.- Parameters:
keyComponentSupplier- Supplier of components capable of displaying keys.valueComponentSupplier- Supplier of components capable of displaying values.- Returns:
- A
CollectionValueComponentProviderofMapEntryFields.
-
mapEntryField
public static <K,V, CollectionValueComponentProvider<Map.Entry<K,C extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasLabel & com.vaadin.flow.component.HasValue<?, K>, W extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasLabel & com.vaadin.flow.component.HasValue<?, V>> V>, mapEntryFieldMapEntryField<K, V>> (String keyLabel, com.vaadin.flow.function.SerializableSupplier<C> keyComponentSupplier, String valueLabel, com.vaadin.flow.function.SerializableSupplier<W> valueComponentSupplier) ACollectionValueComponentProviderthat produces aMapEntryFieldwith given key and value suppliers, but also sets labels to both produced components..- Type Parameters:
K- Key type.V- Value type.C- Ensures key component supplier is aComponentthatHasLabelandHasValueof typeK.W- Ensures value component supplier is aComponentthatHasLabelandHasValueof typeV.- Parameters:
keyLabel- Label for the key component. It is applied as is.keyComponentSupplier- Supplier of components capable of displaying keys.valueLabel- Label for the value component. It is applied as is.valueComponentSupplier- Supplier of components capable of displaying values.- Returns:
- A
CollectionValueComponentProviderofMapEntryFields.
-