Search in sources :

Example 1 with MenuItemCommand

use of org.uberfire.workbench.model.menu.MenuItemCommand in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorMenusTest method checkMenuStructure.

@Test
public void checkMenuStructure() {
    presenter.getMenus(menus -> {
        final AtomicInteger i = new AtomicInteger(0);
        final MenuVisitor visitor = new MenuVisitor() {

            @Override
            public boolean visitEnter(final Menus menus) {
                return true;
            }

            @Override
            public void visitLeave(final Menus menus) {
            }

            @Override
            public boolean visitEnter(final MenuGroup menuGroup) {
                assertEquals(menuItemIdentifiers[i.getAndIncrement()], menuGroup.getIdentifier());
                return true;
            }

            @Override
            public void visitLeave(final MenuGroup menuGroup) {
            }

            @Override
            public void visit(final MenuItemPlain menuItemPlain) {
                assertEquals(menuItemIdentifiers[i.getAndIncrement()], menuItemPlain.getIdentifier());
            }

            @Override
            public void visit(final MenuItemCommand menuItemCommand) {
                assertEquals(menuItemIdentifiers[i.getAndIncrement()], menuItemCommand.getIdentifier());
            }

            @Override
            public void visit(final MenuItemPerspective menuItemPerspective) {
                assertEquals(menuItemIdentifiers[i.getAndIncrement()], menuItemPerspective.getIdentifier());
            }

            @Override
            public void visit(final MenuCustom<?> menuCustom) {
                assertEquals(menuItemIdentifiers[i.getAndIncrement()], menuCustom.getIdentifier());
            }
        };
        menus.accept(visitor);
    });
}
Also used : MenuVisitor(org.uberfire.workbench.model.menu.MenuVisitor) MenuItemCommand(org.uberfire.workbench.model.menu.MenuItemCommand) MenuItemPerspective(org.uberfire.workbench.model.menu.MenuItemPerspective) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Menus(org.uberfire.workbench.model.menu.Menus) MenuItemPlain(org.uberfire.workbench.model.menu.MenuItemPlain) MenuCustom(org.uberfire.workbench.model.menu.MenuCustom) MenuGroup(org.uberfire.workbench.model.menu.MenuGroup) Test(org.junit.Test)

Example 2 with MenuItemCommand

use of org.uberfire.workbench.model.menu.MenuItemCommand in project kie-wb-common by kiegroup.

the class NewResourcesMenuTest method testMenuItemCommand.

@Test
public void testMenuItemCommand() {
    final List<MenuItem> menus = menu.getMenuItems();
    assertNotNull(menus);
    assertEquals(1, menus.size());
    final MenuItem mi = menus.get(0);
    assertTrue(mi.isEnabled());
    assertTrue(mi instanceof MenuItemCommand);
    final MenuItemCommand miu = (MenuItemCommand) mi;
    assertNotNull(miu.getCommand());
    miu.getCommand().execute();
    verify(command, times(1)).execute();
}
Also used : MenuItemCommand(org.uberfire.workbench.model.menu.MenuItemCommand) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MenuItemCommand (org.uberfire.workbench.model.menu.MenuItemCommand)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MenuCustom (org.uberfire.workbench.model.menu.MenuCustom)1 MenuGroup (org.uberfire.workbench.model.menu.MenuGroup)1 MenuItem (org.uberfire.workbench.model.menu.MenuItem)1 MenuItemPerspective (org.uberfire.workbench.model.menu.MenuItemPerspective)1 MenuItemPlain (org.uberfire.workbench.model.menu.MenuItemPlain)1 MenuVisitor (org.uberfire.workbench.model.menu.MenuVisitor)1 Menus (org.uberfire.workbench.model.menu.Menus)1