/** * Returns the filtered number of pages.<p> * * Equals to <code>{@link #getTotalNumberOfPages()}</code> if no filter is set.<p> * * @return the filtered of pages */ public int getNumberOfPages() { return (int)Math.ceil((double)getSize() / getMaxItemsPerPage()); }
/** * Returns the filtered number of pages.<p> * * Equals to <code>{@link #getTotalNumberOfPages()}</code> if no filter is set.<p> * * @return the filtered of pages */ public int getNumberOfPages() { return (int)Math.ceil((double)getSize() / getMaxItemsPerPage()); }
/** * Returns the number (from 1) of the last displayed item.<p> * * @return the number (from 1) of the last displayed item, or zero if the list is empty */ protected int displayedTo() { if (getSize() != 0) { if (!isPrintable()) { if (getCurrentPage() * getMaxItemsPerPage() < getSize()) { return getCurrentPage() * getMaxItemsPerPage(); } } } return getSize(); }
/** * Returns the number (from 1) of the last displayed item.<p> * * @return the number (from 1) of the last displayed item, or zero if the list is empty */ protected int displayedTo() { if (getSize() != 0) { if (!isPrintable()) { if ((getCurrentPage() * getMaxItemsPerPage()) < getSize()) { return getCurrentPage() * getMaxItemsPerPage(); } } } return getSize(); }
/** * Returns all items of the current page.<p> * * @return all items of the current page, a list of {@link CmsListItem} objects */ public List<CmsListItem> getCurrentPageItems() { if (getSize() == 0) { return Collections.emptyList(); } if (m_metadata.isSelfManaged()) { return getContent(); } return Collections.unmodifiableList(getContent().subList(displayedFrom() - 1, displayedTo())); }
/** * Sets the current page.<p> * * @param currentPage the current page to set * * @throws CmsIllegalArgumentException if the argument is invalid */ public void setCurrentPage(int currentPage) throws CmsIllegalArgumentException { if (getSize() != 0) { if ((currentPage < 1) || (currentPage > getNumberOfPages())) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_LIST_INVALID_PAGE_1, new Integer(currentPage))); } } m_currentPage = currentPage; }
/** * Sets the current page.<p> * * @param currentPage the current page to set * * @throws CmsIllegalArgumentException if the argument is invalid */ public void setCurrentPage(int currentPage) throws CmsIllegalArgumentException { if (getSize() != 0) { if ((currentPage < 1) || (currentPage > getNumberOfPages())) { throw new CmsIllegalArgumentException(Messages.get().container( Messages.ERR_LIST_INVALID_PAGE_1, new Integer(currentPage))); } } m_currentPage = currentPage; }
/** * Returns all items of the current page.<p> * * @return all items of the current page, a list of {@link CmsListItem} objects */ public List getCurrentPageItems() { if (getSize() == 0) { return Collections.EMPTY_LIST; } if (m_metadata.isSelfManaged()) { return getContent(); } return Collections.unmodifiableList(getContent().subList(displayedFrom() - 1, displayedTo())); }
/** * Returns the number (from 1) of the first displayed item.<p> * * @return the number (from 1) of the first displayed item, or zero if the list is empty */ protected int displayedFrom() { if (getSize() != 0) { if (isPrintable()) { return 1; } else { return (getCurrentPage() - 1) * getMaxItemsPerPage() + 1; } } return 0; }
/** * Returns the number (from 1) of the first displayed item.<p> * * @return the number (from 1) of the first displayed item, or zero if the list is empty */ protected int displayedFrom() { if (getSize() != 0) { if (isPrintable()) { return 1; } else { return ((getCurrentPage() - 1) * getMaxItemsPerPage()) + 1; } } return 0; }