com.itmill.toolkit.ui
Class Table

java.lang.Object
  extended by com.itmill.toolkit.ui.AbstractComponent
      extended by com.itmill.toolkit.ui.AbstractField
          extended by com.itmill.toolkit.ui.AbstractSelect
              extended by com.itmill.toolkit.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.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.Container, ItemClickEvent.ItemClickSource, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, EventListener

public class Table
extends AbstractSelect
implements Action.Container, Container.Ordered, Container.Sortable, ItemClickEvent.ItemClickSource

TableComponent is used for representing data or components in pageable and selectable table.

Note! Since version 5, components in Table will not have their caption nor icon rendered. In order to workaround this limitation, wrap your component in a Layout.

Since:
3.0
Version:
5.3.0
Author:
IT Mill Ltd.

Nested Class Summary
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.
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractSelect
AbstractSelect.CaptionChangeListener, AbstractSelect.DefaultNewItemHandler, AbstractSelect.Filtering, AbstractSelect.NewItemHandler
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractField
AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.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
           
static int COLUMN_HEADER_MODE_EXPLICIT
          Column header mode: Column headers are explicitly specified with setColumnHeaders.
static int COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
          Column header mode: Column headers are explicitly specified with setColumnHeaders
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 setItemCaptionPropertyId.
 
