Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.anphat.customer.ui; import com.cms.component.CommonDialog; import com.cms.dto.CustomerDTO; import com.cms.utils.Constants; import com.vaadin.data.Property; import com.vaadin.ui.OptionGroup; import com.vaadin.ui.RichTextArea; import com.vwf5.base.utils.DataUtil; import java.util.Map; /** * * @author quyen */ public class CreateEmailForm extends CommonDialog { private OptionGroup optionService; private RichTextArea sample; private final Map<String, String> mapInputedValue; private final CustomerDTO customer; public CreateEmailForm(CustomerDTO customer, Map<String, String> mapInputedValue) { setInfo("80%", "-1px", "Gi email cho nhn vin i?u phi"); mainLayout.setMargin(true); mainLayout.setSpacing(true); this.customer = customer; this.mapInputedValue = mapInputedValue; buildEmailContent(); buildServiceComboBox(); } private void buildServiceComboBox() { optionService = new OptionGroup("Dch v"); optionService.setStyleName("horizontal"); optionService.addItem("Ch k s"); optionService.addItem("IVAN"); optionService.addValueChangeListener((Property.ValueChangeEvent event) -> { String service = (String) event.getProperty().getValue(); String mailContent = getMail(service); sample.clear(); sample.setValue(mailContent); }); optionService.select("Ch k s"); mainLayout.addComponentAsFirst(optionService); } private void buildEmailContent() { sample = new RichTextArea(); sample.setImmediate(true); sample.setWidth("100%"); sample.setHeight("500px"); mainLayout.addComponent(sample); } private String getMail(String service) { String sb; if (service.equals("Ch k s")) { sb = "<b>TN CNG TY</b> : #tencongty <br>" + "<b>MST</b> : #masothue <br>" + "<b>?a ch VAT</b> : #diachitruso <br>" + "<b>Ng?i i din</b> : #nguoidaidien <br>" + "<b>Email</b> : #emaillienhe <br>" + "<b>Ha n ghi</b> : #sotien <br>" + "<b>Chit khu</b> : #chietkhau <br>" + "<b>?a ch COD/ EMS</b> : #diachigiaodich <br>" + "<b>Ng?i nhn</b> : #nguoilienhe <br> " + "<b>?in thoi</b> : #sodienthoailienhe"; } else { sb = "<b>TN CNG TY</b> : #tencongty <br> " + "<b>MST</b> : #masothue <br> " + "<b>M n v</b> : <br> " + "<b>C quan bo him</b> : #coquanquanlythue <br> " + "<b>?a ch ho n</b> : #diachitruso <br> " + "<b>?a ch giao dch</b> : #diachigiaodich <br> " + "<b>Gi ha n</b> : <br> " + "<b>Ng?i i din</b> : #nguoidaidien <b>CV</b> : #chucvunguoidaidien <br> " + "<b>Ng?i lin h</b> : #nguoilienhe <br> " + "<b>S in thoi</b> : #sodienthoailienhe <br> " + "<b>Email</b> : #emaillienhe <br> " + "<b>?ng k ch k s (nu c)</b> : <br> " + "<b>?ng k IVAN</b> : <br> " + "<b>Hnh thc thanh ton</b> : "; } sb = sb.replaceFirst(Constants.REPORT.NAME, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.NAME))); sb = sb.replaceFirst(Constants.REPORT.TAX_CODE, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.TAX_CODE))); sb = sb.replaceFirst(Constants.REPORT.OFFICE_ADDRESS, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.OFFICE_ADDRESS))); sb = sb.replaceFirst(Constants.REPORT.NGUOI_DAIDIEN, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.NGUOI_DAIDIEN))); sb = sb.replaceFirst(Constants.REPORT.CHUVU_NGUOI_DAIDIEN, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.CHUVU_NGUOI_DAIDIEN))); sb = sb.replaceFirst(Constants.REPORT.EMAIL_NGUOI_LIENHE, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.EMAIL_NGUOI_LIENHE))); sb = sb.replaceFirst(Constants.REPORT.SOTIEN, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.SOTIEN))); sb = sb.replaceFirst(Constants.REPORT.CHIETKHAU, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.CHIETKHAU))); sb = sb.replaceFirst(Constants.REPORT.DEPLOY_ADDRESS, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.DEPLOY_ADDRESS))); sb = sb.replaceFirst(Constants.REPORT.NGUOI_LIENHE, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.NGUOI_LIENHE))); sb = sb.replaceFirst(Constants.REPORT.SDT_NGUOI_LIENHE, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.SDT_NGUOI_LIENHE))); sb = sb.replaceFirst(Constants.REPORT.CMND, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.CMND))); sb = sb.replaceFirst(Constants.REPORT.NGAY_CAP_CMND, DataUtil.nvl(mapInputedValue.get(Constants.REPORT.NGAY_CAP_CMND))); sb = sb.replaceFirst(Constants.REPORT.NOI_CAP, DataUtil.nvl(DataUtil.getStringNullOrZero(mapInputedValue.get(Constants.REPORT.NOI_CAP)))); sb = sb.replaceFirst(Constants.REPORT.TAX_DEPARTMENT, DataUtil.nvl(DataUtil.getStringNullOrZero(mapInputedValue.get(Constants.REPORT.TAX_DEPARTMENT)))); return sb; } }