/** * Set the page size of the display. * * @param pageSize the new page size * @see #getPageSize() */ protected void setPageSize(int pageSize) { if (display != null) { Range range = display.getVisibleRange(); int pageStart = range.getStart(); if (isRangeLimited && display.isRowCountExact()) { pageStart = Math.min(pageStart, display.getRowCount() - pageSize); } pageStart = Math.max(0, pageStart); display.setVisibleRange(pageStart, pageSize); } }
/** * Go to a specific page. * * @param index the page index * @see #getPage() */ protected void setPage(int index) { if (display != null && (!isRangeLimited || !display.isRowCountExact() || hasPage(index))) { // We don't use the local version of setPageStart because it would // constrain the index, but the user probably wants to use absolute page // indexes. int pageSize = getPageSize(); display.setVisibleRange(pageSize * index, pageSize); } }
/** * Set the page start index. * * @param index the index * @see #getPageStart() */ protected void setPageStart(int index) { if (display != null) { Range range = display.getVisibleRange(); int pageSize = range.getLength(); if (isRangeLimited && display.isRowCountExact()) { index = Math.min(index, display.getRowCount() - pageSize); } index = Math.max(0, index); if (index != range.getStart()) { display.setVisibleRange(index, pageSize); } } }
public void onClick(ClickEvent event) { // Display should be non-null, but we check defensively. HasRows display = getDisplay(); if (display != null) { Range range = display.getVisibleRange(); int pageSize = Math.min(range.getLength() + increment, display.getRowCount() + (display.isRowCountExact() ? 0 : increment)); display.setVisibleRange(range.getStart(), pageSize); } } });
/** * Returns true if there is enough data such that a call to * {@link #nextPage()} will succeed in moving the starting point of the table * forward. * * @return true if there is a next page */ protected boolean hasNextPage() { if (display == null || display.getRowCount() == 0) { return false; } else if (!display.isRowCountExact()) { return true; } Range range = display.getVisibleRange(); return range.getStart() + range.getLength() < display.getRowCount(); }
/** * Get the text to display in the pager that reflects the state of the pager. * * @return the text */ protected String createText() { // Default text is 1 based. NumberFormat formatter = NumberFormat.getFormat("#,###"); HasRows display = getDisplay(); Range range = display.getVisibleRange(); int pageStart = range.getStart() + 1; int pageSize = range.getLength(); int dataSize = display.getRowCount(); int endIndex = Math.min(dataSize, pageStart + pageSize - 1); endIndex = Math.max(pageStart, endIndex); boolean exact = display.isRowCountExact(); return formatter.format(pageStart) + "-" + formatter.format(endIndex) + (exact ? " of " : " of over ") + formatter.format(dataSize); }
@Override protected void onRangeOrRowCountChanged() { // Assumes a page start index of 0. HasRows display = getDisplay(); int pageSize = display.getVisibleRange().getLength(); boolean hasLess = pageSize > increment; boolean hasMore = !display.isRowCountExact() || pageSize < display.getRowCount(); showLessButton.setVisible(hasLess); showMoreButton.setVisible(hasMore); layout.setText(0, 1, (hasLess && hasMore) ? " | " : ""); }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText(createText()); // Update the prev and first buttons. setPrevPageButtonsDisabled(!hasPreviousPage()); // Update the next and last buttons. if (isRangeLimited() || !display.isRowCountExact()) { setNextPageButtonsDisabled(!hasNextPage()); setFastForwardDisabled(!hasNextPages(getFastForwardPages())); } }
/** * Go to a specific page. * * @param index the page index * @see #getPage() */ protected void setPage(int index) { if (display != null && (!isRangeLimited || !display.isRowCountExact() || hasPage(index))) { // We don't use the local version of setPageStart because it would // constrain the index, but the user probably wants to use absolute page // indexes. int pageSize = getPageSize(); display.setVisibleRange(pageSize * index, pageSize); } }
public void onClick(ClickEvent event) { // Display should be non-null, but we check defensively. HasRows display = getDisplay(); if (display != null) { Range range = display.getVisibleRange(); int pageSize = Math.min(range.getLength() + increment, display.getRowCount() + (display.isRowCountExact() ? 0 : increment)); display.setVisibleRange(range.getStart(), pageSize); } } });
public void onClick(ClickEvent event) { // Display should be non-null, but we check defensively. HasRows display = getDisplay(); if (display != null) { Range range = display.getVisibleRange(); int pageSize = Math.min(range.getLength() + increment, display.getRowCount() + (display.isRowCountExact() ? 0 : increment)); display.setVisibleRange(range.getStart(), pageSize); } } });
@Override public void setPageStart(int index) { HasRows display = getDisplay(); if (display != null) { Range range = display.getVisibleRange(); int pageSize = range.getLength(); if ((!isRangeLimited() || display.getRowCount() <= pageSize) && display.isRowCountExact()) { index = Math.min(index, display.getRowCount() - pageSize); } index = Math.max(0, index); if (index != range.getStart()) { display.setVisibleRange(index, pageSize); } } }
@Override protected void onRangeOrRowCountChanged() { // Assumes a page start index of 0. HasRows display = getDisplay(); int pageSize = display.getVisibleRange().getLength(); boolean hasLess = pageSize > increment; boolean hasMore = !display.isRowCountExact() || pageSize < display.getRowCount(); showLessButton.setVisible(hasLess); showMoreButton.setVisible(hasMore); layout.setText(0, 1, (hasLess && hasMore) ? " | " : ""); }
@Override protected void onRangeOrRowCountChanged() { // Assumes a page start index of 0. HasRows display = getDisplay(); int pageSize = display.getVisibleRange().getLength(); boolean hasLess = pageSize > increment; boolean hasMore = !display.isRowCountExact() || pageSize < display.getRowCount(); showLessButton.setVisible(hasLess); showMoreButton.setVisible(hasMore); layout.setText(0, 1, (hasLess && hasMore) ? " | " : ""); }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText(createText()); // Update the prev and first buttons. setPrevPageButtonsDisabled(!hasPreviousPage()); // Update the next and last buttons. if (isRangeLimited() || !display.isRowCountExact()) { setNextPageButtonsDisabled(!hasNextPage()); setFastForwardDisabled(!hasNextPages(getFastForwardPages())); } }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText(createText()); // Update the prev and first buttons. setPrevPageButtonsDisabled(!hasPreviousPage()); // Update the next and last buttons. if (isRangeLimited() || !display.isRowCountExact()) { setNextPageButtonsDisabled(!hasNextPage()); setFastForwardDisabled(!hasNextPages(getFastForwardPages())); } }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText( createText() ); // Update the prev and first buttons. setPrevPageButtonsDisabled( !hasPreviousPage() ); // Update the next and last buttons. if ( isRangeLimited() || !display.isRowCountExact() ) { setNextPageButtonsDisabled( !hasNextPage() ); setFastForwardDisabled( !hasNextPages( getFastForwardPages() ) ); } }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText(createText()); // Update the prev and first buttons. setPrevPageButtonsDisabled(!hasPreviousPage()); // Update the next and last buttons. if (isRangeLimited() || !display.isRowCountExact()) { setNextPageButtonsDisabled(!hasNextPage()); setFastForwardDisabled(!hasNextPages(getFastForwardPages())); } }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText(createText()); // Update the prev and first buttons. setPrevPageButtonsDisabled(!hasPreviousPage()); // Update the next and last buttons. if (isRangeLimited() || !display.isRowCountExact()) { setNextPageButtonsDisabled(!hasNextPage()); setFastForwardDisabled(!hasNextPages(getFastForwardPages())); } }
@Override protected void onRangeOrRowCountChanged() { HasRows display = getDisplay(); label.setText(createText()); // Update the prev and first buttons. setPrevPageButtonsDisabled(!hasPreviousPage()); // Update the next and last buttons. if (isRangeLimited() || !display.isRowCountExact()) { setNextPageButtonsDisabled(!hasNextPage()); setFastForwardDisabled(!hasNextPages(getFastForwardPages())); } }