Search in sources :

Example 1 with HtmlContentBuilder

use of org.jboss.elemento.HtmlContentBuilder in project playshogi by Tellmarch.

the class KifuTable method getDetails.

private HTMLElement getDetails(final KifuDetails details) {
    Row<Row_12> rowElement = Row.create();
    rowElement.style().setMarginLeft("40px").setMarginRight("40px").setMarginTop("10px").setMarginBottom("10px");
    rowElement.addColumn(Column.span4().appendChild(h(5).add("Description:")).appendChild(TextNode.of("Name: " + details.getName())).appendChild(br()));
    HtmlContentBuilder<HTMLDivElement> previewDiv = Elements.div();
    kifuService.getKifuUsf(null, details.getId(), new AsyncCallback<String>() {

        @Override
        public void onFailure(final Throwable throwable) {
        }

        @Override
        public void onSuccess(final String usf) {
            GamePreview gamePreview = new GamePreview(userPreferences, UsfFormat.INSTANCE.readSingle(usf), 0.5);
            previewDiv.add(gamePreview.asElement());
        }
    });
    rowElement.addColumn(Column.span4().appendChild(previewDiv));
    rowElement.addColumn(Column.span4().appendChild(Button.createDanger(Icons.ALL.delete_forever()).setContent("Delete").addClickListener(evt -> confirmDeletion(details)).style().setMarginRight("20px")).appendChild(Button.createPrimary(Icons.ALL.playlist_add()).setContent("Add to collection").addClickListener(evt -> addKifuToCollection(details)).style().setMarginRight("20px")));
    return rowElement.element();
}
Also used : RequestKifuDeletionEvent(com.playshogi.website.gwt.client.events.kifu.RequestKifuDeletionEvent) ElementWidget(com.playshogi.website.gwt.client.util.ElementWidget) ListKifusEvent(com.playshogi.website.gwt.client.events.collections.ListKifusEvent) Arrays(java.util.Arrays) UsfFormat(com.playshogi.library.shogi.models.formats.usf.UsfFormat) GameCollectionDetails(com.playshogi.website.gwt.shared.models.GameCollectionDetails) Elements(org.jboss.elemento.Elements) ViewKifuPlace(com.playshogi.website.gwt.client.place.ViewKifuPlace) KifuService(com.playshogi.website.gwt.shared.services.KifuService) com.google.gwt.user.client.ui(com.google.gwt.user.client.ui) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) EventBinder(com.google.web.bindery.event.shared.binder.EventBinder) HTMLElement(elemental2.dom.HTMLElement) TextHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter) Row(org.dominokit.domino.ui.grid.Row) UserPreferences(com.playshogi.website.gwt.client.UserPreferences) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) List(java.util.List) Row_12(org.dominokit.domino.ui.grid.Row_12) KifuEditorPlace(com.playshogi.website.gwt.client.place.KifuEditorPlace) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) Button(org.dominokit.domino.ui.button.Button) Icons(org.dominokit.domino.ui.icons.Icons) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) RecordsSorter(org.dominokit.domino.ui.datatable.store.RecordsSorter) ASC(org.dominokit.domino.ui.datatable.plugins.SortDirection.ASC) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Column(org.dominokit.domino.ui.grid.Column) Elements.h(org.jboss.elemento.Elements.h) GWT(com.google.gwt.core.client.GWT) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) DataTable(org.dominokit.domino.ui.datatable.DataTable) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) SelectHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter) ProblemPlace(com.playshogi.website.gwt.client.place.ProblemPlace) Window(com.google.gwt.user.client.Window) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler) KifuServiceAsync(com.playshogi.website.gwt.shared.services.KifuServiceAsync) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) org.dominokit.domino.ui.datatable.plugins(org.dominokit.domino.ui.datatable.plugins) Elements.br(org.jboss.elemento.Elements.br) EventBus(com.google.web.bindery.event.shared.EventBus) ListProblemCollectionsEvent(com.playshogi.website.gwt.client.events.collections.ListProblemCollectionsEvent) KifuDetails(com.playshogi.website.gwt.shared.models.KifuDetails) GamePreview(com.playshogi.website.gwt.client.widget.board.GamePreview) ListGameCollectionsEvent(com.playshogi.website.gwt.client.events.collections.ListGameCollectionsEvent) HTMLDivElement(elemental2.dom.HTMLDivElement) RequestAddKifuToCollectionEvent(com.playshogi.website.gwt.client.events.collections.RequestAddKifuToCollectionEvent) Comparator(java.util.Comparator) Row_12(org.dominokit.domino.ui.grid.Row_12) HTMLDivElement(elemental2.dom.HTMLDivElement) GamePreview(com.playshogi.website.gwt.client.widget.board.GamePreview)

