private void updateSortOrder(SortableHeader<T, ?> header) { int index = sortOrderList.indexOf(header); if (index == 0) { if (header.getSortDirection() != SortDirection.ASCENDING) { header.setSortDirection(SortDirection.ASCENDING); } else { header.setSortDirection(SortDirection.DESCENDING); } } else { // Remove it if it's already sorted on this header later if (index > 0) { sortOrderList.remove(index); } header.setSortDirection(SortDirection.ASCENDING); // Bring this header to front // Deque.addFirst(sortableHeader) sortOrderList.add(0, header); // Update sortIndexes int sortIndex = 0; for (SortableHeader<T, ?> sortableHeader : sortOrderList) { sortableHeader.setSortIndex(sortIndex); sortIndex++; } } }
private void updateSortOrder(SortableHeader<T, ?> header) { int index = sortOrderList.indexOf(header); if (index == 0) { if (header.getSortDirection() != SortDirection.ASCENDING) { header.setSortDirection(SortDirection.ASCENDING); } else { header.setSortDirection(SortDirection.DESCENDING); } } else { // Remove it if it's already sorted on this header later if (index > 0) { sortOrderList.remove(index); } header.setSortDirection(SortDirection.ASCENDING); // Bring this header to front // Deque.addFirst(sortableHeader) sortOrderList.add(0, header); // Update sortIndexes int sortIndex = 0; for (SortableHeader<T, ?> sortableHeader : sortOrderList) { sortableHeader.setSortIndex(sortIndex); sortIndex++; } } }