Example usage for com.vaadin.ui Notification setCaption

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

Introduction

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

Prototype

public void setCaption(String caption) 

Source Link

Document

Sets the caption part of the notification message.

Usage

From source file:ch.bfh.blue.UI.RegisterView.java

License:Open Source License

/**
 * configure handlers and settings for the buttons here
 *///from   w  w  w  . j  a v a2  s  .  co  m
private void configureButtons() {
    buttonBar.addComponents(homeBtn, registerBtn);
    //buttonBar.setMargin(true);
    buttonBar.setSpacing(true);

    registerBtn.addClickListener(e -> {
        if (passwd.getValue().equals(retypepw.getValue())) {
            controller.createPerson(email.getValue(), user.getValue(), passwd.getValue());
            navigator.navigateTo("home");
            Notification notif = new Notification(REGISTRATION_SUCCESS, Notification.Type.WARNING_MESSAGE);
            notif.setDelayMsec(3500);
            notif.show(Page.getCurrent());
        } else {
            notif.setCaption(REGISTRATION_FAIL_PW_MISSMATCH);
            notif.show(Page.getCurrent());
        }

    });

    homeBtn.addClickListener(e -> {
        navigator.navigateTo("home");
    });
}

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 .j a v  a 2s.  c  o 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);/*from   www  .j av a 2  s .  co  m*/

    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.vaadHL.utl.msgs.Msgs.java

License:Apache License

public void showWarning(String caption, int delay) {
    Notification not = new Notification(caption, Notification.Type.WARNING_MESSAGE);
    not.setDelayMsec(delay);//from  w  w w.j ava2s . co  m
    not.setHtmlContentAllowed(true);
    not.setCaption(caption);
    not.show(Page.getCurrent());
}

From source file:com.vaadHL.utl.msgs.Msgs.java

License:Apache License

public void showError(String caption, int delay) {
    Notification not = new Notification("", Notification.Type.ERROR_MESSAGE);
    not.setDelayMsec(delay);//from w  w  w. ja  v a  2s .  c o m
    not.setHtmlContentAllowed(true);
    not.setCaption(caption);
    not.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);/*from www .ja  v a2  s  .  c o m*/
        notif.show(Page.getCurrent());
        return true;
    }
    return false;
}

From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewsConfigUI.java

License:Open Source License

/**
 * 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
 *//*from   w  w w . j a  v  a2  s  .co m*/
public void notifyMessage(String message, String description, Notification.Type type) {
    Notification m_notification = new Notification("Message", type);

    m_notification.setCaption(message);
    m_notification.setDescription(description);
    m_notification.setDelayMsec(1000);

    if (getUI() != null) {
        if (getPage() != null) {
            m_notification.show(getUI().getPage());
        }
    }
}