WorkbenchMegaMenuPresenter extends WorkbenchBaseMenuPresenter { public void addContextMenuItem(final String menuItemId, final String id, final String label, final String parentId, final Command command, final MenuPosition position) { final ChildContextMenuItemPresenter childContextMenuItemPresenter = childContextMenuItemPresenters.get(); childContextMenuItemPresenter.setup(label, command); selectableMenuItemByIdentifier.put(id, childContextMenuItemPresenter); canBeDisabledMenuItemByIdentifier.put(id, childContextMenuItemPresenter); if (parentId == null || parentId.isEmpty()) { if (MenuPosition.RIGHT.equals(position)) { childContextMenuItemPresenter.pullRight(); } view.addContextMenuItem(childContextMenuItemPresenter); } else { view.addContextMenuItemOnParent(childContextMenuItemPresenter, hasChildrenMenuItemByIdentifier.get(parentId)); } view.setContextMenuActive(true); } WorkbenchMegaMenuPresenter(final AuthorizationManager authzManager,
                                      final PerspectiveManager perspectiveManager,
                                      final ActivityManager activityManager,
                                      final User identity,
                                      final View view,
                                      final ManagedInstance<MegaMenuBrand> megaMenuBrands,
                                      final PlaceManager placeManager,
                                      final AuthorizationManager authorizationManager,
                                      final SessionInfo sessionInfo,
                                      final ManagedInstance<ChildMenuItemPresenter> childMenuItemPresenters,
                                      final ManagedInstance<GroupMenuItemPresenter> groupMenuItemPresenters,
                                      final ManagedInstance<ChildContextMenuItemPresenter> childContextMenuItemPresenters,
                                      final ManagedInstance<GroupContextMenuItemPresenter> groupContextMenuItemPresenters,
                                      final Workbench workbench,
                                      final ExperimentalActivitiesAuthorizationManager experimentalActivitiesAuthorizationManager); IsElement getView(); void clear(); void addMenuItem(final String id,
                            final String label,
                            final String parentId,
                            final Command command,
                            final MenuPosition position); void addCustomMenuItem(final IsElement menu,
                                  final MenuPosition position); void addCustomMenuItem(IsWidget menu,
                                  MenuPosition position); void addGroupMenuItem(final String id,
                                 final String label,
                                 final MenuPosition position); void selectMenuItem(final String id); void addContextMenuItem(final String menuItemId,
                                   final String id,
                                   final String label,
                                   final String parentId,
                                   final Command command,
                                   final MenuPosition position); void addContextGroupMenuItem(final String menuItemId,
                                        final String id,
                                        final String label,
                                        final MenuPosition position); void clearContextMenu(); void enableMenuItem(final String menuItemId,
                               final boolean enabled); void enableContextMenuItem(final String menuItemId,
                                      final boolean enabled); void onPerspectiveChange(final PerspectiveChange perspectiveChange); void setupSetVisibleMenuItem(MenuItemPerspective menuItemPerspective);  }
@Test public void addContextMenuItemTest() { final ChildContextMenuItemPresenter childContextMenuItemPresenter = mock(ChildContextMenuItemPresenter.class); doReturn(mock(ChildContextMenuItemPresenter.View.class)).when(childContextMenuItemPresenter).getView(); doReturn(childContextMenuItemPresenter).when(childContextMenuItemPresenters).get(); final HasChildren parent = mock(HasChildren.class); presenter.hasChildrenMenuItemByIdentifier.put("parentId", parent); presenter.addContextMenuItem("menuItemId", "id", "label", "parentId", mock(Command.class), MenuPosition.LEFT); verify(childContextMenuItemPresenter).setup(eq("label"), any()); verify(presenter.selectableMenuItemByIdentifier).put("id", childContextMenuItemPresenter); verify(presenter.canBeDisabledMenuItemByIdentifier).put("id", childContextMenuItemPresenter); verify(view).addContextMenuItemOnParent(childContextMenuItemPresenter, parent); verify(view).setContextMenuActive(true); }