Java 类com.vaadin.ui.MenuBar.MenuItem 实例源码

项目:hawkbit    文件:DashboardMenu.java   
private Component buildUserMenu(final UiProperties uiProperties) {
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    settings.setHtmlContentAllowed(true);

    final MenuItem settingsItem = settings.addItem("", getImage(uiProperties.isGravatar()), null);

    final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
    if (!StringUtils.isEmpty(formattedTenant)) {
        settingsItem.setText(formattedTenant);
        UserDetailsFormatter.getCurrentTenant().ifPresent(tenant -> settingsItem.setDescription(i18n
                .getMessage("menu.user.description", tenant, UserDetailsFormatter.getCurrentUser().getUsername())));
    } else {
        settingsItem.setText("...");
    }

    settingsItem.setStyleName("user-menuitem");

    final String logoutUrl = generateLogoutUrl();

    settingsItem.addItem("Sign Out", selectedItem -> Page.getCurrent().setLocation(logoutUrl));
    return settings;
}
项目:VaadHL    文件:Action.java   
/**
 * Detach the action run listener from the object.
 * 
 * @param o
 */
protected void detachLsnr(Object o) {
    if (o == null)
        return;
    ObjInfo objInfo = attached.get(o);
    if (objInfo == null)
        return;

    if (o instanceof Button) {
        Button.ClickListener al = (ClickListener) objInfo.listener;
        if (al != null)
            ((Button) o).removeClickListener(al);
    } else if (o instanceof MenuItem) {
        ((MenuItem) o).setCommand(null);
    } else if (o instanceof ContextMenuItem) {
        ((ContextMenuItem) o)
                .removeItemClickListener((ContextMenuItemClickListener) objInfo.listener);
    }
}
项目:VaadHL    文件:Action.java   
/**
 * Sets visibility of the object attached to.
 * 
 * @param o
 * @param visible
 */
protected void setVisible(Object o, boolean visible) {
    if (attached == null)
        return;
    if (o instanceof AbstractComponent) {
        ((AbstractComponent) o).setVisible(visible);
    } else if (o instanceof MenuItem) {
        ((MenuItem) o).setVisible(visible);
    } else if (o instanceof ContextMenuItem) {
        ((ContextMenuItem) o).setEnabled(enabled); // not possible to hide
    } else {
        throw new WrongObjectTypeException(
                "VHL-014: Cannot control visibility state of the object type:"
                        + o.getClass().getName());
    }
}
项目:cia    文件:AbstractMenuItemFactoryImpl.java   
/**
 * Inits the application menu bar.
 *
 * @param menuBar
 *            the menu bar
 */
protected final void initApplicationMenuBar(final MenuBar menuBar) {
    menuBar.removeItems();
    menuBar.setWidth(MENU_BAR_WIDTH);
    menuBar.setStyleName(HEADER_STYLE_NAME);
    final MenuItem mainViewItem = menuBar.addItem(APPLICATION, VaadinIcons.SERVER, null);

    mainViewItem.addItem(START_TEXT, VaadinIcons.STAR, COMMAND_MAINVIEW_OVERVIEW);

    final MenuItem mainItem = mainViewItem.addItem(MAIN, VaadinIcons.STAR, null);

    mainItem.addItem(PAGE_VISIT_HISTORY_TEXT, VaadinIcons.LINE_CHART, COMMAND_MAINVIEW_PAGEVISITHISTORY);


    if (UserContextUtil.allowRoleInSecurityContext(ROLE_ADMIN) || UserContextUtil.allowRoleInSecurityContext(ROLE_USER)) {
        mainViewItem.addItem(USERHOME, VaadinIcons.USER,COMMAND_USERHOME);
        createAdminMenu(mainViewItem);
        mainViewItem.addItem(LOGOUT, VaadinIcons.SIGN_OUT, COMMAND_LOGOUT);
    } else {
        mainViewItem.addItem(LOGIN, VaadinIcons.SIGN_IN, COMMAND_LOGIN);
        mainViewItem.addItem(REGISTER, VaadinIcons.FILE_ADD, COMMAND_REGISTER);
    }

}
项目:cia    文件:CountryMenuItemFactoryImpl.java   
/**
 * Adds the sources and indicators to menu.
 *
 * @param countryIndicators
 *            the country indicators
 * @param sourceIndicatorMap
 *            the source indicator map
 */
