/** * Set position of the notification. * <P> * * @param position * the position of the notification. Valid enumerate values are * {@code TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE, BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCH}, * not {@code null} */ public void setPosition(Position position) { setPosition(position.getClientName()); }
/** * Creates a Notification with given text String, duration and position * <P> * Set to {@code 0} or a negative number to disable the notification * auto-closing. * * @param text * the text of the notification * @param duration * the duration in milliseconds to show the notification * @param position * the position of the notification. Valid enumerate values are * TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE, * BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCH */ public Notification(String text, int duration, Position position) { initBaseElementsAndListeners(); setText(text); setDuration((double) duration); setPosition(position); }
@Override public void onNotificationAdded(Notification notification) { if (!isOpened()) { NotificationViewWithoutWrapper view = new NotificationViewWithoutWrapper(notification, holder); view.setWidth("200px"); com.vaadin.flow.component.notification.Notification notificationView = new com.vaadin.flow.component.notification.Notification(view); notificationView.setPosition(com.vaadin.flow.component.notification.Notification.Position.TOP_END); notificationView.setDuration(2000); notificationView.open(); } }
/** * Default constructor. Create an empty notification with component support * and non-auto-closing * <p> * Note: To mix text and child components in notification that also supports * child components, use the {@link Text} component for the textual parts. */ public Notification() { initBaseElementsAndListeners(); getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> deferredJob.accept(ui))); setPosition(DEFAULT_POSITION); setDuration(0); }