com.vaadin.ui.UI.getLocale()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(192)

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

UI.getLocale介绍

[英]* Gets the locale for this UI.
[中]*获取此UI的区域设置。

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Called after the UI is added to the session. A UI instance is attached
 * exactly once, before its {@link #init(VaadinRequest) init} method is
 * called.
 *
 * @see Component#attach
 */
@Override
public void attach() {
  super.attach();
  getLocaleService().addLocale(getLocale());
}

代码示例来源:origin: com.vaadin/vaadin-server

private Locale findLocale() {
  Locale l = null;
  if (component != null) {
    l = component.getLocale();
  }
  if (l == null && UI.getCurrent() != null) {
    l = UI.getCurrent().getLocale();
  }
  if (l == null) {
    l = Locale.getDefault();
  }
  return l;
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Finds an appropriate locale to be used in conversion and validation.
 *
 * @return the found locale, not null
 */
protected Locale findLocale() {
  Locale l = null;
  if (getField() instanceof Component) {
    l = ((Component) getField()).getLocale();
  }
  if (l == null && UI.getCurrent() != null) {
    l = UI.getCurrent().getLocale();
  }
  if (l == null) {
    l = Locale.getDefault();
  }
  return l;
}

代码示例来源:origin: com.vaadin/vaadin-server

.getSystemMessages(ui.getLocale(), null);

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

/**
 * Gets the locale of the current Vaadin UI. If the locale can not be
 * determined, the default locale is returned instead.
 *
 * @return the current locale, never {@code null}.
 * @see com.vaadin.ui.UI#getLocale()
 * @see java.util.Locale#getDefault()
 */
public static Locale getLocale() {
  final UI currentUI = UI.getCurrent();
  return currentUI == null ? Locale.getDefault() : currentUI.getLocale();
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Gets the locale of the current Vaadin UI. If the locale can not be
 * determined, the default locale is returned instead.
 *
 * @return the current locale, never {@code null}.
 * @see com.vaadin.ui.UI#getLocale()
 * @see java.util.Locale#getDefault()
 */
public static Locale getLocale() {
  final UI currentUI = UI.getCurrent();
  return currentUI == null ? Locale.getDefault() : currentUI.getLocale();
}

代码示例来源:origin: peholmst/vaadin4spring

/**
   * Gets the locale of the current Vaadin UI. If the locale can not be determinted, the default locale
   * is returned instead.
   *
   * @return the current locale, never {@code null}.
   * @see com.vaadin.ui.UI#getLocale()
   * @see java.util.Locale#getDefault()
   */
  public Locale getLocale() {
    UI currentUI = UI.getCurrent();
    Locale locale = currentUI == null ? null : currentUI.getLocale();
    if (locale == null) {
      locale = Locale.getDefault();
    }
    return locale;
  }
}

代码示例来源:origin: org.vaadin.spring/spring-vaadin-i18n

/**
   * Gets the locale of the current Vaadin UI. If the locale can not be determinted, the default locale
   * is returned instead.
   *
   * @return the current locale, never {@code null}.
   * @see com.vaadin.ui.UI#getLocale()
   * @see java.util.Locale#getDefault()
   */
  public Locale getLocale() {
    UI currentUI = UI.getCurrent();
    Locale locale = (currentUI == null ? null : currentUI.getLocale());
    if (locale == null) {
      locale = Locale.getDefault();
    }
    return locale;
  }
}

代码示例来源:origin: tepi/FilteringTable

@Override
  protected NumberFormat getFormat(Locale locale) {
    NumberFormat result = super.getFormat(UI.getCurrent().getLocale());
    result.setGroupingUsed(false);
    return result;
  }
});

代码示例来源:origin: viritin/viritin

private void recursiveSetLocale() {
  Stack<Component> stack = new Stack<>();
  stack.addAll(VaadinSession.getCurrent().getUIs());
  while (!stack.isEmpty()) {
    Component component = stack.pop();
    if (component instanceof HasComponents) {
      for (Iterator<Component> i = ((HasComponents) component)
          .iterator(); i.hasNext();) {
        stack.add(i.next());
      }
    }
    if (component instanceof AbstractComponent) {
      AbstractComponent abstractComponent = (AbstractComponent) component;
      abstractComponent.setLocale(UI.getCurrent().getLocale());
    }
  }
}

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

