Java Code Examples for com.vaadin.ui.Button#setClickShortcut()

The following examples show how to use com.vaadin.ui.Button#setClickShortcut() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebComponentsHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static void setClickShortcut(Button button, String shortcut) {
    KeyCombination closeCombination = KeyCombination.create(shortcut);
    int[] closeModifiers = Modifier.codes(closeCombination.getModifiers());
    int closeCode = closeCombination.getKey().getCode();

    button.setClickShortcut(closeCode, closeModifiers);
}
 
Example 2
Source File: AbstractHawkbitLoginUI.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void buildSignInButton() {
    final String caption = isDemo ? i18n.getMessage("button.login.agreeandsignin")
            : i18n.getMessage("button.login.signin");

    signIn = new Button(caption);
    signIn.addStyleName(ValoTheme.BUTTON_PRIMARY + " " + ValoTheme.BUTTON_SMALL + " " + "login-button");
    signIn.setClickShortcut(KeyCode.ENTER);
    signIn.focus();
    signIn.setId("login-signin");
}
 
Example 3
Source File: ConfirmationDialog.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button createCancelButton(final String cancelLabel) {
    final Button button = SPUIComponentProvider.getButton(UIComponentIdProvider.CANCEL_BUTTON, cancelLabel, "",
            null, false, null, SPUIButtonStyleTiny.class);
    button.addClickListener(this);
    button.setClickShortcut(KeyCode.ESCAPE);
    return button;
}
 
Example 4
Source File: ConfirmationDialog.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button createOkButton(final String okLabel) {
    final Button button = SPUIComponentProvider.getButton(UIComponentIdProvider.OK_BUTTON, okLabel, "",
            ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
    button.addClickListener(this);
    button.setClickShortcut(KeyCode.ENTER);
    return button;
}
 
Example 5
Source File: ConfirmDialog.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
public ConfirmDialog(String caption, String message, String okButtonText, String cancelButtonText)
{
    super(caption);
    super.setModal(true);
    super.setClosable(false);
    super.setResizable(false);
    
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(true);
    
    // confirmation message
    windowLayout.addComponent(new Label(message, ContentMode.HTML));
    windowLayout.setSpacing(true);
    
    // buttons
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100.0f, Unit.PERCENTAGE);
    windowLayout.addComponent(buttonsLayout);
    
    okButton = new Button(okButtonText);
    buttonsLayout.addComponent(okButton);
    okButton.setTabIndex(1);
    okButton.addClickListener(this);
    buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
            
    cancelButton = new Button(cancelButtonText);
    buttonsLayout.addComponent(cancelButton);
    cancelButton.setTabIndex(0);
    cancelButton.setClickShortcut(KeyCode.ESCAPE, null);
    cancelButton.addClickListener(this);
    buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
            
    super.setContent(windowLayout);
}
 
Example 6
Source File: LoginView.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
protected HorizontalLayout createCompositionRootx() {
    VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSpacing(true);
    loginPanel.setWidth("400px");

    Label header = new Label("Enter your invitation to start the questionnair");
    header.addStyleName(Reindeer.LABEL_H1);
    loginPanel.addComponent(header);

    invitation = new TextField("Invitation");
    invitation.setWidth("100%");
    invitation.focus();
    invitation.setValue("YAS5ICHRBE");
    loginPanel.addComponent(invitation);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    loginPanel.addComponent(buttons);
    loginPanel.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);

    login = new Button("Start");
    login.setClickShortcut(KeyCode.ENTER);
    login.addStyleName(Reindeer.BUTTON_DEFAULT);
    login.addClickListener(createLoginButtonListener());
    buttons.addComponent(login);

    HorizontalLayout viewLayout = new HorizontalLayout();
    viewLayout.addComponent(loginPanel);
    viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    viewLayout.setSizeFull();
    viewLayout.addStyleName(Reindeer.LAYOUT_BLUE);
    setSizeFull();

    return viewLayout;
}
 
Example 7
Source File: WinLogin.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attach() {
    // Window
    setIcon(Icons.LOGIN.resource());
    setCaption(ViewProperties.getCaption("window.login"));
    setModal(true);
    setWidth("300px");
    setResizable(false);
    setClosable(false);

    // Layout
    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    // Form
    Form form = new Form();
    form.addStyleName("form-login");

    // ユーザ名
    usernameField = new TextField(ViewProperties.getCaption("field.userName"));
    usernameField.setWidth("90%");
    usernameField.focus(); // フォーカスを設定
    usernameField.setRequired(true);
    usernameField.setRequiredError(ViewMessages.getMessage("IUI-000019"));
    form.getLayout().addComponent(usernameField);

    // パスワード
    passwordField = new TextField(ViewProperties.getCaption("field.password"));
    passwordField.setSecret(true);
    passwordField.setWidth("90%");
    passwordField.setRequired(true);
    passwordField.setRequiredError(ViewMessages.getMessage("IUI-000020"));
    form.getLayout().addComponent(passwordField);

    layout.addComponent(form);

    // ログインボタン
    Button loginButton = new Button(ViewProperties.getCaption("button.login"));
    loginButton.setDescription(ViewProperties.getCaption("description.login"));
    loginButton.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            loginButtonClick(event);
        }
    });
    loginButton.setClickShortcut(KeyCode.ENTER);

    layout.addComponent(loginButton);
    layout.setComponentAlignment(loginButton, "right");
}