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, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:com.dungnv.streetfood.ui.DishItemUI.java

private void buildAction() {

    if ("1".equals(item.getDishStatus())) {
        lbTitle.addStyleName("lb-status-active");
    } else {/*from  ww  w  . j av  a  2  s . c o  m*/
        lbTitle.addStyleName("lb-status-inActive");
    }

    String info = !StringUtils.isNullOrEmpty(item.getId())
            ? "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " " + item.getId()
                    + "</b>"
            : "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " --</b>";

    info += !StringUtils.isNullOrEmpty(item.getRating())
            ? "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getRating()
            : "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getViewCount())
            ? "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getViewCount()
            : "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getCommentCount())
            ? "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getCommentCount()
            : "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getShareCount())
            ? "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getShareCount()
            : "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    if (!StringUtils.isNullOrEmpty(info)) {
        lbInfo.setCaption(info);
    }

    btnEdit.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            DishInsert dishInsert = new DishInsert(item//
            , event.getButton().findAncestor(DishView.class)//
            , Constants.ACTION.UPDATE);
            dishInsert.setWidth("80%");
            dishInsert.setHeight("90%");
            dishInsert.setModal(true);
            FWUtils.reloadWindow(dishInsert);
            UI.getCurrent().addWindow(dishInsert);
        }
    });

    btnLink.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            DishLink dishLink = new DishLink(item);
            dishLink.setWidth("80%");
            dishLink.setHeight("75%");
            dishLink.setModal(true);
            FWUtils.reloadWindow(dishLink);
            UI.getCurrent().addWindow(dishLink);
        }
    });

    btnDelete.addClickListener((Button.ClickEvent event) -> {
        ConfirmDialog.show(UI.getCurrent(), BundleUtils.getLanguage("lbl.confirm")//
        , BundleUtils.getLanguage("message.category.delete.confirm")//
        , BundleUtils.getLanguage("lbl.yes")//
        , BundleUtils.getLanguage("lbl.no")//
        , (ConfirmDialog cd) -> {
            if (cd.isConfirmed()) {
                UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
                ResultDTO result = ClientServiceImpl.getInstance().deleteDish(user.getUsername()//
                , getLocale().getLanguage(), getLocale().getCountry(), null, Long.valueOf(itemId));
                if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                    mainView.onSearch(Boolean.TRUE);
                    UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
                } else {
                    Notification.show(
                            result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        });
    });

}

From source file:com.dungnv.streetfood.ui.RestaurantItemUI.java

private void buildAction() {

    if ("1".equals(item.getRestaurantStatus())) {
        lbTitle.addStyleName("lb-status-active");
    } else {/*from   ww w .  j  a v  a  2 s. c  o m*/
        lbTitle.addStyleName("lb-status-inActive");
    }

    String info = !StringUtils.isNullOrEmpty(item.getId())
            ? "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " " + item.getId()
                    + "</b>"
            : "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " --</b>";

    info += !StringUtils.isNullOrEmpty(item.getRating())
            ? "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getRating()
            : "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getViewCount())
            ? "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getViewCount()
            : "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getCommentCount())
            ? "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getCommentCount()
            : "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getShareCount())
            ? "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getShareCount()
            : "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";
    //        
    //        info += !StringUtils.isNullOrEmpty(item.getOperatingTimeStart())
    //                ? "&nbsp|" + FontAwesome.CLOCK_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getOperatingTimeStart() + " / "
    //                : "&nbsp|" + FontAwesome.CLOCK_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--:--" + " / ";
    //        
    //        info += !StringUtils.isNullOrEmpty(item.getOperatingTimeEnd())
    //                ?  item.getOperatingTimeEnd() : "--:--" ;

    if (!StringUtils.isNullOrEmpty(info)) {
        lbInfo.setCaption(info);
    }

    btnEdit.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            RestaurantInsert restaurantInsert = new RestaurantInsert(item//
            , event.getButton().findAncestor(RestaurantView.class)//
            , Constants.ACTION.UPDATE);
            restaurantInsert.setWidth("80%");
            restaurantInsert.setHeight("90%");
            restaurantInsert.setModal(true);
            FWUtils.reloadWindow(restaurantInsert);
            UI.getCurrent().addWindow(restaurantInsert);
        }
    });

    btnLink.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            RestaurantLink restaurantLink = new RestaurantLink(item);
            restaurantLink.setWidth("80%");
            restaurantLink.setHeight("75%");
            restaurantLink.setModal(true);
            FWUtils.reloadWindow(restaurantLink);
            UI.getCurrent().addWindow(restaurantLink);
        }
    });

    btnDelete.addClickListener((Button.ClickEvent event) -> {
        ConfirmDialog.show(UI.getCurrent(), BundleUtils.getLanguage("lbl.confirm")//
        , BundleUtils.getLanguage("message.category.delete.confirm")//
        , BundleUtils.getLanguage("lbl.yes")//
        , BundleUtils.getLanguage("lbl.no")//
        , (ConfirmDialog cd) -> {
            if (cd.isConfirmed()) {
                UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
                ResultDTO result = ClientServiceImpl.getInstance().deleteRestaurant(user.getUsername()//
                , getLocale().getLanguage(), getLocale().getCountry(), null, Long.valueOf(itemId));
                if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                    mainView.onSearch(Boolean.TRUE);
                    UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
                } else {
                    Notification.show(
                            result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        });
    });

}

From source file:com.dungnv.streetfood.ui.SlideShowItemUI.java

private void buildAction() {

    lbTitle.addStyleName("lb-status-active");

    String info = "";

    if (!StringUtils.isNullOrEmpty(item.getId())) {
        info += StringUtils.isNullOrEmpty(info)
                ? FontAwesome.OUTDENT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getId()
                : "&nbsp|" + FontAwesome.OUTDENT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getId();
    }/*  w  w  w.  java  2s. c om*/

    if (!StringUtils.isNullOrEmpty(item.getValidFromGmt())) {
        info += StringUtils.isNullOrEmpty(info)
                ? FontAwesome.OUTDENT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getValidFromGmt()
                : "&nbsp|" + FontAwesome.OUTDENT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getValidFromGmt();
    }

    if (!StringUtils.isNullOrEmpty(item.getValidToGmt())) {
        info += StringUtils.isNullOrEmpty(info)
                ? FontAwesome.OUTDENT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getValidToGmt()
                : "&nbsp|" + FontAwesome.OUTDENT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getValidToGmt();
    }

    if (!StringUtils.isNullOrEmpty(info)) {
        lbInfo.setCaption(info);
    }

    btnEdit.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            SlideShowInsert slideShowInsert = new SlideShowInsert(item//
            , event.getButton().findAncestor(SlideShowView.class)//
            , Constants.ACTION.UPDATE);
            slideShowInsert.setWidth("80%");
            slideShowInsert.setHeight("90%");
            slideShowInsert.setModal(true);
            FWUtils.reloadWindow(slideShowInsert);
            UI.getCurrent().addWindow(slideShowInsert);
        }
    });

    btnDelete.addClickListener((Button.ClickEvent event) -> {
        ConfirmDialog.show(UI.getCurrent(), BundleUtils.getLanguage("lbl.confirm")//
        , BundleUtils.getLanguage("message.category.delete.confirm")//
        , BundleUtils.getLanguage("lbl.yes")//
        , BundleUtils.getLanguage("lbl.no")//
        , (ConfirmDialog cd) -> {
            if (cd.isConfirmed()) {
                UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
                ResultDTO result = ClientServiceImpl.getInstance().deleteSlideShow(user.getUsername()//
                , getLocale().getLanguage(), getLocale().getCountry(), null, Long.valueOf(itemId));
                if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                    mainView.onSearch(Boolean.TRUE);
                    UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
                } else {
                    Notification.show(
                            result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        });
    });

}

From source file:com.dungnv.streetfood.view.ArticleInsert.java

@Override
public void wizardCompleted(WizardCompletedEvent event) {
    UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
    ResultDTO result = null;/*from w w  w .  j a v a2 s.  c  o m*/
    if (null != action) {
        switch (action) {
        case INSERT:
            result = ClientServiceImpl.getInstance().insertArticle(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        case UPDATE:
            result = ClientServiceImpl.getInstance().updateArticle(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        default:
            UI.getCurrent().removeWindow(event.getWizard().findAncestor(Window.class));
            return;
        }
    }

    if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
        view.onSearch(Boolean.TRUE);
        UI.getCurrent().removeWindow(event.getWizard().findAncestor(Window.class));
    } else {
        Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.dungnv.streetfood.view.ArticleLink.java

private void setActionDish() {
    tuiDish.getBtnSave().addClickListener(new Button.ClickListener() {
        @Override/* w w  w .  j av a 2s.c  o  m*/
        public void buttonClick(Button.ClickEvent event) {
            dishRightContainer.removeAllContainerFilters();
            List<DishDTO> list = dishRightContainer.getItemIds();
            List<String> listId = new ArrayList<>();
            if (list != null) {
                list.stream().forEach((dto) -> {
                    listId.add(dto.getId());
                });
            }

            ResultDTO result = ClientServiceImpl.getInstance().insertListDishToRestaurant(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId(), listId);
            if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
            } else {
                Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.dungnv.streetfood.view.ArticleLink.java

private void setActionRestaurant() {
    tuiRestaurant.getBtnSave().addClickListener(new Button.ClickListener() {
        @Override//from  w  w  w.  j  a  v  a 2  s.c o m
        public void buttonClick(Button.ClickEvent event) {
            restaurantRightContainer.removeAllContainerFilters();
            List<RestaurantDTO> list = restaurantRightContainer.getItemIds();
            List<String> listId = new ArrayList<>();
            if (list != null) {
                list.stream().forEach((dto) -> {
                    listId.add(dto.getId());
                });
            }

            ResultDTO result = ClientServiceImpl.getInstance().insertListRestaurantToArticle(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId(), listId);
            if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
            } else {
                Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.dungnv.streetfood.view.CategoryInsert.java

@Override
public void wizardCompleted(WizardCompletedEvent event) {
    UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
    ResultDTO result = null;/*from   www.  j  a  v a 2 s .c  om*/
    if (null != action) {
        switch (action) {
        case INSERT:
            result = ClientServiceImpl.getInstance().insertCategory(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        case UPDATE:
            result = ClientServiceImpl.getInstance().updateCategory(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        default:
            UI.getCurrent().removeWindow(event.getWizard().findAncestor(Window.class));
            return;
        }
    }

    if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
        view.onSearch(Boolean.TRUE);
        UI.getCurrent().removeWindow(event.getWizard().findAncestor(Window.class));
    } else {
        Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.dungnv.streetfood.view.CategoryLink.java

private void setAction() {
    tuiDish.getBtnSave().addClickListener(new Button.ClickListener() {
        @Override/*w  w  w.  ja v  a2s  . com*/
        public void buttonClick(Button.ClickEvent event) {
            dishRightContainer.removeAllContainerFilters();
            List<DishDTO> list = dishRightContainer.getItemIds();
            List<String> listId = new ArrayList<>();
            if (list != null) {
                list.stream().forEach((dto) -> {
                    listId.add(dto.getId());
                });
            }
            ResultDTO result = ClientServiceImpl.getInstance().insertListDishToCategory(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId(), listId);
            if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
            } else {
                Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.dungnv.streetfood.view.DishInsert.java

@Override
public void wizardCompleted(WizardCompletedEvent event) {
    UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
    ResultDTO result = null;//from w w  w.j  av  a 2  s . c  o m
    if (null != action) {
        switch (action) {
        case INSERT:
            result = ClientServiceImpl.getInstance().insertDish(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        case UPDATE:
            result = ClientServiceImpl.getInstance().updateDish(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        default:
            UI.getCurrent().removeWindow(event.getWizard().findAncestor(Window.class));
            return;
        }
    }

    if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
        view.onSearch(Boolean.TRUE);
        UI.getCurrent().removeWindow(event.getWizard().findAncestor(Window.class));
    } else {
        Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.dungnv.streetfood.view.DishLink.java

private void setActionCategory() {
    tuiCategory.getBtnSave().addClickListener(new Button.ClickListener() {
        @Override//from  www  .  j  a v  a 2s.  c  o m
        public void buttonClick(Button.ClickEvent event) {
            categoryRightContainer.removeAllContainerFilters();
            List<CategoryDTO> list = categoryRightContainer.getItemIds();
            List<String> listId = new ArrayList<>();
            if (list != null) {
                list.stream().forEach((dto) -> {
                    listId.add(dto.getId());
                });
            }

            ResultDTO result = ClientServiceImpl.getInstance().insertListCategoryToDish(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId(), listId);
            if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
            } else {
                Notification.show(result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}