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

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

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

Messages.getMessage介绍

[英]Returns localized message.
Locale is determined by the current user session.
[中]返回本地化消息。
区域设置由当前用户会话决定。

代码示例

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

@Override
  public String getMessage(String pack, String key, Locale locale) {
    return messages.getMessage(pack, key, locale);
  }
}

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

protected String getDefaultCaption() {
  if (messages != null) {
    // legacy behaviour
    return messages.getMessage(getClass(), id);
  } else {
    return null;
  }
}

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

@Override
  public void validate(Object value) throws ValidationException {
    if (StringUtils.isNotEmpty((String) value) && !((String) value).matches(".+\\.([A-z]{0,5})"))
      throw new ValidationException(String.format(
          messages.getMessage(OutputFileNameValidator.class, "fillCorrectOutputFileNameMsg"),
          messages.getMessage(ReportWizardCreator.class, "outputFileName")));

  }
}

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

@Override
  public Object exec(List args) throws TemplateModelException {
    if (args.size() == 2)
      return messages.getMessage((String) args.get(0), (String) args.get(1));
    else if (args.size() == 1) {
      return messages.getMessage((Enum) args.get(0));
    } else
      throw new TemplateModelException("Wrong arguments");
  }
}

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

@Override
  public String getCaption() {
    Messages messages = AppBeans.get(Messages.class);
    return messages.getMessage(getClass(), "Layout.root");
  }
}

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

@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
  String msg = messages.getMessage(getClass(), "accessDenied.message");
  windowManager.showNotification(msg, Frame.NotificationType.ERROR);
}

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

public ListPrintFormAction(String id, ListComponent listComponent) {
  super(id);
  this.listComponent = listComponent;
  Messages messages = AppBeans.get(Messages.NAME);
  this.caption = messages.getMessage(ListPrintFormAction.class, "actions.Report");
  this.icon = "icons/reports-print.png";
}

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

@Override
  protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
    String msg = messages.getMessage(LuceneIndexNotFoundExceptionHandler.class, "indexNotFound.msg");
    windowManager.showNotification(msg, Frame.NotificationType.ERROR);
  }
}

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

protected Map<String, Object> getSizeUnitsValues() {
  Map<String, Object> sizeUnitsMap = new HashMap<>();
  for (SizeUnit sizeUnit : SizeUnit.values()) {
    sizeUnitsMap.put(messages.getMessage(sizeUnit), sizeUnit);
  }
  return sizeUnitsMap;
}

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

@Override
  public String getCaption() {
    if (!Strings.isNullOrEmpty(this.caption)) {
      return this.caption;
    }
    Messages messages = AppBeans.get(Messages.NAME);
    return messages.getMessage(StartProcessAction.class, "startProcess");
  }
}

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

@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
  String msg = messages.getMessage(getClass(), "noSuchScreen.message");
  windowManager.showNotification(msg,
      throwable != null ? throwable.getMessage() : null, Frame.NotificationType.ERROR);
}

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

@Override
  public String getCaption() {
    Messages messages = AppBeans.get(Messages.class);
    return messages.getMessage(getClass(), "Layout.grid");
  }
}

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

@Override
public String getCaption() {
  Messages messages = AppBeans.get(Messages.class);
  return messages.getMessage(getClass(), "Layout.css");
}

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

private String formatEnum(Enum enumValue) {
  Messages messages = AppBeans.get(Messages.class);
  GlobalConfig globalConfig = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class);
  Set<String> localizedValues = new HashSet<>();
  for (Locale locale : globalConfig.getAvailableLocales().values()) {
    localizedValues.add(messages.getMessage(enumValue, locale));
  }
  return Joiner.on(" ").join(localizedValues);
}

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

public void setMode(AggregationMode mode) {
  this.mode = mode;
  if (StringUtils.isEmpty(caption)) {
    setCaption(AppBeans.get(Messages.class).getMessage(getClass(), "AggregationMode." + mode.toString()));
  }
}

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

/**
 * Method returns the current value that should be displayed in the UI. The method takes into account the {@link #secret}
 * property value and displays a value placeholder if it should not be visible
 */
@MetaProperty
public String getDisplayedCurrentValue() {
  if (Boolean.TRUE.equals(secret) && isDatatypeMayBeHidden()) {
    return AppBeans.get(Messages.class).getMessage(AppPropertyEntity.class, "AppPropertyEntity.valueIsSecret");
  } else {
    return currentValue;
  }
}

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

/**
 * Method returns the default value that should be displayed in the UI. The method takes into account the {@link #secret}
 * property value and displays a value placeholder if it should not be visible
 */
@MetaProperty
public String getDisplayedDefaultValue() {
  if (Boolean.TRUE.equals(secret) && isDatatypeMayBeHidden()) {
    return AppBeans.get(Messages.class).getMessage(AppPropertyEntity.class, "AppPropertyEntity.valueIsSecret");
  } else {
    return defaultValue;
  }
}

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

protected Label generateLabelByPermissionVariant(PermissionVariant permissionVariant) {
    if (permissionVariant == PermissionVariant.NOTSET)
      return null;

    String labelValue = "<span class=\"role-permission-" + permissionVariant.getColor() + "\">" +
        messages.getMessage(permissionVariant) + "</span>";

    Label label = componentsFactory.createComponent(Label.class);
    label.setHtmlEnabled(true);
    label.setValue(labelValue);

    return label;
  }
}

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

protected void createJpqlDataSet(ReportData reportData, ReportRegion reportRegion, BandDefinition dataBand) {
  DataSet dataSet =  dataSetFactory.createEmptyDataSet(dataBand);
  dataSet.setName(messages.getMessage(getClass(), "dataSet"));
  dataSet.setType(DataSetType.JPQL);
  String query = new JpqlQueryBuilder(reportData, reportRegion).buildQuery();
  dataSet.setText(query);
  dataSet.setDataStore(reportData.getDataStore());
  dataBand.getDataSets().add(dataSet);
}

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

@Override
public void check(Credentials credentials, AuthenticationDetails authenticationDetails) throws LoginException {
  if (credentials instanceof AbstractClientCredentials) {
    AbstractClientCredentials clientCredentials = (AbstractClientCredentials) credentials;
    if (clientCredentials.isCheckClientPermissions()
        && clientCredentials.getClientType() == ClientType.REST_API
        && !authenticationDetails.getSession().isSpecificPermitted("cuba.restApi.enabled")) {
      throw new RestApiAccessDeniedException(messages.getMessage(MSG_PACK, "LoginException.restApiAccessDenied"));
    }
  }
}

相关文章