use of com.playshogi.website.gwt.client.place.ProblemCollectionPlace in project playshogi by Tellmarch.
the class ProblemCollectionsTable method getTableConfig.
private TableConfig<ProblemCollectionDetails> getTableConfig(final AppPlaceHistoryMapper historyMapper) {
TableConfig<ProblemCollectionDetails> tableConfig = new TableConfig<>();
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("id", "#").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getTableRow().getIndex() + 1 + PAGE_SIZE * (simplePaginationPlugin.getSimplePagination().activePage() - 1))))).addColumn(ColumnConfig.<ProblemCollectionDetails>create("name", "Name").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getName())).setSortable(true)).addColumn(ColumnConfig.<ProblemCollectionDetails>create("practice", "Practice").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
String href = "#" + historyMapper.getToken(new ProblemsPlace(cell.getRecord().getId(), 0));
return Elements.a(href).add(Button.createSuccess(Icons.ALL.timer()).setContent("Practice / Speedrun")).element();
})).addColumn(ColumnConfig.<ProblemCollectionDetails>create("difficulty", "Difficulty").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getDifficulty(cell.getRecord())).setSortable(true));
if (!isAuthor) {
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("author", "Author").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getAuthor())).setSortable(true));
}
if (isAuthor || canEdit) {
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("visibility", "Visibility").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getVisibility())));
}
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("solved", "Solved").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getSolved(cell.getRecord()))).addColumn(ColumnConfig.<ProblemCollectionDetails>create("besttime", "Personal Best Time").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getPersonalBest(cell.getRecord())).setSortable(true)).addColumn(ColumnConfig.<ProblemCollectionDetails>create("leaderboard", "Leaderboard").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getLeaderboard(cell.getRecord())));
if (isAuthor) {
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("open", "Open Collection").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
String href = "#" + historyMapper.getToken(new ProblemCollectionPlace(cell.getRecord().getId()));
return Elements.a(href).add(Button.createPrimary("Open")).element();
}));
}
return tableConfig;
}
Aggregations