private static void addSourcesAndIndicatorsToMenu(final MenuItem countryIndicators,
        final Map<String, List<ViewWorldbankIndicatorDataCountrySummary>> sourceIndicatorMap) {

    final Map<String, List<ViewWorldbankIndicatorDataCountrySummary>> sortedIndicatorMap = sourceIndicatorMap
            .entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey()))
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));

    for (final Entry<String, List<ViewWorldbankIndicatorDataCountrySummary>> entry : sortedIndicatorMap
            .entrySet()) {

        final MenuItem sourceItems = countryIndicators.addItem(entry.getKey(), null, null);

        final List<ViewWorldbankIndicatorDataCountrySummary> sortedEntries = entry.getValue().stream()
                .sorted((e1, e2) -> e1.getIndicatorName().compareTo(e2.getIndicatorName()))
                .collect(Collectors.toList());

        for (final ViewWorldbankIndicatorDataCountrySummary indciatorSummary : sortedEntries) {
            sourceItems.addItem(indciatorSummary.getIndicatorName(),
                    new PageModeMenuCommand(UserViews.COUNTRY_RANKING_VIEW_NAME, PageMode.INDICATORS,
                            indciatorSummary.getEmbeddedId().getIndicatorId()));
        }
    }

}
项目:jain-I18n    文件:ActionMenuBar.java   
/**
 * @param actionGroup
 * @param menuItemByGroupName
 * @return
 */
private MenuItem createMenuItem(JNActionGroup actionGroup, Map<String, MenuItem> menuItemByGroupName) {
    MenuItem menuItem = null;
    MenuItem parentItem = null;
    if (StringHelper.isNotEmptyWithTrim(actionGroup.parent())) {
        parentItem = menuItemByGroupName.get(actionGroup.parent());

        if (parentItem == null) {
            JNActionGroup parentActionGroup = actionGroupByName.get(actionGroup.parent());
            if (parentActionGroup != null) {
                parentItem = createMenuItem(parentActionGroup, menuItemByGroupName);
                menuItemByGroupName.put(parentActionGroup.name(), parentItem);
            }
        }
    }

    menuItem = parentItem == null ? menuBar.addItem(actionGroup.name(), null) : parentItem.addItem(actionGroup.name(), null);
    findNAddIcon(actionGroup.icon(), menuItem);

    if (StringHelper.isNotEmptyWithTrim(actionGroup.description()))
        menuItem.setDescription(actionGroup.description());

    if (StringHelper.isNotEmptyWithTrim(actionGroup.style()))
        menuItem.setStyleName(actionGroup.style());
    return menuItem;
}
项目:jain-I18n    文件:ActionMenuBar.java   
/**
 * @param parentItem
 * @param first
 * @param style
 * @param i
 * @param action
 * @return
 */
