Search in sources :

Example 6 with NativeButton

use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.

the class DependencyView method onShow.

@Override
protected void onShow() {
    add(new Text("This test initially loads a stylesheet which makes all text red, a JavaScript for logging window messages, a JavaScript for handling body click events and an HTML which sends a window message"), new Hr(), new HtmlComponent(), new Hr());
    Div clickBody = new Div();
    clickBody.setText("Hello, click the body please");
    clickBody.setId("hello");
    add(clickBody);
    NativeButton jsOrder = new NativeButton("Test JS order", e -> {
        getPage().addJavaScript("/test-files/js/set-global-var.js");
        getPage().addJavaScript("/test-files/js/read-global-var.js", LoadMode.LAZY);
    });
    jsOrder.setId("loadJs");
    /* HTML imports */
    NativeButton htmlOrder = new NativeButton("Test HTML order", e -> {
        getPage().addHtmlImport("base://" + htmlImport2.getResourceUri().toString());
        // This failure can only be seen in the browser console
        getPage().addHtmlImport("/doesnotexist.html");
        // Can't test JS/HTML order because of #765
        getPage().addHtmlImport("base://" + htmlImport3.getResourceUri().toString());
    });
    htmlOrder.setId("loadHtml");
    /* HTML & JS order */
    NativeButton mixedOrder = new NativeButton("Test HTML & JS order", e -> {
        getPage().addHtmlImport("/test-files/html/combinedMixed.html");
    });
    mixedOrder.setId("loadMixed");
    NativeButton allBlue = new NativeButton("Load 'everything blue' stylesheet", e -> {
        getPage().addStyleSheet("/test-files/css/allblueimportant.css");
    });
    allBlue.setId("loadBlue");
    NativeButton loadUnavailableResources = new NativeButton("Load unavailable resources", e -> {
        getPage().addStyleSheet("/not-found.css");
        getPage().addHtmlImport("/not-found.html");
        getPage().addJavaScript("/not-found.js");
    });
    loadUnavailableResources.setId("loadUnavailableResources");
    Div log = new Div();
    log.setId("log");
    add(jsOrder, htmlOrder, mixedOrder, allBlue, loadUnavailableResources, new Hr(), log);
}
Also used : Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) Text(com.vaadin.flow.component.Text) HasText(com.vaadin.flow.component.HasText) Hr(com.vaadin.flow.component.html.Hr)

Example 7 with NativeButton

use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.

the class ExecJavaScriptView method onShow.

@Override
protected void onShow() {
    NativeButton alertButton = createJsButton("Alert", "alertButton", "window.alert($0)", "Hello world");
    NativeButton focusButton = createJsButton("Focus Alert button", "focusButton", "$0.focus()", alertButton);
    NativeButton swapText = createJsButton("Swap button texts", "swapButton", "(function() {var t = $0.textContent; $0.textContent = $1.textContent; $1.textContent = t;})()", alertButton, focusButton);
    NativeButton logButton = createJsButton("Log", "logButton", "console.log($0)", JsonUtils.createArray(Json.create("Hello world"), Json.create(true)));
    NativeButton createElementButton = new NativeButton("Create and update element", e -> {
        Input input = new Input();
        input.addClassName("newInput");
        UI.getCurrent().getPage().executeJavaScript("$0.value = $1", input, "Value from js");
        add(input);
    });
    createElementButton.setId("createButton");
    add(alertButton, focusButton, swapText, logButton, createElementButton);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Input(com.vaadin.flow.component.html.Input)

Example 8 with NativeButton

use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.

the class ExecJavaScriptView method createJsButton.

private NativeButton createJsButton(String text, String id, String script, Serializable... arguments) {
    NativeButton button = new NativeButton(text, e -> UI.getCurrent().getPage().executeJavaScript(script, arguments));
    button.setId(id);
    return button;
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton)

Example 9 with NativeButton

use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.

the class ForTemplateView method createButton.

private NativeButton createButton(String text, String id, Command action) {
    NativeButton button = new NativeButton(text);
    button.addClickListener(e -> action.execute());
    button.setId(id);
    return button;
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton)

Example 10 with NativeButton

use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.

the class HistoryView method createButton.

private static Element createButton(String id, ComponentEventListener<ClickEvent> listener) {
    NativeButton button = new NativeButton(id, listener);
    button.setId(id);
    return button.getElement();
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton)

Aggregations

NativeButton (com.vaadin.flow.component.html.NativeButton)24 Div (com.vaadin.flow.component.html.Div)9 Text (com.vaadin.flow.component.Text)4 Hr (com.vaadin.flow.component.html.Hr)3 Input (com.vaadin.flow.component.html.Input)3 Label (com.vaadin.flow.component.html.Label)3 AttachEvent (com.vaadin.flow.component.AttachEvent)2 Component (com.vaadin.flow.component.Component)2 UI (com.vaadin.flow.component.UI)2 Element (com.vaadin.flow.dom.Element)2 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)2 Route (com.vaadin.flow.router.Route)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HasText (com.vaadin.flow.component.HasText)1 HasValidation (com.vaadin.flow.component.HasValidation)1 Html (com.vaadin.flow.component.Html)1 Paragraph (com.vaadin.flow.component.html.Paragraph)1 Push (com.vaadin.flow.component.page.Push)1 Style (com.vaadin.flow.dom.Style)1