Search in sources :

Example 1 with ShortcutsDelegate

use of com.haulmont.cuba.gui.components.sys.ShortcutsDelegate in project cuba by cuba-platform.

the class WebAbstractDataGrid method createShortcutsDelegate.

protected ShortcutsDelegate<ShortcutListener> createShortcutsDelegate() {
    return new ShortcutsDelegate<ShortcutListener>() {

        @Override
        protected ShortcutListener attachShortcut(String actionId, KeyCombination keyCombination) {
            ShortcutListener shortcut = new ShortcutListenerDelegate(actionId, keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers())).withHandler((sender, target) -> {
                if (sender == componentComposition) {
                    Action action = getAction(actionId);
                    if (action != null && action.isEnabled() && action.isVisible()) {
                        action.actionPerform(WebAbstractDataGrid.this);
                    }
                }
            });
            componentComposition.addShortcutListener(shortcut);
            return shortcut;
        }

        @Override
        protected void detachShortcut(Action action, ShortcutListener shortcutDescriptor) {
            componentComposition.removeShortcutListener(shortcutDescriptor);
        }

        @Override
        protected Collection<Action> getActions() {
            return WebAbstractDataGrid.this.getActions();
        }
    };
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ShowInfoAction(com.haulmont.cuba.gui.components.sys.ShowInfoAction) ShortcutListenerDelegate(com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate) ShortcutsDelegate(com.haulmont.cuba.gui.components.sys.ShortcutsDelegate)

Example 2 with ShortcutsDelegate

use of com.haulmont.cuba.gui.components.sys.ShortcutsDelegate in project cuba by cuba-platform.

the class WebTree method createShortcutsDelegate.

protected ShortcutsDelegate<ShortcutListener> createShortcutsDelegate() {
    return new ShortcutsDelegate<ShortcutListener>() {

        @Override
        protected ShortcutListener attachShortcut(String actionId, KeyCombination keyCombination) {
            ShortcutListener shortcut = new ShortcutListenerDelegate(actionId, keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers())).withHandler((sender, target) -> {
                if (sender == componentComposition) {
                    Action action = getAction(actionId);
                    if (action != null && action.isEnabled() && action.isVisible()) {
                        action.actionPerform(WebTree.this);
                    }
                }
            });
            componentComposition.addShortcutListener(shortcut);
            return shortcut;
        }

        @Override
        protected void detachShortcut(Action action, ShortcutListener shortcutDescriptor) {
            componentComposition.removeShortcutListener(shortcutDescriptor);
        }

        @Override
        protected Collection<Action> getActions() {
            return WebTree.this.getActions();
        }
    };
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ShowInfoAction(com.haulmont.cuba.gui.components.sys.ShowInfoAction) ShortcutListenerDelegate(com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate) ShortcutsDelegate(com.haulmont.cuba.gui.components.sys.ShortcutsDelegate)

Aggregations

BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)2 ShortcutsDelegate (com.haulmont.cuba.gui.components.sys.ShortcutsDelegate)2 ShowInfoAction (com.haulmont.cuba.gui.components.sys.ShowInfoAction)2 ShortcutListenerDelegate (com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate)2 ShortcutListener (com.vaadin.event.ShortcutListener)2