use of com.vaadin.ui.MenuBar in project opennms by OpenNMS.
the class OperationManagerTest method layoutEditMenuGroupingNoGroupTest.
@Test
public void layoutEditMenuGroupingNoGroupTest() {
OperationManager cmdManager = new OperationManager();
cmdManager.addOrUpdateGroupOrder("Edit", Lists.newArrayList("new", "middle", "additions"));
cmdManager.onBind(createTestOperation(), createProperties("Edit", "Circle Layout?group=layout", ""));
cmdManager.onBind(createTestOperation(), createProperties("Edit", "FR Layout?group=layout", ""));
cmdManager.onBind(createTestOperation(), createProperties("Edit", "ISOM Layout?group=layout", ""));
cmdManager.onBind(createTestOperation(), createProperties("Edit", "KK Layout?group=layout", ""));
cmdManager.onBind(createTestOperation(), createProperties("Edit", "Redo Layout", ""));
cmdManager.onBind(createTestOperation(), createProperties("Edit", "Spring Layout?group=layout", ""));
MenuBar menuBar = getMenuBar(cmdManager);
List<MenuBar.MenuItem> menuItems = menuBar.getItems();
assertEquals(1, menuItems.size());
List<MenuBar.MenuItem> subMenuItems = menuItems.get(0).getChildren();
assertEquals(6, subMenuItems.size());
assertEquals("Circle Layout", subMenuItems.get(0).getText());
assertEquals("FR Layout", subMenuItems.get(1).getText());
assertEquals("ISOM Layout", subMenuItems.get(2).getText());
assertEquals("KK Layout", subMenuItems.get(3).getText());
assertEquals("Redo Layout", subMenuItems.get(4).getText());
assertEquals("Spring Layout", subMenuItems.get(5).getText());
}
use of com.vaadin.ui.MenuBar in project opennms by OpenNMS.
the class OperationManagerTest method submenuGroupOrderAlphabeticallyTest.
@Test
public void submenuGroupOrderAlphabeticallyTest() {
OperationManager cmdManager = new OperationManager();
cmdManager.addOrUpdateGroupOrder("File", Lists.newArrayList("new", "help", "additions"));
cmdManager.onBind(createTestOperation(), createProperties("File", "Operation1", ""));
cmdManager.onBind(createTestOperation(), createProperties("File", "Operation3", ""));
cmdManager.onBind(createTestOperation(), createProperties("File", "Operation4", ""));
cmdManager.onBind(createTestOperation(), createProperties("File", "Operation2", ""));
cmdManager.onBind(createTestOperation(), createProperties("File|New", "NewOperation", ""));
MenuBar menuBar = getMenuBar(cmdManager);
List<MenuBar.MenuItem> menuItems = menuBar.getItems();
assertEquals(1, menuItems.size());
List<MenuBar.MenuItem> subMenuItems = menuItems.get(0).getChildren();
assertEquals(5, subMenuItems.size());
assertEquals("New", subMenuItems.get(0).getText());
assertEquals("Operation1", subMenuItems.get(1).getText());
assertEquals("Operation2", subMenuItems.get(2).getText());
assertEquals("Operation3", subMenuItems.get(3).getText());
assertEquals("Operation4", subMenuItems.get(4).getText());
}
use of com.vaadin.ui.MenuBar in project Activiti by Activiti.
the class MainMenuBar method initProfileButton.
protected void initProfileButton() {
final LoggedInUser user = ExplorerApp.get().getLoggedInUser();
// User name + link to profile
MenuBar profileMenu = new MenuBar();
profileMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);
MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);
if (useProfile()) {
// Show profile
rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() {
public void menuSelected(MenuItem selectedItem) {
ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
}
});
// Edit profile
rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_EDIT), new Command() {
public void menuSelected(MenuItem selectedItem) {
// TODO: Show in edit-mode
ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
}
});
// Change password
rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() {
public void menuSelected(MenuItem selectedItem) {
ExplorerApp.get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow());
}
});
rootItem.addSeparator();
}
// Logout
rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() {
public void menuSelected(MenuItem selectedItem) {
ExplorerApp.get().close();
}
});
addComponent(profileMenu);
setComponentAlignment(profileMenu, Alignment.TOP_RIGHT);
setExpandRatio(profileMenu, 1.0f);
}
use of com.vaadin.ui.MenuBar in project opennms by OpenNMS.
the class MenuBuilder method build.
/**
* Converts the current menu configuration to Vaadin's {@link MenuBar} representation.
*
* @param targets The current targets (e.g. the selection)
* @param operationContext The current {@link OperationContext}.
* @param hooks Optional hooks to be executed after a menu item's command has been executed.
* @return The converted {@link MenuBar}
*/
public MenuBar build(List<VertexRef> targets, OperationContext operationContext, Runnable... hooks) {
MenuBar menuBar = new MenuBar();
apply(menuBar, targets, operationContext, hooks);
return menuBar;
}
use of com.vaadin.ui.MenuBar in project opennms by OpenNMS.
the class TopologyContextMenu method updateMenu.
public void updateMenu(GraphContainer graphContainer, UI mainWindow, OperationManager operationManager, List<VertexRef> targets) {
final OperationContext operationContext = new DefaultOperationContext(mainWindow, graphContainer, OperationContext.DisplayLocation.CONTEXTMENU);
// Clear Menu
removeAllItems();
// Rebuild menu
MenuBuilder menuBuilder = new MenuBuilder();
for (OperationServiceWrapper operationServiceWrapper : operationManager.getOperationWrappers()) {
if (operationServiceWrapper.getContextMenuPosition() != null) {
MenuItem item = new OperationMenuItem(operationServiceWrapper);
menuBuilder.addMenuItem(item, operationServiceWrapper.getContextMenuPosition().isEmpty() ? null : operationServiceWrapper.getContextMenuPosition().split("\\|"));
}
}
addNavigateToItems(menuBuilder, targets, operationContext);
MenuBar menu = menuBuilder.build(targets, operationContext, this::notifyMenuUpdateListener);
addItems(menu);
}
Aggregations