Search in sources :

Example 6 with Tabs

use of com.vaadin.flow.component.tabs.Tabs in project flow-components by vaadin.

the class TabsPage method createTabsWithPages.

private void createTabsWithPages() {
    Tab tab1 = new Tab("Tab one");
    Div page1 = new Div();
    page1.setText("Page#1");
    Tab tab2 = new Tab("Tab two");
    Div page2 = new Div();
    page2.setText("Page#2");
    Tab tab3 = new Tab("Tab three");
    Div page3 = new Div();
    page3.setText("Page#3");
    Map<Tab, Component> tabsToPages = new HashMap<>();
    tabsToPages.put(tab1, page1);
    tabsToPages.put(tab2, page2);
    tabsToPages.put(tab3, page3);
    Tabs tabs = new Tabs(tab1, tab2, tab3);
    Div pages = new Div(page1);
    tabs.addSelectedChangeListener(event -> {
        pages.removeAll();
        pages.add(tabsToPages.get(event.getSelectedTab()));
    });
    tabs.setId("tabs-with-pages");
    tab1.setId("tab1");
    tab2.setId("tab2");
    tab3.setId("tab3");
    page1.setId("page1");
    page2.setId("page2");
    page3.setId("page3");
    addCard("Tabs with pages", tabs, pages);
}
Also used : Div(com.vaadin.flow.component.html.Div) Tab(com.vaadin.flow.component.tabs.Tab) HashMap(java.util.HashMap) Tabs(com.vaadin.flow.component.tabs.Tabs) Component(com.vaadin.flow.component.Component)

Example 7 with Tabs

use of com.vaadin.flow.component.tabs.Tabs in project flow-components by vaadin.

the class SelectionEventTest method disableAutoSelect_addFirstTabWithAddComponentAtIndex_noAutoselect.

@Test
public void disableAutoSelect_addFirstTabWithAddComponentAtIndex_noAutoselect() {
    tabs = new Tabs(false);
    addSelectedChangeListener(tabs);
    tabs.addComponentAtIndex(0, tab1);
    Assert.assertEquals("Unexpected selected index after adding the first tab.", -1, tabs.getSelectedIndex());
    Assert.assertNull("Expected no tab to be automatically selected.", tabs.getSelectedTab());
    Assert.assertEquals("Expected no selection event fired.", 0, eventCount);
}
Also used : Tabs(com.vaadin.flow.component.tabs.Tabs) Test(org.junit.Test)

Example 8 with Tabs

use of com.vaadin.flow.component.tabs.Tabs in project flow-components by vaadin.

the class SelectionEventTest method addFirstTabWithAddComponentAtIndex_firstTabAutoselected.

@Test
public void addFirstTabWithAddComponentAtIndex_firstTabAutoselected() {
    tabs = new Tabs();
    addSelectedChangeListener(tabs);
    tabs.addComponentAtIndex(0, tab1);
    Assert.assertEquals("Unexpected selected index after adding the first tab.", 0, tabs.getSelectedIndex());
    Assert.assertEquals("Expected the first added tab to be automatically selected.", tab1, tabs.getSelectedTab());
    Assert.assertEquals("Expected autoselection to fire an event.", 1, eventCount);
}
Also used : Tabs(com.vaadin.flow.component.tabs.Tabs) Test(org.junit.Test)

Example 9 with Tabs

use of com.vaadin.flow.component.tabs.Tabs in project furms by unity-idm.

the class FurmsAppLayoutComponentsHolder method createMenuTabs.

private Tabs createMenuTabs(List<MenuComponent> menuContent) {
    final Tabs tabs = new Tabs();
    tabs.setOrientation(Tabs.Orientation.VERTICAL);
    tabs.addThemeVariants(TabsVariant.LUMO_MINIMAL);
    tabs.setId("tabs");
    final Component[] items = menuContent.stream().map(c -> new TabComponent(getPageTitle(c.component), c)).toArray(Tab[]::new);
    tabs.add(items);
    return tabs;
}
Also used : Text(com.vaadin.flow.component.Text) VaadinTranslator.getTranslation(io.imunity.furms.ui.utils.VaadinTranslator.getTranslation) Component(com.vaadin.flow.component.Component) HasElement(com.vaadin.flow.component.HasElement) Tab(com.vaadin.flow.component.tabs.Tab) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) FurmsRolePicker(io.imunity.furms.ui.view_picker.FurmsRolePicker) Div(com.vaadin.flow.component.html.Div) Tabs(com.vaadin.flow.component.tabs.Tabs) LogoutIconFactory(io.imunity.furms.ui.components.LogoutIconFactory) Supplier(java.util.function.Supplier) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) List(java.util.List) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) TabComponent(io.imunity.furms.ui.components.TabComponent) FurmsLogo(io.imunity.furms.ui.components.branding.logo.FurmsLogo) Element(com.vaadin.flow.dom.Element) FurmsAppLayoutUtils.getPageTitle(io.imunity.furms.ui.components.layout.FurmsAppLayoutUtils.getPageTitle) Optional(java.util.Optional) TabsVariant(com.vaadin.flow.component.tabs.TabsVariant) Icon(com.vaadin.flow.component.icon.Icon) MenuComponent(io.imunity.furms.ui.components.MenuComponent) TabComponent(io.imunity.furms.ui.components.TabComponent) Tabs(com.vaadin.flow.component.tabs.Tabs) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) TabComponent(io.imunity.furms.ui.components.TabComponent) MenuComponent(io.imunity.furms.ui.components.MenuComponent)

Example 10 with Tabs

use of com.vaadin.flow.component.tabs.Tabs in project stackoverflow-qa by yukihane.

the class MainView method createMenu.

private Tabs createMenu() {
    final Tabs tabs = new Tabs();
    tabs.setOrientation(Tabs.Orientation.VERTICAL);
    tabs.addThemeVariants(TabsVariant.LUMO_MINIMAL);
    tabs.setId("tabs");
    tabs.add(createMenuItems());
    return tabs;
}
Also used : Tabs(com.vaadin.flow.component.tabs.Tabs)

Aggregations

Tabs (com.vaadin.flow.component.tabs.Tabs)40 Tab (com.vaadin.flow.component.tabs.Tab)17 Test (org.junit.Test)16 Component (com.vaadin.flow.component.Component)5 Div (com.vaadin.flow.component.html.Div)3 FlexComponent (com.vaadin.flow.component.orderedlayout.FlexComponent)2 ShowComponentRequestedEvent (org.archcnl.ui.outputview.sidebar.events.ShowComponentRequestedEvent)2 HasElement (com.vaadin.flow.component.HasElement)1 Text (com.vaadin.flow.component.Text)1 H3 (com.vaadin.flow.component.html.H3)1 NativeButton (com.vaadin.flow.component.html.NativeButton)1 Icon (com.vaadin.flow.component.icon.Icon)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 TabsVariant (com.vaadin.flow.component.tabs.TabsVariant)1 Element (com.vaadin.flow.dom.Element)1 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)1 LogoutIconFactory (io.imunity.furms.ui.components.LogoutIconFactory)1 MenuComponent (io.imunity.furms.ui.components.MenuComponent)1 TabComponent (io.imunity.furms.ui.components.TabComponent)1