Class BaseEnumLabelProvider

  • All Implemented Interfaces:
    IBaseLabelProvider, ILabelProvider

    public class BaseEnumLabelProvider
    extends LabelProvider
    This class serves as a label provider, which returns localized strings for literals of EEnum enumerations. It holds a reference to an NLS instance, which, hopefully, contains fields named enum_name_literal, and returns the value of such a field in its getText(Object) method.
    • Field Detail

      • LOCALIZATION_KEY_TEMPLATE

        protected static final String LOCALIZATION_KEY_TEMPLATE
        Pattern for fields of an NLS-descendant that hold strings of enumeration literals
      • EMPTY

        protected static final String EMPTY
        The empty value to return if the object provided to getText(Object) method is not an EEnumLiteral.
    • Constructor Detail

      • BaseEnumLabelProvider

        public BaseEnumLabelProvider​(Class<? extends org.eclipse.osgi.util.NLS> messagesClass)
        Creates a Label Provider for literals of EEnum enumerations.

        Parameters:
        messagesClass - an NLS descendant containing fields named as defined by LOCALIZATION_KEY_TEMPLATE
    • Method Detail

      • getText

        public String getText​(org.eclipse.emf.ecore.EEnumLiteral literal)
        Retrieves a localized string corresponding to the provided literal from the underlying NLS descendant. If the corresponding field is not found will return the name of the absent field.
        Parameters:
        literal - the literal to find localized string for
        Returns:
        a localized string for the provided literal, if it was found. Otherwise will return the key that was used to find the string in the underlying NLS-descendant.
      • getText

        public String getText​(Enum enumValue)
        Retrieves a localized string corresponding to the provided enumValue from the underlying NLS descendant. If the corresponding field is not found will return the name of the absent field.
        Parameters:
        literal - the literal to find localized string for
        Returns:
        a localized string for the provided literal, if it was found. Otherwise will return the key that was used to find the string in the underlying NLS-descendant.