use of com.playshogi.website.gwt.shared.models.ProblemCollectionDetails in project playshogi by Tellmarch.
the class MyCollectionsActivity method onSaveDraftCollection.
@EventHandler
public void onSaveDraftCollection(final SaveDraftCollectionEvent event) {
GWT.log("MyCollectionsActivity: Handling SaveDraftCollectionEvent: " + event);
if (event.getId() != null) {
Window.alert("Your collection is uploading - it may take a few minutes to import all kifus to the " + "database. " + "You can keep using the website during that time.");
}
switch(event.getType()) {
case KIFUS:
kifuService.saveDraftCollectionKifus(sessionInformation.getSessionId(), event.getId(), new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error saving draft kifus");
Window.alert("Failed to upload the kifus.");
}
@Override
public void onSuccess(final Void s) {
GWT.log("MyCollectionsActivity: saved draft kifus");
refresh();
}
});
break;
case GAMES:
if (event.getId() == null) {
GameCollectionDetails gcDetails = new GameCollectionDetails(event.getTitle(), event.getDescription(), event.getVisibility());
kifuService.createGameCollection(sessionInformation.getSessionId(), gcDetails, new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error creating new game collection");
Window.alert("Failed to create the game collection.");
}
@Override
public void onSuccess(final Void unused) {
GWT.log("MyCollectionsActivity: created new game collection");
refresh();
}
});
} else if (event.getCollectionId() != null) {
kifuService.addDraftToGameCollection(sessionInformation.getSessionId(), event.getId(), event.getCollectionId(), new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error adding draft game collection");
Window.alert("Failed to upload the game collection.");
}
@Override
public void onSuccess(final Void unused) {
GWT.log("MyCollectionsActivity: added draft game collection");
refresh();
}
});
} else {
GameCollectionDetails gcDetails = new GameCollectionDetails(event.getTitle(), event.getDescription(), event.getVisibility());
kifuService.saveGameCollection(sessionInformation.getSessionId(), event.getId(), gcDetails, new AsyncCallback<String>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error saving draft game collection");
Window.alert("Failed to upload the game collection.");
}
@Override
public void onSuccess(final String s) {
GWT.log("MyCollectionsActivity: saved draft game collection");
refresh();
}
});
}
break;
case PROBLEMS:
if (event.getId() == null) {
ProblemCollectionDetails pcDetails = new ProblemCollectionDetails(event.getTitle(), event.getDescription(), event.getVisibility(), event.getDifficulty(), event.getTags());
problemsService.createProblemCollection(sessionInformation.getSessionId(), pcDetails, new AsyncCallback<String>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error creating new problem collection");
Window.alert("Failed to create the problem collection.");
}
@Override
public void onSuccess(final String s) {
GWT.log("MyCollectionsActivity: created problem collection");
refresh();
}
});
} else if (event.getCollectionId() != null) {
problemsService.addDraftToProblemCollection(sessionInformation.getSessionId(), event.getId(), event.getCollectionId(), new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error adding draft problem collection");
Window.alert("Failed to upload the problem collection.");
}
@Override
public void onSuccess(final Void unused) {
GWT.log("MyCollectionsActivity: added draft problem collection");
refresh();
}
});
} else {
ProblemCollectionDetails pcDetails = new ProblemCollectionDetails(event.getTitle(), event.getDescription(), event.getVisibility(), event.getDifficulty(), event.getTags());
problemsService.saveProblemsCollection(sessionInformation.getSessionId(), event.getId(), pcDetails, new AsyncCallback<String>() {
@Override
public void onFailure(final Throwable throwable) {
GWT.log("MyCollectionsActivity: error saving draft problem collection");
Window.alert("Failed to upload the problem collection.");
}
@Override
public void onSuccess(final String s) {
GWT.log("MyCollectionsActivity: saved draft problem collection");
refresh();
}
});
}
break;
}
}
use of com.playshogi.website.gwt.shared.models.ProblemCollectionDetails in project playshogi by Tellmarch.
the class ProblemCollectionPropertiesForm method updateDetails.
private ProblemCollectionDetails updateDetails(final ProblemCollectionDetails details) {
ProblemCollectionDetails result = new ProblemCollectionDetails(getTitle(), getDescription(), getVisibility(), getDifficulty(), getTags());
result.setId(details.getId());
return result;
}
use of com.playshogi.website.gwt.shared.models.ProblemCollectionDetails in project playshogi by Tellmarch.
the class KifuTable method createCollectionsDropdown.
private ListBox createCollectionsDropdown(final KifuDetails.KifuType type) {
ListBox list = new ListBox();
if (type == KifuDetails.KifuType.PROBLEM) {
for (ProblemCollectionDetails collection : myProblemCollections) {
list.addItem(collection.getName(), collection.getId());
}
} else {
for (GameCollectionDetails collection : myGameCollections) {
list.addItem(collection.getName(), collection.getId());
}
}
list.setVisibleItemCount(1);
return list;
}
use of com.playshogi.website.gwt.shared.models.ProblemCollectionDetails 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