Search in sources :

Example 16 with MenuBar

use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.

the class PlaygroundApplicationHeader method createRightMenuBar.

// tag::applicationheader-createRightMenuBar[]
@Override
protected MenuBar createRightMenuBar() {
    MenuBar rightMenuBar = super.createRightMenuBar();
    MenuItem settings = rightMenuBar.addItem(VaadinIcon.COG.create());
    settings.setId("appmenu-settings");
    addThemeVariantToggles(settings, ThemeVariantToggleMenuItemDefinition.LUMO_DARK, ThemeVariantToggleMenuItemDefinition.LINKKI_CARD, ThemeVariantToggleMenuItemDefinition.LINKKI_COMPACT);
    // end::applicationheader-createRightMenuBar[]
    new ApplicationMenuItemDefinition("Locale", "appmenu-locale", () -> new PmoBasedDialogFactory().newOkDialog("Browser Locale", new LocaleInfoPmo()).open()).createItem(settings.getSubMenu());
    return rightMenuBar;
}
Also used : PmoBasedDialogFactory(org.linkki.framework.ui.dialogs.PmoBasedDialogFactory) MenuBar(com.vaadin.flow.component.menubar.MenuBar) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) ApplicationMenuItemDefinition(org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition)

Example 17 with MenuBar

use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.

the class ApplicationHeaderTest method testRightMenu.

@Test
void testRightMenu() {
    ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.empty());
    header.init();
    MenuBar rightComponent = (MenuBar) ((HorizontalLayout) header.getContent().getComponentAt(1)).getComponentAt(0);
    assertThat(rightComponent.getId()).hasValue(ApplicationHeader.APPMENU_RIGHT_ID);
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) Test(org.junit.jupiter.api.Test)

Example 18 with MenuBar

use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.

the class ApplicationMenuItemDefinitionTest method testCreateItem_SubMenu_NoSubMenu.

@Test
void testCreateItem_SubMenu_NoSubMenu() {
    ApplicationMenuItemDefinition itemDefinition = new ApplicationMenuItemDefinition("name", "id", Handler.NOP_HANDLER);
    MenuBar menuBar = new MenuBar();
    SubMenu subMenu = menuBar.addItem("item").getSubMenu();
    itemDefinition.createItem(subMenu);
    assertThat(subMenu.getItems()).hasSize(1);
    assertThat(subMenu.getItems().get(0).getText()).isEqualTo("name");
    assertThat(subMenu.getItems().get(0).getId()).hasValue("id");
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) SubMenu(com.vaadin.flow.component.contextmenu.SubMenu) Test(org.junit.jupiter.api.Test)

Example 19 with MenuBar

use of com.vaadin.flow.component.menubar.MenuBar in project aire-components by aire-ux.

the class MainView method createTop.

protected HasComponents createTop() {
    val topNav = super.createTop();
    topNav.add(new BreadcrumbNavigation());
    val menuBar = new MenuBar();
    menuBar.addThemeVariants(MenuBarVariant.LUMO_SMALL, MenuBarVariant.LUMO_ICON);
    var homeButton = new NavigationBarButton(MainView.class, new Image("images/icon.svg", "Home"));
    homeButton.setClassName("container-end");
    topNav.add(homeButton);
    val item = menuBar.addItem(VaadinIcon.MENU.create());
    val submenu = item.getSubMenu();
    submenu.addItem(new RouterLink("Zephyr", ModuleGrid.class));
    topNav.add(menuBar);
    return topNav;
}
Also used : lombok.val(lombok.val) BreadcrumbNavigation(io.sunshower.zephyr.ui.controls.BreadcrumbNavigation) RouterLink(com.vaadin.flow.router.RouterLink) NavigationBarButton(io.sunshower.zephyr.ui.controls.NavigationBarButton) MenuBar(com.vaadin.flow.component.menubar.MenuBar) Image(com.vaadin.flow.component.html.Image) ModuleGrid(io.sunshower.zephyr.management.ModuleGrid)

Example 20 with MenuBar

use of com.vaadin.flow.component.menubar.MenuBar in project aire-components by aire-ux.

the class UploadPluginOverlay method addFooter.

private void addFooter() {
    val menubar = new MenuBar();
    menubar.addThemeVariants(MenuBarVariant.LUMO_ICON, MenuBarVariant.LUMO_TERTIARY_INLINE);
    val cancel = new Button("Cancel", VaadinIcon.CLOSE.create());
    cancel.addClickListener(event -> this.cancel());
    val install = new Button("Upload", VaadinIcon.UPLOAD_ALT.create());
    install.addClickListener(this::onSuccess);
    menubar.addItem(cancel);
    menubar.addItem(install);
    getFooter().add(menubar);
}
Also used : lombok.val(lombok.val) Button(com.vaadin.flow.component.button.Button) MenuBar(com.vaadin.flow.component.menubar.MenuBar)

Aggregations

MenuBar (com.vaadin.flow.component.menubar.MenuBar)22 MenuItem (com.vaadin.flow.component.contextmenu.MenuItem)9 Test (org.junit.jupiter.api.Test)8 Button (com.vaadin.flow.component.button.Button)6 lombok.val (lombok.val)6 SubMenu (com.vaadin.flow.component.contextmenu.SubMenu)3 TextField (com.vaadin.flow.component.textfield.TextField)3 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)2 ComponentEvent (com.vaadin.flow.component.ComponentEvent)1 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 Text (com.vaadin.flow.component.Text)1 Unit (com.vaadin.flow.component.Unit)1 Anchor (com.vaadin.flow.component.html.Anchor)1 Image (com.vaadin.flow.component.html.Image)1 Label (com.vaadin.flow.component.html.Label)1 Span (com.vaadin.flow.component.html.Span)1 Notification (com.vaadin.flow.component.notification.Notification)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 RouterLink (com.vaadin.flow.router.RouterLink)1 VaadinService (com.vaadin.flow.server.VaadinService)1