Fields inherited from class com.itmill.toolkit.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
 
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 listener to handle ItemClickEvents.
 void attach()
          Notifies the component that it is connected to an application.
 void changeVariables(Object source, Map 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.
 void focus()
          Focusing to this component is not supported.
protected  String formatPropertyValue(Object rowId, Object colId, Property property)
          Formats table cell property values.
 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.
 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 width of column
 Object getCurrentPageFirstItemId()
          Getter for property currentPageFirstItem.
 int getCurrentPageFirstItemIndex()
          Getter for property currentPageFirstItem.
 FieldFactory getFieldFactory()
          Gets the FieldFactory that is used to create editor for table cells.
 int getPageLength()
          Gets the page length.
protected  Object getPropertyValue(Object rowId, Object colId, Property property)
          Gets the value of property.
 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.
 String getTag()
          Gets the component UIDL tag.
 Object[] getVisibleColumns()
          Gets the array of visible column id:s, including generated columns.
 Collection getVisibleItemIds()
          Returns the list of items on the current page
 boolean isColumnCollapsed(Object propertyId)
          Checks if the specified column is collapsed.
 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 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
 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.
 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
 void removeActionHandler(Action.Handler actionHandler)
          Removes a previously registered action handler for the contents of this container.
 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 ItemClickListener.
 void requestRepaintAll()
           
 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 setColumnCollapsingAllowed(boolean collapsingAllowed)
          Sets whether column collapsing is allowed or not.
 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 reorderingAllowed)
          Sets whether column reordering is allowed or not.
 void setColumnWidth(Object columnId, 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 setEditable(boolean editable)
          Sets the editable property.
 void setEnabled(boolean enabled)
          Enables or disables the component.
 void setFieldFactory(FieldFactory fieldFactory)
          Sets the FieldFactory that is used to create editor for table cells.
 void setLazyLoading(boolean useLazyLoading)
          Table does not support lazy options loading 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 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 setValue(Object newValue)
          Sets the visible value of the property.
 void setVisibleColumns(Object[] visibleColumns)
          Sets the array of visible column property id:s.
 void sort()
          Sorts the table by currently selected sorting column.
 void sort(Object[] propertyId, boolean[] ascending)
          Sorts the table.
 String toString()
          Returns the value of the Property in human readable textual format.
 void valueChange(Property.ValueChangeEvent event)
          Notifies this listener that the Property's value has changed.
 
Methods inherited from class com.itmill.toolkit.ui.AbstractSelect
addItem, addItem, addListener, addListener, containsId, fireItemSetChange, firePropertySetChange, getCaptionChangeListener, getContainerDataSource, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getItemIds, getNewItemHandler, getNullSelectionItemId, getType, getType, getValue, isMultiSelect, isNewItemsAllowed, isNullSelectionAllowed, isSelected, removeListener, removeListener, select, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIcon, setItemIconPropertyId, setMultiSelect, setNewItemHandler, setNullSelectionAllowed, setNullSelectionItemId, setValue, size, unselect
 
Methods inherited from class com.itmill.toolkit.ui.AbstractField
addListener, addListener, addValidator, commit, constructField, discard, fireReadOnlyStatusChange, fireValueChange, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, removeListener, removeListener, removeValidator, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setWriteThrough, validate
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, isEnabled, isImmediate, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeight, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setWidth, setWidth, setWidth, setWidthUnits, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.itmill.toolkit.ui.Field
getDescription, setCaption, setDescription
 

Field Detail

ALIGN_LEFT

public static final String ALIGN_LEFT
Left column alignment. This is the default behaviour.

See Also:
Constant Field Values

ALIGN_CENTER

public static final String ALIGN_CENTER
Center column alignment.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final String ALIGN_RIGHT
Right column alignment.

See Also:
Constant Field Values

COLUMN_HEADER_MODE_HIDDEN

public static final int COLUMN_HEADER_MODE_HIDDEN
Column header mode: Column headers are hidden. This is the default behavior.

See Also:
Constant Field Values

COLUMN_HEADER_MODE_ID

public static final int COLUMN_HEADER_MODE_ID
Column header mode: Property ID:s are used as column headers.

See Also:
Constant Field Values

COLUMN_HEADER_MODE_EXPLICIT

public static final int COLUMN_HEADER_MODE_EXPLICIT
Column header mode: Column headers are explicitly specified with setColumnHeaders.

See Also:
Constant Field Values

COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID

public static final int COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID
Column header mode: Column headers are explicitly specified with setColumnHeaders

See Also:
Constant Field Values

ROW_HEADER_MODE_HIDDEN

public static final int ROW_HEADER_MODE_HIDDEN
Row caption mode: The row headers are hidden. This is the default mode.

See Also:
Constant Field Values

ROW_HEADER_MODE_ID

public static final int ROW_HEADER_MODE_ID
Row caption mode: Items Id-objects toString is used as row caption.

See Also:
Constant Field Values

ROW_HEADER_MODE_ITEM

public static final int ROW_HEADER_MODE_ITEM
Row caption mode: Item-objects toString is used as row caption.

See Also:
Constant Field Values

ROW_HEADER_MODE_INDEX

public static final int ROW_HEADER_MODE_INDEX
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.

See Also:
Constant Field Values

ROW_HEADER_MODE_EXPLICIT

public static final int ROW_HEADER_MODE_EXPLICIT
Row caption mode: Item captions are explicitly specified.

See Also:
Constant Field Values

ROW_HEADER_MODE_PROPERTY

public static final int ROW_HEADER_MODE_PROPERTY
Row caption mode: Item captions are read from property specified with setItemCaptionPropertyId.

See Also:
Constant Field Values

ROW_HEADER_MODE_ICON_ONLY

public static final int ROW_HEADER_MODE_ICON_ONLY
Row caption mode: Only icons are shown, the captions are hidden.

See Also:
Constant Field Values

ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID

public static final 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.

See Also:
Constant Field Values

alwaysRecalculateColumnWidths

protected boolean alwaysRecalculateColumnWidths
Constructor Detail

Table

public Table()
Creates a new empty table.


Table

public Table(String caption)
Creates a new empty table with caption.

Parameters:
caption -

Table

public Table(String caption,
             Container dataSource)
Creates a new table with caption and connect it to a Container.

Parameters:
caption -
dataSource -
Method Detail

getVisibleColumns

public Object[] getVisibleColumns()
Gets the array of visible column id:s, including generated columns.

The columns are show in the order of their appearance in this array.

Returns:
an array of currently visible propertyIds and generated column ids.

setVisibleColumns

public void setVisibleColumns(Object[] visibleColumns)
Sets the array of visible column property id:s.

The columns are show in the order of their appearance in this array.

Parameters:
visibleColumns - the Array of shown property id:s.

getColumnHeaders

public String[] getColumnHeaders()
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() outputs when rendering.

Returns:
the Array of column headers.

setColumnHeaders

public void setColumnHeaders(String[] columnHeaders)
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.

Parameters:
columnHeaders - the Array of column headers that match the getVisibleColumns method.

getColumnIcons

public Resource[] getColumnIcons()
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.

Returns:
the Array of icons that match the getVisibleColumns.

setColumnIcons

public void setColumnIcons(Resource[] columnIcons)
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.

Parameters:
columnIcons - the Array of icons that match the getVisibleColumns.

getColumnAlignments

public String[] getColumnAlignments()
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:

The alignments default to ALIGN_LEFT: any null values are rendered as align lefts.

Returns:
the Column alignments array.

setColumnAlignments

public void setColumnAlignments(String[] columnAlignments)
Sets the column alignments.

The items in the array must match the properties identified by getVisibleColumns(). The possible values for the alignments include:

The alignments default to ALIGN_LEFT

Parameters:
columnAlignments - the Column alignments array.

setColumnWidth

public void setColumnWidth(Object columnId,
                           int width)
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.

Parameters:
columnId - colunmns property id
width - width to be reserved for colunmns content
Since:
4.0.3

getColumnWidth

public int getColumnWidth(Object propertyId)
Gets the width of column

Parameters:
propertyId -
Returns:
width of colun or -1 when value not set

getPageLength

public int getPageLength()
Gets the page length.

Setting page length 0 disables paging.

Returns:
the Length of one page.

setPageLength

public void setPageLength(int pageLength)
Sets the page length.

Setting page length 0 disables paging. The page length defaults to 15.

Parameters:
pageLength - the Length of one page.

getCurrentPageFirstItemId

public Object getCurrentPageFirstItemId()
Getter for property currentPageFirstItem.

Returns:
the Value of property currentPageFirstItem.

setCurrentPageFirstItemId

public void setCurrentPageFirstItemId(Object currentPageFirstItemId)
Setter for property currentPageFirstItemId.

Parameters:
currentPageFirstItemId - the New value of property currentPageFirstItemId.

getColumnIcon

public Resource getColumnIcon(Object propertyId)
Gets the icon Resource for the specified column.

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.

setColumnIcon

public void setColumnIcon(Object propertyId,
                          Resource icon)
Sets the icon Resource for the specified column.

Throws IllegalArgumentException if the specified column is not visible.

Parameters:
propertyId - the propertyId identifying the column.
icon - the icon Resource to set.

getColumnHeader

public String getColumnHeader(Object propertyId)
Gets the header for the specified column.

Parameters:
propertyId - the propertyId indentifying the column.
Returns:
the header for the specifed column if it has one.

setColumnHeader

public void setColumnHeader(Object propertyId,
                            String header)
Sets the column header for the specified column;

Parameters:
propertyId - the propertyId indentifying the column.
header - the header to set.

getColumnAlignment

public String getColumnAlignment(Object propertyId)
Gets the specified column's alignment.

Parameters:
propertyId - the propertyID identifying the column.
Returns:
the specified column's alignment if it as one; null otherwise.

setColumnAlignment

public void setColumnAlignment(Object propertyId,
                               String 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

Parameters:
propertyId - the propertyID identifying the column.
alignment - the desired alignment.

isColumnCollapsed

public boolean isColumnCollapsed(Object propertyId)
Checks if the specified column is collapsed.

Parameters:
propertyId - the propertyID identifying the column.
Returns:
true if the column is collapsed; false otherwise;

setColumnCollapsed

public void setColumnCollapsed(Object propertyId,
                               boolean collapsed)
                        throws IllegalAccessException
Sets whether the specified column is collapsed or not.

Parameters:
propertyId - the propertyID identifying the column.
collapsed - the desired collapsedness.
Throws:
IllegalAccessException

isColumnCollapsingAllowed

public boolean isColumnCollapsingAllowed()
Checks if column collapsing is allowed.

Returns:
true if columns can be collapsed; false otherwise.

setColumnCollapsingAllowed

public void setColumnCollapsingAllowed(boolean collapsingAllowed)
Sets whether column collapsing is allowed or not.

Parameters:
collapsingAllowed - specifies whether column collapsing is allowed.

isColumnReorderingAllowed

public boolean isColumnReorderingAllowed()
Checks if column reordering is allowed.

Returns:
true if columns can be reordered; false otherwise.

setColumnReorderingAllowed

public void setColumnReorderingAllowed(boolean reorderingAllowed)
Sets whether column reordering is allowed or not.

Parameters:
reorderingAllowed - specifies whether column reordering is allowed.

getCurrentPageFirstItemIndex

public int getCurrentPageFirstItemIndex()
Getter for property currentPageFirstItem.

Returns:
the Value of property currentPageFirstItem.

setCurrentPageFirstItemIndex

public void setCurrentPageFirstItemIndex(int newIndex)
Setter for property currentPageFirstItem.

Parameters:
newIndex - the New value of property currentPageFirstItem.

isPageBufferingEnabled

@Deprecated
public boolean isPageBufferingEnabled()
Deprecated. functionality is not needed in ajax rendering model

Getter for property pageBuffering.

Returns:
the Value of property pageBuffering.

setPageBufferingEnabled

@Deprecated
public void setPageBufferingEnabled(boolean pageBuffering)
Deprecated. functionality is not needed in ajax rendering model

Setter for property pageBuffering.

Parameters:
pageBuffering - the New value of property pageBuffering.

isSelectable

public boolean isSelectable()
Getter for property selectable.

The table is not selectable by default.

Returns:
the Value of property selectable.

setSelectable

public void setSelectable(boolean selectable)
Setter for property selectable.

The table is not selectable by default.

Parameters:
selectable - the New value of property selectable.

getColumnHeaderMode

public int getColumnHeaderMode()
Getter for property columnHeaderMode.

Returns:
the Value of property columnHeaderMode.

setColumnHeaderMode

public void setColumnHeaderMode(int columnHeaderMode)
Setter for property columnHeaderMode.

Parameters:
columnHeaderMode - the New value of property columnHeaderMode.

refreshCurrentPage

@Deprecated
public void refreshCurrentPage()
Deprecated. should not need to be used

Refreshes the current page contents.


setRowHeaderMode

public void setRowHeaderMode(int mode)
Sets the row header mode.

The mode can be one of the following ones:

The default value is ROW_HEADER_MODE_HIDDEN

Parameters:
mode - the One of the modes listed above.

getRowHeaderMode

public int getRowHeaderMode()
Gets the row header mode.

Returns:
the Row header mode.
See Also:
setRowHeaderMode(int)

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.

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

setValue

public void setValue(Object newValue)
              throws Property.ReadOnlyException,
                     Property.ConversionException
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.

Specified by:
setValue in interface Property
Overrides:
setValue in class AbstractSelect
Parameters:
newValue - the New selected item or collection of selected items.
Throws:
Property.ReadOnlyException - if the object is in read-only mode
Property.ConversionException - if newValue can't be converted into the Property's native type directly or through String
See Also:
AbstractField.setValue(java.lang.Object)

setContainerDataSource

public void setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer. As a side-effect Table's value (selection) is set to null due old selection not necessary exists in new Container.

Specified by:
setContainerDataSource in interface Container.Viewer
Overrides:
setContainerDataSource in class AbstractSelect
Parameters:
newDataSource - the new data source.
See Also:
Container.Viewer.setContainerDataSource(Container)

changeVariables

public void changeVariables(Object source,
                            Map variables)
Invoked when the value of a variable has changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractSelect
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)

disableContentRefreshing

protected boolean disableContentRefreshing()
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).

