Example usage for com.vaadin.ui.themes ValoTheme NOTIFICATION_FAILURE

List of usage examples for com.vaadin.ui.themes ValoTheme NOTIFICATION_FAILURE

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme NOTIFICATION_FAILURE.

Prototype

String NOTIFICATION_FAILURE

To view the source code for com.vaadin.ui.themes ValoTheme NOTIFICATION_FAILURE.

Click Source Link

Document

Failure notification style.

Usage

From source file:de.fatalix.app.view.login.LoginView.java

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();/*  ww  w .  j a  va 2  s.  c o  m*/
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField("Username", "admin"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField("Password"));
    password.setWidth(15, Unit.EM);
    password.setDescription("Write anything");
    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);

    buttons.addComponent(login = new Button("Login"));
    login.setDisableOnClick(true);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.doLogin(username.getValue(), password.getValue());
            } catch (AuthenticationException ex) {
                LoginView.this.showNotification(
                        new Notification("Wrong login", Notification.Type.ERROR_MESSAGE),
                        ValoTheme.NOTIFICATION_FAILURE);
            } finally {
                login.setEnabled(true);
            }
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    buttons.addComponent(forgotPassword = new Button("Forgot password?"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            showNotification(new Notification("Hint: Try anything", Notification.Type.HUMANIZED_MESSAGE),
                    ValoTheme.NOTIFICATION_SUCCESS);
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    return loginForm;
}

From source file:de.fatalix.bookery.view.login.LoginView.java

License:Open Source License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();//from  w w  w.j  av a 2s  .c o m
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField("Username", "admin"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField("Password"));
    password.setWidth(15, Unit.EM);
    password.setDescription("");

    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);
    login = new Button("login");
    buttons.addComponent(login);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.doLogin(username.getValue(), password.getValue());
            } catch (AuthenticationException ex) {
                LoginView.this.showNotification(
                        new Notification("Wrong login", Notification.Type.ERROR_MESSAGE),
                        ValoTheme.NOTIFICATION_FAILURE);
            } finally {
                login.setEnabled(true);
            }
        }
    });
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    buttons.addComponent(forgotPassword = new Button("Forgot password?"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            showNotification(new Notification("Hint: Ask me", Notification.Type.HUMANIZED_MESSAGE),
                    ValoTheme.NOTIFICATION_SUCCESS);
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    Panel loginPanel = new Panel(loginForm);
    loginPanel.setWidthUndefined();
    loginPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    loginPanel.addAction(new ShortcutListener("commit", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            try {
                presenter.doLogin(username.getValue(), password.getValue());
            } catch (AuthenticationException ex) {
                LoginView.this.showNotification(
                        new Notification("Wrong login", Notification.Type.ERROR_MESSAGE),
                        ValoTheme.NOTIFICATION_FAILURE);
            }
        }
    });
    return loginPanel;
}

From source file:dhbw.clippinggorilla.utilities.ui.VaadinUtils.java

public static void errorNotification(String caption, String description) {
    Notification not = new Notification(caption, null, Notification.Type.TRAY_NOTIFICATION, true);
    not.setDelayMsec(1000);/*www.j  ava  2 s. c  o  m*/
    not.setPosition(Position.TOP_CENTER);
    not.setStyleName(ValoTheme.NOTIFICATION_FAILURE + " " + ValoTheme.NOTIFICATION_SMALL);
    not.show(Page.getCurrent());
}

From source file:org.jumpmind.vaadin.ui.common.CommonUiUtils.java

License:Open Source License

public static void notify(String caption, String message, Throwable ex, Type type) {
    Page page = Page.getCurrent();//from w  w  w.  j a  v  a2 s.  co m
    if (page != null) {
        Notification notification = new Notification(caption,
                contactWithLineFeed(FormatUtils.wordWrap(message, 150)), Type.HUMANIZED_MESSAGE);
        notification.setPosition(Position.MIDDLE_CENTER);
        notification.setDelayMsec(-1);

        String style = ValoTheme.NOTIFICATION_SUCCESS;
        if (type == Type.ERROR_MESSAGE) {
            style = ValoTheme.NOTIFICATION_FAILURE;
        } else if (type == Type.WARNING_MESSAGE) {
            style = ValoTheme.NOTIFICATION_WARNING;
        }
        notification.setStyleName(
                notification.getStyleName() + " " + ValoTheme.NOTIFICATION_CLOSABLE + " " + style);
        notification.show(Page.getCurrent());
    }
}