Search in sources :

Example 1 with DropDownMenu

use of org.gwtbootstrap3.client.ui.DropDownMenu in project kie-wb-common by kiegroup.

the class MenuDevCommandsBuilder method buildDevMenuItem.

private MenuItem buildDevMenuItem() {
    final DropDownMenu menu = new DropDownMenu() {

        {
            addStyleName("pull-right");
        }
    };
    for (final MenuDevCommand command : devCommands) {
        menu.add(new AnchorListItem(command.getText()) {

            {
                setIcon(command.getIcon());
                addClickHandler(event -> command.execute());
            }
        });
    }
    final IsWidget group = new ButtonGroup() {

        {
            add(new Button() {

                {
                    setToggleCaret(false);
                    setDataToggle(Toggle.DROPDOWN);
                    setIcon(IconType.COG);
                    setSize(ButtonSize.SMALL);
                    setTitle("Development");
                }
            });
            add(menu);
        }
    };
    return MenuUtils.buildItem(group);
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) IconType(org.gwtbootstrap3.client.ui.constants.IconType) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) Button(org.gwtbootstrap3.client.ui.Button) Inject(javax.inject.Inject) List(java.util.List) Toggle(org.gwtbootstrap3.client.ui.constants.Toggle) MenuUtils(org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IsWidget(com.google.gwt.user.client.ui.IsWidget) LinkedList(java.util.LinkedList) ButtonSize(org.gwtbootstrap3.client.ui.constants.ButtonSize) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) IsWidget(com.google.gwt.user.client.ui.IsWidget) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) Button(org.gwtbootstrap3.client.ui.Button) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu)

Example 2 with DropDownMenu

use of org.gwtbootstrap3.client.ui.DropDownMenu 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 3 with DropDownMenu

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

the class RefreshPanel method createDropdownMenu.

private void createDropdownMenu() {
    dropdownMenu = new DropDownMenu();
    dropdownMenu.setPull(Pull.LEFT);
    Set<Integer> refreshRates = AbstractRefreshManager.getRefreshRates();
    for (Integer refreshRate : refreshRates) {
        AnchorListItem refreshRateItem = new AnchorListItem();
        refreshRateItem.setText(MillisecondRenderer.getInstance().render(refreshRate));
        refreshRateItem.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                refreshManager.setCurrentRefreshRate(refreshRate);
                removeActiveStyles();
                refreshRateItem.addStyleName(Styles.ACTIVE);
            }
        });
        if (refreshManager.getCurrentRefreshRate() == refreshRate) {
            refreshRateItem.addStyleName(Styles.ACTIVE);
        }
        dropdownMenu.add(refreshRateItem);
    }
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 4 with DropDownMenu

use of org.gwtbootstrap3.client.ui.DropDownMenu 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)

Example 5 with DropDownMenu

use of org.gwtbootstrap3.client.ui.DropDownMenu in project kie-wb-common by kiegroup.

the class BPMNDiagramEditorMenuItemsBuilder method newFormsGenerationMenuItem.

public MenuItem newFormsGenerationMenuItem(final Command generateProcessForm, final Command generateAllForms, final Command generateSelectedForms) {
    final DropDownMenu menu = new DropDownMenu() {

        {
            setPull(Pull.RIGHT);
        }
    };
    menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateProcessForm)) {

        {
            setIcon(IconType.LIST_ALT);
            setIconPosition(IconPosition.LEFT);
            setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateProcessForm));
            addClickHandler(event -> generateProcessForm.execute());
        }
    });
    menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateAllForms)) {

        {
            setIcon(IconType.LIST_ALT);
            setIconPosition(IconPosition.LEFT);
            setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateAllForms));
            addClickHandler(event -> generateAllForms.execute());
        }
    });
    menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateSelectionForms)) {

        {
            setIcon(IconType.LIST_ALT);
            setIconPosition(IconPosition.LEFT);
            setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateSelectionForms));
            addClickHandler(event -> generateSelectedForms.execute());
        }
    });
    final IsWidget group = new ButtonGroup() {

        {
            add(new Button() {

                {
                    setToggleCaret(true);
                    setDataToggle(Toggle.DROPDOWN);
                    setIcon(IconType.LIST_ALT);
                    setSize(ButtonSize.SMALL);
                    setTitle(translationService.getValue(BPMNClientConstants.EditorFormGenerationTitle));
                }
            });
            add(menu);
        }
    };
    return MenuUtils.buildItem(group);
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) IconType(org.gwtbootstrap3.client.ui.constants.IconType) Pull(org.gwtbootstrap3.client.ui.constants.Pull) BPMNClientConstants(org.kie.workbench.common.stunner.bpmn.project.client.resources.BPMNClientConstants) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) IconPosition(org.gwtbootstrap3.client.ui.constants.IconPosition) Button(org.gwtbootstrap3.client.ui.Button) Inject(javax.inject.Inject) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Toggle(org.gwtbootstrap3.client.ui.constants.Toggle) MenuUtils(org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IsWidget(com.google.gwt.user.client.ui.IsWidget) ButtonSize(org.gwtbootstrap3.client.ui.constants.ButtonSize) Command(org.uberfire.mvp.Command) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) IsWidget(com.google.gwt.user.client.ui.IsWidget) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) Button(org.gwtbootstrap3.client.ui.Button) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu)

Aggregations

DropDownMenu (org.gwtbootstrap3.client.ui.DropDownMenu)8 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)7 Button (org.gwtbootstrap3.client.ui.Button)5 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 Inject (javax.inject.Inject)4 ButtonSize (org.gwtbootstrap3.client.ui.constants.ButtonSize)4 IconType (org.gwtbootstrap3.client.ui.constants.IconType)4 Toggle (org.gwtbootstrap3.client.ui.constants.Toggle)4 MenuUtils (org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils)4 Divider (org.gwtbootstrap3.client.ui.Divider)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 DropDownHeader (org.gwtbootstrap3.client.ui.DropDownHeader)2 IconPosition (org.gwtbootstrap3.client.ui.constants.IconPosition)2 Pull (org.gwtbootstrap3.client.ui.constants.Pull)2 ClientTranslationService (org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService)2 Command (org.uberfire.mvp.Command)2