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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations