Class BaseSearchLabelProvider

  • All Implemented Interfaces:
    org.eclipse.jface.viewers.IBaseLabelProvider

    public class BaseSearchLabelProvider
    extends org.eclipse.jface.viewers.BaseLabelProvider
    A base implementation of a label provider for an AbstractTextSearchViewPage. Clients are intended to extend this class and implement interfaces such as ILabelProvider, IStyledLabelProvider, IColorProvider by using methods provided in the base implementation. For potential match support, subclasses need to override isPotentialMatch(Match).
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseSearchLabelProvider​(org.eclipse.search.ui.text.AbstractTextSearchViewPage page)
      Creates a new label provider for the given search result page.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()  
      org.eclipse.swt.graphics.Color getBackground​(java.lang.Object element)
      Provides a background color for the given element.
      org.eclipse.jface.viewers.StyledString getColoredLabelWithCounts​(java.lang.Object element, org.eclipse.jface.viewers.StyledString coloredName)
      Decorates the given styled string with the match count information for the given element.
      org.eclipse.swt.graphics.Color getForeground​(java.lang.Object element)
      Provides a foreground color for the given element.
      java.lang.String getLabelWithCounts​(java.lang.Object element, java.lang.String elementName)
      Decorates the given element name with the match count information for the given element.
      org.eclipse.search.ui.text.AbstractTextSearchViewPage getPage()
      Returns the search result page passed into the constructor.
      protected boolean isPotentialMatch​(org.eclipse.search.ui.text.Match match)
      Returns whether the given match is a potential match.
      • Methods inherited from class org.eclipse.jface.viewers.BaseLabelProvider

        addListener, fireLabelProviderChanged, isLabelProperty, removeListener
      • Methods inherited from class org.eclipse.core.commands.common.EventManager

        addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseSearchLabelProvider

        public BaseSearchLabelProvider​(org.eclipse.search.ui.text.AbstractTextSearchViewPage page)
        Creates a new label provider for the given search result page.
        Parameters:
        page - not null
    • Method Detail

      • dispose

        public void dispose()
        Specified by:
        dispose in interface org.eclipse.jface.viewers.IBaseLabelProvider
        Overrides:
        dispose in class org.eclipse.jface.viewers.BaseLabelProvider
      • getPage

        public org.eclipse.search.ui.text.AbstractTextSearchViewPage getPage()
        Returns the search result page passed into the constructor.
        Returns:
        the search result page (never null)
      • getForeground

        public org.eclipse.swt.graphics.Color getForeground​(java.lang.Object element)
        Provides a foreground color for the given element.

        Default implementation returns the foreground color for potential matches as set in the search preferences if the given element has potential matches and emphasizing of potential matches is enabled in the search preferences. Otherwise, null is returned.

        Parameters:
        element - the element
        Returns:
        the foreground color for the element, or null to use the default foreground color
      • getBackground

        public org.eclipse.swt.graphics.Color getBackground​(java.lang.Object element)
        Provides a background color for the given element.

        Default implementation returns null.

        Parameters:
        element - the element
        Returns:
        the background color for the element, or null to use the default background color
      • getLabelWithCounts

        public java.lang.String getLabelWithCounts​(java.lang.Object element,
                                                   java.lang.String elementName)
        Decorates the given element name with the match count information for the given element.

        Default implementation provides counts for both exact and potential matches (if any).

        Parameters:
        element - not null
        elementName - not null
        Returns:
        the element label with match counts (never null)
      • getColoredLabelWithCounts

        public org.eclipse.jface.viewers.StyledString getColoredLabelWithCounts​(java.lang.Object element,
                                                                                org.eclipse.jface.viewers.StyledString coloredName)
        Decorates the given styled string with the match count information for the given element.

        Default implementation delegates to getLabelWithCounts(Object, String) and applies StyledString.COUNTER_STYLER to the result.

        Parameters:
        element - not null
        coloredName - not null
        Returns:
        the element label with match counts (never null)
      • isPotentialMatch

        protected boolean isPotentialMatch​(org.eclipse.search.ui.text.Match match)
        Returns whether the given match is a potential match.

        Default implementation returns false, which effectively disables potential match support provided in BaseSearchLabelProvider. To enable it, subclasses need to override this method.

        Parameters:
        match - never null
        Returns:
        true if the given match is a potential match, and false if it is an exact match.