Returns:
true if content refresh flag was enabled prior this call

enableContentRefreshing

protected void enableContentRefreshing(boolean refreshContent)
Go to mode where content content refreshing has effect.

Parameters:
refreshContent - true if content refresh needs to be done

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from class: AbstractSelect
Paints the content of this component.

Overrides:
paintContent in class AbstractSelect
Parameters:
target - the Paint Event.
Throws:
PaintException - if the paint operation failed.

getTag

public String getTag()
Description copied from class: AbstractSelect
Gets the component UIDL tag.

Overrides:
getTag in class AbstractSelect
Returns:
the Component UIDL tag as string.

getPropertyValue

protected Object getPropertyValue(Object rowId,
                                  Object colId,
                                  Property property)
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.

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:
setFieldFactory(FieldFactory)

formatPropertyValue

protected String formatPropertyValue(Object rowId,
                                     Object colId,
                                     Property property)
Formats table cell property values. By default the property.toString() and return a empty string for null properties.

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

addActionHandler

public void addActionHandler(Action.Handler actionHandler)
Registers a new action handler for this container

Specified by:
addActionHandler in interface Action.Container
Parameters:
actionHandler - the new handler to be added.
See Also:
Action.Container.addActionHandler(Action.Handler)

removeActionHandler

public void removeActionHandler(Action.Handler actionHandler)
Removes a previously registered action handler for the contents of this container.

