本文整理匯總了Java中com.vaadin.contextmenu.ContextMenu.addItem方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextMenu.addItem方法的具體用法?Java ContextMenu.addItem怎麽用?Java ContextMenu.addItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.contextmenu.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.addItem方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onGenericContextMenu
import com.vaadin.contextmenu.ContextMenu; //導入方法依賴的package包/類
private void onGenericContextMenu(ContextMenuOpenEvent event) {
GridContextClickEvent<String[]> gridE = (GridContextClickEvent<String[]>) event
.getContextClickEvent();
ContextMenu menu = event.getContextMenu();
menu.removeItems();
if (gridE.getColumn() != null) {
menu.addItem(
"Called from column " + gridE.getColumn().getCaption()
+ " on row " + gridE.getRowIndex(),
f -> Notification.show("did something"));
} else if (gridE.getRowIndex() >= 0) {
menu.addItem("Called on row " + gridE.getRowIndex(),
f -> Notification.show("did something"));
} else {
menu.addItem("Called on background",
f -> Notification.show("did something"));
}
}
示例2: adaptAction
import com.vaadin.contextmenu.ContextMenu; //導入方法依賴的package包/類
private static MenuItem adaptAction(ContextMenu menu, Action action) {
MenuItem item = menu.addItem(action.getName(), e -> action.action());
action.setChangeListener(new ActionChangeListener() {
{
update();
}
@Override
public void change() {
update();
}
protected void update() {
item.setEnabled(action.isEnabled());
item.setDescription(action.getDescription());
}
});
return item;
}
示例3: addActions
import com.vaadin.contextmenu.ContextMenu; //導入方法依賴的package包/類
private static void addActions(ContextMenu menu, List<Action> actions) {
for (Action action : actions) {
if (action instanceof ActionGroup) {
ActionGroup actionGroup = (org.minimalj.frontend.action.ActionGroup) action;
MenuItem subMenu = menu.addItem(actionGroup.getName(), e -> {});
addActions(subMenu, actionGroup.getItems());
} else if (action instanceof Separator) {
menu.addSeparator();
} else {
adaptAction(menu, action);
}
}
}