/** * Main messages pack used by GenericUI components and application code. * <br> Set up through app property {@code cuba.messagePack} depending on the client type and set of base projects. * * <br> This method is outdated but not deprecated because it is used in lots of places. Preferred method to * obtain the main message pack is {@link com.haulmont.cuba.core.global.Messages#getMainMessagePack()}. * * <br> To obtain a message from the main message pack use {@link com.haulmont.cuba.core.global.Messages#getMainMessage(String)}. */ public static String getMessagesPack() { Messages messages = AppBeans.get(Messages.NAME); return messages.getMainMessagePack(); }
protected void appendFreeMarkerSettings(StringBuilder templateBody) { Messages messages = AppBeans.get(Messages.NAME); templateBody.append("\n<#setting boolean_format=\""). append(messages.getMessage(messages.getMainMessagePack(), "trueString")). append(","). append(messages.getMessage(messages.getMainMessagePack(), "falseString")). append("\">"); }
@Override protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) { Pattern pattern = Pattern.compile("Class> (.+)"); Matcher matcher = pattern.matcher(message); String entityClassName = ""; if (matcher.find()) { entityClassName = matcher.group(1); } String msg; if (entityClassName.contains(".")) { String entityName = entityClassName.substring(entityClassName.lastIndexOf(".") + 1); String packageName = entityClassName.substring(0, entityClassName.lastIndexOf(".")); String localizedEntityName = messages.getMessage(packageName, entityName); msg = messages.formatMessage(messages.getMainMessagePack(), "optimisticException.message", "\"" + localizedEntityName + "\""); } else { msg = messages.getMessage(messages.getMainMessagePack(), "optimisticExceptionUnknownObject.message"); } windowManager.showNotification(msg, Frame.NotificationType.ERROR); }
protected String getDefaultRequiredMessage(String name) { Messages messages = AppBeans.get(Messages.NAME); return messages.formatMessage(messages.getMainMessagePack(), "validation.required.defaultMsg", name); } }
protected String loadResourceString(String caption) { return messages.getTools().loadString(messages.getMainMessagePack(), caption); }
/** * @deprecated Use {@link #getDefaultRequiredMessage(MetaClass, String)} * @return default required message for specified property. */ @Deprecated public String getDefaultRequiredMessage(MetaProperty metaProperty) { String notNullMessage = getNotNullMessage(metaProperty); if (notNullMessage != null) { return notNullMessage; } return messages.formatMessage(messages.getMainMessagePack(), "validation.required.defaultMsg", getPropertyCaption(metaProperty)); }
/** * Get default required message for specified property of MetaClass. * * @param metaClass MetaClass containing the property * @param propertyName property's name * @return default required message for specified property of MetaClass */ public String getDefaultRequiredMessage(MetaClass metaClass, String propertyName) { MetaPropertyPath propertyPath = metaClass.getPropertyPath(propertyName); if (propertyPath != null) { String notNullMessage = getNotNullMessage(propertyPath.getMetaProperty()); if (notNullMessage != null) { return notNullMessage; } } return messages.formatMessage(messages.getMainMessagePack(), "validation.required.defaultMsg", getPropertyCaption(metaClass, propertyName)); }
switch (temporal.value()) { case DATE: dateMask = messages.getMessage(messages.getMainMessagePack(), "dateFormat"); break; case TIME: dateMask = messages.getMessage(messages.getMainMessagePack(), "timeFormat"); break; default: dateMask = messages.getMessage(messages.getMainMessagePack(), "dateTimeFormat"); dateMask = messages.getMessage(messages.getMainMessagePack(), "dateTimeFormat");