Specified by:
removeActionHandler in interface Action.Container
Parameters:
actionHandler - the handler to be removed.
See Also:
Action.Container.removeActionHandler(Action.Handler)

valueChange

public void valueChange(Property.ValueChangeEvent event)
Notifies this listener that the Property's value has changed. Also listens changes in rendered items to refresh content area.

Specified by:
valueChange in interface Property.ValueChangeListener
Overrides:
valueChange in class AbstractField
Parameters:
event - the value change event telling the data source contents have changed.
See Also:
Property.ValueChangeListener.valueChange(Property.ValueChangeEvent)

attach

public void attach()
Notifies the component that it is connected to an application.

Specified by:
attach in interface Component
Overrides:
attach in class AbstractSelect
See Also:
Component.attach()

detach

public void detach()
Notifies the component that it is detached from the application

Specified by:
detach in interface Component
Overrides:
detach in class AbstractSelect
See Also:
Component.detach()

removeAllItems

public boolean removeAllItems()
Removes all Items from the Container.

Specified by:
removeAllItems in interface Container
Overrides:
removeAllItems in class AbstractSelect
Returns:
True if the operation succeeded.
See Also:
Container.removeAllItems()

removeItem

public boolean removeItem(Object itemId)
Removes the Item identified by ItemId from the Container.