/**
 * Get the most suitable {@link Locale} to use.
 * @return the field, UI or {@link LocalizationContext} locale
 */
protected Locale findLocale() {
  Locale locale = getLocale();
  if (locale == null && UI.getCurrent() != null) {
    locale = UI.getCurrent().getLocale();
  }
  if (locale == null) {
    locale = LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap(l -> l.getLocale())
        .orElse(Locale.getDefault());
  }
  return locale;
}

代码示例来源:origin: org.opencms/opencms-core

/**
   * @see org.opencms.ui.apps.I_CmsAppButtonProvider#createAppButton(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration)
   */
  public Component createAppButton(I_CmsWorkplaceAppConfiguration appConfig) {

    return createAppButton(A_CmsUI.getCmsObject(), appConfig, UI.getCurrent().getLocale());
  }
}

代码示例来源:origin: de.mhus.lib/mhu-lib-vaadin

@Override
public MNls getNls() {
  if (nlsBundle == null)
    nlsBundle = MNlsBundle.lookup(this);
  return nlsBundle.getNls(UI.getCurrent().getLocale());
}

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

/**
 * Get the most suitable {@link Locale} to use.
 * @return the field, UI or {@link LocalizationContext} locale
 */
protected Locale findLocale() {
  Locale locale = getLocale();
  if (locale == null && UI.getCurrent() != null) {
    locale = UI.getCurrent().getLocale();
  }
  if (locale == null) {
    locale = LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap(l -> l.getLocale())
        .orElse(Locale.getDefault());
  }
  return locale;
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.tepi.filtertable.FilterDecorator#getAllItemsVisibleString()
 */
public String getAllItemsVisibleString() {
  try {
    return Messages.get().getBundle(UI.getCurrent().getLocale()).getString(Messages.GUI_FILTER_SHOW_ALL);
  } catch (CmsMessageException e) {
    LOG.error(e.getLocalizedMessage(), e);
  }
  return null;
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Returns the workplace message to the given key using the current users workplace locale.<p>
 *
 * @param key the key
 *
 * @return the message
 */
protected String getWorkplaceMessage(String key) {
  CmsWorkplaceMessages messages = OpenCms.getWorkplaceManager().getMessages(UI.getCurrent().getLocale());
  return messages.key(key);
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Default constructor.
 */
public KeyValidator() {
  super(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_INVALID_KEY_0));
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.opencms.ui.I_CmsAppView#enter(java.lang.String)
 */
public void enter(String newState) {
  if (newState.startsWith(NavigationState.PARAM_SEPARATOR)) {
    newState = newState.substring(1);
  }
  if ((m_appLayout != null) && (m_appConfig != null)) {
    m_appLayout.setAppTitle(m_appConfig.getName(UI.getCurrent().getLocale()));
  }
  m_app.onStateChange(newState);
  if (m_app instanceof I_CmsHasShortcutActions) {
    m_appActions = ((I_CmsHasShortcutActions)m_app).getShortcutActions();
  }
  UI.getCurrent().addActionHandler(this);
}

代码示例来源:origin: org.opencms/opencms-core

/**
   * @see com.vaadin.data.Validator#validate(java.lang.Object)
   */
  public void validate(Object value) throws InvalidValueException {
    if (m_fieldOU.isEnabled() && CmsStringUtil.isNotEmptyOrWhitespaceOnly((String)value)) {
      try {
        OpenCms.getOrgUnitManager().readOrganizationalUnit(A_CmsUI.getCmsObject(), (String)value);
      } catch (CmsException e) {
        throw new InvalidValueException(e.getLocalizedMessage(UI.getCurrent().getLocale()));
      }
    }
  }
}

代码示例来源:origin: org.opencms/opencms-core

public Component getPopupComponent() {
    CmsObject cms = A_CmsUI.getCmsObject();
    Locale locale = UI.getCurrent().getLocale();
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    layout.addStyleName(OpenCmsTheme.QUICK_LAUNCH);
    //    layout.setSpacing(true);
    layout.setMargin(true);
    for (I_CmsWorkplaceAppConfiguration config : OpenCms.getWorkplaceAppManager().getQuickLaunchConfigurations(
      cms)) {
      layout.addComponent(CmsDefaultAppButtonProvider.createAppButton(cms, config, locale));
    }
    return layout;
  }
});

相关文章