Search in sources :

Example 11 with H2

use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.

the class ComboBoxDemoPage method createComboBoxWithCustomValues.

private void createComboBoxWithCustomValues() {
    Div message = createMessageDiv("custom-value-message");
    ComboBox<String> comboBox = new ComboBox<>("City");
    comboBox.setItems("Turku", "Berlin", "San Jose");
    /**
     * Allow users to enter a value which doesn't exist in the data set, and
     * set it as the value of the ComboBox.
     */
    comboBox.addCustomValueSetListener(event -> {
        comboBox.setValue(event.getDetail());
    });
    comboBox.addValueChangeListener(event -> {
        if (event.getSource().isEmpty()) {
            message.setText("No city selected");
        } else {
            message.setText("Selected city: " + event.getValue());
        }
    });
    comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
    comboBox.setId("custom-value-box");
    add(new Div(new H2("Custom Values"), new H2("Allow users to input custom values"), comboBox, message));
}
Also used : Div(com.vaadin.flow.component.html.Div) ComboBox(com.vaadin.flow.component.combobox.ComboBox) H2(com.vaadin.flow.component.html.H2)

Example 12 with H2

use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.

the class ComboBoxDemoPage method createStringComboBox.

private void createStringComboBox() {
    Div message = createMessageDiv("string-selection-message");
    ComboBox<String> comboBox = new ComboBox<>("Browsers");
    comboBox.setItems("Google Chrome", "Mozilla Firefox", "Opera", "Apple Safari", "Microsoft Edge");
    comboBox.addValueChangeListener(event -> {
        if (event.getSource().isEmpty()) {
            message.setText("No browser selected");
        } else {
            message.setText("Selected browser: " + event.getValue());
        }
    });
    comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
    comboBox.setId("string-selection-box");
    add(new Div(new H2("String selection"), comboBox, message));
}
Also used : Div(com.vaadin.flow.component.html.Div) ComboBox(com.vaadin.flow.component.combobox.ComboBox) H2(com.vaadin.flow.component.html.H2)

Example 13 with H2

use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.

the class ComboBoxDemoPage method createDisabledComboBox.

private void createDisabledComboBox() {
    Div message = createMessageDiv("disabled-combobox-message");
    ComboBox<String> comboBox = new ComboBox<>("Disabled ComboBox");
    comboBox.setEnabled(false);
    comboBox.setItems("Google Chrome", "Mozilla Firefox", "Opera", "Apple Safari", "Microsoft Edge");
    comboBox.addValueChangeListener(event -> {
        if (event.getSource().isEmpty()) {
            message.setText("No browser selected");
        } else {
            message.setText("Selected browser: " + event.getValue());
        }
    });
    comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
    comboBox.setId("disabled-combo-box");
    add(new Div(new H2("Disabled ComboBox"), comboBox, message));
}
Also used : Div(com.vaadin.flow.component.html.Div) ComboBox(com.vaadin.flow.component.combobox.ComboBox) H2(com.vaadin.flow.component.html.H2)

Example 14 with H2

use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.

the class GridUpdateDataProviderPage method createBasicGrid.

private void createBasicGrid() {
    Grid<String> grid = new Grid<>();
    grid.setId("basic-grid");
    DataProvider<String, ?> orig = DataProvider.fromCallbacks(query -> IntStream.range(query.getOffset(), query.getOffset() + query.getLimit()).mapToObj(Integer::toString), query -> 10000);
    DataProvider<String, ?> updated = DataProvider.ofItems("foo", "foob", "fooba", "foobar");
    grid.setDataProvider(orig);
    grid.addColumn(i -> i).setHeader("text");
    grid.addColumn(i -> String.valueOf(i.length())).setHeader("length");
    NativeButton updateProvider = new NativeButton("Use another provider", event -> swapDataProviders(grid, orig, updated));
    updateProvider.setId("update-basic-provider");
    add(new H2("Basic grid"), grid, updateProvider);
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) List(java.util.List) Grid(com.vaadin.flow.component.grid.Grid) DataProvider(com.vaadin.flow.data.provider.DataProvider) Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) H2(com.vaadin.flow.component.html.H2) Route(com.vaadin.flow.router.Route) NativeButton(com.vaadin.flow.component.html.NativeButton) Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2)

Example 15 with H2

use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.

the class GridMultiSelectionColumnPage method createInMemoryGrid.

private void createInMemoryGrid() {
    Grid<String> grid = new Grid<>();
    grid.setItems(IntStream.range(0, ITEM_COUNT).mapToObj(Integer::toString));
    setUp(grid);
    grid.setId(IN_MEMORY_GRID_ID);
    add(new H2("In-memory grid"), grid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2)

Aggregations

H2 (com.vaadin.flow.component.html.H2)68 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)29 Div (com.vaadin.flow.component.html.Div)25 Grid (com.vaadin.flow.component.grid.Grid)11 ComboBox (com.vaadin.flow.component.combobox.ComboBox)10 Button (com.vaadin.flow.component.button.Button)8 Paragraph (com.vaadin.flow.component.html.Paragraph)7 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)7 Route (com.vaadin.flow.router.Route)6 List (java.util.List)6 IntStream (java.util.stream.IntStream)6 NativeButton (com.vaadin.flow.component.html.NativeButton)5 ArrayList (java.util.ArrayList)5 Html (com.vaadin.flow.component.Html)4 TextField (com.vaadin.flow.component.textfield.TextField)4 Faker (com.github.javafaker.Faker)3 ItemFilter (com.vaadin.flow.component.combobox.ComboBox.ItemFilter)3 Label (com.vaadin.flow.component.html.Label)3 CallbackDataProvider (com.vaadin.flow.data.provider.CallbackDataProvider)3 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)3