List of usage examples for com.vaadin.ui Notification setDescription
public void setDescription(String description)
From source file:annis.gui.components.HelpButton.java
License:Apache License
@Override public void buttonClick(ClickEvent event) { String caption = "Help"; if (getCaption() != null && !getCaption().isEmpty()) { caption = "Help for \"" + getCaption(); }/* ww w . j ava 2 s.c o m*/ 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()); }
From source file:by.bigvova.ui.LoginUI.java
License:Apache License
private void notification() { Notification notification = new Notification("Welcome to Dashboard Demo"); notification.setDescription( "<span>This application is not real, it only demonstrates an application built with the <a href=\"https://vaadin.com\">Vaadin framework</a>.</span> <span>No username or password is required, just click the <b>Sign In</b> button to continue.</span>"); notification.setHtmlContentAllowed(true); notification.setStyleName("tray dark small closable login-help"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(20000);/* w w w .ja v a 2 s . co m*/ notification.show(Page.getCurrent()); }
From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationController.java
License:Open Source License
public ReservationController(DataModel dataModel, ReservationView reservationView, Navigator navigator) { this.dataModel = dataModel; this.reservationView = reservationView; this.navigator = navigator; reservationView.getLogoutButton().addClickListener(clickEvent -> { // Logout the user / end the session VaadinSession.getCurrent().setAttribute("user", null); // Refresh this view, the navigator should redirect to login view$ navigator.navigateTo(LoginView.NAME); });//w w w. ja v a 2 s . co m reservationView.getRoomSelect() .addValueChangeListener(e -> roomNumber = Integer.parseInt(e.getProperty().getValue().toString())); for (int i = 1; i < dataModel.getRooms().size() + 1; i++) { reservationView.getRoomSelect().addItem(i); reservationView.getRoomSelect().setItemCaption(i, "Room " + i); } reservationView.getMakeReservationButton().addClickListener(clickEvent -> { Date begin = reservationView.getFromField().getValue(); Date end = reservationView.getToField().getValue(); SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Notification notification = new Notification(""); notification.setDelayMsec(2000); String username = String.valueOf(VaadinSession.getCurrent().getAttribute("user")); try { Customer customer = dataModel.getCustomer(username); Room room = dataModel.getRoom(roomNumber); dataModel.addReservation(customer, room, begin, end); notification.setCaption("Success"); notification.setDescription("Added reservation for: " + username + ", Room Nr.: " + roomNumber + ", From: " + df.format(begin) + " until " + df.format(end)); notification.show(Page.getCurrent()); try { createList(username); } catch (Exception e) { e.printStackTrace(); } } catch (IllegalArgumentException iae) { notification.setCaption("Error!"); notification.setDescription("Please check the entries you made for your reservation."); notification.show(Page.getCurrent()); } catch (RuntimeException re) { notification.setCaption("Error!"); notification.setDescription("Room couldn't be found.\nCurrently available rooms: " + dataModel.getRooms().stream().map(Object::toString).collect(Collectors.joining(", ")) .replaceAll("[^\\d , ][^\\@]*\\@", "")); notification.show(Page.getCurrent()); } catch (Exception e) { notification.setCaption("Error!"); notification.setDescription("There already exists a reservation for the chosen time range."); notification.show(Page.getCurrent()); } }); reservationView.getLogoutButton().addClickListener(clickEvent -> { reservationView.getFromField().clear(); reservationView.getToField().clear(); reservationView.getRoomSelect().clear(); }); }
From source file:ch.bfh.ti.soed.hs16.srs.black.view.signUpView.SignUpController.java
License:Open Source License
public void addUser(Button.ClickEvent event) { String username = signUpView.getUsernameField().getValue(); String password = signUpView.getPasswordField().getValue(); String passwordRepeat = signUpView.getPasswordFieldRepeat().getValue(); Notification alertNf = new Notification(""); alertNf.setDelayMsec(2000);// w w w. j a va2 s.com if (username.isEmpty() || password.isEmpty() || passwordRepeat.isEmpty()) { alertNf.setCaption("Please fill out the complete form!"); alertNf.show(Page.getCurrent()); } else if (!password.equals(passwordRepeat)) { alertNf.setCaption("The given passwords aren't identical!"); alertNf.show(Page.getCurrent()); signUpView.getPasswordFieldRepeat().clear(); signUpView.getPasswordFieldRepeat().focus(); } else { try { dataModel.addCustomer(username, password); navigator.navigateTo(ReservationView.NAME); alertNf.setCaption("Account: " + username + " has been successfully created."); alertNf.setDescription("You can now login with your credentials."); alertNf.show(Page.getCurrent()); } catch (IllegalStateException e) { alertNf.setCaption("User already exists!"); alertNf.setDescription("Please enter a different username."); alertNf.show(Page.getCurrent()); signUpView.getUsernameField().focus(); } finally { signUpView.getUsernameField().clear(); signUpView.getPasswordField().clear(); signUpView.getPasswordFieldRepeat().clear(); } } }
From source file:com.jain.addon.component.upload.JUploader.java
License:Apache License
protected void interruptUpload() { upload.interruptUpload();//from w ww . j a v a 2 s .c om I18NProvider provider = ((I18NUI) getUI()).getI18nProvider(); Notification n = new Notification(provider.getTitle(getLocale(), interruptionMessage), Type.TRAY_NOTIFICATION); n.setPosition(Position.MIDDLE_CENTER); n.setDescription(provider.getMessage(getLocale(), interruptionMessage)); n.show(getUI().getPage()); pi.setVisible(false); upload.setVisible(true); }
From source file:com.jain.addon.helper.JNHelper.java
License:Apache License
/** * Method to create Notification//from w ww. j a v a2 s . c o m * @param currentUI * @param title * @param message * @param params * @return Notification */ public static Notification createNotification(UI currentUI, String title, String message, Object... params) { I18NProvider provider = null; if (currentUI instanceof I18NUI) provider = ((I18NUI) currentUI).getI18nProvider(); else provider = DefaultI18NResourceProvider.instance(); Notification notification = new Notification(provider.getTitle(currentUI.getLocale(), title, params), Notification.Type.TRAY_NOTIFICATION); notification.setPosition(Position.MIDDLE_CENTER); notification.setDescription(provider.getMessage(currentUI.getLocale(), message, params)); return notification; }
From source file:com.jain.common.VaadinHelper.java
License:Apache License
public static Notification createNotificationMessage(String title, String message, Object... params) { I18NProvider provider = DefaultI18NResourceProvider.instance(); AuthenticatedUser currentUser = CDIComponent.getInstance(AuthenticatedUser.class); Notification n = new Notification(provider.getTitle(currentUser.getLocale(), title, params), Notification.Type.TRAY_NOTIFICATION); n.setPosition(Position.MIDDLE_CENTER); n.setDescription(provider.getMessage(currentUser.getLocale(), message, params)); return n;/*from w w w . j a va 2 s . c o m*/ }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java
public LoginView() { System.out.println("LOAD LLOGIN"); setSizeFull();// w w w.ja v a2 s .co m Component loginForm = buildLoginForm(); addComponent(loginForm); setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER); Notification notification = new Notification("Welcome to Dashboard Demo"); notification.setDescription( "<span>This application is not real, it only demonstrates an application built with the <a href=\"https://vaadin.com\">Vaadin framework</a>.</span> <span>No username or password is required, just click the <b>Sign In</b> button to continue.</span>"); notification.setHtmlContentAllowed(true); notification.setStyleName("tray dark small closable login-help"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(20000); notification.show(Page.getCurrent()); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPage2.java
License:Open Source License
@Override public boolean actionPlanEditBeginEvent(Serializable apId, String msg) { if (apId != this.apId) return false; if (imAuthor) { Notification notif = new Notification("", "", Notification.Type.HUMANIZED_MESSAGE); notif.setPosition(Position.TOP_LEFT); notif.setStyleName("m-actionplan-edit-notification"); notif.setDelayMsec(3000); // 3 secs to disappear notif.setCaption(""); notif.setDescription(msg); notif.show(Page.getCurrent());/*from w ww. j a v a 2 s . co m*/ return true; } return false; }
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. * /*from w ww. ja va 2s . c o 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()); } }