Example usage for com.vaadin.ui Notification setPosition

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

Introduction

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

Prototype

public void setPosition(Position position) 

Source Link

Document

Sets the position of the notification message.

Usage

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);//  w  ww .  j a v a  2s .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   w  w  w  .j a  va  2s.  com
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());
}

From source file:org.eclipse.hawkbit.ui.ErrorView.java

License:Open Source License

@Override
public void enter(final ViewChangeListener.ViewChangeEvent event) {
    final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName());
    if (view == null) {
        message.setValue(i18n.getMessage("message.error.view", event.getViewName()));
        return;/*from w  ww .  j a v a 2 s. co  m*/
    }
    if (dashboardMenu.isAccessDenied(event.getViewName())) {
        final Notification nt = new Notification("Access denied",
                i18n.getMessage("message.accessdenied.view", event.getViewName()), Type.ERROR_MESSAGE, false);
        nt.setStyleName(SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE);
        nt.setPosition(Position.BOTTOM_RIGHT);
        nt.show(UI.getCurrent().getPage());
        message.setValue(i18n.getMessage("message.accessdenied.view", event.getViewName()));
    }
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private void loginAuthenticationFailedNotification() {
    final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.description"));
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(1_000);/*from  w  ww . ja  v  a2 s .  c o  m*/
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private void loginCredentialsExpiredNotification() {
    final Notification notification = new Notification(
            i18n.getMessage("notification.login.failed.credentialsexpired.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description"));
    notification.setDelayMsec(10_000);/* www .  j  a va 2s  . com*/
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closeable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.LoginView.java

License:Open Source License

void loginAuthenticationFailedNotification() {
    final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.description"));
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(1000);/*www. j  a v  a2 s.  co  m*/
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.LoginView.java

License:Open Source License

void loginCredentialsExpiredNotification() {
    final Notification notification = new Notification(
            i18n.getMessage("notification.login.failed.credentialsexpired.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description"));
    notification.setDelayMsec(10000);//from  w w w  . j  av a2 s .  c  o  m
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closeable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.show(Page.getCurrent());
}

From source file:org.groom.shell.Shell.java

License:Apache License

/**
 * Executes requested shell command.//w  w w  . j a va  2 s.  c om
 *
 * @param cmd the shell command to execute
 */
public static String execute(final String cmd, final String path) {
    LOGGER.debug("Executing shell command: " + cmd);
    try {

        if (UI.getCurrent() != null) {
            Notification.show(cmd, Notification.Type.TRAY_NOTIFICATION);
        }

        List<String> commands = new ArrayList<String>();
        if (PropertiesUtil.getProperty("groom", "os").equals("windows")) {
            commands.add("cmd");
            commands.add("/c");
            commands.add(cmd);
        } else {
            commands.add("/bin/sh");
            commands.add("-c");
            commands.add(cmd);
        }

        SystemCommandExecutor commandExecutor = new SystemCommandExecutor(path, commands);
        commandExecutor.executeCommand();

        StringBuilder errorOutput = commandExecutor.getErrorOutput();
        if (errorOutput.length() > 0) {
            LOGGER.error(errorOutput);
            {
                if (UI.getCurrent() != null) {
                    final Notification notification = new Notification("Shell", errorOutput.toString(),
                            Notification.Type.WARNING_MESSAGE);
                    notification.setDelayMsec(5000);
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            }
        }
        StringBuilder standardOutput = commandExecutor.getStandardOutput();
        if (standardOutput == null) {
            return "";
        }

        return standardOutput.toString();
    } catch (final Throwable t) {
        LOGGER.error("Error executing shell command: " + cmd, t);
        return "";
    }
}

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();/*  w ww.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());
    }
}

From source file:ru.inovus.ui.SignInUI.java

License:Apache License

private void notification() {
    Notification notification = new Notification("!");
    notification.setDescription(// w  ww. ja  va 2s . c o m
            "<span> ??  ?  <b>User</b>  <b>password</b>.</span>");
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("tray dark small closable login-help");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(20000);
    notification.show(Page.getCurrent());
}