Example 2 with HtmlContentBuilder

use of org.jboss.elemento.HtmlContentBuilder in project playshogi by Tellmarch.

the class ProblemTable method getUpDownIcons.

private Node getUpDownIcons(final ProblemDetails record) {
    HtmlContentBuilder<HTMLDivElement> difficulty = div();
    difficulty.add(Button.createPrimary(Icons.ALL.transfer_up_mdi()).addClickListener(e -> eventBus.fireEvent(new MoveProblemUpEvent(record, collectionDetails))));
    difficulty.add(Button.createPrimary(Icons.ALL.transfer_down_mdi()).addClickListener(e -> eventBus.fireEvent(new MoveProblemDownEvent(record, collectionDetails))));
    return difficulty.element();
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) ElementWidget(com.playshogi.website.gwt.client.util.ElementWidget) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) UsfFormat(com.playshogi.library.shogi.models.formats.usf.UsfFormat) Badge(org.dominokit.domino.ui.badges.Badge) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Elements(org.jboss.elemento.Elements) Column(org.dominokit.domino.ui.grid.Column) KifuService(com.playshogi.website.gwt.shared.services.KifuService) GWT(com.google.gwt.core.client.GWT) MoveProblemUpEvent(com.playshogi.website.gwt.client.events.collections.MoveProblemUpEvent) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) DataTable(org.dominokit.domino.ui.datatable.DataTable) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) HTMLElement(elemental2.dom.HTMLElement) ProblemPlace(com.playshogi.website.gwt.client.place.ProblemPlace) Row(org.dominokit.domino.ui.grid.Row) Window(com.google.gwt.user.client.Window) KifuServiceAsync(com.playshogi.website.gwt.shared.services.KifuServiceAsync) SimplePaginationPlugin(org.dominokit.domino.ui.datatable.plugins.SimplePaginationPlugin) TextNode(org.dominokit.domino.ui.utils.TextNode) UserPreferences(com.playshogi.website.gwt.client.UserPreferences) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) ColorScheme(org.dominokit.domino.ui.style.ColorScheme) EventBus(com.google.web.bindery.event.shared.EventBus) BoardPreview(com.playshogi.website.gwt.client.widget.board.BoardPreview) KifuDetails(com.playshogi.website.gwt.shared.models.KifuDetails) RecordDetailsPlugin(org.dominokit.domino.ui.datatable.plugins.RecordDetailsPlugin) Widget(com.google.gwt.user.client.ui.Widget) List(java.util.List) HTMLDivElement(elemental2.dom.HTMLDivElement) Node(elemental2.dom.Node) Row_12(org.dominokit.domino.ui.grid.Row_12) ProblemDetails(com.playshogi.website.gwt.shared.models.ProblemDetails) KifuEditorPlace(com.playshogi.website.gwt.client.place.KifuEditorPlace) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) RemoveProblemFromCollectionEvent(com.playshogi.website.gwt.client.events.collections.RemoveProblemFromCollectionEvent) MoveProblemDownEvent(com.playshogi.website.gwt.client.events.collections.MoveProblemDownEvent) Button(org.dominokit.domino.ui.button.Button) MoveProblemUpEvent(com.playshogi.website.gwt.client.events.collections.MoveProblemUpEvent) MoveProblemDownEvent(com.playshogi.website.gwt.client.events.collections.MoveProblemDownEvent) HTMLDivElement(elemental2.dom.HTMLDivElement)

Example 3 with HtmlContentBuilder

use of org.jboss.elemento.HtmlContentBuilder in project playshogi by Tellmarch.

the class LessonsView method showLessonSelection.

