Example usage for com.vaadin.v7.ui VerticalLayout addStyleName

List of usage examples for com.vaadin.v7.ui VerticalLayout addStyleName

Introduction

In this page you can find the example usage for com.vaadin.v7.ui VerticalLayout addStyleName.

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:info.magnolia.vaadin.periscope.Periscope.java

License:Open Source License

private Component createSpeechButton() {
    final Button startStopButton = new Button();
    startStopButton.addStyleName("record-button");
    startStopButton.setCaptionAsHtml(true);
    startStopButton.setCaption("<span class=\"ion-mic-a\"></span>");
    startStopButton.setClickShortcut(ShortcutAction.KeyCode.R, ShortcutAction.ModifierKey.SHIFT,
            ShortcutAction.ModifierKey.ALT);

    final AtomicBoolean isRecording = new AtomicBoolean(false);

    speechRecognizer.addSpeechResultListener(transcript -> {
        input.setValue(transcript);//from  www .  ja v  a2  s.  c om
        this.consumeQuery(transcript, true);

        startStopButton.removeStyleName("recording");
        isRecording.set(false);
    });

    startStopButton.addClickListener((Button.ClickListener) event -> {
        if (isRecording.get()) {
            return;
        }

        speechRecognizer.record();

        startStopButton.addStyleName("recording");
        isRecording.set(true);
    });

    final VerticalLayout speechWrapper = new VerticalLayout(startStopButton, speechRecognizer);
    speechWrapper.addStyleName("speech-recognition");
    return speechWrapper;
}