T - Type of value.@Tag(value="super-tabs")
@CssImport(value="./styles/super-tabs-multiline.css",
themeFor="vaadin-tabs")
public class SuperTabs<T>
extends com.vaadin.flow.component.customfield.CustomField<T>
implements com.vaadin.flow.component.HasStyle, WithItemsMixin<T,SuperTabs<T>>, WithIdMixin<SuperTabs<T>>, WithHelperMixin<SuperTabs<T>>, WithHelperPositionableMixin<SuperTabs<T>>, WithLabelMixin<SuperTabs<T>>, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T,SuperTabs<T>>
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 Supplier<com.vaadin.flow.component.html.Div> |
DEFAULT_TAB_CONTENTS_CONTAINER
Default container for tab contents.
|
static String |
MULTILINE_THEME_NAME
Name of the theme for multiline tabs.
|
HELPER_ABOVE_THEME_VARIANT| Constructor and Description |
|---|
SuperTabs()
Creates the component with no tabs and default
TabHandler, TabHeaderGenerator and TabContentGenerator. |
SuperTabs(Supplier<C> mainContentSupplier,
T... values)
Creates the component with no tabs and default
TabHandler, TabHeaderGenerator and TabContentGenerator, overriding default main layout component for the tab contents. |
SuperTabs(TabContentGenerator<T> tabContentGenerator,
T... values)
Creates the component with given
TabContentGenerator and tabs, but with default TabHeaderGenerator and TabHandler. |
SuperTabs(TabHeaderGenerator<T> tabHeaderGenerator,
TabContentGenerator<T> tabContentGenerator,
T... values)
Creates the component with given
TabHeaderGenerator, TabContentGenerator and tabs, but default TabHandler. |
SuperTabs(T defaultValue,
Supplier<C> mainContentSupplier,
TabHandler tabHandler,
TabHeaderGenerator<T> tabHeaderGenerator,
TabContentGenerator<T> tabContentGenerator,
T... values)
Creates the component with given
TabHandler, TabHeaderGenerator, TabContentGenerator and tabs, overriding the default value from null to the one provided and overriding default layout component for tab contents. |
SuperTabs(T defaultValue,
TabHandler tabHandler,
TabHeaderGenerator<T> tabHeaderGenerator,
TabContentGenerator<T> tabContentGenerator,
T... values)
Creates the component with given
TabHandler, TabHeaderGenerator, TabContentGenerator and tabs, overriding the default value from null to the one provided. |
SuperTabs(T defaultValue,
TabHeaderGenerator<T> tabHeaderGenerator,
TabContentGenerator<T> tabContentGenerator,
T... values)
Creates the component with default
TabHandler, given TabHeaderGenerator, TabContentGenerator and tabs, overriding the default value from null to the one provided. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addNewTab(T value,
boolean select)
Adds a new tab and content for given value, using
getTabHeaderGenerator() and getTabContentGenerator() to produce components. |
protected void |
addNewTab(T value,
com.vaadin.flow.component.tabs.Tab tab,
com.vaadin.flow.component.Component content,
boolean select)
Adds a new tab and content for given value.
|
void |
addTab(T... values)
This method adds one or more tabs.
|
void |
addTab(T value,
com.vaadin.flow.component.tabs.Tab tabHeader,
com.vaadin.flow.component.Component tabContents)
Adds a tab for a given value.
|
void |
addTabs(Collection<T> values)
Adds a tab for each of the given values.
|
protected T |
generateModelValue() |
TabContentGenerator<T> |
getTabContentGenerator()
Returns the generator responsible for providing content for selected tabs.
|
Optional<com.vaadin.flow.component.Component> |
getTabContents(T value)
Returns contents that corresponds to the given value.
|
TabHandler |
getTabHandler()
Returns the current
TabHandler. |
Optional<com.vaadin.flow.component.tabs.Tab> |
getTabHeader(T value)
Returns tab header that corresponds to the given value.
|
TabHeaderGenerator<T> |
getTabHeaderGenerator()
Returns the generator responsible for providing tabs (headers) for values.
|
protected Optional<Map.Entry<T,com.vaadin.flow.component.tabs.Tab>> |
getValueAndTab(T value)
Finds the value and tab entry corresponding to the given
value. |
List<T> |
getValues()
Returns the values that correspond to tabs.
|
boolean |
isCustomValueAllowed()
Whether or not custom values may be set through
AbstractField.setValue(Object). |
boolean |
isMultiline()
Checks whether tabs wrap to a new line.
|
protected void |
removeExistingTab(T value,
com.vaadin.flow.component.tabs.Tab header)
Removes an existing tab, its header and contents.
|
void |
removeTab(T value)
Removes the tab for a given value, if found.
|
void |
setCustomValueAllowed(boolean customValueAllowed)
Allows or disallows creating new tabs when calling
AbstractField.setValue(Object). |
void |
setId(String id)
Sets this object's id.
|
void |
setItems(Collection<T> collection) |
void |
setMultiline(boolean multiline)
Sets whether or not tabs should overflow to next line.
|
protected void |
setPresentationValue(T t) |
void |
setTabContentGenerator(TabContentGenerator<T> tabContentGenerator)
Sets the generator responsible for providing content for selected tabs.
|
void |
setTabHandler(TabHandler tabHandler)
Sets the new
TabHandler to use. |
void |
setTabHeaderGenerator(TabHeaderGenerator<T> tabHeaderGenerator)
Sets the generator responsible for providing tabs (headers) for values.
|
int |
size()
Returns the number of values that currently correspond to tabs.
|
SuperTabs<T> |
withCustomValueAllowed(boolean customValueAllowed)
Chains
setCustomValueAllowed(boolean) and returns itself. |
SuperTabs<T> |
withMultiline(boolean multiline)
Chains
setMultiline(boolean) and returns itself. |
SuperTabs<T> |
withTabContentGenerator(TabContentGenerator<T> tabContentGenerator)
Chains
setTabContentGenerator(TabContentGenerator) and returns itself. |
SuperTabs<T> |
withTabHandler(TabHandler tabHandler)
Chains
setTabHandler(TabHandler) and returns itself. |
SuperTabs<T> |
withTabHeaderGenerator(TabHeaderGenerator<T> tabHeaderGenerator)
Chains
setTabHeaderGenerator(TabHeaderGenerator) and returns itself. |
add, getErrorMessage, getLabel, isInvalid, remove, setErrorMessage, setInvalid, setLabel, 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, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNamewithItems, withItems, withItemswithIdwithHelperComponent, withHelperTextgetHelperComponent, getHelperText, setHelperComponent, setHelperTextwithHelperAbove, withHelperAbove, withHelperBelowisHelperAbove, setHelperAbove, setHelperAbove, setHelperBelowwithLabelwithValueaddValueChangeListener, 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, focus, getTabIndex, setTabIndexpublic static final Supplier<com.vaadin.flow.component.html.Div> DEFAULT_TAB_CONTENTS_CONTAINER
public static final String MULTILINE_THEME_NAME
public SuperTabs()
TabHandler, TabHeaderGenerator and TabContentGenerator.@SafeVarargs public SuperTabs(Supplier<C> mainContentSupplier, T... values)
TabHandler, TabHeaderGenerator and TabContentGenerator, overriding default main layout component for the tab contents.C - Generic type to ensure the supplier gives a valid Component that implements HasComponents.mainContentSupplier - A callback to construct an instance of a component into which tab contents is put.@SafeVarargs public SuperTabs(TabContentGenerator<T> tabContentGenerator, T... values)
TabContentGenerator and tabs, but with default TabHeaderGenerator and TabHandler.tabContentGenerator - TabContentGenerator to construct content for tabs.values - Values to use.@SafeVarargs public SuperTabs(TabHeaderGenerator<T> tabHeaderGenerator, TabContentGenerator<T> tabContentGenerator, T... values)
TabHeaderGenerator, TabContentGenerator and tabs, but default TabHandler.tabHeaderGenerator - TabHeaderGenerator to construct tab headers.tabContentGenerator - TabContentGenerator to construct content for tabs.values - Values to use.@SafeVarargs public SuperTabs(T defaultValue, TabHeaderGenerator<T> tabHeaderGenerator, TabContentGenerator<T> tabContentGenerator, T... values)
TabHandler, given TabHeaderGenerator, TabContentGenerator and tabs, overriding the default value from null to the one provided.defaultValue - Default value that corresponds to no tab selected.tabHeaderGenerator - TabHeaderGenerator to construct tab headers.tabContentGenerator - TabContentGenerator to construct content for tabs.values - Values to use.@SafeVarargs public SuperTabs(T defaultValue, TabHandler tabHandler, TabHeaderGenerator<T> tabHeaderGenerator, TabContentGenerator<T> tabContentGenerator, T... values)
TabHandler, TabHeaderGenerator, TabContentGenerator and tabs, overriding the default value from null to the one provided.defaultValue - Default value that corresponds to no tab selected.tabHandler - TabHandler to use.tabHeaderGenerator - TabHeaderGenerator to construct tab headers.tabContentGenerator - TabContentGenerator to construct content for tabs.values - Values to use.TabHandlers@SafeVarargs public SuperTabs(T defaultValue, Supplier<C> mainContentSupplier, TabHandler tabHandler, TabHeaderGenerator<T> tabHeaderGenerator, TabContentGenerator<T> tabContentGenerator, T... values)
TabHandler, TabHeaderGenerator, TabContentGenerator and tabs, overriding the default value from null to the one provided and overriding default layout component for tab contents.C - Generic type to ensure the supplier gives a valid Component that implements HasComponents.defaultValue - Default value that corresponds to no tab selected.mainContentSupplier - A callback to construct an instance of a component into which tab contents is put.tabHandler - TabHandler to use.tabHeaderGenerator - TabHeaderGenerator to construct tab headers.tabContentGenerator - TabContentGenerator to construct content for tabs.values - Values to use.TabHandlersprotected void addNewTab(T value, boolean select)
getTabHeaderGenerator() and getTabContentGenerator() to produce components.value - A new value, not yet present in the component. Warning: no check are made to make sure this value is not used.select - Whether or not to select newly added tab.protected void addNewTab(T value, com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content, boolean select)
value - A new value, not yet present in the component. Warning: no check are made to make sure this value is not used.tab - Tab corresponding to the value.content - Content corresponding to the value.select - Whether or not to select newly added tab.@SafeVarargs public final void addTab(T... values)
Collection and calls addTabs(Collection).values - Values to add tabs and contents for.addTabs(Collection)public void addTabs(Collection<T> values)
getTabHeaderGenerator() and getTabContentGenerator() to produce components.
If there were no tabs prior to calling this method, the first tab added this way will be selected.values - Values to add tabs and contents for.public void addTab(T value, com.vaadin.flow.component.tabs.Tab tabHeader, com.vaadin.flow.component.Component tabContents)
value - A value that corresponds to provided tab header and tab contents.tabHeader - Header.tabContents - Contents.protected void removeExistingTab(T value, com.vaadin.flow.component.tabs.Tab header)
value - Value to remove.header - Header being removed.public void removeTab(T value)
value - Value to remove the tab for.protected Optional<Map.Entry<T,com.vaadin.flow.component.tabs.Tab>> getValueAndTab(T value)
value.value - A value to look for.Tab, if any.public Optional<com.vaadin.flow.component.tabs.Tab> getTabHeader(T value)
value - Value to look for.Tab that corresponds to the value, if any.public Optional<com.vaadin.flow.component.Component> getTabContents(T value)
Component.setVisible(boolean) calls on the result are discouraged ;)value - Value to look for.Component that corresponds to the value, if any.protected T generateModelValue()
generateModelValue in class com.vaadin.flow.component.customfield.CustomField<T>protected void setPresentationValue(T t)
setPresentationValue in class com.vaadin.flow.component.customfield.CustomField<T>public List<T> getValues()
getTabHeader(Object),
getTabContents(Object)public int size()
public void setTabContentGenerator(TabContentGenerator<T> tabContentGenerator)
tabContentGenerator - TabContentGenerator. If null, it will be replaced with a default function.public TabContentGenerator<T> getTabContentGenerator()
TabContentGenerator.public SuperTabs<T> withTabContentGenerator(TabContentGenerator<T> tabContentGenerator)
setTabContentGenerator(TabContentGenerator) and returns itself.tabContentGenerator - A TabContentGenerator.setTabContentGenerator(TabContentGenerator)public void setTabHeaderGenerator(TabHeaderGenerator<T> tabHeaderGenerator)
tabHeaderGenerator - TabHeaderGenerator. If null, it will be replaced with a default function.public TabHeaderGenerator<T> getTabHeaderGenerator()
TabContentGenerator.public SuperTabs<T> withTabHeaderGenerator(TabHeaderGenerator<T> tabHeaderGenerator)
setTabHeaderGenerator(TabHeaderGenerator) and returns itself.tabHeaderGenerator - A TabHeaderGenerator.setTabHeaderGenerator(TabHeaderGenerator)public boolean isCustomValueAllowed()
AbstractField.setValue(Object).true when selecting a value that does not have a corresponding tab results in adding a new tab, false otherwise (and by default).public void setCustomValueAllowed(boolean customValueAllowed)
AbstractField.setValue(Object).customValueAllowed - when true, selecting a value that does not have a corresponding tab will result in adding and selecting a new tab; false will ignore setting the value.public SuperTabs<T> withCustomValueAllowed(boolean customValueAllowed)
setCustomValueAllowed(boolean) and returns itself.customValueAllowed - Whether or not to allow setting custom value.setCustomValueAllowed(boolean)public void setTabHandler(TabHandler tabHandler)
TabHandler to use.
Causes all current tab contents to be removed with the current TabHandler, then added and (de)selected with the new one.
Does not trigger value change events nor generating tab headers/contents, as only the handling of tabs is changed.tabHandler - A TabHandler. If null is passed, TabHandlers.REMOVING_HANDLER will be used.public TabHandler getTabHandler()
TabHandler.TabHandler. Never null.public SuperTabs<T> withTabHandler(TabHandler tabHandler)
setTabHandler(TabHandler) and returns itself.tabHandler - A TabHandler. If null is passed, TabHandlers.REMOVING_HANDLER will be used.setTabHandler(TabHandler)public boolean isMultiline()
true and tabs would overflow current viewport, the extra ones will drop to the next line; false otherwise and by default.public void setMultiline(boolean multiline)
multiline - When true and tabs overflow current viewport, the extra ones will drop to the next line; false when all should be displayed in one line (with navigation buttons if needed).public SuperTabs<T> withMultiline(boolean multiline)
setMultiline(boolean) and returns itself.multiline - Whether or not wrap tabs into new line on overflow.setMultiline(boolean)public void setItems(Collection<T> collection)
setItems in interface com.vaadin.flow.data.binder.HasItems<T>Copyright © 2023 Miki. All rights reserved.