List of usage examples for com.vaadin.data.validator RegexpValidator RegexpValidator
public RegexpValidator(String errorMessage, String regexp)
From source file:com.anphat.cms.appparams.ui.DialogCreateAppParams.java
@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);//from w w w . j av a 2 s .com 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; }
From source file:com.anphat.list.ui.DialogCreateDepartment.java
@AutoGenerated private GridLayout buildGridLayoutDepartInfo() { // common part: create layout gridLayoutDepartInfo = new GridLayout(); gridLayoutDepartInfo.setStyleName("custom-feildset"); gridLayoutDepartInfo/*from w ww . j av a 2s. c o m*/ .setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("department.fieldset.title.deptInfo"))); gridLayoutDepartInfo.setCaptionAsHtml(true); gridLayoutDepartInfo.setImmediate(true); gridLayoutDepartInfo.setWidth("100.0%"); gridLayoutDepartInfo.setHeight("-1px"); gridLayoutDepartInfo.setMargin(true); gridLayoutDepartInfo.setSpacing(true); gridLayoutDepartInfo.setColumns(4); gridLayoutDepartInfo.setRows(7); // lblDepartmentCode lblDepartmentCode = new Label(); lblDepartmentCode.setImmediate(true); lblDepartmentCode.setWidth("100.0%"); lblDepartmentCode.setHeight("-1px"); lblDepartmentCode.setValue(BundleUtils.getString("lb.deptstaff.dept.code")); gridLayoutDepartInfo.addComponent(lblDepartmentCode, 0, 0); // txtDepartmentCode txtDepartmentCode = new TextField(); txtDepartmentCode.setImmediate(true); txtDepartmentCode.setWidth("100.0%"); txtDepartmentCode.setHeight("-1px"); txtDepartmentCode.setMaxLength(50); txtDepartmentCode.setRequired(true); txtDepartmentCode.addValidator( new RegexpValidator("^[a-zA-Z0-9-_]+$", BundleUtils.getString("lb.deptstaff.dept.code") + " " + BundleUtils.getString("message.error.code.format"))); gridLayoutDepartInfo.addComponent(txtDepartmentCode, 1, 0); // lblDepartmentName lblDepartmentName = new Label(); lblDepartmentName.setImmediate(true); lblDepartmentName.setWidth("100.0%"); lblDepartmentName.setHeight("-1px"); lblDepartmentName.setValue(BundleUtils.getString("lb.deptstaff.dept.name")); gridLayoutDepartInfo.addComponent(lblDepartmentName, 2, 0); // txtDepartmentName txtDepartmentName = new TextField(); txtDepartmentName.setImmediate(true); txtDepartmentName.setWidth("100.0%"); txtDepartmentName.setHeight("-1px"); txtDepartmentName.setMaxLength(100); txtDepartmentName.setRequired(true); gridLayoutDepartInfo.addComponent(txtDepartmentName, 3, 0); // lblSuperiorUnit // lblSuperiorUnit = new Label(); // lblSuperiorUnit.setImmediate(true); // lblSuperiorUnit.setWidth("100.0%"); // lblSuperiorUnit.setHeight("-1px"); // lblSuperiorUnit.setValue(BundleUtils.getString("lb.deptstaff.dept.level")); // gridLayoutDepartInfo.addComponent(lblSuperiorUnit, 0, 1); // txtSuperiorUnit // txtSuperiorUnit = new TextField(); // txtSuperiorUnit.setImmediate(true); // txtSuperiorUnit.setWidth("100.0%"); // txtSuperiorUnit.setHeight("-1px"); // comboDeptTopLevel = new MappingCombobox(3, 1); // comboDeptTopLevel.getNameCombo().setRequired(true); // gridLayoutDepartInfo.addComponent(comboDeptTopLevel.getLayout(), 1, 1, 3, 1); // lblDescription lblDescription = new Label(); lblDescription.setImmediate(true); lblDescription.setWidth("100.0%"); lblDescription.setHeight("-1px"); lblDescription.setValue(BundleUtils.getString("lb.deptstaff.desc")); gridLayoutDepartInfo.addComponent(lblDescription, 0, 1); // textArea_1 textArea_1 = new TextArea(); textArea_1.setImmediate(true); textArea_1.setWidth("100.0%"); textArea_1.setHeight("-1px"); textArea_1.setMaxLength(300); textArea_1.setStyleName("notRequireStyle"); gridLayoutDepartInfo.addComponent(textArea_1, 1, 1, 3, 1); // lblStatus lblStatus = new Label(); lblStatus.setImmediate(true); lblStatus.setWidth("100.0%"); lblStatus.setHeight("-1px"); lblStatus.setValue(BundleUtils.getString("lb.deptstaff.common.status")); gridLayoutDepartInfo.addComponent(lblStatus, 0, 2); // cbxStatus cbxStatus = new ComboBox(); cbxStatus.setImmediate(true); cbxStatus.setTextInputAllowed(false); cbxStatus.setFilteringMode(FilteringMode.OFF); cbxStatus.setWidth("100.0%"); cbxStatus.setHeight("-1px"); cbxStatus.setRequired(true); gridLayoutDepartInfo.addComponent(cbxStatus, 1, 2); // lblPhoneNumber lblPhoneNumber = new Label(); lblPhoneNumber.setImmediate(true); lblPhoneNumber.setWidth("100.0%"); lblPhoneNumber.setHeight("-1px"); lblPhoneNumber.setValue(BundleUtils.getString("lb.deptstaff.common.phone")); gridLayoutDepartInfo.addComponent(lblPhoneNumber, 2, 2); // txtPhoneNumber txtPhoneNumber = new TextField(); txtPhoneNumber.setImmediate(true); txtPhoneNumber.setInputPrompt(BundleUtils.getString("common.phone.format")); txtPhoneNumber.setWidth("100.0%"); txtPhoneNumber.setHeight("-1px"); txtPhoneNumber.setMaxLength(100); //message // StringBuilder messageErrorOrder = new StringBuilder(); // messageErrorOrder.append(BundleUtils.getString("lb.deptstaff.common.phone")); // messageErrorOrder.append(BundleUtils.getString(" ")); // messageErrorOrder.append(BundleUtils.getString("message.error.phoneformat")); // txtPhoneNumber.addValidator(new RegexpValidator("^\\(?(\\d{3,4})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", messageErrorOrder.toString())); txtPhoneNumber.setStyleName("notRequireStyle"); gridLayoutDepartInfo.addComponent(txtPhoneNumber, 3, 2); // lblFax // lblFax = new Label(); // lblFax.setImmediate(true); // lblFax.setWidth("100.0%"); // lblFax.setHeight("-1px"); // lblFax.setValue(BundleUtils.getString("lb.deptstaff.fax")); // gridLayoutDepartInfo.addComponent(lblFax, 0, 4); // txtFax // txtFax = new TextField(); // txtFax.setImmediate(true); // txtFax.setWidth("100.0%"); // txtFax.setHeight("-1px"); // txtFax.setMaxLength(100); //message // StringBuilder messageErrorFax = new StringBuilder(); // messageErrorFax.append(BundleUtils.getString("lb.deptstaff.fax")); // messageErrorFax.append(BundleUtils.getString(" ")); // messageErrorFax.append(BundleUtils.getString("message.error.numberformat")); // txtFax.addValidator(new RegexpValidator("[0-9]+", messageErrorFax.toString())); // txtFax.setStyleName("notRequireStyle"); // gridLayoutDepartInfo.addComponent(txtFax, 1, 4); // lblEmail lblEmail = new Label(); lblEmail.setImmediate(true); lblEmail.setWidth("100.0%"); lblEmail.setHeight("-1px"); lblEmail.setValue(BundleUtils.getString("lb.deptstaff.common.email")); gridLayoutDepartInfo.addComponent(lblEmail, 2, 3); // txtEmail txtEmail = new TextField(); txtEmail.setImmediate(true); txtEmail.addValidator(new EmailValidator(BundleUtils.getString("common.error.email"))); txtEmail.setRequiredError(BundleUtils.getString("common.error.email")); txtEmail.setInputPrompt(BundleUtils.getString("common.email.hint.format")); txtEmail.setWidth("100.0%"); txtEmail.setHeight("-1px"); txtEmail.setMaxLength(100); txtEmail.setStyleName("notRequireStyle"); gridLayoutDepartInfo.addComponent(txtEmail, 3, 3); // lblAddress lblAddress = new Label(); lblAddress.setImmediate(true); lblAddress.setWidth("100.0%"); lblAddress.setHeight("-1px"); lblAddress.setValue(BundleUtils.getString("lb.deptstaff.dept.addr")); gridLayoutDepartInfo.addComponent(lblAddress, 0, 4); // txtAddress txtAddress = new TextField(); txtAddress.setImmediate(true); txtAddress.setWidth("100.0%"); txtAddress.setHeight("-1px"); txtAddress.setMaxLength(300); // txtAddress.addValidator(new StringLengthValidator(BundleUtils.getString("common.error.length"), 0, 200, true)); txtAddress.setRequired(true); txtAddress.setStyleName("notRequireStyle"); gridLayoutDepartInfo.addComponent(txtAddress, 1, 4, 3, 4); // lblContact // lblContact = new Label(); // lblContact.setImmediate(true); // lblContact.setWidth("100.0%"); // lblContact.setHeight("-1px"); // lblContact.setValue(BundleUtils.getString("lb.deptstaff.contact.person")); // gridLayoutDepartInfo.addComponent(lblContact, 0, 5); // // // txtContact // txtContact = new TextField(); // txtContact.setImmediate(true); // txtContact.setWidth("100.0%"); // txtContact.setHeight("-1px"); // txtContact.setMaxLength(200); // txtContact.setStyleName("notRequireStyle"); // gridLayoutDepartInfo.addComponent(txtContact, 1, 5, 3, 5); return gridLayoutDepartInfo; }
From source file:com.anphat.list.ui.DialogCreateStaff.java
@AutoGenerated private GridLayout buildGridLayoutDepartInfo() { // common part: create layout gridLayoutDepartInfo = new GridLayout(); gridLayoutDepartInfo.setStyleName("custom-feildset"); gridLayoutDepartInfo.setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("caption.title.emp.info"))); gridLayoutDepartInfo.setCaptionAsHtml(true); gridLayoutDepartInfo.setImmediate(true); gridLayoutDepartInfo.setWidth("100.0%"); gridLayoutDepartInfo.setHeight("-1px"); gridLayoutDepartInfo.setMargin(true); gridLayoutDepartInfo.setSpacing(true); gridLayoutDepartInfo.setColumns(4);// ww w . j av a 2s. c om gridLayoutDepartInfo.setRows(7); // lblDepartmentCode lblDepartmentCode = new Label(); lblDepartmentCode.setImmediate(false); lblDepartmentCode.setWidth("100.0%"); lblDepartmentCode.setHeight("-1px"); lblDepartmentCode.setValue(BundleUtils.getString("lb.deptstaff.emp.code")); gridLayoutDepartInfo.addComponent(lblDepartmentCode, 0, 0); // txtStaffCode txtStaffCode = new TextField(); txtStaffCode.setImmediate(true); txtStaffCode.setWidth("100.0%"); txtStaffCode.setHeight("-1px"); txtStaffCode.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER); txtStaffCode.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(final FieldEvents.TextChangeEvent event) { String code = event.getText(); if (code != null) { code = code.replaceAll(" ", ""); if (!DataUtil.isStringNullOrEmpty(code)) { txtStaffCode.setValue(code.toUpperCase()); } } } }); txtStaffCode.setMaxLength(50); txtStaffCode .addValidator(new RegexpValidator("^[a-zA-Z0-9-_]+$", BundleUtils.getString("lb.deptstaff.emp.code") + " " + BundleUtils.getString("message.error.code.format"))); txtStaffCode.setRequired(true); gridLayoutDepartInfo.addComponent(txtStaffCode, 1, 0); // lblDepartmentName lblDepartmentName = new Label(); lblDepartmentName.setImmediate(false); lblDepartmentName.setWidth("100.0%"); lblDepartmentName.setHeight("-1px"); lblDepartmentName.setValue(BundleUtils.getString("lb.deptstaff.emp.name")); gridLayoutDepartInfo.addComponent(lblDepartmentName, 2, 0); // txtStaffName txtStaffName = new TextField(); txtStaffName.setImmediate(true); txtStaffName.setWidth("100.0%"); txtStaffName.setHeight("-1px"); txtStaffName.setMaxLength(200); // txtStaffName.addValidator(new StringLengthValidator(BundleUtils.getString("common.error.length"), 0, 200, true)); txtStaffName.setRequired(true); gridLayoutDepartInfo.addComponent(txtStaffName, 3, 0); // lblSuperiorUnit lblSuperiorUnit = new Label(); lblSuperiorUnit.setImmediate(false); lblSuperiorUnit.setWidth("100.0%"); lblSuperiorUnit.setHeight("-1px"); lblSuperiorUnit.setValue(BundleUtils.getString("lb.deptstaff.emp.dept")); gridLayoutDepartInfo.addComponent(lblSuperiorUnit, 0, 1); // txtSuperiorUnit txtSuperiorUnit = new TextField(); txtSuperiorUnit.setImmediate(true); txtSuperiorUnit.setWidth("100.0%"); txtSuperiorUnit.setHeight("-1px"); comboDeptTopLevel = new MappingCombobox(3, 1); // comboDeptTopLevel.getNameCombo().setRequired(true); gridLayoutDepartInfo.addComponent(comboDeptTopLevel.getLayout(), 1, 1, 3, 1); // // lblStock // lblStock = new Label(); // lblStock.setImmediate(false); // lblStock.setWidth("100.0%"); // lblStock.setHeight("-1px"); // lblStock.setVisible(false); // lblStock.setValue(BundleUtils.getString("lb.deptstaff.emp.stock")); // gridLayoutDepartInfo.addComponent(lblStock, 0, 2); // // // txtSuperiorUnit // comboStock = new MappingCombobox(3, 1); //// comboDeptTopLevel.getNameCombo().setRequired(true); // comboStock.setVisible(false); // gridLayoutDepartInfo.addComponent(comboStock.getLayout(), 1, 2,3 ,2); // lblSuperiorUnit lblStaffType = new Label(); lblStaffType.setImmediate(false); lblStaffType.setWidth("100.0%"); lblStaffType.setHeight("-1px"); lblStaffType.setValue(BundleUtils.getString("lb.deptstaff.emp.type")); // gridLayoutDepartInfo.addComponent(lblStaffType, 0, 3); gridLayoutDepartInfo.addComponent(lblStaffType, 0, 2); // txtSuperiorUnit cbxStaffType = new ComboBox(); cbxStaffType.setImmediate(true); cbxStaffType.setRequired(true); cbxStaffType.setTextInputAllowed(false); cbxStaffType.setFilteringMode(FilteringMode.OFF); cbxStaffType.setWidth("100.0%"); cbxStaffType.setHeight("-1px"); // cbxStaffType.setStyleName("notRequireStyle"); // gridLayoutDepartInfo.addComponent(cbxStaffType, 1, 3); gridLayoutDepartInfo.addComponent(cbxStaffType, 1, 2); // lblDescription lblDescription = new Label(); lblDescription.setImmediate(false); lblDescription.setWidth("100.0%"); lblDescription.setHeight("-1px"); lblDescription.setValue(BundleUtils.getString("lb.deptstaff.common.phone")); // gridLayoutDepartInfo.addComponent(lblDescription, 0, 4); gridLayoutDepartInfo.addComponent(lblDescription, 0, 3); // textArea_1 txtPhoneNumber = new TextField(); txtPhoneNumber.setImmediate(true); txtPhoneNumber.setWidth("100.0%"); txtPhoneNumber.setHeight("-1px"); txtPhoneNumber.setMaxLength(100); StringBuilder messageErrorOrder = new StringBuilder(); messageErrorOrder.append(BundleUtils.getString("lb.deptstaff.common.phone")); messageErrorOrder.append(BundleUtils.getString(" ")); messageErrorOrder.append(BundleUtils.getString("message.error.phoneformat")); txtPhoneNumber.addValidator(new RegexpValidator("^\\(?(\\d{3,4})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", messageErrorOrder.toString())); txtPhoneNumber.setInputPrompt(BundleUtils.getString("common.phone.format")); txtPhoneNumber.setStyleName("notRequireStyle"); // gridLayoutDepartInfo.addComponent(txtPhoneNumber, 1, 4); gridLayoutDepartInfo.addComponent(txtPhoneNumber, 1, 3); // lblStatus lblStatus = new Label(); lblStatus.setImmediate(false); lblStatus.setWidth("100.0%"); lblStatus.setHeight("-1px"); lblStatus.setValue(BundleUtils.getString("lb.deptstaff.common.status")); // gridLayoutDepartInfo.addComponent(lblStatus, 2, 3); gridLayoutDepartInfo.addComponent(lblStatus, 2, 2); // cbxStatus cbxStatus = new ComboBox(); cbxStatus.setImmediate(true); cbxStatus.setTextInputAllowed(false); cbxStatus.setFilteringMode(FilteringMode.OFF); cbxStatus.setWidth("100.0%"); cbxStatus.setHeight("-1px"); cbxStatus.setRequired(true); // gridLayoutDepartInfo.addComponent(cbxStatus, 3, 3); gridLayoutDepartInfo.addComponent(cbxStatus, 3, 2); // lblPhoneNumber lblPhoneNumber = new Label(); lblPhoneNumber.setImmediate(false); lblPhoneNumber.setWidth("100.0%"); lblPhoneNumber.setHeight("-1px"); lblPhoneNumber.setValue(BundleUtils.getString("lb.deptstaff.common.email")); // gridLayoutDepartInfo.addComponent(lblPhoneNumber, 2, 4); gridLayoutDepartInfo.addComponent(lblPhoneNumber, 2, 3); // txtEmail txtEmail = new TextField(); txtEmail.setImmediate(true); txtEmail.addValidator(new EmailValidator(BundleUtils.getString("common.error.email"))); txtEmail.setRequiredError(BundleUtils.getString("common.error.email")); txtEmail.setInputPrompt(BundleUtils.getString("common.email.hint.format")); txtEmail.setWidth("100.0%"); txtEmail.setHeight("-1px"); txtEmail.setMaxLength(100); txtEmail.setStyleName("notRequireStyle"); // gridLayoutDepartInfo.addComponent(txtEmail, 3, 4); gridLayoutDepartInfo.addComponent(txtEmail, 3, 3); // lblFax lblFax = new Label(); lblFax.setImmediate(false); lblFax.setWidth("100.0%"); lblFax.setHeight("-1px"); lblFax.setValue(BundleUtils.getString("lb.deptstaff.emp.birthDate")); // gridLayoutDepartInfo.addComponent(lblFax, 0, 5); gridLayoutDepartInfo.addComponent(lblFax, 0, 4); // pdfBirthDate pdfBirthDate = new PopupDateField(); pdfBirthDate.setLocale(mlocale); pdfBirthDate.setImmediate(true); pdfBirthDate.setWidth("100.0%"); pdfBirthDate.setHeight("-1px"); pdfBirthDate.setStyleName("notRequireStyle"); pdfBirthDate.setDateFormat("dd/MM/yyyy"); CommonUtils.addDateValidator(pdfBirthDate); // gridLayoutDepartInfo.addComponent(pdfBirthDate, 1, 5); gridLayoutDepartInfo.addComponent(pdfBirthDate, 1, 4); // // lblVofficeAcc = new Label(); // lblVofficeAcc.setImmediate(false); // lblVofficeAcc.setWidth("100.0%"); // lblVofficeAcc.setHeight("-1px"); // lblVofficeAcc.setValue("Ti khon V-Office"); // gridLayoutDepartInfo.addComponent(lblVofficeAcc,2,4); // txtVofficeAcc = new TextField(); // txtVofficeAcc.setImmediate(true); // txtVofficeAcc.setWidth("100.0%"); // txtVofficeAcc.setHeight("-1px"); // txtVofficeAcc.setMaxLength(100); // gridLayoutDepartInfo.addComponent(txtVofficeAcc,3,4); // // lblTtnsAcc = new Label(); // lblTtnsAcc.setImmediate(false); // lblTtnsAcc.setWidth("100.0%"); // lblTtnsAcc.setHeight("-1px"); // lblTtnsAcc.setValue("Ti khon TTNS"); // gridLayoutDepartInfo.addComponent(lblTtnsAcc,0,5); // // txtTtnsAcc = new TextField(); // txtTtnsAcc.setImmediate(true); // txtTtnsAcc.setWidth("100.0%"); // txtTtnsAcc.setHeight("-1px"); // txtTtnsAcc.setMaxLength(100); // gridLayoutDepartInfo.addComponent(txtTtnsAcc,1,5); // // // // lblVofficeAcc = new Label(); // lblVofficeAcc.setImmediate(false); // lblVofficeAcc.setWidth("100.0%"); // lblVofficeAcc.setHeight("-1px"); // lblVofficeAcc.setValue("Ti khon khc"); // gridLayoutDepartInfo.addComponent(lblVofficeAcc,2,5); // // // txtOtherAcc = new TextField(); // txtOtherAcc.setImmediate(true); // txtOtherAcc.setWidth("100.0%"); // txtOtherAcc.setHeight("-1px"); // txtOtherAcc.setMaxLength(100); // gridLayoutDepartInfo.addComponent(txtOtherAcc,3,5); return gridLayoutDepartInfo; }
From source file:com.demo.tutorial.agenda.ui.PersonForm.java
public PersonForm(MyUI app) { this.app = app; cmbCiudad.setNullSelectionAllowed(false); cmbCiudad.setTextInputAllowed(false); /* Poblar cmbCiudad usando las ciudades en el data container */ PersonContainer ds = app.getDataSource(); for (Person person : ds.getItemIds()) { //OPCION 1 String city = (String) person.getCiudad(); cmbCiudad.addItem(city);//w ww . j a v a 2s . c om } /*for (Iterator<Person> it = ds.getItemIds().iterator(); it.hasNext();) { //OPCION 2 String city = (it.next()).getCiudad(); cmbCiudad.addItem(city); }*/ /*setFormFieldFactory(new DefaultFieldFactory() { @Override public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("city")) { return cities; } Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("postalCode")) { TextField tf = (TextField) field; tf.setNullRepresentation(""); tf.addValidator(new RegexpValidator("[1-9][0-9]{4}", "Postal code must be a five digit number and cannot start with a zero.")); tf.setRequired(true); } return field; } });*/ fldBinder.setBuffered(true); /** * * Si esta en FALSE el buffered actualiza inmediatamente con tan solo * seleccionar otra fila ** */ //fldBinder.bind(txtNombre, "nombre"); //fldBinder.bind(txtApPaterno, "apPaterno"); footer.setSpacing(true); footer.addComponent(btnGuardar); footer.addComponent(btnCancelar); footer.addComponent(btnEditar); footer.setVisible(false); /** * Para dar formato a numeros y no tenga separado de decimales */ txtCodPostal.setNullRepresentation(""); StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() { @Override protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }; txtCodPostal.setConverter(plainIntegerConverter); String regexp = "[1-9][0-9]{6}"; String message = "{0} Cdigo Postal debe ser de 5 digitos numricos y no puede empezar con cero."; CSValidator validator = new CSValidator(); validator.extend(txtCodPostal); validator.setRegExp(regexp); validator.setPreventInvalidTyping(true); validator.setErrorMessage("Deber ser nmero"); txtCodPostal.setRequired(true); txtCodPostal.setValidationVisible(false); Validator postalCodeValidator = new RegexpValidator(regexp, message); //txtCodPostal.addValidator(postalCodeValidator); //txtCodPostal.addValidator(new StringLengthValidator( // "La longitud debe de ser de 5 digitos (was {0})", // 1, 5, false)); txtEmail.addValidator(new EmailValidator("Invalido email")); //btnGuardar.addClickListener(this); //btnCancelar.addClickListener(this); //btnEditar.addClickListener(this); addComponent(txtNombre); addComponent(txtApPaterno); addComponent(txtEmail); addComponent(txtTelefono); addComponent(txtDireccion); addComponent(txtCodPostal); addComponent(cmbCiudad); addComponent(footer); }
From source file:com.dungnv.streetfood.view.DishSearchDetail.java
private void init() { layout = new VerticalLayout(); layout.setSpacing(true);//from w w w . j a v a 2 s . co m layout.setMargin(true); form = new FormLayout(); form.addStyleName("light"); // form.addStyleName("outlined"); form.setSizeFull(); form.setMargin(true); form.setSpacing(true); layout.addComponent(form); tfName = new TextField(BundleUtils.getLanguage("lbl.dish.name")); tfName.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfName); tfShortDescription = new TextField(BundleUtils.getLanguage("lbl.dish.shortDescription")); tfShortDescription.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfShortDescription); HorizontalLayout hlStatus = new HorizontalLayout(); hlStatus.setCaption(BundleUtils.getLanguage("lbl.status")); hlStatus.addStyleName("horizontal"); hlStatus.setSpacing(true); form.addComponent(hlStatus); cbActive = new CheckBox(BundleUtils.getLanguage("lbl.active")); cbActive.setValue(Boolean.TRUE); hlStatus.addComponent(cbActive); cbInActive = new CheckBox(BundleUtils.getLanguage("lbl.inActive")); cbInActive.setValue(Boolean.TRUE); hlStatus.addComponent(cbInActive); String regexDouble = "[0-9]*.?[0-9]?"; String regexInteger = "[0-9]*"; tfViewCountFrom = new TextField(); tfViewCountFrom.setWidth(200.0f, Unit.PIXELS); tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlViewCountFrom = new CSValidator(); vlViewCountFrom.extend(tfViewCountFrom); vlViewCountFrom.setRegExp(regexInteger); vlViewCountFrom.setPreventInvalidTyping(true); tfViewCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number")); tfViewCountTo = new TextField(); tfViewCountTo.setWidth(200.0f, Unit.PIXELS); tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlViewCountTo = new CSValidator(); vlViewCountTo.extend(tfViewCountTo); vlViewCountTo.setRegExp(regexInteger); vlViewCountTo.setPreventInvalidTyping(true); tfViewCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number")); HorizontalLayout hlViewCount = new HorizontalLayout(tfViewCountFrom, new Label("-"), tfViewCountTo); hlViewCount.setCaption(BundleUtils.getLanguage("lbl.dish.viewCount")); hlViewCount.setSpacing(true); form.addComponent(hlViewCount); tfCommentCountFrom = new TextField(); tfCommentCountFrom.setWidth(200.0f, Unit.PIXELS); tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlCommentCountFrom = new CSValidator(); vlCommentCountFrom.extend(tfCommentCountFrom); vlCommentCountFrom.setRegExp(regexInteger); vlCommentCountFrom.setPreventInvalidTyping(true); tfCommentCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number")); tfCommentCountTo = new TextField(); tfCommentCountTo.setWidth(200.0f, Unit.PIXELS); tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlCommentCountTo = new CSValidator(); vlCommentCountTo.extend(tfCommentCountTo); vlCommentCountTo.setRegExp(regexInteger); vlCommentCountTo.setPreventInvalidTyping(true); tfCommentCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number")); HorizontalLayout hlCommentCount = new HorizontalLayout(tfCommentCountFrom, new Label("-"), tfCommentCountTo); hlCommentCount.setCaption(BundleUtils.getLanguage("lbl.dish.commentCount")); hlCommentCount.setSpacing(true); form.addComponent(hlCommentCount); tfShareCountFrom = new TextField(); tfShareCountFrom.setWidth(200.0f, Unit.PIXELS); tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlShareCountFrom = new CSValidator(); vlShareCountFrom.extend(tfShareCountFrom); vlShareCountFrom.setRegExp(regexInteger); vlShareCountFrom.setPreventInvalidTyping(true); tfShareCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number")); tfShareCountTo = new TextField(); tfShareCountTo.setWidth(200.0f, Unit.PIXELS); tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlShareCountTo = new CSValidator(); vlShareCountTo.extend(tfShareCountTo); vlShareCountTo.setRegExp(regexInteger); vlShareCountTo.setPreventInvalidTyping(true); tfShareCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number")); HorizontalLayout hlShareCount = new HorizontalLayout(tfShareCountFrom, new Label("-"), tfShareCountTo); hlShareCount.setCaption(BundleUtils.getLanguage("lbl.dish.shareCount")); hlShareCount.setSpacing(true); form.addComponent(hlShareCount); tfRatingFrom = new TextField(); tfRatingFrom.setWidth(200.0f, Unit.PIXELS); tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlRatingFrom = new CSValidator(); vlRatingFrom.extend(tfRatingFrom); vlRatingFrom.setRegExp(regexDouble); vlRatingFrom.setPreventInvalidTyping(true); tfRatingFrom.addValidator(new RegexpValidator(regexDouble, "Not a number")); tfRatingTo = new TextField(); tfRatingTo.setWidth(200.0f, Unit.PIXELS); tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlRatingTo = new CSValidator(); vlRatingTo.extend(tfRatingTo); vlRatingTo.setRegExp(regexDouble); vlRatingTo.setPreventInvalidTyping(true); tfRatingTo.addValidator(new RegexpValidator(regexDouble, "Not a number")); HorizontalLayout hlRating = new HorizontalLayout(tfRatingFrom, new Label("-"), tfRatingTo); hlRating.setCaption(BundleUtils.getLanguage("lbl.dish.rating")); hlRating.setSpacing(true); form.addComponent(hlRating); tagSuggestFieldUI = new TagSuggestFieldUI(false); tagSuggestFieldUI.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tagSuggestFieldUI); Map<String, LocaleDTO> mapLocale = ClientServiceImpl.getAllLocales(); if (mapLocale != null && !mapLocale.isEmpty()) { List<LocaleDTO> listLocale = new ArrayList<>(mapLocale.values()); listLocale.stream().map((localeDTO) -> new OptionGroupUI(localeDTO.getLocale()// , localeDTO.getId())).forEach((ogLocale) -> { form.addComponent(ogLocale); listOgLocale.add(ogLocale); }); } HorizontalLayout hlButton = new HorizontalLayout(); hlButton.setSpacing(true); hlButton.setMargin(true); form.addComponent(hlButton); btnSearch = new Button(BundleUtils.getLanguage("lbl.search"), FontAwesome.SEARCH); hlButton.addComponent(btnSearch); btnExportExcel = new Button(BundleUtils.getLanguage("lbl.exportExcel"), FontAwesome.FILE_EXCEL_O); hlButton.addComponent(btnExportExcel); btnExportXML = new Button(BundleUtils.getLanguage("lbl.exportXML"), FontAwesome.FILE_CODE_O); hlButton.addComponent(btnExportXML); btnCancel = new Button(BundleUtils.getLanguage("lbl.cancel"), FontAwesome.BAN); hlButton.addComponent(btnCancel); }
From source file:com.dungnv.streetfood.view.RestaurantSearchDetail.java
private void init() { layout = new VerticalLayout(); layout.setSpacing(true);/*from w ww. j a v a 2s . c o m*/ layout.setMargin(true); form = new FormLayout(); form.addStyleName("light"); // form.addStyleName("outlined"); form.setSizeFull(); form.setMargin(true); form.setSpacing(true); layout.addComponent(form); tfName = new TextField(BundleUtils.getLanguage("lbl.restaurant.name")); tfName.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfName); tfIntroduce = new TextField(BundleUtils.getLanguage("lbl.restaurant.introduce")); tfIntroduce.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfIntroduce); HorizontalLayout hlStatus = new HorizontalLayout(); hlStatus.setCaption(BundleUtils.getLanguage("lbl.status")); hlStatus.addStyleName("horizontal"); hlStatus.setSpacing(true); form.addComponent(hlStatus); cbActive = new CheckBox(BundleUtils.getLanguage("lbl.active")); cbActive.setValue(Boolean.TRUE); hlStatus.addComponent(cbActive); cbInActive = new CheckBox(BundleUtils.getLanguage("lbl.inActive")); cbInActive.setValue(Boolean.TRUE); hlStatus.addComponent(cbInActive); tfAddress = new TextField(BundleUtils.getLanguage("lbl.restaurant.address")); tfAddress.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfAddress); tfPhoneNumber = new TextField(BundleUtils.getLanguage("lbl.restaurant.phoneNumber")); tfPhoneNumber.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfPhoneNumber); tfCapacity = new TextField(BundleUtils.getLanguage("lbl.restaurant.capacity")); tfCapacity.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tfCapacity); HorizontalLayout hlCarParking = new HorizontalLayout(); hlCarParking.setCaption(BundleUtils.getLanguage("lbl.restaurant.carParking")); hlCarParking.addStyleName("horizontal"); hlCarParking.setSpacing(true); form.addComponent(hlCarParking); cbCarParkingYes = new CheckBox(BundleUtils.getLanguage("lbl.yes")); cbCarParkingYes.setValue(Boolean.TRUE); hlCarParking.addComponent(cbCarParkingYes); cbCarParkingNo = new CheckBox(BundleUtils.getLanguage("lbl.no")); cbCarParkingNo.setValue(Boolean.TRUE); hlCarParking.addComponent(cbCarParkingNo); HorizontalLayout hlMotobikeParking = new HorizontalLayout(); hlMotobikeParking.setCaption(BundleUtils.getLanguage("lbl.status")); hlMotobikeParking.addStyleName("horizontal"); hlMotobikeParking.setSpacing(true); form.addComponent(hlMotobikeParking); cbMotobikeParkingYes = new CheckBox(BundleUtils.getLanguage("lbl.yes")); cbMotobikeParkingYes.setValue(Boolean.TRUE); hlMotobikeParking.addComponent(cbMotobikeParkingYes); cbMotobikeParkingNo = new CheckBox(BundleUtils.getLanguage("lbl.no")); cbMotobikeParkingNo.setValue(Boolean.TRUE); hlMotobikeParking.addComponent(cbMotobikeParkingNo); tfOperatingTimeStart = new TimeField(); tfOperatingTimeEnd = new TimeField(); HorizontalLayout hlOperatingTime = new HorizontalLayout(tfOperatingTimeStart, new Label(" - "), tfOperatingTimeEnd); hlOperatingTime.setCaption(BundleUtils.getLanguage("lbl.restaurant.operatingTime")); hlOperatingTime.setSpacing(true); form.addComponent(hlOperatingTime); String regexDouble = "[0-9]*.?[0-9]?"; String regexInteger = "[0-9]*"; tfViewCountFrom = new TextField(); tfViewCountFrom.setWidth(200.0f, Unit.PIXELS); tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlViewCountFrom = new CSValidator(); vlViewCountFrom.extend(tfViewCountFrom); vlViewCountFrom.setRegExp(regexInteger); vlViewCountFrom.setPreventInvalidTyping(true); tfViewCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number")); tfViewCountTo = new TextField(); tfViewCountTo.setWidth(200.0f, Unit.PIXELS); tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlViewCountTo = new CSValidator(); vlViewCountTo.extend(tfViewCountTo); vlViewCountTo.setRegExp(regexInteger); vlViewCountTo.setPreventInvalidTyping(true); tfViewCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number")); HorizontalLayout hlViewCount = new HorizontalLayout(tfViewCountFrom, new Label("-"), tfViewCountTo); hlViewCount.setCaption(BundleUtils.getLanguage("lbl.restaurant.viewCount")); hlViewCount.setSpacing(true); form.addComponent(hlViewCount); tfCommentCountFrom = new TextField(); tfCommentCountFrom.setWidth(200.0f, Unit.PIXELS); tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlCommentCountFrom = new CSValidator(); vlCommentCountFrom.extend(tfCommentCountFrom); vlCommentCountFrom.setRegExp(regexInteger); vlCommentCountFrom.setPreventInvalidTyping(true); tfCommentCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number")); tfCommentCountTo = new TextField(); tfCommentCountTo.setWidth(200.0f, Unit.PIXELS); tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlCommentCountTo = new CSValidator(); vlCommentCountTo.extend(tfCommentCountTo); vlCommentCountTo.setRegExp(regexInteger); vlCommentCountTo.setPreventInvalidTyping(true); tfCommentCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number")); HorizontalLayout hlCommentCount = new HorizontalLayout(tfCommentCountFrom, new Label("-"), tfCommentCountTo); hlCommentCount.setCaption(BundleUtils.getLanguage("lbl.restaurant.commentCount")); hlCommentCount.setSpacing(true); form.addComponent(hlCommentCount); tfShareCountFrom = new TextField(); tfShareCountFrom.setWidth(200.0f, Unit.PIXELS); tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlShareCountFrom = new CSValidator(); vlShareCountFrom.extend(tfShareCountFrom); vlShareCountFrom.setRegExp(regexInteger); vlShareCountFrom.setPreventInvalidTyping(true); tfShareCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number")); tfShareCountTo = new TextField(); tfShareCountTo.setWidth(200.0f, Unit.PIXELS); tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlShareCountTo = new CSValidator(); vlShareCountTo.extend(tfShareCountTo); vlShareCountTo.setRegExp(regexInteger); vlShareCountTo.setPreventInvalidTyping(true); tfShareCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number")); HorizontalLayout hlShareCount = new HorizontalLayout(tfShareCountFrom, new Label("-"), tfShareCountTo); hlShareCount.setCaption(BundleUtils.getLanguage("lbl.restaurant.shareCount")); hlShareCount.setSpacing(true); form.addComponent(hlShareCount); tfRatingFrom = new TextField(); tfRatingFrom.setWidth(200.0f, Unit.PIXELS); tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlRatingFrom = new CSValidator(); vlRatingFrom.extend(tfRatingFrom); vlRatingFrom.setRegExp(regexDouble); vlRatingFrom.setPreventInvalidTyping(true); tfRatingFrom.addValidator(new RegexpValidator(regexDouble, "Not a number")); tfRatingTo = new TextField(); tfRatingTo.setWidth(200.0f, Unit.PIXELS); tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlRatingTo = new CSValidator(); vlRatingTo.extend(tfRatingTo); vlRatingTo.setRegExp(regexDouble); vlRatingTo.setPreventInvalidTyping(true); tfRatingTo.addValidator(new RegexpValidator(regexDouble, "Not a number")); HorizontalLayout hlRating = new HorizontalLayout(tfRatingFrom, new Label("-"), tfRatingTo); hlRating.setCaption(BundleUtils.getLanguage("lbl.restaurant.rating")); hlRating.setSpacing(true); form.addComponent(hlRating); tfPriceFromVn = new TextField(); tfPriceFromVn.setWidth(200.0f, Unit.PIXELS); tfPriceFromVn.addStyleName(ValoTheme.TEXTFIELD_TINY); tfPriceFromVn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlPriceFromVn = new CSValidator(); vlPriceFromVn.extend(tfPriceFromVn); vlPriceFromVn.setRegExp(regexDouble); vlPriceFromVn.setPreventInvalidTyping(true); tfPriceFromVn.addValidator(new RegexpValidator(regexDouble, "Not a number")); tfPriceToVn = new TextField(); tfPriceToVn.setWidth(200.0f, Unit.PIXELS); tfPriceToVn.addStyleName(ValoTheme.TEXTFIELD_TINY); tfPriceToVn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlPriceToVn = new CSValidator(); vlPriceToVn.extend(tfPriceToVn); vlPriceToVn.setRegExp(regexDouble); vlPriceToVn.setPreventInvalidTyping(true); tfPriceToVn.addValidator(new RegexpValidator(regexDouble, "Not a number")); HorizontalLayout hlPriceVn = new HorizontalLayout(tfPriceFromVn, new Label("-"), tfPriceToVn, new Label("VND")); hlPriceVn.setCaption(BundleUtils.getLanguage("lbl.restaurant.priceVn")); hlPriceVn.setSpacing(true); form.addComponent(hlPriceVn); tfPriceFromEn = new TextField(); tfPriceFromEn.setWidth(200.0f, Unit.PIXELS); tfPriceFromEn.addStyleName(ValoTheme.TEXTFIELD_TINY); tfPriceFromEn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlPriceFromEn = new CSValidator(); vlPriceFromEn.extend(tfPriceFromEn); vlPriceFromEn.setRegExp(regexDouble); vlPriceFromEn.setPreventInvalidTyping(true); tfPriceFromEn.addValidator(new RegexpValidator(regexDouble, "Not a number")); tfPriceToEn = new TextField(); tfPriceToEn.setWidth(200.0f, Unit.PIXELS); tfPriceToEn.addStyleName(ValoTheme.TEXTFIELD_TINY); tfPriceToEn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlPriceToEn = new CSValidator(); vlPriceToEn.extend(tfPriceToEn); vlPriceToEn.setRegExp(regexDouble); vlPriceToEn.setPreventInvalidTyping(true); tfPriceToEn.addValidator(new RegexpValidator(regexDouble, "Not a number")); HorizontalLayout hlPriceEn = new HorizontalLayout(tfPriceFromEn, new Label("-"), tfPriceToEn, new Label("USD")); hlPriceEn.setCaption(BundleUtils.getLanguage("lbl.restaurant.priceEn")); hlPriceEn.setSpacing(true); form.addComponent(hlPriceEn); tfWaitingTimeFrom = new TextField(); tfWaitingTimeFrom.setWidth(200.0f, Unit.PIXELS); tfWaitingTimeFrom.addStyleName(ValoTheme.TEXTFIELD_TINY); tfWaitingTimeFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlWaitingTimeFrom = new CSValidator(); vlWaitingTimeFrom.extend(tfWaitingTimeFrom); vlWaitingTimeFrom.setRegExp(regexDouble); vlWaitingTimeFrom.setPreventInvalidTyping(true); tfWaitingTimeFrom.addValidator(new RegexpValidator(regexDouble, "Not a number")); tfWaitingTimeTo = new TextField(); tfWaitingTimeTo.setWidth(200.0f, Unit.PIXELS); tfWaitingTimeTo.addStyleName(ValoTheme.TEXTFIELD_TINY); tfWaitingTimeTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); CSValidator vlWaitingTimeTo = new CSValidator(); vlWaitingTimeTo.extend(tfWaitingTimeTo); vlWaitingTimeTo.setRegExp(regexDouble); vlWaitingTimeTo.setPreventInvalidTyping(true); tfWaitingTimeTo.addValidator(new RegexpValidator(regexDouble, "Not a number")); HorizontalLayout hlWaitingTime = new HorizontalLayout(tfWaitingTimeFrom, new Label("-"), tfWaitingTimeTo); hlWaitingTime.setCaption(BundleUtils.getLanguage("lbl.dish.waitingTime")); hlWaitingTime.setSpacing(true); form.addComponent(hlWaitingTime); Map<String, LocaleDTO> mapLocale = ClientServiceImpl.getAllLocales(); if (mapLocale != null && !mapLocale.isEmpty()) { List<LocaleDTO> listLocale = new ArrayList<>(mapLocale.values()); listLocale.stream().map((localeDTO) -> new OptionGroupUI(localeDTO.getLocale()// , localeDTO.getId())).forEach((ogLocale) -> { form.addComponent(ogLocale); listOgLocale.add(ogLocale); }); } tagSuggestFieldUI = new TagSuggestFieldUI(false); tagSuggestFieldUI.setWidth(80.0f, Unit.PERCENTAGE); form.addComponent(tagSuggestFieldUI); HorizontalLayout hlButton = new HorizontalLayout(); hlButton.setSpacing(true); hlButton.setMargin(true); form.addComponent(hlButton); btnSearch = new Button(BundleUtils.getLanguage("lbl.search"), FontAwesome.SEARCH); hlButton.addComponent(btnSearch); btnExportExcel = new Button(BundleUtils.getLanguage("lbl.exportExcel"), FontAwesome.FILE_EXCEL_O); hlButton.addComponent(btnExportExcel); btnExportXML = new Button(BundleUtils.getLanguage("lbl.exportXML"), FontAwesome.FILE_CODE_O); hlButton.addComponent(btnExportXML); btnCancel = new Button(BundleUtils.getLanguage("lbl.cancel"), FontAwesome.BAN); hlButton.addComponent(btnCancel); }
From source file:com.lizardtech.expresszip.vaadin.ExportOptionsViewComponent.java
License:Apache License
public ExportOptionsViewComponent(ExportProps exportProps) { this.exportProps = exportProps; listeners = new ArrayList<ExportOptionsViewListener>(); txtJobName = new TextField(JOB_NAME); txtEmail = new TextField(EMAIL_ADDRESS); txtUserNotation = new TextField(JOB_USER_NOTATION); numTilesLabel = new Label(); exportSizeEstimate = new Label(); outputFormatComboBox = new ComboBox(OUTPUT_FORMAT, OUTPUT_FORMATS); outputFormatComboBox.setTextInputAllowed(false); outputFormatComboBox.addListener(griddingValuesChangeListener); setSizeFull();/*from ww w. ja v a 2s .c o m*/ /** * Setup output resolution */ exportSizeComboBox = new ComboBox(null, exportSizes); exportSizeComboBox.setNullSelectionAllowed(false); exportSizeComboBox.setNewItemsAllowed(false); exportSizeComboBox.setTextInputAllowed(false); exportSizeComboBox.setImmediate(true); exportSizeComboBox.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { Object choice = event.getProperty().getValue(); String value = ""; if (SMALL.equals(choice)) { gridCheckbox.setValue(Boolean.FALSE); gridCheckbox.setEnabled(false); value = "512"; } else if (MEDIUM.equals(choice)) { gridCheckbox.setValue(Boolean.FALSE); gridCheckbox.setEnabled(false); value = "1280"; } else if (LARGE.equals(choice)) { gridCheckbox.setValue(Boolean.FALSE); gridCheckbox.setEnabled(false); value = "5000"; } boolean custom = CUSTOM.equals(choice); if (!custom) { if (NATIVE.equals(choice)) { txtGroundResolution.setValue(Double.toString(maximumResolution)); } else { if (getExportProps().getAspectRatio() > 1.0d) { txtDimHeight.setValue(value); } else txtDimWidth.setValue(value); } } txtDimWidth.setEnabled(custom); txtDimHeight.setEnabled(custom); txtGroundResolution.setEnabled(custom); } }); // Add Output Resolution to view HorizontalLayout dimensionsLayout = new HorizontalLayout(); dimensionsLayout.addComponent(txtDimWidth); dimensionsLayout.addComponent(txtDimHeight); dimensionsLayout.setSpacing(true); dimensionsLayout.setWidth("100%"); // Format dimensions layout txtDimHeight.setMaxLength(10); txtDimHeight.setWidth("100%"); txtDimHeight.setImmediate(true); txtDimHeight.addListener(heightValChangeListener); txtDimHeight.setRequired(true); txtDimHeight.addValidator(new WidthHeightValidator()); txtDimWidth.setMaxLength(10); txtDimWidth.setWidth("100%"); txtDimWidth.setImmediate(true); txtDimWidth.addListener(widthValChangeListener); txtDimWidth.setRequired(true); txtDimWidth.addValidator(new WidthHeightValidator()); // Format Ground Resolution layout txtGroundResolution.setValue("0"); txtGroundResolution.setImmediate(true); txtGroundResolution.addListener(groundResValChangeListener); txtGroundResolution.setRequired(true); txtGroundResolution.addValidator(new GroundResolutionValidator()); vrtOutputResolution = new VerticalLayout(); vrtOutputResolution.setSpacing(true); vrtOutputResolution.addComponent(exportSizeComboBox); vrtOutputResolution.addComponent(dimensionsLayout); txtGroundResolution.setWidth("75%"); vrtOutputResolution.addComponent(txtGroundResolution); vrtOutputResolution.setComponentAlignment(txtGroundResolution, Alignment.BOTTOM_CENTER); /** * Setup Gridding options */ // Add Gridding option to view griddingLayout = new VerticalLayout(); griddingLayout.setSpacing(true); // Format GridCheckbox layout griddingLayout.addComponent(gridCheckbox); gridCheckbox.setImmediate(true); gridCheckbox.setValue(false); gridCheckbox.addListener(griddingModeChangeListener); xPixelsTextBox.setWidth("100%"); xPixelsTextBox.setImmediate(true); xPixelsTextBox.addValidator(new TileWidthValidator()); xPixelsTextBox.addListener(griddingValuesChangeListener); yPixelsTextBox.setWidth("100%"); yPixelsTextBox.setImmediate(true); yPixelsTextBox.addValidator(new TileHeightValidator()); yPixelsTextBox.addListener(griddingValuesChangeListener); xDistanceTextBox.setWidth("100%"); xDistanceTextBox.setImmediate(true); xDistanceTextBox.addValidator(new TileGeoXValidator()); xDistanceTextBox.addListener(griddingValuesChangeListener); yDistanceTextBox.setWidth("100%"); yDistanceTextBox.setImmediate(true); yDistanceTextBox.addValidator(new TileGeoYValidator()); yDistanceTextBox.addListener(griddingValuesChangeListener); // Format gridding options xTilesTextBox.setWidth("100%"); xTilesTextBox.setImmediate(true); xTilesTextBox.addValidator(new TileXDivisorValidator()); xTilesTextBox.addListener(griddingValuesChangeListener); yTilesTextBox.setWidth("100%"); yTilesTextBox.setImmediate(true); yTilesTextBox.addValidator(new TileYDivisorValidator()); yTilesTextBox.addListener(griddingValuesChangeListener); optGridOpt.setValue(GRID_TILE_DIMENSIONS); optGridOpt.setImmediate(true); optGridOpt.addListener(griddingModeChangeListener); HorizontalLayout hznGridOptions = new HorizontalLayout(); griddingLayout.addComponent(hznGridOptions); hznGridOptions.setWidth("100%"); hznGridOptions.setSpacing(true); hznGridOptions.addComponent(optGridOpt); VerticalLayout vrtGridComboFields = new VerticalLayout(); hznGridOptions.addComponent(vrtGridComboFields); vrtGridComboFields.setWidth("100%"); hznGridOptions.setExpandRatio(vrtGridComboFields, 1.0f); HorizontalLayout hznTileDim = new HorizontalLayout(); hznTileDim.setWidth("100%"); vrtGridComboFields.addComponent(hznTileDim); hznTileDim.addComponent(xPixelsTextBox); hznTileDim.addComponent(yPixelsTextBox); HorizontalLayout hznDistanceDim = new HorizontalLayout(); hznDistanceDim.setWidth("100%"); vrtGridComboFields.addComponent(hznDistanceDim); hznDistanceDim.addComponent(xDistanceTextBox); hznDistanceDim.addComponent(yDistanceTextBox); HorizontalLayout hznDivideGrid = new HorizontalLayout(); hznDivideGrid.setWidth("100%"); vrtGridComboFields.addComponent(hznDivideGrid); hznDivideGrid.addComponent(xTilesTextBox); hznDivideGrid.addComponent(yTilesTextBox); hznDivideGrid.setSpacing(true); hznTileDim.setSpacing(true); hznDistanceDim.setSpacing(true); /** * Format options panel */ // Add Format options to view formatOptionsLayout = new VerticalLayout(); formatOptionsLayout.setWidth("100%"); formatOptionsLayout.setSpacing(true); formatOptionsLayout.setMargin(true); // Format outputformat formatOptionsLayout.addComponent(outputFormatComboBox); outputFormatComboBox.setNullSelectionAllowed(false); formatOptionsLayout.addComponent(packageComboBox); packageComboBox.addItem(ExportProps.OutputPackageFormat.TAR); packageComboBox.addItem(ExportProps.OutputPackageFormat.ZIP); packageComboBox.setNullSelectionAllowed(false); packageComboBox.setTextInputAllowed(false); packageComboBox.setValue(ExportProps.OutputPackageFormat.ZIP); /** * Job Details */ // Set Jobname panel jobDetailsLayout = new VerticalLayout(); jobDetailsLayout.setSpacing(true); jobDetailsLayout.setMargin(true); jobDetailsLayout.addComponent(txtJobName); txtJobName.setRequired(true); txtJobName.setRequiredError("Please enter a job name."); txtJobName.setWidth("100%"); txtJobName.setImmediate(true); String jobname_regexp = "^[ A-Za-z0-9._-]{1,128}$"; txtJobName.addValidator(new RegexpValidator(jobname_regexp, "Job names should be alpha-numeric, less than 128 characters and may include spaces, dashes and underscores")); txtJobName.addValidator(new JobNameUniqueValidator( "A job by that name already exists in your configured export directory")); txtJobName.addListener(resolutionValuesChangeListener); jobDetailsLayout.addComponent(txtUserNotation); txtUserNotation.setWidth("100%"); txtUserNotation.setImmediate(true); String usernotation_regexp = "^[ A-Za-z0-9_-]{0,32}$"; txtUserNotation.addValidator(new RegexpValidator(usernotation_regexp, "User names should be alpha-numeric, less than 32 characters and may include spaces, dashes and underscores")); txtUserNotation.addListener(resolutionValuesChangeListener); // Format Email boolean enableEmail = new BackgroundExecutor.Factory().getBackgroundExecutor().getMailServices() .isValidEmailConfig(); txtEmail.setEnabled(enableEmail); if (enableEmail) { jobDetailsLayout.addComponent(txtEmail); txtEmail.setWidth("100%"); txtEmail.setInputPrompt("enter your email address"); txtEmail.setImmediate(true); txtEmail.addValidator(new EmailValidator("Invalid format for email address.")); txtEmail.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateSubmitEnabledState(); } }); } VerticalLayout exportSummary = new VerticalLayout(); exportSummary.addComponent(numTilesLabel); exportSummary.addComponent(exportSizeEstimate); jobDetailsLayout.addComponent(new Panel(("Export summary"), exportSummary)); // Set submit and back buttons // Add listeners to all fields backButton = new ExpressZipButton("Back", Style.STEP); backButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { ((ExpressZipWindow) getApplication().getMainWindow()).regressToPrev(); } }); submitButton = new ExpressZipButton("Submit", Style.STEP); submitButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { txtJobName.validate(); } catch (InvalidValueException e) { txtJobName.requestRepaint(); updateSubmitEnabledState(); return; } for (ExportOptionsViewListener listener : listeners) { listener.submitJobEvent(getExportProps()); } } }); accordian = new Accordion(); accordian.addStyleName("expresszip"); accordian.setImmediate(true); accordian.addTab(jobDetailsLayout, JOB_DETAILS); accordian.addTab(formatOptionsLayout, FORMAT_OPTIONS); accordian.setSizeFull(); outputDetails = new VerticalLayout(); outputDetails.setMargin(true); outputDetails.setSpacing(true); outputDetails.addComponent(new Panel(DIMENSIONS, vrtOutputResolution)); outputDetails.addComponent(new Panel(TILING, griddingLayout)); accordian.addTab(outputDetails, EXPORT_CONFIGURATION); HorizontalLayout backSubmitLayout = new HorizontalLayout(); backSubmitLayout.setWidth("100%"); backSubmitLayout.addComponent(backButton); backSubmitLayout.addComponent(submitButton); backSubmitLayout.setComponentAlignment(backButton, Alignment.BOTTOM_LEFT); backSubmitLayout.setComponentAlignment(submitButton, Alignment.BOTTOM_RIGHT); VerticalLayout navLayout = new VerticalLayout(); navLayout.addComponent(backSubmitLayout); navLayout.setSpacing(true); ThemeResource banner = new ThemeResource("img/ProgressBar3.png"); navLayout.addComponent(new Embedded(null, banner)); // add scrollbars around formLayout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); layout.setSpacing(true); Label step = new Label("Step 3: Configure Export Options"); step.addStyleName("step"); layout.addComponent(step); layout.addComponent(accordian); layout.setExpandRatio(accordian, 1.0f); layout.addComponent(navLayout); layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER); setCompositionRoot(layout); outputFormatComboBox.select(OUTPUT_FORMATS.get(0)); forceGriddingCheck(); updateGriddingEnabledState(); }
From source file:com.trender.user.component.UserForm.java
public Component regForm() { init("???");//from w ww. j a v a 2s .c om surnameField = new TextField("?"); surnameField.addStyleName("v-textfield-borderless"); surnameField.addValidator(new StringLengthValidator( " , " + "? 2 ?, ?? 45", 2, 45, false)); surnameField.addValidator(new NullValidator("? ", false)); surnameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); surnameField.setInputPrompt("?"); surnameField.setRequired(true); nameField = new TextField("?"); nameField.addStyleName("v-textfield-borderless"); nameField.addValidator(new StringLengthValidator(" ?, ? " + " 2 ?, ?? 45", 2, 45, false)); nameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); nameField.addValidator(new NullValidator("? ", false)); nameField.setInputPrompt("?"); nameField.setRequired(true); addComponent(surnameField); addComponent(nameField); addComponent(horizontalLayout); setMargin(new MarginInfo(false, false, true, true)); performButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UserForm.this.singUp(); } }); clearButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UserForm.this.clearForm(true); } }); return this; }
From source file:com.trender.user.component.UserForm.java
public Component ProfilForm() { addStyleName("light"); setWidth(90, Unit.PERCENTAGE);/*from w w w .j av a2 s.c o m*/ Label title = new Label(); title.setStyleName("h2"); title.setValue(""); passwordField = new PasswordField(" "); passwordField.setInputPrompt("12345678"); passwordField.setWidth(80, Unit.PERCENTAGE); surnameField = new TextField("?"); surnameField.addValidator(new StringLengthValidator( " , " + "? 2 ?, ?? 45", 2, 45, false)); surnameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); surnameField.setInputPrompt("?"); surnameField.setWidth(80, Unit.PERCENTAGE); nameField = new TextField("?"); nameField.addValidator(new StringLengthValidator(" ?, ? " + " 2 ?, ?? 45", 2, 45, false)); nameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); nameField.setInputPrompt("?"); nameField.setWidth(80, Unit.PERCENTAGE); performButton = new Button(""); performButton.setStyleName("v-button-friendly"); clearButton = new Button("?"); clearButton.setStyleName("v-button-quiet"); horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(performButton); horizontalLayout.addComponent(clearButton); horizontalLayout.setSpacing(true); horizontalLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); horizontalLayout.setMargin(new MarginInfo(true, false, false, true)); addComponent(title); addComponent(passwordField); addComponent(surnameField); addComponent(nameField); addComponent(horizontalLayout); return this; }
From source file:control.ExperimentImportController.java
License:Open Source License
protected void initMissingInfoListener(SamplePreparator prep, Map<String, List<String>> missingCategoryToValues, Map<String, List<String>> catToVocabulary) { extCodeToBarcode = new HashMap<String, String>(); // TODO where is this added? does it need to be added? ProjectInformationComponent projectInfoComponent = new ProjectInformationComponent(vocabs.getSpaces(), vocabs.getPeople().keySet()); ValueChangeListener missingInfoFilledListener = new ValueChangeListener() { @Override/*from ww w. j av a 2 s .c om*/ public void valueChange(ValueChangeEvent event) { boolean overflow = false; boolean infoComplete = questionaire.isValid(); boolean samplesToRegister = false; if (infoComplete) { List<SampleSummaryBean> summaries = prep.getSummary(); for (SampleSummaryBean b : summaries) { String cat = ""; if (b.getSampleType().contains("Source")) cat = "Species"; else if (b.getSampleType().contains("Sample Extract")) cat = "Tissues"; else if (b.getSampleType().contains("Preparations")) cat = "Analytes"; if (missingCategoryToValues.containsKey(cat)) { String val = b.getFullSampleContent(); List<String> newVal = new ArrayList<String>(); for (String v : val.split(", ")) { v = v.trim(); String translation = questionaire.getVocabularyLabelForValue(cat, v); if (translation == null) translation = reverseTissueMap.get(v); if (translation == null) translation = v; newVal.add(translation); } b.setSampleContent(StringUtils.join(newVal, ", ")); } } view.setSummary(summaries); projectInfo = projectInfoComponent.getProjectInfo(); String space = questionaire.getSpaceCode(); String project = questionaire.getProjectCode(); try { countExistingOpenbisEntities(space, project); } catch (TooManySamplesException e1) { // TODO Auto-generated catch block overflow = true; } int entityNum = firstFreeEntityID; nextBarcode = null; List<List<ISampleBean>> processed = prep.getProcessed(); Set<String> msCodes = new HashSet<String>(); dnaSampleCodeToMHCType = new HashMap<String, MHCTyping>(); Map<String, String> specialExpToExpCode = new HashMap<String, String>(); for (List<ISampleBean> level : processed) { String type = level.get(0).getType(); String exp = ""; if (!type.equals("Q_MS_RUN") && !type.equals("Q_MHC_LIGAND_EXTRACT")) exp = getNextExperiment(project); // list of existing samples to be removed before registration List<ISampleBean> existing = new ArrayList<ISampleBean>(); for (ISampleBean b : level) { TSVSampleBean t = (TSVSampleBean) b; String extID = (String) t.getMetadata().get("Q_EXTERNALDB_ID"); if (extIDToSample.containsKey(extID)) { existing.add(t); extCodeToBarcode.put(extID, extIDToSample.get(extID).getCode()); } else { t.setProject(project); t.setSpace(space); String code = ""; Map<String, Object> props = t.getMetadata(); switch (t.getType()) { case "Q_BIOLOGICAL_ENTITY": code = project + "ENTITY-" + entityNum; String newVal = questionaire.getVocabularyLabelForValue("Species", props.get("Q_NCBI_ORGANISM")); props.put("Q_NCBI_ORGANISM", taxMap.get(newVal)); entityNum++; break; case "Q_BIOLOGICAL_SAMPLE": try { incrementOrCreateBarcode(project); } catch (TooManySamplesException e) { overflow = true; } code = nextBarcode; newVal = questionaire.getVocabularyLabelForValue("Tissues", props.get("Q_PRIMARY_TISSUE")); props.put("Q_PRIMARY_TISSUE", tissueMap.get(newVal)); break; case "Q_TEST_SAMPLE": try { incrementOrCreateBarcode(project); } catch (TooManySamplesException e) { overflow = true; } code = nextBarcode; newVal = questionaire.getVocabularyLabelForValue("Analytes", props.get("Q_SAMPLE_TYPE")); props.put("Q_SAMPLE_TYPE", newVal); if (getImportType().equals(DesignType.MHC_Ligands_Finished)) { if ("DNA".equals(newVal)) { List<String> c1 = (List<String>) props.get("MHC_I"); List<String> c2 = (List<String>) props.get("MHC_II"); dnaSampleCodeToMHCType.put(code, new MHCTyping(c1, c2)); props.remove("MHC_I"); props.remove("MHC_II"); } } break; case "Q_MHC_LIGAND_EXTRACT": try { incrementOrCreateBarcode(project); } catch (TooManySamplesException e) { overflow = true; } code = nextBarcode; if (!specialExpToExpCode.containsKey(t.getExperiment())) { specialExpToExpCode.put(t.getExperiment(), getNextExperiment(project)); } exp = specialExpToExpCode.get(t.getExperiment()); break; case "Q_MS_RUN": // get ms experiment to connect it correctly if (!specialExpToExpCode.containsKey(t.getExperiment())) { specialExpToExpCode.put(t.getExperiment(), getNextExperiment(project)); } exp = specialExpToExpCode.get(t.getExperiment()); // get parent sample for code String parentExtID = t.fetchParentIDs().get(0); String parentCode = extCodeToBarcode.get(parentExtID);// .getCode(); int msRun = 1; code = ""; while (code.isEmpty() || msCodes.contains(code)) { code = "MS" + Integer.toString(msRun) + parentCode; msRun++; } msCodes.add(code); break; } t.setExperiment(exp); t.setCode(code); extCodeToBarcode.put((String) props.get("Q_EXTERNALDB_ID"), code);// t); List<String> parents = t.fetchParentIDs(); t.setParents(""); for (String parentExtID : parents) { if (extCodeToBarcode.containsKey(parentExtID)) t.addParent(extCodeToBarcode.get(parentExtID));// .getCode()); else logger.warn( "Parent could not be translated, because no ext id to code mapping was found for ext id " + parentExtID); } } } // remove existing samples from registration process level.removeAll(existing); samplesToRegister |= !level.isEmpty(); } fixSpecialExperiments(specialExpToExpCode); view.setProcessed(processed); } view.setRegEnabled(infoComplete && samplesToRegister && !overflow); if (infoComplete) { if (!samplesToRegister) { Styles.notification("Samples already exist.", "Every Analyte ID was already found in existing samples of this project.", NotificationType.DEFAULT); } if (overflow) { Styles.notification("Too many samples.", "This experiment exceeds the maximum number of samples for one project.", NotificationType.ERROR); } } } private void fixSpecialExperiments(Map<String, String> specialExpToExpCode) { Set<String> codes = new HashSet<String>(); if (mhcProperties != null) { codes.addAll(mhcProperties.keySet()); for (String code : codes) { mhcProperties.put(specialExpToExpCode.get(code), mhcProperties.get(code)); mhcProperties.remove(code); } } codes.clear(); if (msProperties != null) { codes.addAll(msProperties.keySet()); for (String code : codes) { msProperties.put(specialExpToExpCode.get(code), msProperties.get(code)); msProperties.remove(code); } } } }; questionaire = view.initMissingInfoComponent(projectInfoComponent, missingCategoryToValues, catToVocabulary, missingInfoFilledListener); // view.addComponent(questionaire); // add project code validators TextField f = projectInfoComponent.getProjectField(); CompositeValidator vd = new CompositeValidator(); RegexpValidator p = new RegexpValidator("Q[A-Xa-x0-9]{4}", "Project must have length of 5, start with Q and not contain Y or Z"); vd.addValidator(p); vd.addValidator(new ProjectNameValidator(openbis)); f.addValidator(vd); f.setImmediate(true); f.setValidationVisible(true); FocusListener fListener = new FocusListener() { private static final long serialVersionUID = 8721337946386845992L; @Override public void focus(FocusEvent event) { TextField pr = projectInfoComponent.getProjectField(); if (!pr.isValid() || pr.isEmpty()) { // new project selected...keep generating codes until one is valid projectInfoComponent.tryEnableCustomProject(generateUnusedProjectCode()); } } }; projectInfoComponent.getProjectField().addFocusListener(fListener); Button.ClickListener projCL = new Button.ClickListener() { /** * */ private static final long serialVersionUID = -6646294420820222646L; @Override public void buttonClick(ClickEvent event) { String existingProject = (String) projectInfoComponent.getProjectBox().getValue(); if (existingProject == null || existingProject.isEmpty()) { projectInfoComponent.tryEnableCustomProject(generateUnusedProjectCode()); } } }; projectInfoComponent.getProjectReloadButton().addClickListener(projCL); questionaire.getSpaceBox().addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { questionaire.resetProjects(); String space = questionaire.getSpaceCode(); if (space != null) { List<String> projects = new ArrayList<String>(); for (Project p : openbis.getProjectsOfSpace(space)) { String code = p.getCode(); // String name = dbm.getProjectName("/" + space + "/" + code); // if (name != null && name.length() > 0) { // if (name.length() >= 80) // name = name.substring(0, 80) + "..."; // code += " (" + name + ")"; // } projects.add(code); } questionaire.setProjectCodes(projects); } } }); }