Class ResourceManager


  • @OpenApiAll
    public class ResourceManager
    extends java.lang.Object
    This class is used to retrieve the resources from the resource bundle files
    • Field Detail

      • DialogResourceResourceFileName

        private static final java.lang.String DialogResourceResourceFileName
        See Also:
        Constant Field Values
      • PropertyResourceFileName

        private static final java.lang.String PropertyResourceFileName
        See Also:
        Constant Field Values
      • MetamodelResourceFileName

        private static final java.lang.String MetamodelResourceFileName
        See Also:
        Constant Field Values
      • RESOURCES_CLASS_NAMES

        public static final java.lang.String[] RESOURCES_CLASS_NAMES
      • resources

        private static final java.util.Map resources
      • availableLanguages

        private static java.util.Set<java.lang.String> availableLanguages
      • resourcesClassLoader

        private static java.lang.ClassLoader resourcesClassLoader
      • localeInfo

        private static LocaleInfo localeInfo
      • alreadyDisplay

        private static final java.util.Collection<java.lang.String> alreadyDisplay
    • Constructor Detail

      • ResourceManager

        public ResourceManager()
    • Method Detail

      • getMetaModelResource

        public static java.lang.String getMetaModelResource​(java.lang.Class type)
        Returns meta model resource.
      • getResourcesClassLoader

        private static java.lang.ClassLoader getResourcesClassLoader()
      • getMetaModelResource

        public static java.lang.String getMetaModelResource​(MDElement presentationElement)
        Returns meta model resource.
      • getMetaModelResource

        public static java.lang.String getMetaModelResource​(javax.jmi.reflect.RefObject element)
        Returns meta model resource.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    int bundle)
        Get string according to key and bundle id. If there are no such - returns key.
        Parameters:
        key - Key to fetch string
        bundle - Bundle ID
        Returns:
        String for key from given bundle.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    java.lang.String bundleName,
                                                    @CheckForNull
                                                    java.lang.ClassLoader loader)
        Get string according to key and bundle id. If there are no such - returns key.
        Parameters:
        key - Key to fetch string
        bundleName - Bundle name
        loader - loader to load resources
        Returns:
        String for key from given bundle.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    int bundle,
                                                    java.lang.String messageArguments)
        Get string according to key and bundle id. If there are no such - returns key. Can retrieve customizable message bundles.
        Parameters:
        key - Key to fetch string
        bundle - Bundle ID
        messageArguments - Set of the message bundle arguments.
        Returns:
        String for key from given bundle.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    int bundle,
                                                    @CheckForNull
                                                    java.lang.Object[] messageArguments)
        Get string according to key and bundle id. If there are no such - returns key. Can retrieve customizable message bundles.
        Parameters:
        key - Key to fetch string
        bundle - Bundle id
        messageArguments - Set of the message bundle arguments.
        Returns:
        String for key from given bundle.
      • formatMessage

        public static java.lang.String formatMessage​(java.lang.String message,
                                                     java.lang.String... arguments)
      • formatMessage

        public static java.lang.String formatMessage​(java.lang.Object[] messageArguments,
                                                     java.lang.String message)
      • getStringFor_

        private static java.lang.String getStringFor_​(java.lang.String key,
                                                      java.lang.String bundle,
                                                      @CheckForNull
                                                      java.lang.ClassLoader loader)
      • initBundle

        @CheckForNull
        private static java.util.ResourceBundle initBundle​(@CheckForNull
                                                           java.lang.ClassLoader loader,
                                                           java.lang.String bundle,
                                                           java.util.Locale locale)
      • createResourceBundle

        private static java.util.ResourceBundle createResourceBundle​(java.lang.String bundleName,
                                                                     java.util.Locale locale,
                                                                     @CheckForNull
                                                                     java.lang.ClassLoader loader)
      • getResourceNameFromID

        private static java.lang.String getResourceNameFromID​(int index)
      • getLocale

        public static java.util.Locale getLocale()
        Gets set locale. If there are no such - creates default.
        Returns:
        locale, which is used for bundles
      • getLocaleInfo

        public static LocaleInfo getLocaleInfo()
      • setLocale

        public static void setLocale​(java.util.Locale locale)
      • setLocale

        public static void setLocale​(LocaleInfo localeInfo)
        Sets locale. This operation is called only when is read environment options
        Parameters:
        localeInfo - Bundles will be choose according this locale
      • getAvailableLanguages

        public static java.util.Set<java.lang.String> getAvailableLanguages()
      • createAvailablePropertyResourceLanguages

        private static void createAvailablePropertyResourceLanguages()
        Creates available languages list. Check all files if at least one bundle defined for language language will be added to available list.
      • createAvailableLanguages

        public static void createAvailableLanguages()
        Creates Available language.
      • createAvailableClassPropertyLanguages

        public static void createAvailableClassPropertyLanguages()
        Creates available languages list. Check only by "MenuResource" keyword
      • getResourceFileNames

        @CheckForNull
        private static java.util.List<java.lang.String> getResourceFileNames()
        Checks for languages. First check in com/nomagic/magicdraw/resources - if there are no, check lib/resources.jar
        Returns:
        List of all files in resource directory. If no such - return null.