Example usage for com.vaadin.server VaadinSession getCurrent

List of usage examples for com.vaadin.server VaadinSession getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession getCurrent.

Prototype

public static VaadinSession getCurrent() 

Source Link

Document

Gets the currently used session.

Usage

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

private void init() {

    setLocale(VaadinSession.getCurrent().getLocale());

    VerticalLayout vLayout = new VerticalLayout();

    tabSheet = new TabSheet();
    tabSheet.setStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    tabSheet.setSizeFull();//w  w  w . j av a2 s .  c o m
    vLayout.addComponent(tabSheet);

    // CategoryDish
    tuiCategory = new TwinColumnUI("name");
    tuiCategory.setLeftLabelCaption(BundleUtils.getLanguage("lbl.category.avaiable.list"));
    tuiCategory.setRightLabelCaption(BundleUtils.getLanguage("lbl.category.selected.list"));
    tabSheet.addTab(tuiCategory, BundleUtils.getLanguage("lbl.dish.categoryDish.tab"));

    // RestaurantDish
    tuiRestaurant = new TwinColumnUI("name");
    tuiRestaurant.setLeftLabelCaption(BundleUtils.getLanguage("lbl.restaurant.avaiable.list"));
    tuiRestaurant.setRightLabelCaption(BundleUtils.getLanguage("lbl.restaurant.selected.list"));
    tabSheet.addTab(tuiRestaurant, BundleUtils.getLanguage("lbl.dish.restaurantDish.tab"));

    // DishArticle
    tuiArticle = new TwinColumnUI("title");
    tuiArticle.setLeftLabelCaption(BundleUtils.getLanguage("lbl.article.avaiable.list"));
    tuiArticle.setRightLabelCaption(BundleUtils.getLanguage("lbl.article.selected.list"));
    tabSheet.addTab(tuiArticle, BundleUtils.getLanguage("lbl.dish.dishArticle.tab"));

    setContent(tabSheet);
}

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

private void setValueCategory() {

    tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {
        @Override//from ww  w.  j a  v  a  2 s. c  o  m
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
            if (!isLoadedRestaurant && event.getTabSheet().getSelectedTab().equals(tuiRestaurant)) {
                isLoadedRestaurant = true;
                setValueRestaurant();
                setActionRestaurant();
            }

            if (!isLoadedArticle && event.getTabSheet().getSelectedTab().equals(tuiArticle)) {
                isLoadedArticle = true;
                setValueArticle();
                setActionArticle();
            }
            if (isLoadedRestaurant && isLoadedArticle) {
                tabSheet.removeSelectedTabChangeListener(this);
            }
        }
    });

    lsCategoryLeft = tuiCategory.getMsLeft().getLsItem();
    lsCategoryRight = tuiCategory.getMsRight().getLsItem();

    user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());

    CategoryDTO categoryDTO = new CategoryDTO();
    categoryDTO.setNotDishId(dto.getId());
    categoryDTO.setIsGetOnlyIdentified("1");
    List<CategoryDTO> categoryLeftList = ClientServiceImpl.getInstance()
            .getListCategoryDTOLess(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, categoryDTO, 0, 0, false,
                    "ASC", "name");

    categoryDTO.setNotDishId(null);
    categoryDTO.setDishId(dto.getId());
    List<CategoryDTO> categoryRightList = ClientServiceImpl.getInstance()
            .getListCategoryDTOLess(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, categoryDTO, 0, 0, false,
                    "ASC", "name");

    if (categoryLeftList != null) {
        categoryLeftContainer.addAll(categoryLeftList);
    }
    if (categoryRightList != null) {
        categoryRightContainer.addAll(categoryRightList);
    }

    lsCategoryLeft.setContainerDataSource(categoryLeftContainer);
    lsCategoryRight.setContainerDataSource(categoryRightContainer);
}

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

