Search in sources :

Example 1 with Window

use of org.dominokit.domino.ui.modals.Window in project playshogi by Tellmarch.

the class UploadKifusPopup method createModalDialog.

private Window createModalDialog() {
    Window modal = new Window("Upload Kifu(s)").setSize(IsModalDialog.ModalSize.LARGE);
    modal.appendChild(TextNode.of("With this dialog you can import a collection of " + "kifus."));
    Select<String> charsetSelect = Select.<String>create().appendChild(SelectOption.create("UTF-8", "Encoding: Unicode (UTF-8) - Ex: 81dojo")).appendChild(SelectOption.create("SHIFT-JIS", "Encoding: Japanese (SHIFT-JIS)")).appendChild(SelectOption.create("windows-932", "Encoding: Japanese (windows-932) - Ex: SC24, " + "KifuForWindows, etc.")).setSearchable(false).selectAt(2);
    fileUpload = FileUpload.create().setIcon(Icons.ALL.touch_app()).setUrl(GWT.getModuleBaseURL() + "uploadKifu").multipleFiles().autoUpload().setName("file").accept("zip,usf,kif,psn").appendChild(Elements.h(3).textContent("Drop files here or click to upload.")).appendChild(Elements.em().textContent("(Supported formats: Zip file containing .usf, .kif or .psn files.)")).onAddFile(fileItem -> {
        Notification.createInfo("File added. " + fileItem.getFileName()).show();
        fileItem.addBeforeUploadHandler((request, formData) -> {
            formData.append("collectionId", draftId);
            formData.append("returnUsf", "false");
            formData.append("returnSummary", "true");
            formData.append("charset", charsetSelect.getValue());
        });
        fileItem.addErrorHandler(request -> Notification.createDanger("Error while uploading").show());
        fileItem.addSuccessUploadHandler(request -> {
            GWT.log("Successful upload");
            parseResponse(request.responseText);
            Notification.createSuccess("File uploaded successfully").show();
            fileItem.remove();
        });
    });
    modal.appendChild(charsetSelect);
    modal.appendChild(fileUpload);
    Tab kifusTab = Tab.create("Kifus").appendChild(b().textContent("Uploaded kifus:")).appendChild(createKifusTable());
    if (enableKifuUpload) {
        kifusTab.appendChild(Button.createPrimary("Upload Kifus only, not in a collection").addClickListener(evt -> {
            eventBus.fireEvent(SaveDraftCollectionEvent.ofKifus(draftId));
            dialog.close();
        }));
    }
    Tab gamesTab = Tab.create("Import as Game Collection").appendChild(b().textContent("Import all kifus as a game collection")).appendChild(createGameCollectionsForm());
    Tab problemsTab = Tab.create("Import as Problem Collection").appendChild(b().textContent("Import all kifus as a problem collection")).appendChild(createProblemCollectionsForm());
    tabs = TabsPanel.create().appendChild(kifusTab);
    if (enableNewGameCollection || enableAddToGameCollection) {
        tabs.appendChild(gamesTab);
    }
    if (enableNewProblemCollection || enableAddToProblemCollection) {
        tabs.appendChild(problemsTab);
    }
    tabs.hide();
    modal.appendChild(tabs);
    Button closeButton = Button.create("CANCEL").linkify();
    closeButton.addClickListener(evt -> modal.close());
    modal.appendFooterChild(closeButton);
    // modal.getBodyElement().style().setOverFlow("scroll").setHeight("100%");
    return modal;
}
Also used : Window(org.dominokit.domino.ui.modals.Window) Icons(org.dominokit.domino.ui.icons.Icons) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) SaveDraftCollectionEvent(com.playshogi.website.gwt.client.events.collections.SaveDraftCollectionEvent) Elements.b(org.jboss.elemento.Elements.b) GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Elements(org.jboss.elemento.Elements) GWT(com.google.gwt.core.client.GWT) AdvancedPaginationPlugin(org.dominokit.domino.ui.datatable.plugins.AdvancedPaginationPlugin) EventBinder(com.google.web.bindery.event.shared.binder.EventBinder) Notification(org.dominokit.domino.ui.notifications.Notification) DataTable(org.dominokit.domino.ui.datatable.DataTable) ArrayList(java.util.ArrayList) Tab(org.dominokit.domino.ui.tabs.Tab) TabsPanel(org.dominokit.domino.ui.tabs.TabsPanel) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) FileUpload(org.dominokit.domino.ui.upload.FileUpload) IsModalDialog(org.dominokit.domino.ui.modals.IsModalDialog) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) EventBus(com.google.web.bindery.event.shared.EventBus) ListProblemCollectionsEvent(com.playshogi.website.gwt.client.events.collections.ListProblemCollectionsEvent) List(java.util.List) Select(org.dominokit.domino.ui.forms.Select) Window(org.dominokit.domino.ui.modals.Window) ListGameCollectionsEvent(com.playshogi.website.gwt.client.events.collections.ListGameCollectionsEvent) Node(elemental2.dom.Node) Button(org.dominokit.domino.ui.button.Button) Tab(org.dominokit.domino.ui.tabs.Tab) Button(org.dominokit.domino.ui.button.Button)

Aggregations

GWT (com.google.gwt.core.client.GWT)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 EventBinder (com.google.web.bindery.event.shared.binder.EventBinder)1 EventHandler (com.google.web.bindery.event.shared.binder.EventHandler)1 ListGameCollectionsEvent (com.playshogi.website.gwt.client.events.collections.ListGameCollectionsEvent)1 ListProblemCollectionsEvent (com.playshogi.website.gwt.client.events.collections.ListProblemCollectionsEvent)1 SaveDraftCollectionEvent (com.playshogi.website.gwt.client.events.collections.SaveDraftCollectionEvent)1 GameCollectionDetails (com.playshogi.website.gwt.shared.models.GameCollectionDetails)1 ProblemCollectionDetails (com.playshogi.website.gwt.shared.models.ProblemCollectionDetails)1 Node (elemental2.dom.Node)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Button (org.dominokit.domino.ui.button.Button)1 ColumnConfig (org.dominokit.domino.ui.datatable.ColumnConfig)1 DataTable (org.dominokit.domino.ui.datatable.DataTable)1 TableConfig (org.dominokit.domino.ui.datatable.TableConfig)1 AdvancedPaginationPlugin (org.dominokit.domino.ui.datatable.plugins.AdvancedPaginationPlugin)1 LocalListDataStore (org.dominokit.domino.ui.datatable.store.LocalListDataStore)1 Select (org.dominokit.domino.ui.forms.Select)1 SelectOption (org.dominokit.domino.ui.forms.SelectOption)1