Search in sources :

Example 6 with Resource

use of com.vaadin.server.Resource in project cuba by cuba-platform.

the class WebAppMenu method createMenuItem.

@Override
public MenuItem createMenuItem(String id, String caption, @Nullable String icon, @Nullable Consumer<MenuItem> command) {
    checkNotNullArgument(id);
    checkItemIdDuplicate(id);
    MenuItem menuItem = new MenuItemImpl(this, id);
    Resource iconResource = null;
    if (icon != null) {
        iconResource = AppBeans.get(IconResolver.class).getIconResource(icon);
    }
    MenuBar.MenuItem delegateItem = component.createMenuItem(caption, iconResource, null);
    if (command != null) {
        delegateItem.setCommand(selectedItem -> command.accept(menuItem));
    }
    ((MenuItemImpl) menuItem).setDelegateItem(delegateItem);
    menuItem.setCaption(caption);
    menuItem.setIcon(icon);
    menuItem.setCommand(command);
    return menuItem;
}
Also used : Resource(com.vaadin.server.Resource) MenuBar(com.vaadin.ui.MenuBar) CubaMenuBar(com.haulmont.cuba.web.toolkit.ui.CubaMenuBar)

Example 7 with Resource

use of com.vaadin.server.Resource in project cuba by cuba-platform.

the class CubaSideMenu method markMenuStructureAsDirty.

protected void markMenuStructureAsDirty() {
    markAsDirty();
    this.structureChanged = true;
    for (String menuIconsKey : menuIconResourceKeys) {
        Resource resource = getResource(menuIconsKey);
        menuIconsKeyMapper.remove(resource);
        setResource(menuIconsKey, null);
    }
    menuItemIdMapper.removeAll();
    menuIconsKeyMapper.removeAll();
    // all badges will be sent to client with items
    badgeUpdates.clear();
}
Also used : Resource(com.vaadin.server.Resource)

Aggregations

Resource (com.vaadin.server.Resource)7 Configuration (com.haulmont.cuba.core.global.Configuration)2 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)2 WebConfig (com.haulmont.cuba.web.WebConfig)2 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)2 FileResource (com.vaadin.server.FileResource)2 IconResolver (com.haulmont.cuba.web.gui.icons.IconResolver)1 CubaMenuBar (com.haulmont.cuba.web.toolkit.ui.CubaMenuBar)1 ExternalResource (com.vaadin.server.ExternalResource)1 BrowserFrame (com.vaadin.ui.BrowserFrame)1 MenuBar (com.vaadin.ui.MenuBar)1 File (java.io.File)1 Nullable (javax.annotation.Nullable)1