Class AbstractHandlySearchResult
- java.lang.Object
-
- org.eclipse.search.ui.text.AbstractTextSearchResult
-
- org.eclipse.handly.ui.search.AbstractHandlySearchResult
-
- All Implemented Interfaces:
org.eclipse.search.ui.ISearchResult,org.eclipse.search.ui.text.IEditorMatchAdapter,org.eclipse.search.ui.text.IFileMatchAdapter
public abstract class AbstractHandlySearchResult extends org.eclipse.search.ui.text.AbstractTextSearchResult implements org.eclipse.search.ui.text.IEditorMatchAdapter, org.eclipse.search.ui.text.IFileMatchAdapterA partial implementation of Handly-based search result. Assumes thatmatchesare reported againstIElements (or elements that can be adapted toIElements via acontent adapter); also supports matches that are reported againstIResources. ImplementsgetEditorMatchAdapter()andgetFileMatchAdapter()methods ofAbstractTextSearchResultby returning appropriate adapters. Anupdatercan be provided at construction time that will update the content of the search result on element change events.
-
-
Constructor Summary
Constructors Constructor Description AbstractHandlySearchResult(HandlySearchResultUpdater updater)Constructs a newAbstractHandlySearchResult.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.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)IContentAdaptergetContentAdapter()Returns the content adapter that defines a mapping betweenIElements and elements of this search result.org.eclipse.search.ui.text.IEditorMatchAdaptergetEditorMatchAdapter()org.eclipse.core.resources.IFilegetFile(java.lang.Object element)org.eclipse.search.ui.text.IFileMatchAdaptergetFileMatchAdapter()protected abstract IInputElementProvidergetInputElementProvider()Returns the input element provider for this search result.booleanisShownInEditor(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
-
-
-
-
Constructor Detail
-
AbstractHandlySearchResult
public AbstractHandlySearchResult(HandlySearchResultUpdater updater)
Constructs a newAbstractHandlySearchResult.- Parameters:
updater- a search result updater, ornullif updating is not desired
-
-
Method Detail
-
isShownInEditor
public boolean isShownInEditor(org.eclipse.search.ui.text.Match match, org.eclipse.ui.IEditorPart editor)If the match element is not an
IResourceand could be adapted to anIElementthrough thecontent adapter, this implementation uses theinput element providerto determine the correspondingIElementfor the editor input and, if there is such an inputIElement, returnstrueif and only if the input elementcontainsthe adapter element. Otherwise, this implementation returnstrueif and only if the correspondingIResource(if any) for the match element equals the resourcecorrespondingto 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
IElementthrough thecontent adapter, the corresponding resource is obtained viaElements.getResource(IElement).
- Specified by:
isShownInEditorin 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 providerto determine the correspondingIElementfor the editor input and collects all matches reported against elements that correspond to theIElementand any of its descendant elements (the corresponding elements are determined via thegetCorrespondingElement(IElement)method of thecontent adapter).- Specified by:
computeContainedMatchesin 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 providerto determine the correspondingIElementfor the given file and collects all matches reported against elements that correspond to theIElementand any of its descendant elements (the corresponding elements are determined via thegetCorrespondingElement(IElement)method of thecontent adapter).- Specified by:
computeContainedMatchesin interfaceorg.eclipse.search.ui.text.IFileMatchAdapter
-
getFile
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:-
If the given element is an
IResource, the corresponding resource is the element itself. -
Otherwise, if the given element could be adapted to an
IElementthrough thecontent adapter, the corresponding resource is obtained viaElements.getResource(IElement).
- Specified by:
getFilein 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:
getEditorMatchAdapterin 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:
getFileMatchAdapterin classorg.eclipse.search.ui.text.AbstractTextSearchResult
-
getContentAdapter
public IContentAdapter getContentAdapter()
Returns the content adapter that defines a mapping betweenIElements and elements of this search result.Default implementation returns a
NullContentAdapter. Subclasses may override.- Returns:
- an
IContentAdapter(nevernull)
-
getInputElementProvider
protected abstract IInputElementProvider getInputElementProvider()
Returns the input element provider for this search result.- Returns:
- the input element provider
-
-