Class TwinColGrid<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.orderedlayout.VerticalLayout
com.flowingcode.vaadin.addons.twincolgrid.TwinColGrid<T>
- All Implemented Interfaces:
AttachNotifier,ClickNotifier<VerticalLayout>,DetachNotifier,HasComponents,HasElement,HasEnabled,HasOrderedComponents<VerticalLayout>,HasSize,HasStyle,HasValidation,HasValue<HasValue.ValueChangeEvent<Set<T>>,,Set<T>> HasValueAndElement<HasValue.ValueChangeEvent<Set<T>>,,Set<T>> FlexComponent<VerticalLayout>,ThemableLayout,Serializable
- Direct Known Subclasses:
LegacyTwinColGrid
@JsModule("./src/fc-twin-col-grid-auto-resize.js")
@CssImport("./styles/twin-col-grid-button.css") @CssImport("./styles/twincol-grid.css")
public class TwinColGrid<T>
extends VerticalLayout
implements HasValueAndElement<HasValue.ValueChangeEvent<Set<T>>,Set<T>>, HasComponents, HasSize, HasValidation
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumenumeration of all available orientation for TwinGolGrid componentNested classes/interfaces inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
FlexComponent.Alignment, FlexComponent.JustifyContentModeNested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V extends Object>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>> -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new TwinColGrid with an emptyListDataProvider.TwinColGrid(@NonNull Grid<T> availableGrid, @NonNull Grid<T> selectionGrid) Constructs a new empty TwinColGrid, using the specified grids for each side.TwinColGrid(Collection<T> options) Constructs a new TwinColGrid with the given options.TwinColGrid(Supplier<Grid<T>> gridSupplier) Constructs a new empty TwinColGrid, using the specified supplier for instantiating both grids. -
Method Summary
Modifier and TypeMethodDescriptionaddColumn(ItemLabelGenerator<T> itemLabelGenerator) Adds a column to each grids.addFilterableColumn(ItemLabelGenerator<T> itemLabelGenerator) addFilterableColumn(ItemLabelGenerator<T> itemLabelGenerator, SerializableFunction<T, String> filterableValue) addValueChangeListener(HasValue.ValueChangeListener<? super HasValue.ValueChangeEvent<Set<T>>> listener) asList()voidclearAll()createFirstHeaderRow(boolean value) Configure this component to create the first header row (for column header labels).final voidforEachGrid(Consumer<Grid<T>> consumer) Return the grid that contains the available items.Returns the text shown above the grid with the available items.Returns the component caption.Return the grid that contains the selected items.Returns the text shown above the grid with the selected items.getValue()Returns the current value of this object which is an immutable set of the currently selected items.booleanReturn whether autoResize is set or not.booleanbooleanbooleanbooleanReturn whether drag-and-drop within the selection grid is allowed.voidsetAutoResize(boolean autoResize) Sets whether component should update orientation on resize.voidsetCaption(String captionText) Sets the component caption.protected voidsetDataProvider(ListDataProvider<T> dataProvider) voidsetErrorMessage(String errorMessage) voidsetInvalid(boolean invalid) voidsetItems(Collection<T> items) voidvoidsetMoveItemsByDoubleClick(boolean value) Sets whether a doubleclick event immediately moves an item to the other gridvoidsetReadOnly(boolean readOnly) voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) voidsetSelectionGridReorderingAllowed(boolean value) Configure whether drag-and-drop within the selection grid is allowed.voidSetvalueto gridwithAvailableGridCaption(String caption) Sets the text shown above the grid with the available items.Adds drag n drop support between grids.withOrientation(TwinColGrid.Orientation orientation) Sets orientation for TwinColGridComponentwithSelectionGridCaption(String caption) Sets the text shown above the grid with the selected items.Allow drag-and-drop within the selection grid.Methods inherited from class com.vaadin.flow.component.orderedlayout.VerticalLayout
addAndExpand, getAlignItems, getAlignSelf, getDefaultHorizontalComponentAlignment, getHorizontalComponentAlignment, setAlignItems, setAlignSelf, setDefaultHorizontalComponentAlignment, setHorizontalComponentAlignment, setPadding, setSpacingMethods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, 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.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
expand, getFlexGrow, getJustifyContentMode, replace, setFlexGrow, setJustifyContentModeMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOfMethods 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.HasValue
clear, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.orderedlayout.ThemableLayout
getBoxSizing, getThemeList, isMargin, isPadding, isSpacing, setBoxSizing, setMargin
-
Constructor Details
-
TwinColGrid
public TwinColGrid()Constructs a new TwinColGrid with an emptyListDataProvider. -
TwinColGrid
Constructs a new empty TwinColGrid, using the specified supplier for instantiating both grids.- Parameters:
gridSupplier- a supplier for instantiating both grids
-
TwinColGrid
public TwinColGrid(@NonNull @NonNull Grid<T> availableGrid, @NonNull @NonNull Grid<T> selectionGrid) Constructs a new empty TwinColGrid, using the specified grids for each side.- Parameters:
availableGrid- the grid that contains the available itemsselectionGrid- the grid that contains the selected items
-
TwinColGrid
Constructs a new TwinColGrid with the given options.- Parameters:
options- the options, cannot benull
-
-
Method Details
-
setCaption
Sets the component caption.- Parameters:
captionText- the component caption.
-
getCaption
Returns the component caption.- Returns:
- the component caption.
-
withOrientation
Sets orientation for TwinColGridComponent- Parameters:
orientation-- Returns:
- this instance for method chaining.
-
getOrientation
-
getAvailableGrid
Return the grid that contains the available items. -
getSelectionGrid
Return the grid that contains the selected items. -
forEachGrid
-
setItems
-
setItems
-
clearAll
public void clearAll() -
setDataProvider
-
withAvailableGridCaption
Sets the text shown above the grid with the available items.nullclears the caption.- Parameters:
caption- The text to show,nullto clear- Returns:
- this instance
-
withSelectionGridCaption
Sets the text shown above the grid with the selected items.nullclears the caption.- Parameters:
caption- The text to show,nullto clear- Returns:
- this instance
-
createFirstHeaderRow
Configure this component to create the first header row (for column header labels). If no column will have a header, this property must be set tofalse.When this property is
true(default), the first column added through this component will append a header row, which will be the "default header row" (used byColumn.setHeader). If no headers are set, then the default header row will be empty.When this property is
false, thenColumn.setHeaderwill allocate a header row when called (which prevents an empty row if no headers are set, but also replaces the filter componentes).- Parameters:
value- whether the first header row will be created when a column is added.- Returns:
- this instance
-
addColumn
Adds a column to each grids. Both columns will use aTextRendererand the value will be converted to a String by using the provideditemLabelGenerator.- Parameters:
itemLabelGenerator- the value provider- Returns:
- the pair of columns
-
withoutAddAllButton
-
withoutRemoveAllButton
-
withoutAddButton
-
withoutRemoveButton
-
withSizeFull
-
withDragAndDropSupport
Adds drag n drop support between grids.- Returns:
- this instance
-
getAvailableGridCaption
Returns the text shown above the grid with the available items.- Returns:
- The text shown or
nullif not set.
-
getSelectionGridCaption
Returns the text shown above the grid with the selected items.- Returns:
- The text shown or
nullif not set.
-
setValue
Setvalueto grid -
getValue
Returns the current value of this object which is an immutable set of the currently selected items. -
addValueChangeListener
public Registration addValueChangeListener(HasValue.ValueChangeListener<? super HasValue.ValueChangeEvent<Set<T>>> listener) - Specified by:
addValueChangeListenerin interfaceHasValue<HasValue.ValueChangeEvent<Set<T>>,Set<T>>
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceHasValue<HasValue.ValueChangeEvent<Set<T>>,Set<T>> - Specified by:
isReadOnlyin interfaceHasValueAndElement<HasValue.ValueChangeEvent<Set<T>>,Set<T>>
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()- Specified by:
isRequiredIndicatorVisiblein interfaceHasValue<HasValue.ValueChangeEvent<Set<T>>,Set<T>> - Specified by:
isRequiredIndicatorVisiblein interfaceHasValueAndElement<HasValue.ValueChangeEvent<Set<T>>,Set<T>>
-
setErrorMessage
- Specified by:
setErrorMessagein interfaceHasValidation
-
getErrorMessage
- Specified by:
getErrorMessagein interfaceHasValidation
-
setInvalid
public void setInvalid(boolean invalid) - Specified by:
setInvalidin interfaceHasValidation
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalidin interfaceHasValidation
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfaceHasValue<HasValue.ValueChangeEvent<Set<T>>,Set<T>> - Specified by:
setReadOnlyin interfaceHasValueAndElement<HasValue.ValueChangeEvent<Set<T>>,Set<T>>
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) - Specified by:
setRequiredIndicatorVisiblein interfaceHasValue<HasValue.ValueChangeEvent<Set<T>>,Set<T>> - Specified by:
setRequiredIndicatorVisiblein interfaceHasValueAndElement<HasValue.ValueChangeEvent<Set<T>>,Set<T>>
-
withSelectionGridReordering
Allow drag-and-drop within the selection grid. -
setSelectionGridReorderingAllowed
public void setSelectionGridReorderingAllowed(boolean value) Configure whether drag-and-drop within the selection grid is allowed. -
isSelectionGridReorderingAllowed
public boolean isSelectionGridReorderingAllowed()Return whether drag-and-drop within the selection grid is allowed. -
addFilterableColumn
-
addFilterableColumn
public FilterableTwinColumn<T> addFilterableColumn(ItemLabelGenerator<T> itemLabelGenerator, SerializableFunction<T, String> filterableValue) -
selectRowOnClick
-
asList
-
getEmptyValue
- Specified by:
getEmptyValuein interfaceHasValue<HasValue.ValueChangeEvent<Set<T>>,Set<T>>
-
isAutoResize
public boolean isAutoResize()Return whether autoResize is set or not. -
setAutoResize
public void setAutoResize(boolean autoResize) Sets whether component should update orientation on resize.- Parameters:
autoResize- if true, component will update orientation on resize
-
setMoveItemsByDoubleClick
public void setMoveItemsByDoubleClick(boolean value) Sets whether a doubleclick event immediately moves an item to the other grid- Parameters:
value- if true, a a doubleclick event will immediately move an item to the other grid
-