Class AbstractHandlySearchResult
- All Implemented Interfaces:
org.eclipse.search.ui.ISearchResult
,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 Summary
ConstructorDescriptionConstructs a newAbstractHandlySearchResult
. -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.search.ui.text.Match[]
computeContainedMatches
(org.eclipse.search.ui.text.AbstractTextSearchResult result, org.eclipse.core.resources.IFile file) org.eclipse.search.ui.text.Match[]
computeContainedMatches
(org.eclipse.search.ui.text.AbstractTextSearchResult result, org.eclipse.ui.IEditorPart editor) Returns the content adapter that defines a mapping betweenIElement
s and elements of this search result.org.eclipse.search.ui.text.IEditorMatchAdapter
org.eclipse.core.resources.IFile
org.eclipse.search.ui.text.IFileMatchAdapter
protected abstract IInputElementProvider
Returns the input element provider for this search result.boolean
isShownInEditor
(org.eclipse.search.ui.text.Match match, org.eclipse.ui.IEditorPart editor) Methods inherited from class org.eclipse.search.ui.text.AbstractTextSearchResult
addListener, addMatch, addMatches, fireChange, getActiveMatchFilters, getAllMatchFilters, getElements, getMatchCount, getMatchCount, getMatches, getMatchSet, removeAll, removeListener, removeMatch, removeMatches, setActiveMatchFilters
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.search.ui.ISearchResult
getImageDescriptor, getLabel, getQuery, getTooltip
-
Constructor Details
-
AbstractHandlySearchResult
Constructs a newAbstractHandlySearchResult
.- Parameters:
updater
- a search result updater, ornull
if updating is not desired
-
-
Method Details
-
isShownInEditor
public 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 anIElement
through thecontent adapter
, this implementation uses theinput element provider
to determine the correspondingIElement
for the editor input and, if there is such an inputIElement
, returnstrue
if and only if the input elementcontains
the adapter element. Otherwise, this implementation returnstrue
if and only if the correspondingIResource
(if any) for the match element equals the resourcecorresponding
to the editor input. The corresponding resource for the match element is determined as follows:-
If the match element is an
IResource
, the corresponding resource is the element itself. -
Otherwise, if the match element could be adapted to an
IElement
through thecontent adapter
, the corresponding resource is obtained viaElements.getResource(IElement)
.
- Specified by:
isShownInEditor
in interfaceorg.eclipse.search.ui.text.IEditorMatchAdapter
-
If the match element is an
-
computeContainedMatches
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 byAbstractTextSearchResult.getMatches(Object)
. In addition, this implementation uses theinput element provider
to determine the correspondingIElement
for the editor input and collects all matches reported against elements that correspond to theIElement
and any of its descendant elements (the corresponding elements are determined via thegetCorrespondingElement(IElement)
method of thecontent adapter
).- Specified by:
computeContainedMatches
in interfaceorg.eclipse.search.ui.text.IEditorMatchAdapter
-
computeContainedMatches
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 theinput element provider
to determine the correspondingIElement
for the given file and collects all matches reported against elements that correspond to theIElement
and any of its descendant elements (the corresponding elements are determined via thegetCorrespondingElement(IElement)
method of thecontent adapter
).- Specified by:
computeContainedMatches
in interfaceorg.eclipse.search.ui.text.IFileMatchAdapter
-
getFile
If the given element has a corresponding resource that is an
IFile
, this implementation returns the file. The corresponding resource is determined as follows:-
If the given element is an
IResource
, the corresponding resource is the element itself. -
Otherwise, if the given element could be adapted to an
IElement
through thecontent adapter
, the corresponding resource is obtained viaElements.getResource(IElement)
.
- Specified by:
getFile
in interfaceorg.eclipse.search.ui.text.IFileMatchAdapter
-
If the given element is an
-
getEditorMatchAdapter
public org.eclipse.search.ui.text.IEditorMatchAdapter getEditorMatchAdapter()This implementation returns this search result, which implements
IEditorMatchAdapter
.- Specified by:
getEditorMatchAdapter
in classorg.eclipse.search.ui.text.AbstractTextSearchResult
-
getFileMatchAdapter
public org.eclipse.search.ui.text.IFileMatchAdapter getFileMatchAdapter()This implementation returns this search result, which implements
IFileMatchAdapter
.- Specified by:
getFileMatchAdapter
in classorg.eclipse.search.ui.text.AbstractTextSearchResult
-
getContentAdapter
Returns the content adapter that defines a mapping betweenIElement
s and elements of this search result.Default implementation returns a
NullContentAdapter
. Subclasses may override.- Returns:
- an
IContentAdapter
(nevernull
)
-
getInputElementProvider
Returns the input element provider for this search result.- Returns:
- the input element provider
-