private MenuItem processAction(MenuItem parentItem, String first, String style, int i, JNAction action) {
    MenuItem lastItem;
    lastItem = parentItem == null ? menuBar.addItem(actionsToName.get(action), listener) : parentItem.addItem(actionsToName.get(action), listener);

    findNAddIcon(action.icon(), lastItem);
    lastItem.setVisible(validatePermission (action));

    if (StringHelper.isNotEmptyWithTrim(action.description()))
        lastItem.setDescription(action.description());
    else
        lastItem.setDescription(actionsToName.get(action));

    if (i == 0)
        lastItem.setStyleName(first);
    else 
        lastItem.setStyleName(style);

    if (action.separator() && parentItem != null) {
        parentItem.addSeparator();
    }
    return lastItem;
}
项目:sqlexplorer-vaadin    文件:SqlExplorer.java   
protected void addShowButton(MenuBar contentMenuBar) {
    boolean visible = showButton != null ? showButton.isVisible() : false;
    showButton = contentMenuBar.addItem("", new Command() {
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            setSplitPosition(savedSplitPosition, Unit.PIXELS);
            setLocked(false);
            showButton.setVisible(false);
        }
    });
    showButton.setIcon(FontAwesome.BARS);
    showButton.setDescription("Show the database explorer");
    showButton.setVisible(visible);
}
项目:openeos    文件:VaadinMenuContributor.java   
@Override
public void contribute(MenuBar menuBar, IUnoVaadinApplication application) {
    Collections.sort(menuList, new Comparator<MenuContributor>() {
        @Override
        public int compare(MenuContributor o1, MenuContributor o2) {
            return new Integer(o1.getOrder()).compareTo(o2.getOrder());
        }
    });

    for (MenuContributor contributor : menuList) {
        for (IMenuDefinition menu : contributor.getRootMenuDefinitionList()) {
            MenuItem menuItem = menuBar.addItem(menu.getName(), createAction(menu, application));
            addRecursiveMenus(contributor, contributor.getChildMenuDefinitionList(menu), menuItem, application);
        }
    }
}
项目:opennmszh    文件:CommandManager.java   
public MenuBar.Command menuCommand(final Command command,
        final GraphContainer graphContainer, final Window mainWindow,
        final OperationContext operationContext, final SelectionManager selectionManager) {

    return new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            List<VertexRef> targets = new ArrayList<VertexRef>(selectionManager.getSelectedVertexRefs());

            DefaultOperationContext context = (DefaultOperationContext) operationContext;
            context.setChecked(selectedItem.isChecked());

            command.doCommand(targets, operationContext);
            m_commandHistoryList.add(command);
            updateMenuItemListeners();
        }
    };
}
项目:opennmszh    文件:CommandManager.java   
public void updateMenuItem(MenuItem menuItem, GraphContainer graphContainer, Window mainWindow, SelectionManager selectionManager) {
    DefaultOperationContext operationContext = new DefaultOperationContext(mainWindow, graphContainer, DisplayLocation.MENUBAR);
    Operation operation = getOperationByMenuItemCommand(menuItem.getCommand());

    //Check for null because separators have no Operation
    if(operation != null) {
        List<VertexRef> selectedVertices = new ArrayList<VertexRef>(selectionManager.getSelectedVertexRefs());
        boolean visibility = operation.display(selectedVertices, operationContext);
        menuItem.setVisible(visibility);
        boolean enabled = operation.enabled(selectedVertices, operationContext);
        menuItem.setEnabled(enabled);

        if (operation instanceof CheckedOperation) {
            if (!menuItem.isCheckable()) {
                menuItem.setCheckable(true);
            }

            menuItem.setChecked(((CheckedOperation) operation).isChecked(selectedVertices, operationContext));
        }
    }
}
项目:opennmszh    文件:MenuBarBuilder.java   
@SuppressWarnings("unchecked")
public MenuBar get() {
       MenuBar menuBar = new MenuBar();

       Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems();
       for(Entry<String, Object> entry : sortedEntrySet) {
           if(entry.getValue() instanceof Map) {
               MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null);
               addMenuItems(menuItem, (Map<String, Object>) entry.getValue());
           }else {
               menuBar.addItem(entry.getKey(), (Command) entry.getValue());
           }

       }
       return menuBar;
   }
