blob: d97640dc9620ff366ca78314396c38ca52dcdec9 [file] [log] [blame]
<!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.&nbsp; 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.&nbsp; The following example is the JDT plug-in's contribution
of the Java search page:</p>
<pre>&lt;extension point=&quot;org.eclipse.search.searchPages&quot;&gt;
&lt;page id=&quot;org.eclipse.jdt.ui.JavaSearchPage&quot;
icon=&quot;icons/full/obj16/jsearch_obj.png&quot;
label=&quot;%JavaSearchPage.label&quot;
sizeHint=&quot;460,160&quot;
extensions=&quot;java:90, jav:90&quot;
showScopeSection=&quot;true&quot;
canSearchEnclosingProjects=&quot;true&quot;
<b>class=&quot;org.eclipse.jdt.internal.ui.search.JavaSearchPage&quot;</b>&gt;
&lt;/page&gt;
&lt;/extension&gt;
</pre>
<p>The <b>class</b> that implements the
search page must be specified.&nbsp; 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>.&nbsp;
The <b>label</b> and <b>icon</b> that can be
used to describe the search in the search dialog are also specified.&nbsp;
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.&nbsp; It is formatted as a comma
separated list of file extensions.&nbsp; Each file extension should be followed
by a numeric weight value, where 0 is the lowest weight, separated by a
colon.&nbsp; 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 &quot;*&quot; 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.&nbsp; Your search page must implement <code>performAction()</code> which
is called when the <b>Search</b> button is pressed.&nbsp; 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>