Search in sources :

Example 1 with HasRows

use of com.google.gwt.view.client.HasRows in project blogwt by billy1380.

the class SimplePager method createText.

/**
 * 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);
}
Also used : HasRows(com.google.gwt.view.client.HasRows) Range(com.google.gwt.view.client.Range) NumberFormat(com.google.gwt.i18n.client.NumberFormat)

Example 2 with HasRows

use of com.google.gwt.view.client.HasRows in project rstudio by rstudio.

the class Pager method createText.

@Override
protected String createText() {
    final HasRows display = getDisplay();
    if (display.getVisibleRange().getStart() == display.getRowCount())
        return "";
    String text = super.createText();
    if (display.isRowCountExact())
        return "Commits " + text;
    else {
        int pos = text.indexOf(" of ");
        return "Commits " + (pos >= 0 ? text.substring(0, pos) : text);
    }
}
Also used : HasRows(com.google.gwt.view.client.HasRows)

Example 3 with HasRows

use of com.google.gwt.view.client.HasRows in project rstudio by rstudio.

the class Pager method setPageStart.

@Override
public void setPageStart(int index) {
    HasRows display = getDisplay();
    if (display != null) {
        Range range = display.getVisibleRange();
        int pageSize = range.getLength();
        index = Math.max(0, index);
        if (index != range.getStart()) {
            display.setVisibleRange(index, pageSize);
        }
    }
}
Also used : HasRows(com.google.gwt.view.client.HasRows) Range(com.google.gwt.view.client.Range)

Example 4 with HasRows

use of com.google.gwt.view.client.HasRows in project blogwt by billy1380.

the class SimplePager method onRangeOrRowCountChanged.

@Override
protected void onRangeOrRowCountChanged() {
    HasRows display = getDisplay();
    elLabel.setInnerHTML(createText());
    // Update the prev and first buttons.
    setPrevPageButtonsDisabled(!hasPreviousPage());
    // Update the next and last buttons.
    if (isRangeLimited() || !display.isRowCountExact()) {
        setNextPageButtonsDisabled(!hasNextPage());
        setFastForwardDisabled(!hasNextPages(getFastForwardPages()));
    }
}
Also used : HasRows(com.google.gwt.view.client.HasRows)

Aggregations

HasRows (com.google.gwt.view.client.HasRows)4 Range (com.google.gwt.view.client.Range)2 NumberFormat (com.google.gwt.i18n.client.NumberFormat)1