private void setValueRestaurant() {

    lsRestaurantLeft = tuiRestaurant.getMsLeft().getLsItem();
    lsRestaurantRight = tuiRestaurant.getMsRight().getLsItem();

    user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());

    RestaurantDTO restaurantDTO = new RestaurantDTO();
    restaurantDTO.setNotDishId(dto.getId());
    restaurantDTO.setIsGetOnlyIdentified("1");
    List<RestaurantDTO> restaurantLeftList = ClientServiceImpl.getInstance()
            .getListRestaurantDTOLess(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, restaurantDTO, 0, 0, false,
                    "ASC", "name");

    restaurantDTO.setNotDishId(null);/*from   w  w  w . j  a  va2s . c o m*/
    restaurantDTO.setDishId(dto.getId());
    List<RestaurantDTO> restaurantRightList = ClientServiceImpl.getInstance()
            .getListRestaurantDTOLess(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, restaurantDTO, 0, 0, false,
                    "ASC", "name");

    if (restaurantLeftList != null) {
        restaurantLeftContainer.addAll(restaurantLeftList);
    }
    if (restaurantRightList != null) {
        restaurantRightContainer.addAll(restaurantRightList);
    }

    lsRestaurantLeft.setContainerDataSource(restaurantLeftContainer);
    lsRestaurantRight.setContainerDataSource(restaurantRightContainer);
}

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

private void setValueArticle() {

    lsArticleLeft = tuiArticle.getMsLeft().getLsItem();
    lsArticleRight = tuiArticle.getMsRight().getLsItem();

    user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());

    ArticleDTO articleDTO = new ArticleDTO();
    articleDTO.setNotDishId(dto.getId());
    articleDTO.setIsGetOnlyIdentified("1");
    List<ArticleDTO> articleLeftList = ClientServiceImpl.getInstance().getListArticleDTOLess(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, articleDTO, 0, 0, false, "ASC",
            "name");

    articleDTO.setNotDishId(null);//from  w  w w .  j  a v a  2s  .co  m
    articleDTO.setDishId(dto.getId());
    List<ArticleDTO> articleRightList = ClientServiceImpl.getInstance().getListArticleDTOLess(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, articleDTO, 0, 0, false, "ASC",
            "name");

    if (articleLeftList != null) {
        articleLeftContainer.addAll(articleLeftList);
    }
    if (articleRightList != null) {
        articleRightContainer.addAll(articleRightList);
    }

    lsArticleLeft.setContainerDataSource(articleLeftContainer);
    lsArticleRight.setContainerDataSource(articleRightContainer);
}

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

public DishView() {
    user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
    setLocale(VaadinSession.getCurrent().getLocale());
    setSizeFull();//from   ww w  .  j  a  v a2s  . c  om
    root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(true);
    root.addStyleName("dashboard-view");
    setContent(root);
    Responsive.makeResponsive(root);
    init();
    root.addComponent(header);

    builAction();
    dtoSearch = new DishDTO();
    onSearch(true);

}

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

public RestaurantInsert(RestaurantDTO dto, RestaurantView view, Constants.ACTION action) {

    setLocale(VaadinSession.getCurrent().getLocale());
    if (dto != null && !StringUtils.isNullOrEmpty(dto.getId())) {
        UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
        dto = ClientServiceImpl.getInstance().getRestaurantDetail(user.getUsername()//
                , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId());
    } else {// w ww  .j  a  va 2 s .c o  m
        dto = null;
    }

    this.dto = dto == null ? new RestaurantDTO() : dto;
    this.view = view;
    this.action = action;
    init();
    setContent(layout);
}

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