项目:opennmszh    文件:MenuBarBuilder.java   
@SuppressWarnings("unchecked")
protected void addMenuItems(MenuItem subMenu, Map<String, Object> value) {

    Set<Entry<String, Object>> sortedEntrySet = getSortedSubmenuGroup(subMenu.getText(), value);
    for(Entry<String, Object> entry : sortedEntrySet) {
        String commandKey = entry.getKey();
        if(entry.getValue() instanceof Map) {
            MenuBar.MenuItem subMenuItem = subMenu.addItem(commandKey, null);
            addMenuItems(subMenuItem, (Map<String, Object>) entry.getValue());
        }else {
            if(commandKey.startsWith("separator")) {
                subMenu.addSeparator();
            }else {
                subMenu.addItem(removeLabelProperties(commandKey), (Command) entry.getValue());
            }
        }

    }
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void createMenuTest() {
    MenuBarBuilder builder = new MenuBarBuilder();
    builder.setTopLevelMenuOrder(Arrays.asList("File", "Edit", "View"));
    builder.addMenuCommand(null, "File");
    builder.addMenuCommand(null, "View");
    builder.addMenuCommand(null, "Edit");
    builder.addMenuCommand(createEmpyCommand(), "File|Test");


    MenuBar menuBar = builder.get();
    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(3, menuItems.size());
    assertEquals("File", menuItems.get(0).getText());
    assertEquals("Edit", menuItems.get(1).getText());
    assertEquals("View", menuItems.get(2).getText());
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void createTopLevelMenuWithAdditionsTest() {
    MenuBarBuilder builder = new MenuBarBuilder();
    builder.setTopLevelMenuOrder(Arrays.asList("File", "Edit", "View", "Additions", "Help"));
    builder.addMenuCommand(null, "Edit");
    builder.addMenuCommand(null, "Test2");
    builder.addMenuCommand(null, "File");
    builder.addMenuCommand(null, "Test1");
    builder.addMenuCommand(null, "Help");
    builder.addMenuCommand(null, "View");

    MenuBar menuBar = builder.get();
    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(6, menuItems.size());
    assertEquals("File", menuItems.get(0).getText());
    assertEquals("Edit", menuItems.get(1).getText());
    assertEquals("View", menuItems.get(2).getText());
    assertEquals("Test1", menuItems.get(3).getText());
    assertEquals("Test2", menuItems.get(4).getText());
    assertEquals("Help", menuItems.get(5).getText());
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void menuItemNoOrderTest() {
    MenuBarBuilder builder = new MenuBarBuilder();
    builder.addMenuCommand(null, "Edit");
    builder.addMenuCommand(null, "Test2");
    builder.addMenuCommand(null, "File");
    builder.addMenuCommand(null, "Test1");
    builder.addMenuCommand(null, "Help");
    builder.addMenuCommand(null, "View");

    MenuBar menuBar = builder.get();
    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(6, menuItems.size());
    assertEquals("Edit", menuItems.get(0).getText());
    assertEquals("File", menuItems.get(1).getText());
    assertEquals("Help", menuItems.get(2).getText());
    assertEquals("Test1", menuItems.get(3).getText());
    assertEquals("Test2", menuItems.get(4).getText());
    assertEquals("View", menuItems.get(5).getText());
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void menuOrderNoAdditionalTest() {
    MenuBarBuilder builder = new MenuBarBuilder();
    builder.setTopLevelMenuOrder(Arrays.asList("File", "Edit", "View", "Help"));
    builder.addMenuCommand(null, "Edit");
    builder.addMenuCommand(null, "Test2");
    builder.addMenuCommand(null, "File");
    builder.addMenuCommand(null, "Test1");
    builder.addMenuCommand(null, "Help");
    builder.addMenuCommand(null, "View");

    MenuBar menuBar = builder.get();
    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(6, menuItems.size());
    assertEquals("File", menuItems.get(0).getText());
    assertEquals("Edit", menuItems.get(1).getText());
    assertEquals("View", menuItems.get(2).getText());
    assertEquals("Help", menuItems.get(3).getText());
    assertEquals("Test1", menuItems.get(4).getText());
    assertEquals("Test2", menuItems.get(5).getText());
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void submenuAlphabeticalOrderTest() {
    CommandManager cmdManager = new CommandManager();
    cmdManager.addOrUpdateGroupOrder("File", Arrays.asList("new", "additions"));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation1?group=new", ""));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation3", ""));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation4", ""));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation2", ""));

    cmdManager.onBind(getTestOperation(), getProps("File|New", "NewOperation", ""));

    MenuBar menuBar = cmdManager.getMenuBar(null, null, null);

    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(1, menuItems.size());

    List<MenuItem> subMenuItems = menuItems.get(0).getChildren();
    assertEquals(6, subMenuItems.size());
    assertEquals("New", subMenuItems.get(0).getText());
    assertEquals("Operation1", subMenuItems.get(1).getText());
    assertEquals("", subMenuItems.get(2).getText());
    assertEquals("Operation2", subMenuItems.get(3).getText());
    assertEquals("Operation3", subMenuItems.get(4).getText());
    assertEquals("Operation4", subMenuItems.get(5).getText());

}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void groupingSeparatorTest() {
    CommandManager cmdManager = new CommandManager();
    cmdManager.addOrUpdateGroupOrder("Default", Arrays.asList("new", "help", "additions"));

    cmdManager.onBind(getTestOperation(), getProps("Device", "Operation1?group=additions", ""));
    cmdManager.onBind(getTestOperation(), getProps("Device", "Operation3?group=additions", ""));
    cmdManager.onBind(getTestOperation(), getProps("Device", "Operation4?group=additions", ""));
    cmdManager.onBind(getTestOperation(), getProps("Device", "Operation2?group=additions", ""));
    cmdManager.onBind(getTestOperation(), getProps(null, "Get Info?group=new", ""));
    cmdManager.onBind(getTestOperation(), getProps("Device", "NewOperation?group=additions", ""));


    MenuBar menuBar = cmdManager.getMenuBar(null, null, null);

    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(1, menuItems.size());

    List<MenuItem> subMenuItems = menuItems.get(0).getChildren();
    assertEquals(5, subMenuItems.size());
    assertEquals("NewOperation", 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());
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
public void submenuGroupOrderAlphabeticallyTest() {
    CommandManager cmdManager = new CommandManager();
    cmdManager.addOrUpdateGroupOrder("File", Arrays.asList("new", "help", "additions"));

    cmdManager.onBind(getTestOperation(), getProps("File", "Operation1", ""));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation3", ""));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation4", ""));
    cmdManager.onBind(getTestOperation(), getProps("File", "Operation2", ""));

    cmdManager.onBind(getTestOperation(), getProps("File|New", "NewOperation", ""));

    MenuBar menuBar = cmdManager.getMenuBar(null, null, null);

    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(1, menuItems.size());

    List<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());
}
项目:opennmszh    文件:TestMenuBarBuilder.java   
@Test
@Ignore
public void submenuCheckedMenuItemTest() {
    CommandManager cmdManager = new CommandManager();
    cmdManager.addOrUpdateGroupOrder("File", Arrays.asList("new", "help", "additions"));

    cmdManager.onBind(getCheckedTestOperation(), getProps("File", "Operation1", ""));

    MenuBar menuBar = cmdManager.getMenuBar(null, null, null);

    List<MenuItem> menuItems = menuBar.getItems();
    assertEquals(1, menuItems.size());

    List<MenuItem> subMenuItems = menuItems.get(0).getChildren();
    assertEquals(1, subMenuItems.size());
    MenuItem menuItem = subMenuItems.get(0);
    assertEquals("Operation1", menuItem.getText());
    assertTrue(menuItem.isCheckable());
}
项目:enterprise-app    文件:MDIWindow.java   
protected void initWindowMenu(String addMenusBefore) {
    MenuItem addMenusBeforMenuItem = null;
    if(menuBar.getItems() != null) {
        for(MenuItem menuItem : menuBar.getItems()) {
            if(menuItem.getText().equals(addMenusBefore)) {
                addMenusBeforMenuItem = menuItem;
            }
        }
    }
    layoutMenu = menuBar.addItemBefore(Constants.uiTabs, null, null, addMenusBeforMenuItem);

    closeAllMenuItem = layoutMenu.addItem(Constants.uiCloseAll, null, this);
    windowsMenuItem = layoutMenu.addItem(Constants.uiWindows, null, this);
    tabsMenuItem = layoutMenu.addItem(Constants.uiTabs, null, this);
    tabsMenuItem.setVisible(false);
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
public void appendStructureMenu(MenuItem parent){
    MenuItem structureMenu=parent.addItem("Add structure", null);

    for(String superclass:CoreDictionary.getSuperclasses()){
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for(final CoreType t:CoreDictionary.getCores(superclass)){
            superClassMenu.addItem(t.getName(), new Command(){
                private static final long serialVersionUID=-148395291969656325L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    theCanvas.addSequenceByName(t.getName());
                }
            });
        }
    }

    createAddResidueMenu(parent);
    createInsertResidueMenu(parent);
    createChangeResidueMenu(parent);
    createTerminalMenu(parent);
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
public void createAddResidueMenu(MenuItem parent) {
    String notation=theCanvas.getWorkspace().getGlycanRenderer().getGraphicOptions().NOTATION;

    MenuItem structureMenu=parent.addItem("Add residue", null);

    for (String superclass : ResidueDictionary.getSuperclasses()) {
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for (ResidueType t : ResidueDictionary.getResidues(superclass)) {
            if (t.canHaveParent()){
                superClassMenu.addItem(t.getName(), new Command(){
                    private static final long serialVersionUID=4750928193466060500L;

                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        theCanvas.addResidueByNameToSelected(selectedItem.getText());
                    }       
                }).setIcon(new ThemeResource("icons"+File.separator+"residues"+File.separator+notation+File.separator+t.getName()+".png"));
            }       
        }

        if(superClassMenu.getChildren()==null){
            structureMenu.removeChild(superClassMenu);
        }
    }
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
private void createChangeResidueMenu(MenuItem parent) {
    MenuItem structureMenu=parent.addItem("Change residue", null);

    String notation=theCanvas.getWorkspace().getGlycanRenderer().getGraphicOptions().NOTATION;

    for (String superclass : ResidueDictionary.getSuperclasses()) {
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for (ResidueType t : ResidueDictionary.getResidues(superclass)){
            superClassMenu.addItem(t.getName(), new Command(){
                private static final long serialVersionUID=-7886271503255704127L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    theCanvas.changeSelectedToResidueByName(selectedItem.getText());
                }
            }).setIcon(new ThemeResource("icons"+File.separator+"residues"+File.separator+notation+File.separator+t.getName()+".png"));
        }
        if(superClassMenu.getChildren()==null){
            structureMenu.removeChild(superClassMenu);
        }
    }

    structureMenu.setEnabled(false);
    menuItemsWithResidueSelectionDependency.add(structureMenu);
}
项目:VaadinUtils    文件:MenuBuilder.java   
private void addMenuItems(MenuBar menubar, Set<MenuItem> unusedTopLevelMenus, final ViewMapping viewmap)
{
    for (Menu menu : getMenuAnnotations(viewmap.getView()))
    {
        String path = createMenuPathString(menu);

        final String[] pathElements = path.split("\\.");

        if (pathElements.length == 2)
        {
            menu.actionType().createLeafItem(new MenuWrapper(menubar), menu, menu.display(), viewmap, menu.atTop());
        }
        else
        {
            MenuItem parentMenuItem = getParentMenuItem(menubar, pathElements[1]);
            unusedTopLevelMenus.remove(parentMenuItem);
            recursiveAdd(parentMenuItem, menu, viewmap, menu.display(),
                    Arrays.copyOfRange(pathElements, 2, pathElements.length));
        }
    }
}
项目:VaadinUtils    文件:MenuBuilder.java   
/**
 * Searches for a menu item. If it doesn't exist it will be created.
 * 
 * @param parentItem
 * @param displayName
 * @param currentPath
 * @return
 */
