Search in sources :

Example 1 with LayoutTip

use of io.jmix.ui.app.core.dev.LayoutTip 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)

Example 2 with LayoutTip

use of io.jmix.ui.app.core.dev.LayoutTip in project jmix by jmix-framework.

the class MainTabSheetActionHandler method analyzeLayout.

protected void analyzeLayout(Object target) {
    Screen screen = findScreen((Layout) target);
    if (screen == null) {
        return;
    }
    LayoutAnalyzer analyzer = new LayoutAnalyzer();
    List<LayoutTip> layoutTips = analyzer.analyze(screen);
    ScreenContext screenContext = UiControllerUtils.getScreenContext(screen);
    if (layoutTips.isEmpty()) {
        Notifications notifications = screenContext.getNotifications();
        notifications.create(NotificationType.HUMANIZED).withCaption("No layout problems found").show();
    } else {
        Screens screens = screenContext.getScreens();
        LayoutAnalyzerScreen analyzerScreen = screens.create(LayoutAnalyzerScreen.class, OpenMode.DIALOG);
        analyzerScreen.setLayoutTips(layoutTips);
        analyzerScreen.show();
    }
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutTip(io.jmix.ui.app.core.dev.LayoutTip) Screen(io.jmix.ui.screen.Screen) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutAnalyzer(io.jmix.ui.app.core.dev.LayoutAnalyzer) Notifications(io.jmix.ui.Notifications) Screens(io.jmix.ui.Screens)

Aggregations

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