Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ITableColumn |
|
| 1.0;1 |
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.contrib.table.model; | |
16 | ||
17 | import java.util.Comparator; | |
18 | ||
19 | import org.apache.tapestry.IRender; | |
20 | import org.apache.tapestry.IRequestCycle; | |
21 | ||
22 | /** | |
23 | * The interface defining a table column. A column is responsible for presenting | |
24 | * a particular part of the data from the objects in the table. This is done via | |
25 | * the getValueRender() method. A column may be sortable, in which case it | |
26 | * defines the way in which the objects in the table must be sorted by providing | |
27 | * a Comparator. | |
28 | * | |
29 | * @author mindbridge | |
30 | */ | |
31 | public interface ITableColumn | |
32 | { | |
33 | ||
34 | /** | |
35 | * Method getColumnName provides the name of the column. The column name | |
36 | * must be unique and is generally used for the identification of the | |
37 | * column. It does not have to be the same as the display name via which the | |
38 | * column is identified to the user (see the getColumnRender() method). | |
39 | * | |
40 | * @return String the name of the column | |
41 | */ | |
42 | String getColumnName(); | |
43 | ||
44 | /** | |
45 | * Method getSortable declares whether the column allows sorting. If the | |
46 | * column allows sorting, it must also return a valid Comparator via the | |
47 | * getComparator() method. | |
48 | * | |
49 | * @return boolean whether the column is sortable or not | |
50 | */ | |
51 | boolean getSortable(); | |
52 | ||
53 | /** | |
54 | * Method getComparator returns the Comparator to be used to sort the data | |
55 | * in the table according to this column. The Comparator must accept two | |
56 | * different rows, compare them according to this column, and return the | |
57 | * appropriate value. | |
58 | * | |
59 | * @return Comparator the Comparator used to sort the table data | |
60 | */ | |
61 | Comparator getComparator(); | |
62 | ||
63 | /** | |
64 | * Method getColumnRenderer provides a renderer that takes care of rendering | |
65 | * the column in the table header. If the column is sortable, the renderer | |
66 | * may provide a mechanism to sort the table in an ascending or descending | |
67 | * manner. | |
68 | * | |
69 | * @param objCycle | |
70 | * the current request cycle | |
71 | * @param objSource | |
72 | * a component that can provide the table model (typically | |
73 | * TableView) | |
74 | * @return IRender the renderer to present the column header | |
75 | */ | |
76 | IRender getColumnRenderer(IRequestCycle objCycle, | |
77 | ITableModelSource objSource); | |
78 | ||
79 | /** | |
80 | * Method getValueRenderer provides a renderer for presenting the value of a | |
81 | * particular row in the current column. | |
82 | * | |
83 | * @param objCycle | |
84 | * the current request cycle | |
85 | * @param objSource | |
86 | * a component that can provide the table model (typically | |
87 | * TableView) | |
88 | * @param objRow | |
89 | * the row data | |
90 | * @return IRender the renderer to present the value of the row in this | |
91 | * column | |
92 | */ | |
93 | IRender getValueRenderer(IRequestCycle objCycle, | |
94 | ITableModelSource objSource, Object objRow); | |
95 | } |