Search in sources :

Example 1 with Root

use of org.vaadin.elements.Root in project vaadin-app-layout by appreciated.

the class GoogleMapDemo method getDemoView.

@Override
protected Component getDemoView() {
    CssLayout wrapper = new CssLayout();
    Root root = ElementIntegration.getRoot(wrapper);
    final Element googleMap = Elements.create("google-map");
    googleMap.setAttribute("style", "height: 500px; width: 500px; display: block");
    googleMap.setAttribute("latitude", "60.45235");
    googleMap.setAttribute("longitude", "22.299727");
    googleMap.setAttribute("zoom", "17");
    root.appendChild(googleMap);
    HorizontalLayout buttons = new HorizontalLayout(new Button("GWT.create US", event -> {
        googleMap.setAttribute("latitude", "37.414274");
        googleMap.setAttribute("longitude", "-122.077409");
    }), new Button("GWT.create EU", event -> {
        googleMap.setAttribute("latitude", "48.152663");
        googleMap.setAttribute("longitude", "11.598418");
    }));
    buttons.setSpacing(true);
    VerticalLayout layout = new VerticalLayout(buttons, wrapper);
    layout.setSpacing(true);
    return layout;
}
Also used : Root(org.vaadin.elements.Root) HtmlImport(com.vaadin.annotations.HtmlImport) Elements(org.vaadin.elements.Elements) ElementIntegration(org.vaadin.elements.ElementIntegration) com.vaadin.ui(com.vaadin.ui) Element(org.vaadin.elements.Element) Root(org.vaadin.elements.Root) Element(org.vaadin.elements.Element)

Example 2 with Root

use of org.vaadin.elements.Root in project catma by forTEXT.

the class TabbedView method attach.

@Override
public void attach() {
    super.attach();
    Root tabSheetRoot = ElementIntegration.getRoot(tabSheet);
    tabSheetRoot.fetchDom(() -> {
        if (!tabSheetRoot.getChildren().isEmpty()) {
            Element tabContainer = (Element) tabSheetRoot.getChildren().get(0);
            Element addButtonElement = Elements.create("div");
            addButtonElement.setAttribute("class", "c-tabbed-view-plus v-button v-widget icon-only " + "v-button-icon-only button__icon v-button-button__icon " + "flat v-button-flat borderless v-button-borderless");
            tabContainer.appendChild(addButtonElement);
            addButtonElement.setInnerHtml(VaadinIcons.PLUS.getHtml());
            addButtonElement.addEventListener("click", args -> {
                addClosableTab(closeableTabFactory.createClosableTab());
            });
        }
    }, tabSheet);
    if (tabSheet.getComponentCount() == 0) {
        addClosableTab(closeableTabFactory.createClosableTab());
    }
}
Also used : Root(org.vaadin.elements.Root) Element(org.vaadin.elements.Element)

Example 3 with Root

use of org.vaadin.elements.Root in project vaadin-app-layout by appreciated.

the class ExistingElementsDemo method getDemoView.

@Override
protected Component getDemoView() {
    Button button = new Button("Click to modify my styles");
    Root root = ElementIntegration.getRoot(button);
    button.addClickListener(e -> {
        Optional<Element> span = root.querySelector("span.v-button-wrap");
        span.ifPresent(element -> {
            if (element.hasAttribute("style")) {
                element.removeAttribute("style");
            } else {
                element.setAttribute("style", "color: red");
            }
        });
    });
    // Fetch dom so that it's available when clicking the button
    root.fetchDom(null);
    return button;
}
Also used : Root(org.vaadin.elements.Root) Button(com.vaadin.ui.Button) Element(org.vaadin.elements.Element)

Example 4 with Root

use of org.vaadin.elements.Root in project vaadin-app-layout by appreciated.

the class Html5InputDemo method getDemoView.

@Override
protected Component getDemoView() {
    input.bindAttribute("value", "change");
    input.addEventListener("change", arguments -> {
        Notification.show("Value changed to " + input.getAttribute("value"));
    });
    typeSelector.setEmptySelectionAllowed(false);
    typeSelector.addValueChangeListener(event -> {
        String type = String.valueOf(typeSelector.getValue());
        input.setAttribute("value", "");
        input.setAttribute("type", type);
        playground.setCaption("input type=" + type);
    });
    typeSelector.setValue("range");
    Root root = ElementIntegration.getRoot(playground);
    root.appendChild(input);
    HorizontalLayout layout = new HorizontalLayout(typeSelector, playground);
    layout.setSpacing(true);
    return layout;
}
Also used : Root(org.vaadin.elements.Root)

Example 5 with Root

use of org.vaadin.elements.Root in project vaadin-app-layout by appreciated.

the class PaperElementsDemo method getDemoView.

@Override
protected Component getDemoView() {
    PaperButton basicButton = PaperButton.create("Basic button");
    basicButton.setRaised(true);
    basicButton.addEventListener("click", args -> {
        Notification.show("Clicked");
    });
    PaperButton notRaisedButton = PaperButton.create("Not raised");
    notRaisedButton.setRaised(false);
    PaperButton noInkButton = PaperButton.create("No ink");
    noInkButton.setRaised(true);
    noInkButton.setNoink(true);
    PaperButton disabledButton = PaperButton.create("Disabled");
    disabledButton.setDisabled(true);
    Layout horizontal = Layout.horizontal();
    horizontal.setJustified(true);
    horizontal.setAttribute("style", "width: 600px");
    horizontal.appendChild(basicButton);
    horizontal.appendChild(notRaisedButton);
    horizontal.appendChild(noInkButton);
    horizontal.appendChild(disabledButton);
    PaperSlider slider = PaperSlider.create();
    slider.setValue(50);
    slider.addEventListener("change", arguments -> {
        Notification.show("Value changed to " + slider.getValue());
    });
    Layout vertical = Layout.vertical();
    vertical.appendHtml("<h2>Slider</h2>");
    vertical.appendChild(slider);
    vertical.appendHtml("<h2>Buttons</h2>");
    vertical.appendChild(horizontal);
    CssLayout wrapper = new CssLayout();
    Root root = ElementIntegration.getRoot(wrapper);
    root.appendChild(vertical);
    return wrapper;
}
Also used : CssLayout(com.vaadin.ui.CssLayout) Root(org.vaadin.elements.Root) CssLayout(com.vaadin.ui.CssLayout)

Aggregations

Root (org.vaadin.elements.Root)5 Element (org.vaadin.elements.Element)3 HtmlImport (com.vaadin.annotations.HtmlImport)1 com.vaadin.ui (com.vaadin.ui)1 Button (com.vaadin.ui.Button)1 CssLayout (com.vaadin.ui.CssLayout)1 ElementIntegration (org.vaadin.elements.ElementIntegration)1 Elements (org.vaadin.elements.Elements)1