@Override
public void wizardCompleted(WizardCompletedEvent event) {
    UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
    ResultDTO result = null;/*from   w ww .  j ava2  s. c  o  m*/
    if (null != action) {
        switch (action) {
        case INSERT:
            result = ClientServiceImpl.getInstance().insertRestaurant(user.getUsername()//
                    , getLocale().getLanguage(), getLocale().getCountry(), null, dto);
            break;
        case UPDATE:
            result = ClientServiceImpl.getInstance().updateRestaurant(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.RestaurantLink.java

private void init() {

    setLocale(VaadinSession.getCurrent().getLocale());

    VerticalLayout vLayout = new VerticalLayout();

    tabSheet = new TabSheet();
    tabSheet.setStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    tabSheet.setSizeFull();/*from  ww  w.j  av  a  2s .c o m*/
    vLayout.addComponent(tabSheet);

    // RestaurantDish
    tuiDish = new TwinColumnUI("name");
    tuiDish.setLeftLabelCaption(BundleUtils.getLanguage("lbl.dish.avaiable.list"));
    tuiDish.setRightLabelCaption(BundleUtils.getLanguage("lbl.dish.selected.list"));
    tabSheet.addTab(tuiDish, BundleUtils.getLanguage("lbl.restaurant.restaurantDish.tab"));

    // RestaurantArticle
    tuiArticle = new TwinColumnUI("title");
    tuiArticle.setLeftLabelCaption(BundleUtils.getLanguage("lbl.article.avaiable.list"));
    tuiArticle.setRightLabelCaption(BundleUtils.getLanguage("lbl.article.selected.list"));
    tabSheet.addTab(tuiArticle, BundleUtils.getLanguage("lbl.restaurant.RestaurantArticle.tab"));

    setContent(tabSheet);
}

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

private void setValueDish() {

    tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {
        @Override//w w  w . j a va2s  .  c om
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {

            if (!isLoadedArticle && event.getTabSheet().getSelectedTab().equals(tuiArticle)) {
                isLoadedArticle = true;
                setValueArticle();
                setActionArticle();
                tabSheet.removeSelectedTabChangeListener(this);
            }
        }
    });

    lsDishLeft = tuiDish.getMsLeft().getLsItem();
    lsDishRight = tuiDish.getMsRight().getLsItem();

    user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());

    DishDTO dishDTO = new DishDTO();
    dishDTO.setNotRestaurantId(dto.getId());
    dishDTO.setIsGetOnlyIdentified("1");
    List<DishDTO> dishLeftList = ClientServiceImpl.getInstance().getListDishDTOLess(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, dishDTO, 0, 0, false, "ASC", "name");

    dishDTO.setNotRestaurantId(null);
    dishDTO.setRestaurantId(dto.getId());
    List<DishDTO> dishRightList = ClientServiceImpl.getInstance().getListDishDTOLess(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, dishDTO, 0, 0, false, "ASC", "name");

    if (dishLeftList != null) {
        dishLeftContainer.addAll(dishLeftList);
    }
    if (dishRightList != null) {
        dishRightContainer.addAll(dishRightList);
    }

    lsDishLeft.setContainerDataSource(dishLeftContainer);
    lsDishRight.setContainerDataSource(dishRightContainer);
}

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

private void setValueArticle() {

    lsArticleLeft = tuiArticle.getMsLeft().getLsItem();
    lsArticleRight = tuiArticle.getMsRight().getLsItem();

    user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());

    ArticleDTO articleDTO = new ArticleDTO();
    articleDTO.setNotRestaurantId(dto.getId());
    articleDTO.setIsGetOnlyIdentified("1");
    List<ArticleDTO> articleLeftList = ClientServiceImpl.getInstance().getListArticleDTOLess(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, articleDTO, 0, 0, false, "ASC",
            "name");

    articleDTO.setNotRestaurantId(null);
    articleDTO.setRestaurantId(dto.getId());
    List<ArticleDTO> articleRightList = ClientServiceImpl.getInstance().getListArticleDTOLess(user.getUsername()//
            , getLocale().getLanguage(), getLocale().getCountry(), null, articleDTO, 0, 0, false, "ASC",
            "name");

    if (articleLeftList != null) {
        articleLeftContainer.addAll(articleLeftList);
    }//from   w  ww.j a  v  a  2s . c  om
    if (articleRightList != null) {
        articleRightContainer.addAll(articleRightList);
    }

    lsArticleLeft.setContainerDataSource(articleLeftContainer);
    lsArticleRight.setContainerDataSource(articleRightContainer);
}