use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.
the class DefaultWorkbenchFeaturesMenusHelper method buildMenusFromNavTree.
public TopLevelMenusBuilder<MenuBuilder> buildMenusFromNavTree(NavTree navTree) {
if (navTree == null) {
return null;
}
MenuBuilder<TopLevelMenusBuilder<MenuBuilder>> builder = null;
for (NavItem navItem : navTree.getRootItems()) {
// Skip dividers
if (navItem instanceof NavDivider) {
continue;
}
// AF-953: Ignore empty groups
if (navItem instanceof NavGroup && ((NavGroup) navItem).getChildren().isEmpty()) {
continue;
}
// Build a top level menu entry
if (builder == null) {
builder = MenuFactory.newTopLevelMenu(navItem.getName());
} else {
builder = builder.endMenu().newTopLevelMenu(navItem.getName());
}
// Append its children
if (navItem instanceof NavGroup) {
List<MenuItem> childItems = buildMenuItemsFromNavGroup((NavGroup) navItem);
builder.withItems(childItems);
}
// Append the place request
NavWorkbenchCtx navCtx = NavWorkbenchCtx.get(navItem);
if (navCtx.getResourceId() != null && ActivityResourceType.PERSPECTIVE.equals(navCtx.getResourceType())) {
PlaceRequest placeRequest = resolvePlaceRequest(navCtx.getResourceId());
builder = builder.place(placeRequest);
}
}
return builder != null ? builder.endMenu() : null;
}
use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.
the class RegisteredDocumentsMenuBuilderTest method testDisable.
@Test
public void testDisable() {
final MenuItem mi = builder.build();
mi.setEnabled(false);
verify(view, times(1)).setEnabled(eq(false));
}
use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.
the class KieEditorTest method testAddDownloadMenuItem.
@Test
public void testAddDownloadMenuItem() {
final MenuItem menuItem = mock(MenuItem.class);
doReturn(menuItem).when(presenter).downloadMenuItem();
presenter.addDownloadMenuItem(fileMenuBuilder);
verify(fileMenuBuilder).addNewTopLevelMenu(menuItem);
}
use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.
the class KieEditorTest method testAddSave.
@Test
public void testAddSave() {
final MenuItem menuItem = mock(MenuItem.class);
when(versionRecordManager.newSaveMenuItem(any(ParameterizedCommand.class))).thenReturn(menuItem);
presenter.addSave(fileMenuBuilder);
verify(fileMenuBuilder).addSave(menuItem);
}
use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.
the class DefaultWorkbenchFeaturesMenusHelperTest method buildMenusFromNavTreeTest.
@Test
public void buildMenusFromNavTreeTest() {
NavTree navTree = new NavTreeBuilder().group("g1", "g1", "g1", true).item("i1", "i1", "i1", true).endGroup().group("g2", "g2", "g2", true).item("i2", "i2", "i2", true).endGroup().group("g3", "g3", "g3", true).endGroup().build();
Menus menus = menusHelper.buildMenusFromNavTree(navTree).build();
List<MenuItem> menuItems = menus.getItems();
assertEquals(menuItems.size(), 2);
MenuGroup group1 = (MenuGroup) menuItems.get(0);
assertEquals(group1.getCaption(), "g1");
assertEquals(group1.getItems().size(), 1);
MenuItem item1 = group1.getItems().get(0);
assertEquals(item1.getCaption(), "i1");
MenuGroup group2 = (MenuGroup) menuItems.get(1);
assertEquals(group2.getCaption(), "g2");
assertEquals(group2.getItems().size(), 1);
MenuItem item2 = group2.getItems().get(0);
assertEquals(item2.getCaption(), "i2");
}
Aggregations