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.github.carljmosca.ui.SearchView.java

@PostConstruct
private void init() {
    setCaption("ZoneMinderV");
    VerticalComponentGroup content = new VerticalComponentGroup();

    cmbMonitors = new NativeSelect<>();
    if (monitorsRepository.count() > 0) {
        List<Monitors> monitors = monitorsRepository.findAll();
        cmbMonitors.setItems(monitors);/*  ww  w. j  ava2s.com*/
        cmbMonitors.setValue(monitors.get(0));
    }
    cmbMonitors.setItemCaptionGenerator(p -> p.getName());
    cmbMonitors.setEmptySelectionAllowed(false);
    cmbMonitors.setEmptySelectionCaption("Select monitor");
    content.addComponent(cmbMonitors);
    datePicker = new DatePicker("Event Date");
    datePicker.setValue(new Date());
    content.addComponent(datePicker);

    final Button btnSearch = new Button("Search");
    btnSearch.addClickListener((ClickEvent event) -> {
        DemoUI demoUI = (DemoUI) this.getUI();
        if (cmbMonitors.getValue() != null && datePicker.getValue() != null) {
            demoUI.setMonitorId(cmbMonitors.getValue().getId());
            demoUI.setEventStartTime(datePicker.getValue());
            getNavigationManager().navigateTo(eventsView);
        } else {
            Notification.show("Select monitor and date");
        }
    });

    setContent(new CssLayout(content, btnSearch));
}

From source file:com.github.daytron.containersdatasource.BeanSampleCombo.java

License:Open Source License

public BeanSampleCombo() {
    Person person1 = new Person(1L, "John", "DOE", new Date(70, 0, 1));
    Person person2 = new Person(2L, "Jane", "doe", new Date(70, 0, 1));
    Person person3 = new Person(3L, "jules", "winnf", new Date(48, 11, 21));
    Person person4 = new Person(4L, "vincent", "Vega", new Date(54, 1, 17));

    container = new BeanItemContainer<>(Person.class);

    container.addAll(Arrays.asList(person1, person2, person3, person4));

    ComboBox comboBox = new ComboBox("List Of Persons", container);
    comboBox.setImmediate(true);/*from  www.  j  a  va  2s  . com*/
    comboBox.setNullSelectionAllowed(true);
    comboBox.setItemCaptionPropertyId("fullname");

    comboBox.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            AbstractSelect combo = (AbstractSelect) event.getProperty();

            Person selected = (Person) combo.getValue();

            if (selected == null) {
                Notification.show("Null selected");
            } else {
                Notification.show(selected.getId() + ": " + selected.getFullname(),
                        Notification.Type.HUMANIZED_MESSAGE);
            }
        }
    });

    addComponent(comboBox);

}

From source file:com.github.daytron.sqlcontainer.DatabaseTableScreen.java

public DatabaseTableScreen() {
    setMargin(true);/*from   www .j a v  a 2s  .  c o  m*/

    table = new Table();
    table.setPageLength(10);
    table.setEditable(true);
    table.setSizeFull();

    table.addGeneratedColumn("", new RemoveItemColumnGenerator());

    HorizontalLayout buttonBar = new HorizontalLayout();

    buttonBar.setMargin(true);
    buttonBar.setSpacing(true);

    Button commitButton = new Button("Commit");
    commitButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                container.commit();
                Notification.show("Changes committed");
            } catch (UnsupportedOperationException | SQLException ex) {
                Logger.getLogger(DatabaseTableScreen.class.getName()).log(Level.SEVERE, null, ex);
                Notification.show("Unable to commit", Notification.Type.ERROR_MESSAGE);
            }

        }
    });

    buttonBar.addComponent(commitButton);
    Button rollbackButton = new Button("Rollback");

    rollbackButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                container.rollback();
                Notification.show("Changes rollback");
            } catch (UnsupportedOperationException | SQLException ex) {
                Logger.getLogger(DatabaseTableScreen.class.getName()).log(Level.SEVERE, null, ex);
                Notification.show("Unable to rollback", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    buttonBar.addComponent(rollbackButton);
    addComponent(table);
    addComponent(buttonBar);
}

From source file:com.github.daytron.twaattin.presenter.LoginBehaviour.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent event) {
    try {/*from w w  w. ja v  a2s.  c  om*/
        String pin = loginField.getValue();

        Principal user = new TwitterAuthenticationStrategy().authenticate(pin);

        VaadinSession.getCurrent().setAttribute(Principal.class, user);

        TimelineScreen aTimelineScreen = new TimelineScreen();
        UI.getCurrent().setContent(aTimelineScreen);

        Notification authenticatedNotification = new Notification("You're now authenticated to Twaattin!",
                Notification.Type.TRAY_NOTIFICATION);
        authenticatedNotification.setPosition(Position.TOP_CENTER);
        authenticatedNotification.show(Page.getCurrent());

    } catch (AuthenticationException e) {
        Notification errorNotification = new Notification(e.getMessage(), "Cick this box to close.",
                Notification.Type.ERROR_MESSAGE);
        errorNotification.show(Page.getCurrent());
    }
}

From source file:com.github.daytron.twaattin.presenter.LogoutBehaviour.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent event) {
    VaadinSession.getCurrent().setAttribute(Principal.class, null);

    UI.getCurrent().setContent(new LoginScreen());

    Notification logoutNotification = new Notification("You've been logout",
            Notification.Type.TRAY_NOTIFICATION);
    logoutNotification.setPosition(Position.TOP_CENTER);
    logoutNotification.show(Page.getCurrent());
}

From source file:com.github.peholmst.i18n4vaadin.cdi.demo.DemoView.java

License:Apache License

@Message(key = "greeting", value = "Hello {0}! How is it going?")
private void sayHello() {
    Notification.show(bundle.greeting(name.getValue()));
}

From source file:com.github.tempora.view.TemporaUI.java

License:Apache License

/**
 * Helper method to display a notification to the end user.
 *
 * @param message the notification description.
 *//*from  w ww .  j  a v  a2s. co m*/
private void notifyEndUser(String message) {
    Notification notification = new Notification("INFO", message, Notification.Type.TRAY_NOTIFICATION, true);
    notification.setPosition(Position.BOTTOM_RIGHT);
    notification.show(getPage());
}

From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.operations.AdminOperation.java

License:Apache License

@Override
public void run() {
    Notification.show(backend.adminOnlyEcho("Hello Admin World"));
}

From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.operations.UserOperation.java

License:Apache License

@Override
public void run() {
    Notification.show(backend.echo("Hello World"));
}

From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.views.UserView.java

License:Apache License

@Autowired
public UserView(MyBackend backend) {
    this.backend = backend;
    Button button = new Button("Call user backend", new Button.ClickListener() {
        @Override//  w w w  .j  a  v a  2s.  com
        public void buttonClick(Button.ClickEvent event) {
            Notification.show(UserView.this.backend.echo("Hello User World!"));
        }
    });
    setCompositionRoot(button);
}