Package com.storedobject.ui
Class EditableGrid<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.grid.Grid<T>
com.storedobject.vaadin.DataGrid<T>
com.storedobject.vaadin.ListGrid<T>
com.storedobject.ui.DataGrid<T>
com.storedobject.ui.AbstractEditableGrid<T>
com.storedobject.ui.EditableGrid<T>
- Type Parameters:
T
- Type of object.
- All Implemented Interfaces:
Executable
,Reentrant
,HasLogic
,EditableDataGrid<T>
,Transactional
,ViewFilterSupport<T>
,ClickHandler
,ExecutableView
,HasColumns<T>
,SupportWindowMode
,ValueChangeHandler
,com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.grid.Grid<T>>
,com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<? extends com.vaadin.flow.component.Component>>
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.grid.Grid<T>>
,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.grid.Grid<T>>
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasEnabled
,com.vaadin.flow.component.HasSize
,com.vaadin.flow.component.HasStyle
,com.vaadin.flow.component.HasTheme
,com.vaadin.flow.component.HasValue.ValueChangeListener
,com.vaadin.flow.data.event.SortEvent.SortNotifier<com.vaadin.flow.component.grid.Grid<T>,
,com.vaadin.flow.component.grid.GridSortOrder<T>> com.vaadin.flow.data.provider.HasDataGenerators<T>
,com.vaadin.flow.data.provider.HasDataView<T,
,Void, com.vaadin.flow.component.grid.dataview.GridDataView<T>> com.vaadin.flow.data.provider.HasLazyDataView<T,
,Void, com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>> com.vaadin.flow.data.provider.HasListDataView<T,
,com.vaadin.flow.component.grid.dataview.GridListDataView<T>> Serializable
,Iterable<T>
,Runnable
,Collection<T>
,EventListener
,List<T>
,SequencedCollection<T>
- Direct Known Subclasses:
ListEditor
An editable grid that can be used to edit a list of objects of any type.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.grid.Grid
com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>, com.vaadin.flow.component.grid.Grid.Column<T>, com.vaadin.flow.component.grid.Grid.DataCommunicatorBuilder<T,
U extends com.vaadin.flow.data.provider.ArrayUpdater>, com.vaadin.flow.component.grid.Grid.MultiSortPriority, com.vaadin.flow.component.grid.Grid.NestedNullBehavior, com.vaadin.flow.component.grid.Grid.SelectionMode, com.vaadin.flow.component.grid.Grid.UpdateQueue Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>
Nested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component>
Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>
Nested classes/interfaces inherited from interface com.storedobject.vaadin.HasColumns
HasColumns.SOGrid<T>
-
Constructor Summary
ConstructorsConstructorDescriptionEditableGrid
(Class<T> objectClass) Constructor.EditableGrid
(Class<T> objectClass, Iterable<String> columns) Constructor.EditableGrid
(Class<T> objectClass, Iterable<String> columns, BiFunction<T, Boolean, T> loader) Constructor.EditableGrid
(Class<T> objectClass, BiFunction<T, Boolean, T> loader) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
addValueChangeTracker
(BiConsumer<AbstractListProvider<T>, Boolean> tracker) void
Cancel the editing if it is active.protected ListProvider
<T> createListDataProvider
(DataList<T> data) Create an instance ofListDataProvider
for the given data.protected void
doDeleteAction
(T object) Carry out the delete action for the object.protected void
doInsertAction
(T object) Carry out the insert action for the object.protected void
doReloadAction
(T object) Carry out the reload action for the object.protected void
Carry out the "reload all" action.protected void
doUndeleteAction
(T object) Carry out the undelete action for the object.protected void
doUpdateAction
(T object) Carry out the update action for the object.boolean
Edit a given item.protected com.vaadin.flow.component.HasValue
<?, ?> getColumnField
(String columnName) Get the field for the column.final T
Get the item being currently edited.final com.vaadin.flow.component.HasValue
<?, ?> Get the field for the given column name.boolean
isColumnEditable
(String columnName) All fields are editable by default unless a field can't be created for the column.final boolean
Check the read-only status.protected boolean
void
Save the currently editing item.void
setAutoSaveOnMove
(boolean autoSave) Set the auto-save mode.void
setReadOnly
(boolean readOnly) Set read only.final Stream
<com.vaadin.flow.component.HasValue<?, ?>> Get the stream of editable fields of this grid.void
This will be invoked just before accepting the changes when editing.Methods inherited from class com.storedobject.ui.AbstractEditableGrid
add, changed, clear, createEditableList, createEditor, customizeColumn, delete, getColumnOrder, getEditableList, isAdded, isColumnSortable, isDeleted, isEdited, isFromClient, isSavePending, reload, reloadAll, setEditOnSingleClick, setFromClient, streamAdded, streamAll, streamDeleted, streamEdited, update
Methods inherited from class com.storedobject.ui.DataGrid
actionAllowed, append, canAllowAction, doAppendAction, getActionPrefix, getDataProvider, getObjectClass, itemAppended, itemDeleted, itemInserted, itemReloaded, itemUndeleted, itemUpdated, load, load, selected, selected, setItems, setItems, setItems, setItems, setItems, setItems, setItems, setItems, sort, sort, validateAppend, validateDelete, validateInsert, validateReload, validateUndelete, validateUpdate
Methods inherited from class com.storedobject.vaadin.ListGrid
add, addAll, addAll, addViewFilter, clearViewFilters, contains, containsAll, get, getData, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, onAttach, onDetach, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, setData, setViewFilter, size, subList, toArray, toArray
Methods inherited from class com.storedobject.vaadin.DataGrid
addConstructedListener, appendFooter, clearConstructedListeners, getColumnByKey, getColumns, getSOGrid, isColumnReorderingAllowed, setColumnReorderingAllowed, streamConstructedListeners
Methods inherited from class com.vaadin.flow.component.grid.Grid
addCellFocusListener, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumnReorderListener, addColumnResizeListener, addColumns, addComponentColumn, addContextMenu, addDataGenerator, addDragEndListener, addDragStartListener, addDropListener, addFirstHeaderRow, addItemClickListener, addItemDoubleClickListener, addSelectionListener, addSortListener, addThemeVariants, addValueProvider, appendFooterRow, appendHeaderRow, asMultiSelect, asSingleSelect, compareMaybeComparables, configureBeanType, createColumn, createColumnId, createDefaultArrayUpdater, createSortingComparator, deselect, deselectAll, getAriaLabel, getArrayUpdater, getBeanType, getClassNameGenerator, getColumnLayers, getColumnRendering, getDataCommunicator, getDefaultColumnFactory, getDefaultHeaderRow, getDragFilter, getDropFilter, getDropMode, getEditor, getEmptyStateComponent, getEmptyStateText, getFooterRows, getGenericDataView, getHeaderRows, getLazyDataView, getListDataView, getNestedNullBehavior, getPageSize, getPartNameGenerator, getPropertySet, getSelectedItems, getSelectionMode, getSelectionModel, getSelectionPreservationMode, getSortOrder, getUniqueKeyProperty, getUniqueKeyProvider, initConnector, insertColumnLayer, isAllRowsVisible, isDetailsVisible, isDetailsVisibleOnClick, isMultiSort, isRowsDraggable, onDataProviderChange, onEnabledStateChanged, prependFooterRow, prependHeaderRow, recalculateColumnWidths, removeAllColumns, removeAllFooterRows, removeAllHeaderRows, removeColumn, removeColumnByKey, removeColumnLayer, removeColumns, removeFooterRow, removeHeaderRow, removeThemeVariants, scrollToEnd, scrollToIndex, scrollToItem, scrollToStart, select, setAllRowsVisible, setAriaLabel, setClassNameGenerator, setColumnKey, setColumnOrder, setColumnOrder, setColumnRendering, setColumns, setDataProvider, setDefaultMultiSortPriority, setDetailsVisible, setDetailsVisibleOnClick, setDragDataGenerator, setDragFilter, setDropFilter, setDropMode, setEmptyStateComponent, setEmptyStateText, setItemDetailsRenderer, setItemSelectableProvider, setMultiSort, setMultiSort, setMultiSort, setMultiSort, setNestedNullBehavior, setPageSize, setPartNameGenerator, setRowsDraggable, setSelectionDragDetails, setSelectionMode, setSelectionModel, setSelectionPreservationMode, setSortableColumns, setTooltipGenerator, setUniqueKeyProperty, setUniqueKeyProvider, updateSelectionModeOnClient
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
Methods inherited from interface com.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClicked
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.storedobject.ui.EditableDataGrid
canDelete, canEdit, canPostLedger, canViewLedger
Methods inherited from interface com.storedobject.common.Executable
act
Methods inherited from interface com.storedobject.vaadin.ExecutableView
abort, clean, clicked, close, createMenuItem, error, execute, execute, getMenuIconName, getMenuItem, getView, invoke, isCloseable, isFullScreen, isHomeView, log, log, message, returnedFrom, run, setClickable, speak, trackValueChange, tray, valueChanged, warning
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
Methods inherited from interface com.storedobject.vaadin.HasColumns
addItemSelectedListener, addItemsSelectedListener, appendHeader, clearAlerts, compact, configure, constructed, createColumn, createColumn, createColumn, createColumn, createColumn, createComponentColumn, createDecoratedWindow, createFooters, createHeader, createHeaders, createHierarchyColumn, createHTMLColumn, createHTMLHierarchyColumn, createView, customizeRenderer, deselect, deselect, executing, getApplication, getCaption, getColumn, getColumnCaption, getColumnCount, getColumnDetail, getColumnFunction, getColumnHeaderComponent, getColumnMethodName, getColumnNames, getColumnSorter, getColumnTemplate, getConfigureButton, getDataClass, getDefinedColumnCount, getFixedColumnWidth, getMenuItem, getObjectRendered, getObjectUnwrapped, getRelativeColumnWidth, getSelected, getTextAlign, getView, getViewComponent, ignoreCaseForColumnSorting, includeColumn, isColumnFrozen, isColumnResizable, isColumnVisible, prependFooter, prependHeader, refresh, refresh, refresh, removeItemSelectedListener, render, select, select, setCaption, setColumnFrozen, setColumnResizable, setColumnVisible, setMethodHandlerHost, sort, sort, sortOrder, sortOrder, unwrap
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, reversed, spliterator
Methods inherited from interface com.storedobject.common.Reentrant
isReentrant
Methods inherited from interface com.storedobject.vaadin.util.SupportWindowMode
createWindow
Methods inherited from interface com.storedobject.ui.Transactional
commit, execute, getLogic, getTransactionManager, run, setLogic, transact, transact, transactControl, transactControl
Methods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
Methods inherited from interface com.storedobject.ui.util.ViewFilterSupport
configure, configure, configure, configureMatch, filterView, getViewFilter
-
Constructor Details
-
EditableGrid
-
EditableGrid
-
EditableGrid
-
EditableGrid
-
-
Method Details
-
isValid
- Overrides:
isValid
in classAbstractEditableGrid<T>
-
createListDataProvider
Description copied from class:ListGrid
Create an instance ofListDataProvider
for the given data. The default implementation creates an instance of Vaadin's implementation. However, a modified implementation can be provided instead.- Overrides:
createListDataProvider
in classDataGrid<T>
- Parameters:
data
- Data for which data provider needs to be created.- Returns:
- An instance of the
ListDataProvider
.
-
addValueChangeTracker
public com.vaadin.flow.shared.Registration addValueChangeTracker(BiConsumer<AbstractListProvider<T>, Boolean> tracker) -
setAutoSaveOnMove
public void setAutoSaveOnMove(boolean autoSave) Set the auto-save mode. If this mode is set totrue
, values will be saved from the field when jumping between rows. By default, it is off and field values will not be saved when jumping between rows.- Parameters:
autoSave
- True/false.
-
isColumnEditable
All fields are editable by default unless a field can't be created for the column.- Specified by:
isColumnEditable
in interfaceEditableDataGrid<T>
- Parameters:
columnName
- Column name.- Returns:
- True/false.
-
getColumnField
Get the field for the column. (Used while editing the row). In general, it is not required to override this. If this method returnsnull
, field will be created by inspecting the return value of the getXXX(T) method (where XXX is the name of the field) if such a method exists. If getXXX(T) method doesn't exist, it will try getXXX() method in the object class. If that also doesn't exist, no field will be created. (getXXX(T)/getXXX() methods and setXXX(T, value)/setXXX(value) methods are used to read from the object and write back to the object. If no setXXX method exists but a getXXX method exists, the field will be read-only).- Parameters:
columnName
- Column name for which field needs to be obtained.- Returns:
- Default implementation returns
null
.
-
getField
Description copied from class:AbstractEditableGrid
Get the field for the given column name.- Overrides:
getField
in classAbstractEditableGrid<T>
- Parameters:
columnName
- Name of the column for which field is required.- Returns:
- Field if found, otherwise
null
is returned.
-
streamEditableFields
Description copied from interface:EditableDataGrid
Get the stream of editable fields of this grid.- Specified by:
streamEditableFields
in interfaceEditableDataGrid<T>
- Returns:
- Stream of editable fields.
-
validateFieldValues
-
setReadOnly
public void setReadOnly(boolean readOnly) Set read only.- Parameters:
readOnly
- If true, rows will not be editable.
-
isReadOnly
public final boolean isReadOnly()Check the read-only status.- Returns:
- True/false.
-
editItem
Edit a given item.- Overrides:
editItem
in classAbstractEditableGrid<T>
- Parameters:
item
- Item to edit.- Returns:
- True if editing is started, otherwise false.
-
cancelEdit
public void cancelEdit()Description copied from class:AbstractEditableGrid
Cancel the editing if it is active.- Specified by:
cancelEdit
in classAbstractEditableGrid<T>
-
saveEdited
public void saveEdited()Save the currently editing item. Editor will be closed only if the item is saved successfully becausevalidateFieldValues()
will be invoked to validate the field values. -
getEditingItem
Get the item being currently edited.- Returns:
- Item that is being edited. Will be null if no editing is going on.
-
doInsertAction
Description copied from class:DataGrid
Carry out the insert action for the object. The object is already validated.- Overrides:
doInsertAction
in classDataGrid<T>
- Parameters:
object
- Item that is newly added.
-
doUpdateAction
Description copied from class:DataGrid
Carry out the update action for the object. The object is already validated.- Overrides:
doUpdateAction
in classDataGrid<T>
- Parameters:
object
- Item that is updated.
-
doDeleteAction
Description copied from class:DataGrid
Carry out the delete action for the object. The object is already validated.- Overrides:
doDeleteAction
in classDataGrid<T>
- Parameters:
object
- Item that is deleted.
-
doUndeleteAction
Description copied from class:DataGrid
Carry out the undelete action for the object. The object is already validated.- Overrides:
doUndeleteAction
in classDataGrid<T>
- Parameters:
object
- Item that is undeleted.
-
doReloadAction
Description copied from class:DataGrid
Carry out the reload action for the object. The object is already validated.- Overrides:
doReloadAction
in classDataGrid<T>
- Parameters:
object
- Item that is undeleted.
-
doReloadAllAction
protected void doReloadAllAction()Description copied from class:DataGrid
Carry out the "reload all" action. All validation are already done before invoking this.- Overrides:
doReloadAllAction
in classDataGrid<T>
-