com.itmill.toolkit.ui
Class Table

java.lang.Object
  extended by com.itmill.toolkit.terminal.Identifiable
      extended by com.itmill.toolkit.ui.AbstractComponent
          extended by com.itmill.toolkit.ui.AbstractField
              extended by com.itmill.toolkit.ui.Select
                  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, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, EventListener

public class Table
extends Select
implements Action.Container, Container.Ordered, Container.Sortable, Sizeable

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

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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.Select
Select.OptionsStream
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractField
AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
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.
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.Select
ITEM_CAPTION_MODE_EXPLICIT, ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID, ITEM_CAPTION_MODE_ICON_ONLY, ITEM_CAPTION_MODE_ID, ITEM_CAPTION_MODE_INDEX, ITEM_CAPTION_MODE_ITEM, ITEM_CAPTION_MODE_PROPERTY, itemIdMapper, items
 
Fields inherited from interface com.itmill.toolkit.terminal.Sizeable
UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNITS_ROWS
 
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.
 Object addItem(Object[] cells, Object itemId)
          Adds the new row to table and fill the visible cells 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 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
 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.
 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.
 String getColumnStyle(Object propertyId)
          Return the stylename for a column.
 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 getHeight()
          Gets the height in pixels.
 int getHeightUnits()
          Gets the height property units.
 Object getItemStylePropertyId()
          Gets the property id to used for styling rows.
 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 UIDL tag corresponding to component.
 int getWidth()
          Gets the width in pixels.
 int getWidthUnits()
          Gets the width property units.
 Object[] getVisibleColumns()
          Gets the array of visible column property id:s.
 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()
          Getter for property pageBuffering.
 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()
          Refreshes the current page contents.
 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 removeItem(Object itemId)
          Removes the Item identified by ItemId from the Container.
 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 setColumnStyle(Object propertyId, String style)
          Set the stylename for a column.
 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 setFieldFactory(FieldFactory fieldFactory)
          Sets the FieldFactory that is used to create editor for table cells.
 void setHeight(int height)
          Sets the height in pixels.
 void setHeightUnits(int units)
          Sets the height units.
 void setItemStylePropertyId(Object propertyId)
          Sets the property id to use for styling rows.
 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)
          Setter for property pageBuffering.
 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 setWidth(int width)
          Sets the width in pixels.
 void setWidthUnits(int units)
          Sets the width units.
 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.
 void valueChange(Property.ValueChangeEvent event)
          Notifies this listener that the Property's value has changed.
 
Methods inherited from class com.itmill.toolkit.ui.Select
addItem, addItem, addListener, addListener, containsId, escapeJSON, fireItemSetChange, firePropertySetChange, getContainerDataSource, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getItemIds, getNullSelectionItemId, getOptionFilter, getType, getType, getValue, isLazyLoading, isMultiSelect, isNewItemsAllowed, isSelected, removeListener, removeListener, select, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIcon, setItemIconPropertyId, setLazyLoading, setMultiSelect, setNullSelectionItemId, setOptionFilter, setValue, size, unselect
 
Methods inherited from class com.itmill.toolkit.ui.AbstractField
addListener, addListener, addValidator, commit, constructField, discard, finalize, fireReadOnlyStatusChange, fireValueChange, getErrorMessage, getFocusableId, getPropertyDataSource, getTabIndex, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isWriteThrough, removeListener, removeListener, removeValidator, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setTabIndex, setWriteThrough, toString, validate
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, childRequestedRepaint, dependsOn, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible
 
Methods inherited from class com.itmill.toolkit.terminal.Identifiable
getDebugId, getUIID, setDebugId, setUIID
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.itmill.toolkit.ui.Field
getDescription, setCaption, setDescription
 
Methods inherited from interface com.itmill.toolkit.ui.Component
addListener, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isVisible, removeListener, setEnabled, setParent, setStyle, setVisible
 
Methods inherited from interface com.itmill.toolkit.terminal.Paintable
addListener, paint, removeListener, requestRepaint, requestRepaintRequests
 
Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner
dependsOn, getDirectDependencies, isImmediate, removeDirectDependency
 

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 behaviour.

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
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 property id:s.

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

Returns:
the Value of property availableColumns.

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 ROW_HEADER_MODE_EXPLICIT or ROW_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 ROW_HEADER_MODE_EXPLICIT or ROW_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 ROW_HEADER_MODE_EXPLICIT or ROW_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 ROW_HEADER_MODE_EXPLICIT or ROW_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 - column property id
width - width to be reserved for column content
Since:
4.0.3

getColumnWidth

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

Parameters:
propertyId -
Returns:
width of column 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 identifying 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 identifying the column.
Returns:
the header for the specified 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 identifying 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

public boolean isPageBufferingEnabled()
Getter for property pageBuffering.

