Package com.e1c.langtool.ui.common.tools
Class LanguageLabelProvider
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.viewers.BaseLabelProvider
org.eclipse.jface.viewers.LabelProvider
com.e1c.langtool.ui.common.tools.LanguageLabelProvider
- All Implemented Interfaces:
IBaseLabelProvider,ILabelProvider
Simple label provider to display a full language name and icon by language code.
-
Constructor Summary
ConstructorsConstructorDescriptionLanguageLabelProvider(Map<String, String> languages) Creates a new label provider for languages. -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.swt.graphics.ImageReturns image of the language icon that is associated with the given language code or default icon if there is not any icon associated with the given language code.Returns the map that associates language codes and names.Returns the representation of language by the given language code.voidsetLanguages(Map<String, String> languages) Sets a new map that associates language codes and names.Methods inherited from class org.eclipse.jface.viewers.LabelProvider
createImageProvider, createTextImageProvider, createTextProviderMethods inherited from class org.eclipse.jface.viewers.BaseLabelProvider
addListener, dispose, fireLabelProviderChanged, isLabelProperty, removeListenerMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jface.viewers.IBaseLabelProvider
addListener, dispose, isLabelProperty, removeListener
-
Constructor Details
-
LanguageLabelProvider
Creates a new label provider for languages. The given map defines mapping between language codes and languages names.- Parameters:
languages- the map where keys are language codes and values are language names
-
-
Method Details
-
getLanguages
Returns the map that associates language codes and names.Note this method returns unmodifiable map.
- Returns:
- the map that associates language codes and names
- See Also:
-
setLanguages
Sets a new map that associates language codes and names.- Parameters:
languages- the map where keys are language codes and values are language names
-
getImage
Returns image of the language icon that is associated with the given language code or default icon if there is not any icon associated with the given language code.Note this method calls
Object.toString()for the given element to get language code, so it can be string with language code value as well an object whoseObject.toString()method returns language code.- Specified by:
getImagein interfaceILabelProvider- Overrides:
getImagein classLabelProvider- Returns:
- image of the language icon that is associated with the given language code
- See Also:
-
getText
Returns the representation of language by the given language code.If the associated language name for the given code was found this method returns string in the following format:
Language (language_code). For example:Russian (ru). In case when there is no one language name associated with the given code it returns the element'stoStringstring.- Specified by:
getTextin interfaceILabelProvider- Overrides:
getTextin classLabelProvider- Returns:
- the representation of language by the given language code
-