@Override public String getMessage(String pack, String key, Locale locale) { return messages.getMessage(pack, key, locale); } }
@Override public String getCaption() { return messages.getMainMessage("actions.Ok"); } });
protected String getInvalidCredentialsMessage(String login, Locale locale) { return messages.formatMessage(MSG_PACK, "LoginException.InvalidLoginOrPassword", locale, login); } }
@Override public String getMessage(@Nonnull String code, Object[] args, String defaultMessage, @Nonnull Locale locale) { if (args != null && args.length > 0) { return messages.formatMainMessage(code, args, locale); } return messages.getMainMessage(code, locale); }
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); }
@Override public void validate(Object value) throws ValidationException { if (value == null || !pattern.matcher(((String) value)).matches()) { String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'"; throw new ValidationException(String.format(msg, value != null ? value : "")); } } }
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("\">"); }
protected void initLocale() { UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.class); Locale locale = userSessionSource.getLocale(); String localeString = messages.getTools().localeToString(locale); if (!Objects.equals(localeString, component.getLocaleString())) { component.setPivotTableMessages(localeString, PivotTableLocaleHelper.getPivotTableLocaleMap(locale)); component.setLocaleString(localeString); component.setEmptyDataMessage(messages.getMainMessage("pivottable.emptyDataMessage", locale)); } }
public String getDefaultErrorMessage() { MetaClass metaClass = metadata.getClass(beanClass); return messages.formatMainMessage("validation.defaultMsg", messages.getTools().getPropertyCaption(metaClass, beanProperty)); }
protected String formatMainMessage(String key, Object... params) { return messages.formatMainMessage(key, params); }
/** * 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(); }
@Override public void validate(Object value) throws ValidationException { if (!(value instanceof String)) { String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'"; throw new ValidationException(String.format(msg, value)); } } }
@Nonnull @Override public String getMessage(@Nonnull String code, Object[] args, @Nonnull Locale locale) throws NoSuchMessageException { if (args != null && args.length > 0) { return messages.formatMainMessage(code, args, locale); } return messages.getMainMessage(code, locale); }
/** * @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)); }
protected String getDialogMessage(User user) { return messages.formatMainMessage( "toSubstitutedUser.msg", StringUtils.isBlank(user.getName()) ? user.getLogin() : user.getName() ); }
protected String getDefaultCaption() { if (messages != null) { // legacy behaviour return messages.getMessage(getClass(), id); } else { return null; } }
/** * @param temporalType a temporal type * @return default date format string for passed temporal type */ public String getDefaultDateFormat(TemporalType temporalType) { return temporalType == TemporalType.DATE ? messages.getMainMessage("dateFormat") : messages.getMainMessage("dateTimeFormat"); } }
protected String getInvalidCredentialsMessage(String login, Locale locale) { return messages.formatMessage(MSG_PACK, "LoginException.InvalidLoginOrPassword", locale, login); }
public PropertyConditionDescriptor(String name, @Nullable String caption, String messagesPack, String filterComponentName, MetaClass metaClass, String entityAlias) { super(name, filterComponentName, metaClass, entityAlias); this.caption = caption; this.messagesPack = messagesPack; Messages messages = AppBeans.get(Messages.NAME); if (!isBlank(caption)) { this.locCaption = messages.getTools().loadString(messagesPack, caption); } else { this.locCaption = FilterConditionUtils.getPropertyLocCaption(datasourceMetaClass, name); } }