Contributing a search page

When the user selects a resource and chooses the search command, the search plug-in launches a dialog containing pages for different kinds of content searches.  These pages are contributed using the org.eclipse.search.searchPages extension point.

The markup for contributing a search page is straightforward.  The following example is the JDT plug-in's contribution of the Java search page:

<extension point="org.eclipse.search.searchPages">
   <page id="org.eclipse.jdt.ui.JavaSearchPage"
		icon="icons/full/obj16/jsearch_obj.png"
		label="%JavaSearchPage.label"
		sizeHint="460,160"
		extensions="java:90, jav:90"
		showScopeSection="true"
		canSearchEnclosingProjects="true"
		class="org.eclipse.jdt.internal.ui.search.JavaSearchPage">
	</page>
</extension>

The class that implements the search page must be specified.  This class must implement the ISearchPage nterface and typically extends DialogPage.  The label and icon that can be used to describe the search in the search dialog are also specified.  Additional parameters control the size of the page and the location of the page within the search dialog.

The extensions attribute specifies the resources on which the search page can operate.  It is formatted as a comma separated list of file extensions.  Each file extension should be followed by a numeric weight value, where 0 is the lowest weight, separated by a colon.  The weight value is a relative value used to allow the search infrastructure to find the search page most appropriate for a given resource.

If a search page can search all possible resources then "*" should be used.

Implementing the search page

The protocol for ISearchPage is simple.  Your search page must implement performAction() which is called when the Search button is pressed.  Of course, your particular search implementation depends on your plug-in's function, but it is typical to open a results viewer in this method using the NewSearchUI method activateSearchResultView().

Your plug-in is responsible for showing its results in the search result view.