Search in sources :

Example 1 with MenuBar

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();
}
Also used : MenuBar(org.ovirt.engine.ui.common.widget.MenuBar)

Example 2 with MenuBar

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);
}
Also used : MenuBar(org.ovirt.engine.ui.common.widget.MenuBar)

Example 3 with MenuBar

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();
        });
    }
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) MenuBar(org.ovirt.engine.ui.common.widget.MenuBar)

Example 4 with MenuBar

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;
}
Also used : MenuBar(org.ovirt.engine.ui.common.widget.MenuBar)

Example 5 with 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;
}
Also used : MenuBar(org.ovirt.engine.ui.common.widget.MenuBar) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) List(java.util.List) MenuItem(com.google.gwt.user.client.ui.MenuItem) NetworkCommand(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand) NetworkOperation(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation)

Aggregations

MenuBar (org.ovirt.engine.ui.common.widget.MenuBar)5 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 List (java.util.List)1 VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)1 LexoNumericComparator (org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)1 NetworkCommand (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand)1 NetworkOperation (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation)1