Once you've populated the ISearchResultView with your search matches, the search results viewer does the rest of the work, launching the appropriate editor and navigating to the location of the result as the user selects different matches. The search infrastructure sorts the match results by the name of the resource.
You can supply one or more customized sorters if a different sorting order is more appropriate for your search results. By providing customized sorters, you can allow the user to select an appropriate sorting order for your matches from the result view's Sort By popup menu.
Customized sorters are contributed using the org.eclipse.search.searchResultSorters extension point.
The following example shows how the JDT plug-in contributes different sorters for the Java search page results.
<extension point="org.eclipse.search.searchResultSorters"> <sorter id="org.eclipse.search.internal.ui.ElementNameSorter" pageId="org.eclipse.jdt.ui.JavaSearchPage" label="%ElementNameSorter.label" tooltip="%ElementNameSorter.tooltip" icon="icons/full/clcl16/search_sortmatch.gif" class="org.eclipse.jdt.internal.ui.search.ElementNameSorter"> </sorter> <sorter id="org.eclipse.search.internal.ui.ParentNameSorter" pageId="org.eclipse.jdt.ui.JavaSearchPage" label="%ParentNameSorter.label" tooltip="%ParentNameSorter.tooltip" icon="icons/full/clcl16/search_sortmatch.gif" class="org.eclipse.jdt.internal.ui.search.ParentNameSorter"> </sorter> ... </extension>
The class that implements the search page must be specified. The class provided should extend ViewerSorter.
The label and icon that can be used to describe the sort order in the Sort By menu are also specified. The pageId designates the search pages for which the sorter should be activated.
Specifying a pageId of "*"
will activate the sorter
for all pages.