Class ListModelTable

java.lang.Object
org.zkoss.zul.AbstractListModel<E>
org.zkoss.zul.ListModelList<Object>
org.adempiere.webui.component.ListModelTable
All Implemented Interfaces:
Serializable, Iterable<Object>, Collection<Object>, List<Object>, org.zkoss.zul.ext.Pageable, org.zkoss.zul.ext.Selectable<Object>, org.zkoss.zul.ext.Sortable<Object>, org.zkoss.zul.ListModel<Object>, org.zkoss.zul.PageableModel

public class ListModelTable extends org.zkoss.zul.ListModelList<Object> implements org.zkoss.zul.ext.Sortable<Object>
ListModel for Listbox and provide support for the Sortable interface.
The model allows for a table structure to be created with columns, in addition to the functionalities provided by ListModelList.
Author:
Andrew Kimball
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.zkoss.zul.AbstractListModel

    org.zkoss.zul.AbstractListModel.DefaultSelectionControl<E extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Array of listeners to changes in the table model.

    Fields inherited from class org.zkoss.zul.ListModelList

    _list

    Fields inherited from class org.zkoss.zul.AbstractListModel

    _selection

    Fields inherited from interface org.zkoss.zul.PageableModel

    INTERNAL_EVENT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    ListModelTable(Collection<?> collection)
    Construct the ListModel with a collection of objects.
    A copy is made of the collection.
    The element in collection should be vector of objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a column to the model.
    void
    Add a listener for events from the data model.
    getDataAt(int rowIndex, int columnIndex)
    Returns the cell value at rowIndex and columnIndex.
    int
    Get the number of columns in the table.
    int
    Get the number of rows in the table.
    int
    Alias for getSize, to ease porting of swing form
    getValueAt(int rowIndex, int columnIndex)
    Alias for getDataAt, to ease porting of swing form
    void
    Remove WTableModelListener listener
    void
    setDataAt(Object aValue, int row, int col)
    Set the cell value at row and column.
    void
    setNoColumns(int columns)
    Set the number of columns that the table is to contain.
    void
    setNoRows(int rowCount)
    Set the number of rows in the table and initialise new rows (if necessary).
    For each new row, an empty collection of the size specified by setNoColumns(int) is created.
    void
    setSorter(org.zkoss.zul.ext.Sortable<Object> lme)
    Set custom sorter for model
    void
    setValueAt(Object value, int row, int col)
    Alias for setDataAt, to ease porting of swing form
    void
    sort(Comparator<Object> cmpr, boolean ascending)
     
    void
    updateComponent(int row)
    Request components that attached to this model to re-render a row.
    void
    updateComponent(int fromRow, int toRow)
    Request components that attached to this model to re-render a range of row.

    Methods inherited from class org.zkoss.zul.ListModelList

    add, add, addAll, addAll, clear, clone, contains, containsAll, equals, fireSelectionEvent, get, getElementAt, getInnerList, getSize, getSortDirection, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, notifyChange, remove, remove, removeAll, removeRange, retainAll, set, size, sort, subList, toArray, toArray, toString

    Methods inherited from class org.zkoss.zul.AbstractListModel

    addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getListDataListeners, getPageCount, getPageSize, getSelection, getSelectionControl, getTotalSize, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl, writeSelection

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.List

    replaceAll, sort, spliterator

    Methods inherited from interface org.zkoss.zul.ext.Sortable

    getSortDirection, sort
    • Field Details

    • Constructor Details

      • ListModelTable

        public ListModelTable()
        Default constructor.
      • ListModelTable

        public ListModelTable(Collection<?> collection)
        Construct the ListModel with a collection of objects.
        A copy is made of the collection.
        The element in collection should be vector of objects.
        Parameters:
        collection - The collection of objects with which to initialise the list
      • Method Details

        • getNoColumns

          public int getNoColumns()
          Get the number of columns in the table.
          Returns:
          the number of columns in the table. 0 if uninitialised.
        • addColumn

          public void addColumn()
          Add a column to the model.
        • setNoColumns

          public void setNoColumns(int columns)
          Set the number of columns that the table is to contain.
          Parameters:
          columns - The number of columns.
        • getNoRows

          public int getNoRows()
          Get the number of rows in the table.
          Returns:
          the number of rows in the table
        • getDataAt

          public Object getDataAt(int rowIndex, int columnIndex)
          Returns the cell value at rowIndex and columnIndex.
          Parameters:
          rowIndex - the index of the row whose value is to be queried
          columnIndex - the index of the column whose value is to be queried
          Returns:
          The object stored at the specified position
        • setDataAt

          public void setDataAt(Object aValue, int row, int col)
          Set the cell value at row and column.
          Parameters:
          aValue - The value to set
          row - the index of the row whose value is to be set
          col - the index of the column whose value is to be set
        • setNoRows

          public void setNoRows(int rowCount)
          Set the number of rows in the table and initialise new rows (if necessary).
          For each new row, an empty collection of the size specified by setNoColumns(int) is created.
          Parameters:
          rowCount - The number of rows to be contained in the table
        • addTableModelListener

          public void addTableModelListener(WTableModelListener listener)
          Add a listener for events from the data model.

          The listener will only be added if it doesn't already exist.

          Parameters:
          listener - A listener for changes in the table mode
        • removeTableModelListener

          public void removeTableModelListener(WTableModelListener listener)
          Remove WTableModelListener listener
          Parameters:
          listener -
        • sort

          public void sort(Comparator<Object> cmpr, boolean ascending)
          Specified by:
          sort in interface org.zkoss.zul.ext.Sortable<Object>
          Overrides:
          sort in class org.zkoss.zul.ListModelList<Object>
        • getValueAt

          public Object getValueAt(int rowIndex, int columnIndex)
          Alias for getDataAt, to ease porting of swing form
          Parameters:
          rowIndex -
          columnIndex -
          Returns:
          column value
        • setValueAt

          public void setValueAt(Object value, int row, int col)
          Alias for setDataAt, to ease porting of swing form
          Parameters:
          value -
          row -
          col -
        • getRowCount

          public int getRowCount()
          Alias for getSize, to ease porting of swing form
          Returns:
          size
        • updateComponent

          public void updateComponent(int row)
          Request components that attached to this model to re-render a row.
          Parameters:
          row -
        • updateComponent

          public void updateComponent(int fromRow, int toRow)
          Request components that attached to this model to re-render a range of row.
          Parameters:
          fromRow -
          toRow -
        • setSorter

          public void setSorter(org.zkoss.zul.ext.Sortable<Object> lme)
          Set custom sorter for model
          Parameters:
          lme - Custom Sortable implementation