List of usage examples for com.google.gwt.view.client HasData getVisibleItemCount
int getVisibleItemCount();
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.//from ww w . j av a 2 s . c om * * @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); } }