com.haulmont.cuba.core.global.Messages.getTools()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中com.haulmont.cuba.core.global.Messages.getTools()方法的一些代码示例,展示了Messages.getTools()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Messages.getTools()方法的具体详情如下:
包路径:com.haulmont.cuba.core.global.Messages
类名称:Messages
方法名:getTools

Messages.getTools介绍

[英]Convenient access to MessageTools bean.
[中]方便地访问MessageTools bean。

代码示例

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@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 : ""));
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@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));
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected String loadResourceString(String caption) {
  return messages.getTools().loadString(messages.getMainMessagePack(), caption);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

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);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

protected Locale getCurrentLocale() {
    Locale locale;
    if (userSessionSource.checkCurrentUserSession()) {
      locale = userSessionSource.getLocale();
    } else {
      locale = messages.getTools().getDefaultLocale();
    }
    return locale;
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected Map<String, MetaClass> getEntitiesLookupFieldOptions() {
  Map<String, MetaClass> options = new TreeMap<>();
  for (MetaClass metaClass : metadata.getTools().getAllPersistentMetaClasses()) {
    if (readPermitted(metaClass)) {
      Class javaClass = metaClass.getJavaClass();
      if (Entity.class.isAssignableFrom(javaClass)) {
        options.put(messages.getTools().getEntityCaption(metaClass) + " (" + metaClass.getName() + ")", metaClass);
      }
    }
  }
  return options;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public String getDefaultErrorMessage() {
  MetaClass metaClass = metadata.getClass(beanClass);
  return messages.formatMainMessage("validation.defaultMsg",
      messages.getTools().getPropertyCaption(metaClass, beanProperty));
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected Locale getUserLocale(LocalizedCredentials credentials, User user) {
  Locale userLocale = null;
  if (credentials.isOverrideLocale()) {
    userLocale = credentials.getLocale();
  }
  if (userLocale == null) {
    if (user.getLanguage() != null) {
      userLocale = LocaleUtils.toLocale(user.getLanguage());
    } else {
      userLocale = messages.getTools().trimLocale(messages.getTools().getDefaultLocale());
    }
  }
  return userLocale;
}

代码示例来源:origin: com.haulmont.charts/charts-web

protected Locale getUserLocale() {
    return userSessionSource.checkCurrentUserSession() ?
        userSessionSource.getUserSession().getLocale() :
        messages.getTools().getDefaultLocale();
  }
}

代码示例来源:origin: com.haulmont.reports/reports-gui

protected void initMetaClassLookup() {
  Map<String, String> metaClassesOptionsMap = new TreeMap<>();
  Collection<MetaClass> classes = metadata.getSession().getClasses();
  for (MetaClass clazz : classes) {
    if (!metadata.getTools().isSystemLevel(clazz)) {
      String caption = messages.getTools().getDetailedEntityCaption(clazz);
      metaClassesOptionsMap.put(caption, clazz.getName());
    }
  }
  metaClass.setOptionsMap(metaClassesOptionsMap);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected void createLanguageLookup() {
  languageLookup = uiComponents.create(LookupField.TYPE_STRING);
  FieldGroup.FieldConfig languageLookupFc = fieldGroupRight.getFieldNN("language");
  languageLookup.setDatasource(languageLookupFc.getTargetDatasource(), languageLookupFc.getProperty());
  languageLookup.setRequired(false);
  Map<String, Locale> locales = configuration.getConfig(GlobalConfig.class).getAvailableLocales();
  Map<String, String> options = new TreeMap<>();
  for (Map.Entry<String, Locale> entry : locales.entrySet()) {
    options.put(entry.getKey(), messages.getTools().localeToString(entry.getValue()));
  }
  languageLookup.setOptionsMap(options);
  languageLookupFc.setComponent(languageLookup);
}

代码示例来源:origin: com.haulmont.charts/charts-web

protected void setupDefaults(StockChartGroup chart) {
  chart.setLanguage(messages.getTools().localeToString(userSessionSource.getLocale()));
  chart.setDataDateFormat(ChartJsonSerializationContext.DEFAULT_JS_DATE_FORMAT);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public MultiplePermissionTarget(Class entityClass, String id, String caption, String permissionValue) {
  super(id, caption);
  Metadata metadata = AppBeans.get(Metadata.class);
  Messages messages = AppBeans.get(Messages.class);
  MetaClass metaclass = metadata.getClassNN(entityClass);
  this.entityMetaClass = metaclass;
  this.entityMetaClassName = metaclass.getName();
  this.localName = messages.getTools().getEntityCaption(metaclass);
  this.entityClass = entityClass;
  this.caption = caption;
  this.permissionValue = permissionValue;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public OperationPermissionTarget(Class entityClass, String id, String caption, String permissionValue) {
  super(id, caption);
  Metadata metadata = AppBeans.get(Metadata.class);
  Messages messages = AppBeans.get(Messages.class);
  MetaClass metaclass = metadata.getClassNN(entityClass);
  this.entityMetaClass = metaclass;
  this.entityMetaClassName = metaclass.getName();
  this.localName = messages.getTools().getEntityCaption(metaclass);
  this.permissionValue = permissionValue;
  this.entityClass = entityClass;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void accept(HasValue.ValueChangeEvent e) {
  if (active) {
    Locale selectedLocale = localesSelect.getValue();
    String localeCode = messages.getTools().localeToString(selectedLocale);
    updateValues(getItem(), localeCode, (String) e.getValue());
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
protected void initNewItem(User item) {
  addDefaultRoles(item);
  item.setLanguage(messages.getTools().localeToString(userSession.getLocale()));
  initUserGroup(item);
}

代码示例来源:origin: com.haulmont.charts/charts-web

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));
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected void initEntityNameField() {
  String entityName = getItem().getEntityName();
  MetaClass metaClass = metadata.getClass(entityName);
  if (metaClass != null) {
    MessageTools messageTools = messages.getTools();
    this.entityName.setValue(messageTools.getEntityCaption(metaClass) + " (" + metaClass.getName() + ")");
  } else {
    this.entityName.setValue(entityName);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

@MetaProperty
public String getDisplayName() {
  String entityName = getLogItem().getEntity();
  String message;
  com.haulmont.chile.core.model.MetaClass metaClass = getClassFromEntityName(entityName);
  if (metaClass != null) {
    Messages messages = AppBeans.get(Messages.NAME);
    message = messages.getTools().getPropertyCaption(metaClass, getName());
  } else {
    return getName();
  }
  return (message != null ? message : getName());
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected Consumer<HasValue.ValueChangeEvent<Locale>> createLocaleSelectValueChangeListener() {
  return e -> {
    captionValueChangeListener.suspend();
    messageValueChangeListener.suspend();
    Locale selectedLocale = (Locale) e.getValue();
    String localeCode = messages.getTools().localeToString(selectedLocale);
    caption.setValue(getItem().getLocalizedCaption(localeCode));
    message.setValue(getItem().getLocalizedMessage(localeCode));
    captionValueChangeListener.resume();
    messageValueChangeListener.resume();
  };
}

相关文章