private MenuItem getMenuItem(MenuItem parentItem, final String displayName) // ,
                                                                            // String
                                                                            // currentPath)
{
    MenuItem currentItem = findMenuItem(parentItem.getChildren(), displayName);

    if (currentItem == null)
    {
        currentItem = parentItem.addItem(displayName, null);
    }
    // if (currentItem != null)
    // {
    // currentItem = parentItem.addItem(menuName, new MenuBar.Command()
    // {
    // private static final long serialVersionUID = 1L;
    //
    // public void menuSelected(MenuItem selectedItem)
    // {
    // UI.getCurrent().getNavigator().navigateTo(menuName);
    // }
    // });
    //
    // }
    return currentItem;
}
项目:VaadinUtils    文件:MenuBuilder.java   
/**
 * Searches for a parement menu item. If it doesn't exist it will be
 * created.
 * 
 * @param parentItem
 * @param menuName
 * @param currentPath
 * @return
 */
private MenuItem getParentMenuItem(MenuBar parentItem, final String displayName) // ,
// String
// currentPath)
{
    MenuItem currentItem = findMenuItem(parentItem.getItems(), displayName);
    if (currentItem == null)
    {
        currentItem = parentItem.addItem(displayName, null);
        /*
         * , new MenuBar.Command() { private static final long
         * serialVersionUID = 1L;
         * 
         * public void menuSelected(MenuItem selectedItem) { if (!parent)
         * UI.getCurrent().getNavigator().navigateTo(viewName); } });
         */

    }
    return currentItem;
}
项目:VaadinUtils    文件:MenuBuilder.java   
private MenuItem findMenuItem(List<MenuItem> list, String currentPath)
{
    MenuItem currentItem = null;

    if (list != null)
    {
        for (MenuItem menuItem : list)
        {
            if (menuItem.getText().equals(currentPath))
            {
                currentItem = menuItem;
                break;
            }
        }
    }
    return currentItem;
}
项目:mideaas    文件:GitPlugin.java   
@Override
public void extendMenu(MenuBar menuBar, SharedProject project) {

    Command commit = createCommitCommand();
    Command github = createGitHubCommand();

    MenuItem gitItem = menuBar.addItem("Git", null);

    if (commit != null) {
        gitItem.addItem("Commit", commit);
    }

    if (github != null) {
        gitHubItem = gitItem.addItem("GitHub", github);
        gitHubItem.setIcon(new ClassResource("/org/vaadin/addon/oauthpopupbuttons/icons/github16.png"));
        gitHubItem.setEnabled(repo.hasCommit());
    }
}
项目:dungeonstory-java    文件:MainScreen.java   
/**
 * Registers a given view to the navigator and menu bar.
 */
