Example usage for com.vaadin.ui Notification setDelayMsec

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

Introduction

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

Prototype

public void setDelayMsec(int delayMsec) 

Source Link

Document

Sets the delay before the notification disappears.

Usage

From source file:com.cms.component.CommonFunction.java

public static void showError(String message) {
    Notification noti = new Notification(message);
    noti.setDelayMsec(1500);
    Notification.show(message, Notification.Type.ERROR_MESSAGE);
}

From source file:com.cms.component.CommonFunctionTableFilter.java

public static void showMessage(String message) {
    Notification noti = new Notification(message);
    noti.setDelayMsec(1500);
    noti.show(message);//from  w  w w.j  av  a  2  s. c o m
}

From source file:com.esofthead.mycollab.vaadin.ui.NotificationUtil.java

License:Open Source License

public static void showNotification(String caption, String description, Type type) {
    Notification warnNotif = new Notification(caption, description, type);
    warnNotif.setHtmlContentAllowed(true);
    warnNotif.setDelayMsec(3000);

    if (Page.getCurrent() != null) {
        warnNotif.show(Page.getCurrent());
    } else {/*from   w  ww  .j  a va  2  s  .c o m*/
        LOG.error("Current page is null");
    }

}

From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java

License:Open Source License

private void displayTrayNotification(AbstractNotification item) {
    if (item instanceof NewUpdateAvailableNotification) {
        NewUpdateAvailableNotification updateNo = (NewUpdateAvailableNotification) item;
        Notification no;
        if (AppContext.isAdmin()) {
            no = new Notification(AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    AppContext.getMessage(
                            ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion())
                            + " "
                            + new A("javascript:com.mycollab.scripts.upgrade('" + updateNo.getVersion() + "','"
                                    + updateNo.getAutoDownloadLink() + "','" + updateNo.getManualDownloadLink()
                                    + "')").appendText(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE)),
                    Notification.Type.TRAY_NOTIFICATION);
        } else {//w ww.j  a  v a 2  s  . c o  m
            no = new Notification(AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion()),
                    Notification.Type.TRAY_NOTIFICATION);
        }

        no.setHtmlContentAllowed(true);
        no.setDelayMsec(300000);

        UI currentUI = UI.getCurrent();
        if (currentUI != null) {
            if (SiteConfiguration.getPullMethod() == SiteConfiguration.PullMethod.push) {
                no.show(currentUI.getPage());
                currentUI.push();
            } else {
                try {
                    UI.getCurrent().setPollInterval(1000);
                    no.show(currentUI.getPage());
                } finally {
                    UI.getCurrent().setPollInterval(-1);
                }
            }
        }
    }
}

From source file:com.foc.vaadin.FocWebEnvironment.java

License:Apache License

