Search in sources :

Example 1 with FlexLayout

use of com.vaadin.flow.component.orderedlayout.FlexLayout in project flow-components by vaadin.

the class FlexLayoutTest method replace_componentToNull_removeAsResult.

@Test
public void replace_componentToNull_removeAsResult() {
    FlexLayout layout = new FlexLayout();
    layout.add(new Label());
    Div div = new Div();
    layout.add(div);
    layout.replace(div, null);
    Assert.assertEquals(1, layout.getComponentCount());
}
Also used : Div(com.vaadin.flow.component.html.Div) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) Label(com.vaadin.flow.component.html.Label) Test(org.junit.Test)

Example 2 with FlexLayout

use of com.vaadin.flow.component.orderedlayout.FlexLayout in project flow-components by vaadin.

the class FlexLayoutTest method replace_nullToComponent_appendAsResult.

@Test
public void replace_nullToComponent_appendAsResult() {
    FlexLayout layout = new FlexLayout();
    layout.add(new Label());
    Div div = new Div();
    layout.replace(null, div);
    Assert.assertEquals(div, layout.getComponentAt(1));
}
Also used : Div(com.vaadin.flow.component.html.Div) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) Label(com.vaadin.flow.component.html.Label) Test(org.junit.Test)

Example 3 with FlexLayout

use of com.vaadin.flow.component.orderedlayout.FlexLayout in project flow-components by vaadin.

the class OrderedLayoutView method createFlexLayoutWithFlexDirection.

private void createFlexLayoutWithFlexDirection() {
    FlexLayout layout = new FlexLayout();
    layout.setWidth("100%");
    layout.setHeight("150px");
    layout.getStyle().set("border", "1px solid #9E9E9E");
    Component component1 = createComponent(1, "#78909C");
    Component component2 = createComponent(2, "#546E7A");
    Component component3 = createComponent(3, "#37474F");
    layout.add(component1, component2, component3);
    Consumer<FlexLayout.FlexDirection> flexDirectionConsumer = flexDirection -> layout.setFlexDirection(flexDirection);
    RadioButtonGroup<FlexLayout.FlexDirection> rbg = createRadioButtonGroup(FlexLayout.FlexDirection.values(), flexDirectionConsumer, FlexLayout.FlexDirection.ROW);
    layout.setId("flex-layout-with-flex-direction");
    addCard("FlexLayout", "FlexLayout with flex direction", layout, rbg);
}
Also used : Component(com.vaadin.flow.component.Component) Scroller(com.vaadin.flow.component.orderedlayout.Scroller) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Div(com.vaadin.flow.component.html.Div) H2(com.vaadin.flow.component.html.H2) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) Consumer(java.util.function.Consumer) BoxSizing(com.vaadin.flow.component.orderedlayout.BoxSizing) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) TextRenderer(com.vaadin.flow.data.renderer.TextRenderer) Span(com.vaadin.flow.component.html.Span) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Example 4 with FlexLayout

use of com.vaadin.flow.component.orderedlayout.FlexLayout in project flow-components by vaadin.

the class OrderedLayoutView method createFlexLayoutWithFlexBasis.

private void createFlexLayoutWithFlexBasis() {
    FlexLayout layout = new FlexLayout();
    layout.setWidth("100%");
    layout.setHeight("50px");
    layout.getStyle().set("border", "1px solid #9E9E9E");
    Component component1 = createComponent(1, "#78909C");
    Component component2 = createComponent(2, "#546E7A");
    Component component3 = createComponent(3, "#37474F");
    layout.add(component1, component2, component3);
    RadioButtonGroup<String> widths = new RadioButtonGroup<>();
    widths.setItems("200px", "100%", "auto");
    widths.setValue("auto");
    widths.addValueChangeListener(event -> layout.setFlexBasis(event.getValue(), component1));
    layout.setId("flex-layout-with-flex-basis");
    addCard("FlexLayout", "FlexLayout with flex basis", layout, widths);
}
Also used : FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Example 5 with FlexLayout

use of com.vaadin.flow.component.orderedlayout.FlexLayout in project flow-components by vaadin.

the class OrderedLayoutView method createFlexLayoutWithFlexShrink.

private void createFlexLayoutWithFlexShrink() {
    FlexLayout layout = new FlexLayout();
    layout.setWidth("100%");
    layout.setHeight("50px");
    layout.getStyle().set("border", "1px solid #9E9E9E");
    Component component1 = createComponent(1, "#78909C");
    Component component2 = createComponent(2, "#546E7A");
    Component component3 = createComponent(3, "#37474F");
    layout.setFlexBasis("500px", component1, component2, component3);
    layout.add(component1, component2, component3);
    RadioButtonGroup<Integer> shrinkValues = new RadioButtonGroup<>();
    shrinkValues.setItems(0, 1, 2);
    shrinkValues.setValue(1);
    shrinkValues.addValueChangeListener(event -> layout.setFlexShrink(event.getValue(), component1));
    layout.setId("flex-layout-with-flex-shrink");
    addCard("FlexLayout", "FlexLayout with flex shrink", layout, shrinkValues);
}
Also used : FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Aggregations

FlexLayout (com.vaadin.flow.component.orderedlayout.FlexLayout)25 Div (com.vaadin.flow.component.html.Div)14 Test (org.junit.Test)12 Component (com.vaadin.flow.component.Component)10 FlexComponent (com.vaadin.flow.component.orderedlayout.FlexComponent)7 Label (com.vaadin.flow.component.html.Label)4 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)4 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)4 Route (com.vaadin.flow.router.Route)4 H2 (com.vaadin.flow.component.html.H2)3 Span (com.vaadin.flow.component.html.Span)3 RadioButtonGroup (com.vaadin.flow.component.radiobutton.RadioButtonGroup)3 Button (com.vaadin.flow.component.button.Button)2 ComboBox (com.vaadin.flow.component.combobox.ComboBox)2 Image (com.vaadin.flow.component.html.Image)2 List (java.util.List)2 ClickEvent (com.vaadin.flow.component.ClickEvent)1 Key (com.vaadin.flow.component.Key)1 UI (com.vaadin.flow.component.UI)1 LUMO_TERTIARY (com.vaadin.flow.component.button.ButtonVariant.LUMO_TERTIARY)1