List of usage examples for com.vaadin.shared Range length
public int length()
From source file:org.vaadin.viritin.grid.SizelessDataCommunicator.java
License:Apache License
@Override protected void sendDataToClient(boolean initial) { if (getDataProvider() == null) { return;//from w w w . j av a 2 s . co m } if (initial || reset) { rpc.reset(0); } Range requestedRows = getPushRows(); if (!requestedRows.isEmpty()) { int offset = requestedRows.getStart(); // Always fetch some extra rows. int limit = requestedRows.length() + getMinPushSize(); List<T> rowsToPush = fetchItemsWithRange(offset, limit); int lastIndex = offset + rowsToPush.size(); if (lastIndex > knownSize) { int rowsToAdd = lastIndex - knownSize; rpc.insertRows(knownSize, rowsToAdd + (rowsToPush.size() == limit ? 1 : 0)); knownSize = lastIndex; } else if (rowsToPush.size() < requestedRows.length()) { // Size decreased int rowsToRemove = Math.max(requestedRows.length() - rowsToPush.size(), knownSize - lastIndex); knownSize = lastIndex; rpc.removeRows(knownSize, rowsToRemove); } pushData(offset, rowsToPush); } if (!getUpdatedData().isEmpty()) { JsonArray dataArray = Json.createArray(); int i = 0; for (T data : getUpdatedData()) { dataArray.set(i++, getDataObject(data)); } rpc.updateData(dataArray); } setPushRows(Range.withLength(0, 0)); getUpdatedData().clear(); }