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 static java.lang.String
DEFAULT
static int
DIALOG_RESOURCE
static java.lang.String
EXTENSION
static int
METAMODEL_RESOURCE
static int
PROPERTY_RESOURCE
static java.lang.String[]
RESOURCES_CLASS_NAMES
-
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.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.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.static java.lang.String
getStringOrElse(java.lang.String key, java.lang.String bundleName, java.lang.ClassLoader loader, java.util.function.Supplier<java.lang.String> alternative)
Get string according to key and bundle id.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
-
RESOURCES_CLASS_NAMES
public static final java.lang.String[] RESOURCES_CLASS_NAMES
-
-
Method Detail
-
getMetaModelResource
public static java.lang.String getMetaModelResource(java.lang.Class type)
Returns meta model resource.
-
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.
-
getStringOrElse
public static java.lang.String getStringOrElse(java.lang.String key, java.lang.String bundleName, @CheckForNull java.lang.ClassLoader loader, java.util.function.Supplier<java.lang.String> alternative)
Get string according to key and bundle id. If there is no such - returns alternative from the passed in supplier.- Parameters:
key
- Key to fetch stringbundleName
- Bundle nameloader
- loader to load resourcesalternative
- result to be returned in case key or bundle is not found- Returns:
- String for key from given bundle, or alternative if the key or bundle is not found
-
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)
-
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()
-
createAvailableLanguages
public static void createAvailableLanguages()
Creates Available language.
-
createAvailableClassPropertyLanguages
public static void createAvailableClassPropertyLanguages()
Creates available languages list. Check only by "MenuResource" keyword
-
-