org.netbeans.spi.quicksearch
Interface SearchProvider
public interface SearchProvider
Main interface of Quick Search API. Implement this interface
to provide new group of results for quick search.
In order to plug into Quick Search UI and show quick search results for your
providers, implementations of SearchProvider must be registered through xml
layer in following way:
<folder name="QuickSearch">
<folder name="MyCategoryID">
<!--Attribute for localization - provide localized display name of category!-->
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.yourmodule.YourBundle"/>
<!--Attribute for command prefix - used to narrow search to this category only!-->
<attr name="command" stringvalue="p"/>
<!--Attribute for category ordering!-->
<attr name="position" intvalue="200"/>
<!--Note that multiple providers can contribute to one category!-->
<file name="org-netbeans-module2-package2-MySearchProviderImpll.instance"/>
<file name="org-netbeans-module2-package3-MySearchProviderImpl2.instance"/>
</folder>
</folder>
evaluate
void evaluate(SearchRequest request,
SearchResponse response)
- Method is called by infrastructure when search operation was requested.
Implementors should evaluate given request and fill response object with apropriate results.
Typical implementation would look like follows:
for (SearchedItem item : getAllItemsToSearchIn()) {
if (isConditionSatisfied(item, request)) {
if (!response.addResult(item.getRunnable(), item.getDisplayName(),
item.getShortcut(), item.getDisplayHint())) {
break;
}
}
}
Threading: This method can be called outside EQ thread by infrastructure.
- Parameters:
request
- Search request object that contains information what to
search for.response
- Search response object that stores search results. Note
that it's important to react to return value of SearchResponse.addResult(...)
method and stop computation if false value is returned.