01: /*
02: * $Id: NavigatorLabel.java 458267 2005-12-09 07:31:35Z ivaynberg $
03: * $Revision: 458267 $
04: * $Date: 2005-12-09 08:31:35 +0100 (Fri, 09 Dec 2005) $
05: *
06: * ====================================================================
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19: package wicket.extensions.markup.html.repeater.data.table;
20:
21: import wicket.Component;
22: import wicket.markup.html.basic.Label;
23: import wicket.model.AbstractReadOnlyModel;
24:
25: /**
26: * Label that provides Showing x to y of z message given for a DataTable
27: *
28: * @author Igor Vaynberg (ivaynberg)
29: *
30: */
31: public class NavigatorLabel extends Label {
32: private static final long serialVersionUID = 1L;
33:
34: /**
35: * @param id
36: * component id
37: * @param table
38: * dataview
39: */
40: public NavigatorLabel(final String id, final DataTable table) {
41: super (id, new AbstractReadOnlyModel() {
42: private static final long serialVersionUID = 1L;
43:
44: public Object getObject(Component component) {
45: int of = table.getRowCount();
46: int from = table.getCurrentPage()
47: * table.getRowsPerPage();
48: int to = Math.min(of, from + table.getRowsPerPage());
49:
50: from++;
51:
52: if (of == 0) {
53: from = 0;
54: to = 0;
55: }
56:
57: return new String("Showing " + from + " to " + to
58: + " of " + of);
59: }
60: });
61: }
62: }
|