use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationHeaderTest method testAddThemeVariantToggles_SingleItem.
@Test
void testAddThemeVariantToggles_SingleItem() {
ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.empty());
header.init();
MenuBar rightComponent = (MenuBar) ((HorizontalLayout) header.getContent().getComponentAt(1)).getComponentAt(0);
MenuItem helpMenuItem = rightComponent.getItems().get(0);
header.addThemeVariantToggles(helpMenuItem, LINKKI_CARD);
assertThat(helpMenuItem.getSubMenu().getItems()).anyMatch(mi -> mi.getText().equals("Card Theme"));
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationMenuItemDefinitionTest method testCreateItem_SubMenu_SubMenu.
@Test
void testCreateItem_SubMenu_SubMenu() {
ApplicationMenuItemDefinition itemDefinition = new ApplicationMenuItemDefinition("name", "id", Arrays.asList(new ApplicationMenuItemDefinition("sub", "sub-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).getSubMenu().getItems()).hasSize(1);
assertThat(subMenu.getItems().get(0).getSubMenu().getItems().get(0).getText()).isEqualTo("sub");
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ProductsSampleDetailsComponent method createMenuBar.
private static MenuBar createMenuBar(String caption, String... submenus) {
MenuBar menuBar = new MenuBar();
MenuItem item = menuBar.addItem(caption);
for (String subMenuCaption : submenus) {
item.getSubMenu().addItem(subMenuCaption);
}
return menuBar;
}
use of com.vaadin.flow.component.menubar.MenuBar in project ArchCNL by Mari-Wie.
the class MainView method createHeader.
private HorizontalLayout createHeader() {
final HorizontalLayout headerBox = new HorizontalLayout();
final Label title = new Label("ArchCNL");
title.getStyle().set("color", "#76d0f1");
title.getStyle().set("font-size", "x-large");
title.getStyle().set("font-weight", "bold");
final MenuBar menuBar = new MenuBar();
final MenuItem project = menuBar.addItem("Project");
final MenuItem edit = menuBar.addItem("Edit");
final MenuItem rules = menuBar.addItem("Rules");
menuBar.addItem("View", e -> fireEvent(new ViewOptionRequestedEvent(this, true)));
menuBar.addItem("Help", e -> fireEvent(new HelpOptionRequestedEvent(this, true)));
final SubMenu projectSubMenu = project.getSubMenu();
projectSubMenu.addItem("New Project", e -> fireEvent(new ProjectOptionRequestedEvent(this, true, ProjectOption.NEW)));
openProjectMenuItem = projectSubMenu.addItem("Open Project", e -> fireEvent(new ProjectOptionRequestedEvent(this, true, ProjectOption.OPEN)));
saveProjectMenuItem = projectSubMenu.addItem("Save", e -> fireEvent(new ProjectOptionRequestedEvent(this, true, ProjectOption.SAVE)));
saveProjectMenuItem.setEnabled(false);
projectSubMenu.addItem("Save As", e -> fireEvent(new ProjectOptionRequestedEvent(this, true, ProjectOption.SAVE_AS)));
final SubMenu editSubMenu = edit.getSubMenu();
editSubMenu.addItem("Undo", e -> fireEvent(new EditOptionRequestedEvent(this, true, EditOption.UNDO)));
editSubMenu.addItem("Redo", e -> fireEvent(new EditOptionRequestedEvent(this, true, EditOption.REDO)));
final SubMenu rulesSubMenu = rules.getSubMenu();
rulesSubMenu.addItem("Import from File", e -> fireEvent(new RulesOptionRequestedEvent(this, true, RulesOption.IMPORT_FROM_FILE)));
rulesSubMenu.addItem("Import Rule Presets", e -> fireEvent(new RulesOptionRequestedEvent(this, true, RulesOption.IMPORT_RULE_PRESETS)));
headerBox.add(title, menuBar);
headerBox.setDefaultVerticalComponentAlignment(Alignment.CENTER);
headerBox.setWidthFull();
return headerBox;
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationHeader method createRightMenuBar.
/**
* Creates a right aligned {@link MenuBar} that is added to the {@link ApplicationHeader} by
* {@link #addRightComponents(HorizontalLayout)}.
*
* @implSpec The created {@link MenuBar} contains a {@link #addHelpMenu(MenuBar) help menu item} by
* default.
*/
protected MenuBar createRightMenuBar() {
MenuBar rightMenuBar = new MenuBar();
rightMenuBar.setId(APPMENU_RIGHT_ID);
rightMenuBar.addThemeVariants(MenuBarVariant.LUMO_ICON);
rightMenuBar.addClassNames(LinkkiApplicationTheme.APPLICATION_MENU);
addHelpMenu(rightMenuBar);
return rightMenuBar;
}
Aggregations