Search in sources :

Example 1 with LayoutAnalyzer

use of com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer 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 LayoutAnalyzer

use of com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer in project cuba by cuba-platform.

the class DesktopWindowManager method createWindowPopupMenu.

protected JPopupMenu createWindowPopupMenu(final Window window) {
    JPopupMenu popupMenu = new JPopupMenu();
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (clientConfig.getManualScreenSettingsSaving()) {
        JMenuItem saveSettingsItem = new JMenuItem(messages.getMainMessage("actions.saveSettings"));
        saveSettingsItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                window.saveSettings();
            }
        });
        popupMenu.add(saveSettingsItem);
        JMenuItem restoreToDefaultsItem = new JMenuItem(messages.getMainMessage("actions.restoreToDefaults"));
        restoreToDefaultsItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                window.deleteSettings();
            }
        });
        popupMenu.add(restoreToDefaultsItem);
    }
    if (clientConfig.getLayoutAnalyzerEnabled()) {
        JMenuItem analyzeLayoutItem = new JMenuItem(messages.getMainMessage("actions.analyzeLayout"));
        analyzeLayoutItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                LayoutAnalyzer analyzer = new LayoutAnalyzer();
                List<LayoutTip> tipsList = analyzer.analyze(window);
                if (tipsList.isEmpty()) {
                    showNotification("No layout problems found", NotificationType.HUMANIZED);
                } else {
                    window.openWindow("layoutAnalyzer", OpenType.DIALOG, ParamsMap.of("tipsList", tipsList));
                }
            }
        });
        popupMenu.add(analyzeLayoutItem);
    }
    return popupMenu;
}
Also used : List(java.util.List) LayoutAnalyzer(com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 3 with LayoutAnalyzer

use of com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer in project cuba by cuba-platform.

the class MainTabSheetActionHandler method analyzeLayout.

protected void analyzeLayout(Object target) {
    Window window = findWindow((Layout) target);
    if (window != null) {
        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));
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) LayoutTip(com.haulmont.cuba.gui.app.core.dev.LayoutTip) LayoutAnalyzer(com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer)

Aggregations

LayoutAnalyzer (com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer)3 ClientConfig (com.haulmont.cuba.client.ClientConfig)2 LayoutTip (com.haulmont.cuba.gui.app.core.dev.LayoutTip)2 Window (com.haulmont.cuba.gui.components.Window)1 ContextMenu (com.vaadin.addon.contextmenu.ContextMenu)1 MenuItem (com.vaadin.addon.contextmenu.MenuItem)1 AbstractComponent (com.vaadin.ui.AbstractComponent)1 List (java.util.List)1