Example usage for com.vaadin.event ShortcutListener getCaption

List of usage examples for com.vaadin.event ShortcutListener getCaption

Introduction

In this page you can find the example usage for com.vaadin.event ShortcutListener getCaption.

Prototype

public String getCaption() 

Source Link

Document

Returns the action's caption.

Usage

From source file:com.haulmont.cuba.web.gui.components.WebFilterHelper.java

License:Apache License

@Override
public void addShortcutListener(TextField textField, final ShortcutListener listener) {
    CubaTextField vTextField = textField.unwrap(CubaTextField.class);
    int[] modifiers = null;
    KeyCombination.Modifier[] listenerModifiers = listener.getKeyCombination().getModifiers();
    if (listenerModifiers != null) {
        modifiers = new int[listenerModifiers.length];
        for (int i = 0; i < modifiers.length; i++) {
            modifiers[i] = listenerModifiers[i].getCode();
        }// w  w w .  j  av a2s . c  o  m
    }
    int keyCode = listener.getKeyCombination().getKey().getCode();

    vTextField.addShortcutListener(
            new com.vaadin.event.ShortcutListener(listener.getCaption(), keyCode, modifiers) {
                @Override
                public void handleAction(Object sender, Object target) {
                    listener.handleShortcutPressed();
                }
            });
}