Class 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>
    This is a ListModel to be used with Listbox. The model allows for a table structure to be created, with columns in addition to the rows provided by ListModelList.
    Author:
    Andrew Kimball
    See Also:
    Serialized Form
      • 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
        protected ArrayList<WTableModelListener> m_listeners
        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
        ListModelTable()
        Default constructor.
        ListModelTable​(Collection<?> collection)
        Construct the ListModel with a collection of objects.
      • Method Summary

        All Methods Instance Methods Concrete Methods 
        Modifier and Type Method Description
        void addColumn()
        Add a column to the model.
        void addTableModelListener​(WTableModelListener listener)
        Add a listener for events from the data model.
        Object getDataAt​(int rowIndex, int columnIndex)
        Returns the cell value at rowIndex and columnIndex.
        int getNoColumns()
        Query thenumber of columns in the table.
        int getNoRows()
        Query the number of rows in the table.
        int getRowCount()
        alias for getSize, to ease porting of swing form
        Object getValueAt​(int rowIndex, int columnIndex)
        alias for getDataAt, to ease porting of swing form
        void removeTableModelListener​(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.
        void setSorter​(org.zkoss.zul.ext.Sortable<Object> lme)  
        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, addSelection, clear, clone, contains, containsAll, equals, fireSelectionEvent, get, getElementAt, getInnerList, getSize, getSortDirection, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, notifyChange, remove, remove, removeAll, removeRange, removeSelection, retainAll, set, size, sort, subList, toArray, toArray, toString
        • Methods inherited from class org.zkoss.zul.AbstractListModel

          addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getPageCount, getPageSize, getSelection, getSelectionControl, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl, writeSelection
        • Methods inherited from interface org.zkoss.zul.ext.Sortable

          getSortDirection, sort
      • Constructor Detail

        • 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 objects should be vectors of objects
          Parameters:
          collection - The collection of objects with which to initialise the list
          • Method Detail

            • getNoColumns

              public int getNoColumns()
              Query thenumber 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()
              Query 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. 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)
            • 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)