Skip to content

Commit

Permalink
Fix inconsistent sort order in map download list. (#12533)
Browse files Browse the repository at this point in the history
Instead of sorting ourselves, which doesn't match JTable's sorting, just use JTable's sorting when creating the table.

Fixes: #12446
  • Loading branch information
asvitkine committed Apr 21, 2024
1 parent 0607de4 commit d9a67c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Expand Up @@ -45,12 +45,10 @@ public MapDownloadSwingTable(final Collection<MapDownloadItem> maps) {
table =
JTableBuilder.<MapDownloadItem>builder()
.columnNames(columnNames)
.rowData(
maps.stream()
.sorted(Comparator.comparing(MapDownloadItem::getMapName))
.collect(Collectors.toList()))
.rowData(maps)
.rowMapper(mapDownloadListing -> rowMapper(mapDownloadListing, tagNames))
.build();
table.getRowSorter().toggleSortOrder(0);
table.addKeyListener(new JTableTypeAheadListener(table, 0));
}

Expand Down
Expand Up @@ -3,6 +3,7 @@
import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
Expand Down Expand Up @@ -34,7 +35,7 @@
public class JTableBuilder<T> {

private Function<T, List<String>> rowMapper;
private List<T> rowData;
private Collection<T> rowData;
private List<List<String>> tableData;
private List<String> columnNames;

Expand Down Expand Up @@ -128,7 +129,7 @@ public JTableBuilder<T> tableData(final List<List<String>> tableData) {
return this;
}

public JTableBuilder<T> rowData(final List<T> rowData) {
public JTableBuilder<T> rowData(final Collection<T> rowData) {
this.rowData = rowData;
return this;
}
Expand Down

0 comments on commit d9a67c3

Please sign in to comment.