private void showLessonSelection() {
    if (sessionInformation.isLoggedIn()) {
        int total = 0;
        int completed = 0;
        for (TreeItem<LessonDetails> lesson : treeItems.values()) {
            if (lesson.getValue().getKifuId() != null || lesson.getValue().getProblemCollectionId() != null) {
                total++;
                if (lesson.getValue().isCompleted()) {
                    completed++;
                }
            }
        }
        HtmlContentBuilder<HTMLUListElement> perDifficulty = Elements.ul();
        for (int difficulty = 1; difficulty <= 5; difficulty++) {
            int todo = 0;
            TreeItem<LessonDetails> suggested = null;
            for (TreeItem<LessonDetails> treeItem : treeItems.values()) {
                LessonDetails lesson = treeItem.getValue();
                if (lesson.getDifficulty() == difficulty && (lesson.getKifuId() != null || lesson.getProblemCollectionId() != null) && !lesson.isCompleted()) {
                    todo++;
                    if (suggested == null) {
                        suggested = treeItem;
                    }
                }
            }
            if (todo > 0) {
                HtmlContentBuilder<HTMLDivElement> div = Elements.div();
                for (int i = 1; i <= 5; i++) {
                    if (i > difficulty) {
                        div.add(Icons.ALL.star_border());
                    } else {
                        div.add(Icons.ALL.star());
                    }
                }
                TreeItem<LessonDetails> finalSuggested = suggested;
                perDifficulty.add(Elements.li().add(div).add((todo == 1 ? "There is 1 new lesson" : "There are " + todo + " new lessons") + " for the difficulty " + getDifficulty(difficulty) + "!").add(Elements.p()).add("Suggested next: ").add(Button.createPrimary(suggested.getTitle()).addClickListener(e -> selectLesson(finalSuggested))).add(Elements.p()));
            }
        }
        previewCard.setTitle("Welcome back, " + sessionInformation.getUsername() + "!");
        previewDescription.textContent("");
        previewDescription.add(TextNode.of("In total, you have completed " + completed + " out of " + total + " " + "available lessons."));
        previewDescription.add(Elements.p());
        previewDescription.add(perDifficulty);
        difficulty.textContent("");
        previewTags.textContent("");
        boardPreview.showPosition(ShogiInitialPositionFactory.READ_ONLY_INITIAL_POSITION);
        boardPreview.setVisible(false);
        openButton.hidden(true);
    } else {
        previewCard.setTitle("Select a Lesson on the left");
        previewDescription.textContent("");
        difficulty.textContent("");
        previewTags.textContent("");
        boardPreview.showPosition(ShogiInitialPositionFactory.READ_ONLY_INITIAL_POSITION);
        boardPreview.setVisible(true);
        openButton.hidden(true);
    }
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) ElementWidget(com.playshogi.website.gwt.client.util.ElementWidget) Inject(com.google.inject.Inject) Badge(org.dominokit.domino.ui.badges.Badge) Elements(org.jboss.elemento.Elements) ViewLessonPlace(com.playshogi.website.gwt.client.place.ViewLessonPlace) Column(org.dominokit.domino.ui.grid.Column) TreeItem(org.dominokit.domino.ui.tree.TreeItem) HashMap(java.util.HashMap) GWT(com.google.gwt.core.client.GWT) Composite(com.google.gwt.user.client.ui.Composite) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) EventBinder(com.google.web.bindery.event.shared.binder.EventBinder) ProblemsPlace(com.playshogi.website.gwt.client.place.ProblemsPlace) Js(jsinterop.base.Js) UserLoggedInEvent(com.playshogi.website.gwt.client.events.user.UserLoggedInEvent) Breadcrumb(org.dominokit.domino.ui.breadcrumbs.Breadcrumb) Tree(org.dominokit.domino.ui.tree.Tree) Map(java.util.Map) LessonsListEvent(com.playshogi.website.gwt.client.events.tutorial.LessonsListEvent) Row(org.dominokit.domino.ui.grid.Row) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler) Card(org.dominokit.domino.ui.cards.Card) TextNode(org.dominokit.domino.ui.utils.TextNode) LessonDetails(com.playshogi.website.gwt.shared.models.LessonDetails) EventBus(com.google.web.bindery.event.shared.EventBus) BoardPreview(com.playshogi.website.gwt.client.widget.board.BoardPreview) SessionInformation(com.playshogi.website.gwt.client.SessionInformation) SfenConverter(com.playshogi.library.shogi.models.formats.sfen.SfenConverter) Alert(org.dominokit.domino.ui.alerts.Alert) Color(org.dominokit.domino.ui.style.Color) Label(org.dominokit.domino.ui.labels.Label) elemental2.dom(elemental2.dom) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) ShogiInitialPositionFactory(com.playshogi.library.shogi.models.shogivariant.ShogiInitialPositionFactory) Button(org.dominokit.domino.ui.button.Button) Singleton(com.google.inject.Singleton) LessonDetails(com.playshogi.website.gwt.shared.models.LessonDetails)

