KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > databinding > datagrid > runtime > rendering > pager > FirstPreviousNextLastPagerRenderer


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.databinding.datagrid.runtime.rendering.pager;
19
20 import org.apache.beehive.netui.util.internal.InternalStringBuilder;
21
22 import org.apache.beehive.netui.databinding.datagrid.api.pager.PagerModel;
23 import org.apache.beehive.netui.databinding.datagrid.api.rendering.IDataGridMessageKeys;
24 import org.apache.beehive.netui.databinding.datagrid.api.rendering.PagerRenderer;
25
26 /**
27  *
28  */

29 public final class FirstPreviousNextLastPagerRenderer
30     extends PagerRenderer {
31
32     protected String JavaDoc internalRender() {
33         InternalStringBuilder buf = new InternalStringBuilder();
34         PagerModel pagerModel = getPagerModel();
35         int currentPage = pagerModel.getPage();
36         int lastPage = pagerModel.getLastPage();
37
38         /* Page # of # First / Previous Next / Last */
39         buf.append(getDataGridTagModel().formatMessage(IDataGridMessageKeys.PAGER_FMT_BANNER,
40                                                        new Integer JavaDoc[]{new Integer JavaDoc(currentPage + 1),
41                                                                      new Integer JavaDoc(lastPage + 1)}));
42
43         buf.append("  ");
44         if(currentPage > pagerModel.getFirstPage())
45             buf.append(buildLiveFirstLink());
46         else
47             buf.append(buildDeadFirstLink());
48
49         buf.append(" / ");
50         if(pagerModel.getPreviousPage() >= 0)
51             buf.append(buildLivePreviousLink());
52         else
53             buf.append(buildDeadPreviousLink());
54
55         buf.append("   ");
56         if(pagerModel.getNextPage() <= lastPage)
57             buf.append(buildLiveNextPageLink());
58         else
59             buf.append(buildDeadNextLink());
60
61         buf.append("&nbsp;/&nbsp;");
62         if(currentPage < lastPage)
63             buf.append(buildLiveLastLink());
64         else
65             buf.append(buildDeadLastLink());
66
67         return buf.toString();
68     }
69 }
70
Popular Tags