Search in sources :

Example 1 with GameCollectionDetails

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;
    }
}
Also used : GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler)

Example 2 with GameCollectionDetails

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));
}
Also used : GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) SaveGameCollectionDetailsEvent(com.playshogi.website.gwt.client.events.collections.SaveGameCollectionDetailsEvent)

Example 3 with GameCollectionDetails

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));
}
Also used : GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) CreateGameCollectionEvent(com.playshogi.website.gwt.client.events.collections.CreateGameCollectionEvent)

Example 4 with GameCollectionDetails

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;
}
Also used : GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails)

Example 5 with GameCollectionDetails

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;
}
Also used : GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails)

Aggregations

GameCollectionDetails (com.playshogi.website.gwt.shared.models.GameCollectionDetails)6 ProblemCollectionDetails (com.playshogi.website.gwt.shared.models.ProblemCollectionDetails)2 GWT (com.google.gwt.core.client.GWT)1 Window (com.google.gwt.user.client.Window)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Widget (com.google.gwt.user.client.ui.Widget)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 EventHandler (com.google.web.bindery.event.shared.binder.EventHandler)1 ConvertGameCollectionEvent (com.playshogi.website.gwt.client.events.collections.ConvertGameCollectionEvent)1 CreateGameCollectionEvent (com.playshogi.website.gwt.client.events.collections.CreateGameCollectionEvent)1 DeleteGameCollectionEvent (com.playshogi.website.gwt.client.events.collections.DeleteGameCollectionEvent)1 SaveGameCollectionDetailsEvent (com.playshogi.website.gwt.client.events.collections.SaveGameCollectionDetailsEvent)1 AppPlaceHistoryMapper (com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper)1 GameCollectionPlace (com.playshogi.website.gwt.client.place.GameCollectionPlace)1 ElementWidget (com.playshogi.website.gwt.client.util.ElementWidget)1 CollectionPropertiesPanel (com.playshogi.website.gwt.client.widget.kifu.CollectionPropertiesPanel)1 HTMLElement (elemental2.dom.HTMLElement)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Button (org.dominokit.domino.ui.button.Button)1