Class LabelProvider

All Implemented Interfaces:
IBaseLabelProvider, ILabelProvider
Direct Known Subclasses:
ComboBoxLabelProvider, DecoratingLabelProvider, EnvironmentTab.EnvironmentVariableLabelProvider, FileEditorMappingLabelProvider, NamedHandleObjectLabelProvider, ObservableMapLabelProvider, PerspectiveLabelProvider, PreferenceLabelProvider, RefactoringHistoryLabelProvider, URLLabelProvider, WorkbenchLabelProvider, WorkbenchPartLabelProvider

public class LabelProvider extends BaseLabelProvider implements ILabelProvider
A label provider implementation which, by default, uses an element's toString value for its text and null for its image.

This class may be used as is, or subclassed to provide richer labels. Subclasses may override any of the following methods:

  • isLabelProperty
  • getImage
  • getText
  • dispose
  • Constructor Details

    • LabelProvider

      public LabelProvider()
      Creates a new label provider.
  • Method Details

    • getImage

      public Image getImage(Object element)
      The LabelProvider implementation of this ILabelProvider method returns null. Subclasses may override.
      Specified by:
      getImage in interface ILabelProvider
      Parameters:
      element - the element for which to provide the label image
      Returns:
      the image used to label the element, or null if there is no image for the given object
    • getText

      public String getText(Object element)
      The LabelProvider implementation of this ILabelProvider method returns the element's toString string. Subclasses may override.
      Specified by:
      getText in interface ILabelProvider
      Parameters:
      element - the element for which to provide the label text
      Returns:
      the text string used to label the element, or null if there is no text label for the given object
    • createTextProvider

      public static LabelProvider createTextProvider(Function<Object,String> textFunction)
      Creates a LabelProvider which implements the getText(java.lang.Object) method by calling the argument function.
      Parameters:
      textFunction - the function which returns the text
      Returns:
      The new LabelProvider
      Since:
      3.19
    • createImageProvider

      public static LabelProvider createImageProvider(Function<Object,Image> imageFunction)
      Creates a LabelProvider which implements the getImage(java.lang.Object) method by calling the argument function.
      Parameters:
      imageFunction - the function which returns the image
      Returns:
      The new LabelProvider
      Since:
      3.19
    • createTextImageProvider

      public static LabelProvider createTextImageProvider(Function<Object,String> textFunction, Function<Object,Image> imageFunction)
      Creates a LabelProvider which implements both the getText(java.lang.Object) and getImage(java.lang.Object) methods by calling the argument functions.
      Parameters:
      textFunction - the function which returns the text
      imageFunction - the function which returns the image
      Returns:
      The new LabelProvider
      Since:
      3.19