use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class RadioButtonGroupImpl method valueBindingConnected.
@Override
protected void valueBindingConnected(ValueSource<V> valueSource) {
super.valueBindingConnected(valueSource);
if (valueSource instanceof EntityValueSource) {
DataAwareComponentsTools dataAwareComponentsTools = applicationContext.getBean(DataAwareComponentsTools.class);
dataAwareComponentsTools.setupOptions(this, (EntityValueSource) valueSource);
}
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class TableFieldFactoryImpl method applyPermissions.
protected void applyPermissions(io.jmix.ui.component.Component columnComponent) {
if (columnComponent instanceof HasValueSource && columnComponent instanceof io.jmix.ui.component.Component.Editable) {
HasValueSource component = (HasValueSource) columnComponent;
MetaPropertyPath propertyPath = ((EntityValueSource) component.getValueSource()).getMetaPropertyPath();
if (propertyPath != null) {
io.jmix.ui.component.Component.Editable editable = (io.jmix.ui.component.Component.Editable) component;
UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(propertyPath);
accessManager.applyRegisteredConstraints(attributeContext);
editable.setEditable(editable.isEditable() && attributeContext.canModify());
}
}
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class DateFieldLoader method getJavaType.
protected Class getJavaType(DateField resultComponent) {
ValueSource valueSource = resultComponent.getValueSource();
if (valueSource instanceof EntityValueSource) {
MetaProperty metaProperty = ((EntityValueSource) valueSource).getMetaPropertyPath().getMetaProperty();
return metaProperty.getRange().asDatatype().getJavaClass();
}
Datatype datatype = resultComponent.getDatatype();
return datatype == null ? Date.class : datatype.getJavaClass();
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class FormLoader method loadComponent.
protected ComponentPosition loadComponent(Element element, @Nullable String columnWidth, @Nullable Float flex) {
Component component;
if ("field".equals(element.getName())) {
component = loadField(element);
} else {
LayoutLoader loader = getLayoutLoader();
ComponentLoader childComponentLoader = loader.createComponent(element);
childComponentLoader.loadComponent();
component = childComponentLoader.getResultComponent();
}
// Set default width
String componentWidth = element.attributeValue("width");
if (Strings.isNullOrEmpty(componentWidth)) {
if (columnWidth != null) {
component.setWidth(columnWidth);
} else if (flex != null) {
component.setWidthFull();
}
}
// Set default caption
if (component instanceof HasValueSource && ((HasValueSource) component).getValueSource() instanceof EntityValueSource && component instanceof Component.HasCaption && ((Component.HasCaption) component).getCaption() == null) {
EntityValueSource valueSource = ((EntityValueSource) ((HasValueSource) component).getValueSource());
MetaPropertyPath metaPropertyPath = valueSource.getMetaPropertyPath();
String propertyName = metaPropertyPath != null ? metaPropertyPath.getMetaProperty().getName() : null;
if (metaPropertyPath != null) {
MetaClass propertyMetaClass = getMetadataTools().getPropertyEnclosingMetaClass(metaPropertyPath);
String propertyCaption = getMessageTools().getPropertyCaption(propertyMetaClass, propertyName);
((Component.HasCaption) component).setCaption(propertyCaption);
}
}
int colspan = loadSpan(element, "colspan");
int rowspan = loadSpan(element, "rowspan");
return new ComponentPosition(component, colspan, rowspan);
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class ReadOnlyScreensSupport method isEditableConsideringDataBinding.
protected boolean isEditableConsideringDataBinding(Component component, boolean editable) {
boolean shouldBeEditable = true;
if (component instanceof HasValueSource && ((HasValueSource) component).getValueSource() != null) {
ValueSource valueSource = ((HasValueSource) component).getValueSource();
shouldBeEditable = !valueSource.isReadOnly();
if (valueSource instanceof EntityValueSource && ((EntityValueSource) valueSource).isDataModelSecurityEnabled()) {
MetaPropertyPath metaPropertyPath = ((EntityValueSource) valueSource).getMetaPropertyPath();
UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(metaPropertyPath);
accessManager.applyRegisteredConstraints(attributeContext);
if (!attributeContext.canModify() || !attributeContext.canView()) {
shouldBeEditable = false;
}
}
}
return editable && shouldBeEditable;
}
Aggregations