Example usage for com.google.gwt.view.client HasData getVisibleItem

List of usage examples for com.google.gwt.view.client HasData getVisibleItem

Introduction

In this page you can find the example usage for com.google.gwt.view.client HasData getVisibleItem.

Prototype

T getVisibleItem(int indexOnPage);

Source Link

Document

Get the row value at the specified visible index.

Usage

From source file:org.gss_project.gss.web.client.GSSSelectionEventManager.java

License:Open Source License

/**
 * Select or deselect a range of row indexes, optionally deselecting all other
 * values.//  w w w  .ja  v  a 2  s  . c  o m
 * 
 * @param selectionModel the {@link MultiSelectionModel} to update
 * @param display the {@link HasData} source of the selection event
 * @param range the {@link Range} of rows to select or deselect
 * @param addToSelection true to select, false to deselect the range
 * @param clearOthers true to deselect rows not in the range
 */
protected void setRangeSelection(MultiSelectionModel<? super T> selectionModel, HasData<T> display, Range range,
        boolean addToSelection, boolean clearOthers) {
    // Get the list of values to select.
    List<T> toUpdate = new ArrayList<T>();
    int itemCount = display.getVisibleItemCount();
    int start = range.getStart();
    int end = start + range.getLength();
    for (int i = start; i < end; i++) {
        toUpdate.add(display.getVisibleItem(i - display.getVisibleRange().getStart()));
    }
    // Clear all other values.
    if (clearOthers) {
        clearSelection(selectionModel);
    }

    // Update the state of the values.
    for (T value : toUpdate) {
        selectionModel.setSelected(value, addToSelection);
    }
}