Search in sources :

Example 6 with MenuBar

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());
}
Also used : MenuBar(com.vaadin.ui.MenuBar) Test(org.junit.Test)

Example 7 with MenuBar

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());
}
Also used : MenuBar(com.vaadin.ui.MenuBar) Test(org.junit.Test)

Example 8 with MenuBar

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);
}
Also used : ChangePasswordPopupWindow(org.activiti.explorer.ui.profile.ChangePasswordPopupWindow) Command(com.vaadin.ui.MenuBar.Command) MenuBar(com.vaadin.ui.MenuBar) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoggedInUser(org.activiti.explorer.identity.LoggedInUser)

Example 9 with MenuBar

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;
}
Also used : MenuBar(com.vaadin.ui.MenuBar)

Example 10 with 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);
}
Also used : DefaultOperationContext(org.opennms.features.topology.app.internal.DefaultOperationContext) OperationContext(org.opennms.features.topology.api.OperationContext) DefaultOperationContext(org.opennms.features.topology.app.internal.DefaultOperationContext) MenuBar(com.vaadin.ui.MenuBar)

Aggregations

MenuBar (com.vaadin.ui.MenuBar)15 Test (org.junit.Test)10 MenuItem (com.vaadin.ui.MenuBar.MenuItem)2 Command (com.vaadin.ui.MenuBar.Command)1 LoggedInUser (org.activiti.explorer.identity.LoggedInUser)1 ChangePasswordPopupWindow (org.activiti.explorer.ui.profile.ChangePasswordPopupWindow)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 DefaultOperationContext (org.opennms.features.topology.app.internal.DefaultOperationContext)1 TestOperationContext (org.opennms.features.topology.app.internal.TestOperationContext)1 ContextMenuState (org.vaadin.peter.contextmenu.client.ContextMenuState)1