Adempiere 3.4.0s

org.adempiere.webui.component
Class ListModelTable

java.lang.Object
  extended by org.zkoss.zul.AbstractListModel
      extended by org.zkoss.zul.ListModelList
          extended by org.adempiere.webui.component.ListModelTable
All Implemented Interfaces:
Serializable, Iterable, Collection, List, org.zkoss.zul.ListModel, org.zkoss.zul.ListModelExt

public class ListModelTable
extends org.zkoss.zul.ListModelList
implements org.zkoss.zul.ListModelExt

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

Field Summary
protected  ArrayList<WTableModelListener> m_listeners
          Array of listeners to changes in the table model.
 
Fields inherited from class org.zkoss.zul.ListModelList
_list
 
Constructor Summary
ListModelTable()
          Default constructor.
ListModelTable(Collection collection)
          Construct the ListModel with a collection of objects.
 
Method Summary
 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.
 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 sort(Comparator cmpr, boolean ascending)
           
 
Methods inherited from class org.zkoss.zul.ListModelList
add, add, addAll, addAll, clear, contains, containsAll, equals, get, getElementAt, getInnerList, getSize, hashCode, indexOf, instance, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeRange, retainAll, set, size, subList, toArray, toArray, toString
 
Methods inherited from class org.zkoss.zul.AbstractListModel
addListDataListener, fireEvent, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_listeners

protected ArrayList<WTableModelListener> m_listeners
Array of listeners to changes in the table model.

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. Please note that the number of rows in a table cannot be decreased.

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 cmpr,
                 boolean ascending)
Specified by:
sort in interface org.zkoss.zul.ListModelExt
Overrides:
sort in class org.zkoss.zul.ListModelList

Adempiere 3.4.0s

AdemPiere