List of usage examples for com.google.gwt.view.client RowCountChangeEvent fire
public static void fire(HasRows source, int rowCount, boolean isExact)
From source file:org.glom.web.client.ui.details.RelatedListTable.java
License:Open Source License
@Override protected AsyncDataProvider<DataItem[]> getDataProvider() { final AsyncDataProvider<DataItem[]> dataProvider = new AsyncDataProvider<DataItem[]>() { @Override/*from w w w. j av a2 s .c o m*/ @SuppressWarnings("unchecked") protected void onRangeChanged(final HasData<DataItem[]> display) { // setup the callback object final Range range = display.getVisibleRange(); final int start = range.getStart(); final AsyncCallback<ArrayList<DataItem[]>> callback = new AsyncCallback<ArrayList<DataItem[]>>() { @Override public void onFailure(final Throwable caught) { // TODO: create a way to notify users of asynchronous callback failures GWT.log("AsyncCallback Failed: OnlineGlomService.getRelatedListData(): " + caught.getMessage()); } @Override public void onSuccess(final ArrayList<DataItem[]> result) { // keep track of the number of non-empty rows (rows with data) numNonEmptyRows = 0; if (result != null) { numNonEmptyRows = result.size(); } // Add empty rows if required. final int numEmptyRows = MIN_TABLE_ROWS - numNonEmptyRows; for (int i = 0; i < numEmptyRows; i++) { // A row that has one null item will be rendered as an empty row. result.add(new DataItem[1]); } updateRowData(start, result); // Note: numNonEmptyRows is not used by the RowCountChangeEvent handler but we need to fire the // event to get ListTable.ListTablePage.createText() to run and update the pager text using // getNumNonEmptyRows(). RowCountChangeEvent.fire(display, numNonEmptyRows, true); } }; // get data from the server final ColumnSortList colSortList = cellTable.getColumnSortList(); int sortColumn = -1; // -1 means no sort. boolean ascending = false; if (colSortList.size() > 0) { // ColumnSortEvent has been requested by the user final ColumnSortInfo info = colSortList.get(0); sortColumn = cellTable.getColumnIndex((Column<DataItem[], ?>) info.getColumn()); ascending = info.isAscending(); } OnlineGlomServiceAsync.Util.getInstance().getRelatedListData(documentID, tableName, portal, foreignKeyValue, start, range.getLength(), sortColumn, ascending, callback); } }; return dataProvider; }
From source file:org.glom.web.client.ui.list.ListViewTable.java
License:Open Source License
@Override protected AsyncDataProvider<DataItem[]> getDataProvider() { final AsyncDataProvider<DataItem[]> dataProvider = new AsyncDataProvider<DataItem[]>() { @SuppressWarnings("unchecked") @Override//from www . j a v a 2 s .co m protected void onRangeChanged(final HasData<DataItem[]> display) { // setup the callback object final Range range = display.getVisibleRange(); final int start = range.getStart(); final AsyncCallback<ArrayList<DataItem[]>> callback = new AsyncCallback<ArrayList<DataItem[]>>() { @Override public void onFailure(final Throwable caught) { // TODO: create a way to notify users of asynchronous callback failures GWT.log("AsyncCallback Failed: OnlineGlomService.getListViewData(): " + caught.getMessage()); } @Override public void onSuccess(final ArrayList<DataItem[]> result) { // keep track of the number of non-empty rows (rows with data) if (result == null) { GWT.log("ListViewTable: result was null."); return; } numNonEmptyRows = result.size(); // Add empty rows if required. final int numEmptyRows = MIN_TABLE_ROWS - numNonEmptyRows; for (int i = 0; i < numEmptyRows; i++) { // A row that has one null item will be rendered as an empty row. result.add(new DataItem[1]); } updateRowData(start, result); // Note: numNonEmptyRows is not used by the RowCountChangeEvent handler but we need to fire the // event to get ListTable.ListTablePage.createText() to run and update the pager text using // getNumNonEmptyRows(). RowCountChangeEvent.fire(display, numNonEmptyRows, true); } }; // get data from the server int sortColumn = -1; // -1 means no sort. boolean ascending = false; final ColumnSortList colSortList = cellTable.getColumnSortList(); if (colSortList.size() > 0) { // ColumnSortEvent has been requested by the user final ColumnSortInfo info = colSortList.get(0); sortColumn = cellTable.getColumnIndex((Column<DataItem[], ?>) info.getColumn()); ascending = info.isAscending(); } OnlineGlomServiceAsync.Util.getInstance().getListViewData(documentID, tableName, quickFind, start, range.getLength(), sortColumn, ascending, callback); } }; return dataProvider; }
From source file:org.jboss.as.console.client.domain.topology.TopologyView.java
License:Open Source License
@Override public void updateHosts(SortedSet<ServerGroup> groups, final int index) { // validation HtmlGenerator html = new HtmlGenerator(); if (groups == null || groups.isEmpty()) { // no server/groups available ... Hint blank = new Hint("No server available!"); container.clear();//from ww w . j ava2 s.c o m container.insert(blank, 0); return; } // initialization assignColors(groups); List<HostInfo> hosts = groups.first().getHosts(); this.hostSize = hosts.size(); this.visibleHosts = min(TopologyPresenter.VISIBLE_HOSTS_COLUMNS, hostSize); this.hostIndex = index; this.hostIndex = max(0, this.hostIndex); this.hostIndex = min(this.hostIndex, this.hostSize - 1); int endIndex = min(this.hostIndex + TopologyPresenter.VISIBLE_HOSTS_COLUMNS, hostSize); // start table and add columns html.startTable().appendHtmlConstant("<colgroup>"); int columnWidth = HOSTS_COLUMNS / (endIndex - this.hostIndex); html.appendColumn(SERVER_GROUPS_COLUMN); for (int i = this.hostIndex; i < endIndex; i++) { html.appendColumn(columnWidth); } html.appendHtmlConstant("</colgroup>"); // first row contains host names html.appendHtmlConstant( "<thead><tr><th class='cellTableHeader'>Hosts →<br/>Groups ↓</th>"); for (int i = this.hostIndex; i < endIndex; i++) { HostInfo host = hosts.get(i); html.appendHost(host); } html.appendHtmlConstant("</tr></thead>"); // remaining rows contain server groups and server instances html.appendHtmlConstant("<tbody>"); for (ServerGroup group : groups) { for (int serverIndex = 0; serverIndex < group.maxServersPerHost; serverIndex++) { html.appendHtmlConstant("<tr>"); if (serverIndex == 0) { html.appendServerGroup(group); } for (int i = this.hostIndex; i < endIndex; i++) { HostInfo host = hosts.get(i); List<ServerInstance> servers = group.serversPerHost.get(host); if (servers.isEmpty() || serverIndex >= servers.size()) { html.emptyCell(); } else { html.appendServer(group, host.getName(), servers.get(serverIndex)); } } html.appendHtmlConstant("</tr>"); } } html.appendHtmlConstant("</tbody>").endTable(); // create html panel and register events HTMLPanel panel = html.createPanel(); for (String id : html.getLifecycleIds()) { com.google.gwt.user.client.Element element = panel.getElementById(id); if (element != null) { DOM.setEventListener(element, lifecycleLinkListener); DOM.sinkEvents(element, ONCLICK); } } if (container.getWidgetCount() == 2) { container.remove(0); } { container.clear(); } container.insert(panel, 0); container.add(pager); // update navigation RowCountChangeEvent.fire(display, hostSize, true); }