/** * 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()); }
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; }
/** * 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; }
.getSystemMessages(ui.getLocale(), null);
/** * 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(); }
/** * 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(); }
/** * 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; } }
/** * 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; } }
@Override protected NumberFormat getFormat(Locale locale) { NumberFormat result = super.getFormat(UI.getCurrent().getLocale()); result.setGroupingUsed(false); return result; } });
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()); } } }
/** * 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; }
/** * @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()); } }
@Override public MNls getNls() { if (nlsBundle == null) nlsBundle = MNlsBundle.lookup(this); return nlsBundle.getNls(UI.getCurrent().getLocale()); }
/** * 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; }
/** * @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; }
/** * 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); }
/** * Default constructor. */ public KeyValidator() { super(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_INVALID_KEY_0)); }
/** * @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); }
/** * @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())); } } } }
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; } });