Class DefaultCockpitLocaleService

    • Field Detail

      • PROPERTY_COCKPITNG_LOCALIZATION_LOCALES

        public static final java.lang.String PROPERTY_COCKPITNG_LOCALIZATION_LOCALES
        See Also:
        Constant Field Values
      • PROPERTY_COCKPITNG_LEGACY_WIDGET_CONFIGURATION_PERSISTENCE_ENABLED

        public static final java.lang.String PROPERTY_COCKPITNG_LEGACY_WIDGET_CONFIGURATION_PERSISTENCE_ENABLED
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultCockpitLocaleService

        public DefaultCockpitLocaleService()
    • Method Detail

      • getCurrentLocale

        public java.util.Locale getCurrentLocale()
        Description copied from interface: CockpitLocaleService
        Returns the currently active locale. You normally do not need to call this. All localized widget labels are automatically rendered using the current locale.
        Specified by:
        getCurrentLocale in interface CockpitLocaleService
        Returns:
        currently active locale
      • setCurrentLocale

        public void setCurrentLocale​(java.util.Locale locale)
        Description copied from interface: CockpitLocaleService
        Changes the current locale to the given one. After calling this you need to refresh the cockpit application (unless this is called before the application was rendered, e.g. shortly after login). You can use Executions.sendRedirect(String) with null as a parameter to re-render the application.
        Specified by:
        setCurrentLocale in interface CockpitLocaleService
        Parameters:
        locale - the locale to be set as the current one
      • executeWithLocale

        public <T> T executeWithLocale​(AbstractExecutionBody<T> executionBody,
                                       java.util.Locale locale)
        Description copied from interface: CockpitLocaleService
        Using this method you can execute code in a context of a different locale than the current one
        Specified by:
        executeWithLocale in interface CockpitLocaleService
        Parameters:
        executionBody - the execution body
        locale - the locale
        Returns:
        the result of the execution body call or null if execution is without result
      • getZKSession

        @Deprecated(since="6.7",
                    forRemoval=true)
        protected org.zkoss.zk.ui.Session getZKSession()
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 6.7 please us lookupZkSession()
      • lookupZkSession

        protected java.util.Optional<org.zkoss.zk.ui.Session> lookupZkSession()
      • getAllLocales

        public java.util.List<java.util.Locale> getAllLocales()
        Description copied from interface: CockpitLocaleService
        Returns a list of all available locales.
        Specified by:
        getAllLocales in interface CockpitLocaleService
        Returns:
        a list of all available locales
      • getAvailableDataLocales

        public java.util.List<java.util.Locale> getAvailableDataLocales​(java.lang.String principal)
        Description copied from interface: CockpitLocaleService
        Returns a collection of available data locales (both enabled and disabled) for specified principal.

        An exception of type AvailableLocaleException is thrown when an attempt to load the cockpit locales failed.

        Specified by:
        getAvailableDataLocales in interface CockpitLocaleService
        Parameters:
        principal - needed to filter available cockpit locales
        Returns:
        collection of available locales
      • toggleDataLocale

        public void toggleDataLocale​(java.util.Locale locale,
                                     java.lang.String principal)
        Description copied from interface: CockpitLocaleService
        Toggles the specified data locale. Does nothing if the locale does not exist. Toggling data locale would enable or disable it for localized editors.
        Specified by:
        toggleDataLocale in interface CockpitLocaleService
        Parameters:
        locale - to toggle
        principal - needed to filter available cockpit locales
      • isLocalePersistenceOnToggleEnabled

        protected boolean isLocalePersistenceOnToggleEnabled()
      • getEnabledDataLocales

        public java.util.List<java.util.Locale> getEnabledDataLocales​(java.lang.String principal)
        Description copied from interface: CockpitLocaleService
        Returns a collection of enabled locales for specified principal. Only enabled locales are used to render localized attributes. By disabling locale you can reduce the visible localized data.

        An exception of type AvailableLocaleException is thrown when an attempt to load the cockpit locales failed.

        Specified by:
        getEnabledDataLocales in interface CockpitLocaleService
        Parameters:
        principal - needed to filter available cockpit locales
        Returns:
        collection of enabled locales
      • getDefaultDataLocale

        public java.util.Locale getDefaultDataLocale​(java.lang.String principal)
        Description copied from interface: CockpitLocaleService
        Returns the default data locale for specified principal. A collapsed localized editor would only show the data using the default data locale.

        An exception of type AvailableLocaleException is thrown when an attempt to load the cockpit locales failed.

        Specified by:
        getDefaultDataLocale in interface CockpitLocaleService
        Parameters:
        principal - needed to filter available cockpit locales
        Returns:
        Locale
      • isDataLocaleEnabled

        public boolean isDataLocaleEnabled​(java.util.Locale locale,
                                           java.lang.String principal)
        Description copied from interface: CockpitLocaleService
        Checks if the given data locale is an active data locale for the given user.
        Specified by:
        isDataLocaleEnabled in interface CockpitLocaleService
        Parameters:
        locale - to check
        principal - needed to filter available cockpit locales
        Returns:
        true if data locale is enabled.
      • saveLocales

        protected void saveLocales​(java.util.Collection<CockpitLocale> cockpitLocale,
                                   java.lang.String principal)
      • buildContext

        protected ConfigContext buildContext​(java.lang.String principal,
                                             boolean addGroupDimension)
      • getAvailableCockpitLocales

        protected java.util.List<CockpitLocale> getAvailableCockpitLocales​(java.lang.String principal)
      • getAllCockpitLocales

        protected java.util.List<CockpitLocale> getAllCockpitLocales​(java.lang.String principal)
        Override, if your system has additional language management.
        Parameters:
        principal - user that can be used to restrict the list of available languages. Can be null.
      • setCockpitProperties

        public void setCockpitProperties​(CockpitProperties cockpitProperties)
      • setCockpitConfigurationService

        public void setCockpitConfigurationService​(CockpitConfigurationService cockpitConfigurationService)
      • setCockpitLocalesFactory

        public void setCockpitLocalesFactory​(CockpitLocalesFactory cockpitLocalesFactory)
      • reset

        public void reset()
        Description copied from interface: Resettable
        Resets the something the implementation provides.
        Specified by:
        reset in interface Resettable
      • setWidgetConfigurationContextDecoratorList

        public void setWidgetConfigurationContextDecoratorList​(java.util.List<WidgetConfigurationContextDecorator> configContextDecoratorList)
      • setAuthorityGroupService

        public void setAuthorityGroupService​(AuthorityGroupService authorityGroupService)