private void addViewToMenuBar(Class<? extends View> viewClass, Resource icon, String caption, String uri) {
    ViewConfig viewConfig = viewClass.getAnnotation(ViewConfig.class);
    addView(viewClass);
    String itemCaption = caption != null ? ViewConfigUtil.getDisplayName(caption)
            : ViewConfigUtil.getDisplayName(viewConfig.displayName());
    String itemUri = uri != null ? uri : viewConfig.uri();
    MenuItem item = menuBar.addItem(itemCaption, icon, command -> navigator.navigateTo(itemUri));
    menuItems.put(viewConfig.uri(), item);
}
项目:hybridbpm    文件:MainMenu.java   
@Override
public void menuSelected(MenuItem selectedItem) {
    if (selectedItem.equals(signOutItem)) {
        HybridbpmUI.getCurrent().logout();
    } else if (selectedItem.equals(profileItem)) {
        UsersLayout.openUserEditor(HybridbpmUI.getUser(), new Window.CloseListener() {

            @Override
            public void windowClose(Window.CloseEvent e) {
                HybridbpmUI.getCurrent().reloadUser();
            }
        });
    }
}
项目:VaadHL    文件:BaseWindow.java   
protected void addStateMenu(MenuItem mit) {

        getAction(ActionsIds.AC_RESTORE_STATE).attach(
                mit.addItem(getI18S("mnStateRestore"), null));

        getAction(ActionsIds.AC_SAVE_STATE).attach(
                mit.addItem(getI18S("mnStateSave"), null));
    }
