Package com.nomagic.magicdraw.resources
Class ResourceManager
- java.lang.Object
-
- com.nomagic.magicdraw.resources.ResourceManager
-
@OpenApiAll public class ResourceManager extends java.lang.Object
This class is used to retrieve the resources from the resource bundle files
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Collection<java.lang.String>
alreadyDisplay
private static java.util.Set<java.lang.String>
availableLanguages
private static java.lang.String
BASE_BUNDLE
static java.lang.String
DEFAULT
static int
DIALOG_RESOURCE
private static java.lang.String
DialogResourceResourceFileName
static java.lang.String
EXTENSION
private static LocaleInfo
localeInfo
static int
METAMODEL_RESOURCE
private static java.lang.String
MetamodelResourceFileName
static int
PROPERTY_RESOURCE
private static java.lang.String
PropertyResourceFileName
private static java.util.Map
resources
static java.lang.String[]
RESOURCES_CLASS_NAMES
private static java.lang.ClassLoader
resourcesClassLoader
-
Constructor Summary
Constructors Constructor Description ResourceManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
createAvailableClassPropertyLanguages()
Creates available languages list.static void
createAvailableLanguages()
Creates Available language.private static void
createAvailablePropertyResourceLanguages()
Creates available languages list.private static java.util.ResourceBundle
createResourceBundle(java.lang.String bundleName, java.util.Locale locale, java.lang.ClassLoader loader)
static java.lang.String
formatMessage(java.lang.Object[] messageArguments, java.lang.String message)
static java.lang.String
formatMessage(java.lang.String message, java.lang.String... arguments)
static java.util.Set<java.lang.String>
getAvailableLanguages()
static java.util.Locale
getLocale()
Gets set locale.static LocaleInfo
getLocaleInfo()
static java.lang.String
getMetaModelResource(MDElement presentationElement)
Returns meta model resource.static java.lang.String
getMetaModelResource(java.lang.Class type)
Returns meta model resource.static java.lang.String
getMetaModelResource(javax.jmi.reflect.RefObject element)
Returns meta model resource.private static java.util.List<java.lang.String>
getResourceFileNames()
Checks for languages.private static java.lang.String
getResourceNameFromID(int index)
private static java.lang.ClassLoader
getResourcesClassLoader()
static java.lang.String
getStringFor(java.lang.String key, int bundle)
Get string according to key and bundle id.static java.lang.String
getStringFor(java.lang.String key, int bundle, java.lang.Object[] messageArguments)
Get string according to key and bundle id.static java.lang.String
getStringFor(java.lang.String key, int bundle, java.lang.String messageArguments)
Get string according to key and bundle id.static java.lang.String
getStringFor(java.lang.String key, java.lang.String bundleName, java.lang.ClassLoader loader)
Get string according to key and bundle id.private static java.lang.String
getStringFor_(java.lang.String key, java.lang.String bundle, java.lang.ClassLoader loader)
private static java.util.ResourceBundle
initBundle(java.lang.ClassLoader loader, java.lang.String bundle, java.util.Locale locale)
static void
setLocale(LocaleInfo localeInfo)
Sets locale.static void
setLocale(java.util.Locale locale)
-
-
-
Field Detail
-
DIALOG_RESOURCE
public static final int DIALOG_RESOURCE
- See Also:
- Constant Field Values
-
PROPERTY_RESOURCE
public static final int PROPERTY_RESOURCE
- See Also:
- Constant Field Values
-
METAMODEL_RESOURCE
public static final int METAMODEL_RESOURCE
- See Also:
- Constant Field Values
-
EXTENSION
public static final java.lang.String EXTENSION
- See Also:
- Constant Field Values
-
DEFAULT
public static final java.lang.String DEFAULT
- See Also:
- Constant Field Values
-
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
-
BASE_BUNDLE
private static final java.lang.String BASE_BUNDLE
- See Also:
- Constant Field Values
-
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
-
-
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 stringbundle
- 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 stringbundleName
- Bundle nameloader
- 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 stringbundle
- Bundle IDmessageArguments
- 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 stringbundle
- Bundle idmessageArguments
- 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.
-
-