Package org.eclipse.emf.common.util
Class DelegatingResourceLocator
java.lang.Object
org.eclipse.emf.common.util.DelegatingResourceLocator
- All Implemented Interfaces:
ResourceLocator
- Direct Known Subclasses:
EMFPlugin
An abstract resource locator implementation
comprising a
primary locator
and a series delegate locators.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected URLThe cached base URL.protected StringThe default localization properties file.A cache of the image descriptions.protected ResourceBundleThe resource bundle containing translated strings.protected booleanWhether to translate strings by default.A cache of the translated strings.protected ResourceBundleThe resource bundle containing untranslated strings.A cache of the untranslated strings. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdelegatedGetImage(String key) Does the work of fetching the image associated with the key, when the image resource is not available locally.protected StringdelegatedGetString(String key, boolean translate) Does the work of fetching the string associated with the key, when the string resource is not available locally.protected ObjectdoGetImage(String key) Does the work of fetching the image associated with the key.protected StringdoGetString(String key, boolean translate) Does the work of fetching the string associated with the key.protected static StringextensionFor(String key) Computes the file extension to be used with the key to specify an image resource.Returns the URL from which all resources are based.protected StringgetBundleLocalization(URL manifestURL) protected abstract ResourceLocator[]Returns the delegate resource locators.Returns the description that can be used to create the image resource associated with the key.protected abstract ResourceLocatorReturns the primary resource locator.Returns the string resource associated with the key.Returns the string resource associated with the key.Returns a string resource associated with the key, and performs substitutions.Returns a string resource associated with the key, and performs substitutions.voidsetShouldTranslate(boolean shouldTranslate) Sets whether strings should be translated by default.booleanIndicates whether strings should be translated by default.
-
Field Details
-
baseURL
The cached base URL. -
untranslatedResourceBundle
The resource bundle containing untranslated strings. -
resourceBundle
The resource bundle containing translated strings. -
strings
A cache of the translated strings. -
untranslatedStrings
A cache of the untranslated strings. -
images
A cache of the image descriptions. -
shouldTranslate
protected boolean shouldTranslateWhether to translate strings by default. -
bundleLocalization
The default localization properties file.- Since:
- 2.14
-
-
Constructor Details
-
DelegatingResourceLocator
public DelegatingResourceLocator()Creates an instance.
-
-
Method Details
-
getPrimaryResourceLocator
Returns the primary resource locator.- Returns:
- the primary resource locator.
-
getDelegateResourceLocators
Returns the delegate resource locators.- Returns:
- the delegate resource locators.
-
getBaseURL
Description copied from interface:ResourceLocatorReturns the URL from which all resources are based.- Specified by:
getBaseURLin interfaceResourceLocator- Returns:
- the URL from which all resources are based.
-
getBundleLocalization
- Throws:
IOException- Since:
- 2.14
-
getImage
Description copied from interface:ResourceLocatorReturns the description that can be used to create the image resource associated with the key. The description will typically be in the form of a URL to the image data. Creation of an actual image depends on the GUI environment; within Eclipse, org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry can be used.- Specified by:
getImagein interfaceResourceLocator- Parameters:
key- the key of the image resource.- Returns:
- the description on the image resource.
-
doGetImage
Does the work of fetching the image associated with the key. It ensures that the image exists.- Parameters:
key- the key of the image to fetch.- Returns:
- the description of the image associated with the key.
- Throws:
IOException- if an image doesn't exist.
-
extensionFor
Computes the file extension to be used with the key to specify an image resource.- Parameters:
key- the key for the imagine.- Returns:
- the file extension to be used with the key to specify an image resource.
-
delegatedGetImage
Does the work of fetching the image associated with the key, when the image resource is not available locally.- Parameters:
key- the key of the image to fetch.- Throws:
MissingResourceException- if the image resource doesn't exist anywhere.- See Also:
-
shouldTranslate
public boolean shouldTranslate()Indicates whether strings should be translated by default.- Returns:
trueif strings should be translated by default;falseotherwise.
-
setShouldTranslate
public void setShouldTranslate(boolean shouldTranslate) Sets whether strings should be translated by default.- Parameters:
shouldTranslate- whether strings should be translated by default.
-
getString
Description copied from interface:ResourceLocatorReturns the string resource associated with the key.- Specified by:
getStringin interfaceResourceLocator- Parameters:
key- the key of the string resource.- Returns:
- the string resource associated with the key.
-
getString
Description copied from interface:ResourceLocatorReturns the string resource associated with the key.- Specified by:
getStringin interfaceResourceLocator- Parameters:
key- the key of the string resource.translate- whether the result is to be translated to the current locale.- Returns:
- the string resource associated with the key.
-
doGetString
Does the work of fetching the string associated with the key. It ensures that the string exists.- Parameters:
key- the key of the string to fetch.- Returns:
- the string associated with the key.
- Throws:
MissingResourceException- if a string doesn't exist.
-
delegatedGetString
Does the work of fetching the string associated with the key, when the string resource is not available locally.- Parameters:
key- the key of the string to fetch.- Throws:
MissingResourceException- if the string resource doesn't exist anywhere.- See Also:
-
getString
Description copied from interface:ResourceLocatorReturns a string resource associated with the key, and performs substitutions.- Specified by:
getStringin interfaceResourceLocator- Parameters:
key- the key of the string.substitutions- the message substitutions.- Returns:
- a string resource associated with the key.
- See Also:
-
getString
Description copied from interface:ResourceLocatorReturns a string resource associated with the key, and performs substitutions.- Specified by:
getStringin interfaceResourceLocator- Parameters:
key- the key of the string.substitutions- the message substitutions.translate- whether the result is to be translated to the current locale.- Returns:
- a string resource associated with the key.
- See Also:
-