| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> |
| <HEAD> |
| |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| |
| <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> |
| <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> |
| |
| <LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css"> |
| <TITLE>Contributing a search page</TITLE> |
| |
| <link rel="stylesheet" type="text/css" HREF="../book.css"> |
| </HEAD> |
| <BODY BGCOLOR="#ffffff"> |
| <H2> |
| Contributing a search page</H2> |
| |
| |
| <p>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 <a href="../reference/extension-points/org_eclipse_search_searchPages.html"><b>org.eclipse.search.searchPages</b></a> |
| extension point.</p><p>The markup for contributing a search page is |
| straightforward. The following example is the JDT plug-in's contribution |
| of the Java search page:</p> |
| <pre><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" |
| <b>class="org.eclipse.jdt.internal.ui.search.JavaSearchPage"</b>> |
| </page> |
| </extension> |
| </pre> |
| <p>The <b>class</b> that implements the |
| search page must be specified. This class must implement the <a href="../reference/api/org/eclipse/search/ui/ISearchPage.html"><b>ISearchPage</b></a> |
| nterface and typically extends <a href="../reference/api/org/eclipse/jface/dialogs/DialogPage.html"><b>DialogPage</b></a>. |
| The <b>label</b> and <b>icon</b> 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.</p> |
| <p>The <b>extensions</b> 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.</p> |
| <p>If a search page can search all possible resources then "*" should be used.</p> |
| <h3>Implementing |
| the search page</h3> |
| <p>The |
| protocol for <a href="../reference/api/org/eclipse/search/ui/ISearchPage.html"><b>ISearchPage</b></a> |
| is simple. Your search page must implement <code>performAction()</code> which |
| is called when the <b>Search</b> 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 <a href="../reference/api/org/eclipse/search/ui/NewSearchUI.html"><b>NewSearchUI</b></a> |
| method <tt>activateSearchResultView().</tt> </p> |
| <p>Your plug-in is responsible for |
| showing its results in the search result view.</p> |
| |
| </BODY> |
| </HTML> |