List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:com.cms.ui.ChangPasswordUI.java
public Boolean checkLogIn(String username, String password) { StaffDTO staffDTO = new StaffDTO(); staffDTO.setCode(username);/*ww w .j a v a 2s . c om*/ staffDTO.setPassword(DataUtil.md5(password)); lstStaffDTO = new ArrayList<>(); List<ConditionBean> lstConditionBean = Lists.newArrayList(); ConditionBean conditionBean = new ConditionBean(); conditionBean.setField("code"); conditionBean.setValue(username); conditionBean.setOp(ConditionBean.Operator.NAME_EQUAL); conditionBean.setType(ConditionBean.Type.STRING); lstConditionBean.add(conditionBean); ConditionBean conditionBean1 = new ConditionBean(); conditionBean1.setField("password"); conditionBean1.setValue(DataUtil.md5(password)); conditionBean1.setOp(ConditionBean.Operator.NAME_EQUAL); conditionBean1.setType(ConditionBean.Type.STRING); lstConditionBean.add(conditionBean1); try { lstStaffDTO = WSStaff.getListStaffByCondition(lstConditionBean, 0, Integer.MAX_VALUE, "", "code"); if (lstStaffDTO.size() == 1) { VaadinSession.getCurrent().setAttribute("staff", lstStaffDTO.get(0)); return true; } else { return false; } } catch (Exception e) { return false; } }
From source file:com.cms.utils.BundleUtils.java
public static String getString(String key, Locale... locale) { try {/*from ww w . j ava2s . co m*/ if (locale != null) { if (locale.length == 0) { Locale mlocale = (Locale) VaadinSession.getCurrent().getSession().getAttribute("locale"); rsConfig = ResourceBundle.getBundle(Constants.LANGUAGE, mlocale); } else { rsConfig = ResourceBundle.getBundle(Constants.LANGUAGE, locale[0]); } } else { rsConfig = ResourceBundle.getBundle(Constants.LANGUAGE, new Locale(getResourceDefault("defaultLanguage"))); } return rsConfig.getString(key); } catch (Exception e) { return key; } }
From source file:com.cms.utils.CasBundleUtils.java
License:Open Source License
public static String getResource(String key, Locale... locale) { Locale mlocale = (Locale) VaadinSession.getCurrent().getSession().getAttribute("locale"); try {//from www . j a v a2 s .c o m if (locale != null) { if (locale.length == 0) { rb = ResourceBundle.getBundle(Constants.CAS, mlocale); } else { rb = ResourceBundle.getBundle(Constants.CAS, locale[0]); } } else { rb = ResourceBundle.getBundle(Constants.CAS, new Locale(getResourceDefault("defaultLanguage"))); } String str = rb.getString(key); if (DataUtil.isStringNullOrEmpty(str)) { return key; } else { return str; } } catch (Exception e) { return key; } }
From source file:com.cms.view.ExportContractFromTaxCode.java
public void addBtnSaveListener() { btnSave.addClickListener((event) -> { if (isValidated()) { Map<String, String> mapInputValue = getValueInputed(); customer.setOfficeAddress(mapInputValue.get(Constants.REPORT.OFFICE_ADDRESS)); customer.setDeployAddress(mapInputValue.get(Constants.REPORT.DEPLOY_ADDRESS)); customer.setRepresentativeName(mapInputValue.get(Constants.REPORT.NGUOI_DAIDIEN)); customer.setRepresentativeId(mapInputValue.get(Constants.REPORT.CMND)); customer.setEmail(mapInputValue.get(Constants.REPORT.EMAIL)); customer.setFax(mapInputValue.get(Constants.REPORT.FAX)); customer.setTelNumber(mapInputValue.get(Constants.REPORT.TEL_NUMBER)); if (DataUtil.isStringNullOrEmpty(customer.getCustId())) { StaffDTO staff = (StaffDTO) VaadinSession.getCurrent().getAttribute("staff"); customer.setStaffName(staff.getName()); customer.setStaffId(staff.getStaffId()); customer.setName(mapInputValue.get(Constants.REPORT.NAME)); customer.setTaxCode(mapInputValue.get(Constants.REPORT.TAX_CODE)); ResultDTO createStatus = WSCustomer.insertCustomer(customer); if (Constants.SUCCESS.equals(createStatus.getMessage())) { customer.setCustId(createStatus.getId()); CommonUtils.showInsertSuccess( BundleUtils.getString("customer.management.header.customerinfo")); btnCreateDoc.setEnabled(true); } else { CommonUtils// w ww.jav a2 s. c o m .showInsertFail(BundleUtils.getString("customer.management.header.customerinfo")); } } else { String updateStatus = WSCustomer.updateCustomer(customer); if (Constants.SUCCESS.equals(updateStatus)) { CommonUtils.showUpdateSuccess( BundleUtils.getString("customer.management.header.customerinfo")); btnCreateDoc.setEnabled(true); } else { CommonUtils .showUpdateFail(BundleUtils.getString("customer.management.header.customerinfo")); } } } CommonUtils.enableButtonAfterClick(event); }); }
From source file:com.cms.view.StatisticsCategoryListView.java
private void buildMainLayout() { layoutMain.setMargin(true);/*from w ww . ja v a 2 s.c o m*/ layoutMain.setSpacing(true); categoryListForm = new StatisticsCategoryListSearchPanel(); categoryListForm.btnSearch.setCaption(BundleUtils.getString("statistics.button.caption")); layoutMain.addComponent(categoryListForm); panelTblStatisticsCategoryList = new CommonTableFilterPanel(); panelTblStatisticsCategoryList.getToolbar().setVisible(false); layoutMain.addComponent(panelTblStatisticsCategoryList); panelMain.setCaption(BundleUtils.getString("title.statistics.categoryList")); StatisticsCategoryListController servicesController = new StatisticsCategoryListController(this); staff = (StaffDTO) VaadinSession.getCurrent().getAttribute("staff"); servicesController.setStaff(staff); }
From source file:com.dungnv.streetfood.service.ClientServiceImpl.java
License:Open Source License
public synchronized static Map<String, TagsDTO> getAllTags() { if (allTags == null || reloadAllTags == null || DateTimeUtils.getTimeBeetweenDates(reloadAllTags, new Date(), Calendar.MINUTE) > 5) { if (allTags != null) { allTags.clear();/*from w w w. j av a2 s .c o m*/ } UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName()); List<TagsDTO> list = getInstance().getListTagsDTO(user.getUsername(), "en", "US", null, new TagsDTO(), 0, 0, "ASC", "name"); for (TagsDTO tags : list) { allTags.put(tags.getName().toLowerCase(), tags); } } return allTags; }
From source file:com.dungnv.streetfood.service.ClientServiceImpl.java
License:Open Source License
public synchronized static Map<String, LocaleDTO> getAllLocales() { if (allLocales == null || reloadAllLocales == null || DateTimeUtils.getTimeBeetweenDates(reloadAllLocales, new Date(), Calendar.MINUTE) > 5) { if (allLocales != null) { allLocales.clear();//from w w w. java2 s. co m } UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName()); List<LocaleDTO> list = getInstance().getListLocaleDTO(user.getUsername(), "en", "US", null// , new LocaleDTO(null, null, null, "1"), 0, 0, "ASC", "locale"); for (LocaleDTO dto : list) { allLocales.put(dto.getId(), dto); } } return allLocales; }
From source file:com.dungnv.streetfood.ui.ArticleItemUI.java
public ArticleItemUI(ArticleDTO item, ArticleView mainView) { setLocale(VaadinSession.getCurrent().getLocale()); this.mainView = mainView; this.item = item == null ? new ArticleDTO() : item; this.itemId = this.item.getId(); init();// ww w . j a v a2 s . c o m buildAction(); }
From source file:com.dungnv.streetfood.ui.ArticleItemUI.java
private void buildAction() { 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.getViewCount()) ? " |" + FontAwesome.EYE.getHtml() + "  :  " + item.getViewCount() : " |" + FontAwesome.EYE.getHtml() + "  :  --"; if (!StringUtils.isNullOrEmpty(info)) { lbInfo.setCaption(info);//from w w w . j a v a 2 s . c om } btnLink.addClickListener((Button.ClickEvent event) -> { if (item != null) { ArticleLink dishLink = new ArticleLink(item); dishLink.setWidth("80%"); dishLink.setHeight("75%"); dishLink.setModal(true); FWUtils.reloadWindow(dishLink); UI.getCurrent().addWindow(dishLink); } }); btnEdit.addClickListener((Button.ClickEvent event) -> { if (item != null) { ArticleInsert articleInsert = new ArticleInsert(item// , event.getButton().findAncestor(ArticleView.class)// , Constants.ACTION.UPDATE); articleInsert.setWidth("80%"); articleInsert.setHeight("90%"); articleInsert.setModal(true); FWUtils.reloadWindow(articleInsert); UI.getCurrent().addWindow(articleInsert); } }); 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().deleteArticle(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.CategoryItemUI.java
public CategoryItemUI(CategoryDTO item, CategoryView mainView) { setLocale(VaadinSession.getCurrent().getLocale()); this.mainView = mainView; this.item = item == null ? new CategoryDTO() : item; this.itemId = this.item.getId(); init();//from w w w .j a v a 2s . c om buildAction(); }