public abstract class AbstractHandlySearchResult
extends org.eclipse.search.ui.text.AbstractTextSearchResult
implements org.eclipse.search.ui.text.IEditorMatchAdapter, org.eclipse.search.ui.text.IFileMatchAdapter
matches
are reported against IElement
s
(or elements that can be adapted to IElement
s via a content adapter
); also supports matches that are
reported against IResource
s. Implements getEditorMatchAdapter()
and getFileMatchAdapter()
methods of AbstractTextSearchResult
by returning appropriate adapters. An updater
can be provided at construction time that will update the content of the
search result on element change events.Constructor and Description |
---|
AbstractHandlySearchResult(HandlySearchResultUpdater updater)
Constructs a new
AbstractHandlySearchResult . |
Modifier and Type | Method and Description |
---|---|
org.eclipse.search.ui.text.Match[] |
computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult result,
org.eclipse.ui.IEditorPart editor) |
org.eclipse.search.ui.text.Match[] |
computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult result,
org.eclipse.core.resources.IFile file) |
IContentAdapter |
getContentAdapter()
Returns the content adapter that defines a mapping between
IElement s and elements of this search result. |
org.eclipse.search.ui.text.IEditorMatchAdapter |
getEditorMatchAdapter() |
org.eclipse.core.resources.IFile |
getFile(java.lang.Object element) |
org.eclipse.search.ui.text.IFileMatchAdapter |
getFileMatchAdapter() |
protected abstract IInputElementProvider |
getInputElementProvider()
Returns the input element provider for this search result.
|
boolean |
isShownInEditor(org.eclipse.search.ui.text.Match match,
org.eclipse.ui.IEditorPart editor) |
addListener, addMatch, addMatches, fireChange, getActiveMatchFilters, getAllMatchFilters, getElements, getMatchCount, getMatchCount, getMatches, removeAll, removeListener, removeMatch, removeMatches, setActiveMatchFilters
public AbstractHandlySearchResult(HandlySearchResultUpdater updater)
AbstractHandlySearchResult
.updater
- a search result updater, or null
if updating is not desiredpublic boolean isShownInEditor(org.eclipse.search.ui.text.Match match, org.eclipse.ui.IEditorPart editor)
If the match element is not an IResource
and could be adapted
to an IElement
through the content
adapter
, this implementation uses the input element provider
to determine the corresponding IElement
for the editor input and, if there is such an input IElement
,
returns true
if and only if the input element contains
the adapter element.
Otherwise, this implementation returns true
if and only
if the corresponding IResource
(if any) for the match element
equals the resource corresponding
to the editor input. The corresponding resource for
the match element is determined as follows:
IResource
, the corresponding resource
is the element itself.
IElement
through the content adapter
, the corresponding
resource is obtained via Elements.getResource(IElement)
.
isShownInEditor
in interface org.eclipse.search.ui.text.IEditorMatchAdapter
public org.eclipse.search.ui.text.Match[] computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult result, org.eclipse.ui.IEditorPart editor)
If the editor input could be adapted to an IFile
,
this implementation collects all matches reported against the
file, as returned by AbstractTextSearchResult.getMatches(Object)
. In addition,
this implementation uses the input
element provider
to determine the corresponding IElement
for
the editor input and collects all matches reported against elements
that correspond to the IElement
and any of its descendant
elements (the corresponding elements are determined via the
getCorrespondingElement(IElement)
method of the content adapter
).
computeContainedMatches
in interface org.eclipse.search.ui.text.IEditorMatchAdapter
public org.eclipse.search.ui.text.Match[] computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult result, org.eclipse.core.resources.IFile file)
This implementation collects all matches reported against the given
file itself, as returned by AbstractTextSearchResult.getMatches(Object)
. In addition,
this implementation uses the input
element provider
to determine the corresponding IElement
for
the given file and collects all matches reported against elements that
correspond to the IElement
and any of its descendant
elements (the corresponding elements are determined via the
getCorrespondingElement(IElement)
method of the content adapter
).
computeContainedMatches
in interface org.eclipse.search.ui.text.IFileMatchAdapter
public org.eclipse.core.resources.IFile getFile(java.lang.Object element)
If the given element has a corresponding resource that is an IFile
, this implementation returns the file. The corresponding resource
is determined as follows:
IResource
, the corresponding resource
is the element itself.
IElement
through the content adapter
, the corresponding
resource is obtained via Elements.getResource(IElement)
.
getFile
in interface org.eclipse.search.ui.text.IFileMatchAdapter
public org.eclipse.search.ui.text.IEditorMatchAdapter getEditorMatchAdapter()
This implementation returns this search result, which implements
IEditorMatchAdapter
.
getEditorMatchAdapter
in class org.eclipse.search.ui.text.AbstractTextSearchResult
public org.eclipse.search.ui.text.IFileMatchAdapter getFileMatchAdapter()
This implementation returns this search result, which implements
IFileMatchAdapter
.
getFileMatchAdapter
in class org.eclipse.search.ui.text.AbstractTextSearchResult
public IContentAdapter getContentAdapter()
IElement
s and elements of this search result.
Default implementation returns a NullContentAdapter
.
Subclasses may override.
IContentAdapter
(never null
)protected abstract IInputElementProvider getInputElementProvider()
Copyright (c) 2014, 2019 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0