/** * Shows a notification message. * * @see Notification * * @param notification * The notification message to show * * @deprecated As of 7.0, use Notification.show(Page) instead. */ @Deprecated public void showNotification(Notification notification) { notification.show(this); }
public static Notification build(final String caption, final String description, final int delayMsec, final boolean htmlContentAllowed) { Notification notification = new Notification(caption); notification.setDescription(description); notification.setStyleName("tray dark small closable login-help"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(delayMsec); notification.setHtmlContentAllowed(htmlContentAllowed); return notification; }
/** * Creates a notification message of the specified type, with a bigger * caption and smaller description. * * Care should be taken to to avoid XSS vulnerabilities if html is allowed. * * @param caption * The message caption * @param description * The message description * @param type * The type of message * @param htmlContentAllowed * Whether html in the caption and description should be * displayed as html or as plain text */ public Notification(String caption, String description, Type type, boolean htmlContentAllowed) { registerRpc(rpc); setCaption(caption); setDescription(description); setHtmlContentAllowed(htmlContentAllowed); setType(type); }
private void setType(Type type) { setStyleName(type.getStyle()); switch (type) { case WARNING_MESSAGE: setDelayMsec(1500); break; case ERROR_MESSAGE: setDelayMsec(DELAY_FOREVER); break; case TRAY_NOTIFICATION: setDelayMsec(3000); setPosition(Position.BOTTOM_RIGHT); break; case ASSISTIVE_NOTIFICATION: setDelayMsec(3000); setPosition(Position.ASSISTIVE); break; case HUMANIZED_MESSAGE: default: break; } }
/** * Shows a notification message on the middle of the current page. The * message automatically disappears ("humanized message"). * * The caption is rendered as plain text with HTML automatically escaped. * * @see #Notification(String) * @see #show(Page) * * @param caption * The message * @return The Notification */ public static Notification show(String caption) { Notification notification = new Notification(caption); notification.extend(UI.getCurrent()); return notification; }
public static void showNotification(String title, String message, Type type, int delayMsec) { Notification notification = new Notification(title, message, type, true); notification.setDelayMsec(delayMsec); notification.show(Page.getCurrent()); }
@Override public void run() { if(!AnnisBaseUI.handleCommonError(ex, "get corpus configurations")) { new Notification(ERROR_MESSAGE_CORPUS_PROPS_HEADER, ERROR_MESSAGE_CORPUS_PROPS, Notification.Type.WARNING_MESSAGE, true). show(Page.getCurrent()); } } });
/** * Method for displaying notification for the user. * * @param message the message to be displayed * @param description the description of this message * @param type the type of this notification */ public void notifyMessage(String message, String description, Notification.Type type) { Notification notification = new Notification("Message", type); notification.setCaption(message); notification.setDescription(description); notification.setDelayMsec(1000); if (getUI() != null) { if (getPage() != null) { notification.show(getUI().getPage()); } } }
@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; } 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())); } }
@Override public void attach() { super.attach(); Object previousSessionError = getSession().getSession().getAttribute("PrevSessionError"); if (previousSessionError != null) { Notification notification = new Notification(previousSessionError.toString(), Notification.Type.ERROR_MESSAGE); notification.setDelayMsec(-1); notification.show(getUI().getPage()); getSession().getSession().setAttribute("PrevSessionError", null); } }
@Override public void show() { com.vaadin.ui.Notification vNotification = new com.vaadin.ui.Notification(caption, description, convertType(notificationType)); if (hideDelayMs != DELAY_DEFAULT) { vNotification.setDelayMsec(hideDelayMs); } else { setNotificationDelayMsec(vNotification, notificationType); } if (position != Position.DEFAULT) { vNotification.setPosition(com.vaadin.shared.Position.valueOf(position.name())); } vNotification.setHtmlContentAllowed(contentMode == ContentMode.HTML); if (styleName != null) { vNotification.setStyleName(styleName); } vNotification.show(ui.getPage()); } }
@Override public void buttonClick(ClickEvent clickEvent) { platformConfigurationService.saveConfigurationValue (ConfigurationConstants.DASHBOARD_BASE_URL, dashboardBaseUrl.getValue()); platformConfigurationService.saveWebServiceUsername(usernameField.getValue()); platformConfigurationService.saveWebServicePassword(passwordField.getValue()); Notification notification = new Notification( "Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } });
@Override public void buttonClick(ClickEvent event) { String caption = "Help"; if(getCaption() != null && !getCaption().isEmpty()) { caption = "Help for \"" + getCaption(); } caption = caption + "<br/><br/>(Click here to close)"; Notification notify = new Notification(caption, Notification.Type.HUMANIZED_MESSAGE); notify.setHtmlContentAllowed(true); notify.setDescription(field.getDescription()); notify.setDelayMsec(-1); notify.show(UI.getCurrent().getPage()); }
@Override public void validationStatusChange(ValidationStatusEvent<?> statusChangeEvent) { if (statusChangeEvent.isInvalid()) { String error = showAllErrors ? statusChangeEvent.getErrorMessages().stream().collect(Collectors.joining("<br/>")) : statusChangeEvent.getErrorMessage(); if (error == null || error.trim().equals("")) { error = "Validation error"; } if (notification != null) { notification.setCaption(error); notification.show(Page.getCurrent()); } else { Notification.show(error, Type.ERROR_MESSAGE); } } }
/** * Shows a notification message on the middle of the UI. The message * automatically disappears ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption is * rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message * * @deprecated As of 7.0, use Notification.show instead but be aware that * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption) { Notification notification = new Notification(caption); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * Shows a notification consisting of a bigger caption and a smaller * description. The position and behavior of the message depends on the * type, which is one of the basic types defined in {@link Notification} , * for instance Notification.TYPE_WARNING_MESSAGE. * * Care should be taken to avoid XSS vulnerabilities if html content is * allowed. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message caption * @param description * The message description * @param type * The type of message * @param htmlContentAllowed * Whether html in the caption and description should be * displayed as html or as plain text * * @deprecated As of 7.0, use new Notification(...).show(Page). */ @Deprecated public void showNotification(String caption, String description, Notification.Type type, boolean htmlContentAllowed) { getPage().showNotification(new Notification(caption, description, type, htmlContentAllowed)); }
protected void setNotificationDelayMsec(com.vaadin.ui.Notification notification, NotificationType type) { if (type == NotificationType.HUMANIZED) { notification.setDelayMsec(HUMANIZED_NOTIFICATION_DELAY_MSEC); } else if (type == NotificationType.WARNING) { notification.setDelayMsec(WARNING_NOTIFICATION_DELAY_MSEC); } }
public static void showNotification(String title, String message, Type type, int delayMsec) { Notification notification = new Notification(title, message, type, true); notification.setDelayMsec(delayMsec); notification.show(Page.getCurrent()); }
public OutputStream receiveUpload(final String filename, final String mimeType) { try { this.mimeType = mimeType; this.file = File.createTempFile(filePrefix, filename); return new FileOutputStream(file); } catch (final java.io.FileNotFoundException e) { new Notification("Could not open file<br/>", e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(Page.getCurrent()); return null; } catch (final java.io.IOException e) { new Notification("System problem uploading file<br/>", e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(Page.getCurrent()); return null; } }
/** * Method for displaying notification for the user. * * @param message the message to be displayed * @param description the description of this message */ public void notifyMessage(String message, String description) { final Notification notification = new Notification("Message", Notification.Type.TRAY_NOTIFICATION); notification.setCaption(message); notification.setDescription(description); notification.setDelayMsec(1000); if (getUI() != null) { if (getPage() != null) { notification.show(getUI().getPage()); } } } }