Search in sources :

Example 1 with ApplicationMenuItemDefinition

use of org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition 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 2 with ApplicationMenuItemDefinition

use of org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition in project linkki by linkki-framework.

the class ApplicationHeaderTest method testLeftMenu.

@Test
void testLeftMenu() {
    ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.of(new ApplicationMenuItemDefinition("name1", "id1", Handler.NOP_HANDLER), new ApplicationMenuItemDefinition("name2", "id2", Handler.NOP_HANDLER)));
    header.init();
    assertThat(header.getContent().getComponentAt(0)).isInstanceOf(ApplicationMenu.class);
    ApplicationMenu leftComponent = (ApplicationMenu) header.getContent().getComponentAt(0);
    assertThat(leftComponent.getItems()).hasSize(2);
}
Also used : ApplicationMenu(org.linkki.framework.ui.application.menu.ApplicationMenu) ApplicationMenuItemDefinition(org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition) Test(org.junit.jupiter.api.Test)

Example 3 with ApplicationMenuItemDefinition

use of org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition in project linkki by linkki-framework.

the class CustomApplicationHeader method addHelpMenuItems.

@Override
protected void addHelpMenuItems(MenuItem helpMenu) {
    new ApplicationMenuItemDefinition(PlaygroundNlsText.getString("ApplicationHeader.Feedback"), "appmenu-custom", () -> Notification.show("Thank you for customizing me!")).createItem(helpMenu.getSubMenu());
    addApplicationInfoMenuItem(helpMenu);
}
Also used : ApplicationMenuItemDefinition(org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition)

Aggregations

ApplicationMenuItemDefinition (org.linkki.framework.ui.application.menu.ApplicationMenuItemDefinition)3 MenuItem (com.vaadin.flow.component.contextmenu.MenuItem)1 MenuBar (com.vaadin.flow.component.menubar.MenuBar)1 Test (org.junit.jupiter.api.Test)1 ApplicationMenu (org.linkki.framework.ui.application.menu.ApplicationMenu)1 PmoBasedDialogFactory (org.linkki.framework.ui.dialogs.PmoBasedDialogFactory)1