Class TreeTable
-
- All Implemented Interfaces:
Buffered
,BufferedValidatable
,Container
,Container.Hierarchical
,Container.ItemSetChangeListener
,Container.ItemSetChangeNotifier
,Container.Ordered
,Container.PropertySetChangeListener
,Container.PropertySetChangeNotifier
,Container.Sortable
,Container.Viewer
,Property<Object>
,Property.Editor
,Property.ReadOnlyStatusChangeListener
,Property.ReadOnlyStatusChangeNotifier
,Property.ValueChangeListener
,Property.ValueChangeNotifier
,Property.Viewer
,Validatable
,Action.Container
,Action.ShortcutNotifier
,ConnectorEventListener
,ContextClickEvent.ContextClickNotifier
,DragSource
,DropTarget
,ItemClickEvent.ItemClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,VariableOwner
,Connector
,Component
,Component.Focusable
,Field<Object>
,HasChildMeasurementHint
,HasComponents
,LegacyComponent
,Serializable
,Iterable<Component>
,EventListener
public class TreeTable extends Table implements Container.Hierarchical
TreeTable extends theTable
component so that it can also visualize a hierarchy of its Items in a similar manner thatTree
does. The tree hierarchy is always displayed in the first actual column of the TreeTable.The TreeTable supports the usual
Table
features like lazy loading, so it should be no problem to display lots of items at once. Only required rows and some cache rows are sent to the client.TreeTable supports standard
Container.Hierarchical
container interfaces, but also a more fine tuned version -Collapsible
. A container implementing theCollapsible
interface stores the collapsed/expanded state internally and can this way scale better on the server side than with standard Hierarchical implementations. Developer must however note thatCollapsible
containers can not be shared among several users as they share UI state in the container.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.ui.Table
Table.Align, Table.CacheUpdateException, Table.CellStyleGenerator, Table.ColumnCollapseEvent, Table.ColumnCollapseListener, Table.ColumnGenerator, Table.ColumnHeaderMode, Table.ColumnReorderEvent, Table.ColumnReorderListener, Table.ColumnResizeEvent, Table.ColumnResizeListener, Table.FooterClickEvent, Table.FooterClickListener, Table.GeneratedRow, Table.HeaderClickEvent, Table.HeaderClickListener, Table.RowGenerator, Table.RowHeaderMode, Table.TableContextClickEvent, Table.TableDragMode, Table.TableDropCriterion, Table.TableTransferable
-
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractSelect
AbstractSelect.AbstractSelectTargetDetails, AbstractSelect.AcceptItem, AbstractSelect.CaptionChangeListener, AbstractSelect.DefaultNewItemHandler, AbstractSelect.Filtering, AbstractSelect.ItemCaptionMode, AbstractSelect.ItemDescriptionGenerator, AbstractSelect.NewItemHandler, AbstractSelect.TargetItemIs, AbstractSelect.VerticalLocationIs
-
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasChildMeasurementHint
HasChildMeasurementHint.ChildMeasurementHint
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.Table
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, alwaysRecalculateColumnWidths, CELL_FIRSTCOL, CELL_GENERATED_ROW, CELL_HEADER, CELL_ICON, CELL_ITEMID, CELL_KEY, COLUMN_HEADER_MODE_EXPLICIT, COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID, COLUMN_HEADER_MODE_HIDDEN, COLUMN_HEADER_MODE_ID, ROW_HEADER_MODE_EXPLICIT, ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID, ROW_HEADER_MODE_HIDDEN, ROW_HEADER_MODE_ICON_ONLY, ROW_HEADER_MODE_ID, ROW_HEADER_MODE_INDEX, ROW_HEADER_MODE_ITEM, ROW_HEADER_MODE_PROPERTY
-
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 class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description TreeTable()
Creates an empty TreeTable with a default container.TreeTable(String caption)
Creates an empty TreeTable with a default container.TreeTable(String caption, Container dataSource)
Creates a TreeTable instance with given captions and data source.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addCollapseListener(Tree.CollapseListener listener)
Adds a collapse listener.void
addExpandListener(Tree.ExpandListener listener)
Adds an expand listener.Object
addItem()
Creates a new item into container with container managed id.Item
addItem(Object itemId)
Create a new item into container.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
addItems(Object... itemId)
Adds given items with given item ids to container.void
addItems(Collection<?> itemIds)
Adds given items with given item ids to container.void
addListener(Tree.CollapseListener listener)
Deprecated.As of 7.0, replaced byaddCollapseListener(CollapseListener)
void
addListener(Tree.ExpandListener listener)
Deprecated.As of 7.0, replaced byaddExpandListener(ExpandListener)
boolean
areChildrenAllowed(Object itemId)
Tests if the Item with given ID can have children.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.protected void
fireCollapseEvent(Object itemId)
Emits a collapse event.protected void
fireExpandEvent(Object itemId)
Emits an expand event.protected int
getAddedRowCount()
Subclass and override this to enable partial row additions, bypassing the normal caching mechanism.Collection<?>
getChildren(Object itemId)
Gets the IDs of all Items that are children of the specified Item.Container.Hierarchical
getContainerDataSource()
Gets the viewing data-source container.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.Object
getHierarchyColumnId()
protected Object
getIdByIndex(int index)
Returns the item ID for the item represented by the index given.Collection<?>
getItemIds()
Gets the item Id collection from the container.protected List<Object>
getItemIds(int firstIndex, int rows)
Object
getParent(Object itemId)
Gets the ID of the parent Item of the specified Item.protected TreeTableState
getState()
Returns the shared state bean with information to be sent from the server to the client.protected int
getUpdatedRowCount()
Subclass and override this to enable partial row updates, bypassing the normal caching and lazy loading mechanism.boolean
hasChildren(Object itemId)
Tests if the Item specified withitemId
has child Items or if it is a leaf.protected int
indexOfId(Object itemId)
boolean
isAnimationsEnabled()
boolean
isCollapsed(Object itemId)
Checks if Item with given identifier is collapsed in the UI.boolean
isLastId(Object itemId)
Tests if the Item corresponding to the given Item ID is the last Item in the Container.protected boolean
isPartialRowUpdate()
Subclass and override this to enable partial row updates and additions, which bypass the normal caching mechanism.boolean
isRoot(Object itemId)
Tests if the Item specified withitemId
is a root Item.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
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.protected void
readBody(org.jsoup.nodes.Element design, DesignContext context)
protected Object
readItem(org.jsoup.nodes.Element tr, Set<String> selected, DesignContext context)
Reads an Item from a design and inserts it into the data source.void
removeCollapseListener(Tree.CollapseListener listener)
Removes a collapse listener.void
removeExpandListener(Tree.ExpandListener listener)
Removes an expand listener.void
removeListener(Tree.CollapseListener listener)
Deprecated.As of 7.0, replaced byremoveCollapseListener(CollapseListener)
void
removeListener(Tree.ExpandListener listener)
Deprecated.As of 7.0, replaced byremoveExpandListener(ExpandListener)
Collection<?>
rootItemIds()
Gets the IDs of all Items in the container that don't have a parent.protected boolean
rowHeadersAreEnabled()
Checks whether row headers are visible.void
setAnimationsEnabled(boolean animationsEnabled)
Animations can be enabled by passing true to this method.boolean
setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
Sets the given Item's capability to have children.void
setCollapsed(Object itemId, boolean collapsed)
Sets the Item specified by given identifier as collapsed or expanded.void
setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer.void
setHierarchyColumn(Object hierarchyColumnId)
Explicitly sets the column in which the TreeTable visualizes the hierarchy.boolean
setParent(Object itemId, Object newParentId)
Sets the parent of an Item.protected boolean
shouldHideAddedRows()
Subclass and override this to enable removing of rows, bypassing the normal caching and lazy loading mechanism.int
size()
Gets the number of items in the container.protected org.jsoup.nodes.Element
writeItem(org.jsoup.nodes.Element tbody, Object itemId, DesignContext context)
Writes a data source Item to a design.protected void
writeItems(org.jsoup.nodes.Element design, DesignContext context)
Writes the data source items to a design.protected void
writeItems(org.jsoup.nodes.Element tbody, Collection<?> itemIds, int depth, DesignContext context)
-
Methods inherited from class com.vaadin.ui.Table
addActionHandler, addColumnCollapseListener, addColumnReorderListener, addColumnResizeListener, addContainerProperty, addContainerProperty, addFooterClickListener, addGeneratedColumn, addHeaderClickListener, addItemClickListener, addListener, addListener, addListener, addListener, addListener, attach, beforeClientResponse, bindPropertyToField, containerPropertySetChange, detach, disableContentRefreshing, enableContentRefreshing, firstItemId, formatPropertyValue, getCacheRate, getCellStyleGenerator, getChildMeasurementHint, getCollapseMenuContent, getColumnAlignment, getColumnAlignments, getColumnExpandRatio, getColumnFooter, getColumnGenerator, getColumnHeader, getColumnHeaderMode, getColumnHeaders, getColumnIcon, getColumnIcons, getColumnWidth, getComponentIterator, getConverter, getCurrentPageFirstItemId, getCurrentPageFirstItemIndex, getCustomAttributes, getDragMode, getDropHandler, getItemDescriptionGenerator, getMultiSelectMode, getPageLength, getPropertyValue, getRowGenerator, getRowHeaderMode, getSortableContainerPropertyIds, getSortContainerPropertyId, getState, getTableFieldFactory, getTransferable, getVisibleColumns, getVisibleItemIds, hasConverter, isColumnCollapsed, isColumnCollapsible, isColumnCollapsingAllowed, isColumnReorderingAllowed, isEditable, isFirstId, isFooterVisible, isMultiSelectTouchDetectionEnabled, isRowCacheInvalidated, isSelectable, isSortAscending, isSortDisabled, isSortEnabled, iterator, markAsDirty, markAsDirtyRecursive, paintRowHeader, readDesign, readItems, refreshRenderedCells, refreshRowCache, registerComponent, removeActionHandler, removeAllActionHandlers, removeAllItems, removeColumnCollapseListener, removeColumnReorderListener, removeColumnResizeListener, removeContainerProperty, removeFooterClickListener, removeGeneratedColumn, removeHeaderClickListener, removeItem, removeItemClickListener, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, resetPageBuffer, setCacheRate, setCellStyleGenerator, setChildMeasurementHint, setCollapseMenuContent, setColumnAlignment, setColumnAlignments, setColumnCollapsed, setColumnCollapsible, setColumnCollapsingAllowed, setColumnExpandRatio, setColumnFooter, setColumnHeader, setColumnHeaderMode, setColumnHeaders, setColumnIcon, setColumnIcons, setColumnReorderingAllowed, setColumnWidth, setContainerDataSource, setConverter, setCurrentPageFirstItemId, setCurrentPageFirstItemIndex, setDragMode, setDropHandler, setEditable, setEnabled, setFooterVisible, setItemDescriptionGenerator, setMultiSelectMode, setMultiSelectTouchDetectionEnabled, setNewItemsAllowed, setPageLength, setRowGenerator, setRowHeaderMode, setSelectable, setSortAscending, setSortContainerPropertyId, setSortDisabled, setSortEnabled, setTableFieldFactory, setVisible, setVisibleColumns, sort, sort, translateDropTargetDetails, unregisterComponent, valueChange, writeDesign
-
Methods inherited from class com.vaadin.ui.AbstractSelect
addItemSetChangeListener, addListener, addListener, addPropertySetChangeListener, containsId, fireItemSetChange, firePropertySetChange, getCaptionChangeListener, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getListeners, getNewItemHandler, getNullSelectionItemId, getType, getType, getValue, isEmpty, isMultiSelect, isNewItemsAllowed, isNullSelectionAllowed, isSelected, paintItem, removeItemSetChangeListener, removeListener, removeListener, removePropertySetChangeListener, sanitizeSelection, select, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIcon, setItemIconPropertyId, setMultiSelect, setNewItemHandler, setNullSelectionAllowed, setNullSelectionItemId, setValue, setValue, unselect
-
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, clear, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getErrorMessage, getInternalValue, getModelType, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, isBuffered, isImmediate, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setLocale, setPropertyDataSource, setReadOnly, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, shouldHideErrors, toString, validate, validate
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setWidth, setWidth, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, removeAttachListener, removeDetachListener, removeExtension, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.Container
addContainerProperty, containsId, getContainerProperty, getContainerPropertyIds, getItem, getType, removeAllItems, removeContainerProperty
-
Methods inherited from interface com.vaadin.data.Container.Hierarchical
removeItem
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
-
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled, isImmediate
-
-
-
-
Constructor Detail
-
TreeTable
public TreeTable()
Creates an empty TreeTable with a default container.
-
TreeTable
public TreeTable(String caption)
Creates an empty TreeTable with a default container.- Parameters:
caption
- the caption for the TreeTable
-
-
Method Detail
-
paintRowAttributes
protected void paintRowAttributes(PaintTarget target, Object itemId) throws PaintException
Description copied from class:Table
A method where extended Table implementations may add their custom attributes for rows.- Overrides:
paintRowAttributes
in classTable
- Throws:
PaintException
-
paintRowIcon
protected void paintRowIcon(PaintTarget target, Object[][] cells, int indexInRowbuffer) throws PaintException
- Overrides:
paintRowIcon
in classTable
- Throws:
PaintException
-
rowHeadersAreEnabled
protected boolean rowHeadersAreEnabled()
Description copied from class:Table
Checks whether row headers are visible.- Overrides:
rowHeadersAreEnabled
in classTable
- Returns:
false
if row headers are hidden,true
otherwise
-
changeVariables
public void changeVariables(Object source, Map<String,Object> variables)
Description copied from class:Table
Invoked when the value of a variable has changed.- Specified by:
changeVariables
in interfaceVariableOwner
- Overrides:
changeVariables
in classTable
- 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:
ComboBox.changeVariables(java.lang.Object, java.util.Map)
-
paintContent
public void paintContent(PaintTarget target) throws PaintException
Description copied from class:AbstractSelect
Paints the content of this component.- Specified by:
paintContent
in interfaceLegacyComponent
- Overrides:
paintContent
in classTable
- Parameters:
target
- the Paint Event.- Throws:
PaintException
- if the paint operation failed.
-
isPartialRowUpdate
protected boolean isPartialRowUpdate()
Description copied from class:Table
Subclass and override this to enable partial row updates and additions, which bypass the normal caching mechanism. This is useful for e.g. TreeTable.- Overrides:
isPartialRowUpdate
in classTable
- Returns:
- true if this update is a partial row update, false if not. For plain Table it is always false.
-
getFirstAddedItemIndex
protected int getFirstAddedItemIndex()
Description copied from class:Table
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.- Overrides:
getFirstAddedItemIndex
in classTable
- Returns:
- The index of the first added item. For plain Table it is always 0.
-
getAddedRowCount
protected int getAddedRowCount()
Description copied from class:Table
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.- Overrides:
getAddedRowCount
in classTable
- Returns:
- the number of rows to be added, starting at the index returned by
Table.getFirstAddedItemIndex()
. For plain Table it is always 0.
-
getFirstUpdatedItemIndex
protected int getFirstUpdatedItemIndex()
Description copied from class:Table
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.- Overrides:
getFirstUpdatedItemIndex
in classTable
- Returns:
- the index of the first item to be updated. For plain Table it is always 0.
-
getUpdatedRowCount
protected int getUpdatedRowCount()
Description copied from class:Table
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.- Overrides:
getUpdatedRowCount
in classTable
- Returns:
- the number of rows to update, starting at the index returned by
Table.getFirstUpdatedItemIndex()
. For plain table it is always 0.
-
shouldHideAddedRows
protected boolean shouldHideAddedRows()
Description copied from class:Table
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 byTable.getFirstAddedItemIndex()
andTable.getAddedRowCount()
should be hidden instead of added.- Overrides:
shouldHideAddedRows
in classTable
- Returns:
- whether the rows to add (see
Table.getFirstAddedItemIndex()
andTable.getAddedRowCount()
) should be added or hidden. For plain Table it is always false.
-
size
public int size()
Description copied from class:AbstractSelect
Gets the number of items in the container.- Specified by:
size
in interfaceContainer
- Overrides:
size
in classAbstractSelect
- Returns:
- the Number of items in the container.
- See Also:
Container.size()
-
getContainerDataSource
public Container.Hierarchical getContainerDataSource()
Description copied from class:AbstractSelect
Gets the viewing data-source container.- Specified by:
getContainerDataSource
in interfaceContainer.Viewer
- Overrides:
getContainerDataSource
in classAbstractSelect
- Returns:
- data source Container
- See Also:
Container.Viewer.getContainerDataSource()
-
setContainerDataSource
public void setContainerDataSource(Container newDataSource)
Description copied from class:Table
Sets the Container that serves as the data source of the viewer. As a side-effect the table's selection value is set to null as the old selection might not exist in new Container.
All rows and columns are generated as visible using this method. If the new container contains properties that are not meant to be shown you should useTable.setContainerDataSource(Container, Collection)
instead, especially if the table is editable.Keeps propertyValueConverters if the corresponding id exists in the new data source and is of a compatible type.
- Specified by:
setContainerDataSource
in interfaceContainer.Viewer
- Overrides:
setContainerDataSource
in classTable
- Parameters:
newDataSource
- the new data source.- See Also:
Container.Viewer.setContainerDataSource(Container)
-
containerItemSetChange
public void containerItemSetChange(Container.ItemSetChangeEvent event)
Description copied from class:Table
Container datasource item set change. Table must flush its buffers on change.- Specified by:
containerItemSetChange
in interfaceContainer.ItemSetChangeListener
- Overrides:
containerItemSetChange
in classTable
- Parameters:
event
- change event text- See Also:
Container.ItemSetChangeListener.containerItemSetChange(Container.ItemSetChangeEvent)
-
getIdByIndex
protected Object getIdByIndex(int index)
Description copied from class:Table
Returns the item ID for the item represented by the index given. Assumes that the current container implementsContainer.Indexed
. SeeContainer.Indexed.getIdByIndex(int)
for more information about the exceptions that can be thrown.- Overrides:
getIdByIndex
in classTable
- Parameters:
index
- the index for which the item ID should be fetched- Returns:
- the item ID for the given index
-
nextItemId
public Object nextItemId(Object itemId)
Description copied from class:Table
Gets the ID of the Item following the Item that corresponds to itemId.- Specified by:
nextItemId
in interfaceContainer.Ordered
- Overrides:
nextItemId
in classTable
- 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)
-
lastItemId
public Object lastItemId()
Description copied from class:Table
Gets the ID of the last Item in the Container.- Specified by:
lastItemId
in interfaceContainer.Ordered
- Overrides:
lastItemId
in classTable
- Returns:
- ID of the last visible Item in the Container
- See Also:
Container.Ordered.lastItemId()
-
prevItemId
public Object prevItemId(Object itemId)
Description copied from class:Table
Gets the ID of the Item preceding the Item that corresponds to the itemId.- Specified by:
prevItemId
in interfaceContainer.Ordered
- Overrides:
prevItemId
in classTable
- 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)
-
isLastId
public boolean isLastId(Object itemId)
Description copied from class:Table
Tests if the Item corresponding to the given Item ID is the last Item in the Container.- Specified by:
isLastId
in interfaceContainer.Ordered
- Overrides:
isLastId
in classTable
- Returns:
true
if the Item is last visible item in the Container,false
if not- See Also:
Container.Ordered.isLastId(java.lang.Object)
-
getItemIds
public Collection<?> getItemIds()
Description copied from class:AbstractSelect
Gets the item Id collection from the container.- Specified by:
getItemIds
in interfaceContainer
- Overrides:
getItemIds
in classAbstractSelect
- Returns:
- the Collection of item ids.
-
areChildrenAllowed
public boolean areChildrenAllowed(Object itemId)
Description copied from interface:Container.Hierarchical
Tests if the Item with given ID can have children.- Specified by:
areChildrenAllowed
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the Item in the container whose child capability is to be tested- Returns:
true
if the specified Item exists in the Container and it can have children,false
if it's not found from the container or it can't have children.
-
getChildren
public Collection<?> getChildren(Object itemId)
Description copied from interface:Container.Hierarchical
Gets the IDs of all Items that are children of the specified Item. The returned collection is unmodifiable.- Specified by:
getChildren
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the Item whose children the caller is interested in- Returns:
- An unmodifiable
collection
containing the IDs of all other Items that are children in the container hierarchy;null
if item does not have any children.
-
getParent
public Object getParent(Object itemId)
Description copied from interface:Container.Hierarchical
Gets the ID of the parent Item of the specified Item.- Specified by:
getParent
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the Item whose parent the caller wishes to find out.- Returns:
- the ID of the parent Item. Will be
null
if the specified Item is a root element.
-
hasChildren
public boolean hasChildren(Object itemId)
Description copied from interface:Container.Hierarchical
Tests if the Item specified with
itemId
has child Items or if it is a leaf. TheContainer.Hierarchical.getChildren(Object itemId)
method always returnsnull
for leaf Items.Note that being a leaf does not imply whether or not an Item is allowed to have children.
- Specified by:
hasChildren
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the Item to be tested- Returns:
true
if the specified Item has children,false
if not (is a leaf)
-
isRoot
public boolean isRoot(Object itemId)
Description copied from interface:Container.Hierarchical
Tests if the Item specified withitemId
is a root Item. The hierarchical container can have more than one root and must have at least one unless it is empty. TheContainer.Hierarchical.getParent(Object itemId)
method always returnsnull
for root Items.- Specified by:
isRoot
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the Item whose root status is to be tested- Returns:
true
if the specified Item is a root,false
if not
-
rootItemIds
public Collection<?> rootItemIds()
Description copied from interface:Container.Hierarchical
Gets the IDs of all Items in the container that don't have a parent. Such items are calledroot
Items. The returned collection is unmodifiable.- Specified by:
rootItemIds
in interfaceContainer.Hierarchical
- Returns:
- An unmodifiable
collection
containing IDs of all root elements of the container
-
setChildrenAllowed
public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException
Description copied from interface:Container.Hierarchical
Sets the given Item's capability to have children. If the Item identified with
itemId
already has children and
is false this method fails andContainer.Hierarchical.areChildrenAllowed(Object)
false
is returned.The children must be first explicitly removed with
Container.Hierarchical.setParent(Object itemId, Object newParentId)
orContainer.removeItem(Object itemId)
.This operation is optional. If it is not implemented, the method always returns
false
.- Specified by:
setChildrenAllowed
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the Item in the container whose child capability is to be setareChildrenAllowed
- boolean value specifying if the Item can have children or not- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
-
setParent
public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException
Sets the parent of an Item. The new parent item must exist and be able to have children. (
). It is also possible to detach a node from the hierarchy (and thus make it root) by setting the parentContainer.Hierarchical.areChildrenAllowed(Object)
== truenull
.This operation is optional.
Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance.- Specified by:
setParent
in interfaceContainer.Hierarchical
- Parameters:
itemId
- ID of the item to be set as the child of the Item identified withnewParentId
newParentId
- ID of the Item that's to be the new parent of the Item identified withitemId
- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
-
addItem
public Object addItem() throws UnsupportedOperationException
Creates a new item into container with container managed id. The id of the created new item is returned. The item can be fetched with getItem() method. if the creation fails, null is returned.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Specified by:
addItem
in interfaceContainer
- Overrides:
addItem
in classAbstractSelect
- Returns:
- the Id of the created item or null in case of failure.
- Throws:
UnsupportedOperationException
- if adding an item without an explicit item ID is not supported by the container- See Also:
Container.addItem()
-
addItem
public Item addItem(Object itemId) throws UnsupportedOperationException
Create a new item into container. The created new item is returned and ready for setting property values. if the creation fails, null is returned. In case the container already contains the item, null is returned. This functionality is optional. If the function is unsupported, it always returns null.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Specified by:
addItem
in interfaceContainer
- Overrides:
addItem
in classAbstractSelect
- Parameters:
itemId
- the Identification of the item to be created.- Returns:
- the Created item with the given id, or null in case of failure.
- Throws:
UnsupportedOperationException
- if adding an item with an explicit item ID is not supported by the container- See Also:
Container.addItem(java.lang.Object)
-
addItem
public Object addItem(Object[] cells, Object itemId) throws UnsupportedOperationException
Adds the new row to table and fill the visible cells (except generated columns) with given values.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Overrides:
addItem
in classTable
- 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 cannot already have a item with given id.- Returns:
- Returns item id for the new row. Returns null if operation fails.
- Throws:
UnsupportedOperationException
-
addItemAfter
public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException
Adds new item after the given item.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Overrides:
addItemAfter
in classTable
- 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)
-
addItemAfter
public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException
Adds new item after the given item.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Overrides:
addItemAfter
in classTable
- 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)
-
addItems
public void addItems(Collection<?> itemIds) throws UnsupportedOperationException
Adds given items with given item ids to container.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Overrides:
addItems
in classAbstractSelect
- Parameters:
itemIds
- item identifiers to be added to underlying container- Throws:
UnsupportedOperationException
- if the underlying container don't support adding items with identifiers
-
addItems
public void addItems(Object... itemId) throws UnsupportedOperationException
Adds given items with given item ids to container.Note: Constructing a big hierarchical data set using the methods in
TreeTable
may cause a decrease in performance. Instead aContainer.Hierarchical
container should be populated before setting it to theTreeTable
.- Overrides:
addItems
in classAbstractSelect
- Parameters:
itemId
- item identifiers to be added to underlying container- Throws:
UnsupportedOperationException
- if the underlying container don't support adding items with identifiers
-
setCollapsed
public void setCollapsed(Object itemId, boolean collapsed)
Sets the Item specified by given identifier as collapsed or expanded. If the Item is collapsed, its children are not displayed to the user.- Parameters:
itemId
- the identifier of the Itemcollapsed
- true if the Item should be collapsed, false if expanded
-
isCollapsed
public boolean isCollapsed(Object itemId)
Checks if Item with given identifier is collapsed in the UI.- Parameters:
itemId
- the identifier of the checked Item- Returns:
- true if the Item with given id is collapsed
- See Also:
Collapsible.isCollapsed(Object)
-
setHierarchyColumn
public void setHierarchyColumn(Object hierarchyColumnId)
Explicitly sets the column in which the TreeTable visualizes the hierarchy. If hierarchyColumnId is not set, the hierarchy is visualized in the first visible column.- Parameters:
hierarchyColumnId
-
-
getHierarchyColumnId
public Object getHierarchyColumnId()
- Returns:
- the identifier of column into which the hierarchy will be visualized or null if the column is not explicitly defined.
-
addExpandListener
public void addExpandListener(Tree.ExpandListener listener)
Adds an expand listener.- Parameters:
listener
- the Listener to be added.
-
addListener
@Deprecated public void addListener(Tree.ExpandListener listener)
Deprecated.As of 7.0, replaced byaddExpandListener(ExpandListener)
-
removeExpandListener
public void removeExpandListener(Tree.ExpandListener listener)
Removes an expand listener.- Parameters:
listener
- the Listener to be removed.
-
removeListener
@Deprecated public void removeListener(Tree.ExpandListener listener)
Deprecated.As of 7.0, replaced byremoveExpandListener(ExpandListener)
-
fireExpandEvent
protected void fireExpandEvent(Object itemId)
Emits an expand event.- Parameters:
itemId
- the item id.
-
addCollapseListener
public void addCollapseListener(Tree.CollapseListener listener)
Adds a collapse listener.- Parameters:
listener
- the Listener to be added.
-
addListener
@Deprecated public void addListener(Tree.CollapseListener listener)
Deprecated.As of 7.0, replaced byaddCollapseListener(CollapseListener)
-
removeCollapseListener
public void removeCollapseListener(Tree.CollapseListener listener)
Removes a collapse listener.- Parameters:
listener
- the Listener to be removed.
-
removeListener
@Deprecated public void removeListener(Tree.CollapseListener listener)
Deprecated.As of 7.0, replaced byremoveCollapseListener(CollapseListener)
-
fireCollapseEvent
protected void fireCollapseEvent(Object itemId)
Emits a collapse event.- Parameters:
itemId
- the item id.
-
isAnimationsEnabled
public boolean isAnimationsEnabled()
- Returns:
- true if animations are enabled
-
setAnimationsEnabled
public void setAnimationsEnabled(boolean animationsEnabled)
Animations can be enabled by passing true to this method. Currently expanding rows slide in from the top and collapsing rows slide out the same way. NOTE! not supported in Internet Explorer 6 or 7.- Parameters:
animationsEnabled
- true or false whether to enable animations or not.
-
getItemIds
protected List<Object> getItemIds(int firstIndex, int rows)
- Overrides:
getItemIds
in classTable
-
readBody
protected void readBody(org.jsoup.nodes.Element design, DesignContext context)
-
readItem
protected Object readItem(org.jsoup.nodes.Element tr, Set<String> selected, DesignContext context)
Description copied from class:AbstractSelect
Reads an Item from a design and inserts it into the data source. Hierarchical select components should override this method to recursively recursively read any child items as well.- Overrides:
readItem
in classTable
- Parameters:
tr
- a child element representing the itemselected
- A set accumulating selected items. If the item that is read is marked as selected, its item id should be added to this set.context
- the DesignContext instance used in parsing- Returns:
- the item id of the new item
-
writeItems
protected void writeItems(org.jsoup.nodes.Element design, DesignContext context)
Description copied from class:AbstractSelect
Writes the data source items to a design. Hierarchical select components should override this method to only write the root items.- Overrides:
writeItems
in classTable
- Parameters:
design
- the element into which to insert the itemscontext
- the DesignContext instance used in writing
-
writeItems
protected void writeItems(org.jsoup.nodes.Element tbody, Collection<?> itemIds, int depth, DesignContext context)
-
writeItem
protected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element tbody, Object itemId, DesignContext context)
Description copied from class:AbstractSelect
Writes a data source Item to a design. Hierarchical select components should override this method to recursively write any child items as well.
-
getState
protected TreeTableState getState()
Description copied from class:AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
-
-