Example 4 with HtmlContentBuilder

use of org.jboss.elemento.HtmlContentBuilder in project domino-ui-demo by DominoKit.

the class MdiIconsViewImpl method createDemoIcon.

private HtmlContentBuilder<HTMLDivElement> createDemoIcon(BaseIcon icon, String... moreClasses) {
    HtmlContentBuilder<HTMLElement> element = span().css("icon-name").textContent(icon.getName());
    if (moreClasses.length > 0) {
        element.css(moreClasses);
    }
    HtmlContentBuilder<HTMLDivElement> iconContainer = div().css("demo-google-material-icon").add(icon).add(element);
    String iconName = icon.getName();
    iconContainer.element().addEventListener("click", evt -> {
        String name = (iconName.replace("mdi-", "").replace("-", "_")) + (iconName.contains("mdi") ? "_mdi" : "");
        copyInput.value = "Icons.ALL." + name + "()";
        copyInput.select();
        EventListener copyListener = e -> {
            ClipboardEvent clipboardEvent = Js.uncheckedCast(e);
            clipboardEvent.clipboardData.setData("text/plain", copyInput.value);
            e.preventDefault();
        };
        DomGlobal.document.addEventListener("copy", copyListener);
        DominoDom.document.execCommand("copy");
        DomGlobal.document.removeEventListener("copy", copyListener);
        Notification.createInfo("Copied to clipboard").show();
    });
    return iconContainer;
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) InputType(org.jboss.elemento.InputType) Elements.input(org.jboss.elemento.Elements.input) HTMLInputElement(elemental2.dom.HTMLInputElement) Elements.a(org.jboss.elemento.Elements.a) UiView(org.dominokit.domino.api.client.annotations.UiView) DominoDom(org.dominokit.domino.ui.utils.DominoDom) CodeResource(org.dominokit.domino.mdiicons.client.views.CodeResource) CodeCard(org.dominokit.domino.componentcase.client.ui.views.CodeCard) LoggerFactory(org.slf4j.LoggerFactory) Column(org.dominokit.domino.ui.grid.Column) Elements.h(org.jboss.elemento.Elements.h) GWT(com.google.gwt.core.client.GWT) Supplier(java.util.function.Supplier) MdiIconsProxy(org.dominokit.domino.mdiicons.client.presenters.MdiIconsProxy) Notification(org.dominokit.domino.ui.notifications.Notification) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) Js(jsinterop.base.Js) LinkToSourceCode(org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode) HTMLElement(elemental2.dom.HTMLElement) Elements.div(org.jboss.elemento.Elements.div) ClipboardEvent(elemental2.dom.ClipboardEvent) Row(org.dominokit.domino.ui.grid.Row) Card(org.dominokit.domino.ui.cards.Card) MdiIcon(org.dominokit.domino.ui.icons.MdiIcon) BaseDemoView(org.dominokit.domino.componentcase.client.ui.views.BaseDemoView) Logger(org.slf4j.Logger) RunAsyncCallback(com.google.gwt.core.client.RunAsyncCallback) DomGlobal(elemental2.dom.DomGlobal) Elements.span(org.jboss.elemento.Elements.span) EventListener(elemental2.dom.EventListener) MdiIconsView(org.dominokit.domino.mdiicons.client.views.MdiIconsView) List(java.util.List) MdiTags(org.dominokit.domino.ui.icons.MdiTags) Color(org.dominokit.domino.ui.style.Color) HTMLDivElement(elemental2.dom.HTMLDivElement) Row_12(org.dominokit.domino.ui.grid.Row_12) BaseIcon(org.dominokit.domino.ui.icons.BaseIcon) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) MdiByTagFactory(org.dominokit.domino.ui.icons.MdiByTagFactory) ClipboardEvent(elemental2.dom.ClipboardEvent) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) EventListener(elemental2.dom.EventListener)

Example 5 with HtmlContentBuilder

use of org.jboss.elemento.HtmlContentBuilder in project domino-ui-demo by DominoKit.

