com.vaadin.ui.
Class Table
java.lang.Object
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractField
com.vaadin.ui.AbstractSelect
com.vaadin.ui.Table
All Implemented Interfaces:
Buffered, BufferedValidatable, Container, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Sortable, Container.Viewer, Property, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.Container, Action.ShortcutNotifier, DragSource, DropTarget, ItemClickEvent.ItemClickNotifier, ItemClickEvent.ItemClickSource, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener
Direct Known Subclasses:
- extends AbstractSelect
- implements Action.Container, Container.Ordered, Container.Sortable, ItemClickEvent.ItemClickSource, ItemClickEvent.ItemClickNotifier, DragSource, DropTarget
public class Table
Table
is used for representing data or components in a pageable
and selectable table.
Scalability of the Table is largely dictated by the container. A table does not have a limit for the number of items and is just as fast with hundreds of thousands of items as with just a few. The current GWT implementation with scrolling however limits the number of rows to around 500000, depending on the browser and the pixel height of rows.
Components in a Table will not have their caption nor icon rendered.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Nested Class Summary | |
---|---|
static class |
Table.CacheUpdateException
Exception thrown when one or more exceptions occurred during updating of the Table cache. |
static interface |
Table.CellStyleGenerator
Allow to define specific style on cells (and rows) contents. |
static interface |
Table.ColumnGenerator
Used to create "generated columns"; columns that exist only in the Table, not in the underlying Container. |
static class |
Table.ColumnReorderEvent
This event is fired when a columns are reordered by the end user user. |
static interface |
Table.ColumnReorderListener
Interface for listening to column reorder events. |
static class |
Table.ColumnResizeEvent
This event is fired when a column is resized. |
static interface |
Table.ColumnResizeListener
Interface for listening to column resize events. |
static class |
Table.FooterClickEvent
Click event fired when clicking on the Table footers. |
static interface |
Table.FooterClickListener
Interface for the listener for column footer mouse click events. |
static class |
Table.GeneratedRow
|
static class |
Table.HeaderClickEvent
Click event fired when clicking on the Table headers. |
static interface |
Table.HeaderClickListener
Interface for the listener for column header mouse click events. |
static interface |
Table.RowGenerator
Row generators can be used to replace certain items in a table with a generated string. |
static class |
Table.TableDragMode
Modes that Table support as drag sourse. |
static class |
Table.TableDropCriterion
Lazy loading accept criterion for Table. |
class |
Table.TableTransferable
Concrete implementation of DataBoundTransferable for data
transferred from a table. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField |
---|
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable |
---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable |
---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Nested classes/interfaces inherited from interface com.vaadin.ui.Field |
---|
Field.ValueChangeEvent |
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered |
---|
Buffered.SourceException |
Nested classes/interfaces inherited from interface com.vaadin.data.Property |
---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Field Summary | |
---|---|
static String |
ALIGN_CENTER
Center column alignment. |
static String |
ALIGN_LEFT
Left column alignment. |
static String |
ALIGN_RIGHT
Right column alignment. |
protected boolean |
alwaysRecalculateColumnWidths
|
protected static int |
CELL_FIRSTCOL
|
protected static int |
CELL_GENERATED_ROW
|
protected static int |
CELL_HEADER
|
protected static int |
CELL_ICON
|
protected static int |
CELL_ITEMID
|
protected static int |
CELL_KEY
|
static int |
COLUMN_HEADER_MODE_EXPLICIT
Column header mode: Column headers are explicitly specified with setColumnHeaders(String[]) . |
static int |
COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
Column header mode: Column headers are explicitly specified with setColumnHeaders(String[]) . |
static int |
COLUMN_HEADER_MODE_HIDDEN
Column header mode: Column headers are hidden. |
static int |
COLUMN_HEADER_MODE_ID
Column header mode: Property ID:s are used as column headers. |
static int |
ROW_HEADER_MODE_EXPLICIT
Row caption mode: Item captions are explicitly specified. |
static int |
ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID
Row caption mode: Item captions are explicitly specified, but if the caption is missing, the item id objects toString() is used
instead. |
static int |
ROW_HEADER_MODE_HIDDEN
Row caption mode: The row headers are hidden. |
static int |
ROW_HEADER_MODE_ICON_ONLY
Row caption mode: Only icons are shown, the captions are hidden. |
static int |
ROW_HEADER_MODE_ID
Row caption mode: Items Id-objects toString is used as row caption. |
static int |
ROW_HEADER_MODE_INDEX
Row caption mode: Index of the item is used as item caption. |
static int |
ROW_HEADER_MODE_ITEM
Row caption mode: Item-objects toString is used as row caption. |
static int |
ROW_HEADER_MODE_PROPERTY
Row caption mode: Item captions are read from property specified with AbstractSelect.setItemCaptionPropertyId(Object) . |
Fields inherited from class com.vaadin.ui.AbstractSelect |
---|
ITEM_CAPTION_MODE_EXPLICIT, ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID, ITEM_CAPTION_MODE_ICON_ONLY, ITEM_CAPTION_MODE_ID, ITEM_CAPTION_MODE_INDEX, ITEM_CAPTION_MODE_ITEM, ITEM_CAPTION_MODE_PROPERTY, itemIdMapper, items |
Fields inherited from interface com.vaadin.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
Fields inherited from interface com.vaadin.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
Constructor Summary | |
---|---|
Table()
Creates a new empty table. |
|
Table(String caption)
Creates a new empty table with caption. |
|
Table(String caption,
Container dataSource)
Creates a new table with caption and connect it to a Container. |
Method Summary | |
---|---|
void |
addActionHandler(Action.Handler actionHandler)
Registers a new action handler for this container |
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Adds a new property to the table and show it as a visible column. |
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue,
String columnHeader,
Resource columnIcon,
String columnAlignment)
Adds a new property to the table and show it as a visible column. |
void |
addGeneratedColumn(Object id,
Table.ColumnGenerator generatedColumn)
Adds a generated column to the Table. |
Object |
addItem(Object[] cells,
Object itemId)
Adds the new row to table and fill the visible cells (except generated columns) with given values. |
Object |
addItemAfter(Object previousItemId)
Adds new item after the given item. |
Item |
addItemAfter(Object previousItemId,
Object newItemId)
Adds new item after the given item. |
void |
addListener(ItemClickEvent.ItemClickListener listener)
Register a listener to handle ItemClickEvent s. |
void |
addListener(Table.ColumnReorderListener listener)
Adds a column reorder listener to the Table. |
void |
addListener(Table.ColumnResizeListener listener)
Adds a column resize listener to the Table. |
void |
addListener(Table.FooterClickListener listener)
Adds a footer click listener which handles the click events when the user clicks on a column footer cell in the Table. |
void |
addListener(Table.HeaderClickListener listener)
Adds a header click listener which handles the click events when the user clicks on a column header cell in the Table. |
void |
attach()
Notifies the component that it is connected to an application. |
protected void |
bindPropertyToField(Object rowId,
Object colId,
Property property,
Field field)
Binds an item property to a field generated by TableFieldFactory. |
void |
changeVariables(Object source,
Map<String,Object> variables)
Invoked when the value of a variable has changed. |
void |
containerItemSetChange(Container.ItemSetChangeEvent event)
Container datasource item set change. |
void |
containerPropertySetChange(Container.PropertySetChangeEvent event)
Container datasource property set change. |
void |
detach()
Notifies the component that it is detached from the application |
protected boolean |
disableContentRefreshing()
Go to mode where content updates are not done. |
protected void |
enableContentRefreshing(boolean refreshContent)
Go to mode where content content refreshing has effect. |
Object |
firstItemId()
Gets the ID of the first Item in the Container. |
protected String |
formatPropertyValue(Object rowId,
Object colId,
Property property)
Formats table cell property values. |
protected int |
getAddedRowCount()
Subclass and override this to enable partial row additions, bypassing the normal caching mechanism. |
double |
getCacheRate()
|
Table.CellStyleGenerator |
getCellStyleGenerator()
Get the current cell style generator. |
String |
getColumnAlignment(Object propertyId)
Gets the specified column's alignment. |
String[] |
getColumnAlignments()
Gets the array of column alignments. |
float |
getColumnExpandRatio(Object propertyId)
Gets the column expand ratio for a columnd. |
String |
getColumnFooter(Object propertyId)
Gets the footer caption beneath the rows |
Table.ColumnGenerator |
getColumnGenerator(Object columnId)
Returns the ColumnGenerator used to generate the given column. |
String |
getColumnHeader(Object propertyId)
Gets the header for the specified column. |
int |
getColumnHeaderMode()
Getter for property columnHeaderMode. |
String[] |
getColumnHeaders()
Gets the headers of the columns. |
Resource |
getColumnIcon(Object propertyId)
Gets the icon Resource for the specified column. |
Resource[] |
getColumnIcons()
Gets the icons of the columns. |
int |
getColumnWidth(Object propertyId)
Gets the pixel width of column |
Object |
getCurrentPageFirstItemId()
Getter for property currentPageFirstItem. |
int |
getCurrentPageFirstItemIndex()
Getter for property currentPageFirstItem. |
Table.TableDragMode |
getDragMode()
|
DropHandler |
getDropHandler()
|
FieldFactory |
getFieldFactory()
Deprecated. use getTableFieldFactory() instead |
protected int |
getFirstAddedItemIndex()
Subclass and override this to enable partial row additions, bypassing the normal caching mechanism. |
protected int |
getFirstUpdatedItemIndex()
Subclass and override this to enable partial row updates, bypassing the normal caching and lazy loading mechanism. |
protected Object |
getIdByIndex(int index)
|
AbstractSelect.ItemDescriptionGenerator |
getItemDescriptionGenerator()
Get the item description generator which generates tooltips for cells and rows in the Table. |
AbstractSelect.MultiSelectMode |
getMultiSelectMode()
Returns the select mode in which multi-select is used. |
int |
getPageLength()
Gets the page length. |
protected Object |
getPropertyValue(Object rowId,
Object colId,
Property property)
Gets the value of property. |
Table.RowGenerator |
getRowGenerator()
|
int |
getRowHeaderMode()
Gets the row header mode. |
Collection<?> |
getSortableContainerPropertyIds()
Gets the container property IDs, which can be used to sort the item. |
Object |
getSortContainerPropertyId()
Gets the currently sorted column property ID. |
TableFieldFactory |
getTableFieldFactory()
Gets the TableFieldFactory that is used to create editor for table cells. |
Table.TableTransferable |
getTransferable(Map<String,Object> rawVariables)
DragSource may convert data added by client side component to meaningful values for server side developer or add other data based on it. |
protected int |
getUpdatedRowCount()
Subclass and override this to enable partial row updates, bypassing the normal caching and lazy loading mechanism. |
Object[] |
getVisibleColumns()
Gets the array of visible column id:s, including generated columns. |
Collection<?> |
getVisibleItemIds()
Returns item identifiers of the items which are currently rendered on the client. |
protected int |
indexOfId(Object itemId)
|
boolean |
isColumnCollapsed(Object propertyId)
Checks if the specified column is collapsed. |
boolean |
isColumnCollapsible(Object propertyId)
Checks if the given column is collapsible. |
boolean |
isColumnCollapsingAllowed()
Checks if column collapsing is allowed. |
boolean |
isColumnReorderingAllowed()
Checks if column reordering is allowed. |
boolean |
isEditable()
Is table editable. |
boolean |
isFirstId(Object itemId)
Tests if the Item corresponding to the given Item ID is the first Item in the Container. |
boolean |
isFooterVisible()
Is the footer currently visible? |
boolean |
isLastId(Object itemId)
Tests if the Item corresponding to the given Item ID is the last Item in the Container. |
boolean |
isPageBufferingEnabled()
Deprecated. functionality is not needed in ajax rendering model |
protected boolean |
isPartialRowUpdate()
Subclass and override this to enable partial row updates and additions, which bypass the normal caching mechanism. |
protected boolean |
isRowCacheInvalidated()
|
boolean |
isSelectable()
Getter for property selectable. |
boolean |
isSortAscending()
Is the table currently sorted in ascending order. |
boolean |
isSortDisabled()
Is sorting disabled altogether. |
Object |
lastItemId()
Gets the ID of the last Item in the Container. |
Object |
nextItemId(Object itemId)
Gets the ID of the Item following the Item that corresponds to itemId. |
void |
paintContent(PaintTarget target)
Paints the content of this component. |
protected void |
paintRowAttributes(PaintTarget target,
Object itemId)
A method where extended Table implementations may add their custom attributes for rows. |
protected void |
paintRowHeader(PaintTarget target,
Object[][] cells,
int indexInRowbuffer)
|
protected void |
paintRowIcon(PaintTarget target,
Object[][] cells,
int indexInRowbuffer)
|
Object |
prevItemId(Object itemId)
Gets the ID of the Item preceding the Item that corresponds to the itemId. |
void |
refreshCurrentPage()
Deprecated. should not need to be used |
protected void |
refreshRenderedCells()
Refreshes the rows in the internal cache. |
void |
refreshRowCache()
Discards and recreates the internal row cache. |
protected void |
registerComponent(Component component)
|
void |
removeActionHandler(Action.Handler actionHandler)
Removes a previously registered action handler for the contents of this container. |
void |
removeAllActionHandlers()
Removes all action handlers |
boolean |
removeAllItems()
Removes all Items from the Container. |
boolean |
removeContainerProperty(Object propertyId)
Removes a Property specified by the given Property ID from the Container. |
boolean |
removeGeneratedColumn(Object columnId)
Removes a generated column previously added with addGeneratedColumn. |
boolean |
removeItem(Object itemId)
Removes the Item identified by ItemId from the Container. |
void |
removeListener(ItemClickEvent.ItemClickListener listener)
Removes an ItemClickListener. |
void |
removeListener(Table.ColumnReorderListener listener)
Removes a column reorder listener from the Table. |
void |
removeListener(Table.ColumnResizeListener listener)
Removes a column resize listener from the Table. |
void |
removeListener(Table.FooterClickListener listener)
Removes a footer click listener |
void |
removeListener(Table.HeaderClickListener listener)
Removes a header click listener |
void |
requestRepaint()
Requests that the Table should be repainted as soon as possible. |
void |
requestRepaintAll()
|
protected void |
resetPageBuffer()
Clears the current page buffer. |
void |
setCacheRate(double cacheRate)
This method adjusts a possible caching mechanism of table implementation. |
void |
setCellStyleGenerator(Table.CellStyleGenerator cellStyleGenerator)
Set cell style generator for Table. |
void |
setColumnAlignment(Object propertyId,
String alignment)
Sets the specified column's alignment. |
void |
setColumnAlignments(String[] columnAlignments)
Sets the column alignments. |
void |
setColumnCollapsed(Object propertyId,
boolean collapsed)
Sets whether the specified column is collapsed or not. |
void |
setColumnCollapsible(Object propertyId,
boolean collapsible)
Sets whether the given column is collapsible. |
void |
setColumnCollapsingAllowed(boolean collapsingAllowed)
Sets whether column collapsing is allowed or not. |
void |
setColumnExpandRatio(Object propertyId,
float expandRatio)
Sets the column expand ratio for given column. |
void |
setColumnFooter(Object propertyId,
String footer)
Sets the column footer caption. |
void |
setColumnHeader(Object propertyId,
String header)
Sets the column header for the specified column; |
void |
setColumnHeaderMode(int columnHeaderMode)
Setter for property columnHeaderMode. |
void |
setColumnHeaders(String[] columnHeaders)
Sets the headers of the columns. |
void |
setColumnIcon(Object propertyId,
Resource icon)
Sets the icon Resource for the specified column. |
void |
setColumnIcons(Resource[] columnIcons)
Sets the icons of the columns. |
void |
setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether column reordering is allowed or not. |
void |
setColumnWidth(Object propertyId,
int width)
Sets columns width (in pixels). |
void |
setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer. |
void |
setCurrentPageFirstItemId(Object currentPageFirstItemId)
Setter for property currentPageFirstItemId. |
void |
setCurrentPageFirstItemIndex(int newIndex)
Setter for property currentPageFirstItem. |
void |
setDragMode(Table.TableDragMode newDragMode)
Sets the drag start mode of the Table. |
void |
setDropHandler(DropHandler dropHandler)
|
void |
setEditable(boolean editable)
Sets the editable property. |
void |
setEnabled(boolean enabled)
Enables or disables the component. |
void |
setFieldFactory(FieldFactory fieldFactory)
Deprecated. use setTableFieldFactory(TableFieldFactory) instead |
void |
setFooterVisible(boolean visible)
Sets the footer visible in the bottom of the table. |
void |
setItemDescriptionGenerator(AbstractSelect.ItemDescriptionGenerator generator)
Set the item description generator which generates tooltips for cells and rows in the Table |
void |
setLazyLoading(boolean useLazyLoading)
Table does not support lazy options loading mode. |
void |
setMultiSelectMode(AbstractSelect.MultiSelectMode mode)
Sets the behavior of how the multi-select mode should behave when the table is both selectable and in multi-select mode. |
void |
setNewItemsAllowed(boolean allowNewOptions)
Adding new items is not supported. |
void |
setPageBufferingEnabled(boolean pageBuffering)
Deprecated. functionality is not needed in ajax rendering model |
void |
setPageLength(int pageLength)
Sets the page length. |
void |
setRowGenerator(Table.RowGenerator generator)
Assigns a row generator to the table. |
void |
setRowHeaderMode(int mode)
Sets the row header mode. |
void |
setSelectable(boolean selectable)
Setter for property selectable. |
void |
setSortAscending(boolean ascending)
Sets the table in ascending order. |
void |
setSortContainerPropertyId(Object propertyId)
Sets the currently sorted column property id. |
void |
setSortDisabled(boolean sortDisabled)
Disables the sorting altogether. |
void |
setTableFieldFactory(TableFieldFactory fieldFactory)
Sets the TableFieldFactory that is used to create editor for table cells. |
void |
setValue(Object newValue)
Sets the visible value of the property. |
void |
setVisible(boolean visible)
Sets the visibility of the component. |
void |
setVisibleColumns(Object[] visibleColumns)
Sets the array of visible column property id:s. |
protected boolean |
shouldHideAddedRows()
Subclass and override this to enable removing of rows, bypassing the normal caching and lazy loading mechanism. |
void |
sort()
Sorts the table by currently selected sorting column. |
void |
sort(Object[] propertyId,
boolean[] ascending)
Sorts the table. |
AbstractSelect.AbstractSelectTargetDetails |
translateDropTargetDetails(Map<String,Object> clientVariables)
Called before the DragAndDropEvent is passed to
DropHandler . |
protected void |
unregisterComponent(Component component)
This method cleans up a Component that has been generated when Table is in editable mode. |
void |
valueChange(Property.ValueChangeEvent event)
Notifies this listener that the Property's value has changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setIcon, setParent, setReadOnly, setStyleName |
Methods inherited from interface com.vaadin.terminal.Paintable |
---|
addListener, getDebugId, paint, removeListener, requestRepaintRequests, setDebugId |
Methods inherited from interface com.vaadin.terminal.VariableOwner |
---|
isImmediate |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setIcon, setParent, setReadOnly, setStyleName |
Methods inherited from interface com.vaadin.terminal.Paintable |
---|
addListener, getDebugId, paint, removeListener, requestRepaintRequests, setDebugId |
Methods inherited from interface com.vaadin.terminal.VariableOwner |
---|
isImmediate |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Methods inherited from interface com.vaadin.ui.Field |
---|
getDescription, setCaption, setDescription |
Field Detail |
---|
CELL_KEY
protected static final int CELL_KEY
See Also:
CELL_HEADER
protected static final int CELL_HEADER
See Also:
CELL_ICON
protected static final int CELL_ICON
See Also:
CELL_ITEMID
protected static final int CELL_ITEMID
See Also:
CELL_GENERATED_ROW
protected static final int CELL_GENERATED_ROW
See Also:
CELL_FIRSTCOL
protected static final int CELL_FIRSTCOL
See Also:
ALIGN_LEFT
public static final String ALIGN_LEFT
- See Also:
- Constant Field Values
Left column alignment. This is the default behaviour.
ALIGN_CENTER
public static final String ALIGN_CENTER
- See Also:
- Constant Field Values
Center column alignment.
ALIGN_RIGHT
public static final String ALIGN_RIGHT
- See Also:
- Constant Field Values
Right column alignment.
COLUMN_HEADER_MODE_HIDDEN
public static final int COLUMN_HEADER_MODE_HIDDEN
- See Also:
- Constant Field Values
Column header mode: Column headers are hidden.
COLUMN_HEADER_MODE_ID
public static final int COLUMN_HEADER_MODE_ID
- See Also:
- Constant Field Values
Column header mode: Property ID:s are used as column headers.
COLUMN_HEADER_MODE_EXPLICIT
public static final int COLUMN_HEADER_MODE_EXPLICIT
- See Also:
- Constant Field Values
Column header mode: Column headers are explicitly specified with
setColumnHeaders(String[])
.
COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
public static final int COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
- See Also:
- Constant Field Values
Column header mode: Column headers are explicitly specified with
setColumnHeaders(String[])
. If a header is not specified for a
given property, its property id is used instead.
This is the default behavior.
ROW_HEADER_MODE_HIDDEN
public static final int ROW_HEADER_MODE_HIDDEN
- See Also:
- Constant Field Values
Row caption mode: The row headers are hidden. This is the default mode.
ROW_HEADER_MODE_ID
public static final int ROW_HEADER_MODE_ID
- See Also:
- Constant Field Values
Row caption mode: Items Id-objects toString is used as row caption.
ROW_HEADER_MODE_ITEM
public static final int ROW_HEADER_MODE_ITEM
- See Also:
- Constant Field Values
Row caption mode: Item-objects toString is used as row caption.
ROW_HEADER_MODE_INDEX
public static final int ROW_HEADER_MODE_INDEX
- See Also:
- Constant Field Values
Row caption mode: Index of the item is used as item caption. The index mode can only be used with the containers implementing Container.Indexed interface.
ROW_HEADER_MODE_EXPLICIT
public static final int ROW_HEADER_MODE_EXPLICIT
- See Also:
- Constant Field Values
Row caption mode: Item captions are explicitly specified.
ROW_HEADER_MODE_PROPERTY
public static final int ROW_HEADER_MODE_PROPERTY
- See Also:
- Constant Field Values
Row caption mode: Item captions are read from property specified with
AbstractSelect.setItemCaptionPropertyId(Object)
.
ROW_HEADER_MODE_ICON_ONLY
public static final int ROW_HEADER_MODE_ICON_ONLY
- See Also:
- Constant Field Values
Row caption mode: Only icons are shown, the captions are hidden.
ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID
public static final int ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID
- See Also:
- Constant Field Values
Row caption mode: Item captions are explicitly specified, but if the
caption is missing, the item id objects toString()
is used
instead.
alwaysRecalculateColumnWidths
protected boolean alwaysRecalculateColumnWidths
Constructor Detail |
---|
Table
public Table()
Creates a new empty table.
Table
public Table(String caption)
- Parameters:
caption
-
Creates a new empty table with caption.
Table
public Table(String caption,
Container dataSource)
- Parameters:
caption
-dataSource
-
Creates a new table with caption and connect it to a Container.
Method Detail |
---|
getVisibleColumns
public Object[] getVisibleColumns()
- Returns:
- an array of currently visible propertyIds and generated column ids.
Gets the array of visible column id:s, including generated columns.
The columns are show in the order of their appearance in this array.
setVisibleColumns
public void setVisibleColumns(Object[] visibleColumns)
- Parameters:
visibleColumns
- the Array of shown property id:s.
Sets the array of visible column property id:s.
The columns are show in the order of their appearance in this array.
getColumnHeaders
public String[] getColumnHeaders()
- Returns:
- the Array of column headers.
Gets the headers of the columns.
The headers match the property id:s given my the set visible column
headers. The table must be set in either
COLUMN_HEADER_MODE_EXPLICIT
or
COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
mode to show the
headers. In the defaults mode any nulls in the headers array are replaced
with id.toString().
setColumnHeaders
public void setColumnHeaders(String[] columnHeaders)
- Parameters:
columnHeaders
- the Array of column headers that match thegetVisibleColumns()
method.
Sets the headers of the columns.
The headers match the property id:s given my the set visible column
headers. The table must be set in either
COLUMN_HEADER_MODE_EXPLICIT
or
COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
mode to show the
headers. In the defaults mode any nulls in the headers array are replaced
with id.toString() outputs when rendering.
getColumnIcons
public Resource[] getColumnIcons()
- Returns:
- the Array of icons that match the
getVisibleColumns()
.
Gets the icons of the columns.
The icons in headers match the property id:s given my the set visible
column headers. The table must be set in either
COLUMN_HEADER_MODE_EXPLICIT
or
COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
mode to show the headers
with icons.
setColumnIcons
public void setColumnIcons(Resource[] columnIcons)
- Parameters:
columnIcons
- the Array of icons that match thegetVisibleColumns()
.
Sets the icons of the columns.
The icons in headers match the property id:s given my the set visible
column headers. The table must be set in either
COLUMN_HEADER_MODE_EXPLICIT
or
COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
mode to show the headers
with icons.
getColumnAlignments
public String[] getColumnAlignments()
ALIGN_LEFT
: Left alignmentALIGN_CENTER
: CenteredALIGN_RIGHT
: Right alignment- Returns:
- the Column alignments array.
Gets the array of column alignments.
The items in the array must match the properties identified by
getVisibleColumns()
. The possible values for the alignments
include:
ALIGN_LEFT
: any null values are
rendered as align lefts.
setColumnAlignments
public void setColumnAlignments(String[] columnAlignments)
ALIGN_LEFT
: Left alignmentALIGN_CENTER
: CenteredALIGN_RIGHT
: Right alignment- Parameters:
columnAlignments
- the Column alignments array.
Sets the column alignments.
The items in the array must match the properties identified by
getVisibleColumns()
. The possible values for the alignments
include:
ALIGN_LEFT
setColumnWidth
public void setColumnWidth(Object propertyId,
int width)
- Parameters:
propertyId
- colunmns property idwidth
- width to be reserved for colunmns content- Since:
- 4.0.3
Sets columns width (in pixels). Theme may not necessary respect very small or very big values. Setting width to -1 (default) means that theme will make decision of width.
Column can either have a fixed width or expand ratio. The latter one set
is used. See @link setColumnExpandRatio(Object, float)
.
setColumnExpandRatio
public void setColumnExpandRatio(Object propertyId,
float expandRatio)
- Parameters:
propertyId
- columns property idexpandRatio
- the expandRatio used to divide excess space for this column
Sets the column expand ratio for given column.
Expand ratios can be defined to customize the way how excess space is
divided among columns. Table can have excess space if it has its width
defined and there is horizontally more space than columns consume
naturally. Excess space is the space that is not used by columns with
explicit width (see setColumnWidth(Object, int)
) or with natural
width (no width nor expand ratio).
By default (without expand ratios) the excess space is divided proportionally to columns natural widths.
Only expand ratios of visible columns are used in final calculations.
Column can either have a fixed width or expand ratio. The latter one set is used.
A column with expand ratio is considered to be minimum width by default (if no excess space exists). The minimum width is defined by terminal implementation.
If terminal implementation supports re-sizable columns the column becomes fixed width column if users resizes the column.
getColumnExpandRatio
public float getColumnExpandRatio(Object propertyId)
- Parameters:
propertyId
- columns property id- Returns:
- the expandRatio used to divide excess space for this column
Gets the column expand ratio for a columnd. See
setColumnExpandRatio(Object, float)
getColumnWidth
public int getColumnWidth(Object propertyId)
- Parameters:
propertyId
-- Returns:
- width of column or -1 when value not set
Gets the pixel width of column
getPageLength
public int getPageLength()
- Returns:
- the Length of one page.
Gets the page length.
Setting page length 0 disables paging.
setPageLength
public void setPageLength(int pageLength)
- Parameters:
pageLength
- the length of one page.
Sets the page length.
Setting page length 0 disables paging. The page length defaults to 15.
If Table has width set (AbstractComponent.setWidth(float, int)
) the client side
may update the page length automatically the correct value.
setCacheRate
public void setCacheRate(double cacheRate)
- Parameters:
cacheRate
- a value over 0 (fastest rendering time). Higher value will cache more rows on server (smoother scrolling). Default value is 2.
This method adjusts a possible caching mechanism of table implementation.
Table component may fetch and render some rows outside visible area. With complex tables (for example containing layouts and components), the client side may become unresponsive. Setting the value lower, UI will become more responsive. With higher values scrolling in client will hit server less frequently.
The amount of cached rows will be cacheRate multiplied with pageLength (
setPageLength(int)
both below and above visible area..
getCacheRate
public double getCacheRate()
- Returns:
- the current cache rate value
- See Also:
setCacheRate(double)
getCurrentPageFirstItemId
public Object getCurrentPageFirstItemId()
- Returns:
- the Value of property currentPageFirstItem.
Getter for property currentPageFirstItem.
getIdByIndex
protected Object getIdByIndex(int index)
setCurrentPageFirstItemId
public void setCurrentPageFirstItemId(Object currentPageFirstItemId)
- Parameters:
currentPageFirstItemId
- the New value of property currentPageFirstItemId.
Setter for property currentPageFirstItemId.
indexOfId
protected int indexOfId(Object itemId)
getColumnIcon
public Resource getColumnIcon(Object propertyId)
- Parameters:
propertyId
- the propertyId indentifying the column.- Returns:
- the icon for the specified column; null if the column has no icon set, or if the column is not visible.
Gets the icon Resource for the specified column.
setColumnIcon
public void setColumnIcon(Object propertyId,
Resource icon)
- Parameters:
propertyId
- the propertyId identifying the column.icon
- the icon Resource to set.
Sets the icon Resource for the specified column.
Throws IllegalArgumentException if the specified column is not visible.
getColumnHeader
public String getColumnHeader(Object propertyId)
- Parameters:
propertyId
- the propertyId identifying the column.- Returns:
- the header for the specified column if it has one.
Gets the header for the specified column.
setColumnHeader
public void setColumnHeader(Object propertyId,
String header)
- Parameters:
propertyId
- the propertyId identifying the column.header
- the header to set.
Sets the column header for the specified column;
getColumnAlignment
public String getColumnAlignment(Object propertyId)
- Parameters:
propertyId
- the propertyID identifying the column.- Returns:
- the specified column's alignment if it as one; null otherwise.
Gets the specified column's alignment.
setColumnAlignment
public void setColumnAlignment(Object propertyId,
String alignment)
- Parameters:
propertyId
- the propertyID identifying the column.alignment
- the desired alignment.
Sets the specified column's alignment.
Throws IllegalArgumentException if the alignment is not one of the
following: ALIGN_LEFT
, ALIGN_CENTER
or
ALIGN_RIGHT
isColumnCollapsed
public boolean isColumnCollapsed(Object propertyId)
- Parameters:
propertyId
- the propertyID identifying the column.- Returns:
- true if the column is collapsed; false otherwise;
Checks if the specified column is collapsed.
setColumnCollapsed
public void setColumnCollapsed(Object propertyId,
boolean collapsed)
throws IllegalStateException
- Parameters:
propertyId
- the propertyID identifying the column.collapsed
- the desired collapsedness.- Throws:
IllegalStateException
- if column collapsing is not allowed
Sets whether the specified column is collapsed or not.
isColumnCollapsingAllowed
public boolean isColumnCollapsingAllowed()
- Returns:
- true if columns can be collapsed; false otherwise.
Checks if column collapsing is allowed.
setColumnCollapsingAllowed
public void setColumnCollapsingAllowed(boolean collapsingAllowed)
- Parameters:
collapsingAllowed
- specifies whether column collapsing is allowed.
Sets whether column collapsing is allowed or not.
setColumnCollapsible
public void setColumnCollapsible(Object propertyId,
boolean collapsible)
- Parameters:
propertyId
- the propertyID identifying the column.collapsible
- true if the column should be collapsible, false otherwise.
Sets whether the given column is collapsible. Note that collapsible
columns can only be actually collapsed (via UI or with
setColumnCollapsed()
) if
isColumnCollapsingAllowed()
is true. By default all columns are
collapsible.
isColumnCollapsible
public boolean isColumnCollapsible(Object propertyId)
- Returns:
- true if the column can be collapsed; false otherwise.
Checks if the given column is collapsible. Note that even if this method
returns true
, the column can only be actually collapsed (via
UI or with setColumnCollapsed()
) if isColumnCollapsingAllowed()
is also
true.
isColumnReorderingAllowed
public boolean isColumnReorderingAllowed()
- Returns:
- true if columns can be reordered; false otherwise.
Checks if column reordering is allowed.
setColumnReorderingAllowed
public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
- Parameters:
columnReorderingAllowed
- specifies whether column reordering is allowed.
Sets whether column reordering is allowed or not.
getCurrentPageFirstItemIndex
public int getCurrentPageFirstItemIndex()
- Returns:
- the Value of property currentPageFirstItem.
Getter for property currentPageFirstItem.
setCurrentPageFirstItemIndex
public void setCurrentPageFirstItemIndex(int newIndex)
- Parameters:
newIndex
- the New value of property currentPageFirstItem.
Setter for property currentPageFirstItem.
isPageBufferingEnabled
@Deprecated
public boolean isPageBufferingEnabled()
- Returns:
- the Value of property pageBuffering.
Deprecated. functionality is not needed in ajax rendering model
Getter for property pageBuffering.
setPageBufferingEnabled
@Deprecated
public void setPageBufferingEnabled(boolean pageBuffering)
- Parameters:
pageBuffering
- the New value of property pageBuffering.
Deprecated. functionality is not needed in ajax rendering model
Setter for property pageBuffering.
isSelectable
public boolean isSelectable()
- Returns:
- the Value of property selectable.
Getter for property selectable.
The table is not selectable by default.
setSelectable
public void setSelectable(boolean selectable)
- Parameters:
selectable
- the New value of property selectable.
Setter for property selectable.
The table is not selectable by default.
getColumnHeaderMode
public int getColumnHeaderMode()
- Returns:
- the Value of property columnHeaderMode.
Getter for property columnHeaderMode.
setColumnHeaderMode
public void setColumnHeaderMode(int columnHeaderMode)
- Parameters:
columnHeaderMode
- the New value of property columnHeaderMode.
Setter for property columnHeaderMode.
refreshRenderedCells
protected void refreshRenderedCells()
Refreshes the rows in the internal cache. Only if
resetPageBuffer()
is called before this then all values are
guaranteed to be recreated.
requestRepaint
public void requestRepaint()
- Specified by:
requestRepaint
in interfacePaintable
- Overrides:
requestRepaint
in classAbstractComponent
Requests that the Table should be repainted as soon as possible.
Note that a Table
does not necessarily repaint its contents when
this method has been called. See refreshRowCache()
for forcing
an update of the contents.
registerComponent
protected void registerComponent(Component component)
unregisterComponent
protected void unregisterComponent(Component component)
- Parameters:
oldVisibleComponents
- a set of components that should be unregistered.- See Also:
getPropertyValue(Object, Object, Property)
This method cleans up a Component that has been generated when Table is in editable mode. The component needs to be detached from its parent and if it is a field, it needs to be detached from its property data source in order to allow garbage collection to take care of removing the unused component from memory. Override this method and getPropertyValue(Object, Object, Property) with custom logic if you need to deal with buffered fields.
refreshCurrentPage
@Deprecated
public void refreshCurrentPage()
Deprecated. should not need to be used
Refreshes the current page contents.
setRowHeaderMode
public void setRowHeaderMode(int mode)
ROW_HEADER_MODE_HIDDEN
: The row captions are hidden.ROW_HEADER_MODE_ID
: Items Id-objectstoString()
is used as row caption.ROW_HEADER_MODE_ITEM
: Item-objectstoString()
is used as row caption.ROW_HEADER_MODE_PROPERTY
: Property set withAbstractSelect.setItemCaptionPropertyId(Object)
is used as row header.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID
: Items Id-objectstoString()
is used as row header. If caption is explicitly specified, it overrides the id-caption.ROW_HEADER_MODE_EXPLICIT
: The row headers must be explicitly specified.ROW_HEADER_MODE_INDEX
: The index of the item is used as row caption. The index mode can only be used with the containers implementingContainer.Indexed
interface.- Parameters:
mode
- the One of the modes listed above.
Sets the row header mode.
The mode can be one of the following ones:
ROW_HEADER_MODE_HIDDEN
getRowHeaderMode
public int getRowHeaderMode()
- Returns:
- the Row header mode.
- See Also:
setRowHeaderMode(int)
Gets the row header mode.
addItem
public Object addItem(Object[] cells,
Object itemId)
throws UnsupportedOperationException
- Parameters:
cells
- the Object array that is used for filling the visible cells new row. The types must be settable to visible column property types.itemId
- the Id the new row. If null, a new id is automatically assigned. If given, the table cant already have a item with given id.- Returns:
- Returns item id for the new row. Returns null if operation fails.
- Throws:
UnsupportedOperationException
Adds the new row to table and fill the visible cells (except generated columns) with given values.
refreshRowCache
public void refreshRowCache()
- Since:
- 6.7.2
Discards and recreates the internal row cache. Call this if you make changes that affect the rows but the information about the changes are not automatically propagated to the Table.
Do not call this e.g. if you have updated the data model through a Property. These types of changes are automatically propagated to the Table.
A typical case when this is needed is if you update a generator (e.g. CellStyleGenerator) and want to ensure that the rows are redrawn with new styles.
Note that calling this method is not cheap so avoid calling it unnecessarily.
setContainerDataSource
public void setContainerDataSource(Container newDataSource)
- Specified by:
setContainerDataSource
in interfaceContainer.Viewer
- Overrides:
setContainerDataSource
in classAbstractSelect
- Parameters:
newDataSource
- the new data source.- See Also:
Container.Viewer.setContainerDataSource(Container)
Description copied from class: AbstractSelect
Sets the Container that serves as the data source of the viewer. As a side-effect the fields value (selection) is set to null due old selection not necessary exists in new Container.
changeVariables
public void changeVariables(Object source,
Map<String,Object> variables)
- Specified by:
changeVariables
in interfaceVariableOwner
- Overrides:
changeVariables
in classAbstractSelect
- Parameters:
source
- the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.- See Also:
Select.changeVariables(java.lang.Object, java.util.Map)
Invoked when the value of a variable has changed.
disableContentRefreshing
protected boolean disableContentRefreshing()
- Returns:
- true if content refresh flag was enabled prior this call
Go to mode where content updates are not done. This is due we want to bypass expensive content for some reason (like when we know we may have other content changes on their way).
enableContentRefreshing
protected void enableContentRefreshing(boolean refreshContent)
- Parameters:
refreshContent
- true if content refresh needs to be done
Go to mode where content content refreshing has effect.
paintContent
public void paintContent(PaintTarget target)
throws PaintException
- Overrides:
paintContent
in classAbstractSelect
- Parameters:
target
- the Paint Event.- Throws:
PaintException
- if the paint operation failed.
Description copied from class: AbstractSelect
Paints the content of this component.
isRowCacheInvalidated
protected boolean isRowCacheInvalidated()
isPartialRowUpdate
protected boolean isPartialRowUpdate()
- Returns:
- true if this update is a partial row update, false if not. For plain Table it is always false.
Subclass and override this to enable partial row updates and additions, which bypass the normal caching mechanism. This is useful for e.g. TreeTable.
getFirstAddedItemIndex
protected int getFirstAddedItemIndex()
- Returns:
- The index of the first added item. For plain Table it is always 0.
Subclass and override this to enable partial row additions, bypassing the normal caching mechanism. This is useful for e.g. TreeTable, where expanding a node should only fetch and add the items inside of that node.
getAddedRowCount
protected int getAddedRowCount()
- Returns:
- the number of rows to be added, starting at the index returned by
getFirstAddedItemIndex()
. For plain Table it is always 0.
Subclass and override this to enable partial row additions, bypassing the normal caching mechanism. This is useful for e.g. TreeTable, where expanding a node should only fetch and add the items inside of that node.
shouldHideAddedRows
protected boolean shouldHideAddedRows()
- Returns:
- whether the rows to add (see
getFirstAddedItemIndex()
andgetAddedRowCount()
) should be added or hidden. For plain Table it is always false.
Subclass and override this to enable removing of rows, bypassing the
normal caching and lazy loading mechanism. This is useful for e.g.
TreeTable, when you need to hide certain rows as a node is collapsed.
This should return true if the rows pointed to by
getFirstAddedItemIndex()
and getAddedRowCount()
should
be hidden instead of added.
getFirstUpdatedItemIndex
protected int getFirstUpdatedItemIndex()
- Returns:
- the index of the first item to be updated. For plain Table it is always 0.
Subclass and override this to enable partial row updates, bypassing the normal caching and lazy loading mechanism. This is useful for updating the state of certain rows, e.g. in the TreeTable the collapsed state of a single node is updated using this mechanism.
getUpdatedRowCount
protected int getUpdatedRowCount()
- Returns:
- the number of rows to update, starting at the index returned by
getFirstUpdatedItemIndex()
. For plain table it is always 0.
Subclass and override this to enable partial row updates, bypassing the normal caching and lazy loading mechanism. This is useful for updating the state of certain rows, e.g. in the TreeTable the collapsed state of a single node is updated using this mechanism.
setValue
public void setValue(Object newValue)
throws Property.ReadOnlyException,
Property.ConversionException
- Specified by:
setValue
in interfaceProperty
- Overrides:
setValue
in classAbstractSelect
- Parameters:
newValue
- the New selected item or collection of selected items.- Throws:
Property.ReadOnlyException
- if the object is in read-only modeProperty.ConversionException
- if newValue can't be converted into the Property's native type directly or through String- See Also:
AbstractField.setValue(java.lang.Object)
Description copied from class: AbstractSelect
Sets the visible value of the property.
The value of the select is the selected item id. If the select is in multiselect-mode, the value is a set of selected item keys. In multiselect mode all collections of id:s can be assigned.
paintRowHeader
protected void paintRowHeader(PaintTarget target,
Object[][] cells,
int indexInRowbuffer)
throws PaintException
- Throws:
PaintException
paintRowIcon
protected void paintRowIcon(PaintTarget target,
Object[][] cells,
int indexInRowbuffer)
throws PaintException
- Throws:
PaintException
paintRowAttributes
protected void paintRowAttributes(PaintTarget target,
Object itemId)
throws PaintException
- Parameters:
target
-itemId
-- Throws:
PaintException
A method where extended Table implementations may add their custom attributes for rows.
getPropertyValue
protected Object getPropertyValue(Object rowId,
Object colId,
Property property)
- Parameters:
rowId
- the Id of the row (same as item Id).colId
- the Id of the column.property
- the Property to be presented.- Returns:
- Object Either formatted value or Component for field.
- See Also:
setTableFieldFactory(TableFieldFactory)
Gets the value of property. By default if the table is editable the fieldFactory is used to create editors for table cells. Otherwise formatPropertyValue is used to format the value representation.
bindPropertyToField
protected void bindPropertyToField(Object rowId,
Object colId,
Property property,
Field field)
- Parameters:
rowId
-colId
-property
-field
-- Since:
- 6.7.3
Binds an item property to a field generated by TableFieldFactory. The default behavior is to bind property straight to Field. If Property.Viewer type property (e.g. PropertyFormatter) is already set for field, the property is bound to that Property.Viewer.
formatPropertyValue
protected String formatPropertyValue(Object rowId,
Object colId,
Property property)
- Parameters:
rowId
- the Id of the row (same as item Id).colId
- the Id of the column.property
- the Property to be formatted.- Returns:
- the String representation of property and its value.
- Since:
- 3.1
Formats table cell property values. By default the property.toString() and return a empty string for null properties.
addActionHandler
public void addActionHandler(Action.Handler actionHandler)
- Specified by:
addActionHandler
in interfaceAction.Container
- Parameters:
actionHandler
- the new handler to be added.- See Also:
Action.Container.addActionHandler(Action.Handler)
Registers a new action handler for this container
removeActionHandler
public void removeActionHandler(Action.Handler actionHandler)
- Specified by:
removeActionHandler
in interfaceAction.Container
- Parameters:
actionHandler
- the handler to be removed.- See Also:
Action.Container.removeActionHandler(Action.Handler)
Removes a previously registered action handler for the contents of this container.
removeAllActionHandlers
public void removeAllActionHandlers()
Removes all action handlers
valueChange
public void valueChange(Property.ValueChangeEvent event)
- Specified by:
valueChange
in interfaceProperty.ValueChangeListener
- Overrides:
valueChange
in classAbstractField
- Parameters:
event
- the value change event telling the data source contents have changed.- See Also:
Property.ValueChangeListener.valueChange(Property.ValueChangeEvent)
Notifies this listener that the Property's value has changed. Also listens changes in rendered items to refresh content area.
resetPageBuffer
protected void resetPageBuffer()
Clears the current page buffer. Call this before
refreshRenderedCells()
to ensure that all content is updated
from the properties.
attach
public void attach()
- Specified by:
attach
in interfaceComponent
- Overrides:
attach
in classAbstractSelect
- See Also:
Component.attach()
Notifies the component that it is connected to an application.
detach
public void detach()
- Specified by:
detach
in interfaceComponent
- Overrides:
detach
in classAbstractSelect
- See Also:
Component.detach()
Notifies the component that it is detached from the application
removeAllItems
public boolean removeAllItems()
- Specified by:
removeAllItems
in interfaceContainer
- Overrides:
removeAllItems
in classAbstractSelect
- Returns:
- True if the operation succeeded.
- See Also:
Container.removeAllItems()
Removes all Items from the Container.
removeItem
public boolean removeItem(Object itemId)
- Specified by:
removeItem
in interfaceContainer
- Overrides:
removeItem
in classAbstractSelect
- Parameters:
itemId
- ID of the Item to remove- Returns:
true
if the operation succeeded,false
if not- See Also:
Container.removeItem(Object)
Removes the Item identified by ItemId
from the Container.
removeContainerProperty
public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException
- Specified by:
removeContainerProperty
in interfaceContainer
- Overrides:
removeContainerProperty
in classAbstractSelect
- Parameters:
propertyId
- ID of the Property to remove- Returns:
- True if the operation succeeded.
- Throws:
UnsupportedOperationException
- if the container does not support removing container properties- See Also:
Container.removeContainerProperty(Object)
Removes a Property specified by the given Property ID from the Container.
addContainerProperty
public boolean addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
throws UnsupportedOperationException
- Specified by:
addContainerProperty
in interfaceContainer
- Overrides:
addContainerProperty
in classAbstractSelect
- Parameters:
propertyId
- the Id of the proprty.type
- the class of the property.defaultValue
- the default value given for all existing items.- Returns:
- True if the operation succeeded.
- Throws:
UnsupportedOperationException
- if the container does not support explicitly adding container properties- See Also:
Container.addContainerProperty(Object, Class, Object)
Adds a new property to the table and show it as a visible column.
addContainerProperty
public boolean addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue,
String columnHeader,
Resource columnIcon,
String columnAlignment)
throws UnsupportedOperationException
- Parameters:
propertyId
- the Id of the proprtytype
- the class of the propertydefaultValue
- the default value given for all existing itemscolumnHeader
- the Explicit header of the column. If explicit header is not needed, this should be set null.columnIcon
- the Icon of the column. If icon is not needed, this should be set null.columnAlignment
- the Alignment of the column. Null implies align left.- Throws:
UnsupportedOperationException
- if the operation is not supported.- See Also:
Container.addContainerProperty(Object, Class, Object)
Adds a new property to the table and show it as a visible column.
addGeneratedColumn
public void addGeneratedColumn(Object id,
Table.ColumnGenerator generatedColumn)
- Parameters:
id
- the id of the column to be addedgeneratedColumn
- theTable.ColumnGenerator
to use for this column
Adds a generated column to the Table.
A generated column is a column that exists only in the Table, not as a property in the underlying Container. It shows up just as a regular column.
A generated column will override a property with the same id, so that the generated column is shown instead of the column representing the property. Note that getContainerProperty() will still get the real property.
Table will not listen to value change events from properties overridden by generated columns. If the content of your generated column depends on properties that are not directly visible in the table, attach value change listener to update the content on all depended properties. Otherwise your UI might not get updated as expected.
Also note that getVisibleColumns() will return the generated columns, while getContainerPropertyIds() will not.
getColumnGenerator
public Table.ColumnGenerator getColumnGenerator(Object columnId)
throws IllegalArgumentException
- Parameters:
columnId
- The id of the generated column- Returns:
- The ColumnGenerator used for the given columnId or null.
- Throws:
IllegalArgumentException
Returns the ColumnGenerator used to generate the given column.
removeGeneratedColumn
public boolean removeGeneratedColumn(Object columnId)
- Parameters:
columnId
- id of the generated column to remove- Returns:
- true if the column could be removed (existed in the Table)
Removes a generated column previously added with addGeneratedColumn.
getVisibleItemIds
public Collection<?> getVisibleItemIds()
- Overrides:
getVisibleItemIds
in classAbstractSelect
- See Also:
AbstractSelect.getVisibleItemIds()
Returns item identifiers of the items which are currently rendered on the client.
Note, that some due to historical reasons the name of the method is bit
misleading. Some items may be partly or totally out of the viewport of
the table's scrollable area. Actually detecting rows which can be
actually seen by the end user may be problematic due to the client server
architecture. Using getCurrentPageFirstItemId()
combined with
getPageLength()
may produce good enough estimates in some
situations.
containerItemSetChange
public void containerItemSetChange(Container.ItemSetChangeEvent event)
- Specified by:
containerItemSetChange
in interfaceContainer.ItemSetChangeListener
- Overrides:
containerItemSetChange
in classAbstractSelect
- Parameters:
event
- change event text- See Also:
Container.ItemSetChangeListener.containerItemSetChange(com.vaadin.data.Container.ItemSetChangeEvent)
Container datasource item set change. Table must flush its buffers on change.
containerPropertySetChange
public void containerPropertySetChange(Container.PropertySetChangeEvent event)
- Specified by:
containerPropertySetChange
in interfaceContainer.PropertySetChangeListener
- Overrides:
containerPropertySetChange
in classAbstractSelect
- Parameters:
event
- Change event.- See Also:
Container.PropertySetChangeListener.containerPropertySetChange(com.vaadin.data.Container.PropertySetChangeEvent)
Container datasource property set change. Table must flush its buffers on change.
setNewItemsAllowed
public void setNewItemsAllowed(boolean allowNewOptions)
throws UnsupportedOperationException
- Overrides:
setNewItemsAllowed
in classAbstractSelect
- Parameters:
allowNewOptions
- the New value of property allowNewOptions.- Throws:
UnsupportedOperationException
- if set to true.- See Also:
AbstractSelect.setNewItemsAllowed(boolean)
Adding new items is not supported.
nextItemId
public Object nextItemId(Object itemId)
- Specified by:
nextItemId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of a visible Item in the Container- Returns:
- ID of the next visible Item or
null
- See Also:
Container.Ordered.nextItemId(java.lang.Object)
Gets the ID of the Item following the Item that corresponds to itemId.
prevItemId
public Object prevItemId(Object itemId)
- Specified by:
prevItemId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of a visible Item in the Container- Returns:
- ID of the previous visible Item or
null
- See Also:
Container.Ordered.prevItemId(java.lang.Object)
Gets the ID of the Item preceding the Item that corresponds to the itemId.
firstItemId
public Object firstItemId()
- Specified by:
firstItemId
in interfaceContainer.Ordered
- Returns:
- ID of the first visible Item in the Container
- See Also:
Container.Ordered.firstItemId()
Gets the ID of the first Item in the Container.
lastItemId
public Object lastItemId()
- Specified by:
lastItemId
in interfaceContainer.Ordered
- Returns:
- ID of the last visible Item in the Container
- See Also:
Container.Ordered.lastItemId()
Gets the ID of the last Item in the Container.
isFirstId
public boolean isFirstId(Object itemId)
- Specified by:
isFirstId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of an Item in the Container- Returns:
true
if the Item is first visible item in the Container,false
if not- See Also:
Container.Ordered.isFirstId(java.lang.Object)
Tests if the Item corresponding to the given Item ID is the first Item in the Container.
isLastId
public boolean isLastId(Object itemId)
- Specified by:
isLastId
in interfaceContainer.Ordered
- Returns:
true
if the Item is last visible item in the Container,false
if not- See Also:
Container.Ordered.isLastId(java.lang.Object)
Tests if the Item corresponding to the given Item ID is the last Item in the Container.
addItemAfter
public Object addItemAfter(Object previousItemId)
throws UnsupportedOperationException
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Parameters:
previousItemId
- Id of the visible item in ordered container after which to insert the new item.- Returns:
- item id the the created new item or null if the operation fails.
- Throws:
UnsupportedOperationException
- if the operation is not supported by the container- See Also:
Container.Ordered.addItemAfter(java.lang.Object)
Adds new item after the given item.
addItemAfter
public Item addItemAfter(Object previousItemId,
Object newItemId)
throws UnsupportedOperationException
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Parameters:
previousItemId
- Id of the visible item in ordered container after which to insert the new item.newItemId
- Id of the new item to be added.- Returns:
- new item or null if the operation fails.
- Throws:
UnsupportedOperationException
- if the operation is not supported by the container- See Also:
Container.Ordered.addItemAfter(java.lang.Object, java.lang.Object)
Adds new item after the given item.
setTableFieldFactory
public void setTableFieldFactory(TableFieldFactory fieldFactory)
- Parameters:
fieldFactory
- the field factory to set.- See Also:
isEditable()
,DefaultFieldFactory
Sets the TableFieldFactory that is used to create editor for table cells. The TableFieldFactory is only used if the Table is editable. By default the DefaultFieldFactory is used.
getTableFieldFactory
public TableFieldFactory getTableFieldFactory()
- Returns:
- TableFieldFactory used to create the Field instances.
- See Also:
isEditable()
Gets the TableFieldFactory that is used to create editor for table cells. The FieldFactory is only used if the Table is editable.
getFieldFactory
@Deprecated
public FieldFactory getFieldFactory()
- Returns:
- FieldFactory used to create the Field instances.
- See Also:
isEditable()
Deprecated. use getTableFieldFactory()
instead
Gets the FieldFactory that is used to create editor for table cells. The FieldFactory is only used if the Table is editable.
setFieldFactory
@Deprecated
public void setFieldFactory(FieldFactory fieldFactory)
- Parameters:
fieldFactory
- the field factory to set.- See Also:
isEditable()
,BaseFieldFactory
Deprecated. use setTableFieldFactory(TableFieldFactory)
instead
Sets the FieldFactory that is used to create editor for table cells. The FieldFactory is only used if the Table is editable. By default the BaseFieldFactory is used.
isEditable
public boolean isEditable()
- Returns:
- true if table is editable, false oterwise.
- See Also:
Field
,FieldFactory
Is table editable. If table is editable a editor of type Field is created for each table cell. The assigned FieldFactory is used to create the instances. To provide custom editors for table cells create a class implementins the FieldFactory interface, and assign it to table, and set the editable property to true.
setEditable
public void setEditable(boolean editable)
- Parameters:
editable
- true if table should be editable by user.- See Also:
Field
,FieldFactory
Sets the editable property. If table is editable a editor of type Field is created for each table cell. The assigned FieldFactory is used to create the instances. To provide custom editors for table cells create a class implementins the FieldFactory interface, and assign it to table, and set the editable property to true.
sort
public void sort(Object[] propertyId,
boolean[] ascending)
throws UnsupportedOperationException
- Specified by:
sort
in interfaceContainer.Sortable
- Parameters:
propertyId
- Array of container property IDs, whose values are used to sort the items in container as primary, secondary, ... sorting criterion. All of the item IDs must be in the collection returned byContainer.Sortable.getSortableContainerPropertyIds()
ascending
- Array of sorting order flags corresponding to each property ID used in sorting. If this array is shorter than propertyId array, ascending order is assumed for items where the order is not specified. Usetrue
to sort in ascending order,false
to use descending order.- Throws:
UnsupportedOperationException
- if the container data source does not implement Container.Sortable- See Also:
Container.Sortable.sort(java.lang.Object[], boolean[])
Sorts the table.
sort
public void sort()
- Throws:
UnsupportedOperationException
- if the container data source does not implement Container.Sortable
Sorts the table by currently selected sorting column.
getSortableContainerPropertyIds
public Collection<?> getSortableContainerPropertyIds()
- Specified by:
getSortableContainerPropertyIds
in interfaceContainer.Sortable
- Returns:
- the IDs of the properties that can be used for sorting the container
- See Also:
Container.Sortable.getSortableContainerPropertyIds()
Gets the container property IDs, which can be used to sort the item.
getSortContainerPropertyId
public Object getSortContainerPropertyId()
- Returns:
- the Container property id of the currently sorted column.
Gets the currently sorted column property ID.
setSortContainerPropertyId
public void setSortContainerPropertyId(Object propertyId)
- Parameters:
propertyId
- the Container property id of the currently sorted column.
Sets the currently sorted column property id.
isSortAscending
public boolean isSortAscending()
- Returns:
true
if ascending,false
if descending.
Is the table currently sorted in ascending order.
setSortAscending
public void setSortAscending(boolean ascending)
- Parameters:
ascending
-true
if ascending,false
if descending.
Sets the table in ascending order.
isSortDisabled
public boolean isSortDisabled()
- Returns:
- True iff sorting is disabled.
Is sorting disabled altogether. True iff no sortable columns are given even in the case where data source would support this.
setSortDisabled
public void setSortDisabled(boolean sortDisabled)
- Parameters:
sortDisabled
- True iff sorting is disabled.
Disables the sorting altogether. To disable sorting altogether, set to true. In this case no sortable columns are given even in the case where datasource would support this.
setLazyLoading
public void setLazyLoading(boolean useLazyLoading)
- See Also:
com.vaadin.ui.Select#setLazyLoading(boolean)
Table does not support lazy options loading mode. Setting this true will throw UnsupportedOperationException.
setCellStyleGenerator
public void setCellStyleGenerator(Table.CellStyleGenerator cellStyleGenerator)
- Parameters:
cellStyleGenerator
- New cell style generator or null to remove generator.
Set cell style generator for Table.
getCellStyleGenerator
public Table.CellStyleGenerator getCellStyleGenerator()
Get the current cell style generator.
addListener
public void addListener(ItemClickEvent.ItemClickListener listener)
- Specified by:
addListener
in interfaceItemClickEvent.ItemClickNotifier
- Parameters:
listener
- ItemClickListener to be registered
Description copied from interface: ItemClickEvent.ItemClickNotifier
Register a listener to handle ItemClickEvent
s.
removeListener
public void removeListener(ItemClickEvent.ItemClickListener listener)
- Specified by:
removeListener
in interfaceItemClickEvent.ItemClickNotifier
- Parameters:
listener
- ItemClickListener to be removed
Description copied from interface: ItemClickEvent.ItemClickNotifier
Removes an ItemClickListener.
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabled
in interfaceComponent
- Overrides:
setEnabled
in classAbstractComponent
- Parameters:
enabled
- a boolean value specifying if the component should be enabled or not
Description copied from interface: Component
Enables or disables the component. The user can not interact disabled components, which are shown with a style that indicates the status, usually shaded in light gray color. Components are enabled by default. Children of a disabled component are automatically disabled; if a child component is explicitly set as disabled, changes in the disabled status of its parents do not change its status.
Button enabled = new Button("Enabled");
enabled.setEnabled(true); // The default
layout.addComponent(enabled);
Button disabled = new Button("Disabled");
disabled.setEnabled(false);
layout.addComponent(disabled);
This method will trigger a
RepaintRequestEvent
for the component and, if it is a
ComponentContainer
, for all its children recursively.
requestRepaintAll
public void requestRepaintAll()
setDragMode
public void setDragMode(Table.TableDragMode newDragMode)
- Parameters:
newDragMode
-
Sets the drag start mode of the Table. Drag start mode controls how Table behaves as a drag source.
getDragMode
public Table.TableDragMode getDragMode()
- Returns:
- the current start mode of the Table. Drag start mode controls how Table behaves as a drag source.
getTransferable
public Table.TableTransferable getTransferable(Map<String,Object> rawVariables)
- Specified by:
getTransferable
in interfaceDragSource
- Parameters:
rawVariables
- the data that client side initially included inTransferable
s client side counterpart.- Returns:
- the
Transferable
instance that will be passed toDropHandler
(and/orAcceptCriterion
)
Description copied from interface: DragSource
DragSource may convert data added by client side component to meaningful values for server side developer or add other data based on it.
For example Tree converts item identifiers to generated string keys for
the client side. Vaadin developer don't and can't know anything about
these generated keys, only about item identifiers. When tree node is
dragged client puts that key to Transferable
s client side
counterpart. In Tree.getTransferable(Map)
the key is converted
back to item identifier that the server side developer can use.
getDropHandler
public DropHandler getDropHandler()
- Specified by:
getDropHandler
in interfaceDropTarget
- Returns:
- the drop hanler that will receive the dragged data or null if drops are not currently accepted
setDropHandler
public void setDropHandler(DropHandler dropHandler)
translateDropTargetDetails
public AbstractSelect.AbstractSelectTargetDetails translateDropTargetDetails(Map<String,Object> clientVariables)
- Specified by:
translateDropTargetDetails
in interfaceDropTarget
- Parameters:
clientVariables
- data passed from the DropTargets client side counterpart.- Returns:
- A DropTargetDetails object with the translated data or null to use a default implementation.
- See Also:
DragSource.getTransferable(Map)
Description copied from interface: DropTarget
Called before the DragAndDropEvent
is passed to
DropHandler
. Implementation may for example translate the drop
target details provided by the client side (drop target) to meaningful
server side values. If null is returned the terminal implementation will
automatically create a TargetDetails
with raw client side data.
setMultiSelectMode
public void setMultiSelectMode(AbstractSelect.MultiSelectMode mode)
- Parameters:
mode
- The select mode of the table
Sets the behavior of how the multi-select mode should behave when the table is both selectable and in multi-select mode.
Note, that on some clients the mode may not be respected. E.g. on touch
based devices CTRL/SHIFT base selection method is invalid, so touch based
browsers always use the MultiSelectMode#SIMPLE
.
getMultiSelectMode
public AbstractSelect.MultiSelectMode getMultiSelectMode()
- Returns:
- The multi select mode
Returns the select mode in which multi-select is used.
addListener
public void addListener(Table.HeaderClickListener listener)
- Parameters:
listener
- The handler which should handle the header click events.
Adds a header click listener which handles the click events when the user clicks on a column header cell in the Table.
The listener will receive events which contain information about which column was clicked and some details about the mouse event.
removeListener
public void removeListener(Table.HeaderClickListener listener)
- Parameters:
listener
- The listener to remove.
Removes a header click listener
addListener
public void addListener(Table.FooterClickListener listener)
- Parameters:
listener
- The handler which should handle the footer click events.
Adds a footer click listener which handles the click events when the user clicks on a column footer cell in the Table.
The listener will receive events which contain information about which column was clicked and some details about the mouse event.
removeListener
public void removeListener(Table.FooterClickListener listener)
- Parameters:
listener
- The listener to remove.
Removes a footer click listener
getColumnFooter
public String getColumnFooter(Object propertyId)
- Parameters:
propertyId
- The propertyId of the column *- Returns:
- The caption of the footer or NULL if not set
Gets the footer caption beneath the rows
setColumnFooter
public void setColumnFooter(Object propertyId,
String footer)
- Parameters:
propertyId
- The properyId of the columnfooter
- The caption of the footer
Sets the column footer caption. The column footer caption is the text displayed beneath the column if footers have been set visible.
setFooterVisible
public void setFooterVisible(boolean visible)
- Parameters:
visible
- Should the footer be visible
Sets the footer visible in the bottom of the table.
The footer can be used to add column related data like sums to the bottom of the Table using setColumnFooter(Object propertyId, String footer).
isFooterVisible
public boolean isFooterVisible()
- Returns:
- Returns true if visible else false
Is the footer currently visible?
addListener
public void addListener(Table.ColumnResizeListener listener)
- Parameters:
listener
- The listener to attach to the Table
Adds a column resize listener to the Table. A column resize listener is called when a user resizes a columns width.
removeListener
public void removeListener(Table.ColumnResizeListener listener)
- Parameters:
listener
- The listener to remove
Removes a column resize listener from the Table.
addListener
public void addListener(Table.ColumnReorderListener listener)
- Parameters:
listener
- The listener to attach to the Table
Adds a column reorder listener to the Table. A column reorder listener is called when a user reorders columns.
removeListener
public void removeListener(Table.ColumnReorderListener listener)
- Parameters:
listener
- The listener to remove
Removes a column reorder listener from the Table.
setItemDescriptionGenerator
public void setItemDescriptionGenerator(AbstractSelect.ItemDescriptionGenerator generator)
- Parameters:
generator
- The generator to use or null to disable
Set the item description generator which generates tooltips for cells and rows in the Table
getItemDescriptionGenerator
public AbstractSelect.ItemDescriptionGenerator getItemDescriptionGenerator()
Get the item description generator which generates tooltips for cells and rows in the Table.
setRowGenerator
public void setRowGenerator(Table.RowGenerator generator)
- Parameters:
generator
- the new row generator
Assigns a row generator to the table. The row generator will be able to replace rows in the table when it is rendered.
getRowGenerator
public Table.RowGenerator getRowGenerator()
- Returns:
- the current row generator
setVisible
public void setVisible(boolean visible)
- Specified by:
setVisible
in interfaceComponent
- Overrides:
setVisible
in classAbstractComponent
- Parameters:
visible
- the boolean value specifying if the component should be visible after the call or not.- See Also:
Component.isVisible()
Description copied from interface: Component
Sets the visibility of the component.
Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change, but the entire HTML element will be empty.
TextField readonly = new TextField("Read-Only");
readonly.setValue("You can't see this!");
readonly.setVisible(false);
layout.addComponent(readonly);
A component is visible only if all of its parents are also visible. If a component is explicitly set to be invisible, changes in the visibility of its parents will not change the visibility of the component.