public class BaseSearchLabelProvider
extends org.eclipse.jface.viewers.BaseLabelProvider
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 and Description |
---|
BaseSearchLabelProvider(org.eclipse.search.ui.text.AbstractTextSearchViewPage page)
Creates a new label provider for the given search result page.
|
Modifier and Type | Method and 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.
|
addListener, fireLabelProviderChanged, isLabelProperty, removeListener
public BaseSearchLabelProvider(org.eclipse.search.ui.text.AbstractTextSearchViewPage page)
page
- not null
public void dispose()
dispose
in interface org.eclipse.jface.viewers.IBaseLabelProvider
dispose
in class org.eclipse.jface.viewers.BaseLabelProvider
public org.eclipse.search.ui.text.AbstractTextSearchViewPage getPage()
null
)public org.eclipse.swt.graphics.Color getForeground(java.lang.Object 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.
element
- the elementnull
to use the default foreground colorpublic org.eclipse.swt.graphics.Color getBackground(java.lang.Object element)
Default implementation returns null
.
element
- the elementnull
to use the default background colorpublic java.lang.String getLabelWithCounts(java.lang.Object element, java.lang.String elementName)
Default implementation provides counts for both exact and potential matches (if any).
element
- not null
elementName
- not null
null
)public org.eclipse.jface.viewers.StyledString getColoredLabelWithCounts(java.lang.Object element, org.eclipse.jface.viewers.StyledString coloredName)
Default implementation delegates to getLabelWithCounts(Object,
String)
and applies StyledString.COUNTER_STYLER
to the result.
element
- not null
coloredName
- not null
null
)protected boolean isPotentialMatch(org.eclipse.search.ui.text.Match match)
Default implementation returns false
,
which effectively disables potential match support
provided in BaseSearchLabelProvider
.
To enable it, subclasses need to override this method.
match
- never null
true
if the given match is a potential match,
and false
if it is an exact match.Copyright (c) 2014, 2019 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0