Example usage for com.vaadin.ui Notification show

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

Introduction

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

Prototype

public static Notification show(String caption) 

Source Link

Document

Shows a notification message on the middle of the current page.

Usage

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private MenuBar.Command save() {
    return (MenuBar.MenuItem selectedItem) -> {

        if (fieldGroup.isValid()) {

            try {
                fieldGroup.commit();//  ww  w. j  a v  a 2s.  co m

                if (appointment.getTimeLapse() != null) {
                    appointment.setProgramDateEnd(timeLapseCalculator
                            .calculateLapse(appointment.getProgramDateStart(), appointment.getTimeLapse()));
                } else {
                    //Si no se ha especificado intervalo de tiempo, se pone la hora de inicio
                    appointment.setProgramDateEnd(appointment.getProgramDateStart());
                }
                appointment = appointmentService.edit(appointment);

                Notification success = new PrettyNotification("Cita guardada correctamente.");
                success.show(Page.getCurrent());

                eventBus.post(new DashboardEvent.NotificationsCountUpdatedEvent());
                eventBus.post(new AppointmentUpdatedEvent());
            } catch (Validator.InvalidValueException | FieldGroup.CommitException e) {
                Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        } else {
            Notification.show("Complete los datos obligatorios.", Notification.Type.ERROR_MESSAGE);
        }

    };
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private MenuBar.Command duplicate() {

    return (MenuBar.MenuItem selectedItem) -> {
        if (this.fieldGroup.isModified()) {
            Notification.show("Guarde los cambios pendientes antes de continuar.");
        } else {/*from w  w  w  .ja v  a 2 s.co m*/
            duplicateAppointment(appointment);
        }
    };
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void duplicateAppointment(Appointment app) {

    InlineDateField date = new InlineDateField();
    //date.setTextFieldEnabled(false);
    date.setLocale(new Locale("es", "ES"));
    date.setResolution(Resolution.MINUTE);
    date.setValue(app.getProgramDateStart().getTime());
    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(date);//  w  ww .  j  av a 2s  . c o m
    layout.setComponentAlignment(date, Alignment.MIDDLE_CENTER);

    DialogWindow dlgWin = new DialogWindow("Seleccione una fecha", layout, DialogWindow.DialogButton.OK,
            DialogWindow.DialogButton.CANCEL) {

        @Override
        protected void onButtonCancelClicked() {
            this.close();
        }

        @Override
        protected void onButtonOKClicked() {
            java.util.Calendar cal;
            cal = new java.util.Calendar.Builder().build();
            cal.setTime(date.getValue());
            try {
                Appointment newAppointment = appointmentService.duplicate(app, cal);

                Notification success = new PrettyNotification("Cita duplicada correctamente");
                success.show(Page.getCurrent());

                eventBus.post(new DashboardEvent.NotificationsCountUpdatedEvent());
                eventBus.post(new AppointmentUpdatedEvent());
                this.close();

                bind(newAppointment);
            } catch (InstantiationException | IllegalAccessException ex) {
                Logger.getLogger(AppointmentView.class.getName()).log(Level.SEVERE, null, ex);
                Notification.show(ex.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }

    };

    dlgWin.setModal(true);
    dlgWin.setCaption("Seleccione nueva fecha");
    UI.getCurrent().addWindow(dlgWin);
    dlgWin.focus();
}

From source file:com.terralcode.gestion.frontend.view.widgets.customer.CustomerView.java

private MenuBar.Command save() {
    return new MenuBar.Command() {

        @Override//  w w w.  j a v a 2  s  .c o  m
        public void menuSelected(MenuBar.MenuItem selectedItem) {

            if (fieldGroup.isValid()) {
                try {
                    fieldGroup.commit();
                    customerCRMService.edit(customer);
                    Notification.show("Datos guardados correctamente");
                } catch (Validator.InvalidValueException e) {
                    Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE);
                } catch (FieldGroup.CommitException e) {
                    Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE);
                }
            } else {
                Notification.show("Complete los datos obligatorios", Notification.Type.ERROR_MESSAGE);
            }

        }
    };
}

From source file:com.terralcode.gestion.frontend.view.widgets.desplegable.ComponenteDesplegableView.java

private Component buildCustomerDetail() {
    GridLayout miGrid = new GridLayout(3, 2);

    ComboBox combo = new ComboBox();
    combo.addValueChangeListener(new Property.ValueChangeListener() {

        @Override// w ww  .j a va2  s . co  m
        public void valueChange(Property.ValueChangeEvent event) {
            seleccion = (String) event.getProperty().getValue();

        }
    });
    combo.addItems("Pocino Ibrico", "Pocino Blanco", "Ovino", "Vacuno", "Avicultura", "Otros");
    //        combo.addItem(especies);
    Label informacion = new Label("datos");
    Button botonMas = new Button("+");
    botonMas.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Integer clave;
            if (valores.containsValue(seleccion)) {
                clave = 1;
                if (!valores.isEmpty()) {
                    clave = valores.size() + 1;
                }

                valores.put(clave, seleccion);
            }
            informacion.setValue(mostrarValores());
            Notification.show(seleccion + " aadido");
        }
    });
    Button botonMenos = new Button("-");
    miGrid.addComponent(informacion, 0, 0);
    miGrid.addComponent(combo, 0, 1);
    miGrid.addComponent(botonMas, 1, 1);
    miGrid.addComponent(botonMenos, 2, 1);

    return miGrid;

}