@Override
public void showNotification(String notificationMessage, String description, int notificationType, int delay,
        String styleName) {/* w  w w. jav  a  2 s . co m*/
    try {
        if (Globals.getApp() != null && Globals.getApp().isUnitTest()
                && FocUnitDictionary.getInstance() != null) {
            FocUnitDictionary.getInstance().expectedNotification_Occured(notificationMessage, description,
                    notificationType);
        } else {
            FocWebSession focWebSession = FocWebApplication.getFocWebSession_Static();
            if (focWebSession == null || focWebSession.isNotificationEnabled()) {
                Notification.Type type = Notification.Type.ERROR_MESSAGE;
                if (notificationType == IFocEnvironment.TYPE_ERROR_MESSAGE) {
                    FocLogger.getInstance().addError("Error Popup: " + notificationMessage + " " + description);
                } else if (notificationType == IFocEnvironment.TYPE_WARNING_MESSAGE) {
                    FocLogger.getInstance()
                            .addWarning("Warning Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.WARNING_MESSAGE;
                } else if (notificationType == IFocEnvironment.TYPE_HUMANIZED_MESSAGE) {
                    FocLogger.getInstance().addInfo("Info Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.HUMANIZED_MESSAGE;
                } else if (notificationType == IFocEnvironment.TYPE_TRAY_NOTIFICATION) {
                    FocLogger.getInstance().addInfo("Tray Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.TRAY_NOTIFICATION;
                }
                Notification notification = new Notification(notificationMessage, description, type);
                notification.setDelayMsec(delay);

                if (!Utils.isStringEmpty(styleName))
                    notification.setStyleName(styleName);
                if (Page.getCurrent() != null) {
                    notification.show(Page.getCurrent());
                }
                /*
                FancyNotifications fancyNotifications = new FancyNotifications();
                fancyNotifications.setPosition(Position.BOTTOM_RIGHT);
                        
                FancyNotification fancyNotification = new FancyNotification(null, notificationMessage, description);
                fancyNotification.getTitleLabel().setContentMode(ContentMode.HTML);
                fancyNotification.getDescriptionLabel().setContentMode(ContentMode.HTML);
                fancyNotification.addLayoutClickListener(notificationClickEvent -> Page.getCurrent().setLocation("https://github.com/alump/FancyLayouts"));
                fancyNotifications.showNotification(fancyNotification);
                */
            }
        }
    } catch (Exception e) {
        Globals.logExceptionWithoutPopup(e);
    }
    //    Notification.show(notificationMessage, description, type);
}

From source file:com.haulmont.cuba.web.LoginWindow.java

License:Apache License

protected void login() {
    String login = loginField.getValue();
    String password = passwordField.getValue() != null ? passwordField.getValue() : "";

    if (StringUtils.isEmpty(login) || StringUtils.isEmpty(password)) {
        String message = messages.getMainMessage("loginWindow.emptyLoginOrPassword", resolvedLocale);
        Notification notification = new Notification(message, Type.WARNING_MESSAGE);
        notification.setDelayMsec(WebWindowManager.WARNING_NOTIFICATION_DELAY_MSEC);
        notification.show(ui.getPage());
        return;/*from   ww  w .  j a  va  2 s.c om*/
    }

    if (!bruteForceProtectionCheck(login, app.getClientAddress())) {
        return;
    }

    try {
        Locale locale = getUserLocale();
        app.setLocale(locale);

        PasswordEncryption passwordEncryption = AppBeans.get(PasswordEncryption.NAME);

        if (loginByRememberMe && rememberMeAllowed) {
            loginByRememberMe(login, password, locale);
        } else if (configuration.getConfig(WebAuthConfig.class).getExternalAuthentication()) {
            // try to login as externally authenticated user, fallback to regular authentication
            // we use resolved locale for error messages
            if (authenticateExternally(login, password, resolvedLocale)) {
                login = convertLoginString(login);

                ((ExternallyAuthenticatedConnection) connection).loginAfterExternalAuthentication(login,
                        locale);
            } else {
                login(login, passwordEncryption.getPlainHash(password), locale);
            }
        } else {
            login(login, passwordEncryption.getPlainHash(password), locale);
        }
        // locale could be set on the server
        if (connection.getSession() != null) {
            app.setLocale(connection.getSession().getLocale());
            if (globalConfig.getLocaleSelectVisible()) {
                app.addCookie(COOKIE_LOCALE, locale.toLanguageTag());
            }
        }
    } catch (LoginException e) {
        log.info("Login failed: {}", e.toString());

        String message = StringUtils.abbreviate(e.getMessage(), 1000);
        String bruteForceMsg = registerUnsuccessfulLoginAttempt(login, app.getClientAddress());
        if (!Strings.isNullOrEmpty(bruteForceMsg)) {
            message = bruteForceMsg;
        }
        showLoginException(message);
    } catch (Exception e) {
        log.warn("Unable to login", e);
        showException(e);
    }
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

protected void setNotificationDelayMsec(Notification notification, NotificationType type) {
    switch (type) {
    case HUMANIZED:
    case HUMANIZED_HTML:
        notification.setDelayMsec(HUMANIZED_NOTIFICATION_DELAY_MSEC);
        break;/*ww  w .  j  av  a 2  s .  c  o  m*/
    case WARNING:
    case WARNING_HTML:
        notification.setDelayMsec(WARNING_NOTIFICATION_DELAY_MSEC);
        break;
    }
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
protected void checkCanOpenWindow(WindowInfo windowInfo, OpenType openType, Map<String, Object> params) {
    if (openType.getOpenMode() != OpenMode.NEW_TAB && openType.getOpenMode() != OpenMode.NEW_WINDOW) {
        return;//from w w w  .ja va  2s  . c  o m
    }

    if (!windowInfo.getMultipleOpen() && getWindow(getHash(windowInfo, params)) != null) {
        //window is already open
        return;
    }

    int maxCount = webConfig.getMaxTabCount();
    if (maxCount > 0 && maxCount <= tabs.size()) {
        Notification notification = new Notification(
                messages.formatMainMessage("tooManyOpenTabs.message", maxCount),
                Notification.Type.WARNING_MESSAGE);
        notification.setDelayMsec(WARNING_NOTIFICATION_DELAY_MSEC);
        notification.show(ui.getPage());

        throw new SilentException();
    }
}

From source file:com.klwork.explorer.NotificationManager.java

License:Apache License

public void showWarningNotification(String captionKey, String descriptionKey, Object... params) {
    Notification notification = new Notification(i18nManager.getMessage(captionKey) + "<br/>",
            MessageFormat.format(i18nManager.getMessage(descriptionKey), params),
            Notification.Type.WARNING_MESSAGE);
    notification.setDelayMsec(5000); // click to hide
    notification.show(Page.getCurrent());
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private void showNotification(Notification notification) {
    // keep the notification visible a little while after moving the
    // mouse, or until clicked
    notification.setDelayMsec(2000);
    notification.show(Page.getCurrent());
}