01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.databinding.datagrid.runtime.rendering.pager;
20:
21: import org.apache.beehive.netui.util.internal.InternalStringBuilder;
22:
23: import org.apache.beehive.netui.databinding.datagrid.api.pager.PagerModel;
24: import org.apache.beehive.netui.databinding.datagrid.api.rendering.IDataGridMessageKeys;
25: import org.apache.beehive.netui.databinding.datagrid.api.rendering.PagerRenderer;
26:
27: /**
28: *
29: */
30: public final class FirstPreviousNextLastPagerRenderer extends
31: PagerRenderer {
32:
33: protected String internalRender() {
34: InternalStringBuilder buf = new InternalStringBuilder();
35: PagerModel pagerModel = getPagerModel();
36: int currentPage = pagerModel.getPage();
37: int lastPage = pagerModel.getLastPage();
38:
39: /* Page # of # First / Previous Next / Last */
40: buf.append(getDataGridTagModel().formatMessage(
41: IDataGridMessageKeys.PAGER_FMT_BANNER,
42: new Integer[] { new Integer(currentPage + 1),
43: new Integer(lastPage + 1) }));
44:
45: buf.append(" ");
46: if (currentPage > pagerModel.getFirstPage())
47: buf.append(buildLiveFirstLink());
48: else
49: buf.append(buildDeadFirstLink());
50:
51: buf.append(" / ");
52: if (pagerModel.getPreviousPage() >= 0)
53: buf.append(buildLivePreviousLink());
54: else
55: buf.append(buildDeadPreviousLink());
56:
57: buf.append(" ");
58: if (pagerModel.getNextPage() <= lastPage)
59: buf.append(buildLiveNextPageLink());
60: else
61: buf.append(buildDeadNextLink());
62:
63: buf.append(" / ");
64: if (currentPage < lastPage)
65: buf.append(buildLiveLastLink());
66: else
67: buf.append(buildDeadLastLink());
68:
69: return buf.toString();
70: }
71: }
|