项目:VaadHL    文件:Action.java   
/**
 * Sets enabled state of the object attached to.
 * 
 * @param o
 * @param enabled
 */
protected void setEnabled(Object o, boolean enabled) {

    if (o instanceof AbstractComponent) {
        ((AbstractComponent) o).setEnabled(enabled);
    } else if (o instanceof MenuItem) {
        ((MenuItem) o).setEnabled(enabled);
    } else if (o instanceof ContextMenuItem) {
        ((ContextMenuItem) o).setEnabled(enabled);
    } else {
        throw new WrongObjectTypeException("VHL-013: "
                + appContext.getI18().getString("MVHL-013")
                + o.getClass().getName());
    }
}
项目:KrishnasSpace    文件:HomeView.java   
/**
 * Init Various View Buttons
 * 
 * @param viewNames
 */
private void initViewButtons(Set<String> viewNames) {

    MenuBar menubar = new MenuBar();
    menubar.setAutoOpen(false);
    MenuItem parent = menubar.addItem("Themes", null);
    addVariousThemes(parent);
    addComponent(menubar);

    for (String viewName : viewNames) {
        Button button = getViewButton(viewName);
        addComponent(button);
    }

}
项目:KrishnasSpace    文件:HomeView.java   
private void addVariousThemes(MenuItem parent) {

        parent.addItem("Dark", getCommandObject("dark"));
        parent.addItem("Facebook", getCommandObject("facebook"));
        parent.addItem("Flat", getCommandObject("flat"));
        parent.addItem("Flat Dark", getCommandObject("flatdark"));
        parent.addItem("Metro", getCommandObject("Metro"));
        parent.addItem("Blue Print", getCommandObject("blueprint"));
        parent.addItem("Light", getCommandObject("light"));
    }
