Package org.eclipse.handly.ui.search
Class BaseSearchLabelProvider
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.jface.viewers.BaseLabelProvider
-
- org.eclipse.handly.ui.search.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 anAbstractTextSearchViewPage
. Clients are intended to extend this class and implement interfaces such asILabelProvider
,IStyledLabelProvider
,IColorProvider
by using methods provided in the base implementation. For potential match support, subclasses need to overrideisPotentialMatch(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
-
-
-
-
Method Detail
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.eclipse.jface.viewers.IBaseLabelProvider
- Overrides:
dispose
in classorg.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
- notnull
elementName
- notnull
- 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 appliesStyledString.COUNTER_STYLER
to the result.- Parameters:
element
- notnull
coloredName
- notnull
- 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 inBaseSearchLabelProvider
. To enable it, subclasses need to override this method.- Parameters:
match
- nevernull
- Returns:
true
if the given match is a potential match, andfalse
if it is an exact match.
-
-