Search in sources :

Example 1 with DropDownHeader

use of org.gwtbootstrap3.client.ui.DropDownHeader in project ovirt-engine by oVirt.

the class AbstractActionTable method updateContextMenu.

/**
 * Rebuilds context menu items to match the action button list.
 * @param dropDownMenu The menu bar to populate.
 * @param actions A list of {@code ActionButtonDefinition}s used to populate the {@code MenuBar}.
 * @param popupPanel The pop-up panel containing the {@code MenuBar}.
 * @param removeOldItems A flag to indicate if we should remove old items.
 * @return A {@code MenuBar} containing all the action buttons as menu items.
 */
private DropDownMenu updateContextMenu(DropDownMenu dropDownMenu, List<ActionButtonDefinition<T>> actions, boolean removeOldItems) {
    if (removeOldItems) {
        ElementTooltipUtils.destroyMenuItemTooltips(dropDownMenu);
        dropDownMenu.clear();
        // Close any other open popups as well.
        closeOtherPopups();
    }
    for (final ActionButtonDefinition<T> buttonDef : actions) {
        if (buttonDef instanceof UiMenuBarButtonDefinition) {
            UiMenuBarButtonDefinition<T> menuBarDef = (UiMenuBarButtonDefinition<T>) buttonDef;
            DropDownHeader subMenuHeader = new DropDownHeader(buttonDef.getText());
            dropDownMenu.add(new Divider());
            subMenuHeader.setVisible(buttonDef.isVisible(getSelectedItems()));
            dropDownMenu.add(subMenuHeader);
            updateContextMenu(dropDownMenu, menuBarDef.getSubActions(), false);
        } else {
            AnchorListItem item = new AnchorListItem(buttonDef.getText());
            item.addClickHandler(e -> buttonDef.onClick(getSelectedItems()));
            updateMenuItem(item, buttonDef);
            dropDownMenu.add(item);
        }
    }
    return dropDownMenu;
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) DropDownHeader(org.gwtbootstrap3.client.ui.DropDownHeader) Divider(org.gwtbootstrap3.client.ui.Divider) UiMenuBarButtonDefinition(org.ovirt.engine.ui.common.widget.action.UiMenuBarButtonDefinition)

Example 2 with DropDownHeader

use of org.gwtbootstrap3.client.ui.DropDownHeader in project ovirt-engine by oVirt.

the class DropdownActionButton method initMenuPopup.

private void initMenuPopup(List<ActionButtonDefinition<T>> actions) {
    if (menuPopup == null) {
        menuPopup = new DropDownMenu();
    }
    for (final ActionButtonDefinition<T> buttonDef : actions) {
        if (buttonDef instanceof UiMenuBarButtonDefinition) {
            UiMenuBarButtonDefinition<T> menuBarDef = (UiMenuBarButtonDefinition<T>) buttonDef;
            DropDownHeader subMenuHeader = new DropDownHeader(buttonDef.getText());
            menuPopup.add(new Divider());
            menuPopup.add(subMenuHeader);
            initMenuPopup(menuBarDef.getSubActions());
        } else {
            AnchorListItem menuItem = new AnchorListItem(buttonDef.getText());
            menuItem.addClickHandler(e -> {
                buttonDef.onClick(selectedItemsProvider.getSelectedItems());
            });
            updateMenuItem(menuItem, buttonDef, selectedItemsProvider.getSelectedItems());
            menuPopup.add(menuItem);
            items.add(new Pair<>(menuItem, buttonDef));
        }
    }
    add(menuPopup);
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) DropDownHeader(org.gwtbootstrap3.client.ui.DropDownHeader) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) Divider(org.gwtbootstrap3.client.ui.Divider)

Aggregations

AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)2 Divider (org.gwtbootstrap3.client.ui.Divider)2 DropDownHeader (org.gwtbootstrap3.client.ui.DropDownHeader)2 DropDownMenu (org.gwtbootstrap3.client.ui.DropDownMenu)1 UiMenuBarButtonDefinition (org.ovirt.engine.ui.common.widget.action.UiMenuBarButtonDefinition)1