BrightSide Workbench Full Report + Source Code
org.turro.collections.CollectionNavigator Class Reference

Public Member Functions

 CollectionNavigator (CollectionHtmlIterator iterator)
 
void setPageSpan (int pageSpan)
 
void render ()
 
Collection< DefaultNavigatorItempages ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 30 of file CollectionNavigator.java.

Constructor & Destructor Documentation

◆ CollectionNavigator()

org.turro.collections.CollectionNavigator.CollectionNavigator ( CollectionHtmlIterator  iterator)

Definition at line 37 of file CollectionNavigator.java.

37  {
38  this.iterator = iterator;
39  this.html = iterator.html;
40  }

Member Function Documentation

◆ pages()

Collection<DefaultNavigatorItem> org.turro.collections.CollectionNavigator.pages ( )

Definition at line 93 of file CollectionNavigator.java.

93  {
94  if(buttons == null) {
95  buttons = new ArrayList<>();
96  int pages = iterator.pages(),
97  current = Math.max(iterator.current(), 0);
98  if(pages < current || pages == 1) return buttons;
99 
100  boolean navbut = pages > pageSpan * 2;
101  int start = 0, limit = pageSpan * 2;
102 
103  if(navbut) {
104  buttons.add(new DefaultNavigatorItem("1", "?page=" + 1, null, current == 0));
105  buttons.add(new DefaultNavigatorItem("&lt;&lt;", "?page=" + (current), null));
106  limit -= 4;
107  start = Integer.max(1, current - (limit / 2));
108  start = Integer.min(start, pages - (limit + 1));
109  }
110 
111  for(int i = start; i < (start + limit) && i < pages; i++) {
112  buttons.add(new DefaultNavigatorItem((i + 1) + "", "?page=" + (i + 1), null, current == i));
113  }
114 
115  if(navbut) {
116  buttons.add(new DefaultNavigatorItem("&gt;&gt;", "?page=" + (current + 2), null));
117  buttons.add(new DefaultNavigatorItem(pages + "", "?page=" + (pages), null, current == pages - 1));
118  }
119 
120  }
121  return buttons;
122  }
Collection< DefaultNavigatorItem > pages()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ render()

void org.turro.collections.CollectionNavigator.render ( )

Definition at line 46 of file CollectionNavigator.java.

46  {
47  int pages = iterator.pages(),
48  current = Math.max(iterator.current(), 0);
49  if(pages < current || pages == 1) return;
50  html.startTag("div", "class='dao-navigator'");
51  html.startTag("ul");
52 
53  if(current - pageSpan > 1) {
54  html.startTag("li");
55  html.startAnchor("?page=" + 1, null);
56  html.write("1");
57  html.endTag("li");
58  }
59 
60  if(current > 1) {
61  html.startTag("li");
62  html.startAnchor("?page=" + (current), null);
63  html.write("&lt&lt");
64  html.endTag("li");
65  }
66 
67  for(int i = current - pageSpan; i < current + pageSpan; i++) {
68  if(i >= 0 && i < pages) {
69  html.startTag("li", current == i ? "class='active'" : null);
70  html.startAnchor("?page=" + (i + 1), null);
71  html.write((i + 1) + "");
72  html.endTag("li");
73  }
74  }
75 
76  if(current != pages && pages > pageSpan) {
77  html.startTag("li");
78  html.startAnchor("?page=" + (current + 2), null);
79  html.write("&gt&gt");
80  html.endTag("li");
81  }
82 
83  if(current + pageSpan < pages) {
84  html.startTag("li");
85  html.startAnchor("?page=" + pages, null);
86  html.write(pages + "");
87  html.endTag("li");
88  }
89 
90  html.endTag("div");
91  }
HTMLGenerator startTag(String tag)
HTMLGenerator startAnchor(String url, String hint)
HTMLGenerator write(String value)
Definition: HTMLHelper.java:69
Here is the call graph for this function:

◆ setPageSpan()

void org.turro.collections.CollectionNavigator.setPageSpan ( int  pageSpan)

Definition at line 42 of file CollectionNavigator.java.

42  {
43  this.pageSpan = pageSpan;
44  }

The documentation for this class was generated from the following file: