use of io.jmix.dynattr.MsgBundleTools in project jmix by jmix-framework.
the class DynamicAttributesCondition method getLocCaption.
@Override
public String getLocCaption() {
if (isBlank(caption) && !isBlank(propertyPath)) {
MessageTools messageTools = AppBeans.get(MessageTools.class);
String propertyCaption = messageTools.getPropertyCaption(metaClass, propertyPath);
if (!isBlank(propertyCaption)) {
return propertyCaption + "." + locCaption;
}
} else if (isNotBlank(caption)) {
MessageTools messageTools = AppBeans.get(MessageTools.class);
return messageTools.loadString(messagesPack, caption);
}
DynAttrMetadata dynamicModelMetadata = AppBeans.get(DynAttrMetadata.class);
AttributeDefinition attribute = dynamicModelMetadata.getAttributes(metaClass).stream().filter(attr -> Objects.equals(EntityValues.getId(attr.getSource()), getCategoryAttributeId())).findFirst().orElse(null);
if (attribute != null) {
MsgBundleTools msgBundleTools = AppBeans.get(MsgBundleTools.class);
return msgBundleTools.getLocalizedValue(attribute.getNameMsgBundle(), attribute.getName());
}
return super.getLocCaption();
}
Aggregations