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();
}
};
}
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();
}
};
}
Aggregations