public boolean hasNext() { if (_tree == null || !_tree.inPagingMold()) return _it.hasNext(); Integer renderedCount = (Integer) _tree.getAttribute(Attributes.RENDERED_ITEM_COUNT); if (renderedCount == null || renderedCount.intValue() < _tree.getPaginal().getPageSize()) return _it.hasNext(); return false; }
private static boolean shallRenderTree(Tree tree) { Integer visited = (Integer) tree.getAttribute(Attributes.VISITED_ITEM_COUNT); final Paginal pgi = tree.getPaginal(); final int ofs = pgi.getActivePage() * pgi.getPageSize(); if (ofs < visited.intValue()) { // count the rendered item Integer renderedCount = (Integer) tree.getAttribute(Attributes.RENDERED_ITEM_COUNT); if (renderedCount == null) renderedCount = new Integer(1); else renderedCount = new Integer(renderedCount.intValue() + 1); tree.setAttribute(Attributes.RENDERED_ITEM_COUNT, renderedCount); return true; } return false; }
/** * Returns a map of current visible item. * @since 3.0.7 */ Map<Treeitem, Boolean> getVisibleItems() { Map<Treeitem, Boolean> map = new HashMap<Treeitem, Boolean>(); final Paginal pgi = getPaginal(); final int pgsz = pgi.getPageSize(); final int ofs = pgi.getActivePage() * pgsz; // data[pageSize, beginPageIndex, visitedCount, visitedTotal, RenderedCount] int[] data = new int[] { pgsz, ofs, 0, 0, 0 }; getVisibleItemsDFS(getChildren(), map, data); return map; }
private static boolean shallVisitTree(Tree tree, Component child) { final Treeitem item = (Treeitem) child; int count = item.isOpen() && item.getTreechildren() != null ? item.getTreechildren().getVisibleItemCount() : 0; Integer visited = (Integer) tree.getAttribute(Attributes.VISITED_ITEM_COUNT); final Paginal pgi = tree.getPaginal(); final int ofs = pgi.getActivePage() * pgi.getPageSize(); int visit = visited != null ? visited.intValue() + 1 : 1; boolean shoulbBeVisited = ofs < visit + count; if (visited == null) visited = new Integer(shoulbBeVisited ? 1 : count + 1); else visited = new Integer(visited.intValue() + (shoulbBeVisited ? 1 : count + 1)); Integer total = (Integer) tree.getAttribute(Attributes.VISITED_ITEM_TOTAL); if (total == null) total = new Integer(count + 1); else total = new Integer(total.intValue() + count + 1); tree.setAttribute(Attributes.VISITED_ITEM_COUNT, visited); tree.setAttribute(Attributes.VISITED_ITEM_TOTAL, total); return shoulbBeVisited; }
final TreeModel model = tree.getModel(); boolean isPagingMold = tree.inPagingMold(); int activePg = isPagingMold ? tree.getPaginal().getActivePage() : 0; if (model != null) { //live data if (!(model instanceof Sortable)) tree.getPaginal().setActivePage(activePg);
/** Sets the active page in which the specified item is. * The active page will become the page that contains the specified item. * * @param item the item to show. If the item is null, invisible, or doesn't belong * to the same tree, nothing happens. * @since 3.0.4 */ public void setActivePage(Treeitem item) { if (item.isRealVisible() && item.getTree() == this && isVisible()) { int index = getVisibleIndexOfItem(item); if (index != -1) { final Paginal pgi = getPaginal(); int pg = index / pgi.getPageSize(); if (pg != getActivePage()) setActivePage(pg); } } }
void addVisibleItemCount(int count) { if (inPagingMold()) { Paginal pgi = getPaginal(); int totalSize = pgi.getTotalSize() + count; //ZK-3173: if visible item count reduces, active page might exceed max page count if (count < 0 && _model instanceof Pageable) { Pageable p = (Pageable) _model; int actpg = p.getActivePage(); if (actpg > 0) { int maxPageIndex = p.getPageCount() - 1; if (actpg > maxPageIndex) { p.setActivePage(maxPageIndex); } } } pgi.setTotalSize(totalSize); invalidate(); //the set of visible items might change } }
Paginal pgi = getPaginal(); if (pgi != null) { int pgsz = pgi.getPageSize(); int begin = getActivePage() * oldsize; int end = begin + oldsize; end = Math.min(getPaginal().getTotalSize(), end); Treeitem item = getSelectedItem(); int sel = getVisibleIndexOfItem(item);
setRendered(false); setLoaded(false); Events.postEvent(new PagingEvent("onPagingImpl", (Paging) tree.getPaginal(), activePage));