Example usage for com.vaadin.ui Notification getStyleName

List of usage examples for com.vaadin.ui Notification getStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Notification getStyleName.

Prototype

public String getStyleName() 

Source Link

Document

Gets the style name for the notification message.

Usage

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();/*www  .ja v a 2  s.  c  o 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());
    }
}