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

public class LanguageLabelProvider extends LabelProvider
Simple label provider to display a full language name and icon by language code.
  • Constructor Details

    • LanguageLabelProvider

      public LanguageLabelProvider(Map<String,String> languages)
      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

      public Map<String,String> 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

      public void setLanguages(Map<String,String> languages)
      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

      public org.eclipse.swt.graphics.Image getImage(Object element)
      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 whose Object.toString() method returns language code.

      Specified by:
      getImage in interface ILabelProvider
      Overrides:
      getImage in class LabelProvider
      Returns:
      image of the language icon that is associated with the given language code
      See Also:
    • getText

      public String getText(Object element)
      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's toString string.

      Specified by:
      getText in interface ILabelProvider
      Overrides:
      getText in class LabelProvider
      Returns:
      the representation of language by the given language code