Returns:
the Value of property pageBuffering.

setPageBufferingEnabled

public void setPageBufferingEnabled(boolean pageBuffering)
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

public void refreshCurrentPage()
Refreshes the current page contents. If the page buffering is turned off, it is not necessary to call this explicitly.


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)

setItemStylePropertyId

public void setItemStylePropertyId(Object propertyId)
Sets the property id to use for styling rows. Does not check if the propertyId exists; does nothing if not. The stylename will be created using toString() on the property, and all non-alphanumeric characters except "-" ([^\\w-]) will be replaced with underscore. Also note that the theme will probably add a prefix to the stylename. For example "a_b-c.'1'" might become "rowstyle-a_b-c__1_".

Parameters:
propertyId - Id of the property to use for row styling

getItemStylePropertyId

public Object getItemStylePropertyId()
Gets the property id to used for styling rows.


addItem

public Object addItem(Object[] cells,
                      Object itemId)
               throws UnsupportedOperationException
Adds the new row to table and fill the visible cells 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 can't already have a item with given id.
Returns:
Returns item id for the new row. Returns null if operation fails.
Throws:
UnsupportedOperationException

setContainerDataSource

public void setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer.

Specified by:
setContainerDataSource in interface Container.Viewer
Overrides:
setContainerDataSource in class Select
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 Select
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)

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

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

getTag

public String getTag()
Gets the UIDL tag corresponding to component.

Overrides:
getTag in class Select
Returns:
the 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.

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 Select
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 Select
See Also:
Component.detach()

removeAllItems

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

Specified by:
removeAllItems in interface Container
Overrides:
removeAllItems in class Select
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 Select
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 Select
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 Select
Parameters:
propertyId - the Id of the property.
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 property
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)

getVisibleItemIds

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

Overrides:
getVisibleItemIds in class Select
See Also:
Select.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 Select
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 Select
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 Select
Parameters:
allowNewOptions - the New value of property allowNewOptions.
Throws:
UnsupportedOperationException - if set to true.
See Also:
Select.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 implementing the FieldFactory interface, and assign it to table, and set the editable property to true.

Returns:
true if table is editable, false otherwise.
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 implementing 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 datasource 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.

getHeightUnits

public int getHeightUnits()
Gets the height property units.

Specified by:
getHeightUnits in interface Sizeable
Returns:
units used in height property.
See Also:
Sizeable.getHeightUnits()

getWidthUnits

public int getWidthUnits()
Gets the width property units.

Specified by:
getWidthUnits in interface Sizeable
Returns:
units used in width property.
See Also:
Sizeable.getWidthUnits()

setHeightUnits

public void setHeightUnits(int units)
Sets the height units. Table supports only Sizeable.UNITS_PIXELS. Setting to any other throws IllegalArgumentException.

Specified by:
setHeightUnits in interface Sizeable
Parameters:
units - the units used in height property.
See Also:
Sizeable.setHeightUnits(int)

setWidthUnits

public void setWidthUnits(int units)
Sets the width units. Table supports only Sizeable.UNITS_PIXELS and Sizeable.UNITS_PERCENTAGE. Setting to any other throws IllegalArgumentException.

Specified by:
setWidthUnits in interface Sizeable
Parameters:
units - the units used in width property.
See Also:
Sizeable.setWidthUnits(int)

getHeight

public int getHeight()
Gets the height in pixels.

Specified by:
getHeight in interface Sizeable
Returns:
the height in pixels or negative value if not assigned.
See Also:
Sizeable.getHeight()

getWidth

public int getWidth()
Gets the width in pixels.

Specified by:
getWidth in interface Sizeable
Returns:
the width in pixels or negative value if not assigned.
See Also:
Sizeable.getWidth()

setHeight

public void setHeight(int height)
Sets the height in pixels. Use negative value to let the client decide the height.

Specified by:
setHeight in interface Sizeable
Parameters:
height - the height to set.

setWidth

public void setWidth(int width)
Sets the width in pixels. Use negative value to allow the client decide the width.

Specified by:
setWidth in interface Sizeable
Parameters:
width - the width to set.

setLazyLoading

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

Overrides:
setLazyLoading in class Select
See Also:
Select.setLazyLoading(boolean)

setColumnStyle

public void setColumnStyle(Object propertyId,
                           String style)
Set the stylename for a column. Any previous value will be overridden. This value will be prefixed with "colstyle-" on the client side, and it will be used e.g. as a CSS classname.

Parameters:
propertyId - the column identifier.
style - stylename for the column. Use null to remove styles from a column.

getColumnStyle

public String getColumnStyle(Object propertyId)
Return the stylename for a column.

Parameters:
propertyId - the column identifier.
Returns:
the stylename assosiated with the column or null.


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