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.cms.appparams.ui; import com.vaadin.annotations.AutoGenerated; import com.vaadin.data.validator.RegexpValidator; import com.vaadin.server.VaadinSession; import com.vaadin.shared.ui.combobox.FilteringMode; import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.cms.component.GridManyButton; import com.cms.dto.AppParamsDTO; import com.cms.utils.BundleUtils; import com.cms.utils.Constants; import com.cms.utils.MakeURL; import java.util.Locale; /** * * @author hungkv */ public class DialogCreateAppParams extends Window { /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ @AutoGenerated private VerticalLayout mainLayout; @AutoGenerated private HorizontalLayout horizontalLayout_2; @AutoGenerated private Button btnCancel; @AutoGenerated private Button btnSave; @AutoGenerated private GridLayout gridLayout_1; @AutoGenerated private ComboBox cboStatus; @AutoGenerated private Label lblStatus; @AutoGenerated private Label lblParamDesc; @AutoGenerated private TextField txtParamType; private TextField txtParamOrder; @AutoGenerated private Label lblParamOrder; @AutoGenerated private Label lblParamType; @AutoGenerated private Label lblParamName; @AutoGenerated private Label lblParamCode; Button btnReset; TextField txtParamCode; TextField txtParamName; TextArea txtAreaParamDesc; Locale mlocale = (Locale) VaadinSession.getCurrent().getSession().getAttribute("locale"); AppParamsDTO appParamsDTO; /** * The constructor should first build the main layout, set the composition * root and then do any custom initialization. * * The constructor will not be automatically regenerated by the visual * editor. */ public DialogCreateAppParams(String caption, AppParamsDTO apdto) { buildMainLayout(); setContent(mainLayout); setWidth("800px"); setHeight("-1px"); setModal(true); setImmediate(true); setCaption(caption); this.appParamsDTO = apdto; // TODO add user code here } @AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("100%"); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); // top-level component properties setWidth("100.0%"); setHeight("-1px"); // gridLayout_1 gridLayout_1 = buildGridLayout_1(); mainLayout.addComponent(gridLayout_1); // horizontalLayout_2 // horizontalLayout_2 = buildHorizontalLayout_2(); // mainLayout.addComponent(horizontalLayout_2); GridManyButton gmb = buildHorizontalLayout_2(); mainLayout.addComponent(gmb); return mainLayout; } @AutoGenerated private GridLayout buildGridLayout_1() { // common part: create layout gridLayout_1 = new GridLayout(); gridLayout_1.setStyleName("custom-feildset"); gridLayout_1.setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("appParam.fieldset.title"))); gridLayout_1.setCaptionAsHtml(true); gridLayout_1.setImmediate(false); gridLayout_1.setWidth("100.0%"); gridLayout_1.setHeight("-1px"); gridLayout_1.setMargin(true); gridLayout_1.setSpacing(true); gridLayout_1.setColumns(4); gridLayout_1.setRows(4); // lblParamCode lblParamCode = new Label(); lblParamCode.setImmediate(false); lblParamCode.setWidth("-1px"); lblParamCode.setHeight("-1px"); lblParamCode.setValue(BundleUtils.getString("lb.appParam.code")); gridLayout_1.addComponent(lblParamCode, 0, 0); txtParamCode = new TextField(); txtParamCode.setImmediate(true); txtParamCode.setWidth("100.0%"); txtParamCode.setHeight("-1px"); txtParamCode.setRequired(true); txtParamCode.setMaxLength(50); // StringBuilder messageError = new StringBuilder(); // messageError.append(BundleUtils.getString("lb.appParam.code")); // messageError.append(BundleUtils.getString(" ")); // messageError.append(BundleUtils.getString("message.error.numberformat")); // txtParamCode.addValidator(new RegexpValidator("[0-9]+", messageError.toString())); gridLayout_1.addComponent(txtParamCode, 1, 0); // lblParamName lblParamName = new Label(); lblParamName.setImmediate(false); lblParamName.setWidth("100%"); lblParamName.setHeight("-1px"); lblParamName.setValue(BundleUtils.getString("lb.appParam.name")); gridLayout_1.addComponent(lblParamName, 2, 0); txtParamName = new TextField(); txtParamName.setImmediate(true); txtParamName.setWidth("100.0%"); txtParamName.setHeight("-1px"); txtParamName.setRequired(true); txtParamName.setMaxLength(200); // txtParamName.addValidator(new RegexpValidator("^[a-zA-Z0-9 -_]+$", BundleUtils.getString("lb.appParam.name")+" "+BundleUtils.getString("message.error.special.char"))); gridLayout_1.addComponent(txtParamName, 3, 0); // lblParamType lblParamType = new Label(); lblParamType.setImmediate(false); lblParamType.setWidth("100%"); lblParamType.setHeight("-1px"); lblParamType.setValue(BundleUtils.getString("lb.appParam.type")); gridLayout_1.addComponent(lblParamType, 0, 1); txtParamType = new TextField(); txtParamType.setImmediate(true); txtParamType.setWidth("100.0%"); txtParamType.setHeight("-1px"); txtParamType.setRequired(true); txtParamType.setMaxLength(100); txtParamType.addValidator(new RegexpValidator("^[a-zA-Z0-9-_]+$", BundleUtils.getString("lb.appParam.type") + " " + BundleUtils.getString("message.error.special.char"))); gridLayout_1.addComponent(txtParamType, 1, 1); // lblParamOrder lblParamOrder = new Label(); lblParamOrder.setImmediate(false); lblParamOrder.setWidth("100%"); lblParamOrder.setHeight("-1px"); lblParamOrder.setValue(BundleUtils.getString("lb.appParam.order")); gridLayout_1.addComponent(lblParamOrder, 2, 1); // cboImplementer txtParamOrder = new TextField(); txtParamOrder.setImmediate(true); txtParamOrder.setWidth("100.0%"); txtParamOrder.setHeight("-1px"); txtParamOrder.setMaxLength(5); StringBuilder messageErrorOrder = new StringBuilder(); messageErrorOrder.append(BundleUtils.getString("lb.appParam.order")); messageErrorOrder.append(BundleUtils.getString(" ")); messageErrorOrder.append(BundleUtils.getString("message.error.numberformat")); txtParamOrder.addValidator(new RegexpValidator("[0-9]+", messageErrorOrder.toString())); gridLayout_1.addComponent(txtParamOrder, 3, 1); // lblStatus lblStatus = new Label(); lblStatus.setImmediate(false); lblStatus.setWidth("100%"); lblStatus.setHeight("-1px"); lblStatus.setValue(BundleUtils.getString("lb.appParam.status")); gridLayout_1.addComponent(lblStatus, 0, 2); cboStatus = new ComboBox(); cboStatus.setImmediate(true); cboStatus.setTextInputAllowed(false); cboStatus.setFilteringMode(FilteringMode.OFF); cboStatus.setWidth("100.0%"); cboStatus.setHeight("-1px"); cboStatus.setStyleName("notRequireStyle"); gridLayout_1.addComponent(cboStatus, 1, 2); // lblToDate lblParamDesc = new Label(); lblParamDesc.setImmediate(false); lblParamDesc.setWidth("100%"); lblParamDesc.setHeight("-1px"); lblParamDesc.setValue(BundleUtils.getString("lb.appParam.description")); gridLayout_1.addComponent(lblParamDesc, 2, 2); // pdfToDate txtAreaParamDesc = new TextArea(); txtAreaParamDesc.setImmediate(true); txtAreaParamDesc.setWidth("100.0%"); txtAreaParamDesc.setHeight("-1px"); txtAreaParamDesc.setMaxLength(300); // txtAreaParamDesc.addValidator(new StringLengthValidator(BundleUtils.getString("message.error.overlengthString"))); gridLayout_1.addComponent(txtAreaParamDesc, 3, 2); // // btnReset // GridLayout button = new GridLayout(1, 1); // button.setWidth("100%"); // button.setHeight("-1px"); // btnReset = new Button(); // btnReset.setStyleName("v-button-link"); // btnReset.setIcon(new ThemeResource("img/refresh-icon.png")); // btnReset.setImmediate(true); // btnReset.setHeight("-1px"); // btnReset.setDescription(Constants.BUTTON_REFRESH); // button.addComponent(btnReset); // button.setComponentAlignment(btnReset, Alignment.TOP_RIGHT); // gridLayout_1.addComponent(button, 3, 3); return gridLayout_1; } @AutoGenerated private GridManyButton buildHorizontalLayout_2() { GridManyButton gridManyButton = new GridManyButton( new String[] { Constants.BUTTON_SAVE, Constants.BUTTON_CANCEL }); btnSave = gridManyButton.getBtnCommon().get(0); btnCancel = gridManyButton.getBtnCommon().get(1); return gridManyButton; // // common part: create layout // horizontalLayout_2 = new HorizontalLayout(); // horizontalLayout_2.setImmediate(false); // horizontalLayout_2.setWidth("100.0%"); // horizontalLayout_2.setHeight("-1px"); // horizontalLayout_2.setMargin(true); // horizontalLayout_2.setSpacing(true); // // // btnSave // btnSave = new Button(); // btnSave.setCaption(BundleUtils.getString("common.button.save")); // btnSave.setImmediate(true); // btnSave.setWidth("-1px"); // btnSave.setHeight("-1px"); // btnSave.setIcon(new ThemeResource(Constants.ICON.SAVE)); // horizontalLayout_2.addComponent(btnSave); // horizontalLayout_2.setComponentAlignment(btnSave, new Alignment(34)); // // // btnCancel // btnCancel = new Button(); // btnCancel.setCaption(BundleUtils.getString("common.button.cancel")); // btnCancel.setImmediate(true); // btnCancel.setWidth("-1px"); // btnCancel.setHeight("-1px"); // btnCancel.setIcon(new ThemeResource(Constants.ICON.CANCEL)); // horizontalLayout_2.addComponent(btnCancel); // horizontalLayout_2.setComponentAlignment(btnCancel, new Alignment(33)); // // return horizontalLayout_2; } public Button getBtnCancel() { return btnCancel; } public void setBtnCancel(Button btnCancel) { this.btnCancel = btnCancel; } public Button getBtnSave() { return btnSave; } public void setBtnSave(Button btnSave) { this.btnSave = btnSave; } // public Button getBtnReset() { // return btnReset; // } // // public void setBtnReset(Button btnReset) { // this.btnReset = btnReset; // } public ComboBox getCboStatus() { return cboStatus; } public void setCboStatus(ComboBox cboStatus) { this.cboStatus = cboStatus; } public TextField getTxtParamType() { return txtParamType; } public void setTxtParamType(TextField txtParamType) { this.txtParamType = txtParamType; } public TextField getTxtParamOrder() { return txtParamOrder; } public void setTxtParamOrder(TextField txtParamOrder) { this.txtParamOrder = txtParamOrder; } public TextField getTxtParamCode() { return txtParamCode; } public void setTxtParamCode(TextField txtParamCode) { this.txtParamCode = txtParamCode; } public TextField getTxtParamName() { return txtParamName; } public void setTxtParamName(TextField txtParamName) { this.txtParamName = txtParamName; } public TextArea getTxtParamDesc() { return txtAreaParamDesc; } public void setTxtParamDesc(TextArea txtAreaParamDesc) { this.txtAreaParamDesc = txtAreaParamDesc; } public AppParamsDTO getAppParamsDTO() { return appParamsDTO; } public void setAppParamsDTO(AppParamsDTO appParamsDTO) { this.appParamsDTO = appParamsDTO; } }