Search in sources :

Example 1 with SampleMethod

use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.

the class AdvancedFormsViewImpl method initSuggestBoxExample.

@SampleMethod
private void initSuggestBoxExample() {
    LocalSuggestBoxStore<String> localStore = LocalSuggestBoxStore.<String>create().addSuggestion(SuggestItem.create("Schroeder Coleman")).addSuggestion(SuggestItem.create("Renee Mcintyre")).addSuggestion(SuggestItem.create("Casey Garza"));
    TextBox friendNameBox = TextBox.create("Your friend name").setHelperText("Add friend name as suggestion");
    KeyboardEvents.listenOnKeyDown(friendNameBox).onEnter(evt -> {
        localStore.addSuggestion(SuggestItem.create(friendNameBox.getValue()));
        friendNameBox.clear();
    });
    suggestBoxCard.setBodyPaddingTop("40px").appendChild(Row.create().appendChild(Column.span6().appendChild(BlockHeader.create("Local suggest store")))).appendChild(Row.create().appendChild(Column.span4().appendChild(friendNameBox)).appendChild(Column.span2().appendChild(Button.createPrimary(Icons.ALL.add()).setContent("ADD FRIEND").addClickListener(evt -> {
        localStore.addSuggestion(SuggestItem.create(friendNameBox.getValue()));
        friendNameBox.clear();
    })))).appendChild(Row.create().appendChild(Column.span12().appendChild(SuggestBox.create("Your friends", localStore).setHelperText("Type any letter and see suggestions"))));
    SuggestBoxStore<String> dynamicStore = new SuggestBoxStore<String>() {

        @Override
        public void filter(String searchValue, SuggestionsHandler<String> suggestionsHandler) {
            DomGlobal.fetch("https://restcountries.com/v2/all?fields=name").then(Response::text).then(json -> {
                List<SuggestItem<String>> suggestItems = new ArrayList<>();
                JsArray<JsPropertyMap<String>> randomNames = Js.cast(Global.JSON.parse(json));
                for (int i = 0; i < randomNames.length; i++) {
                    JsPropertyMap<String> nameProperties = randomNames.getAt(i);
                    if (nameProperties.get("name").toLowerCase().contains(searchValue.toLowerCase())) {
                        SuggestItem suggestItem = SuggestItem.create(nameProperties.get("name"));
                        suggestItems.add(suggestItem);
                    }
                }
                suggestionsHandler.onSuggestionsReady(suggestItems);
                return null;
            });
        }

        @Override
        public void find(String searchValue, Consumer<SuggestItem<String>> handler) {
            DomGlobal.fetch("https://restcountries.com/v2/all?fields=name").then(Response::text).then(json -> {
                JsArray<JsPropertyMap<String>> randomNames = Js.cast(Global.JSON.parse(json));
                for (int i = 0; i < randomNames.length; i++) {
                    JsPropertyMap<String> nameProperties = randomNames.getAt(i);
                    if (nameProperties.get("name").equals(searchValue)) {
                        SuggestItem suggestItem = SuggestItem.create(nameProperties.get("name"));
                        handler.accept(suggestItem);
                        return null;
                    }
                }
                return null;
            });
        }
    };
    suggestBoxCard.appendChild(Row.create().appendChild(Column.span12().appendChild(BlockHeader.create("Dynamic suggest store")))).appendChild(Row.create().appendChild(Column.span12().appendChild(SuggestBox.create("Country", dynamicStore))));
}
Also used : LocalSuggestBoxStore(org.dominokit.domino.ui.forms.LocalSuggestBoxStore) SuggestBoxStore(org.dominokit.domino.ui.forms.SuggestBoxStore) SuggestItem(org.dominokit.domino.ui.forms.SuggestItem) ArrayList(java.util.ArrayList) TextBox(org.dominokit.domino.ui.forms.TextBox) Consumer(java.util.function.Consumer) JsPropertyMap(jsinterop.base.JsPropertyMap) SampleMethod(org.dominokit.domino.SampleMethod)

Example 2 with SampleMethod

use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.

the class LabelsViewImpl method initLabels.

@SampleMethod
private void initLabels() {
    Column column = Column.span(1, 2, 6, 12);
    element.appendChild(Card.create("LABELS").appendChild(Row.create().addColumn(column.copy().appendChild(Label.createDefault("DEFAULT").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createPrimary("PRIMARY").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createSuccess("SUCCESS").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createInfo("INFO").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createWarning("WARNING").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createDanger("DANGER").style().setMargin("10px")))).appendChild(Elements.hr()).appendChild(Elements.h(1).style("text-align: left;").textContent("Example heading ").add(Label.createDanger("New"))).appendChild(Elements.h(2).textContent("Example heading ").add(Label.createWarning("New"))).appendChild(Elements.h(3).textContent("Example heading ").add(Label.createInfo("New"))).appendChild(Elements.h(4).textContent("Example heading ").add(Label.createSuccess("New"))).appendChild(Elements.h(5).textContent("Example heading ").add(Label.createPrimary("New"))).appendChild(Elements.h(6).textContent("Example heading ").add(Label.createDefault("New"))).element());
}
Also used : Column(org.dominokit.domino.ui.grid.Column) SampleMethod(org.dominokit.domino.SampleMethod)

