protected void initCategoryField() { categoryField.setDatasource(rds.getMainDs(), "category"); categoryField.setOptionsDatasource(categoriesDs); }
protected void addFieldsToFieldGroup(FieldGroup newRuntimeFieldGroup, List<FieldGroup.FieldConfig> fields) { int rowsPerColumn; int propertiesCount = rds.getPropertiesFilteredByCategory().size(); if (StringUtils.isNotBlank(cols)) { if (propertiesCount % Integer.parseInt(cols) == 0) { rowsPerColumn = propertiesCount / Integer.parseInt(cols); } else { rowsPerColumn = propertiesCount / Integer.parseInt(cols) + 1; } } else if (StringUtils.isNotBlank(rows)) { rowsPerColumn = Integer.parseInt(rows); } else { rowsPerColumn = propertiesCount; } int columnNo = 0; int fieldsCount = 0; for (FieldGroup.FieldConfig field : fields) { fieldsCount++; newRuntimeFieldGroup.addField(field, columnNo); if (fieldsCount % rowsPerColumn == 0) { columnNo++; newRuntimeFieldGroup.setColumns(columnNo + 1); } } }
protected MetaClass resolveMetaClass(Datasource datasource) { return datasource instanceof RuntimePropsDatasource ? ((RuntimePropsDatasource) datasource).resolveCategorizedEntityClass() : datasource.getMetaClass(); } }
protected void createRuntimeDataComponents() { if (rDS != null && categoriesDs != null) { Map<String, Object> params = new HashMap<>(); params.put("runtimeDs", rDS.getId()); params.put("categoriesDs", categoriesDs.getId()); params.put("fieldWidth", themeConstants.get("cuba.gui.EntityInspectorEditor.field.width")); params.put("borderVisible", Boolean.TRUE); RuntimePropertiesFrame runtimePropertiesFrame = (RuntimePropertiesFrame) openFrame(runtimePane, "runtimePropertiesFrame", params); runtimePropertiesFrame.setFrame(this.getFrame()); runtimePropertiesFrame.setMessagesPack("com.haulmont.cuba.gui.app.core.entityinspector"); runtimePropertiesFrame.setCategoryFieldVisible(false); runtimePropertiesFrame.setHeightAuto(); runtimePropertiesFrame.setWidthFull(); runtimePane.add(runtimePropertiesFrame); } }
protected void loadValidators(FieldGroup fieldGroup, FieldGroup.FieldConfig field) { MetaPropertyPath metaPropertyPath = rds.getMetaClass().getPropertyPath(field.getProperty()); if (metaPropertyPath != null) { MetaProperty metaProperty = metaPropertyPath.getMetaProperty(); Consumer validator = getValidator(metaProperty); if (validator != null) { field.addValidator(validator); } } }
protected void loadRequired(FieldGroup fieldGroup, FieldGroup.FieldConfig field) { CategoryAttribute attribute = dynamicAttributes.getAttributeForMetaClass(rds.resolveCategorizedEntityClass(), field.getId()); if (attribute != null) { String requiredMessage = messages.formatMainMessage( "validation.required.defaultMsg", attribute.getName() ); field.setRequired(Boolean.TRUE.equals(attribute.getRequired()) && requiredControlEnabled); field.setRequiredMessage(requiredMessage); } }
protected List<FieldGroup.FieldConfig> createFieldsForAttributes(FieldGroup newRuntimeFieldGroup) { @SuppressWarnings("unchecked") Collection<DynamicAttributesMetaProperty> metaProperties = rds.getPropertiesFilteredByCategory(); List<FieldGroup.FieldConfig> fields = new ArrayList<>(metaProperties.size()); for (DynamicAttributesMetaProperty property : metaProperties) { FieldGroup.FieldConfig field = newRuntimeFieldGroup.createField(property.getName()); field.setProperty(property.getName()); CategoryAttribute attribute = property.getAttribute(); if (attribute != null) { field.setCaption(attribute.getLocaleName()); if (StringUtils.isNotBlank(attribute.getWidth())) { field.setWidth(attribute.getWidth()); } else { field.setWidth(fieldWidth); } } else { field.setCaption(property.getName()); field.setWidth(fieldWidth); } fields.add(field); } return fields; }
protected void loadEditable(FieldGroup fieldGroup, FieldGroup.FieldConfig field) { if (fieldGroup.isEditable()) { MetaClass metaClass = rds.resolveCategorizedEntityClass(); MetaPropertyPath propertyPath = dynamicAttributesTools.getMetaPropertyPath(metaClass, field.getProperty()); checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass); boolean editableFromPermissions = security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()); if (!editableFromPermissions) { field.setEditable(false); } boolean visibleFromPermissions = security.isEntityAttrReadPermitted(metaClass, propertyPath.toString()); if (!visibleFromPermissions) { field.setVisible(false); } } }