use of org.ovirt.engine.ui.common.widget.MenuBar in project ovirt-engine by oVirt.
the class PolicyUnitPanel method showContextMenu.
protected void showContextMenu(PolicyUnitPanel sourcePanel, int clientX, int clientY) {
MenuBar menuBar = createMenu();
fillMenuBar(menuBar);
if (policyUnit.isEnabled()) {
addSubMenu(menuBar);
}
menuPopup.setWidget(menuBar);
menuPopup.setPopupPosition(clientX, clientY);
menuPopup.show();
}
use of org.ovirt.engine.ui.common.widget.MenuBar in project ovirt-engine by oVirt.
the class PolicyUnitPanel method addSubMenu.
protected void addSubMenu(MenuBar menuBar) {
MenuBar subMenu = new MenuBar(true);
if (position != 0) {
subMenu.addItem(constants.noPositionFilter(), () -> {
model.addFilter(policyUnit, used, 0);
menuPopup.hide();
});
}
if (position >= 0) {
subMenu.addItem(constants.firstFilter(), () -> {
model.addFilter(policyUnit, used, -1);
menuPopup.hide();
});
}
if (position <= 0) {
subMenu.addItem(constants.lastFilter(), () -> {
model.addFilter(policyUnit, used, 1);
menuPopup.hide();
});
}
menuBar.addItem(constants.position(), subMenu);
}
use of org.ovirt.engine.ui.common.widget.MenuBar in project ovirt-engine by oVirt.
the class DraggableVirtualNumaPanel method createMenu.
private void createMenu(final List<VdsNumaNode> numaNodeList, int indexToSkip) {
menuBar = new MenuBar(true);
for (final VdsNumaNode numaNode : numaNodeList) {
final int nodeIndex = numaNode.getIndex();
menuBar.addItem(messages.numaNode(nodeIndex), () -> {
UpdatedVnumaEvent.fire(DraggableVirtualNumaPanel.this, nodeModel.getVm().getId(), true, nodeModel.getIndex(), nodeIndex);
menuPopup.hide();
});
}
if (nodeModel.isPinned()) {
menuBar.addSeparator();
menuBar.addItem(constants.unPinNode(), () -> {
UpdatedVnumaEvent.fire(DraggableVirtualNumaPanel.this, nodeModel.getVm().getId(), false, nodeModel.getIndex(), -1);
menuPopup.hide();
});
}
}
use of org.ovirt.engine.ui.common.widget.MenuBar in project ovirt-engine by oVirt.
the class PolicyUnitPanel method createMenu.
protected MenuBar createMenu() {
MenuBar menuBar = new MenuBar(true);
menuBar.addItem(constants.actionItems(), (Command) null);
menuBar.addSeparator();
return menuBar;
}
use of org.ovirt.engine.ui.common.widget.MenuBar in project ovirt-engine by oVirt.
the class NetworkItemPanel method menuFor.
/**
* Generate a Menu for the provided Network Item.
*/
private MenuBar menuFor(NetworkItemModel<?> item) {
MenuBar menu = rootMenu(item);
Map<NetworkOperation, List<NetworkCommand>> operationMap = item.getSetupModel().commandsFor(item);
for (final Entry<NetworkOperation, List<NetworkCommand>> entry : operationMap.entrySet()) {
final List<NetworkCommand> commands = entry.getValue();
if (entry.getKey().isUnary()) {
// $NON-NLS-1$
assert commands.size() == 1 : "Got a NetworkCommand List with more than one Unary Operation";
menu.addItem(entry.getKey().getVerb(item), () -> executeCommand(entry.getKey(), commands.get(0)));
} else {
Collections.sort(commands, Comparator.comparing(NetworkCommand::getName, new LexoNumericComparator()));
MenuBar subMenu = subMenu();
for (final NetworkCommand command : commands) {
subMenu.addItem(new MenuItem(command.getName(), () -> executeCommand(entry.getKey(), command)));
}
menu.addItem(entry.getKey().getVerb(item), subMenu);
}
}
return menu;
}
Aggregations