E
- row item typepublic interface Table<E extends Entity> extends ListComponent<E>, Component.Editable, HasSettings, HasDataLoadingSettings, HasButtonsPanel, HasPresentations, Component.HasCaption, HasContextHelp, Component.HasIcon, HasRowsCount, LookupComponent<E>, Component.Focusable, RowsCount.RowsCountTarget, HasSubParts, HasHtmlCaption, HasHtmlDescription
Modifier and Type | Interface and Description |
---|---|
static class |
Table.AggregationDistributionContext<E>
Object that contains information about aggregation distribution.
|
static interface |
Table.AggregationDistributionProvider<E>
Allows to handle a group or total aggregation value changes.
|
static class |
Table.AggregationStyle |
static class |
Table.CellClickEvent<T extends Entity> |
static interface |
Table.CellClickListener<T extends Entity>
Deprecated.
Use
setCellClickListener(String, Consumer) instead. |
static class |
Table.Column<T extends Entity> |
static class |
Table.ColumnAlignment |
static class |
Table.ColumnCollapseEvent<E extends Entity>
Event sent every time column collapse state changes.
|
static interface |
Table.ColumnCollapseListener
Deprecated.
Use
addColumnCollapseListener(Consumer) instead |
static interface |
Table.ColumnGenerator<E extends Entity>
Allows rendering of an arbitrary
Component inside a table cell. |
static class |
Table.PlainTextCell
Special component for generated columns which will be rendered as simple text cell.
|
static interface |
Table.Printable<E extends Entity,P>
Allows set Printable representation for column in Excel export.
|
static interface |
Table.PrintableColumnGenerator<E extends Entity,P>
Column generator, which supports print to Excel.
|
static class |
Table.RowHeaderMode |
static class |
Table.SelectionEvent<E extends Entity>
Event sent when the selection changes.
|
static class |
Table.SortDirection
Describes sorting direction.
|
static class |
Table.SortInfo |
static interface |
Table.StyleProvider<E extends Entity>
Allows to define different styles for table cells.
|
ListComponent.IconProvider<E extends Entity>
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.OptionsStyleProvider, Component.Wrapper
HasContextHelp.ContextHelpIconClickEvent
LookupComponent.LookupSelectionChangeEvent<T extends Entity>, LookupComponent.LookupSelectionChangeNotifier<T extends Entity>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE, UNITS_PERCENTAGE, UNITS_PIXELS
Modifier and Type | Method and Description |
---|---|
void |
addColumn(Table.Column<E> column)
Adds the given column to Table.
|
void |
addColumn(Table.Column<E> column,
int index)
Adds the given column at the specified index to Table.
|
default void |
addColumnCollapsedListener(Table.ColumnCollapseListener columnCollapsedListener)
Deprecated.
Use
addColumnCollapseListener(Consumer) instead |
Subscription |
addColumnCollapseListener(java.util.function.Consumer<Table.ColumnCollapseEvent> listener)
Adds a listener for column collapse events.
|
void |
addGeneratedColumn(java.lang.String columnId,
int index,
Table.ColumnGenerator<? super E> generator)
Adds a generated column at the specified index to Table.
|
void |
addGeneratedColumn(java.lang.String columnId,
Table.ColumnGenerator<? super E> generator)
Add a generated column to the table.
|
void |
addGeneratedColumn(java.lang.String columnId,
Table.ColumnGenerator<? super E> generator,
java.lang.Class<? extends Component> componentClass)
Add a generated column to the table.
|
void |
addPrintable(java.lang.String columnId,
Table.Printable<? super E,?> printable)
Adds
Table.Printable representation for column. |
Subscription |
addSelectionListener(java.util.function.Consumer<Table.SelectionEvent<E>> listener)
Registers a new selection listener
|
void |
addStyleProvider(Table.StyleProvider<? super E> styleProvider)
Add style provider for the table.
Table can use several providers to obtain many style names for cells and rows. |
default void |
addValidator(java.util.function.Consumer<?> validator)
Deprecated.
automatic validation of Table is not supported
|
default void |
addValidator(Table.Column column,
java.util.function.Consumer<?> validator)
Deprecated.
automatic validation of Table is not supported
|
Table.AggregationDistributionProvider<E> |
getAggregationDistributionProvider() |
java.util.Map<java.lang.Object,java.lang.Object> |
getAggregationResults()
Returns a map with aggregation results, where keys are table column ids and values are aggregation values.
|
Table.AggregationStyle |
getAggregationStyle() |
Table.Column<E> |
getColumn(java.lang.String id) |
boolean |
getColumnControlVisible() |
boolean |
getColumnReorderingAllowed() |
java.util.List<Table.Column<E>> |
getColumns() |
default CollectionDatasource |
getDatasource()
Deprecated.
Use
getItems() instead |
Action |
getEnterPressAction() |
InstanceContainer<E> |
getInstanceContainer(E item)
This method returns the InstanceContainer which contains the provided item.
|
Action |
getItemClickAction() |
Datasource |
getItemDatasource(Entity item)
Deprecated.
Use
getInstanceContainer(Entity) instead. |
TableItems<E> |
getItems() |
java.util.List<Table.Column> |
getNotCollapsedColumns() |
Table.Printable |
getPrintable(java.lang.String columnId)
Get
Table.Printable representation for column. |
Table.Printable |
getPrintable(Table.Column column)
Get
Table.Printable representation for column. |
int |
getRowHeaderWidth() |
Table.SortInfo |
getSortInfo() |
default java.lang.Object |
getSubPart(java.lang.String name) |
boolean |
isAggregatable() |
boolean |
isAutoScrolling() |
boolean |
isColumnHeaderVisible() |
boolean |
isContextMenuEnabled() |
boolean |
isMultiLineCells() |
boolean |
isShowSelection() |
boolean |
isShowTotalAggregation() |
boolean |
isSortable() |
boolean |
isTextSelectionEnabled() |
static <T extends Entity> |
of(java.lang.Class<T> itemClass) |
void |
refresh()
Deprecated.
refresh datasource instead
|
void |
removeClickListener(java.lang.String columnId)
Remove click listener.
|
void |
removeColumn(Table.Column<E> column)
Removes the given column from Table or do nothing if column is
null . |
void |
removeColumnCollapseListener(java.util.function.Consumer<Table.ColumnCollapseEvent> listener)
Deprecated.
Use
Subscription instead |
default void |
removeColumnCollapseListener(Table.ColumnCollapseListener columnCollapseListener)
Deprecated.
Use
addColumnCollapseListener(Consumer) instead |
void |
removeGeneratedColumn(java.lang.String columnId) |
void |
removePrintable(java.lang.String columnId)
Removes
Table.Printable representation of column. |
void |
removeStyleProvider(Table.StyleProvider<? super E> styleProvider)
Remove style provider for the table.
|
void |
repaint()
Repaint UI representation of the table (columns, generated columns) without refreshing the table data
|
void |
requestFocus(E entity,
java.lang.String columnId)
Set focus on inner field of editable/generated column.
|
void |
scrollTo(E entity)
Scroll table to specified row.
|
void |
selectAll() |
void |
setAggregatable(boolean aggregatable) |
void |
setAggregationDistributionProvider(Table.AggregationDistributionProvider<E> distributionProvider)
Set aggregation distribution provider to handle distribution of data on rows.
|
void |
setAggregationStyle(Table.AggregationStyle aggregationStyle) |
void |
setAutoScrolling(boolean autoScroll)
Enables or disables automatic scroll to a selected row after table update.
|
void |
setCellClickListener(java.lang.String columnId,
java.util.function.Consumer<Table.CellClickEvent<E>> clickListener)
Add lightweight click handler for column cells.
Web specific: cell value will be wrapped in span with cuba-table-clickable-cell style name. You can use .cuba-table-clickable-cell for CSS rules to specify custom representation of cell value. |
default void |
setClickListener(java.lang.String columnId,
Table.CellClickListener<? super E> clickListener)
Deprecated.
Use
setCellClickListener(String, Consumer) instead |
void |
setColumnControlVisible(boolean columnCollapsingAllowed) |
void |
setColumnHeaderVisible(boolean columnHeaderVisible)
Set visibility for table header
|
void |
setColumnReorderingAllowed(boolean columnReorderingAllowed) |
void |
setContextMenuEnabled(boolean contextMenuEnabled) |
default void |
setDatasource(CollectionDatasource datasource)
Deprecated.
Use
setItems(TableItems) instead |
void |
setEnterPressAction(Action action)
Assign action to be executed on Enter key press.
|
void |
setIconProvider(java.util.function.Function<? super E,java.lang.String> iconProvider)
Set the row icon provider for the table.
|
void |
setItemClickAction(Action action)
Assign action to be executed on double click inside a table row.
|
void |
setItems(TableItems<E> tableItems) |
void |
setMultiLineCells(boolean multiLineCells) |
void |
setMultiSelect(boolean multiselect) |
void |
setRequired(Table.Column<E> column,
boolean required,
java.lang.String message) |
void |
setRowHeaderMode(Table.RowHeaderMode mode) |
void |
setRowHeaderWidth(int width)
Set width of row header column.
|
void |
setShowSelection(boolean showSelection)
Hide or show selection
|
void |
setShowTotalAggregation(boolean showAggregation) |
void |
setSortable(boolean sortable) |
void |
setStyleProvider(Table.StyleProvider<? super E> styleProvider)
Set the cell style provider for the table.
All style providers added before this call will be removed. |
void |
setTextSelectionEnabled(boolean value)
Enable or disable text selection in Table cells.
|
void |
showCustomPopup(Component popupComponent)
Show popup inside of Table, relative to last cell click event.
Call this method from Table.CellClickListener implementation. |
void |
showCustomPopupActions(java.util.List<Action> actions)
Show autocloseable popup view with actions, relative to last cell click event.
Call this method from Table.CellClickListener implementation.Autocloseable means that after any click on action popup will be closed. |
void |
sort(java.lang.String columnId,
Table.SortDirection direction)
Sorts the Table data for passed column id in the chosen sort direction.
|
void |
sortBy(java.lang.Object propertyId,
boolean ascending)
Deprecated.
Use
sort(String, SortDirection) method |
getSelected, getSingleSelected, isMultiSelect, setSelected, setSelected
getFrame, setFrame
addAction, addAction, getAction, getActionNN, getActions, removeAction, removeAction, removeAllActions
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getHeightUnits, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, getWidthUnits, isEnabled, isEnabledItself, isEnabledRecursive, isResponsive, isVisible, isVisibleItself, isVisibleRecursive, removeStyleName, requestFocus, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition
isEditable, isEditableWithParent, setEditable
applyDataLoadingSettings
getButtonsPanel, setButtonsPanel
applyPresentation, applyPresentationAsDefault, getDefaultPresentationId, getPresentations, isUsePresentations, loadPresentations, resetPresentation, usePresentations
applySettings, isSettingsEnabled, saveSettings, setSettingsEnabled
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
getIcon, setIcon, setIconFromSet
getRowsCount, setRowsCount, setRowsCountTotalCountDelegate
getLookupSelectedItems, setLookupSelectHandler
focus, getTabIndex, isFocusable, setFocusable, setTabIndex
isCaptionAsHtml, setCaptionAsHtml
getCaption, setCaption
getDescription, setDescription
isDescriptionAsHtml, setDescriptionAsHtml
static final java.lang.String NAME
static <T extends Entity> com.google.common.reflect.TypeToken<Table<T>> of(java.lang.Class<T> itemClass)
java.util.List<Table.Column<E>> getColumns()
Table.Column<E> getColumn(java.lang.String id)
void addColumn(Table.Column<E> column)
column
- the column to addaddColumn(Column, int)
void addColumn(Table.Column<E> column, int index)
column
- the column to addindex
- index of a new columnaddColumn(Column)
void removeColumn(Table.Column<E> column)
null
.column
- the column to removejava.util.Map<java.lang.Object,java.lang.Object> getAggregationResults()
void setItems(TableItems<E> tableItems)
TableItems<E> getItems()
getItems
in interface ListComponent<E extends Entity>
@Deprecated default void setDatasource(CollectionDatasource datasource)
setItems(TableItems)
insteaddatasource
- datasource@Deprecated default CollectionDatasource getDatasource()
getItems()
insteadgetDatasource
in interface ListComponent<E extends Entity>
void setRequired(Table.Column<E> column, boolean required, java.lang.String message)
@Deprecated default void addValidator(Table.Column column, java.util.function.Consumer<?> validator)
@Deprecated default void addValidator(java.util.function.Consumer<?> validator)
void setTextSelectionEnabled(boolean value)
boolean isTextSelectionEnabled()
void setItemClickAction(Action action)
If such action is not set, the table responds to double click by trying to find and execute the following actions:
shortcut
propertyAction getItemClickAction()
void setEnterPressAction(Action action)
If such action is not set, the table responds to pressing Enter by trying to find and execute the following actions:
setItemClickAction(Action)
shortcut
propertyAction getEnterPressAction()
java.util.List<Table.Column> getNotCollapsedColumns()
void setSortable(boolean sortable)
boolean isSortable()
void setAutoScrolling(boolean autoScroll)
boolean isAutoScrolling()
void setAggregatable(boolean aggregatable)
boolean isAggregatable()
void setShowTotalAggregation(boolean showAggregation)
boolean isShowTotalAggregation()
void setColumnReorderingAllowed(boolean columnReorderingAllowed)
boolean getColumnReorderingAllowed()
void setColumnControlVisible(boolean columnCollapsingAllowed)
boolean getColumnControlVisible()
void requestFocus(E entity, java.lang.String columnId)
entity
- entitycolumnId
- column idvoid scrollTo(E entity)
entity
- entity@Deprecated void sortBy(java.lang.Object propertyId, boolean ascending)
sort(String, SortDirection)
methodtable.sortBy(table.getDatasource().getMetaClass().getPropertyPath("name"), ascending);
propertyId
- column indicated by a corresponding MetaPropertyPath
objectascending
- sort directionvoid sort(java.lang.String columnId, Table.SortDirection direction)
columnId
- id of the column to sortdirection
- sort direction@Nullable Table.SortInfo getSortInfo()
void selectAll()
boolean isMultiLineCells()
void setMultiLineCells(boolean multiLineCells)
boolean isContextMenuEnabled()
void setContextMenuEnabled(boolean contextMenuEnabled)
void setRowHeaderWidth(int width)
width
- width of row header column in pxint getRowHeaderWidth()
void setMultiSelect(boolean multiselect)
@Deprecated void refresh()
void repaint()
@Nullable default java.lang.Object getSubPart(java.lang.String name)
getSubPart
in interface ActionsHolder
getSubPart
in interface HasSubParts
@Deprecated default void addColumnCollapsedListener(Table.ColumnCollapseListener columnCollapsedListener)
addColumnCollapseListener(Consumer)
insteadcolumnCollapsedListener
- a listener to add@Deprecated default void removeColumnCollapseListener(Table.ColumnCollapseListener columnCollapseListener)
addColumnCollapseListener(Consumer)
insteadcolumnCollapseListener
- a listener to removeSubscription addColumnCollapseListener(java.util.function.Consumer<Table.ColumnCollapseEvent> listener)
listener
- a listener to addSubscription
object@Deprecated void removeColumnCollapseListener(java.util.function.Consumer<Table.ColumnCollapseEvent> listener)
Subscription
insteadlistener
- a listener to removevoid setRowHeaderMode(Table.RowHeaderMode mode)
void setAggregationStyle(Table.AggregationStyle aggregationStyle)
Table.AggregationStyle getAggregationStyle()
void setStyleProvider(@Nullable Table.StyleProvider<? super E> styleProvider)
void addStyleProvider(Table.StyleProvider<? super E> styleProvider)
void removeStyleProvider(Table.StyleProvider<? super E> styleProvider)
void setIconProvider(java.util.function.Function<? super E,java.lang.String> iconProvider)
setRowHeaderWidth(int)
@Deprecated Datasource getItemDatasource(Entity item)
getInstanceContainer(Entity)
instead.
modelsTable.addGeneratedColumn(
"numberOfSeats",
new Table.ColumnGenerator<Model>() {
public Component generateCell(Model entity) {
LookupField lookupField = componentsFactory.createComponent(LookupField.NAME);
lookupField.setDatasource(modelsTable.getItemDatasource(entity), "numberOfSeats");
lookupField.setOptionsList(Arrays.asList(2, 4, 5));
lookupField.setWidth("100px");
return lookupField;
}
}
);
item
- entity itemInstanceContainer<E> getInstanceContainer(E item)
carsTable.addGeneratedColumn("name", car -> {
TextField<String> textField = uiComponents.create(TextField.NAME);
textField.setValueSource(new ContainerValueSource<>(carsTable.getInstanceContainer(car),"name"));
textField.setValue(car.getName());
return textField;
});
item
- entity itemvoid addGeneratedColumn(java.lang.String columnId, Table.ColumnGenerator<? super E> generator)
columnId
- column identifier as defined in XML descriptor. May or may not correspond to an entity property.generator
- column generator instancevoid addGeneratedColumn(java.lang.String columnId, int index, Table.ColumnGenerator<? super E> generator)
columnId
- column identifier as defined in XML descriptor. May correspond to an entity propertyindex
- index of a new columngenerator
- column generator instancevoid addGeneratedColumn(java.lang.String columnId, Table.ColumnGenerator<? super E> generator, java.lang.Class<? extends Component> componentClass)
columnId
- column identifier as defined in XML descriptor. May or may not correspond to an entity property.generator
- column generator instancecomponentClass
- class of components that generator will providevoid removeGeneratedColumn(java.lang.String columnId)
void addPrintable(java.lang.String columnId, Table.Printable<? super E,?> printable)
Table.Printable
representation for column. columnId
- column idprintable
- printable representationvoid removePrintable(java.lang.String columnId)
Table.Printable
representation of column. columnId
- column id@Nullable Table.Printable getPrintable(Table.Column column)
Table.Printable
representation for column.column
- table column@Nullable Table.Printable getPrintable(java.lang.String columnId)
Table.Printable
representation for column.columnId
- column id@Deprecated default void setClickListener(java.lang.String columnId, Table.CellClickListener<? super E> clickListener)
setCellClickListener(String, Consumer)
insteadcolumnId
- id of columnclickListener
- click listenervoid setCellClickListener(java.lang.String columnId, java.util.function.Consumer<Table.CellClickEvent<E>> clickListener)
columnId
- id of columnclickListener
- click listenervoid removeClickListener(java.lang.String columnId)
columnId
- id of columnvoid setAggregationDistributionProvider(Table.AggregationDistributionProvider<E> distributionProvider)
distributionProvider
- distribution providerTable.AggregationDistributionProvider<E> getAggregationDistributionProvider()
void showCustomPopup(Component popupComponent)
Table.CellClickListener
implementation.popupComponent
- popup contentvoid showCustomPopupActions(java.util.List<Action> actions)
Table.CellClickListener
implementation.actions
- actionsvoid setColumnHeaderVisible(boolean columnHeaderVisible)
boolean isColumnHeaderVisible()
void setShowSelection(boolean showSelection)
boolean isShowSelection()
Subscription addSelectionListener(java.util.function.Consumer<Table.SelectionEvent<E>> listener)
listener
- the listener to register