@Override protected Layout addFields(FieldGroup fieldGroup) { Layout l = super.addFields(fieldGroup); Field id = (Field) fieldGroup.getField("id"); id.setRequired(true); id.setRequiredError(getApp().getMessage("errorMessage.req", id.getCaption())); String idValue = (String) fieldGroup.getItemDataSource().getItemProperty("id").getValue(); // Hide prefix if (idValue != null) { // Means it is not a new sysconfig entry id.setReadOnly(false); idValue = prefix != null ? idValue.substring(prefix.length()) : idValue; id.setValue(idValue); id.setReadOnly(true); } return l; }
@Override protected void attachField(Object propertyId, Field field) { PhysicalAttributeConfirmActualsFieldSetComponent fieldSet = ((CollapsiblePhysicalAttributeConfirmActualsFormComponent) getComponentModel()) .getFieldSetForField((String) propertyId); if (fieldSet != null) { PhysicalAttributeConfirmActualsFieldSetFieldComponent fieldComponent = fieldSet.getFieldSetField((String) propertyId); if (fieldComponent != null) { fields.put(field, fieldComponent); field.setWidth("100%"); VaadinFormFieldAugmenter.augment(field, fieldComponent); if (this.getComponentModel().isReadOnly()) { field.setReadOnly(true); } VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader header = headers.get(fieldSet); if (header == null) { header = addFormSection(fieldSet); } GridLayout gridLayout = (GridLayout) header.getLayout(); Integer index = fieldIndexMap.get(fieldComponent); if (index == null) { index = getNextIndex(gridLayout); fieldIndexMap.put(fieldComponent, index); } allocateIndex(gridLayout, index); Label label = new Label(fieldComponent.getCaption()); label.setStyleName("conx-confirm-actuals-field-caption"); label.setWidth("100%"); addCaptionLabel(gridLayout, index, label); if (fieldSet.isExpected(propertyId)) { field.setEnabled(false); field.setCaption(null); addExpectedField(gridLayout, index, field); } else if (fieldSet.isActual(propertyId)) { field.setCaption(null); addActualField(gridLayout, index, field); } else if (fieldSet.isActualUnit(propertyId)) { field.setCaption(null); addActualUnitField(gridLayout, index, field); } else if (fieldSet.isExpectedUnit(propertyId)) { field.setCaption(null); field.setEnabled(false); addExpectedUnitField(gridLayout, index, field); } } } }