use of com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo in project ovirt-engine by oVirt.
the class ColumnResizeCellTable method applySort.
private void applySort(ColumnSortEvent event, SortedListModel<T> sortedModel) {
Column<?, ?> column = event.getColumn();
if (!(column instanceof SortableColumn)) {
// Column is not sortable, nothing to do
return;
}
SortableColumn<T> sortableColumn = (SortableColumn<T>) column;
SearchableListModel<?, T> searchableModel = (sortedModel instanceof SearchableListModel) ? (SearchableListModel<?, T>) sortedModel : null;
boolean sortApplied = false;
boolean supportsServerSideSorting = searchableModel != null && searchableModel.supportsServerSideSorting();
// Ensure consistent item order with fallback comparator
Comparator<? super T> columnComparator = sortableColumn.getComparator();
Comparator<? super T> realComparator = columnComparator;
if (sortedModel.useDefaultItemComparator() && columnComparator != null) {
realComparator = DefaultModelItemComparator.fallbackFor(columnComparator);
}
// uses Comparator for client-side sorting, use client-side sorting
if (supportsServerSideSorting && realComparator != null) {
sortedModel.setComparator(realComparator, event.isSortAscending());
sortApplied = true;
} else // update model's sort options and reload its items via search query
if (supportsServerSideSorting) {
sortedModel.setComparator(null);
if (searchableModel.isSearchValidForServerSideSorting()) {
searchableModel.updateSortOptions(sortableColumn.getSortBy(), event.isSortAscending());
sortApplied = true;
} else {
// Search string not valid, cannot perform search query
searchableModel.clearSortOptions();
}
} else // Otherwise, fall back to client-side sorting
if (realComparator != null) {
sortedModel.setComparator(realComparator, event.isSortAscending());
sortApplied = true;
// SortedListModel.setComparator does not sort the items
if (searchableModel == null) {
sortedModel.setItems(sortedModel.getItems());
}
}
// Update column sort status, redrawing table headers if necessary
ColumnSortInfo columnSortInfo = event.getColumnSortList().get(0);
if (sortApplied) {
pushColumnSort(columnSortInfo);
} else {
clearColumnSort();
}
}
Aggregations