public void load() { AsyncDataProvider<SearchResultRow> dataProvider = new AsyncDataProvider<SearchResultRow>() { @Override protected void onRangeChanged(HasData<SearchResultRow> display) { SearchRange sr = new SearchRange(-1); Range range = display.getVisibleRange(); if (range != null) { sr.setStart(range.getStart()); sr.setLength(range.getLength()); } ColumnSortList sortList = cellTable.getColumnSortList(); if (sortList != null && sortList.size() > 0) { ColumnSortInfo sort = sortList.get(0); if (sort != null) { sr.setSortField( tableColIdx.get( cellTable.getColumnIndex((Column<SearchResultRow, ?>) sort.getColumn()))); sr.setAscending(sort.isAscending()); } } changeHandler.handleRangeChange(sr); } }; dataProvider.addDataDisplay(cellTable); AsyncHandler sortHandler = new AsyncHandler(cellTable); cellTable.addColumnSortHandler(sortHandler); }
/** Helper to createTable(). Populate table with data fetched by rpc call to the server. */ private void populateTable() { // Initialize the service proxy if (houseDataSvc == null) { houseDataSvc = GWT.create(HouseDataService.class); } updateRowCount(); // Data provider to populate Table dataProvider = new AsyncDataProvider<HouseData>() { @Override protected void onRangeChanged(HasData<HouseData> display) { currentStartItem = display.getVisibleRange().getStart(); int range = display.getVisibleRange().getLength(); pageLength = range; AsyncCallback<List<HouseData>> callback = new AsyncCallback<List<HouseData>>() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(List<HouseData> result) { updateRowData(currentStartItem, result); } }; houseDataSvc.getHouses(currentStartItem, range, callback); } }; dataProvider.addDataDisplay(homesCellTable); }
@Override protected void onBind() { super.onBind(); dataProvider.addDataDisplay(getView().getDisplay()); setInSlot(FacetSearchPresenterWidget.SLOT_CONTENT, facetSearchPresenterWidget); registerHandler( getEventBus() .addHandlerToSource( FacetSearchChangeEvent.TYPE, facetSearchPresenterWidget, new FacetSearchChangeEvent.Handler() { @Override public void onChanged(FacetSearchChangeEvent event) { getView() .getDisplay() .setVisibleRangeAndClearData( getView().getDisplay().getVisibleRange(), true); } })); }
/** Method that places the components in the form. */ @Override public void onLoad() { // Display 15 rows in one page propertiesTable.setPageSize(20); // Add a text column to show the name. TextColumn<OrganizationProperty> nameColumn = new TextColumn<OrganizationProperty>() { @Override public String getValue(OrganizationProperty property) { return property.getProperty().getName(); } }; propertiesTable.addColumn(nameColumn, "Name"); // Add column with an input cell to edit the value of the property TextInputCell valueCell = new TextInputCell(); Column<OrganizationProperty, String> valueColumn = new Column<OrganizationProperty, String>(valueCell) { @Override public String getValue(OrganizationProperty property) { return property.getValue(); } }; valueColumn.setFieldUpdater( new FieldUpdater() { @Override public void update(int index, Object object, Object value) { newPropertyValue = (String) value; } }); propertiesTable.addColumn(valueColumn, "Value"); propertiesTable.addColumnStyleName(2, "gridOrganizationPropertyValueColumn"); // Add column with save button to save the value of the property Column<OrganizationProperty, String> saveButtonColumn = createSaveButtonColumn(); propertiesTable.addColumn(saveButtonColumn); // Get properties final List<OrganizationProperty> properties = new ArrayList<OrganizationProperty>(organization.getOrganizationProperties()); AsyncDataProvider<OrganizationProperty> provider = new AsyncDataProvider<OrganizationProperty>() { @Override protected void onRangeChanged(HasData<OrganizationProperty> display) { int start = display.getVisibleRange().getStart(); int end = start + display.getVisibleRange().getLength(); end = end >= properties.size() ? properties.size() : end; List<OrganizationProperty> sub = properties.subList(start, end); updateRowData(start, sub); } }; provider.addDataDisplay(propertiesTable); provider.updateRowCount(properties.size(), true); SimplePager pager = new SimplePager(); pager.setDisplay(propertiesTable); VerticalPanel vp = new VerticalPanel(); vp.add(propertiesTable); vp.add(pager); mainPanel.add(vp); }
public void addDataDisplay(final HasData<DataMockSummary> display) { dataProvider.addDataDisplay(display); }
public void refreshList() { HasData<DataMockSummary> next = dataProvider.getDataDisplays().iterator().next(); next.setVisibleRangeAndClearData(next.getVisibleRange(), true); }