public class DefaultCockpitLocaleService extends Object implements CockpitLocaleService, Resettable
CockpitLocaleService. Session locale are based on ZK Locale handling. Data Locale
are stored per principal in cockpit-configuration : 'available-locales'.| Constructor and Description |
|---|
DefaultCockpitLocaleService() |
| Modifier and Type | Method and Description |
|---|---|
protected ConfigContext |
buildContext(String principal,
boolean addGroupDimension) |
<T> T |
executeWithLocale(AbstractExecutionBody<T> executionBody,
Locale locale)
Using this method you can execute code in a context of a different locale than the current one
|
protected List<CockpitLocale> |
getAllCockpitLocales(String principal)
Override, if your system has additional language management.
|
List<Locale> |
getAllLocales()
Returns a list of all available locales.
|
protected List<CockpitLocale> |
getAvailableCockpitLocales(String principal) |
List<Locale> |
getAvailableDataLocales(String principal)
Returns a collection of available data locales (both enabled and disabled) for specified principal.
|
protected CockpitConfigurationService |
getCockpitConfigurationService() |
protected CockpitLocalesFactory |
getCockpitLocalesFactory() |
protected CockpitProperties |
getCockpitProperties() |
Locale |
getCurrentLocale()
Returns the currently active locale.
|
Locale |
getDefaultDataLocale(String principal)
Returns the default data locale for specified principal.
|
List<Locale> |
getEnabledDataLocales(String principal)
Returns a collection of enabled locales for specified principal.
|
protected org.zkoss.zk.ui.Session |
getZKSession()
Deprecated.
since 6.7 please us
lookupZkSession() |
boolean |
isDataLocaleEnabled(Locale locale,
String principal)
Checks if the given data locale is an active data locale for the given user.
|
protected Optional<org.zkoss.zk.ui.Session> |
lookupZkSession() |
void |
reset()
Resets the something the implementation provides.
|
protected void |
saveLocales(Collection<CockpitLocale> cockpitLocale,
String principal) |
void |
setAuthorityGroupService(AuthorityGroupService authorityGroupService) |
void |
setCockpitConfigurationService(CockpitConfigurationService cockpitConfigurationService) |
void |
setCockpitLocalesFactory(CockpitLocalesFactory cockpitLocalesFactory) |
void |
setCockpitProperties(CockpitProperties cockpitProperties) |
void |
setCurrentLocale(Locale locale)
Changes the current locale to the given one.
|
void |
setWidgetConfigurationContextDecoratorList(List<WidgetConfigurationContextDecorator> configContextDecoratorList) |
void |
toggleDataLocale(Locale locale,
String principal)
Toggles the specified data locale.
|
public Locale getCurrentLocale()
CockpitLocaleServicegetCurrentLocale in interface CockpitLocaleServicepublic void setCurrentLocale(Locale locale)
CockpitLocaleServiceExecutions.sendRedirect(String) with null as a parameter to re-render the application.setCurrentLocale in interface CockpitLocaleServicelocale - the locale to be set as the current onepublic <T> T executeWithLocale(AbstractExecutionBody<T> executionBody, Locale locale)
CockpitLocaleServiceexecuteWithLocale in interface CockpitLocaleServiceexecutionBody - the execution bodylocale - the locale@Deprecated protected org.zkoss.zk.ui.Session getZKSession()
lookupZkSession()protected Optional<org.zkoss.zk.ui.Session> lookupZkSession()
public List<Locale> getAllLocales()
CockpitLocaleServicegetAllLocales in interface CockpitLocaleServicepublic List<Locale> getAvailableDataLocales(String principal)
CockpitLocaleServiceAvailableLocaleException is thrown when an attempt to load the cockpit locales
failed.getAvailableDataLocales in interface CockpitLocaleServiceprincipal - needed to filter available cockpit localespublic void toggleDataLocale(Locale locale, String principal)
CockpitLocaleServicetoggleDataLocale in interface CockpitLocaleServicelocale - to toggleprincipal - needed to filter available cockpit localespublic List<Locale> getEnabledDataLocales(String principal)
CockpitLocaleServiceAvailableLocaleException is thrown when an attempt to load the cockpit locales
failed.getEnabledDataLocales in interface CockpitLocaleServiceprincipal - needed to filter available cockpit localespublic Locale getDefaultDataLocale(String principal)
CockpitLocaleServiceAvailableLocaleException is thrown when an attempt to load the cockpit locales
failed.getDefaultDataLocale in interface CockpitLocaleServiceprincipal - needed to filter available cockpit localesLocalepublic boolean isDataLocaleEnabled(Locale locale, String principal)
CockpitLocaleServiceisDataLocaleEnabled in interface CockpitLocaleServicelocale - to checkprincipal - needed to filter available cockpit localesprotected void saveLocales(Collection<CockpitLocale> cockpitLocale, String principal)
protected ConfigContext buildContext(String principal, boolean addGroupDimension)
protected List<CockpitLocale> getAvailableCockpitLocales(String principal)
protected List<CockpitLocale> getAllCockpitLocales(String principal)
principal - user that can be used to restrict the list of available languages. Can be null.protected CockpitProperties getCockpitProperties()
public void setCockpitProperties(CockpitProperties cockpitProperties)
protected CockpitConfigurationService getCockpitConfigurationService()
public void setCockpitConfigurationService(CockpitConfigurationService cockpitConfigurationService)
protected CockpitLocalesFactory getCockpitLocalesFactory()
public void setCockpitLocalesFactory(CockpitLocalesFactory cockpitLocalesFactory)
public void reset()
Resettablereset in interface Resettablepublic void setWidgetConfigurationContextDecoratorList(List<WidgetConfigurationContextDecorator> configContextDecoratorList)
public void setAuthorityGroupService(AuthorityGroupService authorityGroupService)
Copyright © 2018. All rights reserved.