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;
}
Aggregations