Search in sources :

Example 1 with ContextMenu

use of io.jmix.ui.widget.addon.contextmenu.ContextMenu in project jmix by jmix-framework.

the class LayoutAnalyzerContextMenuProvider method initContextMenu.

public void initContextMenu(Screen screen, io.jmix.ui.component.Component contextMenuTarget) {
    if (screenProperties.isLayoutAnalyzerEnabled()) {
        ContextMenu contextMenu = new ContextMenu(contextMenuTarget.unwrap(AbstractComponent.class), true);
        MenuBar.MenuItem menuItem = contextMenu.addItem(messages.getMessage("actions.analyzeLayout"), c -> {
            LayoutAnalyzer analyzer = new LayoutAnalyzer();
            List<LayoutTip> tipsList = analyzer.analyze(screen);
            if (tipsList.isEmpty()) {
                Notifications notifications = UiControllerUtils.getScreenContext(screen).getNotifications();
                notifications.create(Notifications.NotificationType.HUMANIZED).withCaption("No layout problems found").show();
            } else {
                Screens screens = UiControllerUtils.getScreenContext(screen).getScreens();
                LayoutAnalyzerScreen layoutAnalyzerScreen = screens.create(LayoutAnalyzerScreen.class, OpenMode.DIALOG);
                layoutAnalyzerScreen.setLayoutTips(tipsList);
                layoutAnalyzerScreen.show();
            }
        });
        menuItem.setStyleName("jmix-cm-item");
    }
}
Also used : AbstractComponent(com.vaadin.ui.AbstractComponent) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutTip(io.jmix.ui.app.core.dev.LayoutTip) MenuBar(com.vaadin.ui.MenuBar) ContextMenu(io.jmix.ui.widget.addon.contextmenu.ContextMenu) LayoutAnalyzer(io.jmix.ui.app.core.dev.LayoutAnalyzer) Notifications(io.jmix.ui.Notifications) Screens(io.jmix.ui.Screens)

Aggregations

AbstractComponent (com.vaadin.ui.AbstractComponent)1 MenuBar (com.vaadin.ui.MenuBar)1 Notifications (io.jmix.ui.Notifications)1 Screens (io.jmix.ui.Screens)1 LayoutAnalyzer (io.jmix.ui.app.core.dev.LayoutAnalyzer)1 LayoutAnalyzerScreen (io.jmix.ui.app.core.dev.LayoutAnalyzerScreen)1 LayoutTip (io.jmix.ui.app.core.dev.LayoutTip)1 ContextMenu (io.jmix.ui.widget.addon.contextmenu.ContextMenu)1