From source file:com.toptal.ui.view.LoginView.java

License:Open Source License

/**
 * Error notification.//from w w w . ja v a 2s  .  c o  m
 * @param message Message.
 */
private void error(final String message) {
    final int delay = 5000;
    final Notification notification = new Notification(message, Notification.Type.WARNING_MESSAGE);
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setIcon(FontAwesome.WARNING);
    notification.setDelayMsec(delay);
    notification.show(Page.getCurrent());
}

From source file:com.tripoin.util.ui.calendar.NotificationTestUI.java

License:Apache License

@Override
protected void init(com.vaadin.server.VaadinRequest request) {
    GridLayout content = new GridLayout(1, 2);
    content.setSizeFull();/*from www.j a  v  a  2 s .  c o m*/
    content.setRowExpandRatio(1, 1.0f);
    setContent(content);
    final Button btn = new Button("Show working notification", new Button.ClickListener() {
        /**
        * 
        */
        private static final long serialVersionUID = -165570248584063787L;

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("This will disappear when you move your mouse!");
        }
    });
    content.addComponent(btn);

    provider = new DummyEventProvider();
    final Calendar cal = new Calendar(provider);
    cal.setLocale(Locale.US);
    cal.setSizeFull();
    cal.setHandler(new DateClickHandler() {
        /**
        * 
        */
        private static final long serialVersionUID = 1903111449161995776L;

        @Override
        public void dateClick(DateClickEvent event) {
            provider.addEvent(event.getDate());
            Notification.show("This should disappear, but if wont unless clicked.");

            // this requestRepaint call interferes with the notification
            cal.markAsDirty();
        }
    });
    content.addComponent(cal);

    java.util.Calendar javaCal = java.util.Calendar.getInstance();
    javaCal.set(java.util.Calendar.YEAR, 2000);
    javaCal.set(java.util.Calendar.MONTH, 0);
    javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
    Date start = javaCal.getTime();
    javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31);
    Date end = javaCal.getTime();

    cal.setStartDate(start);
    cal.setEndDate(end);
}

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

License:Apache License

public void showInfo(String caption, int delay) {
    Notification not = new Notification(caption);
    not.setDelayMsec(delay);//from w w w . ja  v a 2s .c om
    not.setHtmlContentAllowed(true);
    not.show(Page.getCurrent());
}

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  av a  2 s  . com
    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  va  2s  .  c  o m*/
    not.setHtmlContentAllowed(true);
    not.setCaption(caption);
    not.show(Page.getCurrent());

}