当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem类代码示例

本文整理汇总了Java中com.vaadin.ui.MenuBar.MenuItem的典型用法代码示例。如果您正苦于以下问题:Java MenuItem类的具体用法?Java MenuItem怎么用?Java MenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MenuItem类属于com.vaadin.ui.MenuBar包,在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildUserMenu

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:24,代码来源:DashboardMenu.java

示例2: detachLsnr

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:mi9rom,项目名称:VaadHL,代码行数:24,代码来源:Action.java

示例3: setVisible

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
/**
 * 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());
	}
}
 
开发者ID:mi9rom,项目名称:VaadHL,代码行数:22,代码来源:Action.java

示例4: initApplicationMenuBar

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
/**
 * 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);
	}

}
 
开发者ID:Hack23,项目名称:cia,代码行数:30,代码来源:AbstractMenuItemFactoryImpl.java

示例5: addSourcesAndIndicatorsToMenu

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
/**
 * 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()));
		}
	}

}
 
开发者ID:Hack23,项目名称:cia,代码行数:33,代码来源:CountryMenuItemFactoryImpl.java

示例6: createMenuItem

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:lkumarjain,项目名称:jain-I18n,代码行数:31,代码来源:ActionMenuBar.java

示例7: processAction

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:lkumarjain,项目名称:jain-I18n,代码行数:31,代码来源:ActionMenuBar.java

示例8: addShowButton

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
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);
}
 
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:17,代码来源:SqlExplorer.java

示例9: contribute

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:frincon,项目名称:openeos,代码行数:17,代码来源:VaadinMenuContributor.java

示例10: menuCommand

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
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();
		}
	};
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:CommandManager.java

示例11: updateMenuItem

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
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));
   		}
	}
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:CommandManager.java

示例12: get

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
@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;
   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:MenuBarBuilder.java

示例13: addMenuItems

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
@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());
            }
        }
        
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:MenuBarBuilder.java

示例14: createMenuTest

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
@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());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:TestMenuBarBuilder.java

示例15: createTopLevelMenuWithAdditionsTest

import com.vaadin.ui.MenuBar.MenuItem; //导入依赖的package包/类
@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());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:TestMenuBarBuilder.java


注:本文中的com.vaadin.ui.MenuBar.MenuItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。