use of com.vaadin.flow.component.contextmenu.MenuItem in project linkki by linkki-framework.
the class ThemeVariantToggleMenuItemDefinition method createItem.
@Override
public MenuItem createItem(SubMenu subMenu) {
MenuItem createdItem = super.createItem(subMenu);
createdItem.setCheckable(true);
createdItem.setChecked(UI.getCurrent().getElement().getThemeList().contains(variantName));
return toggleThemeOnClick(createdItem);
}
use of com.vaadin.flow.component.contextmenu.MenuItem in project linkki by linkki-framework.
the class ApplicationHeader method addHelpMenu.
/**
* Creates a help menu item in the given parent.
*
* @implNote Override {@link #addHelpMenuItems(MenuItem)} to add sub menu items to the created
* {@link #addHelpMenu(MenuBar) help menu item}.
*/
protected MenuItem addHelpMenu(MenuBar parent) {
MenuItem helpMenu = parent.addItem(VaadinIcon.QUESTION_CIRCLE.create());
helpMenu.setId(APPMENU_HELP_ID);
addHelpMenuItems(helpMenu);
return helpMenu;
}
use of com.vaadin.flow.component.contextmenu.MenuItem 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;
}
use of com.vaadin.flow.component.contextmenu.MenuItem in project linkki by linkki-framework.
the class ThemeVariantToggleMenuItemDefinitionTest method testCreateItem_SubMenu_ReflectsVariantCheckedInitially.
@Test
void testCreateItem_SubMenu_ReflectsVariantCheckedInitially() {
MenuItem item = new ApplicationMenu().addItem("item");
UI.getCurrent().getElement().getThemeList().add("variant");
new ThemeVariantToggleMenuItemDefinition("name", "id", "variant").createItem(item.getSubMenu());
assertThat(item.getSubMenu().getItems()).hasSize(1);
MenuItem createdItem = item.getSubMenu().getItems().get(0);
assertThat(createdItem.getText()).isEqualTo("name");
assertThat(createdItem.getId()).hasValue("id");
assertThat(createdItem.isCheckable()).isTrue();
assertThat(createdItem.isChecked()).isTrue();
}
use of com.vaadin.flow.component.contextmenu.MenuItem in project docs by vaadin.
the class MenuBarIconOnly method createIconItem.
// tag::createIcon[]
private MenuItem createIconItem(MenuBar menu, VaadinIcon iconName, String ariaLabel) {
Icon icon = new Icon(iconName);
MenuItem item = menu.addItem(icon);
item.getElement().setAttribute("aria-label", ariaLabel);
return item;
}
Aggregations