Specified by:
removeItem in interface Container
Overrides:
removeItem in class AbstractSelect
Parameters:
itemId - ID of the Item to remove
Returns:
True if the operation succeeded.
See Also:
Container.removeItem(Object)

removeContainerProperty

public boolean removeContainerProperty(Object propertyId)
                                throws UnsupportedOperationException
Removes a Property specified by the given Property ID from the Container.

Specified by:
removeContainerProperty in interface Container
Overrides:
removeContainerProperty in class AbstractSelect
Parameters:
propertyId - ID of the Property to remove
Returns:
True if the operation succeeded.
Throws:
UnsupportedOperationException
See Also:
Container.removeContainerProperty(Object)

addContainerProperty

public boolean addContainerProperty(Object propertyId,
                                    Class type,
                                    Object defaultValue)
                             throws UnsupportedOperationException
Adds a new property to the table and show it as a visible column.

Specified by:
addContainerProperty in interface Container
Overrides:
addContainerProperty in class AbstractSelect
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
See Also:
Container.addContainerProperty(Object, Class, Object)

addContainerProperty

public boolean addContainerProperty(Object propertyId,
                                    Class type,
                                    Object defaultValue,
                                    String columnHeader,
                                    Resource columnIcon,
                                    String columnAlignment)
                             throws UnsupportedOperationException
Adds a new property to the table and show it as a visible column.

Parameters:
propertyId - the Id of the proprty
type - the class of the property
defaultValue - the default value given for all existing items
columnHeader - 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)

addGeneratedColumn

public void addGeneratedColumn(Object id,
                               Table.ColumnGenerator generatedColumn)
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.

Also note that getVisibleColumns() will return the generated columns, while getContainerPropertyIds() will not.

Parameters:
id - the id of the column to be added
generatedColumn - the Table.ColumnGenerator to use for this column

removeGeneratedColumn

public boolean removeGeneratedColumn(Object columnId)
Removes a generated column previously added with addGeneratedColumn.

Parameters:
columnId - id of the generated column to remove
Returns:
true if the column could be removed (existed in the Table)

getVisibleItemIds

public Collection getVisibleItemIds()
Returns the list of items on the current page

Overrides:
getVisibleItemIds in class AbstractSelect
See Also:
AbstractSelect.getVisibleItemIds()

containerItemSetChange

public void containerItemSetChange(Container.ItemSetChangeEvent event)
Container datasource item set change. Table must flush its buffers on change.

Specified by:
containerItemSetChange in interface Container.ItemSetChangeListener
Overrides:
containerItemSetChange in class AbstractSelect
Parameters:
event - change event text
See Also:
Container.ItemSetChangeListener.containerItemSetChange(com.itmill.toolkit.data.Container.ItemSetChangeEvent)

