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.SpringData, 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.RegistrationaddValueChangeTracker(BiConsumer<AbstractListProvider<T>, Boolean> tracker) voidCancel the editing if it is active.protected ListProvider<T> createListDataProvider(DataList<T> data) Create an instance ofListDataProviderfor the given data.protected voiddoDeleteAction(T object) Carry out the delete action for the object.protected voiddoInsertAction(T object) Carry out the insert action for the object.protected voiddoReloadAction(T object) Carry out the reload action for the object.protected voidCarry out the "reload all" action.protected voiddoUndeleteAction(T object) Carry out the undelete action for the object.protected voiddoUpdateAction(T object) Carry out the update action for the object.booleanEdit a given item.protected com.vaadin.flow.component.HasValue<?, ?> getColumnField(String columnName) Get the field for the column.final TGet the item being currently edited.final com.vaadin.flow.component.HasValue<?, ?> Get the field for the given column name.booleanisColumnEditable(String columnName) All fields are editable by default unless a field can't be created for the column.final booleanCheck the read-only status.protected booleanvoidSave the currently editing item.voidsetAutoSaveOnMove(boolean autoSave) Set the auto-save mode.voidsetReadOnly(boolean readOnly) Set read only.final Stream<com.vaadin.flow.component.HasValue<?, ?>> Get the stream of editable fields of this grid.voidThis 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, updateMethods 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, validateUpdateMethods 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, toArrayMethods inherited from class com.storedobject.vaadin.DataGrid
addConstructedListener, appendFooter, clearConstructedListeners, getColumnByKey, getColumns, getSOGrid, isColumnReorderingAllowed, setColumnReorderingAllowed, streamConstructedListenersMethods 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, getColumnByInternalId, 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, getTooltipPosition, 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, setItemsPageable, setItemsPageable, setMultiSort, setMultiSort, setMultiSort, setMultiSort, setNestedNullBehavior, setPageSize, setPartNameGenerator, setRowsDraggable, setSelectionDragDetails, setSelectionMode, setSelectionModel, setSelectionPreservationMode, setSortableColumns, setTooltipGenerator, setTooltipPosition, setUniqueKeyProperty, setUniqueKeyProvider, updateSelectionModeOnClientMethods 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, 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.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClickedMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.storedobject.ui.EditableDataGrid
canDelete, canEdit, canPostLedger, canViewLedgerMethods inherited from interface com.storedobject.common.Executable
actMethods 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, warningMethods 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.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, getRenderedColumnNames, 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, unwrapMethods 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.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, setThemeNameMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, reversed, spliteratorMethods inherited from interface com.storedobject.common.Reentrant
isReentrantMethods inherited from interface com.storedobject.vaadin.util.SupportWindowMode
createWindowMethods inherited from interface com.storedobject.ui.Transactional
commit, execute, getLogic, getTransactionManager, run, setLogic, transact, transact, transactControl, transactControl, transactControl, transactControlMethods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChangedMethods inherited from interface com.storedobject.ui.util.ViewFilterSupport
configure, configure, configure, configureMatch, filterView, getViewFilter
-
Constructor Details
-
EditableGrid
-
EditableGrid
-
EditableGrid
-
EditableGrid
-
-
Method Details
-
isValid
- Overrides:
isValidin classAbstractEditableGrid<T>
-
createListDataProvider
Description copied from class:ListGridCreate an instance ofListDataProviderfor the given data. The default implementation creates an instance of Vaadin's implementation. However, a modified implementation can be provided instead.- Overrides:
createListDataProviderin 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:
isColumnEditablein 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:AbstractEditableGridGet the field for the given column name.- Overrides:
getFieldin classAbstractEditableGrid<T>- Parameters:
columnName- Name of the column for which field is required.- Returns:
- Field if found, otherwise
nullis returned.
-
streamEditableFields
Description copied from interface:EditableDataGridGet the stream of editable fields of this grid.- Specified by:
streamEditableFieldsin 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:
editItemin classAbstractEditableGrid<T>- Parameters:
item- Item to edit.- Returns:
- True if editing is started, otherwise false.
-
cancelEdit
public void cancelEdit()Description copied from class:AbstractEditableGridCancel the editing if it is active.- Specified by:
cancelEditin 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:DataGridCarry out the insert action for the object. The object is already validated.- Overrides:
doInsertActionin classDataGrid<T>- Parameters:
object- Item that is newly added.
-
doUpdateAction
Description copied from class:DataGridCarry out the update action for the object. The object is already validated.- Overrides:
doUpdateActionin classDataGrid<T>- Parameters:
object- Item that is updated.
-
doDeleteAction
Description copied from class:DataGridCarry out the delete action for the object. The object is already validated.- Overrides:
doDeleteActionin classDataGrid<T>- Parameters:
object- Item that is deleted.
-
doUndeleteAction
Description copied from class:DataGridCarry out the undelete action for the object. The object is already validated.- Overrides:
doUndeleteActionin classDataGrid<T>- Parameters:
object- Item that is undeleted.
-
doReloadAction
Description copied from class:DataGridCarry out the reload action for the object. The object is already validated.- Overrides:
doReloadActionin classDataGrid<T>- Parameters:
object- Item that is undeleted.
-
doReloadAllAction
protected void doReloadAllAction()Description copied from class:DataGridCarry out the "reload all" action. All validations are already done before invoking this.- Overrides:
doReloadAllActionin classDataGrid<T>
-