Search in sources :

Example 1 with MsgBundleTools

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();
}
Also used : MessageTools(io.jmix.core.MessageTools) DynAttrMetadata(io.jmix.dynattr.DynAttrMetadata) MsgBundleTools(io.jmix.dynattr.MsgBundleTools) AttributeDefinition(io.jmix.dynattr.AttributeDefinition)

Aggregations

MessageTools (io.jmix.core.MessageTools)1 AttributeDefinition (io.jmix.dynattr.AttributeDefinition)1 DynAttrMetadata (io.jmix.dynattr.DynAttrMetadata)1 MsgBundleTools (io.jmix.dynattr.MsgBundleTools)1