Class EasyGridWrapper<T,GRID extends Grid<T>>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<GRID>
com.flowingcode.vaadin.addons.easygrid.EasyGridWrapper<T,GRID>
- Type Parameters:
T- the grid bean typeGRID- the concreteGridsubtype being wrapped
- All Implemented Interfaces:
AttachNotifier,BlurNotifier<Grid<T>>,DetachNotifier,Focusable<Grid<T>>,FocusNotifier<Grid<T>>,HasElement,HasEnabled,HasSize,HasStyle,HasTheme,HasDataGenerators<T>,HasDataView<T,,Void, GridDataView<T>> HasLazyDataView<T,,Void, GridLazyDataView<T>> HasListDataView<T,,GridListDataView<T>> Serializable
- Direct Known Subclasses:
EasyGrid
Wraps a
Grid to provide bean property-based column creation and type-aware
ColumnConfiguration resolution. Columns can be created automatically from all top-level
bean properties, from an explicit list of property names, or individually via
addColumn(String) and addColumn(Class, ValueProvider).
EasyGrid is the standard concrete subclass for use with a plain Grid.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component> -
Constructor Summary
ConstructorsConstructorDescriptionEasyGridWrapper(GRID grid, @NonNull Class<T> beanType) Creates anEasyGridWrapperthat discovers all top-level bean properties and adds a column for each.EasyGridWrapper(GRID grid, @NonNull Class<T> beanType, boolean autoCreateColumns) Creates anEasyGridWrapperfor the given bean type, optionally auto-creating columns.EasyGridWrapper(GRID grid, @NonNull Class<T> beanType, String... propertyNames) Creates anEasyGridWrapperthat adds columns for the specified properties in order. -
Method Summary
Modifier and TypeMethodDescription<V> EasyColumn<T,V> addColumn(Class<V> type, ValueProvider<T, V> getter) Adds a column for the given type and value provider.EasyColumn<T,?> Adds a column for the given bean property.voidaddColumns(@NonNull String... propertyNames) Adds columns for the given bean properties in order.voidPasses the wrapped grid to the given customizer, allowing direct configuration of the grid.protected <V> EasyColumn<T,V> createEasyColumn(Class<V> type, ValueProvider<T, V> getter, String propertyName, PropertyDescriptor propertyDescriptor) EasyColumn<T,?> Returns theEasyColumnfor the given property name, ornullif no column with that key exists or the column was not created through the EasyGrid API.final GRIDReturns the wrapped grid.voidhideColumns(@NonNull String... propertyNames) Hides the columns with the given property names.protected GRIDvoidsetColumnOrder(@NonNull String... propertyNames) Sets the order of the columns shown in the grid.<V> ColumnConfiguration<V>typeConfiguration(Class<V> type) Returns theColumnConfigurationfor the given value type at the instance level, creating it if it does not yet exist.Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, 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.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.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.data.provider.HasDataGenerators
addDataGeneratorMethods inherited from interface com.vaadin.flow.data.provider.HasDataView
getGenericDataView, setItems, setItemsMethods 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.data.provider.HasLazyDataView
getLazyDataView, setItems, setItems, setItemsMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
getListDataView, setItems, setItems, setItemsMethods 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, setThemeName
-
Constructor Details
-
EasyGridWrapper
Creates anEasyGridWrapperthat discovers all top-level bean properties and adds a column for each.- Parameters:
grid- the grid to configure, notnullbeanType- the bean type to use, notnull- Throws:
NullPointerException- if eithergridorbeanTypeisnull
-
EasyGridWrapper
public EasyGridWrapper(@NonNull GRID grid, @NonNull @NonNull Class<T> beanType, boolean autoCreateColumns) Creates anEasyGridWrapperfor the given bean type, optionally auto-creating columns.- Parameters:
grid- the grid to configure, notnullbeanType- the bean type to use, notnullautoCreateColumns- whentrue, columns are created automatically for the properties of the bean type- Throws:
NullPointerException- if eithergridorbeanTypeisnull
-
EasyGridWrapper
public EasyGridWrapper(@NonNull GRID grid, @NonNull @NonNull Class<T> beanType, String... propertyNames) Creates anEasyGridWrapperthat adds columns for the specified properties in order.- Parameters:
grid- the grid to configure, notnullbeanType- the bean type to use, notnullpropertyNames- the names of the properties for which columns are created- Throws:
NullPointerException- if eithergridorbeanTypeisnull, or ifpropertyNamesisnull
-
-
Method Details
-
getColumn
Returns theEasyColumnfor the given property name, ornullif no column with that key exists or the column was not created through the EasyGrid API.- Parameters:
propertyName- the property name used as the column key- Returns:
- the
EasyColumnfor the given key, ornull
-
addColumn
Adds a column for the given bean property. The column header is derived from the property name, and the column is made sortable if the property type implementsComparableor is a primitive type.- Parameters:
propertyName- the name of the bean property- Returns:
- the
EasyColumnfor the added column - Throws:
IllegalArgumentException- if the property cannot be resolved or a column for it already exists
-
setColumnOrder
Sets the order of the columns shown in the grid. Only the listed columns are visible after this call; all other columns are hidden. The columns are shown in the order they are listed.- Parameters:
propertyNames- the property names of the columns to show, in the desired order- Throws:
NullPointerException- ifpropertyNamesisnull
-
hideColumns
Hides the columns with the given property names.- Parameters:
propertyNames- the property names of the columns to hide- Throws:
NullPointerException- ifpropertyNamesisnull
-
addColumns
Adds columns for the given bean properties in order.- Parameters:
propertyNames- the names of the bean properties- Throws:
NullPointerException- ifpropertyNamesisnullIllegalArgumentException- if any property cannot be resolved or already has a column
-
addColumn
Adds a column for the given type and value provider. The column is made sortable if the value type implementsComparableor is a primitive type. No column key or header is set automatically; use the returnedEasyColumnto configure them.- Type Parameters:
V- the column value type- Parameters:
type- theClassof the column value, used to resolve theColumnConfigurationgetter- a value provider that extracts the column value from a bean instance- Returns:
- the
EasyColumnfor the added column
-
createEasyColumn
protected <V> EasyColumn<T,V> createEasyColumn(Class<V> type, ValueProvider<T, V> getter, String propertyName, PropertyDescriptor propertyDescriptor) -
typeConfiguration
Returns theColumnConfigurationfor the given value type at the instance level, creating it if it does not yet exist. Modifications to the returned configuration apply to all columns of that type managed by this instance and take precedence overGlobalEasyGridConfiguration.- Type Parameters:
V- the column value type- Parameters:
type- theClassof the column value type- Returns:
- the
ColumnConfigurationfor the given type
-
initContent
- Overrides:
initContentin classComposite<GRID extends Grid<T>>
-
getWrappedGrid
Returns the wrapped grid.- Returns:
- the wrapped grid, never
null
-
configure
Passes the wrapped grid to the given customizer, allowing direct configuration of the grid.- Parameters:
customizer- a consumer that configures the wrapped grid
-