Search in sources :

Example 1 with MenuItem

use of com.vaadin.addon.contextmenu.MenuItem in project cuba by cuba-platform.

the class WebLayoutAnalyzerContextMenuProvider method initContextMenu.

@Override
public void initContextMenu(Window window, Component contextMenuTarget) {
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (clientConfig.getLayoutAnalyzerEnabled()) {
        ContextMenu contextMenu = new ContextMenu(contextMenuTarget.unwrap(AbstractComponent.class), true);
        MenuItem menuItem = contextMenu.addItem(messages.getMainMessage("actions.analyzeLayout"), c -> {
            LayoutAnalyzer analyzer = new LayoutAnalyzer();
            List<LayoutTip> tipsList = analyzer.analyze(window);
            if (tipsList.isEmpty()) {
                window.showNotification("No layout problems found", Frame.NotificationType.HUMANIZED);
            } else {
                window.openWindow("layoutAnalyzer", WindowManager.OpenType.DIALOG, ParamsMap.of("tipsList", tipsList));
            }
        });
        menuItem.setStyleName("c-cm-item");
    }
}
Also used : AbstractComponent(com.vaadin.ui.AbstractComponent) LayoutTip(com.haulmont.cuba.gui.app.core.dev.LayoutTip) ContextMenu(com.vaadin.addon.contextmenu.ContextMenu) MenuItem(com.vaadin.addon.contextmenu.MenuItem) LayoutAnalyzer(com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 2 with MenuItem

use of com.vaadin.addon.contextmenu.MenuItem in project cuba by cuba-platform.

the class WebDataGrid method createContextMenuItem.

protected ActionMenuItemWrapper createContextMenuItem(Action action) {
    MenuItem menuItem = contextMenu.addItem(action.getCaption(), null);
    menuItem.setStyleName("c-cm-item");
    return new ActionMenuItemWrapper(menuItem, showIconsForPopupMenuActions) {

        @Override
        public void performAction(Action action) {
            action.actionPerform(WebDataGrid.this);
        }
    };
}
Also used : MenuItem(com.vaadin.addon.contextmenu.MenuItem)

Aggregations

MenuItem (com.vaadin.addon.contextmenu.MenuItem)2 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 LayoutAnalyzer (com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer)1 LayoutTip (com.haulmont.cuba.gui.app.core.dev.LayoutTip)1 ContextMenu (com.vaadin.addon.contextmenu.ContextMenu)1 AbstractComponent (com.vaadin.ui.AbstractComponent)1