use of com.playshogi.website.gwt.shared.models.GameCollectionDetails 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.GameCollectionDetails in project playshogi by Tellmarch.
the class CollectionPropertiesPanel method saveDetails.
private void saveDetails() {
GameCollectionDetails newDetails = new GameCollectionDetails();
newDetails.setId(details.getId());
newDetails.setName(title.getText());
newDetails.setDescription(description.getText());
newDetails.setVisibility(visibility.getSelectedItemText());
eventBus.fireEvent(new SaveGameCollectionDetailsEvent(newDetails));
}
use of com.playshogi.website.gwt.shared.models.GameCollectionDetails in project playshogi by Tellmarch.
the class CollectionPropertiesPanel method createCollection.
private void createCollection() {
GameCollectionDetails newDetails = new GameCollectionDetails();
newDetails.setName(title.getText());
newDetails.setDescription(description.getText());
newDetails.setVisibility(visibility.getSelectedItemText());
eventBus.fireEvent(new CreateGameCollectionEvent(newDetails));
}
use of com.playshogi.website.gwt.shared.models.GameCollectionDetails in project playshogi by Tellmarch.
the class GameCollectionPropertiesForm method updateDetails.
private GameCollectionDetails updateDetails(final GameCollectionDetails details) {
GameCollectionDetails result = new GameCollectionDetails(getTitle(), getDescription(), getVisibility());
result.setId(details.getId());
return result;
}
use of com.playshogi.website.gwt.shared.models.GameCollectionDetails 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;
}
Aggregations