use of org.uberfire.workbench.model.menu.MenuFactory.TopLevelMenusBuilder 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;
}
Aggregations