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 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
ConstructorsConstructorDescriptionBaseSearchLabelProvider
(org.eclipse.search.ui.text.AbstractTextSearchViewPage page) Creates a new label provider for the given search result page. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
org.eclipse.swt.graphics.Color
getBackground
(Object element) Provides a background color for the given element.org.eclipse.jface.viewers.StyledString
getColoredLabelWithCounts
(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
(Object element) Provides a foreground color for the given element.getLabelWithCounts
(Object element, 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
-
Constructor Details
-
BaseSearchLabelProvider
public BaseSearchLabelProvider(org.eclipse.search.ui.text.AbstractTextSearchViewPage page) Creates a new label provider for the given search result page.- Parameters:
page
- notnull
-
-
Method Details
-
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
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
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
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(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.
-