1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.contrib.table.model.common; |
16 |
| |
17 |
| import java.io.Serializable; |
18 |
| |
19 |
| import org.apache.tapestry.contrib.table.model.ITableModel; |
20 |
| import org.apache.tapestry.contrib.table.model.ITablePagingState; |
21 |
| import org.apache.tapestry.contrib.table.model.ITableSortingState; |
22 |
| import org.apache.tapestry.contrib.table.model.simple.SimpleTableState; |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| public abstract class AbstractTableModel implements ITableModel, Serializable |
31 |
| { |
32 |
| private SimpleTableState m_objTableState; |
33 |
| |
34 |
0
| protected AbstractTableModel()
|
35 |
| { |
36 |
0
| this(new SimpleTableState());
|
37 |
| } |
38 |
| |
39 |
0
| protected AbstractTableModel(SimpleTableState objTableState)
|
40 |
| { |
41 |
0
| m_objTableState = objTableState;
|
42 |
| } |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
0
| public ITablePagingState getPagingState()
|
48 |
| { |
49 |
0
| return getState().getPagingState();
|
50 |
| } |
51 |
| |
52 |
| |
53 |
| |
54 |
| |
55 |
0
| public ITableSortingState getSortingState()
|
56 |
| { |
57 |
0
| return getState().getSortingState();
|
58 |
| } |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
0
| public SimpleTableState getState()
|
65 |
| { |
66 |
0
| return m_objTableState;
|
67 |
| } |
68 |
| |
69 |
| protected abstract int getRowCount(); |
70 |
| |
71 |
0
| public int getPageCount()
|
72 |
| { |
73 |
0
| int nRowCount = getRowCount();
|
74 |
0
| if (nRowCount == 0)
|
75 |
0
| return 1;
|
76 |
| |
77 |
0
| int nPageSize = getPagingState().getPageSize();
|
78 |
0
| if (nPageSize <= 0)
|
79 |
0
| return 1;
|
80 |
| |
81 |
0
| return (nRowCount - 1) / nPageSize + 1;
|
82 |
| } |
83 |
| |
84 |
| } |