List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:com.dungnv.streetfood.view.ArticleLink.java
private void setValueDish() { tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override//from w ww . j ava2 s .co m public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { if (!isLoadedRestaurant && event.getTabSheet().getSelectedTab().equals(tuiRestaurant)) { isLoadedRestaurant = true; setValueRestaurant(); setActionRestaurant(); 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.ArticleLink.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.setNotArticleId(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.setNotArticleId(null); restaurantDTO.setArticleId(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); }//from w w w.j a va 2 s. co m if (restaurantRightList != null) { restaurantRightContainer.addAll(restaurantRightList); } lsRestaurantLeft.setContainerDataSource(restaurantLeftContainer); lsRestaurantRight.setContainerDataSource(restaurantRightContainer); }
From source file:com.dungnv.streetfood.view.ArticleView.java
public ArticleView() { user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName()); setLocale(VaadinSession.getCurrent().getLocale()); setSizeFull();/*from w ww.j a v a 2 s . 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 ArticleDTO(); onSearch(true); }
From source file:com.dungnv.streetfood.view.CategoryInsert.java
public CategoryInsert(CategoryDTO dto, CategoryView 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().getCategoryDetail(user.getUsername()// , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId()); } else {/*from w w w . java 2s .c o m*/ dto = null; } this.dto = dto == null ? new CategoryDTO() : dto; this.view = view; this.action = action; init(); setContent(layout); }
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 w w w . ja v a2 s . co m*/ 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 init() { setLocale(VaadinSession.getCurrent().getLocale()); tabSheet = new TabSheet(); tabSheet.setStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS); tabSheet.setSizeFull();/*from w ww. j a v a 2s . c o m*/ VerticalLayout vLayout = new VerticalLayout(); tuiDish = new TwinColumnUI("name"); tuiDish.setLeftLabelCaption(BundleUtils.getLanguage("lbl.dish.avaiable.list")); tuiDish.setRightLabelCaption(BundleUtils.getLanguage("lbl.dish.selected.list")); vLayout.addComponent(tuiDish); lsDishLeft = tuiDish.getMsLeft().getLsItem(); lsDishRight = tuiDish.getMsRight().getLsItem(); HorizontalLayout hlButtonFooter = new HorizontalLayout(); hlButtonFooter.setSpacing(true); hlButtonFooter.setMargin(true); vLayout.addComponent(hlButtonFooter); vLayout.setComponentAlignment(hlButtonFooter, Alignment.BOTTOM_RIGHT); btnCancel = new Button(BundleUtils.getLanguage("lbl.cancel"), FontAwesome.BAN); hlButtonFooter.addComponent(btnCancel); tabSheet.addTab(vLayout, BundleUtils.getLanguage("lbl.category.categoryDish.tab")); setContent(tabSheet); }
From source file:com.dungnv.streetfood.view.CategoryLink.java
private void setValue() { user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName()); DishDTO dishDTO = new DishDTO(); dishDTO.setNotCategoryId(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.setNotCategoryId(null);// ww w. j a v a2 s.c o m dishDTO.setCategoryId(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.CategoryView.java
public CategoryView() { user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName()); setLocale(VaadinSession.getCurrent().getLocale()); setSizeFull();/*from w w w .j a v a 2 s . c o m*/ root = new VerticalLayout(); root.setSizeFull(); root.setMargin(true); root.addStyleName("dashboard-view"); setContent(root); Responsive.makeResponsive(root); init(); root.addComponent(header); builAction(); dtoSearch = new CategoryDTO(); onSearch(true); }
From source file:com.dungnv.streetfood.view.DishInsert.java
public DishInsert(DishDTO dto, DishView 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().getDishDetail(user.getUsername()// , getLocale().getLanguage(), getLocale().getCountry(), null, dto.getId()); } else {/*from w w w . ja va 2s . com*/ dto = null; } this.dto = dto == null ? new DishDTO() : dto; this.view = view; this.action = action; init(); setContent(layout); }
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;/* w w w .ja va 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); } }