containerPropertySetChange

public void containerPropertySetChange(Container.PropertySetChangeEvent event)
Container datasource property set change. Table must flush its buffers on change.

Specified by:
containerPropertySetChange in interface Container.PropertySetChangeListener
Overrides:
containerPropertySetChange in class AbstractSelect
Parameters:
event - Change event.
See Also:
Container.PropertySetChangeListener.containerPropertySetChange(com.itmill.toolkit.data.Container.PropertySetChangeEvent)

setNewItemsAllowed

public void setNewItemsAllowed(boolean allowNewOptions)
                        throws UnsupportedOperationException
Adding new items is not supported.

Overrides:
setNewItemsAllowed in class AbstractSelect
Parameters:
allowNewOptions - the New value of property allowNewOptions.
Throws:
UnsupportedOperationException - if set to true.
See Also:
AbstractSelect.setNewItemsAllowed(boolean)

focus

public void focus()
           throws UnsupportedOperationException
Focusing to this component is not supported.

Specified by:
focus in interface Component.Focusable
Overrides:
focus in class AbstractField
Throws:
UnsupportedOperationException - if invoked.
See Also:
AbstractField.focus()

nextItemId

public Object nextItemId(Object itemId)
Gets the ID of the Item following the Item that corresponds to itemId.

Specified by:
nextItemId in interface Container.Ordered
Parameters:
itemId - ID of an Item in the Container
Returns:
ID of the next Item or null
See Also:
Container.Ordered.nextItemId(java.lang.Object)

prevItemId

public Object prevItemId(Object itemId)
Gets the ID of the Item preceding the Item that corresponds to the itemId.

Specified by:
prevItemId in interface Container.Ordered
Parameters:
itemId - ID of an Item in the Container
Returns:
ID of the previous Item or null
See Also:
Container.Ordered.prevItemId(java.lang.Object)

firstItemId

public Object firstItemId()
Gets the ID of the first Item in the Container.

Specified by:
firstItemId in interface Container.Ordered
Returns:
ID of the first Item in the Container
See Also:
Container.Ordered.firstItemId()

lastItemId

public Object lastItemId()
Gets the ID of the last Item in the Container.

Specified by:
lastItemId in interface Container.Ordered
Returns:
ID of the last Item in the Container
See Also:
Container.Ordered.lastItemId()

isFirstId

public boolean isFirstId(Object itemId)
Tests if the Item corresponding to the given Item ID is the first Item in the Container.

Specified by:
isFirstId in interface Container.Ordered
Parameters:
itemId - ID of an Item in the Container
Returns:
true if the Item is first in the Container, false if not
See Also:
Container.Ordered.isFirstId(java.lang.Object)

isLastId

public boolean isLastId(Object itemId)
Tests if the Item corresponding to the given Item ID is the last Item in the Container.

Specified by:
isLastId in interface Container.Ordered
Returns:
true if the Item is last in the Container, false if not
See Also:
Container.Ordered.isLastId(java.lang.Object)

addItemAfter

public Object addItemAfter(Object previousItemId)
                    throws UnsupportedOperationException
Adds new item after the given item.

Specified by:
addItemAfter in interface Container.Ordered
Parameters:
previousItemId - Id of the previous item in ordered container.
Returns:
Returns item id the the created new item or null if the operation fails.
Throws:
UnsupportedOperationException
See Also:
Container.Ordered.addItemAfter(java.lang.Object)

addItemAfter

public Item addItemAfter(Object previousItemId,
                         Object newItemId)
                  throws UnsupportedOperationException
Adds new item after the given item.

Specified by:
addItemAfter in interface Container.Ordered
Parameters:
previousItemId - Id of the previous item in ordered container.
newItemId - Id of the new item to be added.
Returns:
Returns new item or null if the operation fails.
Throws:
UnsupportedOperationException
See Also:
Container.Ordered.addItemAfter(java.lang.Object, java.lang.Object)

getFieldFactory

public FieldFactory getFieldFactory()
Gets the FieldFactory that is used to create editor for table cells. The FieldFactory is only used if the Table is editable.

Returns:
FieldFactory used to create the Field instances.
See Also:
isEditable()

