public void setRequiredControlEnabled(boolean requiredControlEnabled) { this.requiredControlEnabled = requiredControlEnabled; FieldGroup newRuntime = (FieldGroup) getComponent("runtime"); if (newRuntime != null) { for (final FieldGroup.FieldConfig field : newRuntime.getFields()) { loadRequired(newRuntime, field); } } }
@Override public void init(Map<String, Object> params) { initDatasources(params); if (StringUtils.isEmpty(fieldWidth)) { fieldWidth = DEFAULT_FIELD_WIDTH; } initCategoryField(); loadComponent(rds); }
protected FieldGroup createRuntimeFieldGroup(Datasource ds) { Component runtime = getComponent("runtime"); if (runtime != null) { remove(runtime); } FieldGroup newRuntimeFieldGroup = uiComponents.create(FieldGroup.class); newRuntimeFieldGroup.setBorderVisible(Boolean.TRUE.equals(borderVisible)); newRuntimeFieldGroup.setWidth("100%"); newRuntimeFieldGroup.setId("runtime"); newRuntimeFieldGroup.setFrame(getFrame()); add(newRuntimeFieldGroup); for (FieldGroup.FieldConfig field : newRuntimeFieldGroup.getFields()) { newRuntimeFieldGroup.removeField(field); } List<FieldGroup.FieldConfig> fields = createFieldsForAttributes(newRuntimeFieldGroup); addFieldsToFieldGroup(newRuntimeFieldGroup, fields); if (!newRuntimeFieldGroup.getFields().isEmpty()) { newRuntimeFieldGroup.setDatasource(ds); newRuntimeFieldGroup.bind(); } for (FieldGroup.FieldConfig fieldConfig : newRuntimeFieldGroup.getFields()) { loadValidators(newRuntimeFieldGroup, fieldConfig); loadRequired(newRuntimeFieldGroup, fieldConfig); loadEditable(newRuntimeFieldGroup, fieldConfig); } initFieldCaptionWidth(newRuntimeFieldGroup); return newRuntimeFieldGroup; }
public void setCategoryFieldEditable(boolean editable) { categoryField.setEditable(editable); FieldGroup newRuntime = (FieldGroup) getComponent("runtime"); if (newRuntime != null) { newRuntime.setEditable(editable); } } }
protected void initDatasources(Map<String, Object> params) { String dsId = (String) params.get("runtimeDs"); if (dsId == null) { throw new DevelopmentException("runtimeProperties initialization error: runtimeDs is not provided"); } rds = (RuntimePropsDatasource) getDsContext().get(dsId); if (rds == null) { throw new DevelopmentException( String.format("runtimeProperties initialization error: runtimeDs '%s' does not exist", dsId)); } String categoriesDsId = (String) params.get("categoriesDs"); if (categoriesDsId == null) { throw new DevelopmentException("runtimeProperties initialization error: categoriesDs is not provided"); } categoriesDs = (CollectionDatasource) getDsContext().get(categoriesDsId); if (categoriesDs == null) { throw new DevelopmentException( String.format("runtimeProperties initialization error: categoriesDs '%s' does not exist", categoriesDsId) ); } }
@SuppressWarnings("unchecked") protected void loadComponent(Datasource ds) { ds.addStateChangeListener(e -> { if (!Datasource.State.VALID.equals(e.getState())) { return; } createRuntimeFieldGroup(ds); }); }
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); } } }