public void maybeUpdateSortingView(List<SortModel> sorting) { if(!currentSorting.equals(sorting)) { ColumnModel<Integer> columnModel = grid.getColumnModel(); ColumnHeader<Integer> tableHeading = grid.getView().getHeader(); if (sorting.isEmpty()) { tableHeading.updateSortIcon(-1, SortDir.ASC); } else { SortModel sortModel = sorting.get(0); for (int i = 0; i < columnModel.getColumnCount(); i++) { String path = columnModel.getValueProvider(i).getPath(); if (path.equals(sortModel.getField())) { tableHeading.updateSortIcon(i, sortModel.getDir() == org.activityinfo.model.query.SortDir.ASC ? SortDir.ASC : SortDir.DESC); break; } } } currentSorting = sorting; } }
private void changeColumnWidth(ColumnResizeEvent e) { ColumnConfig<Integer, Object> column = grid.getColumnModel().getColumn(e.getColumnIndex()); LOGGER.info("Column " + column.getValueProvider().getPath() + " resized to " + e.getColumnWidth() + "px"); tableUpdater.updateColumnWidth(column.getValueProvider().getPath(), e.getColumnWidth()); }
@Override protected void doSort(int colIndex, SortDir sortDir) { String field = grid.getColumnModel().getValueProvider(colIndex).getPath(); org.activityinfo.model.query.SortDir dir; // sortDir is null if the column header is clicked to // toggle the sort direction if(sortDir == null) { if(isFieldSortedAscending(field)) { dir = org.activityinfo.model.query.SortDir.DESC; } else { dir = org.activityinfo.model.query.SortDir.ASC; } } else if(sortDir == SortDir.ASC) { dir = org.activityinfo.model.query.SortDir.ASC; } else { dir = org.activityinfo.model.query.SortDir.DESC; } fireEvent(new SortChangeEvent(field, dir)); }