项目:cia    文件:DocumentMenuItemFactoryImpl.java   
@Override
public void createDocumentsMenuBar(final MenuBar menuBar) {
    initApplicationMenuBar(menuBar);

    applicationMenuItemFactory.addRankingMenu(menuBar);
    final MenuItem documentsItem = menuBar.addItem(DOCUMENTS, VaadinIcons.FILE, null);
    documentsItem.addItem("List all",VaadinIcons.GROUP, COMMAND_DOCUMENTS);
    documentsItem.addItem("Search Documents",VaadinIcons.GROUP, COMMAND_SEARCH_DOCUMENT);

}
项目:cia    文件:PartyRankingMenuItemFactoryImpl.java   
@Override
public void createPartyRankingTopics(final MenuItem partynMenuItem) {

    partynMenuItem.addItem(OVERVIEW_TEXT, VaadinIcons.GROUP,
            COMMAND_OVERVIEW);

    final MenuItem listByTopic = partynMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, VaadinIcons.GROUP, null);

    final MenuItem listItem = listByTopic.addItem(TOTAL_MEMBERS,VaadinIcons.GROUP,
            COMMAND_DATAGRID);
    listItem.setDescription(PARTY_BY_TOTAL_MEMBERS_BASED_ON_ROLES_IN_DEPARTMENTS_COMMITTEES_AND_PARLIAMENT);

    final MenuItem chartByTopic = partynMenuItem.addItem(CHART_BY_TOPIC_TEXT, VaadinIcons.GROUP, null);


    chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT,VaadinIcons.GROUP,
            COMMAND_CHARTS_CURRENT_GOVERNMENT_PARTIES);

    chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_HEAD_COUNT,VaadinIcons.GROUP,
            COMMAND_CHARTS_CURRENT_COMMITTEES);

    chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_PARLIAMENT_HEAD_COUNT,VaadinIcons.GROUP,
            COMMAND_CHARTS_CURRENT_PARTIES);
    chartByTopic.addItem(ALL_PARTIES_TOTAL_DAYS_SERVED_IN_PARLIAMENT,VaadinIcons.GROUP,
            COMMAND_CHARTS_ALL_PARTIES);

    partynMenuItem.addItem(PAGE_VISIT_HISTORY_TEXT, VaadinIcons.GROUP,
            COMMAND_PAGEVISITHISTORY);
}
项目:SecureBPMN    文件:TaskListHeader.java   
protected void initSortMenu() {
  MenuBar menuBar = new MenuBar();
  menuBar.addStyleName(ExplorerLayout.STYLE_SEARCHBOX_SORTMENU);

  //TODO: Adding types of sorting manually and listener/events
  MenuItem rootItem = menuBar.addItem("Sort by", null);
  rootItem.addItem("Id", null);
  rootItem.addItem("Name", null);
  rootItem.addItem("Due date", null);
  rootItem.addItem("Creation date", null);

  layout.addComponent(menuBar);
  layout.setComponentAlignment(menuBar, Alignment.MIDDLE_RIGHT);
}
项目:SecureBPMN    文件:ToolbarPopupEntry.java   
/**
 * Add a menu-item, which executes the given command when clicked.
 */
public MenuItem addMenuItem(String title, final ToolbarCommand command) {
  return rootItem.addItem(title, new Command() {
    private static final long serialVersionUID = 1L;
    public void menuSelected(MenuItem selectedItem) {
      if(command != null) {
        command.toolBarItemSelected();
      }
    }
  });
}