Example usage for com.vaadin.shared.ui.menubar MenuBarConstants ATTRIBUTE_ITEM_STYLE

List of usage examples for com.vaadin.shared.ui.menubar MenuBarConstants ATTRIBUTE_ITEM_STYLE

Introduction

In this page you can find the example usage for com.vaadin.shared.ui.menubar MenuBarConstants ATTRIBUTE_ITEM_STYLE.

Prototype

String ATTRIBUTE_ITEM_STYLE

To view the source code for com.vaadin.shared.ui.menubar MenuBarConstants ATTRIBUTE_ITEM_STYLE.

Click Source Link

Usage

From source file:com.haulmont.cuba.web.widgets.addons.contextmenu.MenuBar.java

License:Apache License

private void paintItem(PaintTarget target, MenuItem item) throws PaintException {
    if (!item.isVisible()) {
        return;/*from   w  ww.j av a2s .co m*/
    }

    target.startTag("item");

    target.addAttribute("id", item.getId());

    if (item.getStyleName() != null) {
        target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_STYLE, item.getStyleName());
    }

    if (item.isSeparator()) {
        target.addAttribute("separator", true);
    } else {
        target.addAttribute("text", item.getText());

        Command command = item.getCommand();
        if (command != null) {
            target.addAttribute("command", true);
        }

        Resource icon = item.getIcon();
        if (icon != null) {
            target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_ICON, icon);
        }

        if (!item.isEnabled()) {
            target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DISABLED, true);
        }

        String description = item.getDescription();
        if (description != null && description.length() > 0) {
            target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION, description);
        }
        if (item.isCheckable()) {
            // if the "checked" attribute is present (either true or false),
            // the item is checkable
            target.addAttribute(MenuBarConstants.ATTRIBUTE_CHECKED, item.isChecked());
        }
        if (item.hasChildren()) {
            for (MenuItem child : item.getChildren()) {
                paintItem(target, child);
            }
        }

    }

    target.endTag("item");
}