Search in sources :

Example 1 with ValidationAwareActionListener

use of com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener in project cuba by cuba-platform.

the class App method createStartContentPane.

protected Container createStartContentPane() {
    JPanel pane = new JPanel(new BorderLayout());
    menuBar = new JMenuBar();
    pane.add(menuBar, BorderLayout.NORTH);
    Locale loc = Locale.getDefault();
    JMenu menu = new JMenu(messages.getMainMessage("mainMenu.file", loc));
    menuBar.add(menu);
    JMenuItem item;
    item = new JMenuItem(messages.getMainMessage("mainMenu.connect", loc));
    item.addActionListener(e -> showLoginDialog());
    menu.add(item);
    item = new JMenuItem(messages.getMainMessage("mainMenu.exit", loc));
    item.addActionListener(new ValidationAwareActionListener() {

        @Override
        public void actionPerformedAfterValidation(ActionEvent e) {
            exit();
        }
    });
    menu.add(item);
    if (isTestMode()) {
        menuBar.setName("startMenu");
    }
    return pane;
}
Also used : Locale(java.util.Locale) ValidationAwareActionListener(com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 2 with ValidationAwareActionListener

use of com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener in project cuba by cuba-platform.

the class WindowBreadCrumbs method update.

public void update() {
    removeAll();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
        Window window = it.next();
        JButton button = new JXHyperlink();
        button.setFocusable(false);
        button.setText(StringUtils.trimToEmpty(window.getCaption()));
        button.addActionListener(new ValidationAwareActionListener() {

            @Override
            public void actionPerformedAfterValidation(ActionEvent e) {
                JButton btn = (JButton) e.getSource();
                Window win = btn2win.get(btn);
                if (win != null) {
                    fireListeners(win);
                }
            }
        });
        btn2win.put(button, window);
        if (it.hasNext()) {
            add(button);
            JLabel separatorLab = new JLabel(">");
            add(separatorLab);
        } else {
            add(new JLabel(window.getCaption()));
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) ValidationAwareActionListener(com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener) ActionEvent(java.awt.event.ActionEvent) JXHyperlink(org.jdesktop.swingx.JXHyperlink)

Example 3 with ValidationAwareActionListener

use of com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener in project cuba by cuba-platform.

the class App method createMenuBar.

protected JComponent createMenuBar() {
    menuBar = new JMenuBar();
    JMenu menu = new JMenu(messages.getMessage(AppConfig.getMessagesPack(), "mainMenu.file"));
    menuBar.add(menu);
    JMenuItem item;
    item = new JMenuItem(messages.getMessage(AppConfig.getMessagesPack(), "mainMenu.disconnect"));
    item.addActionListener(new ValidationAwareActionListener() {

        @Override
        public void actionPerformedAfterValidation(ActionEvent e) {
            logout();
        }
    });
    menu.add(item);
    item = new JMenuItem(messages.getMessage(AppConfig.getMessagesPack(), "mainMenu.exit"));
    item.addActionListener(new ValidationAwareActionListener() {

        @Override
        public void actionPerformedAfterValidation(ActionEvent e) {
            exit();
        }
    });
    menu.add(item);
    MenuBuilder builder = new MenuBuilder(connection.getSession(), menuBar);
    builder.build();
    if (isTestMode()) {
        menuBar.setName("menuBar");
    }
    return menuBar;
}
Also used : ValidationAwareActionListener(com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 4 with ValidationAwareActionListener

use of com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener in project cuba by cuba-platform.

the class MenuBuilder method assignCommand.

private void assignCommand(JMenuItem jMenuItem, MenuItem item) {
    MenuCommand command = new MenuCommand(item);
    jMenuItem.addActionListener(new ValidationAwareActionListener() {

        @Override
        public void actionPerformedAfterValidation(ActionEvent e) {
            command.execute();
            StringBuilder menuPath = new StringBuilder();
            formatMenuPath(item, menuPath);
            userActionsLog.trace("Action \"{}\" was performed using menu item {}", command.getCommandDescription(), menuPath.toString());
        }
    });
}
Also used : ValidationAwareActionListener(com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener) ActionEvent(java.awt.event.ActionEvent) MenuCommand(com.haulmont.cuba.gui.config.MenuCommand)

Aggregations

ValidationAwareActionListener (com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener)4 ActionEvent (java.awt.event.ActionEvent)4 Window (com.haulmont.cuba.gui.components.Window)1 MenuCommand (com.haulmont.cuba.gui.config.MenuCommand)1 Locale (java.util.Locale)1 JXHyperlink (org.jdesktop.swingx.JXHyperlink)1