Example 3 with SampleMethod

use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.

the class FormsValidationsViewImpl method initIcons.

@SampleMethod
private void initIcons() {
    Icon cancel = Icons.ALL.cancel();
    TextBox username = TextBox.create("Username").addLeftAddOn(Icons.ALL.account_circle()).addRightAddOn(cancel);
    cancel.addClickListener(evt -> username.clear()).style().setCursor("pointer");
    HTMLElement showIcon = Icons.ALL.remove_red_eye().clickable().style().setCursor("pointer").element();
    TextBox password = TextBox.password("Password").addLeftAddOn(Icons.ALL.https().element()).addRightAddOn(showIcon);
    showIcon.addEventListener("mousedown", evt -> password.getInputElement().element().type = "text");
    showIcon.addEventListener("mouseup", evt -> password.getInputElement().element().type = "password");
    Icon info = Icons.ALL.info();
    Tooltip.create(info, "All system pages will be shown in the selected language");
    iconsCard.appendChild(username).appendChild(password).appendChild(TextArea.create("Description").addLeftAddOn(Icons.ALL.description())).appendChild(Select.<String>create("Language").addLeftAddOn(Icons.ALL.language()).addRightAddOn(info).appendChild(SelectOption.create("english", "English")).appendChild(SelectOption.create("france", "France")).appendChild(SelectOption.create("arabic", "Arabic")));
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Icon(org.dominokit.domino.ui.icons.Icon) TextBox(org.dominokit.domino.ui.forms.TextBox) SampleMethod(org.dominokit.domino.SampleMethod)

Example 4 with SampleMethod

use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.

the class LoadersViewImpl method sample.

@SampleMethod
private void sample() {
    Card card = Card.create("Loaders", "loader sample");
    Button button = Button.createDefault("CLICK ME").addClickListener(evt -> {
        Loader loader = Loader.create(card.element(), LoaderEffect.PULSE).setLoadingText("Loading ...").start();
        new Timer() {

            @Override
            public void run() {
                loader.stop();
            }
        }.schedule(7000);
    });
    card.appendChild(TextNode.of(SAMPLE_CONTENT)).appendChild(Elements.br()).appendChild(Elements.br()).appendChild(Elements.div().attr("style", "text-align: center").add(button));
}
Also used : Timer(org.gwtproject.timer.client.Timer) Button(org.dominokit.domino.ui.button.Button) Loader(org.dominokit.domino.ui.loaders.Loader) CodeCard(org.dominokit.domino.componentcase.client.ui.views.CodeCard) Card(org.dominokit.domino.ui.cards.Card) SampleMethod(org.dominokit.domino.SampleMethod)

Example 5 with SampleMethod

use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.

the class WavesViewImpl method sample.

@SampleMethod
private void sample() {
    HTMLElement element = div().element();
    WavesSupport.addFor(element).setWaveColor(WaveColor.YELLOW).applyWaveStyle(WaveStyle.CIRCLE);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) SampleMethod(org.dominokit.domino.SampleMethod)

Aggregations

SampleMethod (org.dominokit.domino.SampleMethod)52 HTMLDivElement (elemental2.dom.HTMLDivElement)28 CodeCard (org.dominokit.domino.componentcase.client.ui.views.CodeCard)26 SampleClass (org.dominokit.domino.SampleClass)25 UiView (org.dominokit.domino.api.client.annotations.UiView)25 BaseDemoView (org.dominokit.domino.componentcase.client.ui.views.BaseDemoView)25 LinkToSourceCode (org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode)25 Card (org.dominokit.domino.ui.cards.Card)25 BlockHeader (org.dominokit.domino.ui.header.BlockHeader)25 Button (org.dominokit.domino.ui.button.Button)21 TextBox (org.dominokit.domino.ui.forms.TextBox)21 Elements.div (org.jboss.elemento.Elements.div)21 Color (org.dominokit.domino.ui.style.Color)20 DomGlobal (elemental2.dom.DomGlobal)18 Icons (org.dominokit.domino.ui.icons.Icons)18 HTMLElement (elemental2.dom.HTMLElement)17 Notification (org.dominokit.domino.ui.notifications.Notification)17 Column (org.dominokit.domino.ui.grid.Column)16 DominoElement (org.dominokit.domino.ui.utils.DominoElement)16 List (java.util.List)14