the class IconsViewImpl method createDemoIcon.

private HtmlContentBuilder<HTMLDivElement> createDemoIcon(BaseIcon icon, String... moreClasses) {
    HtmlContentBuilder<HTMLElement> element = span().css("icon-name").textContent(icon.getName());
    if (moreClasses.length > 0) {
        element.css(moreClasses);
    }
    HtmlContentBuilder<HTMLDivElement> iconContainer = div().css("demo-google-material-icon").add(icon).add(element);
    String iconName = icon.getName();
    iconContainer.element().addEventListener("click", evt -> {
        String name = (iconName.replace("mdi-", "").replace("-", "_")) + (iconName.contains("mdi") ? "_mdi" : "");
        copyInput.value = "Icons.ALL." + name + "()";
        copyInput.select();
        EventListener copyListener = e -> {
            ClipboardEvent clipboardEvent = Js.uncheckedCast(e);
            clipboardEvent.clipboardData.setData("text/plain", copyInput.value);
            e.preventDefault();
        };
        DomGlobal.document.addEventListener("copy", copyListener);
        DominoDom.document.execCommand("copy");
        DomGlobal.document.removeEventListener("copy", copyListener);
        Notification.createInfo("Copied to clipboard").show();
    });
    return iconContainer;
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) InputType(org.jboss.elemento.InputType) Elements.input(org.jboss.elemento.Elements.input) HTMLInputElement(elemental2.dom.HTMLInputElement) Elements.a(org.jboss.elemento.Elements.a) UiView(org.dominokit.domino.api.client.annotations.UiView) DominoDom(org.dominokit.domino.ui.utils.DominoDom) LoggerFactory(org.slf4j.LoggerFactory) Column(org.dominokit.domino.ui.grid.Column) GWT(com.google.gwt.core.client.GWT) Notification(org.dominokit.domino.ui.notifications.Notification) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) Elements.p(org.jboss.elemento.Elements.p) Js(jsinterop.base.Js) LinkToSourceCode(org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode) HTMLElement(elemental2.dom.HTMLElement) Elements.div(org.jboss.elemento.Elements.div) ClipboardEvent(elemental2.dom.ClipboardEvent) Row(org.dominokit.domino.ui.grid.Row) Card(org.dominokit.domino.ui.cards.Card) BaseDemoView(org.dominokit.domino.componentcase.client.ui.views.BaseDemoView) Logger(org.slf4j.Logger) RunAsyncCallback(com.google.gwt.core.client.RunAsyncCallback) DomGlobal(elemental2.dom.DomGlobal) Elements.span(org.jboss.elemento.Elements.span) EventListener(elemental2.dom.EventListener) HTMLDivElement(elemental2.dom.HTMLDivElement) IconsView(org.dominokit.domino.icons.client.views.IconsView) BaseIcon(org.dominokit.domino.ui.icons.BaseIcon) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) IconsProxy(org.dominokit.domino.icons.client.presenters.IconsProxy) ClipboardEvent(elemental2.dom.ClipboardEvent) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) EventListener(elemental2.dom.EventListener)

Aggregations

Column (org.dominokit.domino.ui.grid.Column)8 Row (org.dominokit.domino.ui.grid.Row)8 Icons (org.dominokit.domino.ui.icons.Icons)8 HtmlContentBuilder (org.jboss.elemento.HtmlContentBuilder)8 GWT (com.google.gwt.core.client.GWT)7 HTMLDivElement (elemental2.dom.HTMLDivElement)7 HTMLElement (elemental2.dom.HTMLElement)6 EventBus (com.google.web.bindery.event.shared.EventBus)5 AppPlaceHistoryMapper (com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper)5 ElementWidget (com.playshogi.website.gwt.client.util.ElementWidget)5 List (java.util.List)5 Button (org.dominokit.domino.ui.button.Button)5 Row_12 (org.dominokit.domino.ui.grid.Row_12)5 TextNode (org.dominokit.domino.ui.utils.TextNode)5 Elements (org.jboss.elemento.Elements)5 Window (com.google.gwt.user.client.Window)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)4 UsfFormat (com.playshogi.library.shogi.models.formats.usf.UsfFormat)4 KifuService (com.playshogi.website.gwt.shared.services.KifuService)4 KifuServiceAsync (com.playshogi.website.gwt.shared.services.KifuServiceAsync)4