setFieldFactory

public void setFieldFactory(FieldFactory fieldFactory)
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.

Parameters:
fieldFactory - the field factory to set.
See Also:
isEditable(), BaseFieldFactory

isEditable

public boolean isEditable()
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.

Returns:
true if table is editable, false oterwise.
See Also:
Field, FieldFactory

setEditable

public void setEditable(boolean editable)
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.

Parameters:
editable - true if table should be editable by user.
See Also:
Field, FieldFactory

sort

public void sort(Object[] propertyId,
                 boolean[] ascending)
          throws UnsupportedOperationException
Sorts the table.

Specified by:
sort in interface Container.Sortable
Parameters:
propertyId - Array of container property IDs, which 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 by 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. Use true 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[])

sort

public void sort()
Sorts the table by currently selected sorting column.

Throws:
UnsupportedOperationException - if the container data source does not implement Container.Sortable

getSortableContainerPropertyIds

public Collection getSortableContainerPropertyIds()
Gets the container property IDs, which can be used to sort the item.

Specified by:
getSortableContainerPropertyIds in interface Container.Sortable
Returns:
The sortable field ids.
See Also:
Container.Sortable.getSortableContainerPropertyIds()

getSortContainerPropertyId

public Object getSortContainerPropertyId()
Gets the currently sorted column property ID.

Returns:
the Container property id of the currently sorted column.

setSortContainerPropertyId

public void setSortContainerPropertyId(Object propertyId)
Sets the currently sorted column property id.

Parameters:
propertyId - the Container property id of the currently sorted column.

isSortAscending

public boolean isSortAscending()
Is the table currently sorted in ascending order.

Returns:
true if ascending, false if descending.

setSortAscending

public void setSortAscending(boolean ascending)
Sets the table in ascending order.

Parameters:
ascending - true if ascending, false if descending.

isSortDisabled

public boolean isSortDisabled()
Is sorting disabled altogether. True iff no sortable columns are given even in the case where data source would support this.

Returns:
True iff sorting is disabled.

setSortDisabled

public void setSortDisabled(boolean sortDisabled)
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.

Parameters:
sortDisabled - True iff sorting is disabled.

setLazyLoading

public void setLazyLoading(boolean useLazyLoading)
Table does not support lazy options loading mode. Setting this true will throw UnsupportedOperationException.

See Also:
com.itmill.toolkit.ui.Select#setLazyLoading(boolean)

toString

public String toString()
Description copied from class: AbstractField
Returns the value of the Property in human readable textual format.

Specified by:
toString in interface Property
Overrides:
toString in class AbstractField
Returns:
String representation of the value stored in the Property
See Also:
Object.toString()

setCellStyleGenerator

public void setCellStyleGenerator(Table.CellStyleGenerator cellStyleGenerator)
Set cell style generator for Table.

Parameters:
cellStyleGenerator - New cell style generator or null to remove generator.

getCellStyleGenerator

public Table.CellStyleGenerator getCellStyleGenerator()
Get the current cell style generator.


addListener

public void addListener(ItemClickEvent.ItemClickListener listener)
Description copied from interface: ItemClickEvent.ItemClickSource
Register listener to handle ItemClickEvents. Note! Click listeners are rather terminal dependent features. This feature is EXPERIMENTAL

Specified by:
addListener in interface ItemClickEvent.ItemClickSource
Parameters:
listener - ItemClickListener to be registered

removeListener

public void removeListener(ItemClickEvent.ItemClickListener listener)
Description copied from interface: ItemClickEvent.ItemClickSource
Removes ItemClickListener.

Specified by:
removeListener in interface ItemClickEvent.ItemClickSource

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: Component
Enables or disables the component. Being enabled means that the component can be edited. This method will trigger a RepaintRequestEvent.

Note that after enabling a component, Component.isEnabled() might still return false if the parent is disabled.

Also note that if the component contains child-components, it should recursively call requestRepaint() for all descendant components.

Specified by:
setEnabled in interface Component
Overrides:
setEnabled in class AbstractComponent
Parameters:
enabled - the boolean value specifying if the component should be enabled after the call or not

requestRepaintAll

public void requestRepaintAll()


Copyright © 2000-2009 IT Mill Ltd. All Rights Reserved.