1 15 package org.apache.tapestry.contrib.table.model.common; 16 17 import java.util.Iterator ; 18 19 import org.apache.tapestry.contrib.table.model.IBasicTableModel; 20 import org.apache.tapestry.contrib.table.model.ITableColumn; 21 import org.apache.tapestry.contrib.table.model.ITableColumnModel; 22 import org.apache.tapestry.contrib.table.model.simple.SimpleTableState; 23 24 27 public class BasicTableModelWrap extends AbstractTableModel 28 { 29 private static final long serialVersionUID = 1L; 30 31 private IBasicTableModel m_objBasicTableModel; 32 private ITableColumnModel m_objTableColumnModel; 33 34 public BasicTableModelWrap(IBasicTableModel objBasicTableModel, ITableColumnModel objColumnModel) 35 { 36 this(objBasicTableModel, objColumnModel, new SimpleTableState()); 37 } 38 39 public BasicTableModelWrap(IBasicTableModel objBasicTableModel, ITableColumnModel objColumnModel, SimpleTableState objState) 40 { 41 super(objState); 42 m_objBasicTableModel = objBasicTableModel; 43 m_objTableColumnModel = objColumnModel; 44 } 45 46 49 public ITableColumnModel getColumnModel() 50 { 51 return m_objTableColumnModel; 52 } 53 54 57 protected int getRowCount() 58 { 59 return m_objBasicTableModel.getRowCount(); 60 } 61 62 65 public Iterator getCurrentPageRows() 66 { 67 int nPageSize = getPagingState().getPageSize(); 68 if (nPageSize <= 0) 69 nPageSize = getRowCount(); 70 71 int nCurrentPage = getPagingState().getCurrentPage(); 72 int nFrom = nCurrentPage * nPageSize; 73 74 String strSortColumn = getSortingState().getSortColumn(); 75 ITableColumn objSortColumn = getColumnModel().getColumn(strSortColumn); 76 boolean bSortOrder = getSortingState().getSortOrder(); 77 78 return m_objBasicTableModel.getCurrentPageRows(nFrom, nPageSize, objSortColumn, bSortOrder); 79 } 80 81 } 82 | Popular Tags |