Example usage for com.vaadin.ui Notification setIcon

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

Introduction

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

Prototype

public void setIcon(Resource icon) 

Source Link

Document

Sets the icon part of the notification message.

Usage

From source file:com.toptal.ui.view.LoginView.java

License:Open Source License

/**
 * Error notification.//w  ww . j a v a 2  s.  com
 * @param message Message.
 */
private void error(final String message) {
    final int delay = 5000;
    final Notification notification = new Notification(message, Notification.Type.WARNING_MESSAGE);
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setIcon(FontAwesome.WARNING);
    notification.setDelayMsec(delay);
    notification.show(Page.getCurrent());
}

From source file:de.metas.ui.web.service.impl.VaadinWebProcessCtl.java

License:Open Source License

@Override
public void reportAsync(final ProcessInfo pi, final ActionEvent event) {
    final ASyncProcess asyncCtrl = new ASyncProcess() {
        private boolean locked = false;

        @Override//from w  w w.j  a  va2  s  .  co m
        public void lockUI(final ProcessInfo pi) {
            locked = true;

            final Notification notification = new Notification("Executing " + event.getAction().getCaption(),
                    Notification.Type.TRAY_NOTIFICATION);
            notification.setIcon(Theme.getVaadinResource(event.getAction().getIcon()));
            notification.show(Page.getCurrent());
        }

        @Override
        public void unlockUI(final ProcessInfo pi) {
            locked = false;
        }

        @Override
        public boolean isUILocked() {
            return locked;
        }

        @Override
        public void executeASync(final ProcessInfo pi) {
            logger.debug("executeASync: {}", pi);
        }
    };

    ProcessCtl.process(asyncCtrl, pi.getWindowNo(), pi, ITrx.TRX_None); // calls lockUI, unlockUI
}

From source file:edu.vserver.exercises.videoMcq.QuestionWindow.java

License:Apache License

/**
 * Sets a Notification about the correctness of the given answer to the browser window.
 * /*  ww  w  . jav  a 2  s  .  co  m*/
 * @param question latest answered question.
 */
private void informUser(Question question) {
    if (this.isInformative()) {
        Notification n;
        if (question.isCorrectAnswer()) {
            n = new Notification("CORRECT", Notification.Type.HUMANIZED_MESSAGE);
            n.setIcon(new ThemeResource(SPH_Theme.CORRECT_ICON_48PX));
            n.setStyleName("correctAnswer");
        } else {
            n = new Notification("INCORRECT", Notification.Type.HUMANIZED_MESSAGE);
            n.setIcon(new ThemeResource(SPH_Theme.INCORRECT_ICON_48PX));
            n.setStyleName("incorrectAnswer");
        }
        if (question.containsAnswerDescription()) {
            n.setDescription(question.getAnswerDescription());
            n.setDelayMsec(Notification.DELAY_FOREVER);
        } else {
            n.setDelayMsec(500);
        }
        n.setPosition(com.vaadin.shared.Position.MIDDLE_CENTER);
        n.show(Page.getCurrent());
    }

}

From source file:facs.components.BookAdmin.java

License:Open Source License

private void showErrorNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(15000);/*  w w  w . java 2 s. c o  m*/
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.FROWN_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:facs.components.BookAdmin.java

License:Open Source License

private void Notification(String title, String description, String type) {
    Notification notify = new Notification(title, description);
    notify.setPosition(Position.TOP_CENTER);
    if (type.equals("error")) {
        notify.setDelayMsec(16000);// w ww .  j  ava2s .  c  om
        notify.setIcon(FontAwesome.FROWN_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else if (type.equals("success")) {
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.SMILE_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else {
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.MEH_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    }
    notify.show(Page.getCurrent());
}

From source file:facs.components.Booking.java

License:Open Source License

private void showErrorNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(16000);/*  w w w. j ava2s .c  o m*/
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.FROWN_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:facs.components.Booking.java

License:Open Source License

private void showNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(8000);//from  ww  w  .j  a  v a  2  s  .  co m
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.MEH_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:facs.components.Booking.java

License:Open Source License

private void showSuccessfulNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(8000);//from   ww  w  .  ja  va  2s .com
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.SMILE_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:helpers.Utils.java

License:Open Source License

public static void Notification(String title, String description, String type) {
    Notification notify = new Notification(title, description);
    notify.setPosition(Position.TOP_CENTER);
    if (type.equals("error")) {
        notify.setDelayMsec(16000);//from w w w . j  a v  a2s.c  om
        notify.setIcon(FontAwesome.FROWN_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else if (type.equals("success")) {
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.SMILE_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else {
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.COMMENT);
        notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    }
    notify.show(Page.getCurrent());
}

From source file:life.qbic.utils.qOfferManagerUtils.java

License:Open Source License

/**
 * Displays a vaadin Notification with the respective title, description and type.
 * @param title: title of the displayNotification window
 * @param description: description of the displayNotification Window
 * @param type: one of "error", "success" and "warning". Changes the style and the delay of the displayNotification.
 *//*from www .j  a  v  a2s.  c om*/
public static void displayNotification(String title, String description, String type) {
    com.vaadin.ui.Notification notify = new com.vaadin.ui.Notification(title, description);
    notify.setPosition(Position.TOP_CENTER);
    switch (type) {
    case "error":
        notify.setDelayMsec(16000);
        notify.setIcon(FontAwesome.FROWN_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    case "success":
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.SMILE_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    case "warning":
        notify.setDelayMsec(16000);
        notify.setIcon(FontAwesome.MEH_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_WARNING + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    default:
        notify.setDelayMsec(16000);
        notify.setIcon(FontAwesome.MEH_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    }
    notify.show(Page.getCurrent());
}